glimmervoid 0.41.1 → 0.42.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.
Files changed (29) hide show
  1. package/dist/bin/glimmervoid.js +13 -13
  2. package/dist/chunks/{adapters-D8BJffFW.js → adapters-C8GfnK2r.js} +1 -1
  3. package/dist/chunks/{adapters-CyDflXHy.js → adapters-D2u85MEH.js} +5 -5
  4. package/dist/chunks/{agent-api-cli-CvCov9_e.js → agent-api-cli-B-1MqjKc.js} +1 -1
  5. package/dist/chunks/{agent-api-cli-B7-ToJul.js → agent-api-cli-D7JPxNso.js} +10 -5
  6. package/dist/chunks/{agent-api-core-CLxZAole.js → agent-api-core-PwO7fPoc.js} +19 -5
  7. package/dist/chunks/{agent-setup-cli-py1gUMvJ.js → agent-setup-cli-C9qDV2g5.js} +1 -1
  8. package/dist/chunks/config-store-BL8LDBuM.js +1 -0
  9. package/dist/chunks/{config-store-CxYqTNbe.js → config-store-BxCW2IwK.js} +2 -2
  10. package/dist/chunks/{contracts-C9Jj9iDo.js → contracts-LXlDbl4R.js} +2 -2
  11. package/dist/chunks/{control-messages-C6JGCTuy.js → control-messages-88sdxt-U.js} +7 -1
  12. package/dist/chunks/{git-version-D_iXgYTZ.js → git-version-DqagvnAZ.js} +1 -1
  13. package/dist/chunks/{grok-BUGgQVE3.js → grok-DwrAcNHC.js} +1 -1
  14. package/dist/chunks/{main-CRU5ahjl.js → main-DZzDU4Q4.js} +284 -95
  15. package/dist/chunks/{pair-cli-CL1D9xc7.js → pair-cli-3KKNhZ22.js} +2 -2
  16. package/dist/chunks/{remote-config-CaW0mpwr.js → remote-config-Ce5nN0zL.js} +1 -1
  17. package/dist/chunks/{session-C8IpFmGQ.js → session-3eSP3t1i.js} +8 -2
  18. package/dist/chunks/{session-routes-nySS7DUE.js → session-routes-B2oSzmQn.js} +1 -1
  19. package/dist/chunks/{settings-cli-Duculey3.js → settings-cli-BYY991YC.js} +5 -5
  20. package/dist/chunks/{settings-readout-core-CX7DmEuG.js → settings-readout-core-CWAhwZKN.js} +2 -2
  21. package/dist/chunks/{ssh-sign-cli-BEAAFjXg.js → ssh-sign-cli-BbqYIPwh.js} +2 -2
  22. package/dist/client/assets/index-C9wfiVqt.js +176 -0
  23. package/dist/client/assets/index-PnaYWtoe.css +2 -0
  24. package/dist/client/index.html +2 -2
  25. package/dist/server/index.js +1 -1
  26. package/package.json +1 -1
  27. package/dist/chunks/config-store-DcVWBJOV.js +0 -1
  28. package/dist/client/assets/index-CBjFGcSs.js +0 -176
  29. package/dist/client/assets/index-Cbb5NKHK.css +0 -2
@@ -1,176 +0,0 @@
1
- import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _}from"./zod-BRLv4KqJ.js";import{n as v,r as y,t as b}from"./xterm-kR64YvZ-.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var x=g({attempt:c().int().positive(),limit:c().int().positive()}).refine(e=>e.attempt<=e.limit),S={error:l().nullable().optional(),nextAttemptAt:c().finite().nonnegative().nullable().optional(),retry:x.nullable().optional(),isRefreshing:t().optional(),refreshNotice:l().nullable().optional()},ee=f({lastRefreshedAt:c().finite().nonnegative().nullable(),error:l().nullable()}),te=g({lane:u([`my-prs`,`team-review`,`issues`])}),C=g({ok:t(),error:l().optional(),freshness:ee.optional()}),ne=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,w=/^[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9][A-Za-z0-9._-]*$/,re=/^[A-Za-z0-9_=-]+$/;function ie(e){let t=e.split(`/`);return t.length!==2||!t.every(e=>ne.test(e))?null:[t[0],t[1]]}var ae=/^[0-9a-f]{7,40}$/i,oe=/^[0-9a-f]{40}$/;function T(e,{chars:t=7,validate:n=!1}={}){if(typeof e!=`string`||!e)return``;if(!n)return e.slice(0,t);let r=e.trim();return ae.test(r)?r.slice(0,t).toLowerCase():``}var E=l().regex(oe),se=l().regex(/^[^/]+\/[^/]+$/);g({number:c().int().positive(),title:l(),body:l(),url:l(),author:g({login:l(),is_bot:t().optional()}).passthrough(),state:u([`OPEN`,`CLOSED`,`MERGED`]).optional(),isDraft:t(),isCrossRepository:t(),baseRefName:l(),baseRefOid:E,headRefName:l().optional(),headRefOid:E,additions:c().int().nonnegative(),deletions:c().int().nonnegative(),files:p(g({path:l(),additions:c().int().nonnegative(),deletions:c().int().nonnegative()}).passthrough())}).passthrough();var D=g({path:l(),line:c().int().positive(),side:u([`RIGHT`,`LEFT`]).default(`RIGHT`),body:l()}),ce=Object.freeze({STAMP:`APPROVE`,COMMENT:`APPROVE WITH NITS`,NEEDS_YOU:`REQUEST CHANGES`}),O=u([`APPROVE`,`APPROVE WITH NITS`,`REQUEST CHANGES`,`BLOCKED`]),le=r(e=>typeof e==`string`&&Object.hasOwn(ce,e)?ce[e]:e,O),ue=u([`CRITICAL`,`HIGH`,`MEDIUM`,`LOW`]),de=D.extend({severity:ue.optional()}),fe=g({path:l().min(1),line:c().int().positive().nullable(),side:u([`RIGHT`,`LEFT`]),severity:ue,reviewer:l().min(1),disposition:u([`ACTIONABLE`,`NIT`,`AMBIGUOUS`]).nullable(),body:l().min(1)}),pe=g({goal:l().default(``),change:l(),checked:p(l()),gaps:p(l())});g({verdict:O,head:E,summary:l(),assessment:pe.nullable(),findings:p(fe)}),g({body:l(),commit_id:E,comments:p(g({path:l().min(1),line:c().int().positive(),side:u([`RIGHT`,`LEFT`]).default(`RIGHT`),body:l().min(1)}))});var me=u([`APPROVE`,`COMMENT`]),he=u([`APPROVED`,`CHANGES_REQUESTED`,`COMMENTED`]),ge=new Set([`APPROVED`,`CHANGES_REQUESTED`]),_e=u([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]),ve=u([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]),ye={requestSource:u([`direct`,`team`]).default(`team`),isDraft:t().optional(),checksState:ve.nullable().optional()},be=g({login:l().min(1),state:he,commit:E.nullable(),isViewer:t(),submittedAt:l().nullable().optional()});function xe(e,t){return e||(t.includes(`CHANGES_REQUESTED`)?`CHANGES_REQUESTED`:t.includes(`APPROVED`)?`APPROVED`:`REVIEW_REQUIRED`)}function Se(e){return e.reviewDecision!==`APPROVED`||e.requeuedHead!==void 0&&e.requeuedHead===(e.liveHead??e.reviewedHead)?!1:(e.githubReviews??[]).some(e=>e.isViewer&&e.state===`APPROVED`)}var Ce=g({head:E,base:E.optional(),verdict:O,summary:l(),body:l(),comments:p(D),wasPosted:t()}),we=Ce.pick({head:!0,verdict:!0,summary:!0,wasPosted:!0}).extend({comments:p(de)}),Te=l().min(1).max(256).regex(re),Ee=g({addressed:t(),reason:l().trim().min(1).max(4e3)}).strict(),De=g({id:Te,path:l(),line:c().int().positive().nullable(),isResolved:t(),viewerCanResolve:t(),comments:g({pageInfo:g({hasNextPage:t(),endCursor:l().nullable().optional()}),nodes:p(g({body:l(),author:g({login:l()}).nullable(),viewerDidAuthor:t(),createdAt:l().datetime(),url:l().url(),originalCommit:g({oid:E}).nullable()}))})});g({data:g({node:g({comments:De.shape.comments}).nullable()}).nullable()}),g({pullRequest:g({reviewThreads:g({pageInfo:g({hasNextPage:t(),endCursor:l().nullable().optional()}),nodes:p(De)})}).nullable()}),g({data:g({resolveReviewThread:g({thread:g({id:Te,isResolved:m(!0)})})}).nullable(),errors:p(e()).optional()});var Oe=g({id:Te,path:l(),line:c().int().positive().nullable(),isResolved:t(),viewerCanResolve:t(),isNit:t(),url:l().url(),viewerComment:l().max(1500).optional(),lastReplyBody:l().max(1500).optional(),viewerCommentTruncated:t().optional(),lastReplyTruncated:t().optional(),lastReplyAuthor:l(),lastReplyAt:l().datetime(),judgement:Ee.extend({head:E,judgedAt:c().finite(),lastReplyAt:l().datetime()}).optional(),resolveError:l().optional(),resolveAttemptReplyAt:l().optional(),judgeAttempt:g({head:E,lastReplyAt:l(),retryAt:c().finite()}).optional(),unjudgeable:g({head:E,lastReplyAt:l(),reason:l().min(1)}).optional()});g({merge_base_commit:g({sha:E}),files:p(g({filename:l(),previous_filename:l().optional(),patch:l().optional()})).max(300)});var ke=g({total:c().int().nonnegative(),resolved:c().int().nonnegative()}),Ae=g({...ye,key:l(),repo:se,number:c().int().positive(),title:l(),url:l(),author:l(),tier:u([`stamp`,`full`]),reasons:p(l()),reviewedHead:E,reviewedBase:E.optional(),verdict:le,summary:l(),assessment:pe.optional(),body:l(),comments:p(de),status:u([`ready`,`stale`,`posted`,`discarded`,`error`]),error:l().optional(),threads:p(Oe).optional(),viewerThreads:ke.optional(),githubReviews:p(be).optional(),reviewDecision:_e.nullable().optional(),liveHead:E.optional(),prCreatedAt:l().optional(),reviewedAt:c().finite().optional(),postedAt:c().finite().optional(),postedEvent:me.optional(),priorReviewedHead:E.optional(),requeuedHead:E.optional(),earlierReview:we.optional()});function je(e){return e.status===`posted`&&e.postedEvent===`COMMENT`}var Me=u([`approve`,`approve-only`,`comment`,`discard`,`requeue`,`resolve-thread`]);function Ne(e){return e.action===`discard`||e.head!==void 0}var Pe=g({key:l().min(1),head:E.optional(),action:Me,threadId:Te.optional(),body:l(),comments:p(D)}).refine(e=>e.action!==`resolve-thread`||e.threadId!==void 0,{message:`resolve-thread requires threadId`,path:[`threadId`]}).refine(Ne,{message:`only discard may omit head`,path:[`head`]}),Fe=g({key:l(),ok:t(),error:l().optional(),warning:l().optional()}),Ie=g({sessionId:l().min(1),workDir:l().min(1),worktreePath:l().min(1),head:E,deadlineAt:c(),remainingAwakeMs:c().nonnegative().optional(),savedAt:c()}),Le=g({...ye,reviewDecision:_e.nullable().optional(),key:l(),repo:se,number:c().int().positive(),title:l(),url:l(),author:l(),prCreatedAt:l().optional()}),Re=g({draft:Ae.nullable(),reviewedHead:E.nullable(),inFlight:t(),skipReason:l().nullable(),handReview:Le.optional(),reviewAttempts:c().int().nonnegative().default(0),resumable:Ie.nullable().optional(),reviewedAt:c().optional(),threads:p(Oe).optional(),viewerThreads:ke.optional(),autoResolvedThreadIds:p(Te).optional(),githubReviews:p(be).optional(),reviewDecision:_e.nullable().optional(),liveHead:E.optional(),requeuedHead:E.optional(),priorReview:Ce.optional(),discardedReviewHead:E.optional(),requestedAt:c().finite().optional(),updatedAt:c().finite()});i(l(),Re);var ze=u([`preparing`,`checkout`,`reviewing`]),Be=g({at:c().finite(),tool:l(),detail:l()}),Ve=g({...ye,reviewDecision:_e.nullable().optional(),key:l(),repo:se,number:c().int().positive(),title:l(),url:l(),author:l(),tier:u([`stamp`,`full`]),reasons:p(l()),head:E,phase:ze,startedAt:c().finite(),deadlineAt:c().finite().nullable(),toolCalls:c().int().nonnegative(),recentSteps:p(Be),prCreatedAt:l().optional(),priorReviewedHead:E.optional()}),He=g({...S,type:m(`team-review-status`),ts:c().finite(),configured:t(),reason:l().nullable().optional(),drafts:p(Ae),inFlight:p(Ve),queued:p(Le).default([]),handReview:p(Le).default([]),team:g({org:l(),slug:l(),name:l(),avatarUrl:l()}).nullable().optional()}).passthrough(),Ue=u([`merged`,`draft`,`conflicts`,`behind`,`checks-failing`,`changes-requested`,`unresolved-threads`,`checks-pending`,`needs-approval`,`ready`,`unknown`]),We=c().int().nonnegative(),Ge=l().regex(w),Ke=l().regex(/^[1-9][0-9]*$/),qe=o([Ge,`#`,Ke]),Je=o([qe,`@`,E]),Ye=l().refine(e=>qe.safeParse(e).success),Xe=l().refine(e=>Je.safeParse(e).success);d(`outcome`,[f({outcome:m(`pushed`)}),f({outcome:u([`no-change`,`failed`,`stopped`,`timed-out`]),reason:l().min(1)})]);var Ze=f({outcome:u([`pushed`,`no-change`,`failed`,`stopped`,`timed-out`]),reason:l().min(1).optional(),at:c().finite()}),Qe=Ze.extend({key:Ye,headRefOid:E,baseRefOid:E,consecutiveAttempts:c().int().min(1).optional()});f({keepMergeableKeys:p(Ye),keepMergeableAttemptKeys:p(Xe),keepMergeableAttempts:p(Qe).default([]),mergeQueueKeys:p(Ye).default([]),keepMergeablePushedHeadKeys:p(Xe).default([])});var $e=f({repo:Ge,number:c().int().positive(),url:_(),source:u([`hook`,`sha`,`manual`]),linkedAt:c().finite()}),et=f({links:p($e).max(20),unlinkedKeys:p(Ye).default([])}),tt=g({repo:Ge,number:c().int().positive(),keepMergeable:t()}),nt=g({key:l(),ok:t(),error:l().optional()}),rt=nt,it=g({repo:Ge,number:c().int().positive(),mergeWhenReady:t()}),at=nt,ot=u([`MERGE`,`SQUASH`,`REBASE`]),st=g({path:l(),line:c().int().positive().nullable(),isOutdated:t(),url:_(),author:l().nullable(),excerpt:l(),commentCount:c().int().positive(),lastAuthor:l().nullable(),lastActivityAt:l()}),ct=g({reviewer:l().nullable(),state:l(),submittedAt:l().nullable()}),lt=g({outcome:u([`rebased`,`failed`]),at:c().finite(),message:l()}),ut=g({at:c().finite(),message:l()}),k=g({key:l(),repo:Ge,number:c().int().positive(),title:l(),url:_(),isDraft:t(),state:u([`OPEN`,`MERGED`,`CLOSED`]),createdAt:l(),mergedAt:l().nullable(),updatedAt:l(),baseRefName:l(),baseRefOid:E,headRefName:l().min(1),isCrossRepository:t(),headRefOid:E,isInMergeQueue:t(),mergeMethod:ot,mergeable:u([`MERGEABLE`,`CONFLICTING`,`UNKNOWN`]),mergeStateStatus:l(),reviewDecision:u([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable(),checks:g({state:u([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable(),failing:p(l()),pendingCount:We}),unresolvedThreads:We,threads:p(st),behindBy:We.nullable(),reviewRequests:p(g({name:l(),isTeam:t(),avatarUrl:l().nullable()})),approvals:We,reviews:p(ct),stage:Ue,autoRebase:lt.optional(),keepMergeable:t().optional(),keepMergeableAttempt:Ze.optional(),isKeepMergeableFixInFlight:t().optional(),mergeQueuePosition:c().int().positive().nullable().optional(),isMergeQueueHeldForRepairPush:t().optional(),mergeQueueFailure:ut.optional()}).refine(e=>e.key===`${e.repo}#${e.number}`),dt=f({key:Ye,autoRebase:k.shape.autoRebase,keepMergeable:k.shape.keepMergeable,keepMergeableAttempt:k.shape.keepMergeableAttempt,isKeepMergeableFixInFlight:k.shape.isKeepMergeableFixInFlight,mergeQueuePosition:k.shape.mergeQueuePosition,isMergeQueueHeldForRepairPush:k.shape.isMergeQueueHeldForRepairPush,mergeQueueFailure:k.shape.mergeQueueFailure}),ft=g({...S,type:m(`my-prs-status`),ts:c().finite(),configured:t(),reason:l().nullable().optional(),viewer:l().nullable(),prs:p(dt),truncatedNote:l().nullable().optional(),isKeepMergeableEnabled:t().optional(),isMergeQueueEnabled:t().optional()}).passthrough();ft.extend({prs:p(k)});var pt=g({repo:Ge,number:c().int().positive(),headRefOid:E}),mt=u([`merged`,`queued`,`auto-merge`,`unconfirmed`]),ht=g({key:l(),ok:t(),kind:mt.optional(),error:l().optional()}),gt=g({__typename:m(`CheckRun`),name:l(),conclusion:l().nullable(),status:l(),startedAt:l().nullish(),checkSuite:g({app:g({databaseId:c().int().nullish()}).nullish(),workflowRun:g({workflow:g({databaseId:c().int().nullish()})}).nullish()}).nullish()}),_t=g({__typename:m(`StatusContext`),context:l(),state:l()}),vt=a([gt,_t]),yt=g({hasNextPage:t(),endCursor:l().nullable()}),bt=g({__typename:m(`PullRequest`),id:l().regex(re),number:c().int().positive(),title:l(),url:_(),isDraft:t(),state:u([`OPEN`,`MERGED`,`CLOSED`]),createdAt:l(),mergedAt:l().nullable(),updatedAt:l(),baseRefName:l(),baseRefOid:E,headRefName:l().min(1),isCrossRepository:t(),headRefOid:E,isInMergeQueue:t(),mergeable:u([`MERGEABLE`,`CONFLICTING`,`UNKNOWN`]),mergeStateStatus:l(),reviewDecision:u([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable(),repository:g({nameWithOwner:Ge,viewerDefaultMergeMethod:ot}),commits:g({nodes:p(g({commit:g({statusCheckRollup:g({id:l().regex(re).optional(),state:u([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable(),contexts:g({pageInfo:yt.optional(),nodes:p(vt)})}).nullable()})}))}),reviewThreads:g({pageInfo:g({hasNextPage:t()}),nodes:p(g({isResolved:t()}))}),reviewRequests:g({nodes:p(g({requestedReviewer:d(`__typename`,[g({__typename:m(`User`),login:l()}),g({__typename:m(`Team`),slug:l(),avatarUrl:l().nullable(),organization:g({login:l()})}),g({__typename:u([`Bot`,`Mannequin`])})]).nullable()}))}),latestOpinionatedReviews:g({nodes:p(g({state:l()}))}),latestReviews:g({nodes:p(g({state:l(),submittedAt:l().nullable(),author:g({login:l()}).nullable()}))})}),xt=g({login:l()}).nullable();g({isResolved:t(),isOutdated:t(),path:l(),line:c().int().positive().nullable(),firstComment:g({totalCount:We,nodes:p(g({author:xt,bodyText:l(),url:_(),createdAt:l()}))}),lastComment:g({nodes:p(g({author:xt,createdAt:l()}))})}),g({data:g({repository:g({pullRequest:g({reviewThreads:g({pageInfo:g({hasNextPage:t(),endCursor:l().nullable()}),nodes:p(e())})}).nullable()}).nullable()}),errors:p(e()).optional()}),g({data:g({node:g({contexts:g({pageInfo:yt,nodes:p(e())}).nullable()}).nullable()}).nullable(),errors:p(e()).optional()}),g({data:g({repository:g({pullRequest:g({state:l(),isInMergeQueue:t(),autoMergeRequest:g({enabledAt:l().nullable()}).nullable()}).nullable()}).nullable()}),errors:p(e()).optional()}),g({data:g({open:g({issueCount:We,nodes:p(e())}),merged:g({issueCount:We,nodes:p(e())})}),errors:p(e()).optional()});var A=Object.freeze({min:0,exclusiveMin:!0,label:`a positive number`}),St=Object.freeze({min:0,label:`zero or more`}),Ct=Object.freeze({min:0,max:300}),wt=Object.freeze({min:1,max:60}),Tt=Object.freeze({min:.5,max:2}),Et=Object.freeze({flyingAnimalsMinGapSeconds:20,flyingAnimalsMaxGapSeconds:40,flyingAnimalsMinDurationSeconds:6.9,flyingAnimalsMaxDurationSeconds:11.5,flyingAnimalsScale:1,flyingAnimalsOnPhone:!0}),Dt=Object.freeze({min:64,max:16384}),Ot=Object.freeze({min:0,max:65536}),kt=Object.freeze({min:0,max:65535}),At=Object.freeze({min:0,exclusiveMin:!0,max:2147483647/1e3}),jt=A,Mt=A,Nt=A,Pt=A,Ft=A,It=St,Lt=A,Rt=A,zt=A,Bt=A,Vt=A,Ht=A,Ut=A,Wt=A,Gt=A,Kt=Object.freeze({min:60,max:21600,label:`between 60 and 21600`}),qt=Object.freeze({min:1,label:`at least 1`}),Jt=Object.freeze({min:1,label:`at least 1`}),Yt=St,Xt=Object.freeze({min:1,max:30,label:`between 1 and 30`}),Zt=Object.freeze({min:1,max:1440}),Qt=Object.freeze({min:1,max:3650}),$t=Object.freeze({min:30,max:3650}),en=Object.freeze({min:1,max:24}),tn=A,nn=Object.freeze({scanIntervalMinutes:Zt,retainDays:Qt,warehouseRetainDays:$t,sessionBlockHours:en}),rn=Object.freeze({min:15,max:600}),an=Object.freeze({min:5,max:120}),on=Object.freeze({min:1,max:5}),sn=Object.freeze({min:1,max:50});Object.freeze({NON_NEGATIVE_NUMBER_RANGE:St,FLYING_ANIMALS_GAP_RANGE:Ct,FLYING_ANIMALS_DURATION_RANGE:wt,FLYING_ANIMALS_SCALE_RANGE:Tt,CHANGE_MAP_NARRATOR_TIMEOUT_RANGE:rn,KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE:an,PORT_RANGE:kt,POSTHOG_ESCALATION_RANGE:Ut,POSTHOG_FIX_TIMEOUT_RANGE:Kt,POSTHOG_INTERVAL_RANGE:zt,POSTHOG_INVESTIGATION_TIMEOUT_RANGE:Vt,POSTHOG_MAX_CONCURRENT_RANGE:Bt,POSTHOG_MIN_USERS_RANGE:Ht,POSTHOG_TRAFFIC_BASELINE_RANGE:Xt,POSTHOG_TRAFFIC_COOLDOWN_RANGE:Yt,POSTHOG_TRAFFIC_MIN_USERS_RANGE:Jt,POSTHOG_TRAFFIC_MULTIPLIER_RANGE:qt,REPLAY_BUFFER_KB_RANGE:Dt,MEMORY_RESERVE_MB_RANGE:Ot,TASK_TITLE_TIMEOUT_RANGE:At,USAGE_BUDGET_RANGE:tn,USAGE_RETAIN_DAYS_RANGE:Qt,USAGE_SCAN_INTERVAL_RANGE:Zt,VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE:It,VISIONS_COOLDOWN_MS_RANGE:Pt,VISIONS_DISPATCH_TIMEOUT_RANGE:Lt,VISIONS_INTENT_THREAD_TTL_MS_RANGE:Rt,VISIONS_MAX_PER_HOUR_RANGE:Ft,VISIONS_QUIET_MS_RANGE:Nt,WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE:sn,WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE:on});var cn=Object.freeze([`opened`,`checks-failed`,`review-requested`,`approved`,`commented`,`merged`]),ln=Object.freeze([`notify`,`spawn`,`label`,`comment`]),un=2e4,dn=65536,fn=50,pn=/^[a-z0-9][a-z0-9-]{0,63}$/,mn=/[\x00-\x1f\x7f,]|^-/,hn=(e,t)=>{let n=`${e} must be an integer between ${t.min} and ${t.max}`;return c({error:n}).int({error:n}).min(t.min,{error:n}).max(t.max,{error:n})},gn=t({error:`workflows.enabled must be a boolean`}),_n=hn(`workflows.maxConcurrentSessions`,on),vn=hn(`workflows.maxActionsPerPoll`,sn),yn=(e,t)=>p(t,{error:`${e} must be an array`}).min(1,{error:`${e} must list at least one entry when present`}),bn=l({error:`a workflow label name must be a string`}).trim().min(1,{error:`a workflow label name must not be empty`}).max(fn,{error:`a workflow label name must be at most ${fn} characters`}).refine(e=>!mn.test(e),{error:`a workflow label name must not start with a dash or hold a comma or control character`}),xn=l({error:`a workflow comment body must be a string`}).min(1,{error:`a workflow comment body must not be empty`}).max(dn,{error:`a workflow comment body must be at most ${dn} characters`}).refine(e=>e.trim().length>0,{error:`a workflow comment body must not be blank`}),Sn=u(cn,{error:`workflows.rules[].trigger must be one of ${cn.join(`, `)}`}),Cn=d(`type`,[f({type:m(`notify`)}),f({type:m(`spawn`),promptTemplate:l({error:`a spawn action needs a promptTemplate string`}).min(1,{error:`a spawn action promptTemplate must not be empty`}).max(un,{error:`a spawn action promptTemplate must be at most ${un} characters`}).refine(e=>e.trim().length>0,{error:`a spawn action promptTemplate must not be blank`})}),f({type:m(`label`),name:bn}),f({type:m(`comment`),body:xn})],{error:`workflows.rules[].actions[].type must be one of ${ln.join(`, `)}`}),wn=f({mine:t({error:`workflows.rules[].filters.mine must be a boolean`}).optional(),teamReviewRequested:t({error:`workflows.rules[].filters.teamReviewRequested must be a boolean`}).optional(),authors:yn(`workflows.rules[].filters.authors`,l({error:`workflows.rules[].filters.authors must hold GitHub logins`}).regex(ne,{error:`workflows.rules[].filters.authors must hold GitHub logins`})).optional(),labels:yn(`workflows.rules[].filters.labels`,bn).optional(),baseBranches:yn(`workflows.rules[].filters.baseBranches`,l({error:`workflows.rules[].filters.baseBranches must hold branch names`}).min(1,{error:`workflows.rules[].filters.baseBranches must hold branch names`})).optional()},{error:`workflows.rules[].filters must be an object`}),Tn=l({error:`workflows.rules[].id must be a string`}).regex(pn,{error:`workflows.rules[].id must be 1 to 64 lowercase letters, digits and dashes, starting with a letter or digit`}),En=t({error:`workflows.rules[].enabled must be a boolean`}),Dn=f({id:Tn,name:l({error:`workflows.rules[].name must be a string`}).trim().min(1,{error:`workflows.rules[].name must not be empty`}).max(80,{error:`workflows.rules[].name must be at most 80 characters`}),enabled:En.default(!1),repos:yn(`workflows.rules[].repos`,Ge),filters:wn.default({}),trigger:Sn,actions:yn(`workflows.rules[].actions`,Cn)},{error:`workflows.rules[] must be an object`}),On=f({enabled:gn.default(!0),maxConcurrentSessions:_n.default(2),maxActionsPerPoll:vn.default(20),rules:p(Dn,{error:`workflows.rules must be an array`}).default([])},{error:`workflows must be an object`}).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.rules.entries())n.has(i.id)?t.addIssue({code:`custom`,path:[`rules`,r,`id`],message:`workflows.rules[${r}].id "${i.id}" is declared more than once`}):n.add(i.id)}),kn=f({id:Tn,enabled:En},{error:`a dashboard update of workflows.rules[] carries only id and enabled`});f({enabled:gn.optional(),maxConcurrentSessions:_n.optional(),maxActionsPerPoll:vn.optional(),rules:p(kn,{error:`workflows.rules must be an array`}).optional()},{error:`a dashboard update of workflows carries only enabled, maxConcurrentSessions, maxActionsPerPoll and rule toggles`});var An=c().int().nonnegative(),jn=u([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable(),Mn=bt.extend({author:g({login:l()}).nullable(),labels:g({nodes:p(g({name:l()}))}),comments:g({totalCount:An})}),Nn=f({repo:Ge,number:c().int().positive(),title:l(),url:_(),author:l().nullable(),state:u([`OPEN`,`MERGED`,`CLOSED`]),createdAt:l(),mergedAt:l().nullable(),isDraft:t(),isCrossRepository:t(),baseRefName:l(),headRefName:l().min(1),headRefOid:E,labels:p(l()),commentCount:An,reviewRequests:p(l()),checksState:jn,reviewDecision:u([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable()}),Pn=f({polledAtMs:An,prs:p(Nn)});f({repos:i(l().regex(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/),Pn)});var Fn=l().refine(e=>qe.safeParse(e).success&&e===e.toLowerCase()&&Number.isSafeInteger(Number(e.slice(e.lastIndexOf(`#`)+1))));function In(e){return`${e.repo}#${e.number}`.toLowerCase()}g({repository:bt.shape.repository.pick({nameWithOwner:!0}),number:bt.shape.number,updatedAt:bt.shape.updatedAt,headRefOid:bt.shape.headRefOid,state:bt.shape.state,commits:g({nodes:p(g({commit:g({statusCheckRollup:g({state:k.shape.checks.shape.state}).nullable()})}))}),reviewDecision:bt.shape.reviewDecision,mergeable:bt.shape.mergeable}),bt.extend({author:Mn.shape.author.unwrap().extend({__typename:l().optional()}).nullable(),labels:Mn.shape.labels,comments:Mn.shape.comments,latestReviews:g({nodes:p(bt.shape.latestReviews.shape.nodes.element.extend({commit:g({oid:l()}).nullable().optional()}))}),writerOpinionatedReviews:bt.shape.latestOpinionatedReviews.optional()});var Ln=f({key:Fn,id:bt.shape.id,repo:k.shape.repo,number:k.shape.number,title:k.shape.title,url:k.shape.url,author:Nn.shape.author,isAuthorBot:t(),labels:Nn.shape.labels,commentCount:Nn.shape.commentCount,isDraft:k.shape.isDraft,state:k.shape.state,createdAt:k.shape.createdAt,mergedAt:k.shape.mergedAt,updatedAt:k.shape.updatedAt,baseRefName:k.shape.baseRefName,baseRefOid:k.shape.baseRefOid,headRefName:k.shape.headRefName,headRefOid:k.shape.headRefOid,isCrossRepository:k.shape.isCrossRepository,isInMergeQueue:k.shape.isInMergeQueue,mergeMethod:k.shape.mergeMethod,mergeable:k.shape.mergeable,mergeStateStatus:k.shape.mergeStateStatus,reviewDecision:_e.nullable(),checks:k.shape.checks.strict(),rollupState:ve.nullable(),unresolvedThreads:k.shape.unresolvedThreads,threads:p(k.shape.threads.element.strict()),behindBy:k.shape.behindBy,reviewRequests:p(k.shape.reviewRequests.element.strict()),approvals:k.shape.approvals,reviews:p(k.shape.reviews.element.extend({commit:E.nullable()}).strict()),opinionatedWriterReviewStates:p(l())}).refine(e=>e.key===In(e)),Rn=n({type:m(`github-prs`),ts:c().finite().nonnegative(),prs:i(Fn,Ln).refine(e=>Object.entries(e).every(([e,t])=>e===t.key)),freshness:ee}),zn=new Map,Bn=new Set;function Vn(e){let t=Rn.safeParse(e);if(t.success){zn=new Map(Object.entries(t.data.prs));for(let e of Bn)e()}}function Hn(e){return zn.get(e.toLowerCase())}function Un(e){Bn.add(e)}function Wn(e){return e===`remote`?`remote`:`local`}function Gn(e,t){return Wn(t)===`local`||e!==`shutdown`}var Kn=Object.freeze({setTimeoutFn:(e,t)=>setTimeout(e,t),clearTimeoutFn:e=>clearTimeout(e),setIntervalFn:(e,t)=>setInterval(e,t),clearIntervalFn:e=>clearInterval(e)});function qn(e){return typeof e!=`object`||!e||!(`unref`in e)||typeof e.unref!=`function`||e.unref(),e}function Jn({mode:e,delayMs:t,run:n,setTimeoutFn:r=Kn.setTimeoutFn,clearTimeoutFn:i=Kn.clearTimeoutFn,unref:a=!0}){let o=null;function s(){o&&=(i(o),null)}function c(){e===`leading`&&o||(s(),o=r(()=>{o=null,n()},t),a&&qn(o))}return{schedule:c,cancel:s,get isArmed(){return o!==null}}}var j=Object.freeze({DORMANT:`DORMANT`,INITIALIZING:`INITIALIZING`,STARTING:`STARTING`,RUNNING:`RUNNING`,WAITING:`WAITING`,IDLE:`IDLE`,COMPLETE:`COMPLETE`,DONE:`DONE`,FAILED:`FAILED`}),Yn=Object.freeze({[j.DORMANT]:`Dormant`,[j.INITIALIZING]:`Starting`,[j.STARTING]:`Starting`,[j.RUNNING]:`Working`,[j.WAITING]:`Needs Input`,[j.IDLE]:`Idle`,[j.COMPLETE]:`Complete`,[j.DONE]:`Exited`,[j.FAILED]:`Failed`}),Xn=Object.freeze([j.INITIALIZING,j.STARTING,j.RUNNING,j.WAITING,j.IDLE,j.COMPLETE]),Zn=Object.freeze([j.DONE,j.FAILED]),Qn=Object.freeze([j.WAITING,j.IDLE,j.COMPLETE]);function $n(e){return`Git tracks an old Glimmervoid post-turn report in ${e===1?`1 repository`:`${e} repositories`}. Nothing reads it, so run this to stop git tracking it and commit the deletion git then shows. Glimmervoid deletes the file itself on its next start:`}var er=Object.freeze({[j.DORMANT]:`not-started`,[j.INITIALIZING]:`starting`,[j.STARTING]:`starting`,[j.RUNNING]:`working`,[j.WAITING]:`needs-input`,[j.IDLE]:`idle`,[j.COMPLETE]:`complete`,[j.DONE]:`exited`,[j.FAILED]:`failed`}),tr=`monitoring`,nr=e=>({fill:`none`,stroke:`currentColor`,"stroke-width":e,"stroke-linecap":`round`,"stroke-linejoin":`round`}),rr={fill:`currentColor`},ir=Object.freeze({"not-started":[{tag:`circle`,attributes:{cx:`8`,cy:`8`,r:`6`,...nr(`1.6`),"stroke-linecap":`butt`,"stroke-dasharray":`2.6 2.1`}}],starting:[{tag:`circle`,attributes:{cx:`8`,cy:`8`,r:`6`,...nr(`1.8`),"stroke-opacity":`.25`}},{tag:`path`,attributes:{d:`M8 2a6 6 0 0 1 6 6`,...nr(`1.8`),class:`status-icon-spin`}}],working:[{tag:`circle`,attributes:{cx:`8`,cy:`8`,r:`4`,...nr(`1.4`),class:`status-icon-ping`}},{tag:`circle`,attributes:{cx:`8`,cy:`8`,r:`4`,...rr}}],monitoring:[{tag:`path`,attributes:{d:`M1.3 8S3.8 3.4 8 3.4 14.7 8 14.7 8 12.2 12.6 8 12.6 1.3 8 1.3 8z`,...nr(`1.5`)}},{tag:`circle`,attributes:{cx:`8`,cy:`8`,r:`2.2`,...rr}}],"needs-input":[{tag:`path`,attributes:{d:`M4.6 5.2a3.4 3.4 0 1 1 4.9 3.05c-1 .5-1.5 1.1-1.5 2.05v.6`,...nr(`2.5`)}},{tag:`circle`,attributes:{cx:`8`,cy:`14`,r:`1.55`,...rr}}],idle:[{tag:`rect`,attributes:{x:`3.6`,y:`2.8`,width:`3`,height:`10.4`,rx:`.8`,...rr}},{tag:`rect`,attributes:{x:`9.4`,y:`2.8`,width:`3`,height:`10.4`,rx:`.8`,...rr}}],complete:[{tag:`path`,attributes:{d:`M2.8 8.4l3.4 3.4 7-7.4`,...nr(`2.2`)}}],exited:[{tag:`rect`,attributes:{x:`3`,y:`3`,width:`10`,height:`10`,rx:`1.6`,...rr}}],failed:[{tag:`path`,attributes:{d:`M3.5 3.5l9 9M12.5 3.5l-9 9`,...nr(`2`)}}]});function ar(e,t){return!e||e.toLowerCase().endsWith(`[bot]`)?null:`https://avatars.githubusercontent.com/${encodeURIComponent(e)}?s=${t*2}`}function or(e){return e.match(/[a-z0-9]/i)?.[0]?.toUpperCase()??`?`}function M(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!=null&&(r.textContent=n),r}function sr(e,t,n){let r=M(e,t);return r.innerHTML=n,r}function cr(e,t){for(let[n,r]of t)e.style.setProperty(n,r)}function lr({login:e,url:t,cssPx:n}){let r=M(`span`,`avatar`);r.style.width=`${n}px`,r.style.height=`${n}px`;let i=()=>M(`span`,`avatar-monogram`,or(e)),a=t===void 0?ar(e,n):t;if(!a)return r.append(i()),r;let o=M(`img`);return o.src=a,o.width=n,o.height=n,o.loading=`lazy`,o.decoding=`async`,o.referrerPolicy=`no-referrer`,o.alt=``,o.addEventListener(`error`,()=>o.replaceWith(i()),{once:!0}),r.append(o),r}function ur(e,t){let n=M(`span`,`avatar-stack`);for(let r of e){let e=lr({login:r.login,url:r.url,cssPx:t});e.title=r.title,e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,r.title);let i=M(`span`,`avatar-badge`);i.dataset.tone=r.tone,e.append(i),n.append(e)}return n}function N(e,t,n){let r=e.querySelector(t);if(!r||r.tagName.toLowerCase()!==n)throw Error(`${t} does not match a <${n}>`);return r}function P(e,t){let n=e.querySelector(t);if(!(n instanceof HTMLElement))throw Error(`${t} matches no element`);return n}function dr(e,t,n,r=t){if(!n){let n=M(`span`,e,t);return n.title=r,n}let i=M(`a`,e,t);return i.title=r,i.href=n,i.target=`_blank`,i.rel=`noopener`,i}function fr(e,t){return e===j.RUNNING&&t===!0}function pr(e,t=!1){let n=e,r=fr(e,t),i=r?`Monitoring`:Yn[n]||e;return{icon:r?tr:er[n]??er[j.DORMANT],label:i.toUpperCase(),isMonitoring:r}}function mr(e){if(!e)return;let t=null,n=()=>{t=null;let n=e.offsetHeight;n>0&&document.documentElement.style.setProperty(`--header-h`,`${n}px`)};new ResizeObserver(()=>{t===null&&(t=requestAnimationFrame(n))}).observe(e)}function hr(e,t,n){let r=M(`section`,`${e}-section`),i=M(`div`,`${e}-section-head`);return i.append(M(`h2`,`${e}-section-title`,t)),n&&i.append(M(`span`,`${e}-section-hint`,n)),r.append(i),r}function gr(e,t,n,r){let i=M(`span`,`${e}-stat`);return r&&(i.dataset.tone=r),i.append(M(`span`,`${e}-stat-value`,n),M(`span`,`${e}-stat-label`,t)),i}function _r(e){return Array.isArray(e?.projects)?e.projects:[]}function vr(e){return!e||!!e.closest(`[hidden]`)}function yr(e){return navigator.clipboard?.writeText?navigator.clipboard.writeText(e):null}function br(e,t){e&&t&&e.parentElement!==t&&(e._adoptHome||={parent:e.parentElement,next:e.nextElementSibling},t.appendChild(e))}function xr(e,t=null){let n=e?._adoptHome;n&&(delete e._adoptHome,n.parent?.isConnected?n.next&&n.next.parentElement===n.parent?n.parent.insertBefore(e,n.next):n.parent.appendChild(e):t&&t.appendChild(e))}var F=new Map;function Sr(e){return e.card?.dataset.session||e.nameEl?.textContent||``}function Cr(e){return typeof e==`string`?e:String(e)}function I(e){return typeof e==`string`?F.get(e):void 0}var wr=document.getElementById(`sessions-container`),Tr=Object.freeze({layout:`desktop`,activeView:`focus`,phoneScreen:null,focusedSessionId:null,selectedSessionId:null,borrowedCardId:null}),Er=e=>e||null,Dr=Object.freeze({setLayout:e=>({layout:e}),setActiveView:e=>({activeView:e}),setPhoneScreen:e=>({phoneScreen:Er(e)}),focusSession:e=>({focusedSessionId:Er(e)}),selectSession:e=>({selectedSessionId:Er(e)}),borrowCard:e=>({borrowedCardId:Er(e)})});function Or(e){let t=Object.freeze({...Tr,...e}),n=new Set;function r(){return t}function i(e){return typeof e==`function`?(n.add(e),()=>n.delete(e)):()=>{}}function a(e){let n=[];for(let r of Object.keys(e)){if(!(r in Tr))throw Error(`ui-state: unknown key "${r}"`);Object.is(t[r],e[r])||n.push(r)}return n}function o(e,r){let i=Dr[e];if(!i)throw Error(`ui-state: unknown action "${e}"`);let o=i(r),s=a(o);if(s.length===0)return t;let c=t;t=Object.freeze({...t,...o});for(let e of n)try{e(t,s,c)}catch{}return t}return{snapshot:r,subscribe:i,dispatch:o}}var kr=Or(),Ar=()=>kr.snapshot().activeView;function jr(){return kr.snapshot().borrowedCardId}function Mr(e,t,n,{className:r}={}){if(!e?.card||!n)return;let i=jr();i&&i!==t&&Nr();let a=e.card;a._cardHostClass&&a._cardHostClass!==r&&a.classList.remove(a._cardHostClass),a._cardHostClass=r||``,r&&a.classList.add(r),br(a,n),kr.dispatch(`borrowCard`,t),e._ensureTerminalReady?.(),e._setBorrowed?.(!0),e._showPreferredFace?.()}function Nr(){let e=jr();if(kr.dispatch(`borrowCard`,null),!e)return null;let t=F.get(e);t?._showTerminalFace?.(),t?._setBorrowed?.(!1),t?._setActiveViewer?.(!1);let n=t?.card;return n&&(n._cardHostClass&&n.classList.remove(n._cardHostClass),delete n._cardHostClass,xr(n,wr)),e}var Pr=l().regex(w),Fr=l().regex(RegExp(`${w.source.slice(0,-1)}#[1-9][0-9]*$`)),Ir=g({number:c().int().positive(),url:l().url(),title:l(),state:u([`open`,`draft`,`merged`,`closed`])});g({issue:g({closedByPullRequestsReferences:g({nodes:p(g({number:Ir.shape.number,url:Ir.shape.url,title:Ir.shape.title,state:u([`OPEN`,`MERGED`,`CLOSED`]),isDraft:t()}).nullable()).max(5)})}).nullable()});function Lr({state:e,isDraft:t}){return e===`OPEN`?t?`draft`:`open`:e===`MERGED`?`merged`:`closed`}var Rr={key:l(),repo:Pr,number:c().int().positive(),title:l(),url:l().url(),labels:p(l()),assignees:p(l()),author:l(),comments:c().int().nonnegative(),createdAt:h(),updatedAt:h()},zr=u([`project`,`me`,`team`]),Br={...Rr,sources:p(zr).nonempty().refine(e=>new Set(e).size===e.length),teams:p(Pr),projectId:l().nullable(),pullRequests:p(Ir).max(5).default([])},Vr=g(Br).refine(e=>e.key===`${e.repo}#${e.number}`),Hr=g({...Br,sessionId:l().nullable().default(null)}).refine(e=>e.key===`${e.repo}#${e.number}`),Ur=g({...Rr,state:u([`open`,`closed`])});g({number:Rr.number,title:Rr.title,html_url:Rr.url,state:u([`open`,`closed`]),labels:p(a([l(),g({name:l()})])),assignees:p(g({login:l()})),user:g({login:l()}).nullable(),comments:Rr.comments,created_at:Rr.createdAt,updated_at:Rr.updatedAt,repository_url:l().url().optional(),pull_request:e().optional()}),g({items:p(e()),total_count:c().int().nonnegative(),incomplete_results:t()}),g({ok:t(),items:p(Ur),isComplete:t(),error:l()}),g({issues:p(Vr),lastSyncAt:c().finite().nonnegative().nullable(),perRepoSync:i(Pr,g({lastSyncAt:c().finite().nonnegative().nullable(),ticks:c().int().nonnegative(),needsFullReconcile:t()})),sessionLinks:i(Fr,l()).default({}),pullRequestsFetchedAt:i(Fr,h()).default({})});var Wr=g({type:m(`issues-status`),ts:c().finite(),configured:t(),reason:l().nullable(),lastSyncAt:c().finite().nonnegative().nullable(),issues:p(Hr),...S}).passthrough(),Gr=2e4,Kr=4e3,qr=524288,Jr=1e4,Yr=`ExitPlanMode`,Xr=4096,Zr=/^ {0,3}(#{1,6})[ \t]+(.*)$/;function Qr(e){let t=e.trimEnd(),n=t.length;for(;n>0&&t[n-1]===`#`;)n--;if(n===t.length||n===0)return t;let r=t[n-1];return r!==` `&&r!==` `?t:t.slice(0,n).trimEnd()}function $r(e,{overlongLine:t}){if(t===`reject`&&e.length>4096)return null;let n=Zr.exec(e.slice(0,Xr));return n?{level:n[1].length,text:Qr(n[2])}:null}var ei=g({plan:l().min(1),planFilePath:l().min(1),agent_id:l().min(1).optional(),agent_type:l().min(1).optional()}).passthrough();g({tool_name:m(Yr),tool_input:ei,agent_id:l().min(1).optional(),agent_type:l().min(1).optional()}).passthrough(),g({plan:l(),planFilePath:l(),agentId:l().nullable(),agentType:l().nullable()}).extend({sessionId:l().min(1),revision:c().int().positive(),receivedAt:c().finite()});var ti=Object.freeze([`open`,`released`,`decided`,`closed`]),ni=u(ti),ri=Object.freeze([`approve`,`approve-accept-edits`,`revise`,`terminal`]),ii=u(ri),ai=g({heading:l().max(Kr).nullable(),comment:l().min(1).max(Kr)}),oi=g({id:l().min(1),agentId:l().nullable(),revision:c().int().positive(),decision:ii,feedback:l().max(Gr).optional(),comments:p(ai).max(40).optional(),plan:l().min(1).max(qr).optional()}),si=g({revision:c().int().positive(),receivedAt:c().finite(),chars:c().int().nonnegative(),title:l()}),ci=g({revision:c().int().positive(),since:c().finite()}),li=g({agentId:l().nullable(),agentType:l().nullable(),revisions:p(si),state:ni,openRevision:ci.nullable(),approvedRevision:c().int().positive().nullable(),lastDecision:ii.nullable()});g({reviews:p(li)});var ui=g({agentId:l().nullable(),revision:c().int().nonnegative(),plan:l(),planFilePath:l(),receivedAt:c().finite()}),di=g({id:l(),agentId:l().nullable(),agentType:l().nullable(),revision:c().int().positive(),receivedAt:c().finite(),state:ni,lastDecision:ii.nullable(),approvedRevision:c().int().positive().nullable(),chars:c().int().nonnegative(),title:l(),hasPlan:t()}),fi=g({id:l(),agentId:l().nullable(),planFilePath:l(),changedAt:c().finite()}),pi=g({id:l(),reviews:p(li),body:ui.nullable()});Object.freeze([`file`,`subsystem`,`co-change`,`hotspot`,`blast`,`untested`,`collision`,`link`]);var mi=l().min(1),hi=l().min(1),gi=c().int().nonnegative(),_i=p(hi).max(20),vi=u([`added`,`modified`,`deleted`,`renamed`,`untracked`]),yi=f({factId:mi,path:hi,previousPath:hi.optional(),status:vi,isCommitted:t()}),bi=f({factId:mi,agentsPath:hi,title:l(),paths:p(hi).min(1)}),xi=f({factId:mi,path:hi,partner:hi,support:gi,confidence:c().min(0).max(1)}),Si=f({factId:mi,path:hi,commitCount:gi,fixCommitCount:gi}),Ci=f({factId:mi,path:hi,directDependents:_i,directDependentCount:gi,transitiveDependentCount:gi,dependentTests:_i,dependentTestCount:gi}),wi=f({factId:mi,path:hi}),Ti=f({factId:mi,path:hi,otherSessionId:l().min(1),otherSessionName:l()}),Ei=f({factId:mi,providerRepo:l().min(1),packageName:l().min(1),packageDir:l(),consumerManifest:hi,versionSpec:l(),isLocalLink:t(),providerChangedPathCount:gi,importers:_i,importerCount:gi,changedImporterCount:gi}),Di=f({name:l().min(1),root:l().min(1),sessionPathPrefix:l(),base:l().nullable(),files:p(yi),subsystems:p(bi),coChangeGaps:p(xi),hotspots:p(Si),blastRadius:p(Ci),untestedFiles:p(wi),collisions:p(Ti),links:p(Ei),error:l().nullable()}),Oi=f({text:l().min(1).max(600),factIds:p(mi).min(1)}),ki=f({factsHash:l().min(1),model:l().nullable(),claims:p(Oi).max(12)}),Ai=u([`disabled`,`pending`,`ready`,`failed`]),ji=f({sessionId:l().min(1),sig:l().nullable(),generatedAt:c().finite(),repos:p(Di),narrative:ki.nullable(),narratorState:Ai,error:l().min(1).optional()}),Mi=u([`decision`,`retraction`,`conjecture`,`resolution`,`dismissal`,`defect`,`experiment`,`close`,`unable`,`escalation`,`acknowledgement`,`enactment`]),Ni={id:l().min(1),at:h(),session:l(),agent:l(),commit:l().nullable(),dirty:t(),binding:l()},Pi={of:l().min(1),because:l()},Fi=n({id:l(),text:l()}),Ii=d(`kind`,[n({...Ni,kind:m(`decision`),chose:l(),over:p(l()),because:l()}),n({...Ni,kind:m(`retraction`),...Pi}),n({...Ni,kind:m(`conjecture`),observation:l(),couldBe:p(l()),discriminatedBy:l()}),n({...Ni,kind:m(`resolution`),...Pi,as:l().optional()}),n({...Ni,kind:m(`dismissal`),...Pi}),n({...Ni,kind:m(`defect`),what:l(),evidence:l(),files:p(l())}),n({...Ni,kind:m(`experiment`),expectation:l(),context:p(l()),actions:p(Fi),criteria:p(Fi)}),n({...Ni,kind:m(`close`),of:l(),outcome:u([`success`,`failure`,`inconclusive`]),results:i(l(),e())}),n({...Ni,kind:m(`unable`),what:l(),because:l()}),n({...Ni,kind:m(`escalation`),what:l(),because:l()}),n({...Ni,kind:m(`acknowledgement`),...Pi}),n({...Ni,kind:m(`enactment`),practice:l(),results:i(l(),e())})]),Li=a([Ii,g({id:l().min(1),kind:l().min(1).refine(e=>!Mi.safeParse(e).success)})]);n({branch:l().nullable(),escalations:p(e()),records:p(Li),citedBy:i(l(),p(e())),damaged:p(e())});var Ri=f({id:l().min(1),at:h().nullable(),kind:l().min(1),text:l().max(280),detail:l().max(280).nullable(),supersedes:l().nullable()}),zi=d(`ok`,[f({ok:m(!0),latest:Ri.nullable()}),f({ok:m(!1),reason:l().min(1).max(200)})]),Bi=f({journal:zi,updatedAt:c().finite()}),Vi=/^[a-zA-Z0-9_\-. ()]{1,64}$/,Hi=`Session name may only contain letters, numbers, spaces, dashes, dots, underscores, and parentheses (max 64 chars)`,Ui=/[\x00-\x1f\x7f-\x9f]/,Wi=l().refine(e=>!Ui.test(e)).trim().max(120);g({title:l().nullable(),name:l().nullable().optional()}).strict();var Gi=u(j),Ki=g({at:c().finite().nullable(),kind:l(),reason:l().nullable()}).passthrough(),qi=4e3,Ji=1e3,Yi=2e3,Xi=g({question:l().min(1).max(Ji),header:l().max(100).default(``),options:p(g({label:l().min(1).max(200),description:l().max(Ji).default(``)})).min(1).max(8),multiSelect:t().default(!1)}),Zi=g({requestId:a([l().min(1).max(128),c().int()]),kind:u([`command`,`fileChange`,`permissions`,`tool`,`question`]),summary:l().max(qi),isSummaryTruncated:t(),toolName:l().max(200).optional(),questions:p(Xi).min(1).max(4).optional(),alwaysAllowSummary:l().max(qi).optional()}),Qi=i(l().max(Ji),l().max(Yi)),$i=u([`accept`,`acceptForSession`,`decline`]),ea=80,ta=Object.freeze({notInstalled:`not installed`,unsupportedVersion:`unsupported version`,codexHooksUntrusted:`Codex hooks need trust in /hooks`}),na=d(`active`,[g({active:m(!0)}).strict(),g({active:m(!1),reason:l().min(1).max(ea),version:l().optional()}).strict()]),ra=g({id:l(),name:l(),taskTitle:Wi.nullable().default(null),taskTitleIsCustom:t().default(!1),path:l(),agent:l(),state:Gi,stateSince:c(),dangerouslySkipPermissions:t(),saneYolo:t().default(!1),ephemeral:t(),ownerId:l().nullable().optional(),isWorktree:t(),isWorkspace:t().default(!1),isGuarded:t().default(!1),isGuardrailsReleased:t().default(!1),resumeSessionId:l().nullable(),activeAgents:c().int().nonnegative(),awaitingBackgroundTasks:t(),isCompacting:t().default(!1),isWaitingForMemory:t().default(!1),pendingWakeup:Ki.nullable(),pendingPromptKind:l().nullable(),conversationApproval:Zi.nullable().default(null),hasConversationBridge:t().default(!1),isConversationViewOn:t().default(!1),hasPlan:t().default(!1),mergeStatus:l().nullable(),mergeReason:l().nullable(),worktreeNotice:l().nullable(),failureReason:l().nullable().optional(),effectiveBase:l().nullable(),linkedPrs:p($e).default([]),coherenceHooks:na.nullable().default(null),auditLog:p(e())}).passthrough();g({namespace:m(`git`,{error:`namespace must be git`}),publicKey:l({error:`publicKey must be a string`}).min(1,{error:`publicKey must not be empty`}).max(16384,{error:`publicKey must be at most 16384 characters`}),payload:s({error:`payload must be base64`})}).strict(),a([g({ok:m(!0),signature:l()}).strict(),g({ok:m(!1),error:l()}).strict()]);var ia=[`push`,`spawn`,`send`,`read`,`close`,`attention`,`board`,`edit`,`review`,`reviews`,`prs`,`link-pr`,`settings`];[...ia],g({prompt:l({error:`prompt must be a string`}).min(1,{error:`prompt must not be empty`}).max(2e4,{error:`prompt must be at most 20000 characters`}).refine(e=>!e.trimStart().startsWith(`-`),{message:`prompt must not start with a dash, which the agent CLI would read as an option`}),name:l({error:`name must be a string`}).min(1,{error:`name must not be empty`}).max(200,{error:`name must be at most 200 characters`}).optional(),agent:l({error:`agent must be a string`}).min(1,{error:`agent must not be empty`}).max(40,{error:`agent must be at most 40 characters`}).optional()}).strict();var aa=l({error:`the session must be a string`}).min(1,{error:`the session must not be empty`}).max(300,{error:`the session must be at most 300 characters`});g({words:p(l({error:`each word must be a string`}).max(2e4,{error:`each word must be at most 20000 characters`}),{error:`words must be a list`}).min(1,{error:`send needs text`}).max(5e3,{error:`send takes at most 5000 words`})}).strict(),g({child:aa.optional()}).strict(),g({child:aa}).strict();var oa=g({from:u([`parent`,`child`,`glimmervoid`]),at:c().finite(),text:l()}).strict();g({ok:m(!0),channels:p(g({sessionId:l(),name:l(),entries:p(oa),dropped:c().int().nonnegative()}).strict())}).strict(),g({note:l({error:`note must be a string`}).min(1,{error:`note must not be empty`}).max(500,{error:`note must be at most 500 characters`})}).strict(),a([g({ok:m(!0),pending:t()}).strict(),g({ok:m(!1),error:l()}).strict()]),g({id:ra.shape.id,name:ra.shape.name,agent:ra.shape.agent,state:ra.shape.state,ephemeral:ra.shape.ephemeral}).strict(),g({pr:l({error:`pr must be a string`}).min(1,{error:`pr must not be empty`}).max(300,{error:`pr must be at most 300 characters`})}).strict(),g({command:u([`list`,`get`],{error:`command must be list or get`}),path:l({error:`path must be a string`}).min(1,{error:`path must not be empty`}).max(200,{error:`path must be at most 200 characters`}).optional()}).strict(),a([g({ok:m(!0),text:l(),readout:e()}).strict(),g({ok:m(!1),error:l()}).strict()]);var sa=Le.pick({key:!0,title:!0,url:!0,author:!0});g({ok:m(!0),configured:t(),reason:l().nullable(),reviewing:p(sa.extend({phase:Ve.shape.phase})),queued:p(sa),drafts:p(sa.extend({status:Ae.shape.status,verdict:l(),summary:Ae.shape.summary,comments:c().int().nonnegative(),isOutOfDate:t()}))}).strict(),g({ok:m(!0),configured:t(),prs:p(g({key:k.shape.key,title:k.shape.title,url:k.shape.url,state:k.shape.state,isDraft:k.shape.isDraft,stage:k.shape.stage,reviewDecision:k.shape.reviewDecision,approvals:k.shape.approvals,unresolvedThreads:k.shape.unresolvedThreads,behindBy:k.shape.behindBy,mergeable:k.shape.mergeable,isInMergeQueue:k.shape.isInMergeQueue,checks:k.shape.checks.pick({state:!0,failing:!0})}).strict())}).strict();var ca=4096;g({path:l({error:`path must be a string`}).min(1,{error:`path must not be empty`}).max(ca,{error:`path must be at most ${ca} characters`})}).strict();var la=g({path:l(),name:l(),surfacedAt:c().finite()}).strict();g({commands:p(g({name:u(ia),answers:t(),reason:l().optional()}).strict()),guarded:t(),boundary:u([`os-sandbox`,`workspace`,`none`]),environment:g({name:l(),workspace:l(),state:l()}).strict().nullable(),deadEnds:p(g({blocked:l(),route:l()}).strict())}).strict().extend({ok:m(!0)}).strict();var ua=4e3,da=g({ts:c().finite(),uuid:l().nullable(),parentUuid:l().nullable(),vendorSessionId:l().min(1),agentId:l().min(1).optional(),agentType:l().min(1).optional(),transcriptOffset:c().int().nonnegative().optional(),truncated:t().optional()}),fa=d(`kind`,[da.extend({kind:m(`prompt`),text:l()}),da.extend({kind:m(`expansion`),text:l(),toolUseId:l().min(1).optional()}),da.extend({kind:m(`thinking`),text:l()}),da.extend({kind:m(`assistant`),text:l()}),da.extend({kind:m(`tool_call`),toolUseId:l().min(1),name:l().min(1),input:e()}),da.extend({kind:m(`tool_result`),toolUseId:l().min(1),content:l(),isError:t(),truncated:t()}),da.extend({kind:m(`session`),vendor:l().min(1),transcriptPath:l().min(1),reason:l().min(1).optional()}),da.extend({kind:m(`notice`),text:l().max(ua)}),da.extend({kind:m(`raw`),line:l().max(ua)})]);g({transcriptPath:l().min(1),vendorSessionId:l().min(1),offset:c().int().nonnegative(),ingestedSubagentPaths:p(l().min(1)),offsetByTranscriptPath:i(l().min(1),c().int().nonnegative()).default({}),subagentOffsetByPath:i(l().min(1),c().int().nonnegative()).default({})});var pa=l().max(16384),ma=p(pa).max(4096),ha=g({model:pa.nullable(),mcpServers:ma,plugins:p(g({name:pa,skills:ma,agents:ma})).max(4096),skills:ma,agents:ma,hookEvents:p(g({event:pa,runCount:c().int().nonnegative()})).max(4096),hookCommands:p(l().max(65536)).max(4096)}),ga=u([`release`,`main`]),_a=u([`idle`,`running`,`staged`,`succeeded`,`failed`,`discarded`,`interrupted`]),va=u([`fetch`,`stage`,`install`,`link-deps`,`build`]),ya=u([`pending`,`running`,`succeeded`,`failed`]),ba=g({id:va,status:ya,startedAt:c().finite().nullable(),finishedAt:c().finite().nullable(),outputTail:p(l())}).strict(),xa=g({state:_a,fromSha:l().nullable(),toSha:l().nullable(),toVersion:l().nullable(),channel:ga,steps:p(ba),activeStep:va.nullable(),reason:l().nullable(),startedAt:c().finite().nullable(),finishedAt:c().finite().nullable(),failedAtHandOff:t().optional()}).strict(),Sa=xa.pick({state:!0,activeStep:!0,reason:!0,startedAt:!0,finishedAt:!0}),Ca=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,wa=/^[A-Za-z_][A-Za-z0-9_]*$/,Ta=l().regex(/^[^/\s]+\/[^/\s]+$/),Ea=c().finite(),Da=l().min(1),Oa=Object.freeze([`CLAUDE_CODE_OAUTH_TOKEN`]),ka=l().regex(Ca);function Aa(e){return new Set(e.map(e=>e.id)).size===e.length}var ja=d(`kind`,[f({kind:m(`manual`)}),f({kind:m(`github-merged-prs`),repo:Ta,minBodies:c().int().min(1),limit:c().int().min(1).max(500)})]),Ma=d(`kind`,[f({kind:m(`none`)}),f({kind:m(`pr-checkout`)})]),Na=u([`review-findings`,`json`]),Pa=f({promptTemplate:Da,output:Na,timeoutSeconds:c().int().min(30).max(14400)}),Fa=f({id:ka,env:i(l().regex(wa),l()).refine(e=>Oa.every(t=>!Object.hasOwn(e,t)),{message:`arm env must not set ${Oa.join(`, `)}; Glimmervoid injects it per cell`}).optional(),extraArgs:p(l()).optional(),setup:f({command:p(Da).min(1)}).optional()}),Ia=d(`kind`,[f({kind:m(`llm-judge-match`),model:Da})]);f({id:ka,title:Da,caseSource:ja,workspace:Ma,subject:Pa,arms:p(Fa).min(2).refine(Aa,{message:`arm ids must be unique`}),baselineArm:ka,trials:c().int().min(1).max(20),scorer:Ia}).refine(e=>e.arms.some(t=>t.id===e.baselineArm),{message:`baselineArm must name one of the arms`,path:[`baselineArm`]});var La=f({id:ka,text:Da,tags:p(ka),path:Da.optional(),line:c().int().positive().optional()}),Ra=d(`kind`,[f({kind:m(`manual`)}),f({kind:m(`github-pr`),repo:Ta,number:c().int().positive(),url:Da,minedAt:Ea})]);f({id:ka,input:i(l(),e()),references:p(La).min(1).refine(Aa,{message:`reference ids must be unique`}),source:Ra}),g({repo:Ta,number:c().int().positive(),reviewedSha:E,baseSha:E,changedFiles:p(Da)});var za=u([`found`,`partial`,`missed`]),Ba=f({referenceId:ka,verdict:za,findingIndexes:p(c().int().nonnegative())}),Va=u([`scored`,`invalid`,`error`]),Ha=f({caseId:ka,armId:ka,trial:c().int().min(1),status:Va,startedAt:Ea,finishedAt:Ea,degradedReasons:p(Da),findingCount:c().int().nonnegative(),judgements:p(Ba),costUsd:c().finite().nonnegative().nullable(),error:Da.nullable()}),Ua=u([`running`,`completed`,`interrupted`,`failed`]);f({id:ka,suiteId:ka,status:Ua,startedAt:Ea,finishedAt:Ea.nullable(),error:Da.nullable(),cells:p(Ha)});var Wa=c().min(0).max(1).nullable(),Ga=f({trials:c().int().nonnegative(),recall:Wa,recallByTag:i(ka,Wa),degraded:c().int().nonnegative(),invalid:c().int().nonnegative(),costUsd:c().finite().nonnegative().nullable()}),Ka=f({caseId:ka,arms:i(ka,Ga),deltaVsBaseline:i(ka,c().min(-1).max(1).nullable())}),qa=f({runId:ka,suiteId:ka,status:Ua,baselineArm:ka,armIds:p(ka),rows:p(Ka),totals:i(ka,Ga)}),Ja=u([`mine`,`run`,`cancel`]),Ya=g({suiteId:ka,action:Ja}),Xa=g({suiteId:ka,action:Ja,ok:t(),error:l().optional(),runId:ka.optional()}),Za=u([`setup`,`preflight`,`workspace`,`subject`,`judge`]),Qa=g({suiteId:ka,runId:ka,caseId:ka.nullable(),armId:ka,trial:c().int().min(1),phase:Za,cellIndex:c().int().nonnegative(),cellCount:c().int().positive(),startedAt:Ea}),$a=g({id:ka,title:l(),error:l().nullable(),caseCount:c().int().nonnegative(),candidateCount:c().int().nonnegative(),armIds:p(ka),baselineArm:ka.nullable(),latestReport:qa.nullable()}),eo=g({type:m(`benchmark-status`),ts:Ea,configured:t(),reason:l().nullable(),suites:p($a),inFlight:Qa.nullable()}).passthrough(),to=g({__typename:l(),login:l()}).nullable();g({number:c().int().positive(),title:l(),url:Da,mergedAt:l().nullable(),reviewThreads:g({totalCount:c().int().nonnegative()}),reviews:g({totalCount:c().int().nonnegative()})});var no=g({path:l(),line:c().int().positive().nullable(),originalLine:c().int().positive().nullable(),comments:g({nodes:p(g({databaseId:c().int().positive(),author:to,body:l(),createdAt:l(),originalCommit:g({oid:E}).nullable()}))})}),ro=g({databaseId:c().int().positive(),author:to,body:l(),submittedAt:l().nullable(),commit:g({oid:E}).nullable()}),io=d(`__typename`,[g({__typename:m(`BaseRefChangedEvent`),createdAt:l()}),g({__typename:m(`BaseRefForcePushedEvent`),createdAt:l(),beforeCommit:g({oid:E}).nullable()})]);g({author:to,baseRefOid:E,reviewThreads:g({pageInfo:g({hasNextPage:t()}),nodes:p(no)}),reviews:g({pageInfo:g({hasNextPage:t()}),nodes:p(ro)}),timelineItems:g({pageInfo:g({hasNextPage:t()}),nodes:p(io)})}),g({mergeBaseSha:E,changedFiles:p(Da),isFileListComplete:t()});var L=l().nullable().optional(),R=l(),ao=et.shape.unlinkedKeys.unwrap().element,oo=/^https:\/\/github\.com\/([^/\s]+\/[^/\s]+)\/pull\/([0-9]+)(?:[/?#].*)?$/i;function so(e){let t=e.trim(),n=oo.exec(t),r=n?`${n[1]}#${n[2]}`:t,i=ao.safeParse(r);return i.success?i.data:null}function z(e,t){return n({type:m(e),...t})}function co(e={}){return n(e)}var B=l().nullable(),V=c().finite(),lo=V.optional(),uo=B.optional(),fo=co(),po=p(e()),mo=c().int().positive(),ho=l().min(1).max(ca),go=p(a([co({at:V,tool:l(),detail:l()}),co({at:V,note:l()})]));g({id:l(),label:l(),command:l(),args:p(l()),resolvable:t().nullable()}).strict();var _o=g({name:l(),template:l(),parameters:i(l(),l()),hourlyCostUsd:c().nullable(),idleStopMinutes:c()}),vo=p(_o).nullable(),yo=u([`claude-code`,`codex`]),bo=g({agent:yo,state:u([`signed-in`,`signed-out`,`connecting`,`failed`]),source:u([`host`,`glimmervoid`]).nullable(),verificationUrl:l().nullable(),userCode:l().nullable(),needsPastedCode:t(),reason:l().nullable()}).strict(),xo=p(bo),So=g({setupWarning:B,lastFailure:g({message:l(),failedAt:V}).nullable()}),Co=g({id:R,session:l(),taskTitle:Wi.nullable().optional(),taskTitleIsCustom:t().optional(),path:l(),agent:l(),state:Gi,stateSince:V,skipPerms:t(),saneYolo:t(),worktree:t(),workspace:t().optional(),guarded:t().optional(),guardrailsReleased:t().optional(),resumeSessionId:B,ephemeral:t().optional(),ownerId:R.optional(),linkedPrs:p($e).optional()}),wo=1e3,To=RegExp(`^[^\0--Ÿ]+$`),Eo=f({section:u([`committed`,`uncommitted`]),path:l().min(1).max(400).regex(To),line:c().int().positive(),side:u([`old`,`new`]),note:l().min(1).max(wo)}),Do=4096,Oo=Do+2*(qr+Gr+80*Kr),ko=g({reason:l(),message:l()}),Ao=u([`npm-global`,`npx`,`clone`,`unknown`]),jo={updateAvailable:t(),current:B,latest:B,currentSha:B,latestSha:B,releaseUrl:B,command:l(),flavor:Ao,platform:l(),installedBranch:B,upstream:B,isTreeClean:t().nullable(),lastCheckAt:V,channel:ga,behindCount:c().int().nonnegative().nullable(),reason:B,deprecation:B,journalSummary:Sa.nullable(),applyRefusal:ko.nullable()};g(jo);var Mo=8192,No=g({name:l().max(128),stack:l().max(Mo)}).strict(),Po=Object.freeze([`view_shown`,`operator_action`]);Object.freeze([`focus`,`zen`,`prs`,`issues`,`usage`,`radar`,`visions`,`hooks`,`trace`,`benchmarks`,`settings`]),Object.freeze({usage:[`sort`,`range`,`period`,`expand`,`refresh`],issues:[`scope`,`filter`,`search`,`filters-toggle`,`select`,`back`,`go-to-session`,`open-session`,`refresh`],radar:[`report`,`open-session`,`resolve`,`suppress`,`archive-investigation`],reviews:[`open-session`,`approve`,`approve-only`,`comment`,`discard`,`requeue`,`resolve-thread`,`merge`,`keep-mergeable`,`merge-when-ready`,`refresh`]}),Object.freeze([`usage`,`issues`,`radar`,`reviews`]);var Fo=[`remove-session`,`kill`,`start-session`,`restart`,`force-restart`,`merge-session`,`finish-session`,`merge-continue-session`,`discard-session-worktree`,`resolve-session-merge`,`request-session-diff`,`request-change-map`,`request-branch-sync`,`resync-branch`,`debug-state`];function Io(t){return z(t,{id:R,force:e().optional()})}var Lo=Fo.map(Io),Ro=[z(`add-session`,{name:l(),path:l(),repos:p(l()).optional(),agent:l().optional(),dangerouslySkipPermissions:t().optional(),unguarded:t().optional(),runInPlace:t().optional(),environment:l().optional(),requestId:L}),z(`list-conversations`,{id:R,requestId:L}),z(`resume-conversation`,{id:R,conversationId:l()}),z(`rename-session`,{id:R,newName:l()}),z(`get-workspace-repos`,{id:R,requestId:L}),z(`set-workspace-repos`,{id:R,repos:p(l()),requestId:L}),z(`set-session-title`,{id:R,title:Wi}),z(`link-session-pr`,{id:R,key:ao}),z(`unlink-session-pr`,{id:R,key:ao}),z(`ping`,{requestId:L}),z(`get-settings`,{requestId:L}),z(`get-agent-logins`,{requestId:L}),z(`agent-connect`,{agent:yo,action:u([`start`,`cancel`]),requestId:L}),z(`agent-connect-code`,{agent:yo,code:l(),requestId:L}),z(`update-settings`,{settings:i(l(),e()),requestId:L}),z(`scan-repo-roots`,{requestId:L,includeSuggestions:t().optional()}),z(`list-agents`,{requestId:L,rescan:t().optional()}),z(`get-radar-report`,{issueId:a([l(),c()]),requestId:L}),z(`radar-open-session`,{projectId:a([l(),c()]),issueId:a([l(),c()]),requestId:L}),z(`issue-detail`,{requestId:l().min(1),repo:Pr,issueNumber:c().int().positive()}),z(`open-issue-session`,{requestId:L,projectId:l(),repo:Pr,issueNumber:c().int().positive()}),z(`radar-issue-action`,{projectId:a([l(),c()]),issueId:a([l(),c()]),action:l(),requestId:L}),z(`open-team-review-session`,{requestId:L,key:ao}),z(`team-review-action`,{...Pe.shape,requestId:L}).refine(Ne,{message:`only discard may omit head`,path:[`head`]}),z(`benchmark-action`,{...Ya.shape,requestId:L}),z(`my-pr-merge`,{...pt.shape,requestId:L}),z(`my-pr-keep-mergeable`,{...tt.shape,requestId:L}),z(`my-pr-merge-when-ready`,{...it.shape,requestId:L}),z(`github-polling-refresh`,{...te.shape,requestId:L}),z(`radar-archive-investigation`,{id:e().optional(),requestId:L}),z(`telegram-test`,{requestId:L}),z(`request-usage-report`,{requestId:L,days:e().optional(),force:e().optional()}),z(`request-hooks-report`,{requestId:L}),z(`send-diff-annotations`,{id:R,annotations:p(Eo).min(1).max(50),requestId:L}),z(`save-hook`,{hook:i(l(),e()),requestId:L}),z(`delete-hook`,{id:l(),requestId:L}),z(`shutdown`),z(`restart-server`),z(`focus-change`,{focused:t()}),z(`request-health-snapshot`),z(`update-check`),z(`update-apply`),z(`session-trace`,{id:R,requestId:L,after:c().int().nonnegative().default(0),endingAt:a([c().int().nonnegative(),m(`tail`)]).optional()}),z(`session-plan`,{id:R,agentId:B,revision:mo.optional(),draft:t().optional()}),z(`plan-decision`,oi.shape),z(`set-session-conversation-view`,{id:R,isOn:t()}),z(`set-session-guardrails`,{id:R,isOn:t()}),z(`conversation-approval`,{id:R,requestId:Zi.shape.requestId,decision:$i,answers:Qi.optional()}),z(`session-doc-read`,{id:R,path:ho,requestId:L}),z(`session-doc-save`,{id:R,path:ho,text:l(),baseHash:l().min(1),requestId:L}),z(`session-coherence-journal`,{id:R,requestId:L}),z(`session-setup`,{id:R,requestId:L}),z(`client-error`,No.shape),z(`dashboard-telemetry`,{event:u(Po),properties:i(l(),e())}),z(`dismiss`,{id:R,force:e().optional(),expectedState:Gi.optional()}),...Lo];d(`type`,Ro),Object.freeze(`snapshot.hooks-report.save-hook-result.add-session-result.agent-logins.delete-hook-result.workspace-repos.set-workspace-repos-result.hooks-updated.state-change.session-added.session-removed.session-renamed.session-title.session-prs.session-modified.session-git.session-coherence-hooks.session-agents.session-wakeup.session-prompt.session-conversation.session-merge-status.session-worktree-blocked.session-worktree-warning.session-worktree-ready.session-diff.session-diff-error.change-map.send-diff-annotations-result.branch-sync-status.session-changed.post-turn-result.debug-state-response.session-trace-response.session-trace-changed.session-plan-changed.session-plan-draft.session-plan-response.session-docs-changed.session-docs-snapshot.session-doc-response.session-doc-save-result.session-coherence.session-coherence-snapshot.session-coherence-journal-response.session-setup-response.notify.update-status.update-progress.post-turn-leftovers.error.session-error.settings.settings-error.settings-updated.pong.agents-listed.repo-roots-scanned.conversations.resume-conversation-ack.health-snapshot.radar-status.radar-investigation-activity.radar-investigation-finished.radar-report.radar-open-session-result.issue-detail-result.open-issue-session-result.open-team-review-session-result.radar-issue-action-result.team-review-action-result.benchmark-action-result.my-pr-merge-result.my-pr-keep-mergeable-result.my-pr-merge-when-ready-result.github-polling-refresh-result.radar-archive-investigation-result.team-review-status.benchmark-status.my-prs-status.issues-status.usage-sessions.usage-report.plan-limits.usage-budget-alert.visions-findings.visions-comments.visions-hand.visions-intent.visions-fix.visions-snapshot.ingest-activity.ingest-snapshot.client-trust.shutting-down.restarting`.split(`.`));var zo=[z(`snapshot`,{sessions:p(ra),serverBuild:B}),z(`hooks-report`,{requestId:L,ts:lo,hooks:p(fo).optional(),builtin:p(fo).optional(),events:p(co({name:l(),matcher:B,description:l(),http:t().optional()})).optional(),projects:p(co({id:l(),name:l(),agent:l()})).optional(),limits:co({maxTimeoutSec:c().int().positive()}).optional(),error:uo}),z(`save-hook-result`,{requestId:L,ok:t(),error:uo,hook:fo.optional()}),z(`add-session-result`,{requestId:L,ok:t(),error:uo,reason:u([`not-git`]).optional()}),z(`agent-logins`,{requestId:L,logins:xo,error:uo}),z(`delete-hook-result`,{requestId:L,ok:t(),error:uo,id:l().optional()}),z(`workspace-repos`,{requestId:L,id:R,ok:t(),repos:p(l()),error:uo}),z(`set-workspace-repos-result`,{requestId:L,id:R,ok:t(),error:uo}),z(`hooks-updated`,{count:c().int().nonnegative()}),z(`state-change`,{id:R,session:l(),from:Gi,to:Gi,event:l(),timestamp:V,skipPerms:t().optional(),saneYolo:t().optional(),failureReason:l().optional()}),z(`session-added`,Co.shape),z(`session-modified`,Co.shape),z(`session-removed`,{id:R,session:l()}),z(`session-renamed`,{id:R,oldName:l(),newName:l()}),z(`session-title`,{id:R,taskTitle:Wi.nullable(),isCustom:t()}),z(`session-prs`,{id:R,linkedPrs:p($e)}),z(`session-git`,{id:R,worktree:t()}),z(`session-coherence-hooks`,{id:R,coherenceHooks:na.nullable()}),z(`session-agents`,{id:R,activeAgents:c().int().nonnegative(),awaitingBackgroundTasks:t(),timestamp:V}),z(`session-wakeup`,{id:R,pendingWakeup:Ki.nullable(),timestamp:V}),z(`session-prompt`,{isCompacting:t().optional(),id:R,pendingPromptKind:B,timestamp:V}),z(`session-conversation`,{id:R,hasConversationBridge:t(),isConversationViewOn:t(),conversationApproval:Zi.nullable()}),z(`session-merge-status`,{id:R,mergeStatus:l(),reason:B,parked:t(),timestamp:V}),z(`session-worktree-blocked`,{id:R,session:l(),branch:B,notice:B,timestamp:V}),z(`session-worktree-warning`,{id:R,session:l(),branch:B,notice:B,timestamp:V}),z(`session-worktree-ready`,{id:R,session:l(),branch:B,base:B,timestamp:V}),z(`session-diff`,{id:R,committed:co({stat:l(),diff:l()}),uncommitted:co({stat:l(),diff:l()}),hasCommits:t()}),z(`session-diff-error`,{id:R,message:l()}),z(`change-map`,{id:R,map:ji}),z(`send-diff-annotations-result`,{requestId:L,ok:t(),error:uo,pending:t().optional()}),z(`branch-sync-status`,{id:R,branch:B,upstream:B,state:l(),ahead:c().int().nonnegative(),behind:c().int().nonnegative(),fetched:t().nullable(),action:l().optional(),error:uo}),z(`session-changed`,{id:R}),z(`post-turn-result`,{id:R,mode:l(),skipped:B,filesFixed:c().int().nonnegative(),findings:p(co({file:l(),rule:l(),count:c().int().nonnegative()})),timestamp:V}),z(`debug-state-response`,{id:R,payload:fo}),z(`session-trace-response`,{id:R,requestId:L,records:p(fa),start:c().int().nonnegative(),next:c().int().nonnegative(),reset:t(),path:l()}),z(`session-trace-changed`,{id:R}),z(`session-plan-changed`,di.shape),z(`session-plan-draft`,fi.shape),z(`session-plan-response`,pi.shape),z(`session-docs-changed`,{id:R,docs:p(la)}),z(`session-docs-snapshot`,{sessions:i(l(),p(la))}),z(`session-doc-response`,{requestId:L,id:R,path:l(),ok:t(),text:l().optional(),hash:l().optional(),error:uo}),z(`session-doc-save-result`,{requestId:L,id:R,path:l(),ok:t(),hash:l().optional(),conflict:t().optional(),error:uo}),z(`session-coherence`,{id:R,...Bi.shape}),z(`session-coherence-snapshot`,{sessions:i(l(),Bi)}),z(`session-coherence-journal-response`,{requestId:L,id:R,ok:t(),entries:p(Ri).max(200),error:uo}),z(`session-setup-response`,{requestId:L,id:R,ok:t(),setup:ha.optional(),error:uo}),z(`notify`,{session:l(),category:l(),message:l(),escalationCount:c().int().nonnegative(),kind:m(`plan`).optional()}),z(`update-status`,jo),z(`update-progress`,{journal:xa}),z(`post-turn-leftovers`,{repositories:p(l()),command:l()}),z(`error`,{id:R.optional(),message:l(),requestId:L,scope:l().optional()}),z(`session-error`,{id:R.optional(),session:l(),message:l(),scope:l().optional()}),z(`settings`,{settings:fo,requestId:L}),z(`settings-error`,{message:l(),requestId:L}),z(`settings-updated`,{settings:fo,requestId:L}),z(`pong`,{requestId:L}),z(`agents-listed`,{requestId:L,agents:p(co({id:l(),label:l(),resolvable:t()}))}),z(`repo-roots-scanned`,{requestId:L,directories:p(co({root:l(),projects:p(co({name:l(),path:l(),isGit:t().optional()}))})),suggestions:p(co({path:l(),label:l(),gitRepoCount:c().int().nonnegative()})).optional(),error:l().optional()}),z(`conversations`,{requestId:L,id:B,current:B.optional(),conversations:p(co({id:l(),title:l(),cwd:l(),worktreePath:l(),worktreeName:l(),gitBranch:B,mtime:V})),error:l().optional()}),z(`resume-conversation-ack`,{id:R.optional(),resumeSessionId:B.optional(),ok:t(),error:l().optional(),requestId:L}),z(`health-snapshot`,{stats:fo}),z(`radar-status`,{ts:V,intervalMinutes:c(),projects:p(fo),investigations:p(fo)}),z(`radar-investigation-activity`,{projectId:a([l(),c()]),issueId:l(),inFlight:m(!0),startedAt:V.nullable(),trail:go}),z(`radar-investigation-finished`,{projectId:a([l(),c()]),issueId:l(),verdict:l(),summaryLine:B,startedAt:V.nullable(),trail:go}),z(`radar-report`,{requestId:L,ok:t(),found:t(),issueId:B,format:l().optional(),content:l().optional(),message:l().optional(),error:l().optional()}),z(`radar-open-session-result`,{requestId:L,ok:t(),error:uo,sessionId:l().optional(),sessionName:l().optional(),pending:t().optional()}),z(`issue-detail-result`,{requestId:l().min(1),ok:t(),body:l().nullable(),error:l().nullable()}),z(`open-issue-session-result`,{requestId:L,ok:t(),error:uo,sessionId:l().optional(),sessionName:l().optional(),pending:t().optional(),existing:t().optional()}),z(`open-team-review-session-result`,{requestId:L,ok:t(),error:uo,key:ao.optional(),sessionId:l().optional(),sessionName:l().optional(),pending:t().optional(),existing:t().optional()}),z(`radar-issue-action-result`,{requestId:L,ok:t(),error:uo,status:B.optional()}),z(`team-review-action-result`,{...Fe.shape,requestId:L}),z(`benchmark-action-result`,{...Xa.shape,requestId:L}),z(`my-pr-merge-result`,{...ht.shape,requestId:L}),z(`my-pr-keep-mergeable-result`,{...rt.shape,requestId:L}),z(`my-pr-merge-when-ready-result`,{...at.shape,requestId:L}),z(`github-polling-refresh-result`,{...C.shape,requestId:L}),z(`radar-archive-investigation-result`,{requestId:L,ok:t(),error:uo}),z(`telegram-test-result`,{requestId:L,ok:t(),error:uo,telegramDelivery:So.nullable()}),He,eo,ft,Rn,Wr,z(`usage-sessions`,{ts:V,pricingSource:B,sessions:p(co({id:R,tokens:c(),costUSD:c(),officialCostUSD:c().nullable().optional()}))}),z(`usage-report`,{requestId:L,ts:lo,tz:l().optional(),blockHours:c().optional(),totals:fo.optional(),daily:po.optional(),models:po.optional(),sessions:po.optional(),blocks:po.optional(),activeBlock:e().nullable().optional(),anomaly:e().nullable().optional(),byLane:e().optional(),planWindowLanes:e().nullable().optional(),budget:e().optional(),savings:e().optional(),tokenLimit:e().nullable().optional(),pricing:fo.optional(),scan:fo.optional(),warning:uo,error:uo}),z(`plan-limits`,{ts:V,fiveHour:e().nullable(),sevenDay:e().nullable(),source:l(),vendor:u([`claude`,`codex`]).optional()}),z(`usage-budget-alert`,{scope:l(),periodKey:l(),threshold:c(),text:l(),ts:V}),z(`visions-findings`,{uri:l(),diagnostics:po,ts:V}),z(`visions-comments`,{uri:l(),comments:po,ts:V}),z(`visions-hand`,{uri:l(),hand:B,ts:V}),z(`visions-intent`,{projectId:B,intent:fo,ts:V}),z(`visions-fix`,{uri:l(),fix:fo,ts:V}),z(`visions-snapshot`,{documents:p(fo),intent:fo,fixes:p(fo),ts:V}),z(`ingest-activity`,{events:p(fo),overflow:c().int().nonnegative(),ts:V}),z(`ingest-snapshot`,{events:p(fo),sources:e(),ts:V}),z(`client-trust`,{trust:u([`local`,`remote`])}),z(`shutting-down`),z(`restarting`)],Bo=d(`type`,zo),Vo=/^\s*at .+:\d+:\d+\)?$|^[^@\s]*@.+:\d+:\d+$/;function Ho(e){let t=e.stack??``,n=String(e);return(t.startsWith(n)?t.slice(n.length):t).split(`
2
- `).filter(e=>Vo.test(e)).join(`
3
- `)}function Uo(e){return e==null?null:e instanceof Error?{name:(e.name||`Error`).slice(0,128),stack:Ho(e).slice(0,Mo)}:{name:`NonError`,stack:``}}function Wo(e){let t=new Set;return n=>{let r=Uo(n);if(!r)return;let i=`${r.name}\n${r.stack}`;t.has(i)||t.size>=32||e({type:`client-error`,...r})&&t.add(i)}}var Go=[{name:`Nyan cat`,sprite:`is-cat`,trail:`is-rainbow`},{name:`Unicorn`,sprite:`is-unicorn`,trail:`is-sparkles`},{name:`Dragon`,sprite:`is-dragon`,trail:`is-embers`},{name:`Pig`,sprite:`is-pig`,trail:`is-hearts`},{name:`Whale`,sprite:`is-whale`,trail:`is-bubbles`},{name:`Fox`,sprite:`is-fox`,trail:`is-paws`},{name:`Frog`,sprite:`is-frog`,trail:`is-dust`},{name:`Penguin`,sprite:`is-penguin`,trail:`is-snow`},{name:`Bee`,sprite:`is-bee`,trail:`is-honey`},{name:`Owl`,sprite:`is-owl`,trail:`is-stars`},{name:`Cow`,sprite:`is-cow`,trail:`is-daisies`},{name:`Panda`,sprite:`is-panda`,trail:`is-bamboo`},{name:`Red panda`,sprite:`is-red-panda`,trail:`is-leaves`},{name:`Deer`,sprite:`is-deer`,trail:`is-acorns`},{name:`Horse`,sprite:`is-horse`,trail:`is-clover`},{name:`Sheep`,sprite:`is-sheep`,trail:`is-clouds`},{name:`Hamster`,sprite:`is-hamster`,trail:`is-seeds`},{name:`Giraffe`,sprite:`is-giraffe`,trail:`is-acacia`},{name:`Hedgehog`,sprite:`is-hedgehog`,trail:`is-logomarks`}],Ko=1/25,qo=3;function Jo(e,t,n){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(n.max,Math.max(n.min,e))}function Yo(e){if(!Array.isArray(e))return[];let t=new Set(Go.map(e=>e.sprite));return[...new Set(e.filter(e=>typeof e==`string`&&t.has(e)))]}function Xo(e={}){let t=Et,n=Ct,r=wt,i=Jo(e.flyingAnimalsMinGapSeconds,t.flyingAnimalsMinGapSeconds,n),a=Jo(e.flyingAnimalsMaxGapSeconds,t.flyingAnimalsMaxGapSeconds,n),o=Jo(e.flyingAnimalsMinDurationSeconds,t.flyingAnimalsMinDurationSeconds,r),s=Jo(e.flyingAnimalsMaxDurationSeconds,t.flyingAnimalsMaxDurationSeconds,r);return{flyingAnimalsMinGapSeconds:Math.min(i,a),flyingAnimalsMaxGapSeconds:Math.max(i,a),flyingAnimalsMinDurationSeconds:Math.min(o,s),flyingAnimalsMaxDurationSeconds:Math.max(o,s),flyingAnimalsScale:Jo(e.flyingAnimalsScale,t.flyingAnimalsScale,Tt),flyingAnimalsOnPhone:typeof e.flyingAnimalsOnPhone==`boolean`?e.flyingAnimalsOnPhone:t.flyingAnimalsOnPhone,flyingAnimalsExcludedSprites:Yo(e.flyingAnimalsExcludedSprites)}}function Zo(e){return Go.some(t=>!e.includes(t.sprite))}function Qo(e,t=-1,n=Math.random){let r=Go.flatMap((t,n)=>e.includes(t.sprite)?[]:[n]);if(r.length===0)return null;let i=r.length>1?r.filter(e=>e!==t):r,a=Math.min(1,Math.max(0,n()));return i[Math.min(i.length-1,Math.floor(a*i.length))]}function $o(e,t,n=Math.random,r){let i=r===void 0?Qo(e.flyingAnimalsExcludedSprites,t,n):Go.findIndex(e=>e.sprite===r);if(i===null||i<0)return null;let a=e.flyingAnimalsMinDurationSeconds+n()*(e.flyingAnimalsMaxDurationSeconds-e.flyingAnimalsMinDurationSeconds),o=1e3*(e.flyingAnimalsMinGapSeconds+n()*(e.flyingAnimalsMaxGapSeconds-e.flyingAnimalsMinGapSeconds)),s=n()*a,c=n(),l=n()<.5,u=n()<Ko?qo:1;return{animalIndex:i,durationSeconds:a,gapMs:o,firstDelaySeconds:s,verticalProgress:c,isRightToLeft:l,arcProgress:(n()*2-1)*u}}function es({isEnabled:e,hasReducedMotion:t,isPhone:n,options:r}){return t?`Flights are disabled because reduced motion is enabled.`:e?n&&!r.flyingAnimalsOnPhone?`Turn on Show on phone layout to use Fly now here.`:null:`Turn on flying animals to use Fly now.`}var ts=68,ns=42,rs=768,is=.68,as=64,os=5,ss=8,cs=85;function ls(e,t,n){return Math.min(Math.max(e,t),n)}function us({viewportWidthPx:e,viewportHeightPx:t,verticalProgress:n,isRightToLeft:r=!1,arcProgress:i=0}){let a=ls(e/rs,is,1),o=(os+70*n*n)*t/100,s=Math.max(o,as),c=cs*t/100,l=ls(i*ss*t/100,as-s,c-s),u=-.45*e,d=1.45*e;return{scale:a,spriteWidthPx:ts,spriteHeightPx:ns,topPx:s,startXpx:r?d:u,endXpx:r?u:d,facing:r?-1:1,arcPx:l}}function ds(e,t){let n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.round(e*n))/n}function fs(e,t,n){let r=ds(e.scale*t,n);return[[`--nyan-top`,`${e.topPx}px`],[`--nyan-scale`,String(r)],[`--nyan-width`,`${e.spriteWidthPx}px`],[`--nyan-height`,`${e.spriteHeightPx}px`],[`--nyan-start-x`,`${e.startXpx}px`],[`--nyan-end-x`,`${e.endXpx}px`],[`--nyan-facing`,String(e.facing)],[`--nyan-arc`,`${e.arcPx}px`],[`--nyan-travel`,`${Math.abs(e.endXpx-e.startXpx)/r}px`]]}var ps=`chime`,ms=`custom:`,hs=`/custom-sounds`,gs=Object.freeze({chime:{label:`Chime`,peakGain:.12,tones:[{frequency:659.25,startSeconds:0,durationSeconds:.35,waveform:`sine`},{frequency:987.77,startSeconds:.14,durationSeconds:.5,waveform:`sine`}]},ping:{label:`Soft ping`,peakGain:.08,tones:[{frequency:1046.5,startSeconds:0,durationSeconds:.12,waveform:`triangle`},{frequency:1046.5,startSeconds:.13,durationSeconds:.12,waveform:`triangle`},{frequency:1318.51,startSeconds:.26,durationSeconds:.2,waveform:`triangle`}]},beep:{label:`Beep`,peakGain:.15,tones:[{frequency:880,startSeconds:0,durationSeconds:.2,waveform:`sine`}]}}),_s=Object.freeze(Object.entries(gs).map(([e,t])=>({id:e,label:t.label})));function vs(e){return`${ms}${e}`}function ys(e){return`${hs}/${encodeURIComponent(e)}`}function bs(e){return e.startsWith(ms)&&e.slice(7)||null}function xs(e){let t=(e??[]).map(e=>({id:vs(e),label:e}));return[..._s,...t]}function Ss(e,t){if(typeof e!=`string`)return ps;if(Object.hasOwn(gs,e))return e;let n=bs(e);return n&&(t===null||t.includes(n))?e:ps}function Cs(e){return typeof e!=`object`||!e||!(`sounds`in e)||!Array.isArray(e.sounds)?[]:e.sounds.filter(e=>typeof e==`string`&&e!==``)}function ws(e,t){try{let n=localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}}function Ts(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}var Es=`glimmervoid-ui-prefs`,Ds=`glimmervoid:sidebar-width`,Os=e=>t=>typeof t==`boolean`?t:e,ks=e=>t=>typeof t==`string`?t:e,As=e=>typeof e==`string`&&e?e:null,js=e=>typeof e==`number`&&Number.isFinite(e)?e:null,Ms=e=>t=>js(t)??e,Ns=e=>Array.isArray(e)?[...new Set(e.filter(e=>typeof e==`string`&&e!==``))]:[],Ps={soundEnabled:Os(!0),soundId:ks(ps),themeId:ks(`phyrexian`),flyingAnimalsEnabled:Os(!1),flyingAnimalsMinGapSeconds:Ms(Et.flyingAnimalsMinGapSeconds),flyingAnimalsMaxGapSeconds:Ms(Et.flyingAnimalsMaxGapSeconds),flyingAnimalsMinDurationSeconds:Ms(Et.flyingAnimalsMinDurationSeconds),flyingAnimalsMaxDurationSeconds:Ms(Et.flyingAnimalsMaxDurationSeconds),flyingAnimalsScale:Ms(Et.flyingAnimalsScale),flyingAnimalsOnPhone:Os(Et.flyingAnimalsOnPhone),flyingAnimalsExcludedSprites:Yo,notificationsEnabled:Os(!0),sessionUsageChips:Os(!1),phoneArrowPad:Os(!1),activeView:ks(`focus`),lastFocusedSessionId:As,railWidth:js,reviewSidebarExpanded:Os(!1),reviewSidebarView:e=>e===`map`||e===`notes`?e:`diff`,prsQueueWidth:js,prsQueueCollapsed:Os(!1),prsMode:e=>e===`mine`?`mine`:`team`,keptProjects:Ns,traceHiddenKinds:Ns,dismissedUpdate:As,telemetryNoticeDismissed:Os(!1),radarAttentionAck:ks(``),prsAttentionAck:ks(``),prsUnseenRows:ks(``),usageAttentionAck:ks(``),visionsAttentionAck:ks(``)};function Fs(e,t,n){e[t]=Ps[t](n)}function Is(){let e=ws(Es,{}),t={};for(let n of Object.keys(Ps))Fs(t,n,e?.[n]);return t}function Ls(e){return Is()[e]}function H(e,t){let n=Is();Fs(n,e,t),Ts(Es,n)}var Rs=()=>Ls(`soundEnabled`),zs=e=>H(`soundEnabled`,e),Bs=()=>Ls(`soundId`),Vs=e=>H(`soundId`,e),Hs=()=>Ls(`notificationsEnabled`),Us=e=>H(`notificationsEnabled`,e),Ws=()=>Ls(`sessionUsageChips`),Gs=e=>H(`sessionUsageChips`,e),Ks=()=>Ls(`phoneArrowPad`),qs=e=>H(`phoneArrowPad`,e),Js=()=>Ls(`themeId`),Ys=e=>H(`themeId`,e),Xs=()=>Ls(`flyingAnimalsEnabled`),Zs=e=>H(`flyingAnimalsEnabled`,e),Qs=()=>Ls(`activeView`),$s=e=>H(`activeView`,e),ec=()=>Ls(`railWidth`),tc=e=>H(`railWidth`,e),nc=()=>Ls(`reviewSidebarExpanded`),rc=e=>H(`reviewSidebarExpanded`,e),ic=()=>Ls(`reviewSidebarView`),ac=e=>H(`reviewSidebarView`,e),oc=()=>Ls(`prsQueueWidth`),sc=e=>H(`prsQueueWidth`,e),cc=()=>Ls(`prsQueueCollapsed`),lc=e=>H(`prsQueueCollapsed`,e),uc=()=>Ls(`prsMode`),dc=e=>H(`prsMode`,e),fc=()=>Ls(`keptProjects`),pc=e=>H(`keptProjects`,e),mc=()=>Ls(`traceHiddenKinds`),hc=e=>H(`traceHiddenKinds`,e),gc=()=>Ls(`dismissedUpdate`),_c=e=>H(`dismissedUpdate`,e),vc=()=>Ls(`telemetryNoticeDismissed`),yc=e=>H(`telemetryNoticeDismissed`,e),bc=()=>Ls(`radarAttentionAck`),xc=e=>H(`radarAttentionAck`,e),Sc=()=>Ls(`prsAttentionAck`),Cc=e=>H(`prsAttentionAck`,e),wc=()=>Ls(`prsUnseenRows`),Tc=e=>H(`prsUnseenRows`,e),Ec=()=>Ls(`usageAttentionAck`),Dc=e=>H(`usageAttentionAck`,e),Oc=()=>Ls(`visionsAttentionAck`),kc=e=>H(`visionsAttentionAck`,e),Ac=()=>Ls(`lastFocusedSessionId`),jc=e=>H(`lastFocusedSessionId`,e),Mc=()=>js(ws(Ds,null)),Nc=e=>Ts(Ds,js(e)),Pc=e=>H(`flyingAnimalsMinGapSeconds`,e),Fc=e=>H(`flyingAnimalsMaxGapSeconds`,e),Ic=e=>H(`flyingAnimalsMinDurationSeconds`,e),Lc=e=>H(`flyingAnimalsMaxDurationSeconds`,e),Rc=e=>H(`flyingAnimalsScale`,e),zc=e=>H(`flyingAnimalsOnPhone`,e),Bc=e=>H(`flyingAnimalsExcludedSprites`,e),Vc=()=>Xo(Is()),Hc=()=>{let e=Is();return Object.fromEntries(Object.keys(Et).map(t=>[t,e[t]]))},Uc=()=>Ts(Es,{...Is(),...Et}),Wc=us({viewportWidthPx:1440,viewportHeightPx:900,verticalProgress:0});function Gc(e,t=``){let n=M(`div`,`flying-animal-preview ${t}`.trim());n.setAttribute(`aria-hidden`,`true`),n.style.setProperty(`--nyan-width`,`${Wc.spriteWidthPx}px`),n.style.setProperty(`--nyan-height`,`${Wc.spriteHeightPx}px`);let r=M(`div`,`flying-animal-preview-stage`);return r.append(M(`div`,`nyan-trail ${e.trail}`),M(`div`,`nyan-sprite ${e.sprite}`)),n.append(r),n}function Kc(){let e=Qo(Vc().flyingAnimalsExcludedSprites);return e===null?null:Go[e]??null}var qc=6e4,Jc=18e5,Yc=20;function Xc({attempt:e=1,baseMs:t=qc,maxMs:n=Jc,retryAfterMs:r=null,random:i=Math.random,jitter:a=`full`}={}){if(typeof r==`number`&&Number.isFinite(r)&&r>0)return Math.min(r,n);let o=Math.max(0,Math.min(e,Yc)-1),s=Math.min(n,t*2**o);return a===`none`?s:Math.round(a===`half`?s*(.5+.5*i()):i()*s)}var Zc=3e4;function Qc(e,t=Math.random){return Xc({attempt:(typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):0)+1,baseMs:500,maxMs:Zc,random:t,jitter:`half`})}var $c=0,el=1;function tl({hasSocket:e,readyState:t,retryPending:n,connectingAgeMs:r=0}){return n?`retry-now`:e?t===$c?r>1e4?`connect`:`wait`:t===el?`probe`:`connect`:`connect`}function nl(e){return e===`https:`?`wss:`:`ws:`}function rl(e,t){return`${nl(e?.protocol)}//${e.host}${t}`}var il=``,al=null;function ol(){return il}function sl(){return il?Promise.resolve(il):al||(al=fetch(`/control-token`,{credentials:`same-origin`,cache:`no-store`}).then(e=>e.ok?e.json():null).then(e=>{let t=e?.token;return il=typeof t==`string`?t:``,il}).catch(()=>``).finally(()=>{al=null}),al)}function cl(){il=``}function ll(e){return il?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(il)}`:e}function U(e,t){return typeof e==`string`&&e.trim()?e.trim():t}function W(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}var ul=60,dl=3600,fl=24,pl=1024,ml=pl*1024,hl=ml*1024,gl={compact:{second:e=>`${e}s`,minute:e=>`${e}m`,hour:e=>`${e}h`,day:e=>`${e}d`},abbreviated:{second:e=>`${e} sec`,minute:e=>`${e} min`,hour:e=>`${e} hr`,day:e=>`${e} ${e===1?`day`:`days`}`},spelled:{second:e=>`${e} ${e===1?`second`:`seconds`}`,minute:e=>`${e} ${e===1?`minute`:`minutes`}`,hour:e=>`${e} ${e===1?`hour`:`hours`}`,day:e=>`${e} ${e===1?`day`:`days`}`}},_l={rounding:`floor`,wording:`compact`,suffix:` ago`,justNowBelowSeconds:0};function vl(e){return String(e).padStart(2,`0`)}function yl(e,t){return Math.max(0,Math[t](e/1e3))}function bl(e,t){let n=gl[t];if(e<ul)return n.second(e);let r=Math.floor(e/ul);if(r<60)return n.minute(r);let i=Math.floor(r/60);return i<fl?n.hour(i):n.day(Math.floor(i/fl))}function xl(e,t){let n=yl(e,t.rounding);return n<t.justNowBelowSeconds?`just now`:`${bl(n,t.wording)}${t.suffix}`}function Sl(e,{smallestUnit:t,dropsZeroRemainder:n}){let r=(e,t,r)=>n&&t===0?e:`${e} ${t}${r}`;if(t===`s`&&e<ul)return`${e}s`;if(t===`s`&&e<dl)return r(`${Math.floor(e/ul)}m`,e%ul,`s`);let i=Math.floor(e/ul);return i<60?`${i}m`:r(`${Math.floor(i/60)}h`,i%60,`m`)}function Cl(e,{rounding:t,showsHours:n}){let r=yl(e,t),i=vl(r%ul),a=Math.floor(r/ul),o=Math.floor(r/dl);return!n||o===0?`${a}:${i}`:`${o}:${vl(a%60)}:${i}`}function wl(e,t){return e<pl?`${e} B`:t===`KB`||e<ml?`${(e/pl).toFixed(1)} KB`:e<hl?`${(e/ml).toFixed(1)} MB`:`${(e/hl).toFixed(2)} GB`}function Tl(e){let t=new Date(e);return`${t.getFullYear()}-${vl(t.getMonth()+1)}-${vl(t.getDate())}`}function El(e){return`${vl(e.getHours())}:${vl(e.getMinutes())}`}function Dl(e){return e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Ol(e){let t=(Array.isArray(e)?e:[]).filter(e=>typeof e==`string`&&e!==``);return[...new Set(t)].sort().join(`|`)}function kl(e,t){let n=typeof e==`string`?e:``,r=typeof t==`string`?t:``;return n===``?{shown:!1,acknowledged:``}:{shown:n!==r,acknowledged:r}}function Al({getAck:e,setAck:t,signature:n,isLooking:r}){let i=e(),a=e=>{e!==i&&(i=e,t(e))};return{refresh(){let e=n(),t=kl(e,r()?e:i);return a(t.acknowledged),t.shown},acknowledge(){a(n())}}}function jl(e,{label:t}){if(!e)return`Waiting for ${t} status from the server.`;let n=typeof e.reason==`string`?e.reason.trim():``;return e.configured===!1&&n?`${t} is misconfigured: ${n}.`:e.configured===!1?`${t} is off.`:`${t} is on. Waiting for the first poll.`}var Ml=`machine-updates`,Nl=`update-actions`,Pl={spiking:0,regressed:1,worsened:2,new:3,quiet:4},Fl={spiking:`crit`,regressed:`crit`,worsened:`warn`,new:`warn`,quiet:`dim`},Il=99,Ll={ROOT_CAUSE:`root cause`,NEEDS_HUMAN:`needs you`,TRANSIENT:`transient`,FIXED:`fixed`,ERROR:`error`};function Rl(e){return Array.isArray(e)?e.flatMap(e=>{let t=e,n=W(t?.at,0),r=U(t?.note,``);if(r)return[{at:n,note:r}];let i=U(t?.tool,``);return i?[{at:n,tool:i,detail:U(t?.detail,``)}]:[]}):[]}function zl(e){return e.filter(e=>`tool`in e)}function Bl(e){return e.detail?`${e.tool} ${e.detail}`:e.tool}function Vl(e){let t=Rl(e?.trail),n=t.findLast(e=>`note`in e);if(n)return n.note;let r=zl(t).at(-1);return r?Bl(r):``}function Hl(e){let t=[];for(let n of e){if(`note`in n){t.push({kind:`note`,at:n.at,text:n.note});continue}let e=t.at(-1);e?.kind===`work`?e.stepCount+=1:t.push({kind:`work`,at:n.at,stepCount:1})}return t}function Ul(e){let t=U(e?.summaryLine,``);return e?.inFlight===!0&&Vl(e)||t}function Wl(e){return{inFlight:e?.inFlight===!0,startedAt:W(e?.startedAt,null),steps:Rl(e?.trail),verdict:U(e?.verdict,``),summaryLine:U(e?.summaryLine,``)}}function Gl(e,t,n){let r=String(t??``),i=String(n??``);if(!r||!i)return null;for(let t of Array.isArray(e?.projects)?e.projects:[])if(String(t?.projectId??``)===r){for(let e of Array.isArray(t.issues)?t.issues:[])if(String(e?.issueId??``)===i)return e}return null}function Kl(e,t){let n=Gl(e,t?.projectId,t?.issueId);return n?(n.inFlight=!0,n.startedAt=W(t?.startedAt,null),n.trail=Rl(t?.trail),!0):!1}function ql(e){return{inFlight:!1,startedAt:W(e?.startedAt,null),steps:Rl(e?.trail),verdict:U(e?.verdict,``),summaryLine:U(e?.summaryLine,``)}}function Jl(e,t){return!e||!t?!1:String(t.projectId??``)===e.projectId&&String(t.issueId??``)===e.issueId}function Yl(e,t){let n=Gl(e,t?.projectId,t?.issueId);if(!n)return!1;let r=ql(t);return n.inFlight=!1,n.startedAt=r.startedAt,n.trail=r.steps,n.verdict=r.verdict,n.summaryLine=r.summaryLine,!0}function Xl(e){return Ll[typeof e==`string`?e.toUpperCase():``]||String(e??``).toLowerCase()}function Zl(e){return Cl(e,{rounding:`round`,showsHours:!1})}function Ql(e,t){return e==null?``:`+${Zl(t-e)}`}function $l(e){let t=e.steps.at(-1),n=t&&`tool`in t?t.tool:t?.note??``;return[e.steps.length,t?.at??0,n].join(`::`)}function eu(e,t){if(e.inFlight){let n=zl(e.steps).length,r=`${n} ${n===1?`step`:`steps`}`;return`investigating, ${e.startedAt?`started ${t}`:`starting`}, ${r}`}return e.verdict?`finished: ${Xl(e.verdict)}`:`finished`}function tu(e){return jl(e,{label:`PostHog monitoring`})}function nu(e){return W(e.intervalMinutes,null)!==null}function ru(e,t){return e==null||e.configured===!1?`placeholder`:t>0?`ready`:nu(e)?`placeholder`:`pending`}function iu(e){return Fl[e??``]||`dim`}function au(e){if(typeof e?.lastSeen!=`string`)return null;let t=Date.parse(e.lastSeen);return!Number.isFinite(t)||t<=0?null:t}function ou(e){let t=U(e?.status,``).trim().toLowerCase();return!t||t===`active`?``:t}function su(e){return Array.isArray(e)?e.map(e=>Number(e)).filter(e=>Number.isFinite(e)):[]}function cu(e){return Array.isArray(e)?e.map(e=>typeof e==`number`?e:Number(e?.occurrences)).filter(e=>Number.isFinite(e)):[]}function lu(e,t=64,n=16){let r=su(e);if(r.length<2)return``;let i=Math.max(...r),a=Math.min(...r),o=t/(r.length-1),s=n/2,c=i-a;return r.map((e,t)=>{let r=t*o,i=c===0?s:n-(e-a)/c*n;return`${Number(r.toFixed(2))},${Number(i.toFixed(2))}`}).join(` `)}function uu(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0);if(n===0)return null;let r=e.slice(-t).reduce((e,t)=>e+t,0),i=Math.round(Math.abs(r-n)/Math.abs(n)*100);return r>n?{direction:`up`,percent:i}:r<n?{direction:`down`,percent:i}:{direction:`flat`,percent:i}}function du(e){return e.length===0?`0 polls, 0 to 0 occurrences`:`${e.length} polls, ${Math.min(...e)} to ${Math.max(...e)} occurrences`}function fu(e){let t=Array.isArray(e)?e:[],n=0,r=0;for(let e of t)e?.change===`spiking`&&(n+=1),e?.verdict===`NEEDS_HUMAN`&&(r+=1);return{active:t.length,spiking:n,needsHuman:r}}var pu=3e5;function mu(e){let t=Number(e);return!Number.isFinite(t)||t<=0?pu:t*2}function hu(e){let t=e.split(/[\\/]+/).filter(Boolean);return t.length===0?``:t[t.length-1]}function gu(e){let t=hu(U(e?.name,``));if(t)return t;let n=e?.projectId;return n==null||n===``?`project`:String(n)}function _u(e){let t=U(e,``);return t?(t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).split(`/`)[0].split(`@`).pop()??``).replace(/:\d+$/,``):``}function vu(e){let t=new Set,n=Array.isArray(e)?e:[];for(let e of n){let n=_u(e?.host);n&&t.add(n)}return t.size>1}function yu(e,t,n={}){let r=fu(e?.issues),i=U(e?.error,``).slice(0,200),a=Number(t),o=Number(e?.lastTickAt),s=Number.isFinite(a)&&Number.isFinite(o)&&o>0?a-o:0,c=s>mu(n.intervalMs)?s:0;return{loud:r.active>0||r.spiking>0||!!i||c>0,counts:r,error:i,staleMs:c}}function bu(e,t,n={}){let r=[],i=[],a=Array.isArray(e)?e:[];for(let e of a){let a=yu(e,t,n),o={project:e,...a};a.loud?r.push(o):i.push(o)}return{loud:r,quiet:i}}function xu(e,t=null){return(Array.isArray(e?.investigations)?e.investigations:[]).filter(e=>typeof e==`object`&&!!e).filter(e=>typeof e.id==`string`&&e.id!==``).filter(e=>e.archived!==!0).filter(e=>!t?.has(e.id)).map(e=>({id:e.id,issueId:U(e.issueId,``),projectId:e.projectId??null,projectLabel:U(e.projectName,``),title:U(e.title,`Untitled issue`),summaryLine:U(e.summaryLine,``),url:U(e.url,``),verdict:U(e.verdict,`ERROR`).toUpperCase(),mode:U(e.mode,`investigate`),prUrl:/^https:\/\/[^\s"'<>]{1,300}$/.test(U(e.prUrl,``))?U(e.prUrl,``):``,at:Number.isFinite(Number(e.at))?Number(e.at):0})).sort((e,t)=>t.at-e.at)}function Su(e,t){if(!t||t.size===0)return t;let n=Array.isArray(e?.investigations)?e.investigations:[],r=new Set;for(let e of n){if(typeof e!=`object`||!e)continue;let{id:t}=e;typeof t==`string`&&r.add(t)}for(let e of[...t])r.has(e)||t.delete(e);return t}function Cu(e,t){let n=U(e,``);if(n)return/^\d/.test(n)?`v${n}`:n;let r=T(t,{validate:!0});return r?`commit ${r}`:``}function wu(e){return`Update available: ${Cu(e?.current,e?.currentSha)} to ${Cu(e?.latest,e?.latestSha)}`}function Tu({posthog:e}={}){let t=[],n=Array.isArray(e?.projects)?e.projects:[];for(let e of n){let n=U(e?.projectId,U(e?.name,`project`)),r=Array.isArray(e?.issues)?e.issues:[];for(let e=0;e<r.length;e++){let i=r[e],a=U(i?.issueId,U(i?.title,`#${e}`));i?.change===`spiking`&&t.push(`issue:${n}/${a}:spiking`),i?.verdict===`NEEDS_HUMAN`&&t.push(`issue:${n}/${a}:needs-human`)}}return t}function Eu(e={}){return Ol(Tu(e))}function Du(e){return Pl[e??``]??Il}function Ou(e){return Array.isArray(e)?e.map((e,t)=>({issue:e,index:t})).sort((e,t)=>{let n=Du(e.issue?.change)-Du(t.issue?.change);if(n!==0)return n;let r=W(t.issue?.users,0)-W(e.issue?.users,0);if(r!==0)return r;let i=W(t.issue?.occurrences,0)-W(e.issue?.occurrences,0);return i===0?e.index-t.index:i}).map(e=>e.issue):[]}var ku=Object.freeze({fetch:`Fetch`,stage:`Stage`,install:`Install dependencies`,"link-deps":`Link dependencies`,build:`Build`}),Au=Object.freeze({"branch-count-unavailable":`The last check could not compare the checked-out branch with its upstream.`,"branch-diverged":`The checked-out branch has diverged from its upstream.`,"fetch-failed":`The last update check could not fetch the upstream branch.`,"main-channel-requires-clone":`The main channel requires a clone install.`,"no-branch":`The last update check found no checked-out branch.`,"no-upstream":`The checked-out branch has no upstream.`,"release-already-checked-out":`The checkout already contains the latest release. Restart to run it.`,"release-check-failed":`The last release check failed.`,"remote-tip-unavailable":`The last update check could not resolve the upstream branch tip.`,"update-check-failed":`The last update check failed.`}),ju=Object.freeze([`unsupported-flavor`,`unsupported-platform`]),G=`Not connected to the server. Reconnecting.`,Mu=Object.freeze({requested:!1,failure:null});function Nu(e){return e.replace(/^\[[^\]]+\]\s*/,``)}function Pu(e,t,n=null){return t===`request-sent`?{requested:!0,failure:null}:t===`request-unsent`?{requested:!1,failure:G}:t===`progress-frame`?Mu:t===`error-frame`?e.requested?{requested:!1,failure:n}:e:e.failure===null?e:{requested:e.requested,failure:null}}function Fu(e,t){return t?.state?t.state:e?.journalSummary?.state}function Iu(e,t=null,n=null){return{actions:e,note:t,command:n}}function Lu(e){let t=e?.applyRefusal;return t?ju.includes(t.reason):!1}function Ru({status:e,journal:t,request:n=Mu}){if(n.failure===`Not connected to the server. Reconnecting.`)return Iu([],G);let r=zu(Fu(e,t),e,n.requested);return n.failure?{...r,note:n.failure}:r}function zu(e,t,n){if(e===`running`||n)return Iu([]);if(e===`staged`)return Iu([`restart`]);if(!t?.updateAvailable)return Iu([`check`]);let r=t.applyRefusal;return r?r.reason===`target-already-checked-out`?Iu([`restart`],r.message):Lu(t)?Iu([`check`],r.message,U(t.command,null)):Iu([`check`],r.message):Iu([`update`])}function Bu(e){return e?.journalSummary?.state===`staged`||e?.applyRefusal?.reason===`target-already-checked-out`}function Vu(e){let t=U(e?.deprecation,null);return t?`Security notice: ${Cu(e?.current,e?.currentSha)||`This version`} is marked unsafe. ${t}`:null}function Hu(e){let t=Cu(e?.latest,e?.latestSha)||`A new version`;if(Bu(e))return{mode:`restart`,text:`${t} is ready. Restart to update, or it installs on the next start.`};if(e?.journalSummary?.state===`running`)return{mode:`link`,text:`Downloading ${t} in the background.`};let n=wu(e);return!e||e.applyRefusal===void 0||Lu(e)?{mode:`command`,text:n}:{mode:`link`,text:n}}function Uu(e){let t=Hu(e),n=Vu(e);return n?Bu(e)||e?.journalSummary?.state===`running`?{mode:t.mode,tone:`security`,text:`${n} ${t.text}`}:{mode:`command`,tone:`security`,text:n}:{...t,tone:`update`}}function Wu(e){let t=U(e,``);return t?`: ${t}`:``}var Gu=new Set([`idle`,`staged`,`succeeded`,`discarded`]);function Ku(e){return e.state===`failed`?`Update failed${Wu(e.reason)}.`:e.state===`interrupted`?`Update interrupted${Wu(e.reason)}.`:null}function qu(e){return ku[e]??e}function Ju(e){let t=e.steps.find(t=>t.id===e.activeStep);if(t&&t.outputTail.length>0)return{stepId:t.id,lines:t.outputTail};let n=e.steps.findLast(e=>e.outputTail.length>0);return n?{stepId:n.id,lines:n.outputTail}:{stepId:null,lines:[]}}function Yu(e){if(!e||Gu.has(e.state))return null;let t=Ju(e),n=t.stepId!==null&&t.stepId!==e.activeStep?t.stepId:null;return{state:e.state,terminalLine:Ku(e),steps:e.steps.map(e=>({id:e.id,label:qu(e.id),status:e.status})),outputTail:t.lines,outputStepId:t.stepId,outputStepLabel:n===null?null:qu(n)}}var Xu=6e5;function Zu(e){return e.channel!==`main`||!Number.isInteger(e.behindCount)?``:`${e.behindCount} ${e.behindCount===1?`commit`:`commits`} behind`}function Qu(e,t){let n=Fu(e,t),r=Cu(t?.toVersion,t?.toSha)||Cu(e?.latest,e?.latestSha)||`the update`;if(n===`running`)return{tone:`running`,headline:`Downloading ${r} in the background. Glimmervoid keeps running.`};if(n===`staged`)return{tone:`staged`,headline:`${r} is ready. Restart to update now, or it installs on the next start.`};if(!e)return{tone:`unknown`,headline:`No update check has run yet.`};let i=Vu(e);if(i)return{tone:`security`,headline:i};let a=Cu(e.current,e.currentSha)||`an unknown version`;if(e.updateAvailable){let t=Cu(e.latest,e.latestSha)||`a newer build`,n=Zu(e);return{tone:`available`,headline:`Update available: ${a} to ${t}${n?` (${n})`:``}.`}}return U(e.reason,``)?{tone:`unknown`,headline:`Running ${a}. The last check did not finish.`}:{tone:`current`,headline:`Up to date. Running ${a}.`}}function $u(e){if(!e)return`Update status unavailable.`;let t=Cu(e.current,null)||`Unknown version`,n=T(e.currentSha,{validate:!0}),r=U(e.installedBranch,``);return[t,[n?`commit ${n}`:``,r?`on ${r}`:``].filter(Boolean).join(` `),e.isTreeClean===!0?`clean checkout`:e.isTreeClean===!1?`uncommitted local changes`:``].filter(Boolean).join(`, `)}function ed(e){return e?{label:Cu(e.latest,e.latestSha)||`Latest target unknown`,behind:Zu(e),releaseUrl:U(e.releaseUrl,``)}:{label:`Update status unavailable.`,behind:``,releaseUrl:``}}function td({status:e,checkForUpdates:t,now:n,lastAutoCheckAt:r}){if(t===!1||r!==null&&n-r<Xu)return!1;let i=typeof e?.lastCheckAt==`number`?e.lastCheckAt:null;return i===null||n-i>=Xu}function nd({status:e,checkForUpdates:t,relativeTime:n}){if(t===!1)return`Update checks are off.`;if(!e)return`No update check has run.`;let r=U(e.reason,``);return r?Au[r]??`The last update check failed: ${r}.`:e.flavor===`unknown`?`The install flavor is unknown.`:n}var rd=null,id=null,ad=0,od=new Map,sd=null,cd=0,ld=!1,ud=0,dd=0,fd=null,pd=null;function md(e){pd=e}function hd(e){fd=e}function K(e){return rd?.readyState===WebSocket.OPEN&&(rd.send(JSON.stringify(e)),!0)}function gd(e){return dd+=1,`${e}-${dd}`}function _d(e,t,{timeoutMs:n=5e3}={}){let r=gd(e);return new Promise((i,a)=>{let o=setTimeout(()=>{od.delete(r),a(Error(`Request timed out`))},n);od.set(r,{resolve:i,reject:a,timer:o}),rd?.readyState===WebSocket.OPEN?rd.send(JSON.stringify({type:e,requestId:r,...t})):(clearTimeout(o),od.delete(r),a(Error(G)))})}function vd(e){if(typeof e!=`object`||!e||!(`requestId`in e))return;let t=e.requestId;if(typeof t!=`string`)return;let n=od.get(t);n&&(clearTimeout(n.timer),od.delete(t),n.reject(Error(`The server sent a reply this dashboard could not read. Reload the page to pick up the current version.`)))}function yd(e){for(let t of od.values())clearTimeout(t.timer),t.reject(Error(e));od.clear()}function bd(){let e=rd;rd=null,yd(G),pd&&pd(`disconnected`,`Reconnecting`),e?.close(),ad=0,xd()}function xd(){if(id!==null&&(id!==null&&clearTimeout(id),id=null),!ol()&&!ld){ld=!0,sl().finally(()=>{ld=!1,xd()});return}if(ld)return;let e=ud>0?`?since=${ud}`:``,t=rl(location,ll(`/control${e}`)),n=new WebSocket(t);rd=n,cd=Date.now();let r=!1;n.addEventListener(`open`,()=>{r=!0,ad=0,pd&&pd(`connected`,`Connected`)}),n.addEventListener(`message`,e=>{if(rd!==n)return;let t;try{t=JSON.parse(e.data)}catch{console.warn(`[control] Dropped malformed server JSON message`);return}let r=Bo.safeParse(t);if(!r.success){console.warn(`[control] Dropped invalid server message: ${r.error.issues[0]?.message||`invalid payload`}`),vd(t);return}let i=r.data;if(i.type===`snapshot`&&typeof i.seq!=`number`&&(ud=0),typeof i.seq==`number`){if(i.seq<=ud)return;ud=i.seq}let a=typeof i.requestId==`string`?i.requestId:``,o=a?od.get(a):void 0;o?(clearTimeout(o.timer),od.delete(a),o.resolve(i)):fd&&fd(i)}),n.addEventListener(`close`,()=>{if(rd!==n)return;rd=null,yd(G),r||cl(),pd&&pd(`disconnected`,`Reconnecting`);let e=Qc(ad);ad+=1,id=setTimeout(xd,e)})}async function Sd(){if(pd&&pd(`connecting`,`Connecting`),sd)return sd;let e=tl({hasSocket:!!rd,readyState:rd?.readyState??null,retryPending:id!==null,connectingAgeMs:Date.now()-cd});if(e===`retry-now`)return id!==null&&clearTimeout(id),id=null,ad=0,xd(),`reconnecting`;if(e===`connect`)return bd(),`reconnecting`;if(e===`wait`)return`reconnecting`;let t=rd;return sd=_d(`ping`,{}).then(()=>(pd&&pd(`verified`,`Connected`),`ok`)).catch(()=>(rd===t&&t&&bd(),`dead`)).finally(()=>{sd=null}),sd}var Cd=`<h2 class="dialog-title" id="add-session-title">Add Session</h2>
4
- <fieldset class="dialog-mode-controls" aria-label="Session kind">
5
- <button type="button" class="dialog-mode-button" id="add-session-single-mode" aria-pressed="true">Single repo</button>
6
- <button type="button" class="dialog-mode-button" id="add-session-workspace-mode" aria-pressed="false">Workspace</button>
7
- </fieldset>
8
- <label class="dialog-label" id="add-session-picker-label">
9
- Pick a project:
10
- <select class="dialog-input project-picker" id="add-session-picker">
11
- <option value="" disabled selected>Scanning...</option>
12
- </select>
13
- </label>
14
- <fieldset class="dialog-workspace-list" id="add-session-workspace-list" aria-label="Workspace repositories" hidden></fieldset>
15
- <div class="dialog-repo-roots" id="add-session-repo-roots" hidden>
16
- <p class="dialog-repo-roots-title" id="add-session-repo-roots-title">No repository roots yet</p>
17
- <p class="dialog-repo-roots-desc">Add the folder that holds your git checkouts. Its repos show up right here.</p>
18
- </div>
19
- <label class="dialog-label" id="add-session-agent-label" hidden>
20
- Agent
21
- <select class="dialog-input" id="add-session-agent"></select>
22
- </label>
23
- <label class="dialog-label" id="add-session-environment-label" hidden>
24
- Environment
25
- <select class="dialog-input" id="add-session-environment"></select>
26
- <span class="dialog-hint" id="add-session-environment-hint" hidden></span>
27
- </label>
28
- <div class="dialog-label" id="add-session-agent-login" hidden>
29
- <span class="dialog-hint" id="add-session-agent-login-text"></span>
30
- <button type="button" class="btn-dialog btn-dialog-cancel" id="add-session-agent-connect">Connect</button>
31
- </div>
32
- <button type="button" class="dialog-advanced-toggle" id="add-session-advanced-toggle" aria-controls="add-session-advanced">Run in a folder outside your repository roots</button>
33
- <div class="dialog-advanced-panel" id="add-session-advanced" hidden>
34
- <label class="dialog-label">
35
- Name
36
- <input type="text" class="dialog-input" id="add-session-name" placeholder="my-project" autocomplete="off" spellcheck="false">
37
- </label>
38
- <label class="dialog-label" id="add-session-path-label">
39
- Path
40
- <input type="text" class="dialog-input" id="add-session-path" placeholder="Full path to the project folder" autocomplete="off" spellcheck="false">
41
- </label>
42
- </div>
43
- <label class="dialog-label dialog-checkbox-label" id="add-session-run-in-place-label" hidden>
44
- <input type="checkbox" class="dialog-checkbox" id="add-session-run-in-place">
45
- <span>Run in this folder, no worktree</span>
46
- <span class="dialog-hint">This folder is not a git repository with a commit, so the session cannot get its own worktree. The agent changes the folder itself, and nothing keeps its edits apart from yours. Run git init in it and make a first commit to keep them apart.</span>
47
- </label>
48
- <label class="dialog-label dialog-checkbox-label" id="add-session-skip-perms-label">
49
- <input type="checkbox" class="dialog-checkbox" id="add-session-skip-perms">
50
- <span>Skip permission prompts</span>
51
- <span class="dialog-hint">The agent edits files and runs shell commands without asking first, so a bad instruction or a hostile file in the repo can act on this machine unchecked. Leave this off unless you trust the repo and the task.</span>
52
- </label>
53
- <label class="dialog-label dialog-checkbox-label" id="add-session-unguarded-label">
54
- <input type="checkbox" class="dialog-checkbox" id="add-session-unguarded">
55
- <span>Run without guardrails</span>
56
- <span class="dialog-hint">Claude Code sessions run with guardrails that block writes to credentials and Glimmervoid's own state and hide credentials and other agents' settings. Turn this on only for work the guardrails cannot serve.</span>
57
- </label>
58
- <div class="dialog-error" id="add-session-error"></div>
59
- <div class="dialog-actions">
60
- <button type="button" class="btn-dialog btn-dialog-cancel" id="add-session-cancel">Cancel</button>
61
- <button type="button" class="btn-dialog btn-dialog-confirm" id="add-session-confirm">Add</button>
62
- </div>
63
- `,wd=`<h2 class="dialog-title" id="agent-connect-title">Connect</h2>
64
- <p class="dialog-hint" id="agent-connect-intro"></p>
65
- <p class="dialog-label" id="agent-connect-state" role="status"></p>
66
- <div class="dialog-label" id="agent-connect-steps" hidden>
67
- <span>1. Open <a class="dialog-link" id="agent-connect-link" href="about:blank" target="_blank" rel="noopener noreferrer">the sign-in page</a> and sign in.</span>
68
- <span id="agent-connect-code-row" hidden>2. Enter this code there: <code id="agent-connect-code"></code></span>
69
- <label class="dialog-label" id="agent-connect-paste-label" hidden>
70
- 2. Paste the code the page shows
71
- <input type="text" class="dialog-input" id="agent-connect-paste" autocomplete="off" spellcheck="false">
72
- </label>
73
- </div>
74
- <div class="dialog-error" id="agent-connect-error"></div>
75
- <div class="dialog-actions">
76
- <button type="button" class="btn-dialog btn-dialog-cancel" id="agent-connect-close">Close</button>
77
- <button type="button" class="btn-dialog btn-dialog-cancel" id="agent-connect-stop" hidden>Stop sign-in</button>
78
- <button type="button" class="btn-dialog btn-dialog-confirm" id="agent-connect-submit" hidden>Submit code</button>
79
- <button type="button" class="btn-dialog btn-dialog-confirm" id="agent-connect-start">Start sign-in</button>
80
- </div>
81
- `,Td={busy:`text-text-muted`,ok:`text-state-done`,error:`text-state-failed`},q=15e3,Ed=`Something went wrong. Details are hidden in streamer mode.`;function Dd(e,t){return e!==`error`||t.startsWith(`Not connected to the server. Reconnecting.`)?t:document.documentElement.hasAttribute(`data-streamer`)?Ed:t}function Od(e=`action-status`){let t=M(`p`,e);return t.setAttribute(`role`,`status`),t.hidden=!0,{element:t,show:(n,r)=>{t.className=`${e} text-xs ${Td[n]}`,t.dataset.tone=n,t.textContent=Dd(n,r),t.hidden=!1},clear:()=>{t.hidden=!0,t.textContent=``,delete t.dataset.tone}}}function kd(e,t){return K(e)?!0:(t.show(`error`,G),!1)}function Ad(e,t){let n=e instanceof Error?e.message:``;return n===`Request timed out`?`The server did not answer within ${Math.round(t/1e3)} s.`:n||`Not connected to the server. Reconnecting.`}async function jd(e,t,n,{busyText:r,timeoutMs:i=q}={}){r&&n.show(`busy`,r);try{let r=await _d(e,t,{timeoutMs:i});return n.clear(),r}catch(e){return n.show(`error`,Ad(e,i)),null}}function Md(){let e=document.getElementById(`header-status`),t=document.getElementById(`header-status-text`),n=document.getElementById(`header-status-dismiss`);return!e||!t||!n?null:(n.dataset.wired===void 0&&(n.dataset.wired=``,n.addEventListener(`click`,Fd)),{line:e,text:t})}function Nd(e,{hidesInStreamerMode:t=!0}={}){let n=Md();if(!n)return;let r=t?Dd(`error`,e):e;n.text.textContent=r,n.text.title=r,n.line.hidden=!1}function Pd(e){let t=Md();t&&t.text.textContent===e&&Fd()}function Fd(){let e=Md();e&&(e.line.hidden=!0,e.text.textContent=``,e.text.title=``)}var Id=`claude-code`,Ld=Object.freeze({"claude-code":``,codex:`Codex`,grok:`Grok`});function Rd(e){if(typeof e!=`string`)return``;let t=e.trim();return!t||t===`claude-code`?``:Ld[t]||t}function zd(e,{defaultId:t=Id}={}){let n=(Array.isArray(e)?e:[]).filter(e=>e?.resolvable&&typeof e.id==`string`&&e.id).map(e=>{let t=String(e.id);return{id:t,label:typeof e.label==`string`&&e.label?e.label:t}}),r=n.some(e=>e.id===t)?t:n.length>0?n[0].id:t;return{show:n.length>1,options:n,selectedId:r}}var Bd=`No supported agent CLI was found on the PATH Glimmervoid runs with. Install Claude Code (or another supported agent), make sure its command is on that PATH, then run glimmervoid doctor to confirm.`;function Vd(e){let t=typeof e==`object`&&e?e:null;return t===null||!Array.isArray(t.agents)||t.error||zd(t.agents).options.length>0?{canSpawn:!0,guidance:``}:{canSpawn:!1,guidance:Bd}}var Hd={agent:`upcoming`,repoRoots:`upcoming`,firstSession:`upcoming`};function Ud(e,t){return e<t?`done`:e===t?`current`:`upcoming`}function Wd({agentListing:e,repoRoots:t}){let n=Vd(e).canSpawn?t.length===0?2:3:1;return{agent:Ud(1,n),repoRoots:Ud(2,n),firstSession:Ud(3,n)}}function Gd(e){return zd(typeof e==`object`&&e?e.agents:[]).options.map(e=>e.label).join(`, `)}function Kd(e){return e===1?`1 git repo`:`${e} git repos`}function qd(e,t){let n=t.trim();return!n||e.includes(n)?null:[...e,n]}var Jd=0,Yd=`Could not read the current repository roots.`;function Xd(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}async function Zd(e){let t=await _d(`get-settings`,{});if(t.type!==`settings`)return Yd;let n=t.settings.repoRoots;if(!Xd(n))return Yd;let r=qd(n,e);if(!r)return null;let i=await _d(`update-settings`,{settings:{repoRoots:r}});return i.type===`settings-error`?i.message:null}function Qd({onAdded:e}){Jd+=1;let t=`repo-roots-adder-path-${Jd}`,n=M(`div`,`repo-roots-adder`),r=M(`div`,`repo-roots-adder-found`),i=M(`span`,`repo-roots-adder-label`,`FOUND ON THIS MACHINE`),a=M(`ul`,`repo-roots-adder-list`);r.append(i,a),r.hidden=!0;let o=M(`label`,`repo-roots-adder-label`,`TYPE A PATH`);o.htmlFor=t;let s=M(`div`,`repo-roots-adder-row`),c=M(`input`,`dialog-input repo-roots-adder-input`);c.id=t,c.type=`text`,c.placeholder=`~/src`,c.autocomplete=`off`,c.spellcheck=!1;let l=M(`button`,`btn-dialog btn-dialog-cancel`,`Add`);l.type=`button`,l.disabled=!0,s.append(c,l);let u=M(`p`,`repo-roots-adder-error`);u.setAttribute(`role`,`alert`),n.append(r,o,s,u);let d=!1;function f(e){d=e;for(let t of n.querySelectorAll(`button`))t.disabled=e;e||(l.disabled=c.value.trim()===``)}async function p(t){if(!d){f(!0),u.textContent=``;try{let n=await Zd(t);if(n){u.textContent=n;return}c.value=``,e()}catch(e){u.textContent=`Could not save the folder: ${e instanceof Error?e.message:String(e)}`}finally{f(!1)}}}c.addEventListener(`input`,()=>{l.disabled=d||c.value.trim()===``}),c.addEventListener(`keydown`,e=>{e.key===`Enter`&&c.value.trim()!==``&&(e.preventDefault(),p(c.value.trim()))}),l.addEventListener(`click`,()=>{p(c.value.trim())});function m(e){a.textContent=``;for(let t of e){let e=M(`li`,`repo-roots-adder-suggestion`),n=M(`button`,`btn-dialog btn-dialog-cancel`,`Add`);n.type=`button`,n.setAttribute(`aria-label`,`Add ${t.label}`),n.addEventListener(`click`,()=>{p(t.path)}),e.append(M(`span`,`repo-roots-adder-path`,t.label),M(`span`,`repo-roots-adder-count`,Kd(t.gitRepoCount)),n),a.append(e)}r.hidden=e.length===0,o.textContent=e.length>0?`OR TYPE A PATH`:`TYPE A PATH`}return{element:n,setSuggestions:m}}function $d(e){return[...document.querySelectorAll(`.dialog-overlay`)].at(-1)===e}function ef({dialogClass:e=`dialog`,closeOnBackdrop:t=!0,onEscape:n}={}){let r=document.activeElement,i=document.createElement(`div`);i.className=`dialog-overlay`;let a=document.createElement(`div`);a.className=e,i.appendChild(a),document.body.appendChild(i);function o(e){e.key===`Escape`&&(n?$d(i)&&n():s())}document.addEventListener(`keydown`,o);function s(){i.remove(),document.removeEventListener(`keydown`,o),r instanceof HTMLElement&&r.focus()}return t&&i.addEventListener(`click`,e=>{e.target===i&&s()}),{overlay:i,dialog:a,close:s}}function tf(e,t){e.setAttribute(`role`,`dialog`),e.setAttribute(`aria-modal`,`true`),e.setAttribute(`aria-labelledby`,t),af(e)}function nf({title:e,dialogClass:t=`dialog`,cancelLabel:n=`Cancel`}){let{overlay:r,dialog:i,close:a}=ef({dialogClass:t}),o=`dialog-title-${Math.random().toString(36).slice(2)}`,s=M(`h3`,`dialog-title`,e);s.id=o;let c=M(`div`,`dialog-actions`),l=M(`button`,`btn-dialog btn-dialog-cancel`,n);return c.append(l),i.append(s),tf(i,o),{overlay:r,dialog:i,close:a,titleEl:s,actions:c,btnCancel:l}}function rf({title:e,message:t,confirmLabel:n=`Confirm`,danger:r=!1,onConfirm:i}){let{dialog:a,close:o,actions:s,btnCancel:c}=nf({title:e}),l=M(`p`,`dialog-message`,t),u=M(`button`,r?`btn-dialog btn-dialog-confirm btn-dialog-danger`:`btn-dialog btn-dialog-confirm`,n);s.append(u),a.append(l,s),c.addEventListener(`click`,o),u.addEventListener(`click`,()=>{o(),i?.()}),requestAnimationFrame(()=>c.focus())}function af(e){e.addEventListener(`keydown`,t=>{if(t.key!==`Tab`)return;let n=[...e.querySelectorAll(`button, input, select, textarea, [tabindex]:not([tabindex="-1"])`)];if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey&&document.activeElement===r?(t.preventDefault(),i.focus()):!t.shiftKey&&document.activeElement===i&&(t.preventDefault(),r.focus())})}function of(e){return e instanceof Error?e.message:String(e)}function sf(e,t,n=!1){let r=M(`label`,`dialog-checkbox-label`),i=M(`input`);return i.type=`checkbox`,i.className=`dialog-checkbox`,i.value=t,i.checked=n,r.append(i,M(`span`,null,e)),r}function cf(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}async function lf(e){let[t,n]=await Promise.all([_d(`get-workspace-repos`,{id:e}),_d(`scan-repo-roots`,{}).catch(()=>null)]);if(t.type!==`workspace-repos`)throw Error(`Unexpected reply`);if(!t.ok)throw Error(t.error||`Could not read the workspace`);let r=t.repos.map(e=>({name:cf(e),path:e,isMember:!0})),i=new Set(t.repos),a=n?.type===`repo-roots-scanned`?n.directories:[];for(let e of a.flatMap(e=>e.projects))i.has(e.path)||(i.add(e.path),r.push({name:e.name,path:e.path,isMember:!1}));return r}function uf(e){let{overlay:t,dialog:n,close:r,actions:i,btnCancel:a}=nf({title:`Workspace repositories`}),o=M(`p`,`dialog-message`,`Saving restarts the session and resumes its conversation. A removed repository keeps its workspace branch, so committed work survives.`),s=M(`fieldset`,`dialog-workspace-list`);s.setAttribute(`aria-label`,`Workspace repositories`),s.append(M(`div`,`dialog-hint`,`Loading repositories...`));let c=M(`div`,`dialog-hint`);c.setAttribute(`role`,`status`);let l=M(`div`,`dialog-error`),u=M(`button`,`btn-dialog btn-dialog-confirm`,`Save`);u.type=`button`,u.disabled=!0,i.append(u),n.append(o,s,c,l,i),a.addEventListener(`click`,r),requestAnimationFrame(()=>a.focus()),lf(e).then(e=>{if(t.isConnected){s.textContent=``;for(let t of e)s.append(sf(t.name,t.path,t.isMember));u.disabled=!1}}).catch(e=>{t.isConnected&&(s.textContent=``,l.textContent=`Could not load repositories: ${of(e)}`)}),u.addEventListener(`click`,()=>{let n=[...s.querySelectorAll(`input:checked`)].map(e=>e.value);n.length<2?l.textContent=`Select at least two repositories.`:(l.textContent=``,u.disabled=!0,c.textContent=`Saving`,_d(`set-workspace-repos`,{id:e,repos:n}).then(e=>{if(!t.isConnected)return;if(e.type===`set-workspace-repos-result`&&e.ok){r();return}let n=e.type===`set-workspace-repos-result`?e.error:null;l.textContent=n||`Could not update the workspace.`}).catch(e=>{t.isConnected&&(l.textContent=`Could not update the workspace: ${of(e)}`)}).finally(()=>{c.textContent=``,u.disabled=!1}))})}function df(e,t){if(e===t)return!0;let n=`${t} (`;if(!e.startsWith(n)||!e.endsWith(`)`))return!1;let r=e.slice(n.length,-1);return/^\d+$/.test(r)}function ff(e,t){let n=0;for(let r of t)df(r,e)&&n++;return n}function pf(e,t){let n=new Set(t);if(!n.has(e))return e;for(let t=2;t<1e3;t++){let r=`${e} (${t})`;if(!n.has(r))return r}return`${e} (${Date.now()})`}function mf(){let e=[];for(let[,t]of F)e.push(t.card.dataset.session??``);return e}function hf(e){return ff(e,mf())}function gf(e){return pf(e??``,mf())}var _f=320,vf=8e3,yf=new Set;function bf(e){yf.add(e)}var xf=(e,t)=>{for(let n of yf)n(e,t)},Sf=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);function Cf(e){Sf?.matches||document.hidden||e?.animate&&e.animate([{transform:`scale(1)`,opacity:.65},{transform:`scale(1.35)`,opacity:1,offset:.3},{transform:`scale(1)`,opacity:.9}],{duration:300,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})}function wf(e){if(!e||e.currentState!==j.RUNNING)return;let t=performance.now();e._lastOutputAt=t,!(t-(e._activityGate||0)<_f)&&(e._activityGate=t,e._activity===`quiet`&&(e._activity=`active`,xf(e,`flag`)),xf(e,`beat`))}function Tf(e){if(!e||e.currentState!==j.RUNNING)return;let t=performance.now()-(e._lastOutputAt||0)>=vf?`quiet`:`active`;e._activity!==t&&(e._activity=t,xf(e,`flag`))}function Ef(e,t){e&&(t&&(e._lastOutputAt=performance.now(),e._activityGate=0,e._activity=`active`),t||(e._activity=void 0),xf(e,`flag`))}var Df=new Set([j.RUNNING,j.WAITING,j.STARTING,j.INITIALIZING]),Of=e=>Df.has(e);function kf(e){return Of(e.currentState)?Cl(Date.now()-(e.stateSince||Date.now()),{rounding:`floor`,showsHours:!0}):``}var Af=new Set;function jf(e){return Af.add(e),()=>Af.delete(e)}function Mf(){for(let[,e]of F)Tf(e);for(let e of Af)try{e()}catch{}}setInterval(()=>{document.hidden||Mf()},1e3),document.addEventListener(`visibilitychange`,()=>{document.hidden||Mf()});function Nf(e){return xl(Number(e)||0,{rounding:`round`,wording:`compact`,suffix:``,justNowBelowSeconds:0})}function Pf(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?`never`:`${Nf(Date.now()-e)} ago`}var Ff=e=>`polled ${Pf(e)}`;function If(e){let t=[],n=[],r=null,i=e=>{let t=e.format(e.ts);e.el.textContent!==t&&(e.el.textContent=t)},a=()=>{let r=e();if(r&&!r.closest(`[hidden]`)){for(let e of t)i(e);for(let e of n)e()}};return{track(e,n,r=Ff){let a={el:e,ts:n,format:r};i(a),t.push(a)},onTick(e){n.push(e)},reset(){t=[],n=[]},ensure(){r||=jf(a)}}}function Lf(e,{value:t,disabled:n=!1,selected:r=!1}={}){let i=M(`option`,null,e);return t!=null&&(i.value=t),n&&(i.disabled=!0),r&&(i.selected=!0),i}function Rf(e){return typeof e!=`object`||!e?!1:`skipPermissionsByDefault`in e&&e.skipPermissionsByDefault===!0}function zf(e){if(typeof e!=`object`||!e||!(`coderEnvironments`in e))return[];let t=vo.safeParse(e.coderEnvironments);return t.success&&t.data?t.data:[]}function Bf(e){let t=Object.entries(e.parameters).map(([e,t])=>`${e}=${t}`).join(`, `);return[`Template ${e.template}.`,t?`Parameters: ${t}.`:``,e.hourlyCostUsd===null?``:`Costs $${e.hourlyCostUsd.toFixed(2)} an hour.`,`Stops after ${e.idleStopMinutes} idle minutes.`].filter(Boolean).join(` `)}var Vf=Object.freeze({"claude-code":`Claude Code`,codex:`Codex`}),Hf=[],Uf=new Set;function Wf(e){let t=xo.safeParse(e);if(t.success){Hf=t.data;for(let e of Uf)e()}}function Gf(e){return Hf.find(t=>t.agent===e)??null}function Kf(e){return Uf.add(e),()=>{Uf.delete(e)}}function qf(e){let t=yo.safeParse(e);return t.success?t.data:null}function Jf(e,t){let n=Vf[t];return e?e.state===`signed-in`&&e.source===`host`?`${n} uses the login already on this machine.`:e.state===`signed-in`?`${n} uses the login Glimmervoid connected.`:e.state===`connecting`?e.reason??`${n} sign-in is waiting for you.`:e.state===`failed`?e.reason??`${n} sign-in failed.`:`${n} has no login on this machine, so remote ${n} sessions cannot sign in.`:`Checking whether ${n} is signed in.`}function Yf(){_d(`get-agent-logins`,{},{timeoutMs:q}).then(e=>{e.type===`agent-logins`&&Wf(e.logins)}).catch(()=>{})}function Xf(e){let t=Vf[e],{dialog:n,close:r}=ef();n.innerHTML=wd,tf(n,`agent-connect-title`),P(n,`#agent-connect-title`).textContent=`Connect ${t}`,P(n,`#agent-connect-intro`).textContent=`Glimmervoid signs ${t} in for its own remote sessions and keeps that login in its own folder, apart from any login you already have on this machine. The sign-in runs here and is never recorded.`;let i=P(n,`#agent-connect-state`),a=P(n,`#agent-connect-steps`),o=N(n,`#agent-connect-link`,`a`),s=P(n,`#agent-connect-code-row`),c=P(n,`#agent-connect-code`),l=P(n,`#agent-connect-paste-label`),u=N(n,`#agent-connect-paste`,`input`),d=P(n,`#agent-connect-error`),f=N(n,`#agent-connect-close`,`button`),p=N(n,`#agent-connect-stop`,`button`),m=N(n,`#agent-connect-submit`,`button`),h=N(n,`#agent-connect-start`,`button`);function g(){if(!n.isConnected){v();return}let t=Gf(e),r=t?.state===`connecting`;i.textContent=Jf(t,e),h.hidden=r,p.hidden=!r;let u=r?t.verificationUrl:null;a.hidden=u===null,o.href=u??``,o.textContent=u??``,s.hidden=!t?.userCode,c.textContent=t?.userCode??``;let d=r&&t.needsPastedCode;l.hidden=!d,m.hidden=!d}async function _(t,n,r){r.disabled=!0,d.textContent=``;try{let r=await _d(t,{agent:e,...n},{timeoutMs:q});if(r.type!==`agent-logins`)return;Wf(r.logins),r.error&&(d.textContent=r.error)}catch(e){d.textContent=`The server did not answer (${Ad(e,q)}).`}finally{r.disabled=!1}}h.addEventListener(`click`,()=>{_(`agent-connect`,{action:`start`},h)}),p.addEventListener(`click`,()=>{_(`agent-connect`,{action:`cancel`},p)}),m.addEventListener(`click`,()=>{let e=u.value;u.value=``,_(`agent-connect-code`,{code:e},m)}),u.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),m.click())}),f.addEventListener(`click`,r);let v=Kf(g);g(),Yf()}function Zf(e){return e.type===`add-session-result`&&e.error?e.error:e.type===`error`?e.message:`The session was not added.`}function Qf(){ep(null)}function $f(e){ep(e)}function ep(e){let{dialog:t,close:n}=ef();t.innerHTML=Cd,tf(t,`add-session-title`);let r=N(t,`#add-session-picker`,`select`),i=P(t,`#add-session-picker-label`),a=P(t,`#add-session-workspace-list`),o=N(t,`#add-session-single-mode`,`button`),s=N(t,`#add-session-workspace-mode`,`button`),c=P(t,`#add-session-agent-label`),l=N(t,`#add-session-agent`,`select`),u=P(t,`#add-session-environment-label`),d=N(t,`#add-session-environment`,`select`),f=P(t,`#add-session-environment-hint`),p=P(t,`#add-session-agent-login`),m=P(t,`#add-session-agent-login-text`),h=N(t,`#add-session-agent-connect`,`button`),g=P(t,`#add-session-repo-roots`),_=P(t,`#add-session-repo-roots-title`),v=N(t,`#add-session-advanced-toggle`,`button`),y=P(t,`#add-session-advanced`),b=N(t,`#add-session-name`,`input`),x=N(t,`#add-session-path`,`input`),S=P(t,`#add-session-path-label`),ee=N(t,`#add-session-skip-perms`,`input`),te=N(t,`#add-session-unguarded`,`input`),C=P(t,`#add-session-run-in-place-label`),ne=N(t,`#add-session-run-in-place`,`input`),w=P(t,`#add-session-error`),re=N(t,`#add-session-cancel`,`button`),ie=N(t,`#add-session-confirm`,`button`),ae=!1,oe=[],T=null,E=!1;function se(e){ae=e,o.setAttribute(`aria-pressed`,String(!e)),s.setAttribute(`aria-pressed`,String(e)),i.hidden=e,a.hidden=!e,v.hidden=e,v.setAttribute(`aria-expanded`,String(e)),y.hidden=!e,S.hidden=e,e&&requestAnimationFrame(()=>b.focus())}o.addEventListener(`click`,()=>se(!1)),s.addEventListener(`click`,()=>se(!0)),v.setAttribute(`aria-expanded`,`false`),v.addEventListener(`click`,()=>{let e=y.hidden;y.hidden=!e,v.setAttribute(`aria-expanded`,String(e)),e&&requestAnimationFrame(()=>b.focus())});let D=Qd({onAdded:fe});g.append(D.element);let ce=Od(`dialog-hint`),O=M(`button`,`btn-dialog btn-dialog-cancel`,`Scan again`);O.type=`button`,O.hidden=!0,O.addEventListener(`click`,()=>{fe()});let le=M(`div`,`flex items-center gap-2`);le.append(ce.element,O),g.before(le);function ue(e){r.textContent=``,r.appendChild(Lf(`Scan failed`,{disabled:!0,selected:!0})),a.textContent=``,ce.show(`error`,`The project scan failed: ${e}`),O.hidden=!1,O.disabled=!1}function de(e){let t=e.type===`repo-roots-scanned`;_.textContent=t&&e.directories.length>0?`No projects in your repository roots yet`:`No repository roots yet`,D.setSuggestions(t?e.suggestions??[]:[]),g.hidden=!1}function fe(){return O.disabled=!0,ce.show(`busy`,`Scanning your repository roots`),_d(`scan-repo-roots`,{includeSuggestions:!0},{timeoutMs:q}).then(e=>{if(e.type===`repo-roots-scanned`&&e.error){ue(e.error);return}ce.clear(),O.hidden=!0,r.textContent=``,a.textContent=``,g.hidden=!0,r.appendChild(Lf(`-- Select a project --`,{value:``,disabled:!0,selected:!0}));let t=!1,n=e.type===`repo-roots-scanned`?e.directories:[];for(let e of n){if(e.projects.length===0)continue;let n=M(`optgroup`);n.label=e.root;for(let r of e.projects){let e=hf(r.name),i=e>0?`${r.name} (${e} open)`:r.name,o=r.isGit===!1?`${i} (not a git repo)`:i;n.appendChild(Lf(o,{value:JSON.stringify({name:r.name,path:r.path,isGit:r.isGit!==!1})})),a.appendChild(sf(r.name,r.path)),t=!0}r.appendChild(n)}t||(r.textContent=``,r.appendChild(Lf(`No projects yet`,{disabled:!0,selected:!0})),a.textContent=`No projects yet.`,de(e))}).catch(e=>{ue(Ad(e,q))})}fe(),r.addEventListener(`change`,()=>{try{let e=JSON.parse(r.value);b.value=gf(e.name),x.value=e.path,be(!e.isGit)}catch{}});let pe=Id,me=!1;function he(e){let t=M(`p`,`dialog-hint dialog-hint-warning`,e);return t.setAttribute(`role`,`status`),w.before(t),t}function ge(e){me=!0,ie.disabled=!0,he(e).id=`add-session-agent-guidance`}_d(`list-agents`,{},{timeoutMs:q}).then(e=>{let t=Vd(e);t.canSpawn||ge(t.guidance);let n=zd(e.type===`agents-listed`?e.agents:[]);if(pe=n.selectedId,n.show){l.textContent=``;for(let e of n.options)l.appendChild(Lf(e.label,{value:e.id,selected:e.id===n.selectedId}));c.hidden=!1}}).catch(e=>{he(`Could not load the agent list (${Ad(e,q)}), so the session uses the default agent.`)}),l.addEventListener(`change`,()=>{pe=l.value,_e()});function _e(){if(!t.isConnected){ve();return}let e=qf(pe),n=e?Gf(e):null;p.hidden=T===null||e===null||n===null||n.state===`signed-in`,m.textContent=e?Jf(n,e):``}h.addEventListener(`click`,()=>{let e=qf(pe);e&&Xf(e)});let ve=Kf(_e);Yf();let ye=!1;ee.addEventListener(`change`,()=>{ye=!0}),_d(`get-settings`,{},{timeoutMs:q}).then(e=>{e.type===`settings-error`?he(`Could not load your settings (${e.message}). Check Skip permissions yourself.`):(xe(zf(e.settings)),!ye&&(ee.checked=Rf(e.settings)))}).catch(e=>{he(`Could not load your settings (${Ad(e,q)}). Check Skip permissions yourself.`)});function be(e){E=e,C.hidden=!e||T!==null,ne.checked=!1}function xe(e){if(e.length!==0){oe=e,d.textContent=``,d.appendChild(Lf(`Local`,{value:``,selected:!0}));for(let t of e)d.appendChild(Lf(t.name,{value:t.name}));u.hidden=!1}}d.addEventListener(`change`,()=>{T=oe.find(e=>e.name===d.value)??null,s.hidden=T!==null,f.hidden=T===null,f.textContent=T?Bf(T):``,be(E),_e(),T!==null&&ae&&se(!1)}),b.addEventListener(`input`,()=>{r.selectedIndex=0}),x.addEventListener(`input`,()=>{r.selectedIndex=0,be(!1)});function Se(){if(me)return;let e=b.value.trim(),t=x.value.trim();if(ae){let t=[...a.querySelectorAll(`input:checked`)].map(e=>e.value);if(!e||t.length<2){w.textContent=`Enter a name and select at least two repositories.`;return}let n={name:gf(e),path:t[0],repos:t,dangerouslySkipPermissions:ee.checked,unguarded:te.checked};pe&&pe!==`claude-code`&&(n.agent=pe),Ce(n);return}if(!e||!t){w.textContent=`Both fields are required. Select a project or use Advanced options.`;return}let n={name:gf(e),path:t,dangerouslySkipPermissions:ee.checked,unguarded:te.checked,runInPlace:ne.checked};pe&&pe!==`claude-code`&&(n.agent=pe),T&&(n.environment=T.name),Ce(n)}function Ce(e){ie.disabled=!0,w.textContent=``,_d(`add-session`,e,{timeoutMs:q}).then(e=>{e.type===`add-session-result`&&e.ok?n():(w.textContent=Zf(e),e.type===`add-session-result`&&e.reason===`not-git`&&(C.hidden=!1))}).catch(e=>{w.textContent=`The session was not added: ${Ad(e,q)}`}).finally(()=>{ie.disabled=me})}re.addEventListener(`click`,n),ie.addEventListener(`click`,Se),b.addEventListener(`keydown`,e=>{e.key===`Enter`&&(ae&&Se(),ae||x.focus())}),x.addEventListener(`keydown`,e=>{e.key===`Enter`&&Se()}),e?(y.hidden=!1,v.setAttribute(`aria-expanded`,`true`),b.value=e.name,x.value=e.path,be(!0),requestAnimationFrame(()=>ne.focus())):requestAnimationFrame(()=>r.focus())}function tp({issueId:e,issueTitle:t,format:n,content:r,message:i,error:a}){let{dialog:o,close:s,actions:c,btnCancel:l}=nf({title:`Investigation report`,dialogClass:`dialog dialog-report`,cancelLabel:`Close`}),u=M(`div`,`dialog-report-meta`,t||e||``),d=null;if(n===`html`&&!a&&!i){let e=M(`iframe`,`dialog-report-frame`);e.setAttribute(`sandbox`,``),e.srcdoc=r||``,d=e}d||=M(`pre`,a?`dialog-report-body dialog-report-error`:`dialog-report-body`,a||i||r||``),o.append(u,d,c),l.addEventListener(`click`,s),requestAnimationFrame(()=>l.focus())}function np({issueTitle:e,projectLabel:t,onOpenReport:n}){let{dialog:r,close:i,actions:a,btnCancel:o}=nf({title:`Investigation`,dialogClass:`dialog dialog-report`,cancelLabel:`Close`}),s=M(`div`,`dialog-report-meta`,t?`${t}: ${e}`:e),c=M(`p`,`dialog-trail-status`),l=M(`p`,`dialog-trail-summary`),u=M(`ol`,`dialog-trail-steps`),d=M(`p`,`dialog-trail-empty`,`No tool calls yet; the session is reading the issue.`),f=M(`button`,`btn-dialog btn-dialog-cancel`,`Open report`);f.type=`button`,f.hidden=!0,f.addEventListener(`click`,()=>{i(),n()}),a.prepend(f),r.append(s,c,l,u,d,a),o.addEventListener(`click`,i),requestAnimationFrame(()=>o.focus());let p=null,m=``;function h(e){let t=u.scrollHeight-u.scrollTop-u.clientHeight<24,n=$l(e);if(m!==n){u.textContent=``;for(let t of Hl(e.steps)){let n=M(`li`,`dialog-trail-step dialog-trail-${t.kind}`),r=t.kind===`note`?t.text:`${t.stepCount} ${t.stepCount===1?`step`:`steps`}`;n.append(M(`span`,`dialog-trail-at`,Ql(e.startedAt,t.at)),M(`span`,`dialog-trail-detail`,r)),u.append(n)}m=n}d.hidden=e.steps.length>0||!e.inFlight,u.hidden=e.steps.length===0,t&&(u.scrollTop=u.scrollHeight)}function g(e){c.textContent=eu(e,Pf(e.startedAt))}function _(){p&&(g(p),c.dataset.tone=p.inFlight?`live`:`done`,l.textContent=p.summaryLine,l.hidden=!p.summaryLine,f.hidden=p.inFlight||!p.verdict,h(p))}let v=jf(()=>{r.isConnected?p?.inFlight&&g(p):v()});return{update(e){p=e,_()},isOpen:()=>r.isConnected,close:()=>{v(),i()}}}function rp(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:!0}}var ip=4e3;function ap(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function op(e,t,n,r=ip){try{let i=e.getItem(t);if(i){let e=Number(i);if(Number.isFinite(e)&&n-e<r)return!1}return e.setItem(t,String(n)),!0}catch{return!0}}var sp=`#plan/`;function cp(e){return`${sp}${encodeURIComponent(e)}`}function lp(e){if(!e.startsWith(sp))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}function up(){return typeof Notification>`u`?null:Notification}function dp(){return up()!==null}function fp(){let e=up();return e?e.permission:`unavailable`}async function pp(){let e=up();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function mp(){return!dp()&&!window.isSecureContext?`Browsers allow desktop notifications only over HTTPS or on localhost, and this page is plain HTTP on another address. Open the dashboard on localhost, or use Telegram.`:dp()?fp()===`denied`&&Hs()?`Blocked by the browser. Allow notifications for this site in its site settings.`:null:`This browser does not support desktop notifications.`}function hp(){return Hs()&&fp()==="default"}function gp(e=()=>{}){let t=M(`div`,`notification-permission`),n=()=>{let r=mp();if(t.replaceChildren(),t.hidden=!r&&!hp(),r){t.append(M(`p`,`notification-permission-hint text-xs text-text-muted`,r));return}let i=M(`button`,`btn-dialog btn-dialog-cancel`,`Enable desktop notifications`);i.type=`button`,i.addEventListener(`click`,()=>{i.disabled=!0,pp().then(()=>{n(),e()})}),t.append(i)};return n(),{element:t,refresh:n}}var _p=`Desktop notifications are blocked by the browser, so alerts show only in this tab. Allow notifications for this site to get them again.`,vp=new Map,yp=!1;function bp(){yp||(yp=!0,Nd(_p,{hidesInStreamerMode:!1}))}function xp(e,t){let n=vp.get(e)??new Set;n.add(t),vp.set(e,n),t.addEventListener(`close`,()=>n.delete(t))}function Sp(e){let t=vp.get(e);if(t){vp.delete(e);for(let e of t)e.close()}}function Cp({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=up();if(!a||!Hs()||document.documentElement.hasAttribute(`data-streamer`)||!i&&typeof document<`u`&&typeof document.hasFocus==`function`&&document.hasFocus()||(a.permission===`denied`&&bp(),a.permission!==`granted`)||!op(window.localStorage,ap(e,t),Date.now()))return;let o=typeof e==`string`?e:``,s=F.get(o),c=s?Sr(s):``;try{let i=new a(c||`Glimmervoid`,rp(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&o&&(window.location.hash=cp(o)),i.close()},s&&xp(o,i)}catch{}}function wp(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function Tp(e){return/^#settings(?:[/?]|$)/.test(e)}function Ep(e){let t=e.trim();return t?`#settings?q=${encodeURIComponent(t)}`:`#settings`}function Dp(e,t,n){let r=M(`a`,`settings-link`,n);return r.href=wp(e,t),r}var Op=`↑`,kp=`↓`,Ap=`←`,jp=`→`,Mp=`⌘`,Np=`⌥`,Pp=Array.from({length:9},(e,t)=>[`Digit${t+1}`,t+1]),Fp=[{action:`next-attention`,keyCaptions:[`J`],label:`Jump to the next session needing you`,stepByCode:new Map([[`KeyJ`,0]])},{action:`rail-step`,keyCaptions:[Op,kp],label:`Previous / next session in the rail`,stepByCode:new Map([[`ArrowUp`,-1],[`ArrowDown`,1]])},{action:`view-step`,keyCaptions:[Ap,jp],label:`Previous / next view tab`,stepByCode:new Map([[`ArrowLeft`,-1],[`ArrowRight`,1]]),unavailablePlatform:`other`},{action:`view-step`,keyCaptions:[`PgUp`,`PgDn`],label:`Previous / next view tab`,stepByCode:new Map([[`PageUp`,-1],[`PageDown`,1]]),unavailablePlatform:`mac`},{action:`session-nth`,keyCaptions:[`1..9`],label:`Jump to session 1 to 9`,stepByCode:new Map(Pp),isShellChord:!0,needsMacOption:!0},{action:`new-session`,keyCaptions:[`0`],label:`Add a session`,stepByCode:new Map([[`Digit0`,0]]),isShellChord:!0},{action:`merge`,keyCaptions:[`I`],label:`Merge the selected session`,stepByCode:new Map([[`KeyI`,0]])},{action:`resolve-or-resync`,keyCaptions:[`U`],label:`Resolve a parked merge, or resync the base branch`,stepByCode:new Map([[`KeyU`,0]]),isShellChord:!0},{action:`streamer-mode`,keyCaptions:[`\\`],label:`Turn streamer mode on or off`,stepByCode:new Map([[`Backslash`,0]]),isShellChord:!0}];function Ip(e){return Fp.filter(t=>t.unavailablePlatform!==e)}function Lp(e){return/Mac|iPhone|iPad/.test(e)?`mac`:`other`}function Rp(e,t,n){return e.ctrlKey||e.shiftKey?!1:t===`mac`?e.metaKey&&e.altKey===!!n.needsMacOption:e.altKey&&!e.metaKey}function zp(e,t,n){return n.isTerminalFocused&&t!==`mac`&&!!e.isShellChord}var Bp=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`]);function Vp(e){return Bp.has(e.key)?e.key:e.code}function Hp(e,t,n={isTerminalFocused:!1}){let r=Vp(e);for(let i of Ip(t)){let a=i.stepByCode.get(r);if(a!==void 0)return!Rp(e,t,i)||zp(i,t,n)?null:{action:i.action,step:a}}return null}function Up(e,t){return t===`focus`||t===`zen`&&e.action===`next-attention`}function Wp(e,t){return e===`mac`?t?.needsMacOption?`${Mp}${Np}`:Mp:`Alt`}function Gp(e,t){let n=Ip(t).find(t=>t.action===e);if(!n)throw Error(`Unknown dashboard shortcut: ${e}`);return n}function Kp(e,t){let n=Gp(e,t);return[Wp(t,n),n.keyCaptions.join(` `)]}function qp(e,t){let[n,r]=Kp(e,t);return t===`mac`?`${n}${r}`:`${n}+${r}`}function Jp(e){let t=e===`mac`?`Meta`:`Alt`;return`ArrowUp ArrowDown ${t}+ArrowUp ${t}+ArrowDown`}function Yp(e){let t=e===`mac`?Mp:`Ctrl`;return[{title:`Dashboard`,items:Ip(e).map(t=>({combos:t.keyCaptions.map(n=>[Wp(e,t),n]),label:t.label}))},{title:`Navigation`,items:[{combos:[[Op],[kp]],label:`Move rail highlight (rail focused)`},{combos:[[Ap],[jp]],label:`Switch view tab (tab focused)`}]},{title:`Terminal`,items:[{combos:[[t,`C`]],label:`Copy selection`},{combos:[[t,`V`]],label:`Paste`},{combos:[[t,`Backspace`]],label:`Delete previous word`}]},{title:`General`,items:[{combos:[[`Esc`]],label:`Close dialog / cancel rename`}]}]}var Xp=Lp(navigator.userAgent);function Zp(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(M(`span`,`shortcut-sep`,`+`)),e.appendChild(M(`kbd`,`kbd`,t))})}function Qp(e){let t=M(`span`,`shortcut-keys`);return Zp(t,e),t}var $p=`npm install -g @anthropic-ai/claude-code`,em={done:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label="Done"><circle cx="12" cy="12" r="10"></circle><path d="M7.5 12.5l3 3 6-6.5"></path></svg>`,current:`<svg width="18" height="18" viewBox="0 0 24 24" role="img" aria-label="Needed"><path d="M12 3l9 9-9 9-9-9z" fill="currentColor"></path></svg>`,upcoming:`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" role="img" aria-label="Not started"><circle cx="12" cy="12" r="10"></circle></svg>`},tm=null,nm=null,rm=null,im=null,am={steps:Hd,agentSummary:``,repoRoots:[]},om=0,sm=Od(`first-run-load-status`),cm=gp();function lm({title:e,state:t,summary:n,badge:r,body:i}){let a=M(`li`,`first-run-step`);a.dataset.state=t,t===`current`&&a.setAttribute(`aria-current`,`step`);let o=M(`div`,`first-run-step-head`),s=M(`span`,`first-run-step-icon`);if(s.innerHTML=em[t],o.append(s,M(`span`,`first-run-step-title`,e)),t===`done`&&n&&o.append(M(`span`,`first-run-step-summary`,n)),t===`current`&&r&&o.append(M(`span`,`first-run-step-badge`,r)),a.append(o),t!==`current`)return a;let c=M(`div`,`first-run-step-body`);return c.append(...i()),a.append(c),a}function um(){let e=M(`div`,`first-run-step-actions`);return rm=M(`button`,`btn-dialog btn-dialog-cancel`,`Rescan`),rm.type=`button`,rm.addEventListener(`click`,()=>{mm({rescanAgents:!0})}),e.append(rm,M(`span`,`first-run-step-hint`,`Any other terminal agent can be added under customAgents.`)),[M(`p`,`first-run-step-text`,`No supported agent is on PATH. Install Claude Code, Codex or Grok, then rescan. Rescan still finding nothing means the CLI went into a folder the server cannot see: restart Glimmervoid from a terminal where the command runs.`),M(`code`,`first-run-command`,$p),e]}function dm(){let e=im??Qd({onAdded:()=>{mm({rescanAgents:!1})}});return im=e,[M(`p`,`first-run-step-text`,`The folder that holds your git checkouts. Each subfolder becomes a project you can start a session in.`),e.element]}function fm(){let e=M(`div`,`first-run-step-actions`),t=M(`button`,`btn-dialog btn-dialog-confirm`,`+ Session`);t.type=`button`,t.addEventListener(`click`,Qf);let n=M(`span`,`first-run-step-hint`,`Folders and agents can change later in `);n.append(Dp(`machine-sessions`,`repository-roots`,`Settings > Sessions`),`.`),e.append(t,n);let r=M(`p`,`first-run-step-text`,`Run a few at once. When one needs you, `);return r.append(Qp(Kp(`next-attention`,Xp)),` jumps straight to it from any tab.`),[M(`p`,`first-run-step-text`,`Pick a project and an agent. The session runs in its own git worktree, so your checkout is never touched.`),r,e]}function pm(){if(!nm)return;let{steps:e,agentSummary:t,repoRoots:n}=am;nm.replaceChildren(lm({title:`1. Agent CLI`,state:e.agent,summary:t,badge:`MISSING`,body:um}),lm({title:`2. Repository roots`,state:e.repoRoots,summary:n.join(`, `),badge:`NEEDED`,body:dm}),lm({title:`3. First session`,state:e.firstSession,summary:``,badge:``,body:fm}))}async function mm({rescanAgents:e}){om+=1;let t=om;rm&&(rm.disabled=!0);try{let[n,r]=await Promise.all([_d(`list-agents`,e?{rescan:!0}:{},{timeoutMs:q}),_d(`scan-repo-roots`,{includeSuggestions:!0},{timeoutMs:q})]);if(t!==om)return;let i=r.type===`repo-roots-scanned`,a=i?r.directories.map(e=>e.root):[];am={steps:Wd({agentListing:n,repoRoots:a}),agentSummary:Gd(n),repoRoots:a},sm.clear(),pm(),im?.setSuggestions(i?r.suggestions??[]:[])}catch(e){if(rm&&(rm.disabled=!1),t!==om)return;sm.show(`error`,`The checklist could not load: ${Ad(e,q)} It loads again once the server answers. If it stays like this, check the terminal running Glimmervoid, or run glimmervoid doctor.`)}}function hm(){if(tm)return tm;let e=M(`section`,`first-run-checklist`);e.setAttribute(`aria-labelledby`,`first-run-title`);let t=M(`h2`,`first-run-title`,`Get to your first session`);t.id=`first-run-title`,nm=M(`ol`,`first-run-steps`);let n=M(`p`,`first-run-footer`,`This list goes away once a session exists. Something off? Run `);return n.append(M(`code`,null,`glimmervoid doctor`),` in a terminal.`),e.append(M(`span`,`first-run-eyebrow`,`FIRST RUN`),t,M(`p`,`first-run-intro`,`Glimmervoid runs the agent CLIs you already have, inside the repositories you point it at. Two checks, then start.`),nm,sm.element,cm.element,n),tm=e,pm(),e}function gm(e,t){if(!t){tm?.parentElement===e&&(tm.hidden=!0);return}let n=hm(),r=!n.hidden&&n.parentElement===e;n.parentElement!==e&&e.append(n),n.hidden=!1,cm.refresh(),r||mm({rescanAgents:!1})}function _m(){tm&&!tm.hidden&&tm.isConnected&&mm({rescanAgents:!1})}var vm=new Set([`http:`,`https:`]);function ym(e){let t;try{t=new URL(e)}catch{return null}return vm.has(t.protocol)?t.href:null}var bm=2,xm=8,Sm=/^ {0,3}(`{3,}|~{3,})([^`]*)$/,Cm=/^(\s*)(?:([-+*])|(\d+)[.)])\s+(.+)$/,wm=/^ {0,3}(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$/,Tm=/^:?-{3,}:?$/,Em=/^[A-Za-z0-9_+#.-]{1,32}$/;function Dm(e){return $r(e,{overlongLine:`reject`})}function Om(e){let t=e.trim().split(/\s+/)[0]??``;return Em.test(t)?t:``}function km(e,t){if(!t)return;let n=e.at(-1);n?.type===`text`?n.text+=t:e.push({type:`text`,text:t})}function Am(e,t){return e.startsWith(`**`,t)?`**`:e.startsWith(`__`,t)?`__`:null}function jm(e,t){return e.startsWith(`*`,t)?`*`:e.startsWith(`_`,t)?`_`:null}function Mm(e,t,n){let r=e.indexOf(t,n);return r>n?r:-1}function Nm(e,t){let n=e.indexOf(t);return function(r){return n===-1?-1:(n>=r||(n=e.indexOf(t,r)),n)}}function Pm(e,t){let n=1;for(let r=t;r<e.length;r++){let t=e[r];if(t===`(`&&n++,t===`)`&&n--,n===0)return r;if(n>bm)return-1}return-1}function Fm(e,t,n){if(e[t]!==`[`)return null;let r=n(t+1);if(r<=t+1||e[r+1]!==`(`)return null;let i=Pm(e,r+2);return i===-1?null:{label:e.slice(t+1,r),target:e.slice(r+2,i),end:i+1}}function Im(e){let t=[],n=Nm(e,`]`),r=0;for(;r<e.length;){let i=Fm(e,r,n);if(i){let e=ym(i.target.trim());e&&t.push({type:`link`,href:e,children:Im(i.label)}),e||km(t,i.label),r=i.end;continue}if(e.startsWith("`",r)){let n=Mm(e,"`",r+1);if(n!==-1){t.push({type:`code`,text:e.slice(r+1,n)}),r=n+1;continue}}let a=Am(e,r);if(a){let n=Mm(e,a,r+a.length);if(n!==-1){t.push({type:`strong`,children:Im(e.slice(r+a.length,n))}),r=n+a.length;continue}}let o=jm(e,r);if(o){let n=Mm(e,o,r+1);if(n!==-1){t.push({type:`emphasis`,children:Im(e.slice(r+1,n))}),r=n+1;continue}}km(t,e[r]),r++}return t}function Lm(e){return e.map(e=>e.type===`text`||e.type===`code`?e.text:Lm(e.children)).join(``)}var Rm=`plan-h-`;function zm(e,t){let n=e.toLowerCase().normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`section`,r=(t.slugCounts.get(n)??0)+1;return t.slugCounts.set(n,r),`${Rm}${r===1?n:`${n}-${r}`}`}function Bm(e){if(typeof e!=`string`||!e.includes(`|`))return!1;let t=Vm(e);return t.length<2?!1:t.every(e=>Tm.test(e))}function Vm(e){let t=e.trim();return t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1)),t.split(`|`).map(e=>e.trim())}function Hm(e){let t=Cm.exec(e);return t?{indent:t[1].replace(/\t/g,` `).length,ordered:!!t[3],content:t[4]}:null}function Um(e,t,n,r){let i=Hm(e[t]);if(!i)return null;let a=[],o=i.ordered,s=i.indent,c=t;for(;c<e.length;){let t=Hm(e[c]);if(!t||t.indent<s)break;if(t.indent>s){if(r>=xm)break;let t=Um(e,c,n,r+1);if(!t||a.length===0)break;a.at(-1)?.children.push(t.block),c=t.next}else{if(t.ordered!==o)break;a.push({children:[{type:`paragraph`,children:Im(t.content)}]}),c++}}return{block:{type:`list`,ordered:o,items:a},next:c}}function Wm(e,t){let n=e[t]??``;return n.trim()===``||Dm(n)||Sm.test(n)||wm.test(n)||Hm(n)||/^ {0,3}>/.test(n)?!0:t+1<e.length&&n.includes(`|`)&&Bm(e[t+1])}function Gm(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.trim()===``){i++;continue}let o=Sm.exec(a);if(o){let t=[],n=o[1][0],a=o[1].length;for(i++;i<e.length;){let r=/^ {0,3}(`{3,}|~{3,})\s*$/.exec(e[i]);if(r&&r[1][0]===n&&r[1].length>=a)break;t.push(e[i]),i++}i<e.length&&i++,r.push({type:`code`,language:Om(o[2]),text:t.join(`
82
- `)});continue}let s=Dm(a);if(s){let e=Im(s.text);r.push({type:`heading`,level:s.level,id:zm(Lm(e),t),children:e}),i++;continue}if(wm.test(a)){r.push({type:`rule`}),i++;continue}if(i+1<e.length&&a.includes(`|`)&&Bm(e[i+1])){let t=Vm(a).map(Im),n=[];for(i+=2;i<e.length&&e[i].includes(`|`)&&e[i].trim()!==``;)n.push(Vm(e[i]).map(Im)),i++;r.push({type:`table`,header:t,rows:n});continue}let c=Um(e,i,t,n);if(c){r.push(c.block),i=c.next;continue}if(n<xm&&/^ {0,3}>/.test(a)){let a=[];for(;i<e.length&&/^ {0,3}>/.test(e[i]);)a.push(e[i].replace(/^ {0,3}> ?/,``)),i++;r.push({type:`blockquote`,blocks:Gm(a,t,n+1)});continue}let l=[a.trim()];for(i++;i<e.length&&!Wm(e,i);)l.push(e[i].trim()),i++;r.push({type:`paragraph`,children:Im(l.join(` `))})}return r}function Km(e){return Gm(e.replace(/\r\n?/g,`
83
- `).split(`
84
- `),{slugCounts:new Map},0)}function qm(e){let t=[],n={heading:null,id:null,level:0,blocks:[]},r=()=>{(n.heading!==null||n.blocks.length!==0)&&t.push(n)};for(let t of e)t.type===`heading`?(r(),n={heading:Lm(t.children),id:t.id,level:t.level,blocks:[t]}):n.blocks.push(t);return r(),t}function Jm(e,t){for(let n of t){if(n.type===`text`){e.append(document.createTextNode(n.text));continue}if(n.type===`code`){e.append(M(`code`,`plan-inline-code`,n.text));continue}if(n.type===`emphasis`){let t=M(`em`);Jm(t,n.children),e.append(t);continue}if(n.type===`strong`){let t=M(`strong`);Jm(t,n.children),e.append(t);continue}let t=M(`a`,`plan-link`);t.href=n.href,t.target=`_blank`,t.rel=`noopener noreferrer`,Jm(t,n.children),e.append(t)}}function Ym(e){let t=M(`li`);return Xm(t,e.children),t}function Xm(e,t){for(let n of t)if(n.type===`heading`){let t=M(`h${n.level}`,`plan-heading`);t.id=n.id,Jm(t,n.children),e.append(t)}else if(n.type===`paragraph`){let t=M(`p`,`plan-paragraph`);Jm(t,n.children),e.append(t)}else if(n.type===`list`){let t=n.ordered?M(`ol`,`plan-list`):M(`ul`,`plan-list`);t.append(...n.items.map(Ym)),e.append(t)}else if(n.type===`code`){let t=M(`pre`,`plan-code`),r=M(`code`,n.language?`language-${n.language}`:null,n.text);t.append(r),e.append(t)}else if(n.type===`table`){let t=M(`div`,`plan-table-wrap`),r=M(`table`,`plan-table`),i=M(`thead`),a=M(`tr`);for(let e of n.header){let t=M(`th`);Jm(t,e),a.append(t)}i.append(a);let o=M(`tbody`);for(let e of n.rows){let t=M(`tr`);for(let n of e){let e=M(`td`);Jm(e,n),t.append(e)}o.append(t)}r.append(i,o),t.append(r),e.append(t)}else if(n.type===`blockquote`){let t=M(`blockquote`,`plan-blockquote`);Xm(t,n.blocks),e.append(t)}else e.append(M(`hr`,`plan-rule`))}function Zm(e){let t=M(`div`,`plan-document`);return Xm(t,e),t}function Qm(e,{hasComment:t,isComposing:n,onComment:r,attachmentFor:i}){let a=M(`div`,`plan-document`),o=[];for(let s of e){let e=M(`section`,`plan-section`);e.dataset.selected=`false`,e.addEventListener(`click`,()=>{for(let t of o)t.dataset.selected=String(t===e)}),o.push(e);let c=M(`div`,`plan-section-head`),l=s.blocks[0],u=l?.type===`heading`;if(u&&Xm(c,[l]),u||(e.id=`plan-introduction`),!t(s)&&!n(s)){let e=M(`button`,`plan-section-comment`,`Comment`);e.type=`button`,e.setAttribute(`aria-label`,`Comment on ${s.heading??`Introduction`}`),e.addEventListener(`click`,()=>r(s)),c.append(e)}let d=M(`div`,`plan-section-body`);Xm(d,u?s.blocks.slice(1):s.blocks),e.append(c,d);let f=i(s);f&&e.append(f),a.append(e)}return a}var $m={added:`+`,removed:`-`,unchanged:` `,skipped:` `};function eh(e){let t=M(`div`,`plan-diff`);for(let n of e.lines){let e=M(`div`,`plan-diff-line plan-diff-${n.kind}`),r=M(`span`,`plan-diff-gutter`,$m[n.kind]);r.setAttribute(`aria-hidden`,`true`),e.append(r,M(`span`,`plan-diff-text`,n.text)),t.append(e)}return t}var th=`glimmervoid-streamer-mode`,nh=new Set,rh=ws(th,!1)===!0,ih=null;function ah(e){document.documentElement.toggleAttribute(`data-streamer`,e),ih?.setAttribute(`aria-pressed`,String(e))}ah(rh);function oh(){return rh}function sh(e){if(Ts(th,e),e!==oh()){rh=e,ah(e);for(let t of nh)t(e)}}function ch(e){return nh.add(e),()=>nh.delete(e)}async function lh(e){try{let t=await _d(`update-settings`,{settings:{streamerMode:e}},{timeoutMs:q});return t.type===`settings-error`?String(t.message):(sh(e),``)}catch(e){return Ad(e,q)}}async function uh(){let e=!oh();e&&sh(!0);let t=await lh(e);t&&Nd(`${e?`Streamer mode is on in this browser only. The server did not save it`:`Streamer mode is still on. The server did not save the change`}: ${t}`,{hidesInStreamerMode:!1})}function dh(){uh()}function fh(e){ih=e,ah(oh()),e.addEventListener(`click`,dh)}var ph=new Map,mh=null;function hh(e){return ph.get(e)??[]}function gh(e){return hh(e).length>0}function _h(e){I(e)?.btnDocs.classList.toggle(`visible`,gh(e))}function vh(e){let t=hh(e.sessionId);e.select.replaceChildren(...t.map(t=>{let n=M(`option`,null,t.name);return n.value=t.path,n.selected=t.path===e.docPath,n})),e.select.hidden=t.length<2,e.title.textContent=t.find(t=>t.path===e.docPath)?.name??e.title.textContent}function yh(e){let t=hh(e.sessionId).some(t=>t.path===e.docPath);e.btnEdit.setAttribute(`aria-pressed`,String(e.mode===`edit`)),e.btnPreview.setAttribute(`aria-pressed`,String(e.mode===`preview`)),e.textarea.hidden=e.mode!==`edit`,e.preview.hidden=e.mode!==`preview`,e.select.disabled=e.isBusy,e.btnReload.disabled=e.isBusy||!t,e.btnSave.disabled=e.isBusy||!t||e.baseHash===null||!e.hasUnsavedChanges}function bh(e,t,n=`quiet`){e.status.textContent=t,e.status.dataset.tone=n}function xh(e){e.preview.replaceChildren(Zm(Km(e.textarea.value)))}function Sh(e,t){rf({title:e,message:`Your unsaved edits will be lost.`,confirmLabel:`Discard`,danger:!0,onConfirm:t})}function Ch(e,t,n){e.hasUnsavedChanges?Sh(t,n):n()}async function wh(e,t){try{return{reply:await _d(e,t,{timeoutMs:q}),failureText:null}}catch(e){return{reply:null,failureText:Ad(e,q)}}}async function Th(e,t){e.docPath=t,e.isBusy=!0,e.baseHash=null,e.textarea.readOnly=!0,vh(e),bh(e,`Loading`),yh(e);let{reply:n,failureText:r}=await wh(`session-doc-read`,{id:e.sessionId,path:t});if(mh!==e||e.docPath!==t)return;e.isBusy=!1,e.textarea.readOnly=!1;let i=n?.type===`session-doc-response`?n:null;!i?.ok||i.text===void 0||i.hash===void 0?(bh(e,i?.error||r||`Could not open this doc`,`warn`),yh(e)):(e.textarea.value=i.text,e.baseHash=i.hash,e.hasUnsavedChanges=!1,e.mode===`preview`&&xh(e),bh(e,``),yh(e))}async function Eh(e){if(e.btnSave.disabled||e.baseHash===null)return;e.isBusy=!0,bh(e,`Saving`),yh(e);let t=e.docPath,n=e.textarea.value,{reply:r,failureText:i}=await wh(`session-doc-save`,{id:e.sessionId,path:t,text:n,baseHash:e.baseHash});if(mh!==e||e.docPath!==t)return;e.isBusy=!1;let a=r?.type===`session-doc-save-result`?r:null;!a?.ok||a.hash===void 0?(bh(e,a?.conflict?`The agent changed this file since you opened it. Reload to see its version.`:a?.error||i||`Save failed`,`warn`),yh(e)):(e.baseHash=a.hash,e.hasUnsavedChanges=e.textarea.value!==n,bh(e,e.hasUnsavedChanges?`Unsaved changes`:`Saved`),yh(e))}function Dh(e,t){e.mode=t,t===`preview`&&xh(e),yh(e),t===`edit`&&e.textarea.focus()}function Oh(e,t){let n=M(`button`,`plan-control ${t}`,e);return n.type=`button`,n}function kh(e){let t=hh(e)[0];if(!t||mh)return;let n=()=>Ch(y,`Close this doc?`,()=>y.close()),r=ef({dialogClass:`doc-editor`,closeOnBackdrop:!1,onEscape:n}),i=`doc-editor-title-${e}`,a=M(`h3`,`doc-editor-title`,t.name);a.id=i;let o=M(`select`,`plan-control doc-editor-picker`);o.setAttribute(`aria-label`,`Doc`);let s=M(`span`,`doc-editor-status`);s.setAttribute(`role`,`status`);let c=Oh(`Edit`,`doc-editor-mode`),l=Oh(`Preview`,`doc-editor-mode`),u=Oh(`Reload`,`doc-editor-reload`),d=Oh(`Save`,`doc-editor-save`),f=Oh(`Close`,`doc-editor-close`),p=M(`div`,`doc-editor-modes`);p.append(c,l);let m=M(`div`,`doc-editor-actions`);m.append(s,u,d,f);let h=M(`div`,`doc-editor-header`);h.append(a,o,p,m);let g=M(`textarea`,`plan-editor doc-editor-text`);g.spellcheck=!0,g.setAttribute(`aria-labelledby`,i);let _=M(`div`,`doc-editor-preview`),v=M(`div`,`doc-editor-body`);v.append(g,_),r.dialog.append(h,v),tf(r.dialog,i);let y={sessionId:e,docPath:t.path,baseHash:null,hasUnsavedChanges:!1,isBusy:!1,mode:oh()?`preview`:`edit`,title:a,select:o,textarea:g,preview:_,status:s,btnEdit:c,btnPreview:l,btnReload:u,btnSave:d,close:()=>{mh=null,r.close()}};mh=y,g.addEventListener(`input`,()=>{y.hasUnsavedChanges||(y.hasUnsavedChanges=!0,bh(y,`Unsaved changes`),yh(y))}),g.addEventListener(`keydown`,e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),Eh(y))}),o.addEventListener(`change`,()=>{let e=o.value;o.value=y.docPath,Ch(y,`Open another doc?`,()=>{Th(y,e)})}),c.addEventListener(`click`,()=>Dh(y,`edit`)),l.addEventListener(`click`,()=>Dh(y,`preview`)),u.addEventListener(`click`,()=>{Ch(y,`Reload this doc?`,()=>{Th(y,y.docPath)})}),d.addEventListener(`click`,()=>{Eh(y)}),f.addEventListener(`click`,n),Th(y,t.path),y.mode===`edit`&&g.focus()}function Ah(e){mh&&mh.sessionId===e&&(vh(mh),yh(mh),!hh(e).some(e=>e.path===mh?.docPath)&&bh(mh,`This doc is no longer surfaced, so it cannot be saved.`,`warn`))}function jh(e){ph.set(e.id,e.docs),e.docs.length===0&&ph.delete(e.id),_h(e.id),Ah(e.id)}function Mh(e){let t=[...ph.keys()];ph.clear();for(let[t,n]of Object.entries(e.sessions))ph.set(t,n);for(let e of new Set([...t,...ph.keys()]))_h(e),Ah(e)}function Nh({dialogClass:e,titleText:t,titleId:n,body:r,onCloseRequest:i}){let a=ef({dialogClass:e,closeOnBackdrop:!1,onEscape:i}),o=M(`div`,`coherence-journal-header`),s=M(`h3`,`dialog-title`,t);s.id=n;let c=M(`button`,`btn-dialog btn-dialog-cancel`,`Close`);return c.type=`button`,o.append(s,c),a.dialog.append(o,...r),tf(a.dialog,s.id),c.addEventListener(`click`,i),a.overlay.addEventListener(`click`,e=>{e.target===a.overlay&&i()}),{close:a.close,focusClose:()=>c.focus()}}function Ph({requestPrefix:e,dialogClass:t,titleText:n,unavailableLabel:r,timeoutMs:i}){let a=null;function o(e){e.timer!==null&&clearTimeout(e.timer),e.timer=null,e.requestId=null}function s({sessionId:s,status:c,body:l,parts:u,paintBeforeRequest:d,buildRequest:f}){a?.close();let p=gd(e),m=Nh({dialogClass:t,titleText:n,titleId:`${p}-title`,body:l,onCloseRequest:()=>h.close()}),h={sessionId:s,status:c,parts:u,requestId:p,timer:null,close:()=>{o(h),a===h&&(a=null),m.close()}};a=h,d?.(),m.focusClose(),K(f(p))?h.timer=setTimeout(()=>{h.requestId=null,h.timer=null,c.textContent=`${r}: request timed out`},i):(h.requestId=null,c.textContent=`${r}: not connected`)}function c(e){let t=a;return!t||t.sessionId!==e.id||t.requestId===null||t.requestId!==e.requestId?null:(o(t),t)}return{open:s,settleResponse:c,currentPanel:()=>a}}var Fh=2,Ih={needsYou:1,broken:2,askedOfYou:3,waiting:4,settled:5},Lh={danger:Ih.broken,warn:Ih.askedOfYou,wait:Ih.waiting,ok:Ih.settled,muted:Ih.settled};function Rh(e){return e?Lh[e]:Ih.settled}function zh(e){let t=[...e].sort((e,t)=>e.tier-t.tier),n=t.slice(Fh);return{visible:t.slice(0,Fh),overflowCount:n.length,overflowHoverText:n.map(e=>`${e.text} ${e.hoverText}`).join(`
85
- `)}}function Bh(e){return e.map(e=>[e.key,e.text,e.hoverText,e.look?.icon,e.look?.tone,e.tier].join(`|`)).join(`
86
- `)}var Vh={decision:`Decision`,retraction:`Retraction`,conjecture:`Conjecture`,resolution:`Resolution`,dismissal:`Dismissal`,defect:`Defect`,experiment:`Experiment`,close:`Close`,unable:`Unable`,escalation:`Escalation`,acknowledgement:`Acknowledgement`,enactment:`Enactment`};function Hh(e){return e?.active!==!1||e.reason===ta.notInstalled?[]:[{key:`coherence-hooks`,text:`Hooks off`,hoverText:`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`,look:{icon:`failed`,tone:`danger`},tier:Ih.broken}]}function Uh(e){let t=Mi.safeParse(e.kind);return{heading:`${t.success?Vh[t.data]:e.kind} | ${e.at??`Unknown time`} | ${e.id}`,text:e.text,detail:e.detail,supersedes:e.supersedes?`Supersedes: ${e.supersedes}`:null}}function Wh(e,t){let n=[];return e?.active===!1&&n.push(`Coherence hooks not active: ${e.reason}${e.version?` (${e.version})`:``}`),t&&!t.journal.ok&&n.push(`Journal unavailable: ${t.journal.reason}`),{lines:n}}var Gh=new Map,Kh=new Map,qh=Ph({requestPrefix:`coherence-journal`,dialogClass:`dialog coherence-journal-drawer`,titleText:`Coherence journal`,unavailableLabel:`Journal unavailable`,timeoutMs:5e3});function Jh(e,t){Kh.delete(e),t&&Kh.set(e,t),eg(e)}function Yh(e){Gh.delete(e),Kh.delete(e);let t=qh.currentPanel();t?.sessionId===e&&t.close()}function Xh(e){let t=Gh.get(e.id);t&&t.updatedAt>e.updatedAt||(Gh.set(e.id,e),eg(e.id))}function Zh(e){Gh.clear();for(let[t,n]of Object.entries(e.sessions))Gh.set(t,n);let t=qh.currentPanel();t&&eg(t.sessionId)}function Qh(e){return Hh(Kh.get(e)??null).map(t=>({...t,onActivate:()=>tg(e)}))}function $h(e){return Gh.get(e)?.journal.ok===!0}function eg(e){let t=qh.currentPanel();if(!t||t.sessionId!==e)return;let n=Wh(Kh.get(e)??null,Gh.get(e)??null);t.parts.reading.replaceChildren(...n.lines.map(e=>M(`p`,null,e)))}function tg(e){let t=M(`div`,`coherence-journal-reading`),n=M(`p`,`coherence-journal-status`,`Loading journal`);n.setAttribute(`role`,`status`);let r=M(`div`,`coherence-journal-entries`);qh.open({sessionId:e,status:n,body:[t,n,r],parts:{reading:t,entries:r},paintBeforeRequest:()=>eg(e),buildRequest:t=>({type:`session-coherence-journal`,id:e,requestId:t})})}function ng(e){let t=qh.settleResponse(e);t&&(e.ok?(t.status.textContent=e.entries.length===0?`No journal entries`:`${e.entries.length} journal entries (up to 200)`,t.parts.entries.replaceChildren(...e.entries.map(e=>{let t=Uh(e),n=M(`article`,`coherence-journal-entry`);return n.append(M(`h4`,null,t.heading),M(`p`,null,t.text)),t.detail&&n.append(M(`p`,null,t.detail)),t.supersedes&&n.append(M(`p`,null,t.supersedes)),n}))):t.status.textContent=`Journal unavailable: ${e.error||`could not read journal`}`)}var rg=/\bElectron\/\d/,ig=new Set([`localhost`,`127.0.0.1`]);function ag(e){return rg.test(e)}function og({userAgent:e,pageHostname:t}){return ag(e)&&ig.has(t)}function sg(e){return ym(e)!==null}var cg=new Set([0,1]);function lg({button:e,opensInNewTab:t}){return t&&cg.has(e)}function ug(){return og({userAgent:navigator.userAgent,pageHostname:location.hostname})}function dg(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function fg(e){try{let t=await sl();return(await fetch(`/open-external`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})})).ok}catch{return!1}}function pg(e){!ug()||!sg(e)?dg(e):fg(e).then(t=>{t||dg(e)})}function mg(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&lg({button:e.button,opensInNewTab:t.target===`_blank`})&&sg(t.href)&&(e.preventDefault(),pg(t.href))}function hg(e){ug()&&(e.addEventListener(`click`,mg,!0),e.addEventListener(`auxclick`,mg,!0))}var gg=new Map([[`plan`,`Plan ready`],[`permission`,`Needs permission`]]);function _g(e){return gg.get(e)??`Needs input`}function vg({hasPlan:e,pendingPromptKind:t,hasOpenReview:n,hasApprovedReview:r=!1}){return e&&(n||t===`plan`&&!r)?`plan`:`terminal`}function yg({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}var bg=new Map(Object.entries({WAITING:`now`,COMPLETE:`later`,FAILED:`resting`,IDLE:`resting`,RUNNING:`resting`,STARTING:`resting`,INITIALIZING:`resting`,DORMANT:`resting`,DONE:`resting`}));function xg(e){return(typeof e.state==`string`?bg.get(e.state):void 0)??`resting`}function Sg(e,t){return[...e].map(([e,n])=>{let r=n.currentState||j.DORMANT;return{id:e,ui:n,name:t(n),isDormant:r===j.DORMANT,state:r,ownerId:n.ownerId??null}})}function Cg(e){let t=new Set(e.map(({id:e})=>e)),n=e=>e.ownerId&&t.has(e.ownerId)?e.ownerId:null,r=new Map;for(let t of e){let e=n(t);e&&r.set(e,[...r.get(e)??[],t])}return e.flatMap(e=>n(e)?[]:[e,...r.get(e.id)??[]])}function wg(e){return Cg([...e].sort((e,t)=>Number(e.isDormant===!0)-Number(t.isDormant===!0)))}function Tg({ownerName:e,ownedCount:t}){return e===null?t===1?`Owns 1 session`:t>1?`Owns ${t} sessions`:null:`Owned by ${e}`}function Eg(e,t){return e.length?e[((t==null?-1:e.indexOf(t))+1)%e.length]:null}function Dg(e,t){return t!==null&&e.includes(t)?t:e[0]??null}var Og=new Map([[j.FAILED,`Failed`],[j.COMPLETE,`Finished`]]);function kg(e,t){return Og.get(e)??_g(t??``)}function Ag(e,t,n){if(!e.length)return null;let r=n<0?-1:1,i=t==null?-1:e.indexOf(t);return e[((i===-1?r===1?-1:0:i)+r+e.length)%e.length]}function jg({state:e}={}){return xg({state:e})!==`resting`}var Mg=new Map([[j.WAITING,0],[j.FAILED,1],[j.COMPLETE,2]]);function Ng({state:e}){return typeof e==`string`?Mg.get(e):void 0}function Pg(e){return e.filter(e=>Ng(e)!==void 0).sort((e,t)=>(Ng(e)??0)-(Ng(t)??0)).map(({id:e})=>e)}function Fg(e){let t={waitingCount:0,finishedCount:0,failedCount:0};for(let n of e||[])n?.state===j.FAILED?t.failedCount++:jg(n||{})&&(n?.state===j.COMPLETE?t.finishedCount++:t.waitingCount++);return t}function Ig({waitingCount:e,finishedCount:t,failedCount:n}){return e+n+t}function Lg({waitingCount:e,failedCount:t}){return e+t}function Rg(e){return Ig(e)>0}function zg({waitingCount:e,finishedCount:t,failedCount:n}){let r=[];return e===1&&r.push(`1 NEEDS YOU`),e>1&&r.push(`${e} NEED YOU`),n>0&&r.push(`${n} FAILED`),t>0&&r.push(`${t} FINISHED`),r.length===0?`ALL CLEAR`:r.join(`, `)}var Bg=new Map([[`hand`,2]]),Vg=1;function Hg(e){return e?typeof e==`string`&&Bg.get(e)||Vg:0}function Ug(e){let t=!1,n=0;for(let r of e||[]){let e=Hg(r);e<=n||(t=typeof r!=`string`||r,n=e)}return t}var Wg=`#c084fc`,Gg=Object.freeze({failed:{icon:er[j.FAILED],color:`#ef4444`},waiting:{icon:er[j.WAITING],color:`#f59e0b`}});function Kg(e){let{waitingCount:t,failedCount:n}=Fg(Array.isArray(e)?e:[]);return t>0?`waiting`:n>0?`failed`:`idle`}function qg(e){return ir[e].map(({tag:e,attributes:t})=>`<${e} ${Object.entries(t).map(([e,t])=>`${e}="${t}"`).join(` `)}/>`).join(``)}function Jg(e){if(e===`idle`)return`<path d="M10 8 L22 16 L10 24Z" fill="${Wg}"/>`;let{icon:t,color:n}=Gg[e];return`<g color="${n}" transform="translate(4 4) scale(1.5)">${qg(t)}</g>`}function Yg(e){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="6" fill="#0a0810"/><rect x="1" y="1" width="30" height="30" rx="5" fill="none" stroke="#2a2440" stroke-width="1"/>${Jg(e)}</svg>`}function Xg(){let e=document.querySelector(`link[rel="icon"]`);if(e instanceof HTMLLinkElement)return e;let t=document.createElement(`link`);return t.rel=`icon`,t.type=`image/svg+xml`,document.head.append(t),t}var Zg=Xg(),Qg=`idle`;function $g(e){let t=Kg([...e.values()].map(({currentState:e})=>({state:e})));t!==Qg&&(Qg=t,Zg.href=`data:image/svg+xml,${encodeURIComponent(Yg(t))}`)}function e_(e,t){return Number.isFinite(e)?Math.round(Math.min(t.maxPx,Math.max(t.minPx,e))):null}function t_(e,t){return e===`ArrowRight`?t:e===`ArrowLeft`?-t:null}function n_({resizer:e,column:t,widthHost:n,widthProperty:r,bounds:i,keyStepPx:a,getStoredWidth:o,setStoredWidth:s,growsLeftward:c=!1}){let l=c?-1:1;e.setAttribute(`aria-valuemin`,String(i.minPx)),e.setAttribute(`aria-valuemax`,String(i.maxPx));let u=t=>{let a=e_(t,i);return a===null?null:(n.style.setProperty(r,`${a}px`),e.setAttribute(`aria-valuenow`,String(a)),a)},d=o();d!==null&&u(d);let f=0,p=0;e.addEventListener(`pointerdown`,n=>{n.button===0&&(f=n.clientX,p=t.getBoundingClientRect().width,e.setPointerCapture(n.pointerId),e.dataset.dragging=`true`,n.preventDefault())}),e.addEventListener(`pointermove`,t=>{e.hasPointerCapture(t.pointerId)&&u(p+l*(t.clientX-f))});let m=t=>{e.releasePointerCapture(t.pointerId),delete e.dataset.dragging};e.addEventListener(`pointerup`,t=>{e.hasPointerCapture(t.pointerId)&&(m(t),s(u(p+l*(t.clientX-f))))}),e.addEventListener(`pointercancel`,t=>{e.hasPointerCapture(t.pointerId)&&(m(t),u(p))}),e.addEventListener(`dblclick`,()=>{n.style.removeProperty(r),e.setAttribute(`aria-valuenow`,String(Math.round(t.getBoundingClientRect().width))),s(null)}),e.addEventListener(`keydown`,e=>{let n=t_(e.key,a);if(n===null)return;e.preventDefault();let r=u(t.getBoundingClientRect().width+l*n);r!==null&&s(r)})}function r_(e){return String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function i_(e,t,n){let r=M(`button`,`popup-menu-item ${n}`);return r.type=`button`,r.setAttribute(`role`,`menuitem`),r.setAttribute(`aria-label`,e),r.append(M(`span`,`popup-menu-item-label`,e),M(`span`,`popup-menu-item-hint`,t)),r}function a_(e){return e.key===`ArrowDown`||e.key===`ArrowUp`}function o_(e,t){let n=document.activeElement,r=n instanceof HTMLElement?e.indexOf(n):-1;e[((t.key===`ArrowDown`?r+1:r<0?e.length-1:r-1)+e.length)%e.length]?.focus()}var s_=`http://www.w3.org/2000/svg`;function c_(e,t){let n=document.createElementNS(s_,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}function l_(e,t){let n=document.createElementNS(s_,`svg`);return n.setAttribute(`width`,String(e)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 ${e} ${t}`),n.setAttribute(`aria-hidden`,`true`),n}var u_=`M4 4L12 12M12 4L4 12`,d_=`M12 8a4 4 0 1 1-8 0a4 4 0 1 1 8 0M8 1.5v2.5M8 12v2.5M1.5 8h2.5M12 8h2.5M3.4 3.4l1.77 1.77M10.83 10.83l1.77 1.77M3.4 12.6l1.77-1.77M10.83 5.17l1.77-1.77`,f_=`M3 4h10M3 8h10M3 12h10`,p_=`M3 8h0.01M8 8h0.01M13 8h0.01`;function m_(e){let t=l_(16,16);return t.classList.add(`line-icon`),t.append(c_(`path`,{d:e,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),t}var h_=new WeakMap;function g_(e){let t=h_.get(e);if(t?.element.parentElement===e.card)return t;let n=t??Od(`session-action-status m-0 px-3 py-1`);return e.termWrap.before(n.element),h_.set(e,n),n}function __(e,t){let n=g_(e);return kd(t,n)?(n.clear(),!0):!1}var v_=!1,y_=new Set;function b_(e){v_=!!e,Q_();for(let e of y_)e(v_)}function x_(e){return y_.add(e),()=>y_.delete(e)}function S_(){return v_}var C_=null;function w_(e){C_=e}var T_=null;function E_(e){T_=e}var D_=null;function O_(e){D_=e}var k_=[{cls:`agent-badge`,title:`Agent CLI this session supervises`},{cls:`worktree-badge`,text:`worktree`,title:`Running in a linked git worktree`,ariaLabel:`Linked git worktree`},{cls:`guardrails-badge`,text:`guardrails`,title:`Guardrails on: credentials, Glimmervoid state and blocked folders are off-limits to this session`,ariaLabel:`Guardrails on`},{cls:`post-turn-badge`,ariaHidden:!0},{cls:`usage-badge`,title:`Tokens and estimated API list-price cost for this conversation`},{cls:`wakeup-badge`},{cls:`prompt-badge`,title:`Waiting on a permission or input prompt`}];function A_({cls:e,text:t=``,title:n,ariaLabel:r,ariaHidden:i}){let a=M(`span`,e,t);return n&&(a.title=n),r&&a.setAttribute(`aria-label`,r),i&&a.setAttribute(`aria-hidden`,`true`),a}function j_(e,t){e.textContent=t?`SANE YOLO`:`YOLO`,e.title=t?`Skips permission prompts; Sane YOLO blocks catastrophic commands`:`Running with --dangerously-skip-permissions`}function M_(e,t){t&&(e.dataset.saneYolo=``),t||delete e.dataset.saneYolo;let n=e.querySelector(`.perms-badge`);n&&j_(n,t)}function N_(e,t){let n=I(e);n&&M_(n.card,t)}function P_(e,t,n,r={}){let i=n||j.INITIALIZING,a=M(`div`,`session-card`);a.dataset.id=e,a.dataset.session=t,a.dataset.state=i,r.skipPerms&&(a.dataset.skipPerms=``),r.saneYolo&&(a.dataset.saneYolo=``),r.worktree&&(a.dataset.worktree=``),r.workspace&&(a.dataset.workspace=``),r.guarded&&(a.dataset.guarded=``),r.guardrailsReleased&&(a.dataset.guardrailsReleased=``),r.ephemeral&&(a.dataset.ephemeral=``),r.path&&(a.dataset.path=String(r.path));let o=M(`div`,`session-card-header`),s=M(`span`,`session-name`,t);s.title=`Double-click or press F2 to rename`,s.tabIndex=0;let c=r.skipPerms?M(`span`,`perms-badge`):null;c&&j_(c,r.saneYolo===!0);let l=M(`span`,`session-task-title`);z_(l,r.taskTitle);let u=M(`div`,`session-actions`),d=M(`div`,`session-overflow`),f=M(`button`,`btn-action btn-session-menu visible`);f.append(m_(p_)),f.type=`button`,f.title=`Session actions`,f.setAttribute(`aria-label`,`Session actions`),f.setAttribute(`aria-haspopup`,`menu`),f.setAttribute(`aria-expanded`,`false`);let p=M(`div`,`popup-menu session-overflow-menu`);p.id=`session-menu-${e}`,p.setAttribute(`role`,`menu`),f.setAttribute(`aria-controls`,p.id);let m=i_(`Restart`,`Keeps this conversation`,`overflow-restart`),h=i_(`Restart fresh`,`Ends this conversation and starts a new one`,`overflow-restart-fresh`),g=i_(`Resume conversation...`,`Pick an earlier conversation`,`overflow-resume`),_=i_(`Edit repositories...`,`Add or remove repositories in this workspace`,`overflow-workspace-repos`),v=i_(`Link pull request...`,`Link or unlink pull requests for this session`,`overflow-link-pr visible`),y=i_(`Conversation view`,`Show this session as messages (experimental)`,`overflow-conversation-view`);y.setAttribute(`role`,`menuitemcheckbox`),y.setAttribute(`aria-checked`,`false`);let b=i_(`Guardrails`,`Limit what this session can read, write and reach`,`overflow-guardrails`);b.setAttribute(`role`,`menuitemcheckbox`),F_(b,a),v.onclick=()=>{p.classList.remove(`open`),f.setAttribute(`aria-expanded`,`false`),I_(e)};let x=i_(`Coherence journal`,`Decisions and notes this session recorded`,`overflow-coherence-journal`);x.setAttribute(`aria-haspopup`,`dialog`);let S=()=>x.classList.toggle(`visible`,T_?.isReadable(e)===!0);f.onclick=S,f.onkeydown=S,x.onclick=()=>{p.classList.remove(`open`),f.setAttribute(`aria-expanded`,`false`),T_?.open(e)};let ee=i_(`Session setup`,`MCP servers, plugins and hooks this session loaded`,`overflow-session-setup visible`);ee.setAttribute(`aria-haspopup`,`dialog`),ee.onclick=()=>{p.classList.remove(`open`),f.setAttribute(`aria-expanded`,`false`),D_?.(e)},p.append(m,h,g,_,y,b,x,ee,v),d.append(f,p);let te=M(`button`,`btn-action btn-debug`);te.append(m_(d_)),te.title=`Debug state`,te.setAttribute(`aria-label`,`Debug session state`);let C=M(`button`,`btn-action btn-trace`);C.append(m_(f_)),C.type=`button`,C.title=`Trace`,C.setAttribute(`aria-label`,`Trace`);let ne=M(`button`,`btn-action btn-remove visible`);ne.append(m_(u_)),ne.type=`button`,ne.title=`Remove session`,ne.setAttribute(`aria-label`,`Remove session`);let w=M(`button`,`btn-action btn-face-plan`,`Plan`);w.type=`button`,w.title=`Show plan`;let re=M(`button`,`btn-action btn-face-plan btn-docs`,`Docs`);re.type=`button`,re.title=`Open docs the agent surfaced`,u.append(re,w,te,C,d,ne);let ie=M(`div`,`session-card-tags`),ae=k_.map(e=>A_(e));c&&ae.push(c),ie.append(...ae);let oe=M(`span`,`session-ownership`);oe.hidden=!0,o.append(s,l,oe,ie,u);let T=M(`div`,`terminal-wrap`);return a.append(o,T),{card:a,header:o,nameEl:s,taskTitleEl:l,btnRestart:m,btnRestartFresh:h,btnSessionMenu:f,btnResume:g,btnWorkspaceRepos:_,btnConversationView:y,btnGuardrails:b,btnTrace:C,btnRemove:ne,btnPlan:w,btnDocs:re,btnDebug:te,sessionMenu:p,termWrap:T}}function F_(e,t){let n=t.dataset.guarded!==void 0,r=t.dataset.ephemeral===void 0&&(n||t.dataset.guardrailsReleased!==void 0);e.classList.toggle(`visible`,r),e.setAttribute(`aria-checked`,String(n))}function I_(e){let{dialog:t,close:n,actions:r,btnCancel:i}=nf({title:`Link pull request`}),a=M(`p`,`dialog-message`,`Paste a GitHub pull request URL or owner/repo#number.`),o=M(`input`,`dialog-input`);o.type=`text`,o.placeholder=`owner/repo#123`,o.autocomplete=`off`,o.spellcheck=!1,o.setAttribute(`aria-label`,`Pull request URL or owner/repo#number`);let s=M(`div`,`dialog-error`);s.setAttribute(`role`,`alert`);let c=M(`div`,`session-pr-chips dialog-linked-prs`);c.hidden=!0,C_?.(c,e);let l=M(`button`,`btn-dialog btn-dialog-confirm`,`Link`);l.type=`button`,r.append(l),t.append(c,a,o,s,r);function u(){let t=so(o.value);t?K({type:`link-session-pr`,id:e,key:t})?n():s.textContent=G:s.textContent=`Enter a github.com pull request URL or owner/repo#number.`}i.addEventListener(`click`,n),l.addEventListener(`click`,u),o.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),u())}),requestAnimationFrame(()=>o.focus())}function L_(e,t){e.tabIndex=0,e.setAttribute(`role`,`button`),e.addEventListener(`click`,t),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())})}function R_(e,t){let n=e.querySelector(`.session-ownership`);n&&(n.textContent=t??``,n.hidden=t===null)}function z_(e,t){e.title=t??``,t&&e.removeAttribute(`aria-label`),t||e.setAttribute(`aria-label`,`Describe the task`),!e.querySelector(`input`)&&(e.textContent=t??``)}function B_(e,t){let n=e.titleTargetEl?.isConnected?e.titleTargetEl:e.taskTitleEl;if(n.querySelector(`input`))return;let r=document.createElement(`input`);r.type=`text`,r.className=`session-title-input`,r.setAttribute(`aria-label`,`Task`),r.value=e.taskTitleIsCustom?e.taskTitle??``:``,r.placeholder=e.taskTitle??`What is this session working on?`,r.maxLength=120;let i=n.getAttribute(`role`),a=n.getAttribute(`tabindex`);n.removeAttribute(`role`),n.removeAttribute(`tabindex`),n.replaceChildren(r),r.focus(),r.select();function o(o){r.removeEventListener(`blur`,s),r.removeEventListener(`keydown`,c),o&&__(e,{type:`set-session-title`,id:t,title:r.value.trim()}),n.replaceChildren(),i!==null&&n.setAttribute(`role`,i),a!==null&&n.setAttribute(`tabindex`,a),z_(n,e.taskTitle)}function s(){o(!0)}function c(e){e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),o(!0)),e.key===`Escape`&&(e.preventDefault(),o(!1))}r.addEventListener(`blur`,s),r.addEventListener(`keydown`,c)}var V_=`session-rename-input`;function H_(e){return!!e?.querySelector(`.${V_}`)}function U_(e,t,{returnsFocusToTerminal:n=!0}={}){let r=e.renameTargetEl?.isConnected?e.renameTargetEl:e.nameEl;if(!r||H_(r))return;let i=e.card?.dataset.session??r.textContent??``,a=document.createElement(`input`);a.type=`text`,a.className=V_,a.value=i,a.maxLength=64,r.textContent=``,r.appendChild(a),a.focus(),a.select();let o=g_(e);function s(t){return e.card.dataset.ephemeral===void 0?Vi.test(t)?[...F.values()].some(n=>n!==e&&n.card.dataset.session===t)?`Session "${t}" already exists.`:``:Hi:`This session cannot be renamed`}function c(t=e.card?.dataset.session??i){r.textContent=t,e.nameEl&&e.nameEl!==r&&(e.nameEl.textContent=t),n&&e.term?.focus()}function l(){let e=a.value.trim(),t=e&&e!==i?s(e):``;t?(o.show(`error`,t),a.select()):u()}function u(){let n=a.value.trim();if(f(),!n||n===i){c();return}let r=s(n);r?(o.show(`error`,r),c()):__(e,{type:`rename-session`,id:t,newName:n})?c(n):c()}function d(){f(),c()}function f(){a.removeEventListener(`blur`,u),a.removeEventListener(`keydown`,p)}function p(e){e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(e.preventDefault(),d()),e.stopPropagation()}a.addEventListener(`blur`,u),a.addEventListener(`keydown`,p)}function W_(){let e=M(`button`,`debug-close`);return e.type=`button`,e.title=`Close`,e.setAttribute(`aria-label`,`Close debug overlay`),e.append(m_(u_)),e}function G_(e){return e?Dl(new Date(e)):`-`}function K_(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function q_(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${K_(e.quietMs)})`:``}function J_(e){let t=`<span class="debug-dim">${G_(e.ts)}</span>`;if(e.kind===`signal`){let n=r_([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${r_(e.event||``)}</span>`:e.action===`gate-held`?`${t} ${n} → held <span class="debug-dim">(${Number(e.active)||0} bg)</span>`:`${t} ${n} → <span class="debug-dim">no-op</span>`}if(e.kind===`gate`){let n=(e.repeats??0)>1?` <span class="debug-dim">x${Number(e.repeats)}</span>`:``,r=q_(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${r_(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=r_(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${r_(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${r_(e.category||`?`)}: <span class="debug-dim">${r_(e.from||`?`)} → ${r_(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${r_(e.kind||`decision`)}</span>`}function Y_(e,t){if(!e.debugOverlay)return;let n=t,r=``;if(r+=`<div class="debug-section"><div class="debug-section-title">State</div>`,r+=`<div class="debug-field"><span class="debug-label">Current:</span> <span class="debug-value">${r_(n.state)}</span></div>`,r+=`</div>`,r+=`<div class="debug-section"><div class="debug-section-title">Transitions (last ${n.transitions.length})</div>`,n.transitions.length===0&&(r+=`<div class="debug-field debug-dim">No transitions recorded</div>`),n.transitions.length>0)for(let e of n.transitions){let t=e.detail&&typeof e.detail==`object`?e.detail:null,n=t?[t.signal,t.source,t.deferred?`deferred`:null].filter(Boolean):[],i=n.length>0?` <span class="debug-dim">${r_(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${G_(e.timestamp)}</span> ${r_(e.from)} → ${r_(e.to)} <span class="debug-label">${r_(e.event)}</span>${i}</div>`}r+=`</div>`;let i=n.detection||{},a=i.lastSignal,o=i.titleState||{};r+=`<div class="debug-section"><div class="debug-section-title">Detection</div>`,r+=`<div class="debug-field"><span class="debug-label">Last signal:</span> <span class="debug-value">${a?`${r_(a.signal)} (${r_(a.source||`?`)}${a.confidence?`/${r_(a.confidence)}`:``})`:`none`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hooks injected:</span> <span class="debug-value">${i.hooksInjected?`yes`:`no`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hook seen:</span> <span class="debug-value">${i.hookSeen?`yes`:`no (degraded → title)`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Title state:</span> <span class="debug-value">${r_(o.lastKind||`none`)}${o.hasSeenSpinner?` · spun`:``}</span></div>`,r+=`</div>`;let s=i.agents||{},c=i.gate;r+=`<div class="debug-section"><div class="debug-section-title">Agents</div>`,r+=`<div class="debug-field"><span class="debug-label">Active:</span> <span class="debug-value">${Number(s.active)||0} (counted ${Number(s.counted)||0}, declared ${Number(s.declared)||0})</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Idle:</span> <span class="debug-value">${Number(s.idleNames)||0} names, ${Number(s.idleTasks)||0} tasks</span></div>`;let l=c?`held ${K_(c.heldForMs)} (seq ${Number(c.seq)||0}, lastActivity ${Number(c.lastActivitySeq)||0})`:`none`;r+=`<div class="debug-field"><span class="debug-label">Gate:</span> <span class="debug-value">${r_(l)}</span></div>`,r+=`</div>`;let u=Array.isArray(n.decisions)?n.decisions:[];r+=`<div class="debug-section"><div class="debug-section-title">Decisions (last ${u.length})</div>`,u.length===0&&(r+=`<div class="debug-field debug-dim">No decisions recorded</div>`);for(let e of u)r+=`<div class="debug-field">${J_(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r,e.debugOverlay.prepend(W_())}function X_(e,t){if(e.debugOpen){Z_(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`<div class="debug-field debug-dim">Loading...</div>`,n.prepend(W_()),e.card.appendChild(n),e.debugOverlay=n,e.debugOpen=!0,n.addEventListener(`click`,t=>{t.stopPropagation(),t.target instanceof Element&&t.target.closest(`.debug-close`)&&Z_(e)}),K({type:`debug-state`,id:t})}function Z_(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function Q_(){for(let[,e]of F)e.btnDebug.classList.toggle(`visible`,v_),e.btnTrace.classList.toggle(`visible`,v_),!v_&&e.debugOpen&&Z_(e)}function $_(e){let t=typeof e.id==`string`?F.get(e.id):void 0;t?.debugOpen&&Y_(t,e.payload)}function ev(e){I(e)?.debugOpen&&K({type:`debug-state`,id:e})}function tv(e){let t=l_(16,16);t.classList.add(`status-icon`),t.dataset.icon=e;for(let n of ir[e])t.append(c_(n.tag,n.attributes));return t}function nv(e,t){e.dataset.icon!==t&&(e.dataset.icon=t,e.replaceChildren(tv(t)))}var rv={merged:`M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z`,draft:`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z`,conflict:`M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,behind:`M13.03 8.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L3.47 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l2.97 2.97V3.75a.75.75 0 0 1 1.5 0v7.44l2.97-2.97a.75.75 0 0 1 1.06 0Z`,failed:`M2.343 13.657A8 8 0 1 1 13.658 2.343 8 8 0 0 1 2.343 13.657ZM6.03 4.97a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042L6.94 8 4.97 9.97a.749.749 0 0 0 .326 1.275.749.749 0 0 0 .734-.215L8 9.06l1.97 1.97a.749.749 0 0 0 1.275-.326.749.749 0 0 0-.215-.734L9.06 8l1.97-1.97a.749.749 0 0 0-.326-1.275.749.749 0 0 0-.734.215L8 6.94Z`,running:`M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z`,passed:`M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z`,ready:`M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z`,"changes-requested":`M1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V4.664a.25.25 0 0 0-.073-.177l-2.914-2.914a.25.25 0 0 0-.177-.073ZM8 3.25a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0V7h-1.5a.75.75 0 0 1 0-1.5h1.5V4A.75.75 0 0 1 8 3.25Zm-3 8a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75Z`,thread:`M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z`,reviewer:`M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 13H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25v-8.5C0 1.784.784 1 1.75 1ZM1.5 2.75v8.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm5.28 1.72a.75.75 0 0 1 0 1.06L5.31 7l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.75.75 0 0 1 1.06 0Zm2.44 0a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.69 7 9.22 5.53a.75.75 0 0 1 0-1.06Z`,"your-turn":`M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z`,queued:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z`,fork:`M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z`,discarded:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm9.78-2.22-5.5 5.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l5.5-5.5a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z`,stale:`M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z`,unknown:`M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67c.169-.339.436-.701.849-.977C6.845 4.16 7.369 4 8 4a2.756 2.756 0 0 1 1.637.525c.503.377.863.965.863 1.725 0 .448-.115.83-.329 1.15-.205.307-.47.513-.692.662-.109.072-.22.138-.313.195l-.006.004a6.24 6.24 0 0 0-.26.16.952.952 0 0 0-.276.245.75.75 0 0 1-1.248-.832c.184-.264.42-.489.692-.661.103-.067.207-.132.313-.195l.007-.004c.1-.061.182-.11.258-.161a.969.969 0 0 0 .277-.245C8.96 6.514 9 6.427 9 6.25a.612.612 0 0 0-.262-.525A1.27 1.27 0 0 0 8 5.5c-.369 0-.595.09-.74.187a1.01 1.01 0 0 0-.34.398ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,none:`M2 7.75A.75.75 0 0 1 2.75 7h10a.75.75 0 0 1 0 1.5h-10A.75.75 0 0 1 2 7.75Z`};function iv(e,t){let n=l_(16,16);return n.classList.add(`pr-status-icon`),t&&(n.dataset.tone=t),n.append(c_(`path`,{d:rv[e],fill:`currentColor`})),n}function av(e,{className:t=``,linkUrl:n,ariaLabel:r,onActivate:i}={}){let a=`signal ${t}`.trim(),o=n?dr(a,``,n,e.hoverText):M(`span`,a);return o.title=e.hoverText,r&&o.setAttribute(`aria-label`,r),e.look&&(o.dataset.tone=e.look.tone,o.append(iv(e.look.icon,e.look.tone))),o.append(e.text),i&&ov(o,i,!n),o}function ov(e,t,n){e.addEventListener(`click`,e=>{e.stopPropagation(),!e.defaultPrevented&&(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t()))}),n&&(e.tabIndex=0,e.setAttribute(`role`,`button`)),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.stopPropagation(),e.preventDefault(),t()))})}function sv(e){e.removeAttribute(`tabindex`),e.removeAttribute(`role`)}function cv(e,t){if(e.closest(`button, a[href]`))for(let e of t){sv(e);for(let t of e.querySelectorAll(`[role="button"]`))sv(t)}}function lv(e){if(e.overflowCount===0)return null;let t=M(`span`,`signal-overflow`,`+${e.overflowCount}`);return t.title=e.overflowHoverText,t}function uv(e,t,n=e=>av(e,e)){let r=Bh(t);if(e.dataset.signalSignature===r)return;e.dataset.signalSignature=r;let i=zh(t),a=i.visible.map(n),o=lv(i);o&&a.push(o),cv(e,a),e.hidden=a.length===0,e.replaceChildren(...a)}var dv=[],fv=`plan`,pv={parked:{text:`PARKED`,hoverText:`Merge parked`,look:{icon:`failed`,tone:`danger`},tier:Ih.broken},merging:{text:`MERGING`,hoverText:`Merging`,look:{icon:`queued`,tone:`wait`},tier:Ih.waiting}};function mv(e){dv.push(e)}function hv(e){let t=pv[e];return t?[{...t,key:`merge`}]:[]}function gv(e){let t=e.closest(`.session-row`),n=t?.dataset.id;t&&n&&uv(e,[...hv(t.dataset.merge??``),...dv.flatMap(e=>e(n))])}function _v(){for(let e of document.querySelectorAll(`.session-row-signals`))gv(e)}function vv(e,t=``){let n=M(e,`session-row ${t}`.trim());return n.innerHTML=`<span class="session-row-glyph" aria-hidden="true"></span><span class="session-row-main"><span class="session-row-name"></span><span class="session-row-task" hidden></span><span class="session-row-ownership" hidden></span><span class="session-row-meta"><span class="session-row-label"></span><span class="session-row-signals" hidden></span></span></span><span class="session-row-elapsed" aria-hidden="true"></span>`,{row:n,refs:{glyph:P(n,`.session-row-glyph`),label:P(n,`.session-row-label`),ownership:P(n,`.session-row-ownership`),name:P(n,`.session-row-name`),task:P(n,`.session-row-task`),signals:P(n,`.session-row-signals`),elapsed:P(n,`.session-row-elapsed`)}}}function yv(e,t){let n=M(`div`,`session-row-item`),r=M(`button`,`session-row-remove`);return r.append(m_(u_)),r.type=`button`,r.title=`Remove session`,r.setAttribute(`aria-label`,`Remove session`),r.addEventListener(`click`,e=>{e.stopPropagation(),t()}),n.append(e,r),{item:n,removeButton:r}}function bv(e,t,n,r=!1,i=null){e.dataset.state=n,e.dataset.prompt=i??``;let{icon:a,label:o,isMonitoring:s}=pr(n,r),c=i===fv?`Plan ready`:o;return e.toggleAttribute(`data-monitoring`,s),nv(t.glyph,a),t.label.textContent=c,c}function xv(e){let t=e.ownerId?F.get(e.ownerId):void 0,n=t?Sr(t):null,r=e.card.dataset.id,i=[...F.values()].filter(e=>e.ownerId===r).length;return Tg({ownerName:n,ownedCount:i})}function Sv(e,t,n){let r=xv(n);return t.ownership.textContent=r??``,t.ownership.hidden=r===null,e.closest(`.session-row-item`)?.toggleAttribute(`data-owned`,n.ownerId!==null&&F.has(n.ownerId)),R_(n.card,r),r}function Cv(e,t,{ui:n,state:r,name:i,mergeStatus:a}){let o=bv(e,t,r,n.awaitingBackgroundTasks,n.pendingPromptKind);t.name.textContent=i,t.task.textContent=n.taskTitle,t.task.hidden=!n.taskTitle||n.taskTitle===i,e.dataset.merge=a,gv(t.signals),e.dataset.activity=n._activity||``,t.elapsed.textContent=kf(n);let s=Sv(e,t,n),c=[i,n.taskTitle,o,s].filter(Boolean).join(`, `);return e.setAttribute(`aria-label`,c),e.title=c,o}var wv={ready:{label:`Ready`,meaning:`Ready to merge, or nothing left for you to do.`},passed:{label:`Passed`,meaning:`Checks passing, approved, or nothing open.`},failed:{label:`Failed`,meaning:`Checks failing, an automated review failed, or an auto-rebase failed.`},conflict:{label:`Conflict`,meaning:`Merge conflicts with the base branch.`},"your-turn":{label:`Your turn`,meaning:`Waiting on you: a review to give or a thread to answer.`},"changes-requested":{label:`Changes`,meaning:`A reviewer requested changes.`},thread:{label:`Threads`,meaning:`Unresolved review threads or comments.`},behind:{label:`Behind`,meaning:`The branch is behind its base.`},stale:{label:`Out of date`,meaning:`New commits landed since the automated review.`},fork:{label:`Fork`,meaning:`Opened from a fork, so it is reviewed by hand.`},running:{label:`Running`,meaning:`Checks or an automated review in progress.`},reviewer:{label:`Reviewer`,meaning:`Waiting on a reviewer.`},queued:{label:`Queued`,meaning:`Waiting for an automated review slot.`},draft:{label:`Draft`,meaning:`Still a draft.`},merged:{label:`Merged`,meaning:`Merged.`},discarded:{label:`Discarded`,meaning:`Review discarded or dismissed.`},unknown:{label:`Unknown`,meaning:`GitHub has not computed this yet.`},none:{label:`None`,meaning:`Nothing applies, such as no checks or no review requested.`}},Tv=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:Yn[e],meaning:t}),Ev=Object.freeze([Tv(j.DORMANT,`Not started yet.`),Tv(j.STARTING,`Setting up the worktree and booting the agent.`),Tv(j.RUNNING,`The agent is mid-turn.`),Tv(j.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),Tv(j.WAITING,`Waiting on a permission prompt or your answer.`),Tv(j.COMPLETE,`Finished a turn you have not looked at yet.`),Tv(j.IDLE,`Ready for the next prompt.`),Tv(j.DONE,`The agent process ended.`),Tv(j.FAILED,`The agent failed to start or crashed. A red line above the terminal says why it could not start; its terminal output shows a crash.`)]);function Dv(e,t){let n=M(`section`,`status-legend`),r=M(`dl`,`status-legend-rows`);return r.append(...t),n.append(M(`h2`,`status-legend-title`,e),r),n}function Ov(e,t){let n=M(`div`,`status-legend-row`);return n.append(e,M(`dd`,`status-legend-meaning`,t)),n}function kv(){return Dv(`Status colors`,Ev.map(e=>{let t=M(`dt`,`status-legend-badge`),n=M(`span`,`status-legend-glyph`),r=M(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=Ov(t,e.meaning);return bv(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function Av(){return Dv(`Pull request icons`,Object.keys(wv).map(e=>{let t=wv[e],n=M(`dt`,`status-legend-badge`);return n.append(iv(e),M(`span`,`status-legend-name`,t.label)),Ov(n,t.meaning)}))}var jv=new Set(fc());function Mv(){pc([...jv])}function Nv(e){if(!e)return;let t=String(e);jv.has(t)||(jv.add(t),Mv())}function Pv(e,t){let n=new Set;for(let r of e||[]){let e=t(r);if(!e)continue;let i=String(e);n.add(i),Nv(i)}return[...jv].filter(e=>!n.has(e))}function Fv(e){return!e||!jv.delete(String(e))?!1:(Mv(),!0)}function Iv(e,t=`explicit-state`){let n=t===`dormant-fallback`?e||j.DORMANT:e;return n===j.DORMANT?`start-session`:n===j.COMPLETE?`dismiss`:null}function Lv({previousState:e,nextState:t,isPhoneLayout:n,isDocumentVisible:r,isDocumentFocused:i,isActiveViewer:a,hasFocusInsideTerminal:o}){return t!==j.COMPLETE||!e||e===j.COMPLETE||!r?!1:n?a:i&&o}function Rv(e,t){if(!e)return null;let n=t.get(e);return!n||(n.currentState||j.DORMANT)===j.DORMANT?null:e}function zv(){return kr.snapshot().selectedSessionId}function Bv(e){kr.dispatch(`selectSession`,e)}function Vv(e){return kr.subscribe((t,n)=>{n.includes(`selectedSessionId`)&&e(t.selectedSessionId)})}function Hv(e,t=`explicit-state`){let n=F.get(e);if(!n)return null;let r=Iv(n.currentState,t);return r&&__(n,{type:r,id:e}),n}function Uv(e,{rememberFocus:t=!0}={}){Bv(e),t&&jc(e)}function Wv(){return Rv(Ac(),F)}function Gv(e=Sr){return Sg([...F],e)}function Kv(e,t){let n=F.get(e);return n?__(n,t):K(t)?!0:(Nd(G),!1)}async function qv(e,t){try{let n=gf(t),r=await _d(`add-session`,{name:n,path:e},{timeoutMs:q});if(r.type===`add-session-result`&&r.ok)return;if(r.type===`add-session-result`&&r.reason===`not-git`){$f({name:n,path:e});return}Nd(Zf(r))}catch(e){Nd(`The session was not added: ${Ad(e,q)}`)}}function Jv(e,t){e&&qv(e,t)}function Yv(e,t){let n=F.get(e);if(!n)return;let r=t||n.card?.dataset.merge||`none`,i=r===`pending-review`||r===`parked`;rf({title:`Remove Session`,message:i?`"${Sr(n)}" has unmerged worktree changes that will be permanently discarded if you remove it. Merge or review them first to keep them. Remove anyway?`:`Remove session "${Sr(n)}"?`,confirmLabel:i?`Discard & Remove`:`Remove`,danger:!0,onConfirm:()=>{__(n,{type:`remove-session`,id:e})}})}var Xv=Object.freeze({[j.IDLE]:`compaction_restore_idle`,[j.COMPLETE]:`compaction_restore_complete`,[j.WAITING]:`compaction_restore_waiting`});function Zv(e){return Object.values(Xv).some(t=>t===e)}var Qv=new Set([`claude-code`,`codex`]),$v=`\x1B`,ey=`${$v}[200~`,ty=`${$v}[201~`,ny=400,ry=4e3,iy=/^\[Image: source: (.+)\]$/,ay=`uploads`,oy=new Set([`Agent`,`Task`]),sy=/^Async agent launched/,cy=`<task-notification>`,ly=/<tool-use-id>([^<]+)<\/tool-use-id>/,uy=/<task-id>([^<]+)<\/task-id>/,dy=/agentId: ([\w-]+)/,fy=/<status>([^<]+)<\/status>/,py=6e5;function my(e){return typeof e==`string`&&Qv.has(e)}function hy(e,t){if(!my(e))return null;let n=t.replace(/\r\n?/g,`
87
- `).trim();return n?[{data:n.includes(`
88
- `)?`${ey}${n}${ty}`:n,delayBeforeMs:0},{data:`\r`,delayBeforeMs:ny}]:null}function gy(e){return my(e)?[{data:`\r`,delayBeforeMs:0}]:null}function _y(e){return my(e)?[{data:$v,delayBeforeMs:0}]:null}function vy(e,t){return e===j.WAITING&&typeof t==`string`&&t!==``}function yy(e,t){return e.uuid??`${e.kind}-${e.ts}-${t}`}function by(e){return typeof e.agentId==`string`}function xy(e){let t=iy.exec(e.trim());if(!t)return null;let[n,r,i]=t[1].split(/[\\/]/).slice(-3);return n!==ay||!r||!i?null:`/upload/${encodeURIComponent(r)}/${encodeURIComponent(i)}`}function Sy(e,t){let n=e[e.length-1];n?.kind===`user`&&n.imageUrls.push(t)}function Cy(e){if(!e||typeof e!=`object`)return`Agent`;let t=e.description;return typeof t==`string`&&t.trim()?t.trim():`Agent`}function wy(e,t,n){if(!e)return;if(t.isError){e.state=`failed`;return}if(!sy.test(t.content)){e.state=`done`;return}let r=dy.exec(t.content)?.[1];r&&n.set(r,e)}function Ty(e){return e.trimStart().startsWith(cy)}function Ey(e,t,n){let r=ly.exec(e)?.[1];if(r)return t.get(r);let i=uy.exec(e)?.[1];return i?n.get(i):void 0}function Dy(e,t,n){let r=Ey(e,t,n);r?.state===`running`&&(r.state=fy.exec(e)?.[1]===`completed`?`done`:`failed`)}function Oy(e){let t=[],n=new Map,r=new Map,i=new Map,a=new Map,o=null;function s(){o&&t.push(o),o=null}function c(e,t){return o??={kind:`work`,key:e,steps:[],agentRuns:[],startedAt:t,endedAt:t},o.endedAt=Math.max(o.endedAt,t),o}return e.forEach((e,o)=>{let l=yy(e,o);if(!by(e)){if((e.kind===`prompt`||e.kind===`expansion`)&&Ty(e.text))Dy(e.text,i,a);else if(e.kind===`prompt`)s(),t.push({kind:`user`,key:l,text:e.text,at:e.ts,imageUrls:[]});else if(e.kind===`expansion`)for(let n of e.text.split(`
89
- `)){let e=xy(n);e&&Sy(t,e)}else if(e.kind===`assistant`){if(!e.text.trim())return;t.push({kind:`assistant`,key:l,text:e.text,at:e.ts})}else if(e.kind===`notice`)t.push({kind:`notice`,key:l,text:e.text,at:e.ts});else if(e.kind===`thinking`)c(l,e.ts);else if(e.kind===`tool_call`){let t=c(l,e.ts),a={isRunning:!0};if(t.steps.push(a),n.set(e.toolUseId,a),r.set(e.toolUseId,t),!oy.has(e.name))return;let o={key:l,description:Cy(e.input),state:`running`};t.agentRuns.push(o),i.set(e.toolUseId,o)}else if(e.kind===`tool_result`){let t=n.get(e.toolUseId),o=r.get(e.toolUseId);if(!t||!o)return;t.isRunning=!1,o.endedAt=Math.max(o.endedAt,e.ts),wy(i.get(e.toolUseId),e,a)}}}),s(),t}function ky(e){return e.flatMap(e=>e.kind===`work`?e.agentRuns.filter(e=>e.state===`running`):[])}function Ay(e){let t=e.at(-1);return t?.kind===`work`?t:null}function jy(e){return new Set(e.flatMap(e=>e.kind===`user`?[e.key]:[]))}function My(e,t,n){if(n-e.sentAt>py)return!0;let r=e.text.trim();return t.some(t=>t.kind===`user`&&!e.userKeysAtSend.has(t.key)&&t.text.includes(r))}function Ny(e){return`${e} ${e===1?`agent`:`agents`}`}function Py(e){let t=Math.max(1,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}function Fy(e){let t=e.agentRuns.length>0?`, ${Ny(e.agentRuns.length)}`:``;return`Worked ${Py(e.endedAt-e.startedAt)}${t}`}function Iy(e,t){let n=t>0?`${Ny(t)} running`:``;return e===null?n:n?`Working ${Py(e)}, ${n}`:`Working ${Py(e)}`}function Ly(e){return e.length<=ry?e:e.slice(e.length-ry)}var Ry=`(max-width: 768px)`,zy=`(pointer: coarse)`;function By({coarse:e,narrowWidth:t}={}){return e===!0&&t===!0?`phone`:`desktop`}var Vy=window.matchMedia?.(zy),Hy=window.matchMedia?.(Ry);function Uy(){return By({coarse:!!Vy?.matches,narrowWidth:!!Hy?.matches})}function Wy(e){document.documentElement.dataset.layout!==e&&(document.documentElement.dataset.layout=e)}function Gy(){kr.subscribe((e,t)=>{t.includes(`layout`)&&Wy(e.layout)});let e=Uy();Wy(e),kr.dispatch(`setLayout`,e);let t=()=>kr.dispatch(`setLayout`,Uy());return Vy?.addEventListener?.(`change`,t),Hy?.addEventListener?.(`change`,t),e}function Ky(){return kr.snapshot().layout===`phone`}function qy(e){return kr.subscribe((t,n)=>{n.includes(`layout`)&&e(t.layout)})}var Jy=`CommitMono`,Yy=[400,700].map(e=>`${e} 14px ${Jy}`),Xy=`monospace`;function Zy(e){return e.trim().replace(/^['"]|['"]$/g,``)}function Qy(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>Zy(e)!==Jy);return r.length>0?r.join(`, `):Xy}function $y(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function eb(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function tb(){return document.fonts?Yy.every(e=>document.fonts.check(e)):!1}function nb(){return Qy(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),tb())}function rb(e){document.fonts&&$y(document.fonts,Yy,e)}var ib=6,ab=262144,ob=16384,sb=()=>{};function cb(e,t){if(t.length<=ob)e.push(t);else for(let n=0;n<t.length;n+=ob)e.push(t.slice(n,n+ob))}function lb({budget:e=ib,maxChunkBytes:t=ab,requestFrame:n,cancelFrame:r}={}){let i=n||(e=>requestAnimationFrame(e)),a=r||(e=>cancelAnimationFrame(e)),o=new Map,s=[],c=0,l=null;function u(){l===null&&(l=i(h))}function d(e){return e.readIdx<e.pending.length}function f(e){d(e)||(e.pending.length=0,e.readIdx=0,e.dirty=!1)}function p(e){return!!(e?.live&&e.dirty&&!e.inFlight&&d(e))}function m(){for(let e of o.values())if(p(e))return!0;return!1}function h(){l=null;let n=s.length,r=0;for(let i=0;i<n&&r<e;i++){let e=s[(c+i)%n],a=o.get(e);if(!p(a))continue;let l=[],m=0;for(;a.readIdx<a.pending.length;){let e=a.pending[a.readIdx];if(typeof e!=`string`){if(m>0)break;a.readIdx++,e.run();continue}let n=t-m;if(m+e.length<=t)cb(l,e),m+=e.length,a.readIdx++;else{m===0&&(cb(l,e.slice(0,n)),m+=n,a.pending[a.readIdx]=e.slice(n));break}}let h=l.pop();if(h===void 0)f(a),r++;else{f(a),d(a)&&a.readIdx>=64&&(a.pending.splice(0,a.readIdx),a.readIdx=0),a.inFlight=!0;for(let e of l)a.write(e,sb);a.write(h,()=>{a.live&&(a.inFlight=!1,d(a)&&(a.dirty=!0,u()))}),r++}}n>0&&(c=(c+1)%n),m()&&u()}return{register(e,t){let n=o.get(e);n?(n.write=t,n.live=!0):(o.set(e,{write:t,pending:[],readIdx:0,inFlight:!1,dirty:!1,live:!0}),s.push(e))},unregister(e){let t=o.get(e);if(!t)return;t.live=!1,o.delete(e);let n=s.indexOf(e);n!==-1&&s.splice(n,1),c>=s.length&&(c=0)},enqueue(e,t){let n=o.get(e);n&&t&&(n.pending.push(t),n.dirty=!0,u())},enqueueAction(e,t){let n=o.get(e);n&&(n.pending.push({run:t}),n.dirty=!0,u())},has(e){return o.has(e)},size(){return o.size},running(){return l!==null},stop(){l!==null&&(a(l),l=null)}}}var ub=lb(),db=.3,fb=null;function pb(){return xs(fb)}function mb(e){return Ss(e,fb)}async function hb(){try{let e=await fetch(hs,{credentials:`same-origin`,cache:`no-store`});e.ok&&(fb=Cs(await e.json()))}catch{}}function gb(){let e=new AudioContext;return e.state===`suspended`&&e.resume(),e}function _b(e,t){setTimeout(()=>e.close().catch(()=>{}),(t+.1)*1e3)}function vb(e){yb(gs[e]??gs.chime)}function yb(e){let t=gb(),n=t.createGain();n.gain.value=e.peakGain,n.connect(t.destination);let r=t.currentTime,i=0;for(let a of e.tones){let e=r+a.startSeconds,o=e+a.durationSeconds,s=t.createOscillator(),c=t.createGain();s.type=a.waveform,s.frequency.setValueAtTime(a.frequency,e),a.endFrequency&&s.frequency.exponentialRampToValueAtTime(a.endFrequency,o),c.gain.setValueAtTime(.001,e),c.gain.exponentialRampToValueAtTime(a.gain??1,e+.01),c.gain.exponentialRampToValueAtTime(.001,o),s.connect(c),c.connect(n),s.start(e),s.stop(o),i=Math.max(i,a.startSeconds+a.durationSeconds)}_b(t,i)}async function bb(e){try{let t=await fetch(ys(e),{credentials:`same-origin`});return t.ok?await t.arrayBuffer():null}catch{return null}}async function xb(e){let t=await bb(e);if(!t)return!1;let n=gb();try{let e=await n.decodeAudioData(t),r=n.createGain();r.gain.value=db,r.connect(n.destination);let i=n.createBufferSource();return i.buffer=e,i.connect(r),i.start(),_b(n,e.duration),!0}catch{return n.close().catch(()=>{}),!1}}var Sb=[659.25,830.61,987.77,1108.73,987.77,830.61,739.99,659.25,739.99,830.61,987.77,1108.73,987.77,830.61];function Cb(){try{let e=new AudioContext;if(e.state===`suspended`&&e.resume(),e.state===`suspended`)return;let t=e.createGain();t.gain.value=.05,t.connect(e.destination);let n=.125,r=e.currentTime;for(let i=0;i<Sb.length;i++){let a=r+i*n,o=e.createOscillator(),s=e.createGain();o.type=`square`,o.frequency.value=Sb[i],s.gain.setValueAtTime(.001,a),s.gain.exponentialRampToValueAtTime(1,a+.01),s.gain.exponentialRampToValueAtTime(.001,a+n*.9),o.connect(s),s.connect(t),o.start(a),o.stop(a+n)}let i=r+Sb.length*n;t.gain.setValueAtTime(.05,i-.05),t.gain.exponentialRampToValueAtTime(.001,i),setTimeout(()=>e.close().catch(()=>{}),(i-r+.1)*1e3)}catch{}}function wb(){try{vb(ps)}catch{}}function Tb(e){try{let t=mb(e),n=bs(t);if(!n){vb(t);return}xb(n).then(e=>{e||wb()})}catch{}}var Eb={"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.06)`,"--state-running":`#22c55e`,"--state-running-bg":`rgba(34, 197, 94, 0.06)`,"--state-waiting":`#f59e0b`,"--state-waiting-bg":`rgba(245, 158, 11, 0.08)`,"--state-failed":`#ef4444`,"--state-failed-bg":`rgba(239, 68, 68, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#eab308`,"--state-idle-bg":`rgba(234, 179, 8, 0.06)`},Db={background:`--bg-card`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#ef4444`,brightRed:`#f87171`,green:`#22c55e`,brightGreen:`#4ade80`,yellow:`#eab308`,brightYellow:`#facc15`,cyan:`#06b6d4`,brightCyan:`#22d3ee`},Ob={golgari:{label:`Golgari (Green/Black)`,colors:{"--bg":`#060b08`,"--bg-card":`#0a120e`,"--bg-header":`#081009`,"--bg-surface":`#0e1a12`,"--border":`#1a2e1f`,"--border-dim":`#122016`,"--border-hover":`#2a4a32`,"--text":`#b8ccbe`,"--text-dim":`#6a9070`,"--text-head":`#dceede`,"--text-muted":`#7a9a80`,"--accent":`#2dd4a0`,"--accent-dim":`#1a9a6e`,...Eb,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#94a3b8`,"--state-done-bg":`rgba(45, 212, 160, 0.06)`,"--state-starting":`#a78bfa`,"--state-starting-bg":`rgba(167, 139, 250, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...Db,foreground:`#c8dece`,blue:`--accent`,brightBlue:`#5ee8bc`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8dece`,brightWhite:`#e8f5ea`}},midnight:{label:`Midnight (Blue/Purple)`,colors:{"--bg":`#080816`,"--bg-card":`#0e0e20`,"--bg-header":`#0b0b1a`,"--bg-surface":`#131328`,"--border":`#1c1c38`,"--border-dim":`#141430`,"--border-hover":`#2a2a50`,"--text":`#b8b8d4`,"--text-dim":`#8585b3`,"--text-head":`#dcdcf0`,"--text-muted":`#7c7ca9`,"--accent":`#4f6ef7`,"--accent-dim":`#3a54c0`,...Eb,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#94a3b8`,"--state-done-bg":`rgba(59, 130, 246, 0.06)`,"--state-starting":`#a855f7`,"--state-starting-bg":`rgba(168, 85, 247, 0.06)`,"--state-complete":`#60a5fa`,"--state-complete-bg":`rgba(96, 165, 250, 0.06)`},terminal:{...Db,foreground:`#c8c8e0`,blue:`--accent`,brightBlue:`#60a5fa`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8c8e0`,brightWhite:`#e8e8ff`}},phyrexian:{label:`Phyrexian (Iridescent)`,colors:{"--bg":`#0a0810`,"--bg-card":`#100e18`,"--bg-header":`#0c0a14`,"--bg-surface":`#16122a`,"--border":`#2a2440`,"--border-dim":`#1e1a32`,"--border-hover":`#3e3660`,"--text":`#c8c0e0`,"--text-dim":`#8d82b9`,"--text-head":`#e8e0ff`,"--text-muted":`#8579b1`,"--accent":`#c084fc`,"--accent-dim":`#9656d6`,...Eb,"--state-monitoring":`#60a5fa`,"--state-monitoring-bg":`rgba(96, 165, 250, 0.08)`,"--state-done":`#67e8f9`,"--state-done-bg":`rgba(103, 232, 249, 0.06)`,"--state-starting":`#f472b6`,"--state-starting-bg":`rgba(244, 114, 182, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...Db,foreground:`#c8c0e0`,blue:`#67e8f9`,brightBlue:`#a5f3fc`,magenta:`--accent`,brightMagenta:`#d8b4fe`,white:`#c8c0e0`,brightWhite:`#e8e0ff`}},compleated:{label:`Compleated (Light)`,colors:{"--bg":`#ece8e0`,"--bg-card":`#f7f4ee`,"--bg-header":`#f0ece4`,"--bg-surface":`#e4e0d6`,"--border":`#b8b0a0`,"--border-dim":`#ccc6b8`,"--border-hover":`#908878`,"--text":`#2a2622`,"--text-dim":`#5a5448`,"--text-head":`#0e0c0a`,"--text-muted":`#676157`,"--accent":`#0e0c0a`,"--accent-dim":`#2a2622`,"--state-running":`#16803c`,"--state-running-bg":`rgba(22, 128, 60, 0.08)`,"--state-waiting":`#b45309`,"--state-waiting-bg":`rgba(180, 83, 9, 0.08)`,"--state-failed":`#dc2626`,"--state-failed-bg":`rgba(220, 38, 38, 0.06)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#64748b`,"--state-done-bg":`rgba(26, 24, 22, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#a16207`,"--state-idle-bg":`rgba(161, 98, 7, 0.06)`,"--state-starting":`#7c3aed`,"--state-starting-bg":`rgba(124, 58, 237, 0.06)`,"--state-complete":`#059669`,"--state-complete-bg":`rgba(5, 150, 105, 0.06)`},terminal:{background:`#faf8f4`,foreground:`#1a1816`,cursor:`#1a1816`,cursorAccent:`#faf8f4`,black:`#1a1816`,brightBlack:`#5a5448`,red:`#b91c1c`,brightRed:`#dc2626`,green:`#15803d`,brightGreen:`#16a34a`,yellow:`#92400e`,brightYellow:`#a16207`,blue:`#1d4ed8`,brightBlue:`#2563eb`,magenta:`#6d28d9`,brightMagenta:`#7c3aed`,cyan:`#0e7490`,brightCyan:`#0891b2`,white:`#5a5448`,brightWhite:`#3a3630`}},unicorn:{label:`Rainbow Unicorns (Dark)`,colors:{"--bg":`#191022`,"--bg-card":`#201730`,"--bg-header":`#1c1329`,"--bg-surface":`#281c3c`,"--border":`#3a2c52`,"--border-dim":`#2a2040`,"--border-hover":`#55407a`,"--text":`#d4c8e6`,"--text-dim":`#9a88b8`,"--text-head":`#ede4fa`,"--text-muted":`#a897c4`,"--accent":`#e8a3c4`,"--accent-dim":`#c4739e`,"--state-running":`#42d780`,"--state-running-bg":`rgba(66, 215, 128, 0.10)`,"--state-waiting":`#f79f3b`,"--state-waiting-bg":`rgba(247, 159, 59, 0.10)`,"--state-failed":`#f05442`,"--state-failed-bg":`rgba(240, 84, 66, 0.13)`,"--state-monitoring":`#2dd4bf`,"--state-monitoring-bg":`rgba(45, 212, 191, 0.08)`,"--state-done":`#f04ca4`,"--state-done-bg":`rgba(240, 76, 164, 0.13)`,"--state-initializing":`#8f87a6`,"--state-initializing-bg":`rgba(143, 135, 166, 0.08)`,"--state-idle":`#bcb02f`,"--state-idle-bg":`rgba(188, 176, 47, 0.08)`,"--state-starting":`#a17ef1`,"--state-starting-bg":`rgba(161, 126, 241, 0.08)`,"--state-complete":`#34baf4`,"--state-complete-bg":`rgba(52, 186, 244, 0.14)`},terminal:{background:`#201730`,foreground:`#d4c8e6`,cursor:`--accent`,cursorAccent:`#201730`,black:`#8c7dab`,brightBlack:`#9c8fb5`,red:`#e8887e`,brightRed:`#f4a89f`,green:`#86e0ab`,brightGreen:`#a3edc0`,yellow:`#f0c674`,brightYellow:`#f5d896`,blue:`#9cb3f0`,brightBlue:`#b5c8f5`,magenta:`#dd8ecf`,brightMagenta:`#e6a8dc`,cyan:`#7fd4d0`,brightCyan:`#a0e6e2`,white:`#d4c8e6`,brightWhite:`#f4ecfc`}},"posthog-light":{label:`PostHog (Light)`,colors:{"--bg":`#eeefe9`,"--bg-card":`#fdfdf8`,"--bg-header":`#eeefe9`,"--bg-surface":`#e5e7e0`,"--border":`#bfc1b7`,"--border-dim":`#d2d3cc`,"--border-hover":`#9ea096`,"--text":`#23251d`,"--text-dim":`#65675e`,"--text-head":`#111111`,"--text-muted":`#73756b`,"--accent":`#c03300`,"--accent-dim":`#8e2600`,"--state-running":`#237a36`,"--state-running-bg":`rgba(77, 117, 51, 0.08)`,"--state-waiting":`#b17816`,"--state-waiting-bg":`rgba(177, 120, 22, 0.10)`,"--state-failed":`#8c0d3b`,"--state-failed-bg":`rgba(140, 13, 59, 0.07)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#3e6b9e`,"--state-done-bg":`rgba(62, 107, 158, 0.08)`,"--state-initializing":`#73756b`,"--state-initializing-bg":`rgba(115, 117, 107, 0.07)`,"--state-idle":`#835c19`,"--state-idle-bg":`rgba(131, 92, 25, 0.07)`,"--state-starting":`#a621c8`,"--state-starting-bg":`rgba(166, 33, 200, 0.07)`,"--state-complete":`#34796f`,"--state-complete-bg":`rgba(52, 121, 111, 0.08)`},terminal:{background:`--bg-card`,foreground:`#23251d`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`#23251d`,brightBlack:`#65675e`,red:`#c03300`,brightRed:`#df6133`,green:`#4d7533`,brightGreen:`#6aa84f`,yellow:`#835c19`,brightYellow:`#b17816`,blue:`#3e6b9e`,brightBlue:`#2f80fa`,magenta:`#74108d`,brightMagenta:`#a621c8`,cyan:`#34796f`,brightCyan:`#30abc6`,white:`#4d4f46`,brightWhite:`#23251d`}},"posthog-dark":{label:`PostHog (Dark)`,colors:{"--bg":`#1e1f23`,"--bg-card":`#25262b`,"--bg-header":`#232429`,"--bg-surface":`#2d2e37`,"--border":`#3e424f`,"--border-dim":`#32343f`,"--border-hover":`#626674`,"--text":`#edeef4`,"--text-dim":`#aeb3c2`,"--text-head":`#fafafa`,"--text-muted":`#9ea096`,"--accent":`#f87a4c`,"--accent-dim":`#f54e00`,"--state-running":`#36c46f`,"--state-running-bg":`rgba(54, 196, 111, 0.08)`,"--state-waiting":`#f7a501`,"--state-waiting-bg":`rgba(247, 165, 1, 0.09)`,"--state-failed":`#f35454`,"--state-failed-bg":`rgba(243, 84, 84, 0.09)`,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#589df8`,"--state-done-bg":`rgba(88, 157, 248, 0.08)`,"--state-initializing":`#8f8f8c`,"--state-initializing-bg":`rgba(143, 143, 140, 0.07)`,"--state-idle":`#ffce5c`,"--state-idle-bg":`rgba(255, 206, 92, 0.07)`,"--state-starting":`#8567ff`,"--state-starting-bg":`rgba(133, 103, 255, 0.09)`,"--state-complete":`#29dbbb`,"--state-complete-bg":`rgba(41, 219, 187, 0.08)`},terminal:{background:`--bg-card`,foreground:`#edeef4`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#f35454`,brightRed:`#f87a4c`,green:`#36c46f`,brightGreen:`#96e5b6`,yellow:`#f7a501`,brightYellow:`#ffce5c`,blue:`#2f80fa`,brightBlue:`#9fc4ff`,magenta:`#8567ff`,brightMagenta:`#e2d6ff`,cyan:`#30abc6`,brightCyan:`#29dbbb`,white:`#aeb3c2`,brightWhite:`#fafafa`}}},kb=`phyrexian`,Ab=null;function jb(e){let t=Ob[e];if(!t)return;let n=Ab;Ab=e;let r=document.documentElement;r.dataset.theme=e;for(let[e,n]of Object.entries(t.colors))r.style.setProperty(e,n);e===`unicorn`&&n!==null&&n!==`unicorn`&&Cb()}function Mb(e){document.documentElement.toggleAttribute(`data-show-usage`,e)}function Nb(e){document.documentElement.toggleAttribute(`data-arrow-pad`,e)}function Pb(){let e=Ob[Ab||kb];if(!e)return{};let t=getComputedStyle(document.documentElement),n={};for(let[r,i]of Object.entries(e.terminal))n[r]=i.startsWith(`--`)?t.getPropertyValue(i).trim():i;return n}function Fb(){return Object.entries(Ob).map(([e,t])=>({id:e,label:t.label}))}var Ib=c().int().min(1).max(500),Lb=c().int().min(1).max(200);d(`type`,[g({type:m(`input`),data:l()}),g({type:m(`claim`),cols:Ib,rows:Lb}),g({type:m(`unview`)})]);var Rb=g({type:m(`pty-size`),cols:Ib,rows:Lb,seq:c().int().nonnegative()}),zb=`history`;u([`screen`,`deep`]);function Bb(e){try{return JSON.parse(e)}catch{return null}}function Vb(e){let t=Rb.safeParse(Bb(e));return t.success?t.data:null}function Hb(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function Ub(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function Wb(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function Gb({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&Hb(e,n))}function Kb({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function qb({isDocumentVisible:e,isBorrowedCard:t,isTerminalFaceShown:n}){return!e||!t||!n}function Jb({viewportTopLine:e,scrollbackLineCount:t,isDeepHistoryLoadedOrPending:n}){return e===0&&t>0&&t<5e3&&!n}function Yb(e,t){let n=`/terminals/${encodeURIComponent(e)}`;return t?`${n}?${zb}=deep`:n}function Xb({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:Gb({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function Zb({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function Qb({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!Hb(e,t),s=Ub(n)?Wb(n):null,c=r&&!!s&&!Hb(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:Gb({authoritative:e,isActiveViewer:r,lastClaim:a})}}function $b(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function ex(e){let t=$b(e);return t===null?null:Vb(t)}function tx(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=ex(e);return n?t.hasSeenSize?n.seq<=t.lastSeq?{kind:`stale`}:{kind:`size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`attach-size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`ignored`}}var nx=``,rx=`\x1B`,ix=`\r`,ax=new Map([[`deleteContentBackward`,nx],[`deleteByComposition`,nx],[`deleteCompositionText`,nx],[`deleteWordBackward`,rx],[`deleteSoftLineBackward`,rx],[`deleteHardLineBackward`,rx]]);function ox(e){return ax.get(e)??``}var sx=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function cx(e){return typeof e!=`string`||e===``||!sx.has(e)}function lx(e){return e?e.keyCode===229||e.key===`Process`:!1}function ux(e,t){let n=Array.from(e??``),r=Array.from(t??``),i=Math.min(n.length,r.length),a=0;for(;a<i&&n[a]===r[a];)a++;return nx.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,ix)}var dx=/https?:\/\/[^\s<>"']+/g,fx=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),px={")":`(`,"]":`[`,"}":`{`};function mx(e,t){let n=0;for(let r of e)r===t&&n++;return n}function hx(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(fx.has(t)){e=e.slice(0,-1);continue}let n=px[t];if(n&&mx(e,n)<mx(e,t))e=e.slice(0,-1);else return e}}function gx(e){let t=[];for(let n of e.matchAll(dx)){let e=hx(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var _x=50;function vx(){return{activate(e,t){pg(t)},allowNonHttpProtocols:!1}}function yx(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<_x;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<_x;)r++;let i=``,a=[];for(let t=n;t<=r;t++){let n=e.getLine(t);if(!n)break;for(let e=0;e<n.length;e++){let r=n.getCell(e);if(!r)break;if(r.getWidth()===0)continue;let o=r.getChars()||` `;for(let n=0;n<o.length;n++)i+=o[n],a.push({x:e+1,y:t+1})}}return{text:i,cellAt:a}}function bx(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=yx(r,t),o=[];for(let{start:e,end:t,url:n}of gx(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){pg(t)}})}n(o.length?o:void 0)}})}var xx=`(?:password|passwd|pwd|token|api[_-]?key|secret|credential|auth[_-]?token|access[_-]?key|secret[_-]?key|private[_-]?key|client[_-]?secret|connection[_-]?string)`,Sx=`(?:"[^"\\r\\n]*"|'[^'\\r\\n]*'|[^\\s\\r\\n]+)`,Cx=`[^\\S\\r\\n]`,wx=`${xx}${Cx}*(?:=>|[:=])${Cx}*`,Tx=`[?&][A-Za-z0-9_.-]*`,Ex=`[^\\r\\n;&|]{0,200}?`,Dx=`(?:mysql|mysqldump|mysqladmin|mysqlshow|mariadb|mariadb-dump)`,Ox=RegExp(`(${wx})${Sx}`,`gi`),kx=RegExp(`(\\bBearer${Cx}+)[A-Za-z0-9._~+/=-]{8,}`,`gi`),Ax=[/\bAKIA[0-9A-Z]{16}\b/g,/\bgh[pousr]_[A-Za-z0-9]{16,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{20,}/g,/\bsk-[A-Za-z0-9_-]{20,}/g,/\bph[cx]_[A-Za-z0-9]{20,}\b/g,/\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g,/\beyJ[A-Za-z0-9_=-]{6,}\.[A-Za-z0-9_=-]{6,}\.[A-Za-z0-9_=-]{4,}/g,/-----BEGIN(?:[A-Z0-9 ]+)? PRIVATE KEY-----/g],jx=[RegExp(`((?:^|\\s)--?${xx}${Cx}+)${Sx}`,`gi`),RegExp(`((?:^|\\s)-(?:pwd|pw)(?![a-z])${Cx}*=?${Cx}*)${Sx}`,`g`),RegExp(`(-AsPlainText${Cx}+)${Sx}`,`gi`),RegExp(`((?:^|\\s)setx${Cx}+[^\\s\\r\\n]*${xx}[^\\s\\r\\n]*${Cx}+)${Sx}`,`gi`)],Mx=[RegExp(`(\\bauthorization${Cx}*:${Cx}*Basic${Cx}+)[A-Za-z0-9+/=_-]{8,}`,`gi`),RegExp(`(\\bdocker${Cx}+login\\b${Ex}${Cx}-p(?:${Cx}+|=))${Sx}`,`gi`),RegExp(`(\\bcurl\\b${Ex}${Cx}(?:--user|-u)(?:${Cx}+|=)[^\\s:\\r\\n]+:)${Sx}`,`gi`),RegExp(`(\\b${Dx}\\b${Ex}${Cx}-p)${Sx}`,`g`),/\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+(?=@)/gi];[...jx,...Mx];var Nx=[/-----END(?:[A-Z0-9 ]+)? PRIVATE KEY-----/g,/^([^\S\r\n]*)(?=[A-Za-z0-9+/]*[g-zG-Z+/])(?=[A-Za-z0-9+/=]{60,76}[^\S\r\n]*$)[A-Za-z0-9+/]+={0,2}(?=[^\S\r\n]*$)/gm],Px=RegExp(`(${Tx}(?:${xx}|_key)=)[^&#\\s]+`,`gi`),Fx=[Ox,RegExp(`(\\b(?=[A-Z0-9_]*(?:SECRET|TOKEN|KEY|PASSWORD))[A-Z][A-Z0-9_]*=)${Sx}`,`g`)],Ix=[kx,...jx,...Mx,...Ax,...Nx];function Lx(e,t){return[...e.matchAll(t)].map(e=>({matchStart:e.index,valueStart:e.index+(e[1]??``).length,end:e.index+e[0].length}))}function Rx(e,t){let n=0;return e.filter(e=>{for(;n<t.length&&t[n].end<=e.matchStart;)n+=1;let r=t.at(n);return!r||e.matchStart<r.matchStart})}function zx(e){let t=[];for(let n of e.toSorted((e,t)=>e.start-t.start)){let e=t.at(-1);e&&n.start<=e.end?e.end=Math.max(e.end,n.end):t.push({...n})}return t}function Bx(e){let t=Lx(e,Px);return zx([...t,...Fx.flatMap(n=>Rx(Lx(e,n),t)),...Ix.flatMap(t=>Lx(e,t))].map(e=>({start:e.valueStart,end:e.end})))}var Vx=`#808080`,Hx=new WeakMap;function Ux(e,t,n){return`${e}:${t}:${n}`}function Wx(e){return Ux(e.marker.line,e.x,e.width)}function Gx(e,t){let n=t;for(;n>0&&t-n<63&&e.getLine(n)?.isWrapped;)n--;return n}function Kx(e,t){let n=t;for(;n-t<63&&e.getLine(n+1)?.isWrapped;)n++;return n}function qx(e,t,n){let r=``;for(let i=t;i<=n;i++)r+=e.getLine(i)?.translateToString(!1)??``;return r}function Jx(e,t,n,r){let i=``,a=[];for(let o=t;o<=n;o++){let t=e.getLine(o);if(!t)break;for(let e=0;e<t.length;e++){let n=t.getCell(e,r);if(!n)break;let s=n.getWidth();if(s===0)continue;let c=n.getChars()||` `;for(let t=0;t<c.length;t++)i+=c[t],a.push({line:o,x:e,width:s})}}return{text:i,cellAt:a}}function Yx(e,t){let n=null;for(let r of t)n&&n.line===r.line?n.width=Math.max(n.width,r.x+r.width-n.x):(n={line:r.line,x:r.x,width:r.width},e.push(n))}function Xx(e,t,n,r){let i=[];if(Bx(qx(e,t,n)).length===0)return i;let{text:a,cellAt:o}=Jx(e,t,n,r);for(let e of Bx(a))Yx(i,o.slice(e.start,e.end));return i}function Zx(e,t){let n=e.getNullCell(),r=[],i=t;for(;i<e.length;){let t=Kx(e,i);r.push(...Xx(e,i,t,n)),i=t+1}return r}function Qx(){return{masks:[],watermark:null,isFullRescanOwed:!0}}function $x(e){e.decoration.dispose(),e.marker.dispose()}function eS(e){for(let t of e.masks)$x(t);e.masks.length=0,e.watermark?.dispose(),e.watermark=null,e.isFullRescanOwed=!0}function tS(e,t){let n=e.watermark;return e.isFullRescanOwed||!n||n.isDisposed?0:Math.min(n.line,t.baseY)}function nS(e){let t=0;for(;t<e.masks.length&&e.masks[t].marker.isDisposed;)e.masks[t].decoration.dispose(),t++;t>0&&e.masks.splice(0,t)}function rS(e,t){let n=new Map,r=e.masks.at(-1);for(;r&&(r.marker.isDisposed||r.marker.line>=t);)e.masks.pop(),r.marker.isDisposed&&r.decoration.dispose(),r.marker.isDisposed||n.set(Wx(r),r),r=e.masks.at(-1);return nS(e),n}function iS(e,t){let n={normal:Qx(),alternate:Qx()},r=e.cols;function i(t){return e.buffer.active.type===t}function a(t,n){if(!i(n)||t.isDisposed)return!1;let r=t.line-e.buffer.active.viewportY;return r>=0&&r<e.rows}function o(t,n,r){t.style.backgroundColor=e.options.theme?.foreground??Vx,t.style.pointerEvents=`none`,t.style.display=a(n,r)?`block`:`none`}function s(e){for(let t of n[e].masks){let n=t.decoration.element;n&&o(n,t.marker,e)}}function c(t,n){let r=e.registerMarker(t.line-(n.baseY+n.cursorY));if(!r)return null;let i=e.registerDecoration({marker:r,x:t.x,width:t.width,layer:`top`});if(!i)return r.dispose(),null;let a=n.type;return i.onRender(e=>o(e,r,a)),{marker:r,decoration:i,x:t.x,width:t.width}}function l(){if(!oh())return;let t=e.buffer.active,r=n[t.type],i=Gx(t,tS(r,t)),a=rS(r,i);for(let e of Zx(t,i)){let n=Ux(e.line,e.x,e.width),i=a.get(n);a.delete(n);let o=i??c(e,t);o&&r.masks.push(o)}for(let e of a.values())$x(e);r.watermark?.dispose(),r.watermark=e.registerMarker(-t.cursorY)??null,r.isFullRescanOwed=!1}function u(){eS(n.normal),eS(n.alternate)}function d(){u(),r=e.cols,l()}let f=[e.onWriteParsed(l),e.onResize(({cols:e})=>{e!==r&&(r=e,n.normal.isFullRescanOwed=!0,n.alternate.isFullRescanOwed=!0,l())}),e.buffer.onBufferChange(e=>{eS(n.alternate),s(`normal`),e.type===`alternate`&&l()})],p=ch(d);t.addEventListener(`abort`,()=>{p();for(let e of f)e.dispose();u(),Hx.delete(e)},{once:!0}),Hx.set(e,d)}function aS(e){Hx.get(e)?.()}function oS({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}async function sS(e,t){let n={"x-glimmervoid-upload-name":encodeURIComponent(t.name)};t.type&&(n[`content-type`]=t.type);try{let r=await fetch(`/upload/${encodeURIComponent(e)}`,{method:`POST`,body:t,headers:n});return r.ok?!0:(Nd(await lS(r)),!1)}catch{return Nd(`Upload failed`),!1}}async function cS(e,t){for(let n of t)await sS(e,n)}async function lS(e){try{let t=await e.json();if(t&&typeof t.error==`string`)return`Upload failed: ${t.error}`}catch{}return`Upload failed`}var uS=1.2,dS=.005;function fS(e,t){let n=Math.abs(t);return n<10?!1:n>Math.abs(e)*uS}function pS(e,t,n=1/0){if(!(t>0))return{scrollLines:0,remainderPx:e};let r=Math.trunc(e/t),i=Math.max(-n,Math.min(n,r));return{scrollLines:i===0?0:-i,remainderPx:e-i*t}}function mS(e,t,n){let r=e.length>=4?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function hS(e){if(!e||e.length<2)return 0;let t=e[0],n=e[e.length-1],r=n.timestampMs-t.timestampMs;if(!(r>0))return 0;let i=(n.positionPx-t.positionPx)/r,a=Math.abs(i);if(!(a>=.08))return 0;let o=Math.min(a,5);return i<0?-o:o}function gS({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function _S(e,t){if(!e)return{scrollLines:0,state:null};let n=t-e.lastMs;if(!(n>0))return{scrollLines:0,state:e};let r=Math.abs(e.velocityPxPerMs)-dS*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=pS(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function vS(e,t){return e===`alternate`||!!t&&t!==`none`}function yS(e,t){return!(e>0)||!(t>0)?0:e/t}var bS=1;function xS(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function SS(e,t){for(let n of e)if(n.identifier===t)return n;return null}function CS(e,t){if(xS(t))return;let n=()=>document.documentElement.dataset.layout===`phone`,r=null,i=0,a=0,o=0,s=!1,c=0,l=[],u=null,d=null,f=()=>{d!==null&&cancelAnimationFrame(d),d=null,u=null},p=()=>vS(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return yS(e?.clientHeight||t.element?.clientHeight||0,t.rows)},h=()=>{r=null,s=!1,c=0,l=[]},g=(e,n,r)=>{let i=e<0?-1:1;for(let a=0;a<Math.abs(e);a++)t.element?.dispatchEvent(new WheelEvent(`wheel`,{deltaY:i,deltaMode:bS,clientX:n,clientY:r,bubbles:!0,cancelable:!0}))},_=()=>{if(d=null,!u)return;if(!e.isConnected||!n()||p()){f();return}let r=t.buffer?.active?.viewportY,{scrollLines:i,state:a}=_S(u,performance.now());u=a,i!==0&&t.scrollLines(i),u&&(i!==0&&t.buffer?.active?.viewportY===r?f():d=requestAnimationFrame(_))},v=(e,t,n)=>{u=gS({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:m(),pendingPx:n}),u&&(d=requestAnimationFrame(_))};e.addEventListener(`touchstart`,e=>{if(f(),!n()||e.touches.length!==1){h();return}let t=e.touches[0];r=t.identifier,i=t.clientX,a=t.clientY,o=t.clientY,s=!1,c=0,l=[]},{passive:!0}),e.addEventListener(`touchmove`,e=>{if(r===null||!n())return;let u=SS(e.touches,r);if(!u)return;if(!s){if(!fS(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=mS([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=mS(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=pS(c,m(),d?8:void 0);c=h,f!==0&&(d?g(f,u.clientX,u.clientY):t.scrollLines(f))},{passive:!1}),e.addEventListener(`touchend`,e=>{if(!s||p()){h();return}l=mS(l,o,e.timeStamp);let t=hS(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}function wS(e){return e.needsReload?!0:e.wasAttachedWithoutLayout&&e.hasLayoutNow}function TS(e,t,n=[]){let r=new Set(Array.isArray(n)?n:[n]),i=[];for(let n of e)e.length-i.length>=t&&!r.has(n)&&i.push(n);return i}var ES=window.matchMedia?.(`(pointer: coarse)`).matches?4:12,DS=new Map;function OS(e){return e.clientWidth>0&&e.clientHeight>0}function kS(e){let t=e.webglAddon;if(!t)return;let n=[...e.term?.element?.querySelectorAll(`canvas`)??[]];e.webglAddon=null;try{t.dispose()}catch{}for(let e of n)e.getContext(`webgl2`)?.getExtension(`WEBGL_lose_context`)?.loseContext()}function AS(e){DS.delete(e),e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,kS(e)}function jS(e){let t=[e],n=kr.snapshot().borrowedCardId,r=n?F.get(n):void 0;r&&t.push(r);for(let e of TS([...DS.keys()],ES,t))AS(e),e.needsWebGLReload=!0}function MS(e){e?.term&&wS({needsReload:e.needsWebGLReload,wasAttachedWithoutLayout:e.webglAttachedWithoutLayout,hasLayoutNow:OS(e.termWrap)})&&PS(e,{isForced:!0})}function NS(){for(let e of DS.keys()){let t=e.term;if(e.webglAddon&&t)try{t.clearTextureAtlas(),t.refresh(0,t.rows-1)}catch{AS(e),e.needsWebGLReload=!0}}}function PS(e,t={}){try{if(e.webglAddon&&!e.needsWebGLReload&&!t.isForced){DS.delete(e),DS.set(e,!0);return}e.webglAddon&&(kS(e),DS.delete(e)),jS(e);let n=new b;n.onContextLoss(()=>{n.dispose(),e.webglAddon=null,DS.delete(e),e.needsWebGLReload=!0});let r=e.term;if(!r)throw Error(`webgl: the terminal was disposed before the addon loaded`);r.loadAddon(n),e.webglAddon=n,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!OS(e.termWrap),DS.set(e,!0),requestAnimationFrame(()=>{e.webglAddon===n&&e.term&&e.term.refresh(0,e.term.rows-1)})}catch{e.webglAddon=null,e.needsWebGLReload=!1,e.webglAttachedWithoutLayout=!1,DS.delete(e)}}function FS(e){let t=Hp(e,Xp,{isTerminalFocused:!0});return t?Up(t,document.body.dataset.activeView):!1}var IS=1024,LS=250,RS=`(max-width: 768px)`,zS=12,BS=14,VS=5e4,HS=!1;function US(e){HS=e}var WS=!1;window.addEventListener(`blur`,()=>{WS=!0}),window.addEventListener(`focus`,()=>{WS=!1});function GS(e){let t=document.activeElement;return Kb({isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),hasFocusInsideCard:t instanceof Node&&e.contains(t),hasWindowBlurredSinceFocus:WS,isPhoneLayout:Ky()})}function KS(e,t){return qb({isDocumentVisible:document.visibilityState===`visible`,isBorrowedCard:kr.snapshot().borrowedCardId===t,isTerminalFaceShown:e.face===`terminal`})}var qS=new WeakMap,JS=new WeakMap,YS=new WeakSet,XS=new WeakSet,ZS=new WeakMap,QS=5e3,$S=15e3,eC=`Keys you type now are held and sent once the terminal reconnects.`,tC=`The terminal is still reconnecting and its key buffer is full, so new keys are dropped.`,nC=`The agent copied text. The browser needs a click before it can reach your clipboard.`,rC=`The clipboard is unavailable in this browser.`;function iC(e,t,n,r){let i=ZS.get(e);i&&(i.clearTimerId!==null&&clearTimeout(i.clearTimerId),i.clearTimerId=null,i.shownKind=t,i.status.show(n,r),n!==`busy`&&(i.clearTimerId=setTimeout(()=>aC(e,t),n===`ok`?QS:$S)))}function aC(e,t){let n=ZS.get(e);n&&n.shownKind===t&&(n.clearTimerId!==null&&clearTimeout(n.clearTimerId),n.clearTimerId=null,n.shownKind=null,n.status.clear())}function oC(e){let t=e.buffer.active;return t.viewportY<t.baseY}function sC(e,t,{hasNewOutput:n=!1}={}){let r=ZS.get(e)?.jumpToLatestButton;if(!r)return;let i=oC(t);r.hidden=!i,i?n&&(r.dataset.hasNewOutput=`true`):delete r.dataset.hasNewOutput}function cC(e,t){if(qS.has(e)||!oC(t))return;let n=t.buffer.active,r=n.length-n.viewportY;YS.has(e)?qS.set(e,r):JS.set(e,r)}function lC(e,t,n){let r=e.term;r&&Jb({viewportTopLine:n,scrollbackLineCount:r.buffer.active.baseY,isDeepHistoryLoadedOrPending:YS.has(e)})&&(YS.add(e),XS.add(e),qS.set(e,r.buffer.active.length-n),MC(t))}function uC(e,t){e._hasMissedOutputWhileHidden&&(KS(e,t)||(e._hasMissedOutputWhileHidden=!1,MC(t)))}document.addEventListener(`visibilitychange`,()=>{if(document.visibilityState!==`visible`)return;let e=kr.snapshot().borrowedCardId;if(!e)return;let t=F.get(e);t&&uC(t,e)});function dC(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new TextDecoder().decode(n)}function fC(e,t,n){let r=(n instanceof Error?n.message:``)||String(n);console.error(`[clipboard:${t}]`,n),iC(e,`clipboard`,`error`,`Clipboard ${t} failed: ${r}`)}function pC(e,t,n,r){let i=yr(t);i?i.then(()=>{r&&iC(e,`clipboard`,`ok`,r)}).catch(t=>fC(e,n,t)):iC(e,`clipboard`,`error`,rC)}function mC(e,t){let n=ZS.get(e);n&&(n.pendingClipboardText=t,n.clipboardPrompt.hidden=!1)}function hC(e){let t=ZS.get(e),n=t?.pendingClipboardText;t&&n!=null&&(t.pendingClipboardText=null,t.clipboardPrompt.hidden=!0,pC(e,n,`osc52 write`,`Copied to the clipboard.`))}function gC(e,t,n){let r=Od(`terminal-notice`),i=M(`div`,`terminal-clipboard-prompt`);i.hidden=!0;let a=M(`button`,`btn-dialog btn-dialog-confirm`,`Copy to clipboard`);a.type=`button`,a.addEventListener(`click`,()=>hC(t)),i.append(M(`span`,`terminal-clipboard-prompt-text`,nC),a);let o=M(`div`,`terminal-notices`);o.append(i,r.element);let s=M(`button`,`terminal-jump-latest btn-dialog btn-dialog-ghost`,`Jump to latest`);s.type=`button`,s.hidden=!0,s.addEventListener(`click`,()=>{n.scrollToBottom(),n.focus()});let c=M(`div`,`terminal-drop-zone`);c.setAttribute(`aria-hidden`,`true`),c.append(M(`span`,`terminal-drop-zone-label`,`Drop to upload to this session`)),e.append(o,s,c),ZS.set(t,{status:r,shownKind:null,clearTimerId:null,clipboardPrompt:i,pendingClipboardText:null,jumpToLatestButton:s})}function _C(e,t){return F.get(e)===t&&!t.dataWs}function vC(e){return e.querySelector(`:scope > .terminal-connecting`)}function yC(e){if(vC(e))return;let t=M(`div`,`terminal-connecting`);t.append(M(`span`,`terminal-connecting-label`,`Connecting`)),e.append(t)}function bC(e){let t=vC(e);if(!t)return;t.querySelector(`:scope > .terminal-connecting-animal`)?.remove();let n=Kc();n&&t.prepend(Gc(n,`terminal-connecting-animal`))}var xC=new Set;function SC(e){return xC.add(e),()=>xC.delete(e)}function CC(){let e=0;for(let t of F.values())t.card.dataset.link===`connecting`&&e++;return e}function wC(e){let t=oS({hasTerminal:e.term!==null,isSocketOpen:e.dataWs?.readyState===WebSocket.OPEN,isInputHeld:OC}),n=t===`connecting`&&!OC&&XS.has(e)?`live`:t;if(n===`none`){delete e.card.dataset.link,TC();return}let r=n===`connecting`&&e.card.dataset.link!==`connecting`;e.card.dataset.link=n,r&&bC(e.termWrap),TC()}function TC(){for(let e of xC)e()}function EC(e,t,n,r){cC(t,n),ub.unregister(e),t.dataWs=null,wC(t),t._resetGridClaim?.(),setTimeout(()=>{_C(e,t)&&sl().catch(()=>{}).then(()=>{_C(e,t)&&DC(e,t,n)})},r)}function DC(e,t,n){let r=qS.get(t);qS.delete(t);let i=JS.get(t);JS.delete(t);let a=r!==void 0,o=r??i,s=!1,c=rl(location,ll(Yb(e,a))),l=new WebSocket(c);l.binaryType=`arraybuffer`,t.dataWs=l,wC(t);let u=!1,d={hasSeenSize:!1,lastSeq:0};ub.register(e,(e,t)=>n.write(e,t)),l.addEventListener(`message`,r=>{if(t.dataWs!==l)return;let i=tx(r.data,d);if(i.kind===`bytes`){wf(t);let r=s;if(s=!1,KS(t,e)){t._hasMissedOutputWhileHidden=!0;return}if(ub.enqueue(e,i.data),!r)return;let a=o??0;ub.enqueueAction(e,()=>{n.scrollToLine(Math.max(0,n.buffer.active.length-a))});return}if(i.kind===`attach-size`){t._hasMissedOutputWhileHidden=!1,s=o!==void 0,a||YS.delete(t),d.hasSeenSize=!0,d.lastSeq=i.seq,n.reset(),aS(n),t.ptySize={cols:i.cols,rows:i.rows},t._syncGrid?.();return}if(i.kind!==`size`)return;d.lastSeq=i.seq;let c={cols:i.cols,rows:i.rows};ub.enqueueAction(e,()=>{t.ptySize=c,t._syncGrid?.()})}),l.addEventListener(`close`,()=>{if(t.dataWs!==l)return;XS.delete(t),u||cl();let r=Qc(t._dataWsRetryAttempt||0);t._dataWsRetryAttempt=(t._dataWsRetryAttempt||0)+1,EC(e,t,n,r)}),l.addEventListener(`open`,()=>{u=!0,t._dataWsRetryAttempt=0,XS.delete(t),wC(t),t._syncGrid?.({isActivationEdge:!0}),t._retryOwedGridClaim?.(),t._inputQueue?.length&&setTimeout(()=>{t.dataWs===l&&kC(t)},50)})}var OC=!1;function kC(e){let t=e._inputQueue,n=e.dataWs;if(!OC&&t?.length&&n?.readyState===WebSocket.OPEN){for(let e of t)n.send(JSON.stringify({type:`input`,data:e}));t.length=0,aC(e,`keys`)}}function AC(){OC=!0;for(let e of F.values())wC(e)}function jC(){OC=!1;for(let e of F.values())wC(e),kC(e)}function MC(e){let t=I(e);if(typeof e!=`string`||!t?.term)return;let n=t.dataWs;t._dataWsRetryAttempt=0,EC(e,t,t.term,0),n?.close()}function NC(e,t){let n=e.dataWs;e.dataWs=null,ub.unregister(t),n&&n.readyState<=WebSocket.OPEN&&n.close()}function PC(e,t,n){if(!e||t==null||t===``)return!1;if(n?.fromSoftKeyboard||e._resetSoftKeyboardBuffer?.(),!OC&&!e._inputQueue?.length&&e.dataWs?.readyState===WebSocket.OPEN)return e.dataWs.send(JSON.stringify({type:`input`,data:t})),!0;if(!e._inputQueue)return!1;let r=e.dataWs?.readyState!==WebSocket.OPEN;return e._inputQueue.length>=IS?(iC(e,`keys`,`error`,tC),!1):(e._inputQueue.push(t),r&&iC(e,`keys`,`busy`,eC),!0)}function FC(e,t){let n=window.matchMedia?.(RS).matches?zS:BS,r=new v({cursorBlink:HS,fontSize:n,fontFamily:nb(),theme:Pb(),scrollback:VS,allowProposedApi:!0,linkHandler:vx()}),i=new y;r.loadAddon(i),yC(e),r.open(e),gC(e,t,r),bx(r),iS(r,t.abortController.signal),t.term=r,t.fitAddon=i,AS(t);let a=null,o=null,s=!1,c=null,l=null;function u(){o!==null&&(clearTimeout(o),o=null)}function d(){if(!s)return null;let e=t.fitAddon;if(!e)return null;let n=e.proposeDimensions();return n?{cols:n.cols,rows:n.rows}:null}function f(e){if(!s||!GS(t.card)||t.dataWs?.readyState!==WebSocket.OPEN)return!1;t.dataWs.send(JSON.stringify({type:`claim`,cols:e.cols,rows:e.rows})),c=e,l=null;let n=Gb({authoritative:t.ptySize??null,isActiveViewer:s,lastClaim:c});return t.card.dataset.grid=n?`following`:`exact`,!0}function p(e){u(),l=e,o=setTimeout(()=>{o=null,f(e)},LS)}function m(){l&&o===null&&f(l)}function h({isActivationEdge:e=!1}={}){let n=t.term;if(!n)return;let r=Qb({authoritative:t.ptySize??null,applied:{cols:n.cols,rows:n.rows},proposal:d(),isActiveViewer:s,isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:c});r.resizeTo&&n.resize(r.resizeTo.cols,r.resizeTo.rows),t.card.dataset.grid=r.isFollowing?`following`:`exact`,r.keepsPendingSettle||(u(),l=null),r.sendUnview?(c=null,t.dataWs?.send(JSON.stringify({type:`unview`}))):r.owedClaim&&(e&&f(r.owedClaim)||p(r.owedClaim))}function g(){let e=Xb({authoritative:t.ptySize??null,isActiveViewer:s,isDocumentEngaged:GS(t.card),isDataWsOpen:t.dataWs?.readyState===WebSocket.OPEN,lastClaim:c});e!==`none`&&(u(),e===`rebid`&&(c=null),h({isActivationEdge:!0}))}let _=new ResizeObserver(()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,h()}))});_.observe(e),t.resizeObserver=_,t._syncGrid=h,t._resetGridClaim=()=>{u(),l=Zb({isActiveViewer:s,lastClaim:c,owedClaim:l}),c=null},t._retryOwedGridClaim=m,t._syncGridOnEngagementEdge=g,t._isActiveViewer=()=>s,t._setActiveViewer=e=>{s!==e&&(s=e,u(),l=null,e&&MS(t),h({isActivationEdge:!0}))},t.card.addEventListener(`focusin`,()=>{WS=!1,g()},{signal:t.abortController.signal}),PS(t);let b=null;r.onScroll(()=>{b===null&&(b=requestAnimationFrame(()=>{b=null,t.term&&(t.term.refresh(0,t.term.rows-1),sC(t,t.term))}))}),r.onWriteParsed(()=>sC(t,r,{hasNewOutput:!0})),r.parser.registerOscHandler(52,e=>{let n=e.indexOf(`;`);if(n<0)return!0;let r=e.slice(n+1);if(r===``||r===`?`)return!0;let i;try{i=dC(r)}catch(e){return fC(t,`osc52 decode`,e),!0}return document.hasFocus()&&navigator.userActivation?.isActive!==!1?(pC(t,i,`osc52 write`),!0):(mC(t,i),!0)}),r.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;if(FS(e))return!1;let n=e.ctrlKey||e.metaKey;if(n&&e.key===`c`&&r.hasSelection()){let e=r.getSelection();return r.clearSelection(),pC(t,e,`copy`),!1}return n&&e.key===`v`?!1:n&&e.key===`Backspace`?(PC(t,`\x1B`),!1):!0}),IC(e,r,t),CS(e,r)}function IC(e,t,n){let r=t.textarea;if(!r)return;let i=``,a=()=>{i=r.value},o=()=>{i=``,Ky()&&r.value!==``&&(r.value=``)};n._resetSoftKeyboardBuffer=o;let s=()=>{let e=ux(i,r.value);return i=r.value,e!==``&&(PC(n,e,{fromSoftKeyboard:!0}),t.scrollToBottom(),!0)},c=(t,n)=>{e.addEventListener(t,e=>{Ky()?n(e):a()},!0)};c(`keydown`,e=>{lx(e)?e.stopPropagation():(s(),queueMicrotask(o))}),c(`compositionstart`,e=>{e.stopPropagation()}),c(`compositionupdate`,e=>{e.stopPropagation()}),c(`compositionend`,e=>{e.stopPropagation(),setTimeout(s,0)}),c(`input`,e=>{if(!cx(e.inputType)){queueMicrotask(o);return}if(e.stopPropagation(),s())return;let r=ox(e.inputType);r!==``&&(PC(n,r,{fromSoftKeyboard:!0}),t.scrollToBottom())})}function LC(e,t){e._inputQueue=[];let n=e.term;n&&(n.onData(t=>{PC(e,t)}),n.onScroll(n=>{lC(e,t,n)}),zC(e.termWrap,t,e.abortController.signal),DC(t,e,n))}function RC(e){return!!e&&Array.from(e.types).includes(`Files`)}function zC(e,t,n){e.addEventListener(`paste`,e=>{let n=e.clipboardData;n&&n.files.length!==0&&n.getData(`text/plain`)===``&&(e.preventDefault(),e.stopPropagation(),cS(t,Array.from(n.files)))},{capture:!0,signal:n}),e.addEventListener(`dragover`,t=>{RC(t.dataTransfer)&&(t.preventDefault(),t.dataTransfer.dropEffect=`copy`,e.dataset.dropTarget=`true`)},{signal:n}),e.addEventListener(`dragleave`,t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||delete e.dataset.dropTarget},{signal:n}),e.addEventListener(`drop`,n=>{delete e.dataset.dropTarget,RC(n.dataTransfer)&&(n.preventDefault(),n.stopPropagation(),cS(t,Array.from(n.dataTransfer.files)))},{capture:!0,signal:n})}function BC(e,t){e.term||(FC(e.termWrap,e),LC(e,t))}function VC(e){e?._syncGridOnEngagementEdge?.()}function HC(e,t){if(!e)return;BC(e,t),uC(e,t),MS(e);let n=e.term;n&&(n.refresh(0,n.rows-1),VC(e))}function UC(e,t,n){e&&(n&&BC(e,t),e._setActiveViewer?.(n))}var WC=`conversation:`,GC=1e4,KC=48,qC=`, `,JC=`+`,YC=`■`,XC=`↑`,ZC=1e3,QC={command:`Run command?`,fileChange:`Apply file changes?`,permissions:`Grant permissions?`},$C=1;function ew(e){e?.previewUrl&&URL.revokeObjectURL(e.previewUrl)}function tw(e,t,n){let r=M(`button`,`conversation-icon-button ${e}`,t);return r.type=`button`,r.title=n,r.setAttribute(`aria-label`,n),r}function nw(e){return e.conversationApproval!==null||vy(e.currentState,e.pendingPromptKind)}function rw(e,t,n,r,i=0){let a=n[i];a?setTimeout(()=>{I(e)===t?i>0&&nw(t)?r(`stopped-by-prompt`):PC(t,a.data)?rw(e,t,n,r,i+1):r(`unreachable`):r(`unreachable`)},a.delayBeforeMs):r(`sent`)}function iw({signal:e,sendControl:t,showTerminal:n}){let r=M(`div`,`conversation-face`);r.hidden=!0;let i=M(`div`,`conversation-log`);i.setAttribute(`role`,`log`),i.setAttribute(`aria-live`,`polite`);let a=M(`p`,`conversation-empty`,`No conversation yet. Messages appear here as the agent works.`),o=M(`div`,`conversation-approval`);o.hidden=!0;let s=M(`p`,`conversation-bridge-note`,`Restart this Codex session to connect it to the conversation view. Until then, use the terminal.`);s.hidden=!0;let c=M(`p`,`conversation-bridge-note`,`The session trace is unavailable, so there is nothing to show here. Use the terminal.`);c.hidden=!0;let l=M(`details`,`conversation-working`),u=M(`summary`,`conversation-working-summary`);u.setAttribute(`role`,`status`);let d=M(`ul`,`conversation-agent-list`);l.append(u,d),l.hidden=!0;let f=M(`form`,`conversation-composer`),p=M(`p`,`conversation-status`);p.setAttribute(`role`,`status`);let m=M(`div`,`conversation-attachment`);m.hidden=!0;let h=M(`div`,`conversation-composer-row`),g=tw(`conversation-attach`,JC,`Attach a photo or file`),_=M(`input`,`conversation-file-picker`);_.type=`file`,_.hidden=!0;let v=M(`textarea`,`conversation-input`);v.dataset.dashboardShortcuts=`allowed`,v.rows=1,v.placeholder=`Message the agent`,v.setAttribute(`aria-label`,`Message the agent`);let y=tw(`conversation-stop`,YC,`Stop the current turn (Esc)`),b=tw(`conversation-send`,XC,`Send`);b.type=`submit`,h.append(g,v,y,b),f.append(p,m,h,_),r.append(i,l,c,s,o,f);let x=null,S=[],ee=0,te=!1,C=null,ne=!1,w=null,re=!1,ie=[],ae=[],oe=null,T=!1,E=new Set;function se(){return x?I(x)??null:null}function D(e){p.textContent=e}function ce(){v.style.height=`auto`,v.style.height=`${v.scrollHeight+v.offsetHeight-v.clientHeight}px`}function O(){C&&clearTimeout(C.timeoutHandle),C=null}function le(){if(!x||r.hidden||!c.hidden)return;if(C){ne=!0;return}let e=`${WC}${$C++}`,n=te?ee:null;t(n===null?{type:`session-trace`,id:x,requestId:e,endingAt:`tail`}:{type:`session-trace`,id:x,requestId:e,after:n})?(ne=!1,C={requestId:e,after:n,timeoutHandle:setTimeout(()=>{C=null,le()},GC)}):D(`Conversation unavailable while disconnected.`)}function ue(){return i.scrollHeight-i.scrollTop-i.clientHeight<=KC}function de(e){let t=M(`a`,`conversation-image-link`);t.href=e,t.target=`_blank`,t.rel=`noopener`;let n=M(`img`,`conversation-image`);return n.src=e,n.alt=`Attached image`,n.loading=`lazy`,n.addEventListener(`error`,()=>t.remove(),{once:!0}),t.append(n),t}function fe(e){let t=M(`article`,`conversation-message conversation-user is-pending`);return e.text&&t.append(M(`p`,`conversation-text`,e.text)),e.attachment?.previewUrl&&t.append(de(e.attachment.previewUrl)),e.attachment&&!e.attachment.previewUrl&&t.append(M(`p`,`conversation-attachment-name`,e.attachment.name)),t}function pe(e){let t=M(`article`,`conversation-message conversation-${e.kind}`);return e.kind===`assistant`?(t.append(Zm(Km(e.text))),t):(t.append(M(`p`,`conversation-text`,e.text)),e.kind===`user`&&t.append(...e.imageUrls.map(de)),t)}function me(e,t){e.replaceChildren(...t.map(e=>{let t=M(`li`,`conversation-agent is-${e.state}`);return t.append(M(`span`,`conversation-agent-name`,e.description),M(`span`,`conversation-agent-state`,e.state)),t}))}function he(e){if(e.agentRuns.length===0)return M(`p`,`conversation-work`,Fy(e));let t=M(`details`,`conversation-work`);t.open=E.has(e.key),t.addEventListener(`toggle`,()=>{t.open?E.add(e.key):E.delete(e.key)});let n=M(`ul`,`conversation-agent-list`);return me(n,e.agentRuns),t.append(M(`summary`,``,Fy(e)),n),t}function ge(){return se()?.currentState===j.RUNNING}function _e(){let e=se(),t=ky(ae),n=ge()?Ay(ae)?.agentRuns??[]:[],r=[...new Set([...n,...t])];if(l.hidden=!e||!ge()&&t.length===0,l.hidden||!e)return;let i=ge()?Math.max(0,Date.now()-e.stateSince):null;u.textContent=Iy(i,t.length),l.classList.toggle(`has-agents`,r.length>0),me(d,r)}function ve(){let e=!r.hidden&&ge();e&&!oe&&(oe=setInterval(_e,ZC)),!e&&oe&&(clearInterval(oe),oe=null),_e()}function ye(){i.scrollTop=i.scrollHeight}function be(){let e=T||ue();ae=Oy(S);let t=Date.now(),n=ie.filter(e=>My(e,ae,t));for(let e of n)ew(e.attachment);ie=ie.filter(e=>!n.includes(e));let r=[...(ge()&&Ay(ae)?ae.slice(0,-1):ae).map(e=>e.kind===`work`?he(e):pe(e)),...ie.map(fe)];i.replaceChildren(...r.length>0?r:[a]),_e(),e&&(ye(),requestAnimationFrame(ye),te&&(T=!1))}function xe(){if(m.replaceChildren(),m.hidden=!w,w){if(w.previewUrl){let e=M(`img`,`conversation-attachment-thumbnail`);e.src=w.previewUrl,e.alt=``,m.append(e)}m.append(M(`span`,`conversation-attachment-name`,w.name))}}function Se(e){w!==e&&ew(w),w=e,xe()}function Ce(e,t=()=>{}){let n=se();if(!n||!x||!e){D(`Unable to reach this session.`);return}D(``);let r={sent:``,unreachable:`Unable to reach this session.`,"stopped-by-prompt":`Not sent: a prompt appeared, so the message was typed but not submitted. Check the terminal.`};rw(x,n,e,e=>{D(r[e]),t(e)})}function we(e,n,r){x&&D(t({type:`conversation-approval`,id:x,requestId:e.requestId,decision:n,...r?{answers:r}:{}})?``:`Unable to send the answer while disconnected.`)}function Te(e,t){let n=M(`button`,`conversation-approval-action`,e);return n.type=`button`,n.addEventListener(`click`,t),n}function Ee(e){return e.kind===`tool`?`Allow ${e.toolName??`this tool`}?`:QC[e.kind]??`Approve this request?`}function De(e){o.append(M(`p`,`conversation-approval-note`,`This request cannot be shown in full here. Read and answer it in the terminal.`));let t=M(`div`,`conversation-approval-actions`);t.append(Te(`Open terminal`,()=>n()),Te(`Decline`,()=>we(e,`decline`))),o.append(t)}function Oe(e){if(o.append(M(`p`,`conversation-approval-title`,Ee(e)),M(`pre`,`conversation-approval-summary`,e.summary)),e.isSummaryTruncated){De(e);return}let t=M(`div`,`conversation-approval-actions`);t.append(Te(`Approve`,()=>we(e,`accept`))),e.kind!==`tool`&&t.append(Te(`Approve for session`,()=>we(e,`acceptForSession`))),e.alwaysAllowSummary&&(o.append(M(`p`,`conversation-approval-note`,`Always allow adds, for this session only: ${e.alwaysAllowSummary}`)),t.append(Te(`Always allow`,()=>we(e,`acceptForSession`)))),t.append(Te(`Decline`,()=>we(e,`decline`))),o.append(t)}function ke(e){let t=M(`p`,`conversation-approval-title`,e.question);return e.header&&t.prepend(M(`span`,`conversation-question-header`,e.header)),t}function Ae(e,t){o.append(ke(t));let n=M(`div`,`conversation-question-options`);for(let r of t.options){let i=Te(r.label,()=>we(e,`accept`,{[t.question]:r.label}));r.description&&(i.title=r.description),n.append(i)}let r=M(`div`,`conversation-approval-actions`);r.append(Te(`Decline`,()=>we(e,`decline`))),o.append(n,r)}function je(e,t){let n=M(`form`,`conversation-question-form`);t.forEach((e,t)=>{let r=M(`fieldset`,`conversation-question`),i=M(`legend`,`conversation-question-text`,e.question);e.header&&i.prepend(M(`span`,`conversation-question-header`,e.header)),r.append(i);for(let n of e.options){let i=M(`label`,`conversation-question-option`),a=M(`input`);a.type=e.multiSelect?`checkbox`:`radio`,a.name=`question-${t}`,a.value=n.label,i.append(a,M(`span`,``,n.label)),n.description&&(i.title=n.description),r.append(i)}n.append(r)});let r=M(`div`,`conversation-approval-actions`),i=M(`button`,`conversation-approval-action`,`Send answers`);i.type=`submit`,r.append(i,Te(`Decline`,()=>we(e,`decline`))),n.append(r),n.addEventListener(`submit`,r=>{r.preventDefault();let i={};t.forEach((e,t)=>{let r=[...n.querySelectorAll(`input[name="question-${t}"]:checked`)].map(e=>e.value);r.length>0&&(i[e.question]=r.join(qC))}),Object.keys(i).length===t.length?we(e,`accept`,i):D(`Answer every question first.`)}),o.append(n)}function Me(e){let t=e.questions??[];if(e.isSummaryTruncated||t.length===0){o.append(M(`p`,`conversation-approval-title`,`Claude Code has a question`),M(`pre`,`conversation-approval-summary`,e.summary)),De(e);return}let[n]=t;t.length===1&&!n.multiSelect?Ae(e,n):je(e,t)}function Ne(e){e.kind===`question`?Me(e):Oe(e)}function Pe(){o.append(M(`p`,`conversation-approval-title`,`The agent is waiting on a prompt`)),o.append(M(`p`,`conversation-approval-note`,`Read and answer it in the terminal.`));let e=M(`div`,`conversation-approval-actions`);e.append(Te(`Open terminal`,()=>n())),o.append(e)}function Fe(){let e=se();o.replaceChildren();let t=e?.conversationApproval??null,n=e?vy(e.currentState,e.pendingPromptKind):!1,r=e?.agent===`codex`&&!e.hasConversationBridge;s.hidden=!r,o.hidden=!t&&!n,b.disabled=!o.hidden||r,Ie(),e&&(t?Ne(t):n&&Pe())}function Ie(){g.disabled=b.disabled||re}function Le(e){let t=hy(e,v.value);return t||!w?t:gy(e)}function Re(){let e=se();y.disabled=e?.currentState!==j.RUNNING,ve()}f.addEventListener(`submit`,e=>{if(e.preventDefault(),b.disabled)return;let t=Le(se()?.agent);if(!t)return;let n={text:v.value.trim(),attachment:w,sentAt:Date.now(),userKeysAtSend:jy(ae)};v.value=``,ce(),w=null,xe(),ie.push(n),T=!0,be(),Ce(t,e=>{e!==`sent`&&(ew(n.attachment),ie=ie.filter(e=>e!==n),be())})},{signal:e}),v.addEventListener(`input`,ce,{signal:e});let ze=0,Be=new ResizeObserver(()=>{let e=i.clientHeight,t=ze===0;ze=e,t&&e!==0&&(T=!0,ye(),te&&(T=!1))});Be.observe(i),e?.addEventListener(`abort`,()=>{oe&&clearInterval(oe),Be.disconnect()},{once:!0}),v.addEventListener(`keydown`,e=>{e.key!==`Enter`||e.shiftKey||e.isComposing||Ky()||(e.preventDefault(),f.requestSubmit())},{signal:e}),y.addEventListener(`click`,()=>Ce(_y(se()?.agent)),{signal:e}),g.addEventListener(`click`,()=>_.click(),{signal:e}),_.addEventListener(`change`,()=>{let e=_.files?.[0];if(_.value=``,!e||!x)return;if(b.disabled){D(`Not attached: the agent is not ready for a message. Check the terminal.`);return}let t=x;re=!0,Ie(),sS(t,e).then(n=>{if(re=!1,Ie(),!n||x!==t)return;let r=e.type.startsWith(`image/`)?URL.createObjectURL(e):null;Se({name:e.name,previewUrl:r})})},{signal:e});function Ve(e){if(x!==e){x=e,S=[],ee=0,te=!1,O(),Se(null),E.clear();for(let e of ie)ew(e.attachment);ie=[],D(``)}r.hidden=!1,c.hidden=!0,T=!0,be(),Ue(),le()}function He(){r.hidden=!0,O(),ve()}function Ue(){r.hidden||(Fe(),Re(),be())}function We(e){if(!C||e.requestId!==C.requestId)return!1;let t=C;if(O(),e.id!==x)return!0;let n=t.after!==null&&e.start===t.after&&!e.reset;return t.after!==null&&!n?(te=!1,S=[],le(),!0):(S=Ly(t.after===null?[...e.records]:[...S,...e.records]),ee=e.next,te=!0,be(),ne&&le(),!0)}function Ge(e){return!C||e.requestId!==C.requestId?!1:(O(),ne=!1,c.hidden=!1,!0)}function Ke(e){e!==x||r.hidden||(c.hidden=!0,le())}return{el:r,show:Ve,hide:He,refresh:Ue,applyTraceResponse:We,applyTraceError:Ge,applyTraceChanged:Ke}}function aw(e){if(!e)return 0;let t=0;return e.listenerMismatch&&t++,e.orphanPty&&t++,e.destroyedReachable&&t++,t}function ow(e,t){return e||aw(t)>0}var sw={DORMANT:`DOR`,INITIALIZING:`INI`,STARTING:`STA`,RUNNING:`RUN`,WAITING:`WAI`,IDLE:`IDL`,COMPLETE:`CMP`,DONE:`DON`,FAILED:`FAI`},cw=null,lw=!1,uw=!1,dw=null,fw=null,pw=null,mw=`—`;function hw(e){return e==null?mw:wl(e,`GB`)}function gw(e){return e==null?mw:Sl(e,{smallestUnit:`s`,dropsZeroRemainder:!1})}function _w(e){return e==null?mw:`${gw(Math.max(0,Math.round((Date.now()-e)/1e3)))} ago`}function vw(){let e=M(`div`,`health-footer`);e.dataset.expanded=`false`,e.hidden=!0;let t=M(`div`,`health-summary`),n=M(`button`,`health-toggle`);n.type=`button`,n.setAttribute(`aria-expanded`,`false`),n.setAttribute(`aria-controls`,`health-detail`);let r=M(`span`,`health-chev`,`▲`);r.setAttribute(`aria-hidden`,`true`),n.append(r,M(`span`,`health-toggle-label`,`Health`));let i=M(`div`,`health-stats`);t.append(n,i);let a=M(`div`,`health-detail`);return a.id=`health-detail`,a.hidden=!0,n.addEventListener(`click`,()=>{uw=!uw,e.dataset.expanded=String(uw),n.setAttribute(`aria-expanded`,String(uw)),a.hidden=!uw,uw&&(K({type:`request-health-snapshot`}),bw())}),e.append(t,a),dw=e,fw=i,pw=a,e}function yw(){if(!fw||!cw)return;let e=cw,t=aw(e.anomalies);fw.innerHTML=`
90
- <span class="health-stat" title="V8 heap used"><span class="health-stat-label">Heap</span> ${hw(e.process.heapUsed)}</span>
91
- <span class="health-stat" title="Resident set size (process memory)"><span class="health-stat-label">RSS</span> ${hw(e.process.rss)}</span>
92
- <span class="health-stat" title="External buffers (PTY data lives here)"><span class="health-stat-label">Ext</span> ${hw(e.process.external)}</span>
93
- <span class="health-stat" title="Active resources (handles + requests)"><span class="health-stat-label">Hdl</span> ${e.process.activeResources}</span>
94
- <span class="health-stat" title="Memory headroom at the last start check, and starts held for memory"><span class="health-stat-label">Mem</span> ${hw(e.memoryGate?.headroomBytes)} / ${e.memoryGate?.heldStartCount??0} held</span>
95
- <span class="health-stat" title="Sessions: alivePty / total"><span class="health-stat-label">Sess</span> ${e.sessions.alivePty}/${e.sessions.total}</span>
96
- <span class="health-stat" title="WebSockets: control + data"><span class="health-stat-label">WS</span> ${e.websockets.control}+${e.websockets.data}</span>
97
- <span class="health-stat" title="Server uptime"><span class="health-stat-label">Up</span> ${gw(e.uptimeSeconds)}</span>
98
- ${t>0?`<span class="health-anomaly" title="${t} anomaly type(s), expand for details">⚠ ${t}</span>`:``}
99
- `}function bw(){if(!pw||!cw)return;let e=cw,t=e.process,n=e.websockets,r=e.sessions,i=e.anomalies,a=``;if(aw(i)>0){let e=[];i.listenerMismatch&&e.push(`Listener count mismatch: data WS listener leaked or missing`),i.orphanPty&&e.push(`Orphan PTY: session has live PTY but state is DONE/FAILED/DORMANT`),i.destroyedReachable&&e.push(`Destroyed session still reachable in sessions map`),a=`
100
- <div class="health-section health-section-warn">
101
- <div class="health-section-title">⚠ Anomalies</div>
102
- ${e.map(e=>`<div class="health-row">${e}</div>`).join(``)}
103
- </div>
104
- `}let o=r.list.map(e=>{let t=[];e.destroyed&&t.push(`destroyed`),e.pendingRestart&&t.push(`pendingRestart`);let n=Object.entries(e.timers).filter(([,e])=>e).map(([e])=>e).join(`,`)||`none`;return`
105
- <tr>
106
- <td>${r_(e.name)}</td>
107
- <td class="health-mono">${sw[e.state]||e.state}</td>
108
- <td class="health-mono">${e.hasPty?e.ptyPid:mw}</td>
109
- <td class="health-mono">${hw(e.outputBufferBytes)}</td>
110
- <td class="health-mono">${e.outputBufferEntries}</td>
111
- <td class="health-mono">${e.dataListenerCount}</td>
112
- <td class="health-mono health-dim">${n}</td>
113
- <td class="health-mono health-dim">${t.join(` `)||``}</td>
114
- </tr>
115
- `}).join(``);pw.innerHTML=`
116
- ${a}
117
- <div class="health-section">
118
- <div class="health-section-title">Process</div>
119
- <div class="health-grid">
120
- <div class="health-row"><span class="health-label">Heap used</span><span class="health-mono">${hw(t.heapUsed)}</span></div>
121
- <div class="health-row"><span class="health-label">Heap total</span><span class="health-mono">${hw(t.heapTotal)}</span></div>
122
- <div class="health-row"><span class="health-label">RSS</span><span class="health-mono">${hw(t.rss)}</span></div>
123
- <div class="health-row"><span class="health-label">External</span><span class="health-mono">${hw(t.external)}</span></div>
124
- <div class="health-row"><span class="health-label">Array buffers</span><span class="health-mono">${hw(t.arrayBuffers)}</span></div>
125
- <div class="health-row"><span class="health-label">Active resources</span><span class="health-mono">${t.activeResources}</span></div>
126
- <div class="health-row"><span class="health-label">Uptime</span><span class="health-mono">${gw(e.uptimeSeconds)}</span></div>
127
- </div>
128
- </div>
129
-
130
- <div class="health-section">
131
- <div class="health-section-title">Memory gate</div>
132
- <div class="health-grid">
133
- <div class="health-row"><span class="health-label">Headroom</span><span class="health-mono">${hw(e.memoryGate?.headroomBytes)}</span></div>
134
- <div class="health-row"><span class="health-label">Read</span><span class="health-mono">${_w(e.memoryGate?.headroomReadAtMs)}</span></div>
135
- <div class="health-row"><span class="health-label">Starts held</span><span class="health-mono">${e.memoryGate?.heldStartCount??0}</span></div>
136
- </div>
137
- </div>
138
-
139
- <div class="health-section">
140
- <div class="health-section-title">WebSockets</div>
141
- <div class="health-grid">
142
- <div class="health-row"><span class="health-label">Control clients</span><span class="health-mono">${n.control}</span></div>
143
- <div class="health-row"><span class="health-label">Data clients</span><span class="health-mono">${n.data}</span></div>
144
- <div class="health-row"><span class="health-label">Tracked per session</span><span class="health-mono">${n.dataPerSessionTotal}</span></div>
145
- </div>
146
- </div>
147
-
148
- <div class="health-section">
149
- <div class="health-section-title">Sessions (${r.total} total · ${r.alivePty} alive PTY)</div>
150
- <div class="health-row health-dim">Listeners ${r.totalDataListeners} · Output buffer ${hw(r.totalOutputBufferBytes)}</div>
151
- <table class="health-table">
152
- <thead>
153
- <tr>
154
- <th>Name</th><th>State</th><th>PID</th><th>Buffer</th><th>Entries</th><th>Listeners</th><th>Timers</th><th>Flags</th>
155
- </tr>
156
- </thead>
157
- <tbody>${o||`<tr><td colspan="8" class="health-dim">No sessions</td></tr>`}</tbody>
158
- </table>
159
- </div>
160
- `}function xw(){if(!dw)return;let e=ow(lw,cw?.anomalies),t=dw.hidden;dw.hidden=!e,e&&t&&cw&&(yw(),uw&&bw())}function Sw(e){lw=e,xw()}function Cw(e){if(dw)return dw;let t=vw();return e.appendChild(t),xw(),t}function ww(e){cw=e,xw(),dw&&!dw.hidden&&(yw(),uw&&bw())}function Tw(e){return e.replace(/\r\n?/g,`
161
- `).split(`
162
- `)}function Ew(e){return{kind:`unchanged`,text:e}}function Dw(e){return{kind:`skipped`,text:`${e} unchanged lines`}}function Ow(e,t){return e.length<=7?e.map(t):[...e.slice(0,3).map(t),Dw(e.length-6),...e.slice(e.length-3).map(t)]}function kw(e){return e}function Aw(e){let t=[],n=0;for(;n<e.length;){if(e[n].kind!==`unchanged`){t.push(e[n]),n++;continue}let r=n;for(;r<e.length&&e[r].kind===`unchanged`;)r++;t.push(...Ow(e.slice(n,r),kw)),n=r}return t}function jw(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return r}function Mw(e,t,n){let r=Math.min(e.length,t.length)-n,i=0;for(;i<r&&e[e.length-1-i]===t[t.length-1-i];)i++;return i}function Nw(e,t){let n=e.length,r=t.length;if(n===0)return t.map(e=>({kind:`added`,text:e}));if(r===0)return e.map(e=>({kind:`removed`,text:e}));let i=r+1,a=new Int32Array((n+1)*i);for(let o=n-1;o>=0;o--)for(let n=r-1;n>=0;n--){let r=o*i+n;a[r]=e[o]===t[n]?a[r+i+1]+1:Math.max(a[r+i],a[r+1])}let o=[],s=0,c=0;for(;s<n&&c<r;)e[s]===t[c]?(o.push(Ew(e[s])),s++,c++):a[(s+1)*i+c]>=a[s*i+c+1]?(o.push({kind:`removed`,text:e[s]}),s++):(o.push({kind:`added`,text:t[c]}),c++);for(;s<n;)o.push({kind:`removed`,text:e[s]}),s++;for(;c<r;)o.push({kind:`added`,text:t[c]}),c++;return o}function Pw(e,t){let n=Tw(e),r=Tw(t),i=jw(n,r),a=Mw(n,r,i),o=n.slice(i,n.length-a),s=r.slice(i,r.length-a);return o.length+s.length>2e3?{lines:[],isTooLarge:!0}:{lines:Aw([...Ow(n.slice(0,i),Ew),...Nw(o,s),...Ow(n.slice(n.length-a),Ew)]),isTooLarge:!1}}var Fw=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function Iw(e){return e===`approve`||e===`approve-accept-edits`}function Lw(e){return(e.state===`decided`||e.state===`closed`)&&Iw(e.lastDecision)}function Rw(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&Lw(n)}function zw(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function Bw(e){let t=zw(e.state,e.selectedAgentId);return t?e.selectedRevision&&t.revisions.some(t=>t.revision===e.selectedRevision)?e.selectedRevision:t.revisions.at(-1)?.revision??null:null}function Vw(e,t){return zw(e,t)?.openRevision?.revision??null}function Hw(e,t,n){if(n===null)return null;let r=zw(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function Uw(e,t){let n=t-e;return Number.isFinite(n)?xl(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function Ww(e,t,n){return t!==null&&t.state===`open`&&t.openRevision!==null&&t.openRevision.revision===n&&e.body!==null&&e.isConnected&&e.isDraft!==!0&&!e.isDecisionInFlight}function Gw(e,t,n){let r=Ww(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return Fw.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function Kw(e,t){return e.openRevision===null?t!==null&&e.approvedRevision===t?`Approved`:e.state===`released`?`Answer in the terminal`:e.state===`decided`?e.lastDecision===`revise`?`Feedback sent, waiting for the next revision`:`Approved`:`Closed`:e.openRevision.revision===t?``:`Rev ${e.openRevision.revision} is the one open`}function qw(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function Jw(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+Do}function Yw(e){let t=e.plan;if(t!==void 0&&t.length===0)return`the edited plan is empty, so nothing was sent`;if(t!==void 0&&new TextEncoder().encode(t).byteLength>524288)return`the edited plan is over the plan size cap, so nothing was sent`;let n=e.comments??[];return n.length>40?`more than 40 section comments are pending, so nothing was sent`:n.find(e=>e.comment.length>4e3||(e.heading?.length??0)>4e3)?`a section comment is over ${Kr} characters, so nothing was sent`:qw(e)>1e4?`the feedback composes more than the ${Jr} characters the hook reply carries, so nothing was sent`:Jw(e)>Oo?`the decision is larger than one control frame carries, so nothing was sent`:null}function Xw(e){return e?`, ${e}`:``}function Zw(e,t,n){if(!e.isConnected)return`Disconnected`;if(!t||n===null)return`No plan revision selected`;if(e.isDecisionInFlight)return`Sending your decision`;if(e.body===null)return`Loading`;if(e.isDraft===!0)return`Draft`;let r=Kw(t,n);if(r)return r;if(e.hasUnsavedComment===!0)return`Save or cancel the open comment first.`;let i=e.pendingCommentCount??0;return i<=0?``:i===1?`1 comment to send. Remove it to approve.`:`${i} comments to send. Remove them to approve.`}function Qw(e,t,n){let r=Zw(e,t,n);return r?`${r}${Xw(e.problem)}`:e.problem??``}function $w(e){let t=zw(e.state,e.selectedAgentId),n=Bw(e);return{tabs:e.state.reviews.map(e=>({agentId:e.agentId,label:e.agentId===null?`Main`:e.agentType||`Agent`,selected:e===t})),revisions:(t?.revisions??[]).map(e=>({revision:e.revision,label:`Rev ${e.revision}`,isOpen:e.revision===t?.openRevision?.revision,receivedAt:e.receivedAt,selected:e.revision===n})),selectedAgentId:t?.agentId??null,selectedRevision:n,previousRevision:Hw(e.state,t?.agentId??null,n),status:Qw(e,t,n),actions:Gw(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:Hw(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:Ww(e,t,n)}]}}function eT(e,t){let n=e.reviews.findIndex(e=>e.agentId===t.agentId),r=[...(n===-1?null:e.reviews[n])?.revisions??[]],i=r.findIndex(e=>e.revision===t.revision),a={revision:t.revision,receivedAt:t.receivedAt,chars:t.chars,title:t.title};r[i===-1?r.length:i]=a,r.sort((e,t)=>e.revision-t.revision);let o={agentId:t.agentId,agentType:t.agentType,revisions:r,state:t.state,openRevision:t.state===`open`?{revision:t.revision,since:t.receivedAt}:null,approvedRevision:t.approvedRevision,lastDecision:t.lastDecision},s=[...e.reviews];return s[n===-1?s.length:n]=o,{reviews:s}}function tT({headingOffsets:e,scrollTop:t,isScrolledToEnd:n,readingLineOffset:r}){if(e.length===0)return null;if(n)return e.length-1;let i=t+r,a=0;for(let t=0;t<e.length&&!(e[t]>i);t++)a=t;return a}var nT=12,rT=8,iT=``,aT=48,oT=new Map;function sT(e,t){return JSON.stringify([e,t])}function cT(e){return e.id??iT}function lT(e,t){let n=oT.get(e);n||(n=new Map,oT.set(e,n));let r=sT(t.agentId,t.revision);for(n.delete(r),n.set(r,t.plan);n.size>nT;){let e=n.keys().next().value;if(typeof e!=`string`)break;n.delete(e)}}function uT(e){oT.delete(e)}function dT(e,t,n){return!e||n===null?null:oT.get(e)?.get(sT(t,n))??null}function fT(e){let t=M(`section`,`plan-face`);t.hidden=!0;let n=M(`header`,`plan-head`),r=M(`select`,`plan-heading-picker`);r.setAttribute(`aria-label`,`Plan section`);let i=M(`div`,`plan-view-panel`),a=M(`div`,`plan-sheet-head`),o=M(`button`,`plan-control plan-sheet-close`,`×`);o.type=`button`,o.setAttribute(`aria-label`,`Close`),a.append(M(`span`,null,`View`),o);let s=M(`div`,`plan-view-group plan-author-group`),c=M(`div`,`plan-tabs`);c.setAttribute(`role`,`tablist`),c.setAttribute(`aria-label`,`Plan author`),s.append(M(`span`,`plan-sheet-label`,`Author`),c);let l=M(`div`,`plan-view-group plan-revision-group`),u=M(`div`,`plan-revision-stepper`),d=M(`button`,`plan-control plan-revision-previous`,`‹`);d.type=`button`,d.setAttribute(`aria-label`,`Previous revision`);let f=M(`button`,`plan-control plan-revision-next`,`›`);f.type=`button`,f.setAttribute(`aria-label`,`Next revision`);let p=M(`span`,`plan-revision-label`),m=M(`span`,`plan-revision-age`);u.append(d,p,f,m);let h=M(`div`,`plan-revision-list`);h.setAttribute(`role`,`radiogroup`),h.setAttribute(`aria-label`,`Revision`),l.append(M(`span`,`plan-sheet-label`,`Revision`),u,h);let g=M(`div`,`plan-view-group plan-mode-group`),_=M(`div`,`plan-modes`);_.setAttribute(`role`,`radiogroup`),_.setAttribute(`aria-label`,`Show`),g.append(M(`span`,`plan-sheet-label`,`Show`),_);let v=M(`div`,`plan-head-spacer`),y=M(`div`,`plan-draft-notice`),b=M(`span`,`plan-draft-dot`);b.setAttribute(`aria-hidden`,`true`);let x=M(`button`,`plan-control plan-draft-chip`,`Peek draft`);x.type=`button`,y.append(b,x),i.append(a,s,l,g,v,y);let S=M(`button`,`plan-control plan-view-button`,`View`);S.type=`button`,S.setAttribute(`aria-haspopup`,`dialog`),S.setAttribute(`aria-expanded`,`false`);let ee=M(`button`,`plan-control plan-minimize-button`,`Minimize`);ee.type=`button`,ee.addEventListener(`click`,e.showTerminal),n.append(r,i,S,ee);let te=M(`div`,`plan-sheet-backdrop`),C=M(`div`,`plan-body-layout`),ne=M(`nav`,`plan-heading-rail`);ne.setAttribute(`aria-label`,`Plan sections`);let w=M(`article`,`plan-reading-column`);C.append(ne,w);let re=M(`textarea`,`plan-editor`);re.setAttribute(`aria-label`,`Plan markdown`),re.spellcheck=!1;let ie=M(`footer`,`plan-action-bar`),ae=M(`span`,`plan-status`);ae.setAttribute(`role`,`status`);let oe=M(`div`,`plan-decision-slot`),T=M(`label`,`plan-accept-edits`),E=M(`input`,`plan-accept-edits-checkbox`);E.type=`checkbox`,T.append(E,M(`span`,null,`Accept edits`)),oe.append(T,ae),ie.append(oe);let se=new Map;for(let[e,t]of[[`terminal`,`Answer in terminal`],[`revise`,`Send feedback`],[`approve`,`Approve`]]){let n=M(`button`,`plan-action`,t);n.type=`button`,n.dataset.decision=e,n.addEventListener(`click`,()=>{n.disabled||nt(e)}),se.set(e,n),ie.append(n)}t.append(n,C,ie,te);let D=null,ce={reviews:[]},O=null,le=null,ue=!0,de=``,fe=``,pe=``,me=``,he=!1,ge=null,_e=!1,ve=null,ye=!1,be=!1,xe=null,Se=[],Ce=null,we=null,Te=new Map,Ee=new Map,De=new Map,Oe=[],ke=!1,Ae=null,je=!1;function Me(e,t=!0){je=e,i.replaceChildren(...e?[a,g,l,s,y,v]:[a,s,l,g,v,y]),c.setAttribute(`role`,e?`radiogroup`:`tablist`);for(let t of c.querySelectorAll(`button`)){let n=t.getAttribute(`aria-selected`)===`true`||t.getAttribute(`aria-checked`)===`true`;t.setAttribute(`role`,e?`radio`:`tab`),t.removeAttribute(e?`aria-selected`:`aria-checked`),t.setAttribute(e?`aria-checked`:`aria-selected`,String(n))}i.dataset.open=String(e),te.dataset.open=String(e),S.setAttribute(`aria-expanded`,String(e)),C.inert=e,ie.inert=e,r.inert=e,S.inert=e,ee.inert=e,e?(i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-label`,`Plan view`),i.setAttribute(`aria-modal`,`true`),o.focus()):(i.removeAttribute(`role`),i.removeAttribute(`aria-modal`),t&&S.focus())}function Ne(e){e.addEventListener(`keydown`,t=>{let n={ArrowLeft:-1,ArrowUp:-1,ArrowRight:1,ArrowDown:1}[t.key];if(n===void 0&&t.key!==`Home`&&t.key!==`End`)return;let r=[...e.querySelectorAll(`button:not(:disabled)`)];if(r.length===0)return;t.preventDefault();let i=(r.indexOf(document.activeElement)+(n??0)+r.length)%r.length;t.key===`Home`&&(i=0),t.key===`End`&&(i=r.length-1);let a=je;r[i].click(),!(a&&e!==_)&&(e===_||!je)&&e.querySelector(`[aria-checked="true"], [aria-selected="true"]`)?.focus()})}let Pe=kr.subscribe((e,t)=>{t.includes(`layout`)&&je&&Me(!1,!1)});e.signal?.addEventListener(`abort`,Pe,{once:!0}),Ne(_),Ne(c),Ne(h),S.addEventListener(`click`,()=>Me(!je)),o.addEventListener(`click`,()=>Me(!1)),te.addEventListener(`click`,()=>Me(!1)),i.addEventListener(`keydown`,e=>{if(!je)return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),Me(!1);return}if(e.key!==`Tab`)return;let t=[...i.querySelectorAll(`button:not(:disabled)`)].filter(e=>e.getClientRects().length>0&&e.tabIndex>=0),n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())});function Fe(e){w.querySelector(`#${CSS.escape(e)}`)?.scrollIntoView({behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`,block:`start`})}r.addEventListener(`change`,()=>Fe(r.value));function Ie(){ke=!1;let e=Oe.map(e=>w.querySelector(`#${CSS.escape(e.dataset.headingId??``)}`)).filter(e=>e!==null),t=w.getBoundingClientRect().top-w.scrollTop,n=tT({headingOffsets:e.map(e=>e.getBoundingClientRect().top-t),scrollTop:w.scrollTop,isScrolledToEnd:w.scrollTop>0&&w.scrollTop+w.clientHeight>=w.scrollHeight-2,readingLineOffset:aT}),i=n===null?null:e[n]?.id??null;for(let e of Oe)e.dataset.headingId===i?e.setAttribute(`aria-current`,`location`):e.removeAttribute(`aria-current`);i!==null&&(r.value=i)}function Le(){ke||t.hidden||Oe.length===0||(ke=!0,requestAnimationFrame(Ie))}w.addEventListener(`scroll`,Le,{passive:!0});function Re(){Ae=null,_e=!1,ye=!1,be=!1,xe=null}function ze(t){Ce=t,e.reportProblem(t),Tt()}function Be(e){le=e,Ce=null,Re(),Me(!1,je),Tt()}function Ve(e){let t=ce.reviews.find(e=>e.agentId===O)?.revisions??[],n=t[t.findIndex(e=>e.revision===le)+e];n&&Be(n.revision)}d.addEventListener(`click`,()=>Ve(-1)),f.addEventListener(`click`,()=>Ve(1));function He(e,t){return`${D??``}:${e??`main`}:${t??`latest`}`}function Ue(){return He(O,le)}function We(e,t,n){return`${e??``}:${sT(t,n??0)}`}function Ge(){return We(D,O,le)}function Ke(){return Ee.get(Ge())??null}function qe(){return Ke()?.size??0}function Je(){if(Ae===null)return!1;let e=Ee.get(Ae.target.bucketKey)?.get(Ae.target.sectionSlot)??``;return Ae.field.value.trim()!==e}function Ye(e){let t=Ee.get(e);if(!t)return[];let n=[];for(let e of Se){let r=t.get(cT(e));r&&n.push({heading:e.heading,comment:r})}return n}function Xe(e,t){let n=t.trim(),r=Ee.get(e.bucketKey)??new Map;Ee.set(e.bucketKey,r),n.length===0&&r.delete(e.sectionSlot),n.length>0&&r.set(e.sectionSlot,n),r.size===0&&Ee.delete(e.bucketKey),Tt()}function Ze(e){if(be||he)return;let t={bucketKey:Ge(),sectionSlot:cT(e)},n=M(`div`,`plan-comment-composer`),r=M(`label`,`plan-comment-label`,`Comment on ${e.heading??`Introduction`}`),i=M(`textarea`,`plan-comment-input`);i.maxLength=Kr,i.value=Ee.get(t.bucketKey)?.get(t.sectionSlot)??``,r.append(i);let a=M(`div`,`plan-comment-actions`),o=M(`button`,`plan-control plan-comment-cancel`,`Cancel`);o.type=`button`;let s=M(`button`,`plan-control plan-comment-save`,`Save comment`);s.type=`button`,a.append(o,s),n.append(r,a);let c={target:t,element:n,field:i};Ae=c,i.addEventListener(`input`,wt),o.addEventListener(`click`,()=>{Ae===c&&(Ae=null,Tt())}),s.addEventListener(`click`,()=>{Ae===c&&(Ae=null),Xe(t,i.value)}),Tt(),i.focus()}function Qe(e){let t={bucketKey:Ge(),sectionSlot:cT(e)};if(Ae?.target.bucketKey===t.bucketKey&&Ae.target.sectionSlot===t.sectionSlot)return Ae.element;let n=Ke()?.get(t.sectionSlot);if(!n)return null;let r=M(`div`,`plan-comment-card`),i=M(`div`,`plan-comment-head`),a=M(`button`,`plan-control plan-comment-edit`,`Edit`);a.type=`button`,a.addEventListener(`click`,()=>Ze(e));let o=M(`button`,`plan-control plan-comment-remove`,`Remove`);return o.type=`button`,o.disabled=he,a.disabled=he,o.addEventListener(`click`,()=>Xe(t,``)),i.append(M(`span`,`plan-comment-label`,`Your comment`),a,o),r.append(i,M(`p`,`plan-comment-text`,n)),r}function $e(t,n,r={}){if(!D||n.revision===null||he)return!1;let i=Yw(r);if(i!==null)return ze(i),!1;let a={agentId:n.agentId,revision:n.revision,decision:t,...r};return e.sendDecision(D,a)?(Ce=null,he=!0,ge=Iw(t)?n:null,Tt(),!0):(ze(G),!1)}function et(e){if(!_e)return{};let t=re.value;return t===dT(D,e.agentId,e.revision)?{}:{plan:t}}function tt(e){let t=We(D,e.agentId,e.revision),n=Ye(t);n.length!==0&&$e(`revise`,e,{comments:n})&&e.revision!==null&&(we={bucketKey:t,agentId:e.agentId,revision:e.revision},Tt())}function nt(e){let t={agentId:O,revision:le};e===`revise`?tt(t):$e(e===`approve`&&!T.hidden&&E.checked?`approve-accept-edits`:e,t,et(t))}function rt(e){Ae=null,_e=e===`edit`,ye=e===`changes`,_e&&ve!==Ge()&&(re.value=dT(D,O,le)??``,ve=Ge()),Ce=null,Tt()}function it(e){return`${e.kind}:${He(e.agentId,e.revision)}`}function at(e){for(De.set(it(e),e);De.size>rT;){let e=De.keys().next().value;if(typeof e!=`string`)break;De.delete(e)}}function ot(e,t){return e.agentId===t.agentId?e.kind===`draft`?t.revision===0:t.revision===0?!1:e.revision===null||e.revision===t.revision:!1}function st(e){for(let[t,n]of De)if(ot(n,e))return De.delete(t),n;return null}function ct(){for(let[e,t]of De)if(t.kind===`draft`)return De.delete(e),t;return null}function lt(){if(De.size!==1)return null;let e=De.entries().next().value;return e?(De.delete(e[0]),e[1]):null}function ut(){if(!D)return;let t=Ue();de!==t&&e.requestPlan(D,O,le??void 0)&&(de=t,at({kind:`selection`,agentId:O,revision:le}))}function k(){t.hidden||ut()}function dt(){return Hw(ce,O,le)}function ft(t){if(!D)return;let n=He(O,t);pe!==n&&e.requestPlan(D,O,t)&&(pe=n,at({kind:`diff-base`,agentId:O,revision:t}))}function pt(){if(!D)return;let t=`${D}:${O??`main`}`;me!==t&&e.requestDraft(D,O)&&(me=t,at({kind:`draft`,agentId:O,revision:null}))}function mt(e,t){return`${e??``}:${t??``}`}function ht(){return ce.reviews.find(e=>e.agentId===O)?.revisions.find(e=>e.revision===le)?.receivedAt??0}function gt(){let e=Te.get(mt(D,O));return e!==void 0&&e>ht()}function _t(){be?(Re(),Tt()):(Ae=null,_e=!1,ye=!1,pt(),Tt())}x.addEventListener(`click`,_t);function vt(e){ne.replaceChildren(),r.replaceChildren(),Oe=[];for(let t of e){let e=t.id??`plan-introduction`,n=t.heading??`Introduction`,i=M(`button`,`plan-heading-link`,n);i.type=`button`,i.dataset.level=String(t.level),i.dataset.headingId=e,i.title=n,i.dataset.commented=String(Ke()?.has(cT(t))===!0),Oe.push(i),i.addEventListener(`click`,()=>Fe(e)),ne.append(i);let a=M(`option`,null,n);a.value=e,r.append(a)}}function yt(e){let t=dt();if(t===null){w.append(M(`p`,`plan-loading`,`This is the first revision, so there is nothing to diff`));return}let n=dT(D,O,t);if(n===null){w.append(M(`p`,`plan-loading`,`Loading the previous revision`)),ft(t);return}let r=Pw(n,e);r.isTooLarge?(w.append(M(`p`,`plan-loading`,`This diff is too large to show, so the newer revision stands alone`)),w.append(Zm(Km(e)))):w.append(eh(r))}function bt(e){if(w.replaceChildren(),_e){vt(Se),w.append(re);return}if(e===null){if(Se=[],vt(Se),fe===Ue()){w.append(M(`p`,`plan-loading`,`This plan revision could not be loaded`));return}w.append(M(`p`,`plan-loading`,`Loading plan`)),ut();return}let t=Km(e);if(Se=qm(t),vt(Se),ye){yt(e);return}if(be){w.append(Zm(t));return}let n=Ke();w.append(Qm(Se,{hasComment:e=>n?.has(cT(e))===!0,isComposing:e=>Ae?.target.bucketKey===Ge()&&Ae.target.sectionSlot===cT(e),onComment:Ze,attachmentFor:Qe}))}function xt(e){s.hidden=e.tabs.length<2,c.replaceChildren();for(let t of e.tabs){let e=M(`button`,`plan-tab`,t.label);e.type=`button`,e.setAttribute(`role`,je?`radio`:`tab`),e.setAttribute(je?`aria-checked`:`aria-selected`,String(t.selected)),e.tabIndex=t.selected?0:-1,e.addEventListener(`click`,()=>{O=t.agentId,le=null,Ce=null,de=``,fe=``,pe=``,me=``,Re(),Me(!1,je),Tt()}),c.append(e)}}function A(){return be?xe:dT(D,O,le)}function St(e){return $w({state:ce,selectedAgentId:O,selectedRevision:le,body:e,isConnected:ue,isDecisionInFlight:he,isDraft:be,pendingCommentCount:qe(),hasUnsavedComment:Je(),problem:Ce})}function Ct(e){ae.textContent=e.status,ae.hidden=e.status.length===0;let t=e.actions.some(e=>e.kind===`approve`&&e.enabled);T.hidden=!t,E.disabled=!t;for(let t of e.actions){let e=se.get(t.kind);e&&(e.disabled=!t.enabled)}}function wt(){Ct(St(A()))}function Tt(){let e=je&&i.contains(document.activeElement),t=$w({state:ce,selectedAgentId:O,selectedRevision:le,body:null,isConnected:ue});(O!==t.selectedAgentId||le!==t.selectedRevision)&&Re(),O=t.selectedAgentId,le=t.selectedRevision,ve!==Ge()&&(ve=null);let n=A(),a=St(n);xt(a);let s=a.revisions.findIndex(e=>e.selected),c=a.revisions[s],l=Date.now();u.hidden=a.revisions.length<2,p.textContent=`Rev ${s+1} of ${a.revisions.length}`,m.textContent=c?Uw(c.receivedAt,l):``,d.disabled=s<=0,f.disabled=s<0||s>=a.revisions.length-1,h.replaceChildren();for(let e of[...a.revisions].reverse()){let t=M(`button`,`plan-revision-option`);t.type=`button`,t.dataset.revision=String(e.revision),t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.selected)),t.tabIndex=e.selected?0:-1,t.append(M(`span`,`plan-revision-name`,e.label),M(`span`,`plan-revision-age`,Uw(e.receivedAt,l))),e.isOpen&&t.append(M(`span`,`plan-revision-open`,`OPEN`)),t.addEventListener(`click`,()=>Be(e.revision)),h.append(t)}_.replaceChildren();let g=_e?`edit`:ye?`changes`:`read`,v=a.modes.find(e=>e.kind===g&&e.enabled)??a.modes[0];for(let e of a.modes){let t=M(`button`,`plan-control plan-mode`,e.label);t.type=`button`,t.dataset.mode=e.kind,t.disabled=!e.enabled,t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.kind===g)),t.tabIndex=e.kind===v.kind?0:-1,t.addEventListener(`click`,()=>{t.disabled||(rt(e.kind),_.querySelector(`[aria-checked="true"]`)?.focus())}),_.append(t)}y.hidden=!gt()&&!be,x.hidden=y.hidden,x.setAttribute(`aria-pressed`,String(be)),Ct(a),bt(n),r.disabled=Oe.length===0,Le(),e&&!i.contains(document.activeElement)&&o.focus()}function Et(t){ge!==null&&Rw(t,ge.agentId)&&(ge=null,ve=null,e.showTerminal())}function Dt(e){Ae=null,e!==D&&(ge=null,he=!1,Ce=null,De.clear()),Me(!1,!1),D=e,t.hidden=!1,de=``,fe=``,Tt(),k()}function Ot(){Ae=null,Me(!1,!1),t.hidden=!0}function kt(e,t){return t.kind!==`selection`||e.agentId!==O?!1:t.revision===null?le===null||le===e.revision:t.revision===le}function At(e){e.kind===`draft`?(me=``,ze(`the draft could not be read, so nothing was shown`)):e.kind===`diff-base`?pe=``:fe=He(e.agentId,e.revision)}function jt(e){we!==null&&Vw(e,we.agentId)!==we.revision&&(Ee.delete(we.bucketKey),we=null)}function Mt(e){he=!1,Nt({reviews:e.reviews});let t=e.body;if(!t){let e=lt()??ct();e!==null&&At(e);return}let n=st(t);if(t.revision===0){if(me=``,n===null||t.agentId!==O)return;xe=t.plan,be=!0}else lT(e.id,t),n!==null&&kt(t,n)&&(O=t.agentId,le=t.revision,de=``,fe=``)}function Nt(e){let t=Vw(e,O);t!==null&&t!==Vw(ce,O)&&(le=t,Re()),jt(e),ce=e,he=!1,Et(e)}function Pt(e){let n=!1;e.state&&Nt(e.state),e.draft&&Te.set(mt(e.draft.id,e.draft.agentId),e.draft.changedAt),e.decisionRefused&&(ge=null,he=!1,we=null,e.refusalText&&(Ce=e.refusalText)),typeof e.isConnected==`boolean`&&(n=e.isConnected&&!ue,ue=e.isConnected,n&&(de=``,fe=``,pe=``,me=``,he=!1)),e.requestFailed&&(fe=de),e.response&&Mt(e.response),t.hidden||Tt(),(n||e.decisionRefused)&&k()}return{el:t,show:Dt,hide:Ot,update:Pt}}function pT(e){let t=new Map;for(let n of e.files){let e=n.path.split(`/`);for(let r=0;r<e.length;r++){let i=e.slice(0,r).join(`/`),a=t.get(i);a!==void 0&&a.localeCompare(n.path)<=0||t.set(i,n.path)}}return t}function mT(e,t){let n=[],r=new Set(e.files.map(e=>e.path));for(let i of e.links){let a=t.get(i.providerRepo),o=a?.firstChangedPathByDirectory.get(i.packageDir),s=o??i.importers.find(e=>r.has(e))??i.importers[0]??i.consumerManifest,c=o&&a?a.repo:e,l=i.importerCount===1?`file`:`files`,u=i.providerChangedPathCount===1?`file`:`files`,d=i.changedImporterCount===1?`file`:`files`,f=i.isLocalLink?`Linked locally (${i.versionSpec}), so ${i.providerRepo} changes reach it now.`:`Uses ${i.versionSpec} from the registry, so ${i.providerRepo} changes reach it only after a publish.`;i.providerChangedPathCount>0&&(f+=` ${i.providerRepo} changed ${i.providerChangedPathCount} ${u} in ${i.packageDir||`the repository root`}.`),i.changedImporterCount>0&&(f+=` ${i.changedImporterCount} importing ${d} changed here.`),n.push({factId:i.factId,kind:`link`,severity:6,path:s,openPath:`${c.sessionPathPrefix}${s}`,headline:`${e.name} imports ${i.packageName} from ${i.providerRepo} in ${i.importerCount} ${l}`,detail:f})}for(let t of e.collisions)n.push({factId:t.factId,kind:`collision`,severity:5,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`${t.path} is also changed in "${t.otherSessionName}"`,detail:`Another live session is changing this file.`});for(let t of e.coChangeGaps){let r=t.confidence>0?Math.round(t.support/t.confidence):0;n.push({factId:t.factId,kind:`co-change`,severity:4,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`Usually changes with ${t.partner} (${t.support} of ${r} commits)`,detail:`${t.partner} is absent from these changes.`})}for(let t of e.untestedFiles)n.push({factId:t.factId,kind:`untested`,severity:3,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`No test reaches ${t.path}`,detail:`No dependent test was found in the import graph.`});for(let t of e.hotspots)n.push({factId:t.factId,kind:`hotspot`,severity:2,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`${t.path} is a hotspot`,detail:`${t.fixCommitCount} of its last ${t.commitCount} commits were fixes.`});for(let t of e.blastRadius)t.transitiveDependentCount<10||n.push({factId:t.factId,kind:`blast`,severity:1,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`Wide blast radius: ${t.transitiveDependentCount} files depend on ${t.path}`,detail:`${t.directDependentCount} direct dependents; ${t.dependentTestCount} dependent tests.`});return n.sort((e,t)=>t.severity-e.severity||e.path.localeCompare(t.path)||e.factId.localeCompare(t.factId))}function hT(e,t){let n=new Map(e.blastRadius.map(e=>[e.path,e])),r=e.files.filter(e=>e.isCommitted).length;return{header:{name:e.name,fileCount:e.files.length,committedCount:r,uncommittedCount:e.files.length-r,base:e.base},subsystems:e.subsystems.map(e=>({title:e.title,fileCount:e.paths.length})),warnings:mT(e,t),files:e.files.map(t=>({path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,status:t.status,isCommitted:t.isCommitted,dependentCount:n.get(t.path)?.transitiveDependentCount??0,testCount:n.get(t.path)?.dependentTestCount??0})),error:e.error}}function gT(e){let t=new Set(e.repos.flatMap(e=>e.links.map(e=>e.providerRepo))),n=new Map;for(let r of e.repos)t.has(r.name)&&!n.has(r.name)&&n.set(r.name,{repo:r,firstChangedPathByDirectory:pT(r)});let r=e.repos.map(e=>hT(e,n));return{repos:!e.error&&r.every(e=>e.header.fileCount===0&&e.warnings.length===0&&!e.error)?[]:r,narrative:{state:e.narratorState,claims:e.narratorState===`ready`?e.narrative?.claims.map(e=>({text:e.text,factIds:e.factIds}))??[]:[],status:{disabled:null,pending:`Narrative is being prepared.`,ready:null,failed:`Narrative could not be prepared.`}[e.narratorState]},error:e.error??null}}function _T(e,t,n,r){let i=M(`button`,n);return i.type=`button`,i.title=`Open ${e} in the diff`,i.addEventListener(`click`,()=>r(t)),i}function vT(e,t){let n=M(`section`,`review-map-repo`),r=M(`div`,`review-map-repo-head`);r.append(M(`strong`,`review-map-repo-name`,e.header.name)),n.append(r);let i=M(`div`,`review-map-summary`);if(i.append(M(`span`,``,`${e.header.committedCount} committed`)),i.append(M(`span`,``,`${e.header.uncommittedCount} uncommitted`)),i.append(M(`span`,``,`Base: ${T(e.header.base,{chars:8})||`unknown`}`)),n.append(i),e.error&&n.append(M(`p`,`review-map-error`,e.error)),e.subsystems.length>0){let t=M(`div`,`review-map-subsystems`);for(let n of e.subsystems)t.append(M(`span`,`review-map-chip`,`${n.title} (${n.fileCount})`));n.append(t)}if(e.warnings.length>0){n.append(M(`h3`,`review-map-label`,`Signals`));let r=M(`div`,`review-map-warnings`);for(let n of e.warnings){let e=_T(n.path,n.openPath,`review-map-warning`,t);e.dataset.severity=String(n.severity),e.dataset.kind=n.kind,e.append(M(`span`,`review-map-warning-headline`,n.headline)),e.append(M(`span`,`review-map-detail`,n.detail)),r.append(e)}n.append(r)}if(e.files.length>0){n.append(M(`h3`,`review-map-label`,`Files`));let r=M(`div`,`review-map-files`);for(let n of e.files){let e=_T(n.path,n.openPath,`review-map-file`,t);e.dataset.status=n.status,e.append(M(`span`,`review-map-file-path`,n.path)),e.append(M(`span`,`review-map-file-meta`,`${n.status} · ${n.isCommitted?`committed`:`uncommitted`} · ${n.dependentCount} dependents · ${n.testCount} tests`)),r.append(e)}n.append(r)}return n}function yT(e,t){let n=M(`div`,`review-map`);if(e.error&&n.append(M(`p`,`review-map-error`,e.error)),e.narrative.status&&n.append(M(`p`,`review-map-narrative-status`,e.narrative.status)),e.narrative.claims.length>0){let t=M(`section`,`review-map-narrative`);t.append(M(`h3`,`review-map-label`,`Narrative`));for(let n of e.narrative.claims){let e=M(`p`,`review-map-claim`,n.text);e.dataset.factIds=n.factIds.join(` `),t.append(e)}n.append(t)}for(let r of e.repos)n.append(vT(r,t));return n}function bT(e){let t=/^@@+ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return!Number.isFinite(n)||!Number.isFinite(r)?null:{oldStart:n,newStart:r}}function xT(e){let t=[];if(!e)return t;let n=String(e).split(/\r?\n/),r=null,i=null,a=null,o=null,s=()=>{if(a===null)return null;let e=a;return a=e+1,e},c=()=>{if(o===null)return null;let e=o;return o=e+1,e},l=e=>{let n={path:``,oldPath:null,status:`modified`,added:0,removed:0,binary:!1,hunks:[]};t.push(n),i=null;let r=/^diff --git a\/(.+?) b\/(.+)$/.exec(e);return r&&(n.oldPath=r[1]??null,n.path=r[2]??``),n};for(let e of n)if(e.startsWith(`diff --git `))r=l(e);else{if(!r){if(!e.startsWith(`--- `)&&!e.startsWith(`@@`))continue;r=l(`diff --git a/ b/`)}if(r){if(e.startsWith(`new file mode`))r.status=`added`;else if(e.startsWith(`deleted file mode`))r.status=`deleted`;else if(e.startsWith(`rename from `))r.oldPath=e.slice(12),r.status=`renamed`;else if(e.startsWith(`rename to `))r.path=e.slice(10),r.status=`renamed`;else if(e.startsWith(`Binary files`))r.binary=!0;else if(!(e.startsWith(`index `)||e.startsWith(`similarity index`)||e.startsWith(`dissimilarity index`)||e.startsWith(`old mode`)||e.startsWith(`new mode`))){if(e.startsWith(`--- `)){if(e===`--- /dev/null`){r.status=`added`;continue}if(!r.path){let t=e.slice(4).replace(/^a\//,``);t&&t!==`/dev/null`&&(r.oldPath=r.oldPath||t)}}else if(e.startsWith(`+++ `)){if(e===`+++ /dev/null`){r.status=`deleted`;continue}if(!r.path){let t=e.slice(4).replace(/^b\//,``);t&&t!==`/dev/null`&&(r.path=t)}}else if(e.startsWith(`@@`)){i={header:e,lines:[]},r.hunks.push(i);let t=bT(e);a=t?t.oldStart:null,o=t?t.newStart:null}else if(i){if(e===``)continue;let t=e[0];if(t===`+`){i.lines.push({type:`add`,text:e.slice(1),oldLineNumber:null,newLineNumber:c()}),r.added++;continue}if(t===`-`){i.lines.push({type:`del`,text:e.slice(1),oldLineNumber:s(),newLineNumber:null}),r.removed++;continue}if(t===`\\`){i.lines.push({type:`meta`,text:e.slice(1).trim(),oldLineNumber:null,newLineNumber:null});continue}i.lines.push({type:`context`,text:t===` `?e.slice(1):e,oldLineNumber:s(),newLineNumber:c()})}}}}for(let e of t)e.path||=e.oldPath||`(unknown)`;return t}function ST(e,t,n,r){return`${e}:${r}:${n}:${t}`}function CT(e,t,n){if(!e)return[];let r=new Set;if(e.committed!==t.committed&&r.add(`committed`),e.uncommitted!==t.uncommitted&&r.add(`uncommitted`),r.size===0)return[];let i=[];for(let e of n)r.has(e.slice(0,e.indexOf(`:`)))&&i.push(e);return i}function wT(e,t){return t.type===`del`?t.oldLineNumber===null?null:{path:e.path,line:t.oldLineNumber,side:`old`}:t.newLineNumber===null?null:{path:e.path,line:t.newLineNumber,side:`new`}}function TT(e,t){return t===`merged`||t===`none`||e===`parked`&&t===`pending-review`}function ET(e){let t=0,n=0;for(let r of e||[])t+=r.added||0,n+=r.removed||0;return{files:(e||[]).length,added:t,removed:n}}function DT({status:e,mergeReason:t,fetched:n,hasDiffError:r,hasChanges:i,hasCommits:a,canMerge:o,isWorkspace:s,live:c,effectiveBase:l}){return e===`parked`&&t===`base-diverged`?{text:`Parked: base branch diverged`,namesMergeTarget:!1}:e===`parked`?{text:`Parked: merge conflict`,namesMergeTarget:!1}:e===`merging`?{text:`Merging`,namesMergeTarget:!1}:e===`merged`?{text:`Merged`,namesMergeTarget:!1}:r?{text:`Could not read changes`,namesMergeTarget:!1}:n?i?s?{text:`Changes in this worktree`,namesMergeTarget:!1}:o?{text:`Ready to merge into ${AT(l)}`,namesMergeTarget:!0}:c?a?{text:`Not ready to merge`,namesMergeTarget:!1}:{text:`Uncommitted changes`,namesMergeTarget:!1}:{text:`Session ended`,namesMergeTarget:!1}:{text:`No changes yet`,namesMergeTarget:!1}:{text:`Checking for changes`,namesMergeTarget:!1}}function OT(e,t){return e.namesMergeTarget?null:`merges into ${AT(t)}`}function kT({status:e,mergeReason:t,live:n,isMergeRendered:r,hasChanges:i}){return e===`parked`&&n&&t!==`base-diverged`?`resolve`:!i&&e!==`parked`&&e!==`merging`?`none`:r?`merge`:`none`}function AT(e){return e||`base`}function jT(e,t){return`Merge into ${AT(e)}, push it, and rebase this worktree, then keep working (${t})`}function MT(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function NT(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function PT({status:e,hasCommits:t,live:n,state:r}){return e===`merging`||!t?null:!n&&(e===`parked`||e===`merged`)?`Session ended.`:!n||e===`parked`?null:r===`INITIALIZING`||r===`STARTING`?`Starting up. Mergeable once the session is live.`:null}function FT({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function IT(e){return e||`its upstream`}function LT(e){if(!e)return null;let t=e.branch||`Base branch`,{state:n,ahead:r,behind:i}=e,a=IT(e.upstream);return n===`no-upstream`?`${t}: no upstream`:n===`unknown`&&e.error&&e.action===void 0?`${t}: sync check failed: ${e.error}`:n===`unknown`?`${t}: sync state unknown vs ${a}`:n===`in-sync`?`${t}: in sync with ${a}`:n===`ahead`?`${t}: ${r} ahead of ${a}`:n===`behind`?`${t}: ${i} behind ${a}`:n===`diverged`?`${t}: ${r} ahead, ${i} behind ${a}`:null}function RT(e){return!e||e.fetched===!1?`recheck`:e.state===`ahead`||e.state===`behind`?`resync`:`recheck`}function zT(e,t,n){let r=n?` (${t})`:``;if(!e||RT(e)===`recheck`)return`Click to fetch and check again${r}`;let i=e.branch||`Base branch`,a=IT(e.upstream);return e.state===`behind`?`Click to fast-forward ${i} to ${a}${r}`:`Click to push ${i} to ${a}${r}`}function BT(e){return e?.state!==`in-sync`||e.fetched===!1}function VT({fetched:e,changedFileCount:t,view:n}){return!e||t===0?!1:n!==`diff`}function HT(e){if(e.error)return`Resync failed: ${e.error}`;let t=e.branch||`The base branch`,n=IT(e.upstream);return e.action===`fast-forwarded`?`Fast-forwarded ${t} to ${n}.`:e.action===`pushed`?`Pushed ${t} to ${n}.`:e.state===`diverged`?`${t} has diverged from ${n}. Resolve manually.`:e.state===`in-sync`?null:e.state===`no-upstream`?`${t} has no upstream to resync against.`:`Could not determine sync status.`}var UT=new Set([`pending-review`,`parked`]),WT=600,GT=qp(`merge`,Xp),KT=qp(`resolve-or-resync`,Xp),qT={minPx:260,maxPx:700},JT=16,YT=5e3,XT=new Map,ZT=new Map,QT=new Map,$T=new Map,eE=new Map,tE=new Map,nE=new Set,rE=new Set,iE=new Set,aE=ic(),oE=null,sE=null,cE=null,lE=null,uE=new Map,dE=null,fE=null,pE=null,mE=null,hE=null,gE=null,_E=!1,vE=null,yE=null,bE=null,xE=null,SE=new Map,CE=null,wE=null,TE=new Map,EE=null,DE=null,OE=null,kE=null,AE=null,jE=new Map,ME=new Map,NE=0,PE=null,FE=!1,IE=null;function LE(e,t){let n=M(`button`,`review-icon-button`);return n.type=`button`,n.title=e,n.setAttribute(`aria-label`,e),n.append(m_(t)),n}function RE(){_E=!1,cE?.querySelector(`.review-more-menu`)?.remove(),cE?.querySelector(`.review-more-button`)?.setAttribute(`aria-expanded`,`false`)}function zE({panel:e}){if(sE=e,!sE)return;let t=sE,n=M(`div`,`review-sidebar-head`),r=M(`span`,`review-sidebar-title`,`Review`);gE=M(`span`,`review-sidebar-session`),r.append(gE);let i=e=>{t.toggleAttribute(`data-collapsed`,e),rc(!e)},a=M(`div`,`review-header-tabs`);a.setAttribute(`role`,`group`),a.setAttribute(`aria-label`,`Review view`);for(let[e,t]of[[`map`,`Map`],[`diff`,`Diff`],[`notes`,`Notes`]]){let n=M(`button`,`review-header-tab`,t);n.type=`button`,n.addEventListener(`click`,()=>KD(e)),uE.set(e,n),a.append(n)}dE=M(`span`,`review-notes-count`),a.append(dE);let o=LE(`Close review`,`M6 3L11 8L6 13`);o.classList.add(`review-sidebar-close`),o.addEventListener(`click`,()=>i(!0)),n.append(r,a,o);let s=M(`div`,`review-sidebar-rail`),c=LE(`Open review`,`M10 3L5 8L10 13`);c.classList.add(`review-sidebar-open`),c.addEventListener(`click`,()=>i(!1)),pE=M(`div`,`review-rail-status`),mE=M(`span`,`review-rail-added`),hE=M(`span`,`review-rail-removed`),pE.append(mE,hE),fE=M(`span`,`review-rail-label`,`Review`),s.append(c,fE,pE),cE=M(`div`,`review-controls`),lE=M(`div`,`review-sidebar-body`),EE=M(`div`,`review-notes-footer`),DE=M(`button`,`review-btn review-btn-primary`,`Send notes`),DE.type=`button`,DE.title=`Paste the drafted review notes into this session as one message`,DE.addEventListener(`click`,jD),OE=M(`div`,`review-notes-status`),EE.append(OE,DE),AE=M(`div`,`review-notes-list`),kE=M(`div`,`review-notes-outcome`),kE.setAttribute(`role`,`status`);let l=M(`div`,`review-resize-handle`);l.setAttribute(`role`,`separator`),l.setAttribute(`aria-orientation`,`vertical`),l.setAttribute(`aria-label`,`Resize review sidebar`),l.tabIndex=0,t.append(s,n,cE,lE,kE,EE,l),t.toggleAttribute(`data-collapsed`,!nc()),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&_E&&(e.preventDefault(),RE(),cE?.querySelector(`.review-more-button`)?.focus())}),document.addEventListener(`pointerdown`,e=>{_E&&e.target instanceof Element&&(cE?.contains(e.target)&&e.target.closest(`.review-more-button, .review-more-menu`)||RE())}),n_({resizer:l,column:t,widthHost:t,widthProperty:`--sidebar-width`,bounds:qT,keyStepPx:JT,getStoredWidth:Mc,setStoredWidth:Nc,growsLeftward:!0}),Vv(e=>{_E=!1,bE=null,rE.clear(),iE.clear(),oE=null,wD(),e&&hD(e),e&&!_D(e)&&vD(e),QD()}),QD()}function BE(e){sE&&(e?br(sE,e):xr(sE))}function VE(e,t){let n=XT.get(e);XT.set(e,t),TT(n,t)&&(QT.delete(e),$T.delete(e),eE.delete(e),e===zv()&&gD(e)),e===zv()&&QD()}function HE(e,t,n=null){let r=t||`none`;ZT.set(e,n);let i=SE.get(e);i!==void 0&&i!==r&&SE.delete(e),VE(e,r)}function UE(e){let t=Cr(e);t&&SE.delete(t)&&t===zv()&&QD()}function WE(e,t,n=null){ZT.set(e,n),SE.delete(e),VE(e,t||`none`)}function GE(e,t){let n=QT.get(e)??null;QT.set(e,t),$T.delete(e),e===zv()&&(YE(n,t),oE&&qD(oE,t),QD(),JD())}function KE(e,t){let n=Cr(e);n&&($T.set(n,t),n===zv()&&QD())}function qE(e,t){let n=Cr(e);if(!n)return;let r=ji.safeParse(t);r.success&&r.data.sessionId===n&&(eE.set(n,r.data),n===zv()&&QD())}function JE(e){return{committed:e?.committed?.diff||``,uncommitted:e?.uncommitted?.diff||``}}function YE(e,t){if(!e)return;let n=PE===null?[...jE.keys()]:[...jE.keys(),PE];if(n.length===0)return;let r=new Set(CT(JE(e),JE(t),n));if(r.size===0)return;PE!==null&&r.has(PE)&&XE(PE);for(let e of r){let t=jE.get(e);t&&ZE(t),jE.delete(e)}let i=ME.size;IE=i===0?null:`The diff changed under ${i} note${i===1?``:`s`}. ${i===1?`It is`:`They are`} kept under Notes as no longer attached and will not be sent.`}function XE(e){PE=null;let t=TE.get(e),n=lE?.querySelector(`[data-editor-for="${CSS.escape(e)}"] input`)?.value.trim()??``;t&&n&&jE.get(e)?.note!==n&&ZE({...t.target,section:t.section,note:n})}function ZE(e){ME.set(`orphan:${NE}`,e),NE+=1}function QE(e,t){let n=Cr(e),r=t;tE.set(n,r),r&&r.action!==void 0&&$E(n,r),n===zv()&&QD()}function $E(e,t){nE.delete(e),clearTimeout(wE??void 0),wE=null;let n=HT(t);CE=n?{forId:e,text:n,isError:!!t.error}:null,CE&&!CE.isError&&(wE=setTimeout(()=>{CE&&CE.forId===e&&(CE=null),QD()},5e3))}function eD(e){let t=Cr(e);t&&t===zv()&&hD(t)}function tD(e){let t=Cr(e);if(t!==zv())return;let n=!QT.has(t)||$T.has(t),r=!eE.has(t)||nD(eE.get(t));n&&hD(t),r&&!n&&gD(t),QD()}function nD(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function rD(e){let t=Cr(e);XT.delete(t),ZT.delete(t),QT.delete(t),$T.delete(t),eE.delete(t),tE.delete(t),nE.delete(t),CE&&CE.forId===t&&(clearTimeout(wE??void 0),CE=null),t===zv()?Bv(null):QD()}function iD(){let e=zv(),t=e?F.get(e):null;if(!e||!t)return aD(null,`No session is open to merge.`);if(_D(e))return aD(e,`A workspace session has no worktree to merge.`);if(SE.has(e))return aD(e,`Merge is already on its way for "${CD(t,e)}".`);let n=XT.get(e)||`none`,r=!!QT.get(e)?.hasCommits,i=NT(n,ZT.get(e)||null,dD(t.currentState,r));return kT({status:n,mergeReason:ZT.get(e)||null,live:mD(t.currentState),isMergeRendered:i.isRendered,hasChanges:uD(e)})!==`merge`||!i.isEnabled?aD(e,PT({status:n,hasCommits:r,live:mD(t.currentState),state:t.currentState})??`Nothing to merge in "${CD(t,e)}" right now.`):(fD(e,t.currentState),!0)}function aD(e,t){return bE={forId:e,text:t},clearTimeout(xE??void 0),xE=setTimeout(()=>{bE=null,QD()},YT),QD(),!1}function oD(){let e=zv();if(!e||_D(e))return!1;let t=F.get(e);if(!t)return!1;let n=XT.get(e)||`none`,r=ZT.get(e)||null;return kT({status:n,mergeReason:r,live:mD(t.currentState),isMergeRendered:NT(n,r,!1).isRendered,hasChanges:uD(e)})!==`resolve`||sD(e)?!1:(cD(e),!0)}function sD(e){return vE?.forId===e&&!vE.isError}function cD(e){let t=K({type:`resolve-session-merge`,id:e});vE=t?{forId:e,text:`Resolve prompt sent`,isError:!1}:{forId:e,text:`Not connected. The resolve prompt was not sent.`,isError:!0},clearTimeout(yE??void 0),yE=setTimeout(()=>{vE=null,QD()},t?3e3:YT),QD()}function lD(){let e=zv();return!e||!F.has(e)||_D(e)||bD(e)?!1:(xD(e),!0)}function uD(e){let t=QT.get(e)??null,n=[...xT(t?.committed?.diff||``),...xT(t?.uncommitted?.diff||``)];return FT({fetched:QT.has(e),changedFileCount:ET(n).files,hasCommits:!!t?.hasCommits})}function dD(e,t){return(Qn.includes(e)||e===j.RUNNING)&&t}function fD(e,t){t===j.RUNNING?rf({title:`Merge while working`,message:`This session still looks like it is working. Merging rebases its worktree under it. Merge anyway?`,confirmLabel:`Merge anyway`,onConfirm:()=>pD(e,!0)}):pD(e,!1)}function pD(e,t){SE.has(e)||(K(t?{type:`merge-continue-session`,id:e,force:!0}:{type:`merge-continue-session`,id:e})?(SE.set(e,XT.get(e)||`none`),e===zv()&&QD()):aD(e,`Not connected. The merge was not sent.`))}function mD(e){return e!==j.DORMANT&&e!==j.DONE&&e!==j.FAILED}function hD(e){K({type:`request-session-diff`,id:e}),gD(e)}function gD(e){eE.has(e)||eE.set(e,null),K({type:`request-change-map`,id:e})}function _D(e){return F.get(e)?.card.dataset.workspace!==void 0}function vD(e){tE.set(e,null),K({type:`request-branch-sync`,id:e}),e===zv()&&QD()}function yD(e){nE.add(e),clearTimeout(wE??void 0),CE&&CE.forId===e&&(CE=null),K({type:`resync-branch`,id:e}),e===zv()&&QD()}function bD(e){return nE.has(e)||tE.get(e)===null}function xD(e){bD(e)||(RT(tE.get(e))===`resync`?yD(e):vD(e))}function SD(e,t){return t?{text:`Resyncing`,loading:!0,error:!1}:CE&&CE.forId===e?{text:CE.text,loading:!1,error:CE.isError}:null}function CD(e,t){return e?.card?.dataset.session||t}function wD(){jE.clear(),ME.clear(),PE=null,IE=null,FE=!1}function TD(e){return jE.get(e)??null}function ED(){return`${jE.size} note${jE.size===1?``:`s`} drafted`}function DD(e,t,n){let r=M(`div`,`review-notes-entry`),i=t.side===`old`?` (removed line)`:``,a=n?`, no longer attached: the diff changed, not sent`:``;r.append(M(`span`,`review-notes-entry-where`,`${t.section} ${t.path}:${t.line}${i}${a}`)),r.append(M(`span`,`review-notes-entry-note`,t.note));let o=M(`button`,`review-note-remove`,`Remove`);return o.type=`button`,o.title=`Drop this note`,o.addEventListener(`click`,()=>n?WD(e):GD(e)),r.append(o),r}function OD(){if(AE){AE.replaceChildren(),AE.hidden=jE.size===0&&ME.size===0;for(let[e,t]of jE)AE.append(DD(e,t,!1));for(let[e,t]of ME)AE.append(DD(e,t,!0))}}function kD(){if(!EE||!DE||!OE)return;let e=zv(),t=!!e&&F.has(e);EE.hidden=!t||aE===`map`||jE.size===0,DE.disabled=FE||jE.size===0,OE.textContent=ED(),dE&&(dE.hidden=jE.size===0,dE.textContent=String(jE.size),dE.setAttribute(`aria-label`,ED())),kE&&(kE.textContent=FE?`Sending notes...`:IE,kE.hidden=!t||aE===`map`||!kE.textContent),OD(),aE===`notes`&&t&&AD()}function AD(){lE&&AE&&(lE.replaceChildren(),jE.size===0&&ME.size===0?nO(`No notes yet`,`Open the Diff tab and press note on a line to draft one.`):lE.append(AE))}function jD(){let e=zv();e&&!FE&&jE.size!==0&&(FE=!0,IE=null,kD(),_d(`send-diff-annotations`,{id:e,annotations:[...jE.values()]}).then(PD,MD))}function MD(e){FE=!1;let t=e instanceof Error?e.message:``;IE=t?`Could not send the notes: ${t}.`:`Could not send the notes.`,kD()}function ND(e){return e.type===`send-diff-annotations-result`&&typeof e.error==`string`&&e.error?e.error:e.type===`error`&&typeof e.message==`string`&&e.message?e.message:`Could not send the notes.`}function PD(e){FE=!1,e.type!==`send-diff-annotations-result`||e.ok!==!0?(IE=ND(e),kD()):e.pending===!0?(IE=`Notes queued until the session wakes. They stay drafted here, and pressing Send notes again re-sends them.`,kD()):(IE=`Notes sent.`,jE.clear(),PE=null,QD())}function FD(e,t){let n=M(`div`,`review-note`);n.dataset.noteFor=e,n.append(M(`span`,`review-note-text`,t));let r=M(`button`,`review-note-remove`,`Remove`);return r.type=`button`,r.title=`Drop this note`,r.addEventListener(`click`,()=>GD(e)),n.append(r),n}function ID(e,t){let n=M(`div`,`review-note-editor`);n.dataset.editorFor=e;let r=M(`input`,`review-note-input`);r.type=`text`,r.value=t,r.maxLength=wo,r.placeholder=`Note for this line`,r.addEventListener(`keydown`,t=>{t.key===`Enter`?(t.preventDefault(),UD(e,r.value)):t.key===`Escape`&&(t.preventDefault(),HD())});let i=M(`button`,`review-note-save`,`Save`);i.type=`button`,i.addEventListener(`click`,()=>UD(e,r.value));let a=M(`button`,`review-note-cancel`,`Cancel`);return a.type=`button`,a.addEventListener(`click`,HD),n.append(r,i,a),n}function LD(e){let t=[],n=TD(e);return PE===e&&t.push(ID(e,n?n.note:``)),n&&t.push(FD(e,n.note)),t}function RD(e,t){let n=LD(t);return e.after(...n),n}function zD(e){let t=e.nextElementSibling;for(;t instanceof HTMLElement&&(t.dataset.noteFor!==void 0||t.dataset.editorFor!==void 0);){let e=t.nextElementSibling;t.remove(),t=e}}function BD(e){let t=TE.get(e);if(!t)return;let n=null;for(let r of t.rows){zD(r);let t=RD(r,e);for(let e of t){let t=e.querySelector(`input`);!n&&t instanceof HTMLInputElement&&(n=t)}}n&&(n.focus(),n.select())}function VD(e){let t=PE;PE=e,t&&t!==e&&BD(t),BD(e)}function HD(){let e=PE;e&&(PE=null,BD(e))}function UD(e,t){let n=TE.get(e);if(!n)return;let r=t.trim();r&&(jE.size>=50&&!jE.has(e)?(IE=`Only 50 notes can be sent at once.`,kD()):(jE.set(e,{...n.target,section:n.section,note:r}),IE=null,PE=null,BD(e),kD()))}function WD(e){ME.delete(e),IE=null,kD()}function GD(e){jE.delete(e),IE=null,BD(e),kD()}function KD(e){aE=e,e!==`diff`&&(oE=null),ac(e),QD()}function qD(e,t){if(!t)return;let n=xT(t.committed?.diff),r=xT(t.uncommitted?.diff);for(let t of n)(t.path===e||t.oldPath===e)&&rE.add(`committed:${t.path}`);for(let t of r)(t.path===e||t.oldPath===e)&&rE.add(`uncommitted:${t.path}`)}function JD(){if(!lE||!oE)return;let e=lE.querySelectorAll(`.review-file`);for(let t of e)if(t.dataset.path===oE||t.dataset.oldPath===oE){t.scrollIntoView({block:`nearest`}),oE=null;return}}function YD(e){oE=e,qD(e,QT.get(zv()??``)),KD(`diff`),JD()}function XD(){if(PE===null||!lE)return null;let e=lE.querySelector(`[data-editor-for="${CSS.escape(PE)}"] input`);return e?{noteKey:PE,text:e.value,selectionStart:e.selectionStart,selectionEnd:e.selectionEnd,hadFocus:document.activeElement===e}:null}function ZD(e){if(!e||e.noteKey!==PE||!lE)return;let t=lE.querySelector(`[data-editor-for="${CSS.escape(e.noteKey)}"] input`);t&&(t.value=e.text,e.hadFocus&&(t.focus({preventScroll:!0}),t.setSelectionRange(e.selectionStart,e.selectionEnd)))}function QD(){let e=XD(),t=lE?.scrollTop??0;$D(),ZD(e),lE&&(lE.scrollTop=t)}function $D(){if(!cE||!lE)return;cE.replaceChildren(),lE.replaceChildren();for(let[e,t]of uE)t.setAttribute(`aria-pressed`,String(aE===e));TE.clear(),kD(),fE&&(fE.hidden=!0),pE&&(pE.hidden=!0);let e=zv(),t=e?F.get(e):null;if(tO(e,t),!e||!t){bE&&cE.append(eO(bE.text,!0)),nO(`No session selected`,`Click a session name to review its changes here.`);return}let n=_D(e),r=XT.get(e)||`none`,i=ZT.get(e)||null,a=t.currentState,o=UT.has(r),s=QT.has(e),c=s?QT.get(e):null,l=$T.get(e)??null,u=c?xT(c.committed?.diff||``):[],d=c?xT(c.uncommitted?.diff||``):[],f=!!c?.hasCommits,p=mD(a),m=NT(r,i,dD(a,f)),h=tE.get(e),g=nE.has(e),_=AT(t.effectiveBase),v=ET([...u,...d]),y=kT({status:r,mergeReason:i,live:p,hasChanges:FT({fetched:s,changedFileCount:v.files,hasCommits:f}),isMergeRendered:m.isRendered}),b=DT({status:r,mergeReason:i,fetched:s,hasDiffError:l!==null,hasChanges:v.files>0||f,hasCommits:f,canMerge:!n&&m.isEnabled,isWorkspace:n,live:p,effectiveBase:_}),x=M(`div`,`review-status-headline`);if(x.append(M(`span`,`review-status-text`,b.text)),!n&&!BT(h)){let t=LT(h);if(t){x.title=t;let n=LE(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);n.classList.add(`review-branch-sync-refresh`),n.title=zT(h,KT,y!==`resolve`),n.disabled=bD(e),n.setAttribute(`aria-description`,t),n.addEventListener(`click`,()=>xD(e)),x.append(M(`span`,`sr-only`,t),n)}}cE.append(x);let S=M(`div`,`review-status-meta`);if(VT({fetched:s,changedFileCount:v.files,view:aE})&&S.append(M(`span`,`review-status-files`,`${v.files} file${v.files===1?``:`s`}`),M(`span`,`review-status-added`,`+${v.added}`),M(`span`,`review-status-removed`,`-${v.removed}`),M(`span`,`review-status-spacer`)),!n&&BT(h)){let t=rO(e,y!==`resolve`);t&&S.append(t)}S.childElementCount>0&&cE.append(S),r===`parked`&&cE.append(M(`div`,`review-status-explanation`,MT(i))),fE&&(fE.hidden=!1),pE&&(pE.hidden=!1,pE.setAttribute(`aria-label`,`${b.text}, +${v.added}, -${v.removed}`),pE.title=b.text),mE&&(mE.textContent=`+${v.added}`),hE&&(hE.textContent=`-${v.removed}`);let ee=n?null:sO(e,{status:r,reviewable:o,mergeAction:m,live:p,state:a,effectiveBase:_,primaryAction:y});ee&&cE.append(ee);let te=n?null:SD(e,g),C=!n&&y===`merge`&&!m.isEnabled?PT({status:r,hasCommits:f,live:p,state:a}):null;if(C){let e=M(`div`,`review-control-reason`,C);e.id=`review-merge-reason`,cE.append(e),cE.querySelector(`#review-merge-btn`)?.setAttribute(`aria-describedby`,e.id)}if(te?.text){let e=M(`div`,te.loading?`review-control-reason review-loading`:`review-control-reason`,te.text);e.id=`review-resync-reason`,te.error&&e.classList.add(`review-control-reason-error`),e.setAttribute(`role`,`status`),S.append(e),S.isConnected||cE.insertBefore(S,x.nextSibling),cE.querySelector(`.review-branch-sync-button, .review-branch-sync-refresh`)?.setAttribute(`aria-describedby`,e.id)}if(vE?.forId===e&&cE.append(eO(vE.text,vE.isError)),bE&&(bE.forId===e||bE.forId===null)&&cE.append(eO(bE.text,!0)),aE!==`notes`){if(aE===`map`){let t=eE.get(e);if(!t){lE.append(M(`div`,`review-nochanges review-loading`,`Loading map...`));return}lE.append(yT(gT(t),YD))}else l?lE.append(M(`p`,`review-diff-error`,l)):(u.length>0&&lE.append(iO(`committed`,`Committed`,OT(b,_),u)),d.length>0&&lE.append(iO(`uncommitted`,`Uncommitted`,null,d)))}}function eO(e,t){let n=M(`div`,t?`review-control-reason review-control-reason-error`:`review-resolve-sent`,e);return n.setAttribute(`role`,`status`),n}function tO(e,t){if(!gE)return;let n=e&&t?CD(t,e):``;gE.textContent=n,gE.hidden=!n,gE.title=n}function nO(e,t){if(!lE)return;let n=M(`div`,`review-empty`);n.append(M(`div`,`review-empty-title`,e),M(`div`,`review-empty-desc`,t)),lE.append(n)}function rO(e,t){let n=tE.get(e);if(n===void 0)return null;if(n===null)return M(`span`,`review-branch-sync-text review-loading`,`Checking branch sync...`);let r=LT(n)||`Base branch: sync state unknown`,i=M(`span`,`review-branch-sync-text`);n.state&&(i.dataset.syncState=n.state),n.fetched===!1&&(i.dataset.stale=`true`);let a=LE(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);return a.classList.add(`review-branch-sync-button`),a.title=zT(n,KT,t),a.disabled=nE.has(e),a.addEventListener(`click`,()=>xD(e)),i.append(a,M(`span`,`review-branch-sync-label`,r)),i}function iO(e,t,n,r){let i=M(`div`,`review-section`);i.dataset.kind=e;let a=ET(r),o=M(`div`,`review-section-head`),s=M(`div`,`review-section-id`);s.append(M(`span`,`review-section-label`,t)),n&&s.append(M(`span`,`review-section-meaning`,n)),o.append(s);let c=M(`div`,`review-section-stat`);c.append(M(`span`,`review-stat-files`,`${a.files} file${a.files===1?``:`s`}`)),c.append(M(`span`,`review-add`,`+${a.added}`),M(`span`,`review-del`,`-${a.removed}`)),o.append(c),i.append(o);let l=M(`div`,`review-diff`);for(let t of r)l.append(aO(t,e));return i.append(l),i}function aO(e,t){let n=`${t}:${e.path}`,r=rE.has(n),i=M(`div`,`review-file`);i.dataset.path=e.path,e.oldPath&&(i.dataset.oldPath=e.oldPath),i.dataset.status=e.status,i.dataset.open=r?`true`:`false`;let a=M(`button`,`review-file-head`);a.type=`button`,a.setAttribute(`aria-expanded`,r?`true`:`false`);let o=M(`span`,`review-file-twisty`,r?`▾`:`▸`);o.setAttribute(`aria-hidden`,`true`),a.append(o,M(`span`,`review-file-path`,e.path));let s=M(`span`,`review-file-counts`);if(e.binary&&s.append(M(`span`,`review-bin`,`bin`)),e.binary||s.append(M(`span`,`review-add`,`+${e.added}`),M(`span`,`review-del`,`-${e.removed}`)),a.append(s),a.addEventListener(`click`,()=>{let e=rE.has(n);e&&rE.delete(n),e||rE.add(n),QD()}),i.append(a),!r)return i;let c=M(`div`,`review-file-body`);if(e.binary)return c.append(M(`div`,`review-file-binary`,`Binary file not shown`)),i.append(c),i;let l=0,u=!1;for(let r of e.hunks){if(l>=WT&&!iE.has(n)){u=!0;break}c.append(M(`div`,`review-hunk-head`,r.header));for(let i of r.lines){if(l>=WT&&!iE.has(n)){u=!0;break}let r=M(`div`,`review-line review-line-${i.type}`),a=i.type===`add`?`+`:i.type===`del`?`-`:i.type===`meta`?`\\`:` `;r.append(M(`span`,`review-line-gutter`,a)),r.append(M(`span`,`review-line-text`,i.text));let o=wT(e,i);if(c.append(r),l++,!o)continue;let s=ST(t,o.path,o.line,o.side),d=TE.get(s)??{target:o,section:t,rows:[]};d.rows.push(r),TE.set(s,d),r.dataset.noteKey=s;let f=M(`button`,`review-annotate`,`note`);f.type=`button`,f.title=`Note on ${o.path}:${o.line}`,f.addEventListener(`click`,()=>VD(s)),r.append(f),RD(r,s)}if(u)break}if(u){let e=M(`button`,`review-expand`,`Show the rest of this file`);e.type=`button`,e.addEventListener(`click`,()=>{iE.add(n),QD()}),c.append(e)}return i.append(c),i}function oO({id:e,label:t,shortcut:n,title:r,disabled:i=!1,danger:a=!1,onClick:o}){let s=M(`button`,a?`review-btn review-btn-danger`:`review-btn review-btn-primary`);return s.type=`button`,e&&(s.id=e),r&&(s.title=r),s.disabled=i,s.innerHTML=n?`${t} <kbd class="review-shortcut" aria-hidden="true">${n}</kbd>`:t,s.addEventListener(`click`,o),s}function sO(e,{status:t,reviewable:n,mergeAction:r,live:i,state:a,effectiveBase:o,primaryAction:s}){let c=M(`div`,`review-actions`),l=s===`resolve`;s===`merge`&&c.append(oO({id:`review-merge-btn`,label:`Merge`,shortcut:GT,title:jT(o,GT),disabled:!r.isEnabled||SE.has(e),onClick:()=>fD(e,a)})),l&&c.append(oO({label:`Resolve`,shortcut:KT,title:`Paste a resolve prompt into this session so the agent can finish the merge (${KT})`,disabled:sD(e),onClick:()=>cD(e)}));let u=M(`div`,`review-action-controls`);if(u.append(c),!n||i)return c.childElementCount>0?u:null;let d=LE(`More review actions`,p_);if(d.classList.add(`review-more-button`),d.setAttribute(`aria-haspopup`,`menu`),d.setAttribute(`aria-expanded`,String(_E)),d.setAttribute(`aria-controls`,`review-more-menu`),d.addEventListener(`click`,()=>{_E=!_E,QD(),(cE?.querySelector(_E?`.review-more-menu button:not(:disabled)`:`.review-more-button`)??cE?.querySelector(`.review-more-button`))?.focus()}),c.append(d),!_E)return u;let f=M(`div`,`review-more-menu`);if(f.id=`review-more-menu`,f.setAttribute(`role`,`menu`),f.setAttribute(`aria-label`,`More review actions`),n&&!i){let n=oO({label:`Discard worktree`,danger:!0,disabled:t===`merging`,onClick:()=>{_E=!1,QD(),rf({title:`Discard worktree`,message:`Throw away the worktree changes for "${CD(F.get(e),e)}"? This cannot be undone.`,confirmLabel:`Discard`,danger:!0,onConfirm:()=>K({type:`discard-session-worktree`,id:e})})}});n.setAttribute(`role`,`menuitem`),f.append(n)}return u.append(f),u}var cO=Object.freeze({Bash:`command`,Read:`file_path`,Edit:`file_path`,MultiEdit:`file_path`,Write:`file_path`,NotebookEdit:`notebook_path`,Grep:`pattern`,Glob:`pattern`,WebFetch:`url`,WebSearch:`query`,Task:`description`,Agent:`description`,Skill:`skill`});function lO(e){let t=e.split(/\r?\n/,1)[0]?.trim()??``;return t.length<=160?t:`${t.slice(0,157)}...`}function uO(e,t){let n=cO[e];if(!n||!t||typeof t!=`object`||Array.isArray(t))return``;let r=t[n];return typeof r==`string`?lO(r):``}var dO=5e3;function fO(e){let t=e.match(/<command-name>([^<]*)<\/command-name>/)?.[1];return t===void 0||/[\r\n]/.test(t)?null:t.trim()||null}function pO(e,t){if(!e.toolUseId)return fO(e.text)??`context`;let n=t.get(e.toolUseId);return n?uO(n.name,n.input)||n.name:`expansion`}function mO(e){return e.kind!==`expansion`||e.toolUseId?!1:fO(e.text)!==null}function hO(e){return e.kind===`prompt`||e.kind===`session`||mO(e)}function gO(e){return new TextEncoder().encode(e).byteLength}function _O(e){return e.kind===`prompt`||e.kind===`expansion`||e.kind===`thinking`||e.kind===`assistant`||e.kind===`notice`?e.text:e.kind===`tool_result`?e.content:e.kind===`raw`?e.line:e.kind===`tool_call`?JSON.stringify(e.input,null,2)??String(e.input??``):[`${e.vendor} ${e.vendorSessionId}`,e.transcriptPath,e.reason??``].filter(Boolean).join(`
163
- `)}var vO={prompt:`PROMPT`,expansion:`EXPANSION`,thinking:`THINKING`,assistant:`ASSISTANT`,tool_call:`TOOL`,tool_result:`RESULT`,session:`SESSION`,notice:`NOTICE`,raw:`RAW`},yO=[{kind:`thinking`,label:`Thinking`},{kind:`tool_result`,label:`Tool result`},{kind:`raw`,label:`Raw`}];function bO(e,t){if(e.kind===`prompt`)return{prefix:`Prompt: `,text:lO(e.text)};if(e.kind===`thinking`)return{prefix:`Thinking: `,text:lO(e.text)};if(e.kind===`assistant`)return{prefix:`Assistant: `,text:lO(e.text)};if(e.kind===`notice`)return{prefix:`Notice: `,text:lO(e.text)};if(e.kind===`raw`)return{prefix:`Raw: `,text:lO(e.line)};if(e.kind===`session`)return{prefix:`Session: `,text:`${e.vendor} ${e.vendorSessionId}`};if(e.kind===`expansion`)return{prefix:`Expansion: `,text:pO(e,t)};if(e.kind===`tool_call`){let t=uO(e.name,e.input);return t?{prefix:`${e.name}: `,text:t}:{prefix:``,text:e.name}}return{prefix:`${t.get(e.toolUseId)?.name??`Tool`} result: `,text:`${gO(e.content)} bytes`}}function xO(e){if(!e.agentType)return``;let t=e.agentId?` ${e.agentId.slice(-6)}`:``;return`[${e.agentType}${t}] `}function SO(e,t){let n=bO(e,t),r=xO(e),i=e.kind===`tool_call`||e.kind===`tool_result`?`${n.prefix}${n.text}`:n.text,a=[],o=e.kind===`notice`?`muted`:`default`;if(e.kind===`tool_result`&&e.isError&&(o=`error`,a.push(`error`)),e.truncated===!0&&(o!==`error`&&(o=`muted`),a.push(`truncated`)),e.kind===`tool_result`){let n=t.get(e.toolUseId),r=n?e.ts-n.ts:NaN;Number.isFinite(r)&&r>=0&&a.push(r>1e3?`${(r/1e3).toFixed(1)}s`:`${Math.round(r)}ms`)}return{kind:e.kind,tag:vO[e.kind],text:`${r}${i}`,tone:o,badges:a}}function CO(e,t){return{record:e,...SO(e,t)}}function wO(e){return e.kind!==`tool_result`&&e.kind!==`expansion`?null:e.toolUseId||null}function TO(e,t){let n=wO(e);return!n||t.has(n)?null:n}function EO(e,t,n=1){e.set(t,(e.get(t)??0)+n)}function DO(e,t){let n=(e.get(t)??0)-1;n>0?e.set(t,n):e.delete(t)}function OO(e,t){if(t.size!==0)for(let n of e.turns)for(let r=0;r<n.rows.length;r+=1){let i=n.rows[r],a=wO(i.record);a&&t.has(a)&&(n.rows[r]=CO(i.record,e.toolCallByUseId))}}function kO(){return{turns:[],toolCallByUseId:new Map,unresolvedToolUseCounts:new Map}}function AO(e){if(e.startedAt===null)return 0;let t=e.head?.record.ts??e.startedAt;for(let n of e.rows)t=Math.max(t,n.record.ts);return Math.max(0,t-e.startedAt)}function jO(e){let{rowCount:t,toolCallCount:n,errorCount:r,resultBytes:i}=e.metrics;return`${`${t} ${t===1?`row`:`rows`}`}, ${`${n} ${n===1?`tool`:`tools`}`}, ${`${r} ${r===1?`error`:`errors`}`}, ${wl(i,`KB`)}, ${Zl(AO(e))}`}function MO(){return{rowCount:0,toolCallCount:0,errorCount:0,resultBytes:0}}function NO(e,t,n){e.metrics.rowCount+=n,t.record.kind===`tool_call`&&(e.metrics.toolCallCount+=n),t.record.kind===`tool_result`&&(e.metrics.resultBytes+=gO(t.record.content)*n,t.record.isError&&(e.metrics.errorCount+=n))}function PO(e,t){for(let n of t)n.kind===`tool_call`&&e.toolCallByUseId.set(n.toolUseId,n);let n=[],r=e.turns[e.turns.length-1]??null;for(let i of t){let t=TO(i,e.toolCallByUseId);t&&EO(e.unresolvedToolUseCounts,t);let a=CO(i,e.toolCallByUseId);if(hO(i)){r={head:a,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:MO()},NO(r,a,1),e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:a,rows:[]});continue}r||(r={head:null,rows:[],hasTrimmedRows:!1,startedAt:i.ts,metrics:MO()},e.turns.push(r),n.push({turnIndex:e.turns.length-1,isNewTurn:!0,head:null,rows:[]})),r.rows.push(a),NO(r,a,1);let o=e.turns.length-1,s=n[n.length-1];s&&s.turnIndex===o?s.rows.push(a):n.push({turnIndex:o,isNewTurn:!1,head:null,rows:[a]})}return n}function FO(e,t){let n=kO();PO(n,t);let r=new Set;for(let[t,i]of n.toolCallByUseId)e.toolCallByUseId.has(t)||(e.toolCallByUseId.set(t,i),r.add(t));let i=new Set;for(let t of r)e.unresolvedToolUseCounts.delete(t)&&i.add(t);for(let[t,r]of n.unresolvedToolUseCounts)e.toolCallByUseId.has(t)||EO(e.unresolvedToolUseCounts,t,r);let a=n.turns[n.turns.length-1],o=e.turns[0],s=!!a&&!!o&&!o.head,c=s?a.head:null,l=s?a.rows:[];if(s){n.turns.pop();let e=a.startedAt,t=o.startedAt;e!==null&&(t===null||e<t)&&(o.startedAt=a.startedAt),o.head=c,o.rows=[...l,...o.rows],o.metrics={rowCount:a.metrics.rowCount+o.metrics.rowCount,toolCallCount:a.metrics.toolCallCount+o.metrics.toolCallCount,errorCount:a.metrics.errorCount+o.metrics.errorCount,resultBytes:a.metrics.resultBytes+o.metrics.resultBytes}}return e.turns=[...n.turns,...e.turns],OO(e,i),{newTurns:n.turns,mergedHead:c,mergedRows:l,needsRerender:i.size>0}}function IO(e){return e.rows.length+ +!!e.head}function LO(e){let t=0;for(let n of e.turns)t+=IO(n);return t}function RO(e,t){for(let n of t){if(n.record.kind===`tool_call`){e.toolCallByUseId.delete(n.record.toolUseId);continue}let t=wO(n.record);t&&DO(e.unresolvedToolUseCounts,t)}}function zO(e,t){RO(e,t.head?[t.head,...t.rows]:t.rows)}function BO(e,t){let n=e.turns[0];if(!n)return 0;let r=Math.min(t,n.rows.length);if(r<=0)return 0;let i=n.rows.slice(0,r);RO(e,i);for(let e of i)NO(n,e,-1);return n.rows=n.rows.slice(r),n.hasTrimmedRows=!0,r}function VO(e,t=dO){let n=LO(e),r=0;for(;n>t&&r<e.turns.length-1;){let t=e.turns[r];if(!t)break;n-=IO(t),zO(e,t),r+=1}return r>0&&(e.turns=e.turns.slice(r)),n<=t?{droppedTurnCount:r,droppedRowCount:0}:{droppedTurnCount:r,droppedRowCount:BO(e,n-t)}}function HO(e){let t=[],n=new Set;for(let r of e)r.id&&r.name&&!n.has(r.id)&&(n.add(r.id),t.push({id:r.id,label:r.name}));return t}function UO(e,t,n,r=!0){return t&&e.some(e=>e.id===t)?t:n&&e.some(e=>e.id===n)?n:r?e[0]?.id??null:null}function WO(e){return!e.selectedSessionId||!e.isPanelVisible||e.hasPendingRequest?null:e.hasLoadedOnce?{id:e.selectedSessionId,direction:`forward`,after:e.nextOffset}:{id:e.selectedSessionId,direction:`tail`,after:0,endingAt:`tail`}}function GO(e,t=dO){return!e.selectedSessionId||!e.hasLoadedOnce||e.hasDroppedEarliestRows||e.residentRowCount>=t?!1:e.firstOffset>0}function KO(e,t=dO){return!GO(e,t)||e.hasPendingRequest||!e.selectedSessionId?null:{id:e.selectedSessionId,direction:`earlier`,after:0,endingAt:e.firstOffset}}function qO(e){let{pendingRequest:t,resident:n,reply:r}=e;return!t||t.id!==r.id?`ignore`:!n||n.sessionId!==r.id?`stale`:r.reset||r.next<r.start?`reset`:t.direction===`tail`?n.hasLoadedOnce?`stale`:`seed`:t.direction===`earlier`?n.firstOffset===t.endingAt?r.next===t.endingAt?`prepend`:`reset`:`stale`:n.nextOffset===t.after?r.start===t.after?`append`:`reset`:`stale`}function JO(e){return e.hasSelectionChanged||e.isRenderedTraceStale||!e.hasRenderedOnce}function YO(e,t,n){return e!==0||t?null:n?.startedAt??null}function XO(e,t){return ZO(e,t)?e.filter(e=>e!==t):[...e,t]}function ZO(e,t){return e.includes(t)}function QO(e){return e?`No trace has been recorded for ${e.label}.`:`No sessions are available.`}var $O=1e4,ek=null,tk=null,nk=null,rk=null,ik=[],ak=!1,ok=mc(),sk=null,ck=null,lk=[],uk=null,dk=null,J=null,fk=null,pk=!1,mk=null;function hk(){return!!ek&&!vr(ek)}function gk(){return lk.find(e=>e.id===uk)??null}function _k(){fk&&=(clearTimeout(fk.timeoutHandle),null)}function vk(){fk=null,mk=`The trace did not load within ${Math.round($O/1e3)} s.`,Hk()}function yk(e){_k(),pk=!1,mk=null,uk=e,J=e?{sessionId:e,grouping:kO(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,ak=!0}function bk(e){let t=UO(lk,dk,uk,e);return dk&&t===dk&&(dk=null),t!==uk&&(yk(t),!0)}function xk(e){if(!sk)return;let t=e.endingAt===void 0?{type:`session-trace`,id:e.id,after:e.after}:{type:`session-trace`,id:e.id,endingAt:e.endingAt};sk(t)?fk={request:e,timeoutHandle:setTimeout(vk,$O)}:(mk=G,Uk())}function Sk(e=!1){if(!sk)return;let t=WO({selectedSessionId:uk,isPanelVisible:e||hk(),hasPendingRequest:!!fk,hasLoadedOnce:J?.hasLoadedOnce??!1,nextOffset:J?.nextOffset??0});t&&xk(t)}function Ck(){return{selectedSessionId:uk,hasPendingRequest:!!fk,hasLoadedOnce:J?.hasLoadedOnce??!1,hasDroppedEarliestRows:J?.hasDroppedEarliestRows??!1,firstOffset:J?.firstOffset??0,residentRowCount:J?LO(J.grouping):0}}function wk(){if(!sk)return;let e=KO(Ck());e&&xk(e)}function Tk(e){lk.some(t=>t.id===e)&&e!==uk&&(dk=null,yk(e),Sk(),Hk())}function Ek(){let e=M(`label`,`trace-session-field`),t=M(`span`,`trace-session-label`,`Session`),n=M(`select`,`trace-session-select`);n.disabled=lk.length===0;for(let e of lk){let t=M(`option`,null,e.label);t.value=e.id,t.selected=e.id===uk,n.append(t)}return n.addEventListener(`change`,()=>Tk(n.value)),e.append(t,n),e}function Dk(e){e.toggleAttribute(`data-hidden`,ZO(ok,e.dataset.kind??``))}function Ok(){if(nk)for(let e of nk.querySelectorAll(`.trace-row`))Dk(e)}function kk(e){if(nk)for(let t of nk.querySelectorAll(`details`))t.open=e}function Ak(){let e=M(`div`,`trace-filters`);for(let t of yO){let n=M(`button`,`trace-filter`,t.label);n.type=`button`;let r=()=>{n.setAttribute(`aria-pressed`,String(!ZO(ok,t.kind)))};r(),n.addEventListener(`click`,()=>{ok=XO(ok,t.kind),hc(ok),r(),Ok()}),e.append(n)}for(let[t,n]of[[`Expand all`,!0],[`Collapse all`,!1]]){let r=M(`button`,`trace-expand-control`,t);r.type=`button`,r.addEventListener(`click`,()=>{kk(n)}),e.append(r)}return e}function jk(){let e=hr(`trace`,`Session trace`,`Bodies load from the local trace file only when requested.`),t=M(`div`,`trace-controls`);t.append(Ek());let n=J?.filePath??``,r=M(`code`,`trace-path`,n);r.title=n,t.append(r);let i=J?YO(J.firstOffset,J.hasDroppedEarliestRows,J.grouping.turns[0]):null;if(i!==null&&t.append(M(`span`,`trace-session-start`,`Started ${new Date(i).toLocaleString()}`)),e.append(t,Ak()),!mk)return e;let a=Od(`trace-status`);return a.show(`error`,mk),e.append(a.element),e}function Mk(e){let t=M(`div`,`trace-copy-wrap`),n=M(`button`,`trace-copy`,`Copy`);n.type=`button`;let r=M(`span`,`trace-copy-status`);return r.setAttribute(`role`,`status`),n.addEventListener(`click`,()=>{let t=yr(e);t?(t.then(()=>{r.textContent=`Copied`}).catch(()=>{r.textContent=`Copy failed`}),setTimeout(()=>{r.textContent=``},1600)):r.textContent=`Copy failed`}),t.append(n,r),t}function Nk(){let e=M(`div`,`trace-earlier-wrap`),t=M(`button`,`trace-load-earlier`,`Load earlier`);return t.type=`button`,t.addEventListener(`click`,()=>{wk()}),e.append(t),e}function Pk(e,t,n=``){let r=M(`details`,`trace-row${n?` ${n}`:``}`);r.dataset.kind=e.kind,r.dataset.tone=e.tone,Dk(r);let i=M(`summary`,`trace-row-summary`);i.append(M(`span`,`trace-offset`,Ql(t,e.record.ts)),M(`span`,`trace-kind`,e.tag),M(`span`,`trace-row-label`,e.text));for(let t of e.badges){let e=M(`span`,`trace-badge`,t);e.dataset.badge=t,i.append(e)}let a=M(`div`,`trace-row-body`);r.append(i,a);let o=!1;return r.addEventListener(`toggle`,()=>{if(!r.open||o)return;o=!0;let t=_O(e.record);a.append(Mk(t),M(`pre`,`trace-row-pre`,t))}),r}function Fk(e){return M(`span`,`trace-turn-metrics`,jO(e))}function Ik(e,t){e&&t&&(t.textContent=jO(e))}function Lk(e,t){let n=e.children,r=Math.min(t.rows.length,n.length);for(let e=0;e<r;e+=1){let r=n[e]?.querySelector(`.trace-offset`);r&&(r.textContent=Ql(t.startedAt,t.rows[e].record.ts))}}function Rk(e,t,n){let r=Pk(t,e.startedAt,`trace-turn-head`);return P(r,`.trace-row-summary`).append(n),r}function zk(e){let t=M(`section`,`trace-turn`),n=Fk(e);if(e.head&&t.append(Rk(e,e.head,n)),!e.head){let e=M(`h2`,`trace-leading-title`);e.append(M(`span`,`trace-leading-label`,`Before first prompt`),n),t.append(e)}let r=M(`div`,`trace-rows`);for(let t of e.rows)r.append(Pk(t,e.startedAt));return e.hasTrimmedRows&&t.append(M(`p`,`trace-trimmed`,`Earlier rows trimmed`)),t.append(r),{section:t,rowsElement:r,metricsElement:n}}function Bk(e){return e?fk?.request.id===e.id&&!J?.hasLoadedOnce?`Loading trace.`:QO(e):QO(null)}function Vk(){if(!ek)return;let e=M(`div`,`trace-content`);tk=jk(),e.append(tk),nk=null,rk=null,ik=[];let t=gk(),n=J?.grouping.turns??[];if(!t||n.length===0){e.append(M(`p`,`trace-empty`,Bk(t))),ek.replaceChildren(e),ak=!1;return}GO(Ck())&&(rk=Nk(),e.append(rk));let r=M(`div`,`trace-turns`);for(let e of n){let t=zk(e);ik.push(t),r.append(t.section)}nk=r,Ok(),e.append(r),ek.replaceChildren(e),ak=!1}function Hk(){ek&&(hk()?Vk():ak=!0)}function Uk(){if(!tk||!hk())return;let e=jk();tk.replaceWith(e),tk=e}function Wk(e){if(!nk)return;let t=J?.grouping.turns[e.turnIndex];if(!t)return;if(e.isNewTurn){let e=zk(t);ik.push(e),nk.append(e.section);return}let n=ik[e.turnIndex];if(n){for(let r of e.rows)n.rowsElement.append(Pk(r,t.startedAt));Ik(t,n.metricsElement)}}function Gk(e){let t=e.parentElement;t&&!t.querySelector(`.trace-trimmed`)&&t.insertBefore(M(`p`,`trace-trimmed`,`Earlier rows trimmed`),e)}function Kk(){GO(Ck())?!rk&&nk?.parentElement&&(rk=Nk(),nk.parentElement.insertBefore(rk,nk)):(rk?.remove(),rk=null)}function qk(){if(!J)return;let e=VO(J.grouping);if(!(e.droppedTurnCount>0||e.droppedRowCount>0)){Kk();return}let t=!J.hasDroppedEarliestRows;if(J.hasDroppedEarliestRows=!0,ik=ik.slice(e.droppedTurnCount),nk)for(let t=0;t<e.droppedTurnCount;t+=1)nk.firstElementChild?.remove();let n=ik[0];if(n&&e.droppedRowCount>0){for(let t=0;t<e.droppedRowCount;t+=1)n.rowsElement.firstElementChild?.remove();Gk(n.rowsElement),Ik(J.grouping.turns[0],n.metricsElement)}t&&Uk(),Kk()}function Jk(e){if(!J)return;let t=PO(J.grouping,e);if(hk()&&!ak&&nk){for(let e of t)Wk(e);qk()}else nk=null,qk(),hk()?Vk():ak=!0}function Yk(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||!Array.isArray(t.records)||typeof t.next!=`number`||typeof t.start!=`number`?null:{id:t.id,records:t.records,start:t.start,next:t.next,reset:t.reset===!0,path:typeof t.path==`string`?t.path:``}}function Xk(){pk&&!fk&&(pk=!1,Sk())}function Zk(e){if(!nk)return;let t=ik[0]??null,n=t?.rowsElement.parentElement??null,r=J?.grouping.turns[e.newTurns.length]??null;if((e.mergedHead||e.mergedRows.length>0)&&t&&n&&r){let i=t.rowsElement;if(e.mergedHead){n.querySelector(`.trace-leading-title`)?.remove();let a=Fk(r),o=Rk(r,e.mergedHead,a);n.insertBefore(o,i),t.metricsElement=a}e.mergedHead||Ik(r,t.metricsElement);let a=document.createDocumentFragment();for(let t of e.mergedRows)a.append(Pk(t,r.startedAt));i.prepend(a),Lk(i,r)}let i=document.createDocumentFragment(),a=[];for(let t of e.newTurns){let e=zk(t);a.push(e),i.append(e.section)}nk.prepend(i),ik.unshift(...a)}function Qk(e){if(!J)return;let t=FO(J.grouping,e),n=hk()&&!ak&&!!nk&&!t.needsRerender,r=ek?.parentElement??null,i=r?.scrollHeight??0,a=r?.scrollTop??0;n&&Zk(t),qk(),n||Hk(),n&&Uk(),r&&(r.scrollTop=a+r.scrollHeight-i)}function $k(e){ek||(ek=M(`div`,`trace-panel`),e.append(ek),Vk())}function eA(e){sk=e}function tA(e){ck=e}function nA(e){dk=e,ck?.()}function rA(e){lk=HO(e);let t=bk(hk());t&&Sk(),(t||!tk)&&Hk(),!t&&tk&&Uk()}function iA(){if(!ek)return;let e=bk(!0);Sk(!0),JO({hasSelectionChanged:e,isRenderedTraceStale:ak,hasRenderedOnce:!!tk})&&Vk()}function aA(e){let t=Yk(e);if(!t)return;let n=qO({pendingRequest:fk?.request??null,resident:J?{sessionId:J.sessionId,firstOffset:J.firstOffset,nextOffset:J.nextOffset,hasLoadedOnce:J.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});n===`ignore`?Xk():(_k(),mk&&(mk=null,Uk()),n===`stale`?Xk():n===`reset`?(yk(t.id),J&&(J.filePath=t.path),Sk(),Hk(),Xk()):J&&(J.filePath=t.path,n===`prepend`?(J.firstOffset=t.start,Qk(t.records),Xk()):(n===`seed`&&(J.hasLoadedOnce=!0,J.firstOffset=t.start),J.nextOffset=t.next,Jk(t.records),Xk())))}function oA(e){let t=e?.id;typeof t==`string`&&t===uk&&hk()&&(fk?pk=!0:Sk())}function sA(e){let t=e?.id;if(typeof t!=`string`||fk?.request.id!==t)return!1;_k(),pk=!1;let n=e?.message;return mk=typeof n==`string`&&n?n:`The trace could not be read.`,Hk(),!0}function cA(e){_k(),pk=!1,mk=e?null:G,e?(Uk(),Sk()):Hk()}var lA=`Estimated list prices, not a bill.`,uA=`Enable in Settings.`,dA=Object.freeze([{value:`7`,label:`Last 7 days`,days:7},{value:`30`,label:`Last 30 days`,days:30},{value:`90`,label:`Last 90 days`,days:90},{value:`all`,label:`All retained`,days:null}]),fA=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],pA=/^(\d{4})-(\d{2})-(\d{2})$/,mA=new Set([`day`,`model`,`label`]),hA=new Set([`model`,`label`]);function gA(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function _A(e){return e.includes(`.`)?e.replace(/0+$/,``).replace(/\.$/,``):e}function vA(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e);return`${t<0?`-`:``}${gA(String(Math.abs(t)))}`}function yA(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.abs(e);if(t===0)return`$0.00`;let n=e<0?`-`:``;if(t<1e-4)return e<0?`above -$0.0001`:`<$0.0001`;if(t<.01)return`${n}$${t.toFixed(4)}`;let[r,i]=t.toFixed(2).split(`.`);return`${n}$${gA(r)}.${i}`}function bA(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=e<0?`-`:``,n=Math.abs(e);if(n<1e3){let e=Math.round(n);return`${e===0?``:t}${e}`}return n<999950?`${t}${_A((n/1e3).toFixed(1))}k`:n<999995e3?`${t}${_A((n/1e6).toFixed(2))}M`:`${t}${_A((n/1e9).toFixed(2))}B`}function xA(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:e>0&&e<.1?`<0.1%`:`${_A(e.toFixed(1))}%`}function SA(e){let t=Number(e?.costUSD);return Number.isFinite(t)&&t>0?`costUSD`:`tokens`}function CA(e){return e===`costUSD`?`share of cost`:`share of tokens`}function wA(e,t){let n=Number(e),r=Number(t);return!Number.isFinite(n)||!Number.isFinite(r)||r<=0?null:n/r*100}function TA(e){let t=pA.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=fA[Number(t[2])-1];return n?`${n} ${Number(t[3])}`:String(e)}function EA(e){let t=DA(e);return t.length===0?``:t.length===1?TA(t[0]):`${TA(t[0])} to ${TA(t[t.length-1])}`}function DA(e){return(Array.isArray(e)?e:[]).map(e=>typeof e==`string`?e:e?.day).map(e=>String(e??``)).filter(e=>pA.test(e)).sort()}function OA(e){let t=Number(e?.ts);return!Number.isFinite(t)||t<=0?``:kA(t,typeof e?.tz==`string`&&e.tz?e.tz:null)}function kA(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`};t&&(n.timeZone=t);let r=AA(e,n);return pA.test(r)?r:AA(e,{year:`numeric`,month:`2-digit`,day:`2-digit`})}function AA(e,t){try{return new Intl.DateTimeFormat(`en-CA`,t).format(new Date(e))}catch{return``}}function jA(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?`-`:Sl(Math.round(e)*60,{smallestUnit:`m`,dropsZeroRemainder:!0})}function MA(e){let t=Number(e);if(!Number.isFinite(t)||t<=0)return`-`;let n=new Date(t),r=fA[n.getMonth()];return r?`${r} ${n.getDate()} ${El(n)}`:`-`}function NA(e){if(!e||typeof e!=`object`)return[];let t=[];if(Number.isFinite(e.tokensPerMinute)){let n=Number.isFinite(e.tokensPerMinuteExCache)?`${bA(e.tokensPerMinuteExCache)} excluding cache`:``;t.push({label:`tokens per min`,value:bA(e.tokensPerMinute),sub:n})}return Number.isFinite(e.costPerHour)&&t.push({label:`cost per hour`,value:yA(e.costPerHour),sub:``}),t}function PA(e){if(!e||typeof e!=`object`)return``;let t=[];Number.isFinite(e.projectedTokens)&&t.push(`${bA(e.projectedTokens)} tokens`),Number.isFinite(e.projectedCostUSD)&&t.push(yA(e.projectedCostUSD));let n=Number.isFinite(e.remainingMinutes)?`${jA(e.remainingMinutes)} left in this block`:``;if(t.length===0)return n;let r=`-> ${t.join(`, `)} by block end`;return n?`${r}, ${n}`:r}function FA(e,t=Date.now()){let n=Number(e?.startTs),r=Number(e?.endTs);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)return null;let i=(r-n)/6e4,a=Math.min(Math.max((t-n)/6e4,0),i);return{totalMinutes:i,elapsedMinutes:a,remainingMinutes:Math.max(i-a,0),pct:Math.round(a/i*100)}}function IA(e){return typeof e!=`number`||!Number.isFinite(e)?`ok`:e>=100?`crit`:e>=80?`warn`:`ok`}function LA(e){let t=W(e?.max,null);return t===null||t<=0?null:t}function RA(e){let t=LA(e),n=W(e?.pct,null);return t===null||n===null?null:n*100}function zA(e,t){let n=LA(t),r=W(e?.projectedTokens,null);return n===null||r===null?null:r/n*100}function BA(e){let t=RA(e);return t===null?``:`${Math.round(t)}% of ${bA(e?.max)} tokens, the largest completed block seen`}function VA(e,t){let n=zA(e,t);return n===null?``:n>=100?`On this burn rate the block ends past that reference, at ${Math.round(n)}% of it.`:`On this burn rate the block ends at ${Math.round(n)}% of that reference.`}var HA=Object.freeze([{key:`input`,label:`input`},{key:`output`,label:`output`},{key:`cacheCreate`,label:`cache write`},{key:`cacheRead`,label:`cache read`}]);function UA(e){let t=HA.map(t=>{let n=Number(e?.[t.key]);return{spec:t,tokens:Number.isFinite(n)&&n>0?n:0}}),n=t.reduce((e,t)=>e+t.tokens,0);return n<=0?[]:t.map(e=>{let t=wA(e.tokens,n)??0,r=bA(e.tokens);return{key:e.spec.key,label:e.spec.label,value:r,pct:t,title:`${e.spec.label} ${r}, ${xA(t)}`}})}var WA=Object.freeze({interactive:`Interactive`,"pr-review":`PR review`,"team-review":`PR reviews`,posthog:`PostHog`,"my-prs":`Keep mergeable`,workflows:`Workflows`,"change-map":`Change map`,visions:`Visions`,benchmark:`Benchmarks`,"agent-spawn":`Agent API`,"task-title":`Task titles`,other:`Other`}),GA=`Sessions spawned by Glimmervoid; terminal sessions count as other`,KA=`Claude sessions Glimmervoid spawned for its own work; plan share is estimated pro rata by cost`;function qA(e){let t=U(e,``);return t?WA[t]||t:WA.other}function JA(e){let t=e?.byLane;return Array.isArray(t)?t.filter(e=>e&&typeof e.lane==`string`):[]}function YA(e){if(typeof e!=`string`)return!1;let t=e.trim();return t!==``&&t!==`interactive`&&t!==`other`}function XA(e){return JA(e).some(e=>YA(e.lane))}var ZA=Object.freeze({fiveHour:`This 5 hour block`,sevenDay:`7 day window`});function QA(e,t,n){let r=Xj(e,t);return!r||r.resetsAtMs!==null&&r.resetsAtMs<=n?null:r.pct}function $A(e,t,n,r){if(!Array.isArray(t))return null;let i=t.filter(e=>e&&typeof e.lane==`string`),a=i.reduce((e,t)=>e+W(t.costUSD,0),0),o=i.reduce((e,t)=>e+W(t.tokens,0),0),s=i.filter(e=>YA(e.lane)).map(e=>({lane:String(e.lane),label:qA(e.lane),tokens:W(e.tokens,0),costUSD:W(e.costUSD,0)})),c=s.reduce((e,t)=>e+t.costUSD,0),l=s.reduce((e,t)=>e+t.tokens,0),u=a>0?wA(c,a):wA(l,o),d=QA(n,e,r),f=u===null||d===null?null:u/100*d;return{key:e,label:ZA[e],tokens:l,costUSD:c,sharePct:u,planPct:f,lanes:s}}function ej(e,t,n=Date.now()){let r=e?.planWindowLanes;return!r||typeof r!=`object`?[]:Yj.map(e=>$A(e.key,r[e.key],t,n)).filter(e=>e!==null)}function tj(e){return e.planPct===null?``:`about ${xA(e.planPct)} of plan`}function nj(e){return e.lanes.filter(e=>e.costUSD>0||e.tokens>0).map(e=>`${e.label} ${e.costUSD>0?yA(e.costUSD):bA(e.tokens)}`).join(`, `)}var rj=`team-review`;function ij(e){if(!Array.isArray(e?.byLane))return null;let t=JA(e).find(e=>e.lane===rj),n=W(t?.costUSD,0),r=W(t?.tokens,0),i=SA(e?.totals),a=wA(i===`costUSD`?n:r,e?.totals?.[i]),o=a===null?``:`${xA(a)} of range ${i===`costUSD`?`cost`:`tokens`}`,s=[yA(n),o,aj(t?.sessions)].filter(Boolean).join(`, `);return{label:qA(rj),value:bA(r),sub:s}}function aj(e){let t=W(e,null);return t===null||t<=0?``:`${vA(t)} ${t===1?`session`:`sessions`}`}function oj(e){let t=e?.rtk;return!t||typeof t!=`object`||t.available!==!0?null:t}function sj(e){let t=e?.cache;return!t||typeof t!=`object`?null:t}function cj(e){return oj(e)!==null||sj(e)!==null}function lj(e){let t=oj(e);if(!t)return null;let n=W(t.commands,0),r=n===1?`command`:`commands`;return{value:`${bA(W(t.savedTokens,0))} tokens`,sub:`${xA(W(t.savingsPct,0))} avg across ${vA(n)} ${r}`}}function uj(e){let t=sj(e);if(!t)return null;let n=bA(W(t.cacheReadTokens,0)),r=(Array.isArray(t.unpricedModels)?t.unpricedModels:[]).filter(e=>e),i=`${n} cache read tokens`;if(r.length===0)return{value:yA(W(t.savedUSD,0)),sub:i};let a=r.length===1?`model`:`models`;return{value:yA(W(t.savedUSD,0)),sub:`${i}, a floor (${r.length} unpriced ${a})`}}function dj(e){let t=e?.budget?.rows;return Array.isArray(t)?t.filter(e=>e&&W(e.budgetUsd,null)!==null):[]}function fj(e){return e===`monthly`?`this month`:`today`}function pj(e){return`${yA(W(e?.spentUsd,0))} of ${yA(W(e?.budgetUsd,0))}`}function mj(e){let t=W(e?.pct,null);return t===null?0:t}function hj(e){return`${fj(e?.scope)} spend against budget`}var gj=Object.freeze([{value:`day`,label:`Day`},{value:`week`,label:`Week`},{value:`month`,label:`Month`}]);function _j(e){let t=pA.exec(String(e??``));return t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12):null}function vj(e){let t=_j(e);if(!t)return``;let n=(t.getDay()+6)%7;return t.setDate(t.getDate()-n),Tl(t)}function yj(e){let t=pA.exec(String(e??``));return t?`${t[1]}-${t[2]}`:``}function bj(e){return{key:e,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0,days:0,sources:new Set,vendorSet:new Set,modelByName:new Map}}function xj(e,t){e.tokens+=W(t?.tokens,0),e.costUSD+=W(t?.costUSD,0),e.input+=W(t?.input,0),e.output+=W(t?.output,0),e.cacheCreate+=W(t?.cacheCreate,0),e.cacheRead+=W(t?.cacheRead,0),e.days+=1,e.sources.add(t?.source===`history`?`history`:`live`);let n=Array.isArray(t?.vendors)?t.vendors:[];for(let t of n)e.vendorSet.add(t);let r=t?.models||[];for(let t of r){t?.vendor&&e.vendorSet.add(t.vendor);let n=SM(t),r=e.modelByName.get(n)||{key:n,model:t?.model??n,vendor:t?.vendor,tokens:0,costUSD:0,input:0,output:0,cacheCreate:0,cacheRead:0};r.tokens+=W(t?.tokens,0),r.costUSD+=W(t?.costUSD,0),r.input+=W(t?.input,0),r.output+=W(t?.output,0),r.cacheCreate+=W(t?.cacheCreate,0),r.cacheRead+=W(t?.cacheRead,0),e.modelByName.set(n,r)}}function Sj(e){let{modelByName:t,sources:n,vendorSet:r,...i}=e,a={...i};return a.day=e.key,a.models=Array.from(t.values()).sort((e,t)=>t.tokens-e.tokens),a.source=n.has(`live`)?`live`:`history`,a.vendors=Array.from(r).sort(),a}function Cj(e,t){let n=new Map,r=Array.isArray(e)?e:[];for(let e of r){let r=t(e?.day);if(!r)continue;let i=n.get(r)||bj(r);xj(i,e),n.set(r,i)}return Array.from(n.values()).map(Sj)}function wj(e){return Cj(e,vj)}function Tj(e){return Cj(e,yj)}function Ej(e,t){return t===`week`?wj(e):t===`month`?Tj(e):Array.isArray(e)?[...e]:[]}var Dj=/^(\d{4})-(\d{2})$/;function Oj(e,t){if(t===`month`){let t=Dj.exec(String(e??``));if(!t)return String(e??``)||`-`;let n=fA[Number(t[2])-1];return n?`${n} ${t[1]}`:String(e)}if(t===`week`){let t=TA(e);return t===`-`?t:`week of ${t}`}return TA(e)}function kj(e){return(Array.isArray(e)?e:[]).some(e=>e?.source===`history`)?`older days from local history`:``}var Aj=Object.freeze([.05,.25,.5,.75]),jj=Object.freeze([`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`]);function Mj(e,t){let n=W(e,0),r=W(t,0);if(n<=0||r<=0)return 0;let i=n/r,a=1;for(let e=0;e<Aj.length;e+=1)i>=Aj[e]&&(a=e+1);return a}function Nj(e,{weeks:t=16,today:n=new Date}={}){let r=(Array.isArray(e)?e:[]).filter(e=>pA.test(String(e?.day??``))),i=new Map(r.map(e=>[String(e.day),e])),a=n instanceof Date?n:new Date(n),o=Number.isFinite(a.getTime())?a:new Date,s=typeof n==`string`&&pA.test(n)?n:Tl(o),c=_j(vj(s));if(!c)return{cells:[],max:0,weeks:0};let l=new Date(c.getFullYear(),c.getMonth(),c.getDate()-(t-1)*7,12),u=Tl(l),d=[],f=0,p=null;for(let e of r){let t=String(e.day);(p===null||t<p)&&(p=t),!(t<u||t>s)&&(f=Math.max(f,W(e.tokens,0)))}for(let e=0;e<t;e+=1)for(let t=0;t<7;t+=1){let n=Tl(new Date(l.getFullYear(),l.getMonth(),l.getDate()+e*7+t,12)),r=i.get(n)||null,a=n>s,o=p!==null&&n<p;d.push({day:n,week:e,weekday:t,tokens:W(r?.tokens,0),costUSD:W(r?.costUSD,0),source:r?.source===`history`?`history`:r?`live`:null,noData:a||o||!r&&p===null,tone:Mj(r?.tokens,f)})}return{cells:d,max:f,weeks:t}}function Pj(e){let t=TA(e?.day);if(e?.noData)return`${t}: no data`;let n=W(e?.tokens,0);return n<=0?`${t}: no usage`:`${t}: ${bA(n)} tokens, ${yA(W(e?.costUSD,0))}`}function Fj(e){if(!e)return``;let t=W(e.baselineDays,null),n=t===null?`recent`:`${Math.round(t)} day`;return`Today is ${Bj(e.ratio)} the ${n} average: ${yA(e.todayUsd)} against ${yA(e.baselineUsd)}.`}function Ij(e){return e?`This block is burning ${Bj(e.ratio)} the usual rate: ${bA(e.current)} tokens per minute against ${bA(e.baseline)}.`:``}function Lj(e){return[Fj(e?.daily),Ij(e?.burn)].filter(Boolean).join(` `)}function Rj(e){return e?.daily||e?.burn?`warn`:`ok`}function zj(e){return!!(e?.daily||e?.burn)}function Bj(e){let t=W(e,null);return t===null?`-`:`${_A(t.toFixed(1))}x`}var Vj=Object.freeze({claude:`Claude`,codex:`Codex`,grok:`Grok`});function Hj(e){let t=U(e,``);return t?Vj[t]||t:Vj.claude}function Uj(e,t){return Gj(t)?Hj(e?.vendor):``}function Wj(e){let t=e?.byVendor;return!t||typeof t!=`object`?[]:Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`).sort((e,n)=>W(t[n]?.tokens,0)-W(t[e]?.tokens,0)).map(e=>({vendor:e,label:Hj(e),tokens:W(t[e]?.tokens,0),costUSD:W(t[e]?.costUSD,0)}))}function Gj(e){let t=e?.byVendor;if(!t||typeof t!=`object`)return!1;let n=Object.keys(t).filter(e=>t[e]&&typeof t[e]==`object`);return n.length>1||n.length===1&&n[0]!==`claude`}var Kj=`Claude only`;function qj(e){return Gj(e)?Kj:``}var Jj=36e5,Yj=Object.freeze([{key:`fiveHour`,label:`5 hour`},{key:`sevenDay`,label:`7 day`}]);function Xj(e,t){let n=e?.[t];if(!n||typeof n!=`object`)return null;let r=W(n.pct,null),i=W(n.resetsAtMs,null);return r===null&&i===null?null:{pct:r,resetsAtMs:i}}var Zj=Object.freeze([{vendor:`claude`,label:`Claude Code`},{vendor:`codex`,label:`Codex`}]);function Qj(e){return e?.vendor===`codex`?`codex`:`claude`}function $j(e,t){let n=`official, from ${Zj.filter(({vendor:t})=>e.includes(t)).map(({label:e})=>e).join(` and `)}`,r=e.length===1&&e[0]===`claude`?qj(t):``;return r?`${n}, ${r}`:n}function eM(e){return Yj.some(t=>Xj(e,t.key)!==null)}function tM(e){return Xj(e,`fiveHour`)?.pct??null}function nM(e){return e===`estimated`?`estimated from the largest completed block`:``}function rM(e,t=null){let n=tM(t);if(n!==null)return IA(n);let r=IA(RA(e?.tokenLimit));return r===`ok`?IA(zA(e?.activeBlock?.projection,e?.tokenLimit)):r}function iM(e,t=null){let n=[],r=rM(e,t);r!==`ok`&&n.push(`block:${r}`),e?.anomaly?.daily&&n.push(`anomaly:daily`),e?.anomaly?.burn&&n.push(`anomaly:burn`);for(let t of dj(e)){let e=mj(t);if(e<90)continue;let r=typeof t?.scope==`string`&&t.scope?t.scope:`budget`;n.push(`budget:${r}:${e>=100?`over`:`near`}`)}return Ol(n)}function aM(e){let t=W(e?.pct,null);return t===null?`-`:`${xA(t)} used`}function oM(e,t=Date.now()){let n=W(e,null);if(n===null||n<=0)return``;let r=(n-t)/6e4;return r<=0?`resetting now`:`resets in ${jA(r)}`}function sM(e,t=Date.now()){let n=W(e,null);return n===null||n<=0?``:`${Math.max(0,Math.round((t-n)/6e4))}m old`}function cM(e,t=Date.now()){let n=W(e,null);return n===null||n<=0||t-n>Jj}function lM(e,t=Date.now()){if(!cM(e,t))return``;let n=sM(e,t);return n?`showing last-known usage (${n})`:`showing last-known usage`}function uM(e,t=``){let n=e?.source;if(n===`fetched`){let e=U(t,``);return e?`Prices fetched from the public model price table, ${e}.`:`Prices fetched from the public model price table.`}if(n===`cache`){let e=U(t,``);return e?`Prices from the cached public model price table, ${e}.`:`Prices from the cached public model price table.`}return n===`snapshot`?`Prices from the price table bundled with this Glimmervoid build.`:n===`unavailable`?`Model prices could not be loaded, so every cost below counts as zero.`:`Pricing source not reported yet.`}function dM(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function fM(e){let t=(Array.isArray(e)?e:[]).map(e=>String(e)).filter(e=>e);if(t.length===0)return``;let n=t.length===1?`model`:`models`;return`No price for ${t.length} ${n}: ${t.join(`, `)}. Their cost counts as zero here.`}function pM(e){if(Array.isArray(e))return e.length;let t=Number(e);return Number.isFinite(t)?t:null}function mM(e){if(!e||typeof e!=`object`)return``;let t=[],n=pM(e.dirs);if(n!==null&&t.push(`${vA(n)} transcript ${n===1?`directory`:`directories`}`),Number.isFinite(e.files)&&t.push(`${vA(e.files)} files`),Number.isFinite(e.entries)&&t.push(`${vA(e.entries)} entries`),Number.isFinite(e.lastScanMs)&&t.push(`last pass ${vA(e.lastScanMs)}ms`),t.length===0)return``;let r=`Scanned ${t.join(`, `)}.`;return e.partial===!0?`${r} Some files were skipped this pass and will be re-read on the next one.`:r}function hM(e){return U(e?.error,``)}function gM(e){let t=U(e?.warning,``);return t?`Glimmervoid could not read every transcript location: ${t}`:``}function _M(e){return hM(e)!==``}function vM(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return n==null||n===t}function yM(e){let t=String(e??``).trim();if(!t)return``;let n=t.split(/[\\/]+/).filter(e=>e);return n.length===0?t:n[n.length-1]}function bM(e){return typeof e?.id==`string`&&e.id!==``}function xM(e){let t=U(e?.label,``);return bM(e)&&t?t:yM(e?.project)||t||`unknown project`}function SM(e){return U(typeof e==`string`?e:e?.model,`unknown model`)}function CM(e){return String(e?.day??``)}function wM(e,t,n){if(!mA.has(t)){let n=Number(e?.[t]);return Number.isFinite(n)?n:0}return t===`day`?CM(e):n(e)}function TM(e,t,n,r=xM){let i=Array.isArray(e)?[...e]:[],a=n===`asc`?1:-1;return i.sort((e,n)=>{let i=wM(e,t,r),o=wM(n,t,r);if(typeof i==`string`||typeof o==`string`)return a*String(i).localeCompare(String(o));if(i!==o)return a*(i-o);let s=Number(e?.tokens),c=Number(n?.tokens),l=Number.isFinite(s)?s:0,u=Number.isFinite(c)?c:0;return l===u?r(e).localeCompare(r(n)):u-l})}function EM(e){return hA.has(e)?`asc`:`desc`}function DM(e,t){return e?.key===t?{key:t,dir:e.dir===`asc`?`desc`:`asc`}:{key:t,dir:EM(t)}}function OM(e,t){return e?.key===t?e.dir===`asc`?`ascending`:`descending`:`none`}var kM=Object.freeze({key:`lastTs`,dir:`desc`}),AM=Object.freeze({key:`tokens`,dir:`desc`}),jM=Object.freeze({key:`day`,dir:`desc`});function MM(e,t=kM){return TM(e,t.key,t.dir,xM)}function NM(e,t,n=10){if(!Array.isArray(e))return{rows:[],hiddenCount:0};let r=Number.isFinite(n)?Math.max(0,Math.floor(n)):10;return t||e.length<=r?{rows:e,hiddenCount:0}:{rows:e.slice(0,r),hiddenCount:e.length-r}}function PM(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:`${vA(t)} hidden`}function FM(e,t=AM){return TM(e,t.key,t.dir,SM)}function IM(e,t=jM){return TM(e,t.key,t.dir,CM)}function LM(e,t){return(Array.isArray(e)?e:[]).find(e=>String(e?.day??``)===String(t??``))||null}function RM(e,t=8){return(Array.isArray(e)?e:[]).filter(e=>e&&e.isGap!==!0).sort((e,t)=>(Number(t?.startTs)||0)-(Number(e?.startTs)||0)).slice(0,Math.max(0,t)).map(e=>({startTs:Number(e.startTs),tokens:typeof e.tokens==`number`&&Number.isFinite(e.tokens)?e.tokens:0,costUSD:typeof e.costUSD==`number`&&Number.isFinite(e.costUSD)?e.costUSD:0,isActive:e.isActive===!0}))}function zM(e){let t=W(e?.officialCostUSD,null);if(t!==null&&t>0)return{costUSD:t,source:`official`};let n=W(e?.costUSD,null);return n!==null&&n>0?{costUSD:n,source:`estimated`}:{costUSD:null,source:null}}function BM(e){let t=Number(e?.tokens);if(!Number.isFinite(t)||t<=0)return``;let{costUSD:n}=zM(e);return n===null?bA(t):`${bA(t)} ${yA(n)}`}function VM(e){let{source:t}=zM(e);return t===`official`?`Tokens counted from the transcript; cost reported by Claude Code for this conversation`:`Tokens and estimated API list-price cost for this conversation`}function HM(e,t){return t===j.RUNNING?e===`restart-fresh`?{title:`Restart fresh`,message:`This agent is mid-turn. A fresh restart ends this conversation and starts a new one. Restart anyway?`,confirmLabel:`Restart fresh`,danger:!0}:{title:`Restart`,message:`This agent is mid-turn. Restarting interrupts the current turn and keeps this conversation. Restart anyway?`,confirmLabel:`Restart`,danger:!1}:null}function UM(e,t,n){let r=Xn.includes(t)?`force-restart`:`restart`;return e===`restart-fresh`?{type:r,id:n,fresh:!0}:{type:r,id:n}}function WM(e,t,n){let r=()=>n.send(UM(e,n.readState(),t)),i=HM(e,n.readState());i?n.confirm({...i,onConfirm:r}):r()}var GM=`DORMANT`;function KM(e){return e?xl(Date.now()-e,{rounding:`round`,wording:`compact`,suffix:` ago`,justNowBelowSeconds:60}):``}function qM(e,t,n){let r=M(`button`,`resume-item`);r.type=`button`,r.setAttribute(`role`,`option`),e.id===t&&r.classList.add(`resume-item-current`);let i=[e.worktreeName,e.gitBranch?e.gitBranch.replace(/^refs\/heads\//,``):null,KM(e.mtime)].filter(Boolean).join(` · `);return r.innerHTML=`<span class="resume-item-title">${r_(e.title||e.id)}</span><span class="resume-item-meta">${r_(i)}${e.id===t?` · current`:``}</span>`,r.addEventListener(`click`,()=>n(e.id)),r}function JM(e,t={}){let n=(t.currentState||``)===GM,{overlay:r,dialog:i,close:a,actions:o,btnCancel:s}=nf({title:`Resume a conversation`,dialogClass:`dialog resume-dialog`}),c=M(`p`,`dialog-message`,`Pick a Claude conversation from this repo (any worktree) to continue in this card.`),l=M(`div`,`resume-list`);l.setAttribute(`role`,`listbox`),l.setAttribute(`aria-label`,`Resumable conversations`),l.append(M(`div`,`resume-empty`,`Loading conversations...`));let u=M(`button`,`btn-dialog btn-dialog-cancel`,`Start fresh`);u.title=`Clear any resume binding so this card starts a new conversation`,o.prepend(u);let d=Od(`dialog-error`);i.append(c,l,d.element,o);async function f(t){if(i.dataset.applying!==void 0)return;i.dataset.applying=``;let r=await jd(`resume-conversation`,{id:e,conversationId:t||``},d);if(delete i.dataset.applying,!r)return;if(r.type!==`resume-conversation-ack`||!r.ok){d.show(`error`,r.type===`error`?r.message:`The conversation was not changed.`);return}a();let o=F.get(e);t&&o&&(n?__(o,{type:`start-session`,id:e}):g_(o).show(`ok`,`Conversation will resume on this session's next restart.`))}s.addEventListener(`click`,a),u.addEventListener(`click`,()=>{f(null)}),requestAnimationFrame(()=>s.focus()),_d(`list-conversations`,{id:e},{timeoutMs:q}).then(e=>{if(!r.isConnected)return;let t=e.type===`conversations`?e.conversations:[];if(l.innerHTML=``,e.error){l.append(M(`div`,`resume-empty`,`Could not list conversations: ${e.error}`));return}if(t.length===0){l.append(M(`div`,`resume-empty`,`No prior conversations found for this repo.`));return}let n=e.type===`conversations`?e.current??null:null;for(let e of t)l.append(qM(e,n,e=>{f(e)}))}).catch(e=>{r.isConnected&&(l.innerHTML=``,l.append(M(`div`,`resume-empty`,`Could not list conversations: ${Ad(e,q)}`)))})}var YM=e=>e==null?``:String(e),XM=e=>Xn.includes(e),ZM=e=>Zn.includes(e),QM=!1;function $M(e){return QM&&my(e.agent)&&e.card.dataset.ephemeral===void 0}function eN(e){return $M(e)&&e.isConversationViewOn&&e.isBorrowed}function tN(e){e.btnConversationView.classList.toggle(`visible`,$M(e)),e.btnConversationView.setAttribute(`aria-checked`,String(e.isConversationViewOn))}function nN(e){QM=e;for(let t of F.values())!e&&t.face===`conversation`&&t._showTerminalFace?.(),cN(t)}function rN(e){let t=I(e);return!t||!eN(t)?!1:(t.face=`conversation`,t.card.dataset.face=`conversation`,t.termWrap.hidden=!0,t.planFace.hide(),t.conversationFace.show(Cr(e)),cN(t),!0)}function iN(e,t){let n=I(e);if(!n)return;let r=n.isConversationViewOn;n.hasConversationBridge=t.hasConversationBridge,n.conversationApproval=t.conversationApproval,n.isConversationViewOn=t.isConversationViewOn,cN(n),n.conversationFace.refresh(),r!==t.isConversationViewOn&&(t.isConversationViewOn?rN(e):n.face===`conversation`&&n._showTerminalFace?.())}function aN(e){return I(e.id)?.conversationFace.applyTraceResponse(e)===!0}function oN(e){I(e.id)?.conversationFace.applyTraceError(e)}function sN(e){I(e)?.conversationFace.applyTraceChanged(Cr(e))}function cN(e){tN(e);let t=e.currentState,n=XM(t)||ZM(t);e.btnRestart.classList.toggle(`visible`,n),e.btnRestartFresh.classList.toggle(`visible`,n),e.btnResume.classList.toggle(`visible`,e.card.dataset.ephemeral===void 0),e.btnWorkspaceRepos.classList.toggle(`visible`,e.card.dataset.workspace!==void 0),e.btnTrace.classList.toggle(`visible`,S_()),e.btnPlan.classList.toggle(`visible`,yg(e)!==`hidden`),e.btnRemove.classList.add(`visible`)}function lN(e){e.sessionMenu.classList.remove(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`false`)}function uN(e,t){L_(e.taskTitleEl,()=>B_(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),U_(e,t)}),e.nameEl.addEventListener(`click`,()=>{H_(e.nameEl)||Bv(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),U_(e,t))});function n(n){lN(e),e.btnSessionMenu.focus(),WM(n,t,{readState:()=>e.currentState,send:t=>{__(e,t)},confirm:rf})}e.btnRestart.addEventListener(`click`,()=>n(`restart`)),e.btnRestartFresh.addEventListener(`click`,()=>n(`restart-fresh`)),e.btnResume.addEventListener(`click`,()=>{lN(e),JM(t,{currentState:e.currentState})}),e.btnWorkspaceRepos.addEventListener(`click`,()=>{lN(e),uf(t)}),e.btnTrace.addEventListener(`click`,()=>{lN(e),nA(t)}),e.btnDocs.addEventListener(`click`,()=>{lN(e),kh(t)}),e.btnConversationView.addEventListener(`click`,()=>{lN(e),__(e,{type:`set-session-conversation-view`,id:t,isOn:!e.isConversationViewOn})}),e.btnGuardrails.addEventListener(`click`,()=>{lN(e),e.btnSessionMenu.focus();let n=n=>()=>{__(e,{type:`set-session-guardrails`,id:t,isOn:n})};e.card.dataset.guarded===void 0?rf({title:`Restore guardrails`,message:`This session restarts with guardrails on, interrupting any turn in progress.`,confirmLabel:`Restore guardrails`,danger:!1,onConfirm:n(!0)}):rf({title:`Release guardrails`,message:`This session restarts without guardrails, interrupting any turn in progress. It can then read, write and reach anything your account can, including credentials and Glimmervoid itself.`,confirmLabel:`Release guardrails`,danger:!0,onConfirm:n(!1)})}),e.btnPlan.addEventListener(`click`,()=>{let n=yg(e);n!==`hidden`&&(n===`face`?bN(t):location.hash=cp(t))}),e.btnRemove.addEventListener(`click`,()=>{lN(e),Yv(t)}),e.btnSessionMenu.addEventListener(`click`,t=>{t.stopPropagation();for(let[,t]of F)t!==e&&lN(t);let n=e.sessionMenu.classList.toggle(`open`);e.btnSessionMenu.setAttribute(`aria-expanded`,String(n))});function r(t){if(a_(t)){t.preventDefault(),t.stopPropagation();for(let[,t]of F)t!==e&&lN(t);e.sessionMenu.classList.add(`open`),e.btnSessionMenu.setAttribute(`aria-expanded`,`true`),o_([...e.sessionMenu.querySelectorAll(`.popup-menu-item.visible`)],t)}}e.btnSessionMenu.addEventListener(`keydown`,r),e.sessionMenu.addEventListener(`keydown`,r),document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e.sessionMenu.classList.contains(`open`)&&(t.preventDefault(),lN(e),e.btnSessionMenu.focus())},{signal:e.abortController.signal}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;!e.sessionMenu.contains(n)&&n!==e.btnSessionMenu&&lN(e)},{signal:e.abortController.signal}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),X_(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&Z_(e)},{signal:e.abortController.signal})}function dN(e,t,n){let r=I(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&z_(e,r.taskTitle)}}function fN(e){return typeof e==`string`&&F.has(e)}function pN(){return F.size}function mN(e){let t=e||{};t.cursorBlink!=null&&US(t.cursorBlink),t.debugMode!=null&&(b_(t.debugMode),Sw(t.debugMode));for(let[,e]of F)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function hN(){eb(F.values(),nb())}function gN(){let e=Lg(Fg([...F.values()].map(e=>({state:e.currentState}))));document.title=e>0?`(${e}) Glimmervoid`:`Glimmervoid`}function _N(e,t,n,r={}){if(!wr)return;let i=Cr(e),a=YM(n)||j.DORMANT,o=P_(i,YM(t),a,r),s=a===j.DORMANT;wr.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),c.conversationFace.hide(),cN(c),HC(c,i)}function u(){rN(i)||l()}let d=new AbortController,f=fT({signal:d.signal,requestPlan:(e,t,n)=>K({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>K({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:u,sendDecision:(e,t)=>K({type:`plan-decision`,id:e,...t}),reportProblem:e=>qN(i,e)}),p=iw({signal:d.signal,sendControl:e=>K(e),showTerminal:l});return c={term:null,fitAddon:null,webglAddon:null,needsWebGLReload:!1,webglAttachedWithoutLayout:!1,dataWs:null,card:o.card,nameEl:o.nameEl,taskTitleEl:o.taskTitleEl,taskTitle:r.taskTitle??null,taskTitleIsCustom:r.taskTitleIsCustom??!1,path:YM(r.path),ownerId:r.ownerId??null,stateSince:typeof r.stateSince==`number`&&Number.isFinite(r.stateSince)?r.stateSince:Date.now(),sessionMenu:o.sessionMenu,termWrap:o.termWrap,btnDebug:o.btnDebug,btnRestart:o.btnRestart,btnRestartFresh:o.btnRestartFresh,btnSessionMenu:o.btnSessionMenu,btnResume:o.btnResume,btnWorkspaceRepos:o.btnWorkspaceRepos,btnConversationView:o.btnConversationView,btnGuardrails:o.btnGuardrails,btnTrace:o.btnTrace,btnPlan:o.btnPlan,btnDocs:o.btnDocs,btnRemove:o.btnRemove,debugOverlay:null,debugOpen:!1,abortController:d,currentState:a,face:`terminal`,isBorrowed:!1,hasPlan:!1,pendingPromptKind:null,planReviewState:{reviews:[]},planFace:f,conversationFace:p,conversationApproval:null,hasConversationBridge:!1,isConversationViewOn:!1},c._ensureTerminalReady=()=>HC(c,i),c._showTerminalFace=l,c._showPreferredFace=()=>{vN(c)===`plan`?bN(i):rN(i)||l()},c._setBorrowed=e=>{c.isBorrowed=e,cN(c)},o.card.append(f.el,p.el),F.set(i,c),uN(c,i),cN(c),c.btnDocs.classList.toggle(`visible`,gh(i)),a===j.RUNNING&&Ef(c,!0),s||(FC(o.termWrap,c),LC(c,i)),gN(),c}function vN(e){let t=e.planReviewState.reviews.some(e=>e.state===`open`),n=e.planReviewState.reviews.some(Lw);return vg({hasPlan:e.hasPlan,pendingPromptKind:e.pendingPromptKind,hasOpenReview:t,hasApprovedReview:n})}function yN(e){let t=I(e);return!t?.isBorrowed||vN(t)!==`plan`?!1:bN(e)}function bN(e){let t=I(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.conversationFace.hide(),t.planFace.show(Cr(e)),cN(t),!0)}function xN(e,t){let n=I(e);n&&(n.hasPlan=t===!0,cN(n),yN(e))}function SN(e){let t=I(e.id);t&&(t.planReviewState=eT(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),cN(t),yN(e.id))}function CN(e){let t=I(e.id);t&&t.planFace.update({draft:e})}function wN(e){let t=I(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),cN(t))}function TN(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return!1;let t=I(e.id);return t?e.scope===`plan`?(t.planFace.update({requestFailed:!0}),!0):(t.planFace.update({decisionRefused:!0,refusalText:e.message}),!0):!1}function EN(e){for(let[,t]of F)t.planFace.update({isConnected:e})}function DN(e,t){let n=I(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function ON(e,t){let n=I(e);if(!n)return;n.agent=typeof t==`string`?t:null,cN(n);let r=Rd(t);MN(n,`.agent-badge`,`agent`,{on:r!==``,value:r,text:r})}function kN(e,t){let n=I(e);n&&(t?n.card.dataset.worktree=``:delete n.card.dataset.worktree)}function AN(e,t,n){let r=I(e);r&&(jN(r.card,`guarded`,t),jN(r.card,`guardrailsReleased`,n),F_(r.btnGuardrails,r.card))}function jN(e,t,n){n?e.dataset[t]=``:delete e.dataset[t]}function MN(e,t,n,r){let{on:i,value:a=``,text:o,title:s}=r,c=e.card.querySelector(t);if(i)e.card.dataset[n]=a,c&&(o!==void 0&&(c.textContent=o),s!==void 0&&(c.title=s));else{if(delete e.card.dataset[n],!c)return;o!==void 0&&(c.textContent=``),s!==void 0&&c.removeAttribute(`title`)}}function NN(e,t,n=!1){let r=I(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=fr(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function PN(e,t){let n=I(e);if(!n)return;let r=BM(t);MN(n,`.usage-badge`,`usage`,{on:!!r,text:r||``,title:r?VM(t):void 0})}function FN(e,t,n){return t?{on:!0,value:`compacting`,title:`Context compaction in progress`,text:`compacting`}:e?{on:!0,value:YM(e),title:`Waiting on a permission or input prompt`,text:_g(YM(e))}:n?{on:!0,value:`memory`,title:`Held until Glimmervoid has enough free memory to start it`,text:`Waiting for memory`}:{on:!1,title:``,text:``}}function IN(e,t,n=!1,r=!1){let i=I(e);i&&(i.pendingPromptKind=typeof t==`string`?t:null,MN(i,`.prompt-badge`,`prompt`,FN(t,n,r)),i.conversationFace.refresh(),!yN(e)&&(typeof t!=`string`||t===``)&&i.face===`terminal`&&rN(e))}function LN(e){return e?`sleeping until ~${El(new Date(e))}`:`scheduled`}function RN(e,t){let n=I(e);n&&MN(n,`.wakeup-badge`,`wakeup`,{on:!!t,value:t?.kind||`wakeup`,text:LN(t?.at),title:t?.reason?`Scheduled revival: ${t.reason}`:`Scheduled revival pending`})}function zN(e,t){let n=I(e);if(!n)return;let r=Array.isArray(t.findings)?t.findings:[],i=t.filesFixed||0,a=null,o=0;!t.skipped&&t.mode===`fix`&&i>0&&(a=`fixed`,o=i),!t.skipped&&t.mode===`report`&&r.length>0&&(a=`flagged`,o=new Set(r.map(e=>e.file)).size);let s={};for(let e of r)s[e.rule]=(s[e.rule]||0)+(e.count||0);let c=Object.keys(s).map(e=>`${e}: ${s[e]}`).join(`, `),l=a===`fixed`?`auto-fixed`:`flagged`;MN(n,`.post-turn-badge`,`pt`,{on:!!a,value:a||void 0,text:`${a===`fixed`?`✓`:`⚠`} ${o}`,title:`Post-turn ${l} ${o} file(s)${c?` (${c})`:``}`})}function BN(e,t){t===`pending-review`||t===`parked`||t===`merging`?e.dataset.merge=t:delete e.dataset.merge}function VN(e,t,n=null){let r=I(e),i=YM(t)||`none`;r&&BN(r.card,i),HE(Cr(e),i,YM(n)||null)}function HN(e,t,n=null){let r=I(e),i=YM(t)||`none`;r&&BN(r.card,i),WE(Cr(e),i,YM(n)||null)}function UN(e,t){GE(Cr(e),t)}function WN(e,t){let n=I(e);if(!n)return;let r=YM(t);n.card.dataset.session=r,n.nameEl.textContent=r}function GN(e){let t=I(e);t&&(Z_(t),F.delete(Cr(e)),uT(Cr(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),NC(t,Cr(e)),AS(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),gN())}function KN(e,t,n){if(!t||!e.term)return;let r=n===j.DONE?`Session complete`:`Session failed`,i=n===j.DONE?`\x1B[34m`:`\x1B[31m`;e.term.write(`\r\n\r\n\x1b[2m${i} ${r}\x1b[0m\r\n\r\n\x1b[2m Open the session actions menu and choose Restart to start a new session.\x1b[0m\r\n`)}function qN(e,t){let n=I(e);n?g_(n).show(`error`,t):Nd(t)}function JN(e,t){let n=I(e);if(!n)return;let r=n.card.querySelector(`:scope > .session-failure-reason`);if(!(n.currentState===j.FAILED&&t)){r?.remove();return}let i=r??M(`p`,`session-failure-reason`);i.setAttribute(`role`,`status`),i.textContent=t,r||n.termWrap.before(i)}function YN(e,t){e.term&&(t===j.DONE||t===j.FAILED)&&(e.term.clear(),e.term.reset())}function XN(e){let t=F.get(e);t&&jg({state:t.currentState})&&document.visibilityState===`visible`&&document.hasFocus()&&K({type:`dismiss`,id:e,expectedState:t.currentState})}function ZN(e,t,n){let r=document.activeElement;return Lv({previousState:t,nextState:n,isPhoneLayout:Ky(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}function QN(e,t,n,r=``){let i=I(e);if(!i)return;let a=YM(t),o=i.currentState;i.currentState=a,a!==j.RUNNING&&(i.awaitingBackgroundTasks=!1),i.conversationFace.refresh(),a!==o&&(i.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),Ef(i,a===j.RUNNING)),o===j.DORMANT&&a!==j.DORMANT&&BC(i,Cr(e)),jg({state:a})||Sp(Cr(e)),i.card.dataset.state=a,i.card.toggleAttribute(`data-monitoring`,fr(a,i.awaitingBackgroundTasks)),cN(i),(a===j.WAITING&&o!==j.WAITING||a===j.COMPLETE&&o!==j.COMPLETE)&&!Zv(r)&&Rs()&&Tb(Bs()),ZN(i,o,a)&&K({type:`dismiss`,id:Cr(e),expectedState:j.COMPLETE});let s=a===j.DONE||a===j.FAILED,c=o!==j.DONE&&o!==j.FAILED&&o!==j.INITIALIZING;s&&c&&(i.card.classList.remove(`completion-flash`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.card.classList.add(`completion-flash`),i.card.addEventListener(`animationend`,()=>i.card.classList.remove(`completion-flash`),{once:!0})})}),Rs()&&Tb(Bs())),(a===j.DONE||a===j.FAILED)&&KN(i,c,a),a===j.INITIALIZING&&YN(i,o),gN()}var $N=`(no path)`;function eP(e){if(!e)return $N;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||`(no path)`}function tP(e,t,n){let r=Array.isArray(e)?e:[],i=new Map;for(let e of r){let n=t(e),r=n?String(n):$N,a=i.get(r);a||(a={key:r,label:r===`(no path)`?$N:eP(r),title:r,rows:[]},i.set(r,a)),a.rows.push(e)}if(n)for(let e of n){if(!e)continue;let t=String(e);t===`(no path)`||i.has(t)||i.set(t,{key:t,label:eP(t),title:t,rows:[]})}let a=[...i.values()];return a.sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0,sensitivity:`base`})||e.key.localeCompare(t.key)),{flat:i.size<=1,order:a.map(e=>e.key),groups:a}}function nP(e,t){if(!e||!Array.isArray(e.groups))return[];let n=t||new Set,r=[];if(e.flat){for(let t of e.groups)for(let e of t.rows)r.push(e.id);return r}let i=new Map(e.groups.map(e=>[e.key,e]));for(let t of e.order){if(n.has(t))continue;let e=i.get(t);if(e)for(let t of e.rows)r.push(t.id)}return r}function rP({onAdd:e,onForget:t}){let n=M(`div`,`session-group-header`),r=M(`span`,`session-group-label`),i=M(`span`,`session-group-count`),a=M(`span`,`session-group-rule`);a.setAttribute(`aria-hidden`,`true`);let o=M(`button`,`session-group-add`,`+`);o.type=`button`,o.addEventListener(`click`,()=>e(n.dataset.path,n.dataset.label));let s=M(`button`,`session-group-forget`);return s.type=`button`,s.append(m_(u_)),s.addEventListener(`click`,()=>t(n.dataset.path)),n.append(r,i,a,s,o),{header:n,label:r,count:i,addButton:o,forgetButton:s}}function iP(e,t,n){let{header:r,label:i,count:a,addButton:o,forgetButton:s}=e,c=t.key===$N,l=t.rows.length===0;r.dataset.path=t.key,r.dataset.label=t.label,r.title=t.title,r.toggleAttribute(`data-empty`,l),i.textContent=t.label,a.textContent=String(t.rows.length),a.title=`${t.rows.length} ${t.rows.length===1?`session`:`sessions`}`,o.hidden=c,s.hidden=c||!l,c||(o.title=`Add a session to ${t.label}`,o.setAttribute(`aria-label`,`Add a session to ${t.label}`)),!c&&l&&(s.title=`Remove ${t.label} from the ${n}`,s.setAttribute(`aria-label`,`Remove ${t.label} from the ${n}`))}var aP={waitingCount:0,finishedCount:0,failedCount:0};function oP(e){let t=M(`div`,`attention-banner`);return t.setAttribute(`role`,`status`),e.classList.add(`attention-banner-jump`),t.append(M(`span`,`attention-banner-count`),e),sP(t,aP),t}function sP(e,t){P(e,`.attention-banner-count`).textContent=zg(t),e.toggleAttribute(`data-empty`,!Rg(t)),e.toggleAttribute(`data-jumpable`,Ig(t)>0)}var cP=e=>e.ui.path,lP=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),uP=null,dP=null,fP=null,pP=null,mP=null,hP=null,gP=null,_P=!1,vP=null,yP=!1,bP=new Map,xP=new Map,SP=new Map,CP=new Map,wP=null,TP=``,EP=[],DP=new Set;function OP(){return nP(AP(zP()),DP)}function kP(e){let t=wP;if(wP=e||null,t&&t!==wP){let e=xP.get(t);e&&(e.tabIndex=-1,e.setAttribute(`aria-selected`,`false`))}if(wP){let e=xP.get(wP);e&&(e.tabIndex=0,e.setAttribute(`aria-selected`,`true`))}}function AP(e){return tP(e,cP,Pv(e,cP))}function jP(e){let t=CP.get(e.key),n=SP.get(e.key);return(!t||!n)&&(t=rP({onAdd:Jv,onForget:e=>{Fv(e),GP()}}),n=M(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),CP.set(e.key,t),SP.set(e.key,n)),iP(t,e,`rail`),n.setAttribute(`aria-label`,`${e.label} sessions`),{header:t.header,list:n}}function MP(){return _P}function NP(){return kr.snapshot().focusedSessionId}function PP({rail:e,center:t,resizer:n}){if(uP=e,fP=t,!uP||!fP)return;let r=uP,i=fP;LP(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,Jp(Xp)),dP=oP(Qp(Kp(`next-attention`,Xp)));let a=M(`details`,`rail-status-key`);a.append(M(`summary`,`rail-status-key-summary`,`Status key`),kv()),r.append(dP,a),mP=M(`div`,`focus-empty`),mP.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,hP=mP.querySelector(`.focus-empty-title`),gP=mP.querySelector(`.focus-empty-desc`),pP=M(`div`,`focus-card-slot`),i.append(mP,pP),r.addEventListener(`keydown`,RP)}var FP={minPx:180,maxPx:480},IP=16;function LP(e){e&&uP&&n_({resizer:e,column:uP,widthHost:uP,widthProperty:`--rail-width`,bounds:FP,keyStepPx:IP,getStoredWidth:ec,setStoredWidth:tc})}function RP(e){if(e.key===`Delete`||e.key===`Backspace`){let t=e.target instanceof HTMLElement?e.target:null,n=t?.dataset.id;if(!n||xP.get(n)!==t)return;e.preventDefault(),Yv(n,bP.get(n));return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=Ag(OP(),wP,e.key===`ArrowDown`?1:-1);t!=null&&(e.preventDefault(),kP(t),xP.get(t)?.focus())}function zP(){return wg(Gv(BP))}function BP(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function VP(e){let{row:t,refs:n}=vv(`button`);t.type=`button`,t.dataset.id=e,t.setAttribute(`role`,`option`),t.addEventListener(`click`,()=>HP(e));let{item:r,removeButton:i}=yv(t,()=>Yv(e,bP.get(e)));return r.setAttribute(`role`,`presentation`),i.tabIndex=-1,Object.assign(t,{_refs:n,_row:r})}function HP(e){let t=Hv(e);t&&(eF(e),XP(t,e))}function UP(e,{id:t,ui:n,state:r,name:i}){let a=bP.get(t)||`none`;Cv(e,e._refs,{ui:n,state:r,name:i??``,mergeStatus:a===`none`?``:a}),e.classList.toggle(`focused`,t===NP());let o=t===wP;e.setAttribute(`aria-selected`,String(o)),e.tabIndex=o?0:-1}function WP(e,t){if(!_P)return;let n=e?.card?.dataset.id,r=n?xP.get(n):null;r&&(t===`flag`?r.dataset.activity=e._activity||``:Cf(r._refs?.glyph))}bf(WP),jf(()=>{if(_P)for(let[e,t]of xP){let n=F.get(e);n&&(t._refs.elapsed.textContent=kf(n))}});function GP(){if(!_P)return;let e=uP;if(!e)return;let t=AP(zP()),n=new Set,r=(e,t)=>{let r=e.map(e=>e.id).join(`,`),i=t._lastOrderKey===r&&t.childElementCount===e.length;for(let r of e){let{id:e}=r;n.add(e);let a=xP.get(e);a||(a=VP(e),xP.set(e,a)),UP(a,r),i||t.appendChild(a._row)}t._lastOrderKey=r},i=new Set(t.order),a=t.groups.map(e=>e.key).join(`
164
- `),o=a===TP;TP=a;for(let n of t.groups){let{header:t,list:i}=jP(n);o||e.append(t,i),r(n.rows,i)}for(let[e,t]of[...CP])i.has(e)||(t.header.remove(),SP.get(e)?.remove(),CP.delete(e),SP.delete(e));for(let[e,t]of xP)n.has(e)||(t._row.remove(),xP.delete(e),e===wP&&(wP=null));for(let e of[...bP.keys()])F.has(e)||bP.delete(e);let s=EP;EP=nP(t,DP);let c=NP();if(c&&!F.has(c)){kr.dispatch(`focusSession`,null),wP=null;let e=KP(s,c);if(e){let t=!document.activeElement||document.activeElement===document.body;eF(e),t&&XP(F.get(e),e);return}}tF();let l=NP();if(l){let e=F.get(l);e&&e.card.parentElement!==pP&&QP(e,l)}JP()}function KP(e,t){let n=e.filter(e=>e===t||F.has(e));return n.length<2?EP.find(e=>F.has(e))??null:Ag(n,t,n.indexOf(t)===n.length-1?-1:1)}function qP(){return Pg(zP())}function JP(){dP&&sP(dP,Fg(zP()))}function YP(){if(!_P)return;let e=qP();if(!e.length)return;let t=Eg(e,vP);if(!t)return;vP=t;let n=F.get(t),r=t===NP();Hv(t),eF(t),xP.get(t)?.scrollIntoView({block:`nearest`}),r&&ZP(t),XP(n,t)}function XP(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{_P&&NP()===t&&e.term?.focus()}))}function ZP(e){if(lP?.matches||document.hidden)return;let t=xP.get(e);t?.animate&&t.animate([{transform:`scale(1)`},{transform:`scale(1.045)`,offset:.3},{transform:`scale(1)`}],{duration:360,easing:`cubic-bezier(0.22, 1, 0.36, 1)`});let n=F.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function QP(e,t){pP&&(Mr(e,t,pP,{className:`focus-centered`}),UC(e,t,!0))}function $P(){let e=NP();e&&(jr()===e&&Nr(),kr.dispatch(`focusSession`,null))}function eF(e){_P&&F.has(e)&&(XN(e),e!==NP()&&($P(),kr.dispatch(`focusSession`,e),wP=e,Uv(e),GP()))}function tF(){if(!mP||!hP||!gP)return;let e=NP(),t=!!(e&&F.has(e)),n=F.size>0;mP.hidden=t,gm(mP,!n),hP.hidden=!n,gP.hidden=!n,!t&&n&&(hP.textContent=`No session selected`,gP.textContent=`Select a session from the rail on the left to focus it here.`)}function nF(e,t){bP.set(Cr(e),typeof t==`string`&&t?t:`none`),_P&&GP()}function rF(e){_P&&F.has(e)&&eF(e)}function iF(e){return!_P||!F.has(e)?!1:(eF(e),bN(e))}function aF(e){if(!_P)return;let t=OP()[e-1];t&&HP(t)}function oF(e){if(!_P)return;let t=Ag(OP(),wP,e);t!=null&&(HP(t),xP.get(t)?.scrollIntoView({block:`nearest`}))}window.addEventListener(`focus`,()=>{let e=NP();_P&&e&&XN(e)});function sF(){uP&&(_P=!0,$P(),wP=null,GP(),yP&&qP().length>0?YP():lF())}function cF(e){yP=!0;try{e()}finally{yP=!1}}function lF(){if(!_P||NP())return;let e=Wv();e&&eF(e)}function uF(){_P&&=($P(),wP=null,!1)}var dF=`t-[0-9a-f]{8}`,fF=`No findings. Open a markdown file in a connected editor.`,pF=`No intent yet. The visions proposes one after its first pass.`,mF=`Unowned`,hF=RegExp(`^${dF}$`);function gF(){return{byProject:{},unowned:[]}}function _F(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.text==`string`?t.text:``;if(!n)return null;let r=Number(t.ts),i=Number(t.hits);return{id:typeof t.id==`string`&&hF.test(t.id)?t.id:null,text:n,uris:Array.isArray(t.uris)?t.uris.filter(e=>typeof e==`string`&&e!==``):[],ts:Number.isFinite(r)&&r>0?r:0,hits:Number.isInteger(i)&&i>0?i:1}}function vF(e){if(Array.isArray(e))return e.map(_F).filter(e=>e!==null);let t=_F(e);return t?[t]:[]}function yF(e){let t=e?.intent;if(!t||typeof t!=`object`)return gF();let n=t;if(!(Object.hasOwn(n,`byProject`)||Object.hasOwn(n,`unowned`)||Object.hasOwn(n,`global`)))return{byProject:{},unowned:vF(n)};let r=n.byProject&&typeof n.byProject==`object`?n.byProject:{},i=[];for(let[e,t]of Object.entries(r)){let n=vF(t);n.length!==0&&e&&i.push([e,n])}return{byProject:Object.fromEntries(i),unowned:vF(Object.hasOwn(n,`unowned`)?n.unowned:n.global)}}function bF(e,t){let n=typeof t?.id==`string`?t.id:null;if(!n)return e;let r=e.findIndex(e=>e.id===n);return r<=0?e:[e[r],...e.slice(0,r),...e.slice(r+1)]}function xF(e,t){let n=e||gF(),r=t?.intent;if(!r||typeof r!=`object`)return n;let i=r,a=bF(Array.isArray(i.threads)?vF(i.threads):vF(i),i.active),o=typeof t?.projectId==`string`&&t.projectId?t.projectId:null;if(!o)return{byProject:{...n.byProject},unowned:a};let s={...n.byProject};return a.length===0&&delete s[o],a.length>0&&(s[o]=a),{byProject:s,unowned:n.unowned}}function SF(e,t=null){let n=t&&typeof t.get==`function`?t.get(e):null;return typeof n==`string`&&n?n:e}function CF(e,{key:t,label:n,now:r}){return e.map((e,i)=>({key:`${t}:${e.id||i}`,label:n,text:e.text,hasText:!0,active:i===0,meta:DF(e,r)}))}function wF(e,t=null,n=Date.now()){let r=e||gF(),i=Object.entries(r.byProject||{}).filter(([e,t])=>e&&Array.isArray(t)&&t.length>0).map(([e,n])=>({projectId:e,label:SF(e,t),threads:n})).sort((e,t)=>e.label.localeCompare(t.label)).flatMap(({projectId:e,label:t,threads:r})=>CF(r,{key:e,label:t,now:n})),a=CF(Array.isArray(r.unowned)?r.unowned:[],{key:`unowned`,label:mF,now:n});return i.length+a.length>0?[...a,...i]:[{key:`unowned`,label:mF,text:pF,hasText:!1,active:!1,meta:``}]}function TF(e){return e?.text?`proposed by visions`:``}function EF(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:xl(Number(t)-n,{rounding:`floor`,wording:`spelled`,suffix:` ago`,justNowBelowSeconds:60})}function DF(e,t=Date.now()){let n=TF(e);if(!n)return``;let r=typeof e?.id==`string`&&e.id?`thread ${e.id}, `:``,i=EF(e?.ts,t);return i?`${r}${n}, ${i}`:`${r}${n}`}function OF(e){let t=Number(e?.range?.start?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function kF(e){let t=Number(e?.range?.start?.character);return Number.isFinite(t)?t:0}function AF(e){let t=Number(e?.range?.start?.line);return Number.isFinite(t)?t:0}function jF(e){let t=typeof e==`string`?e:``;if(!t)return``;let n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);if(!r)return t;try{return decodeURIComponent(r)}catch{return r}}function MF(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(Math.floor(e),0):0}function NF(e){let t=MF(e);return t===1?`1 finding`:`${t} findings`}function PF(e){let t=MF(e);return t===1?`1 comment`:`${t} comments`}function FF(e){let t=MF(e?.findings?.length),n=MF(e?.comments?.length),r=typeof e?.hand==`string`&&e.hand?1:0,i=[];return r>0&&i.push(`raised hand`),t>0&&i.push(NF(t)),n>0&&i.push(PF(n)),i.length>0?i.join(`, `):NF(0)}function IF(e){let t=typeof e==`string`?e.trim():``;return t?`Raised hand: ${t}`:``}function LF(e){return(typeof e?.hand==`string`?e.hand.trim():``)||null}function RF(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=LF(t);return i?(n.set(r,i),n):(n.delete(r),n)}function zF(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=typeof e?.hand==`string`?e.hand.trim():``;n&&r&&t.set(n,r)}return t}var BF=`hand`,VF=`unseen`,HF=`
165
- `;function UF(e){let t=2166136261,n=3266489909;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619)>>>0,n=Math.imul(n^i,2246822507)>>>0}return`${t.toString(36).padStart(7,`0`)}${n.toString(36).padStart(7,`0`)}`}function WF(e,t){return UF(JSON.stringify([e,...t]))}function GF(e,t){return WF(`finding`,[e,OF(t),String(t.code??``),String(t.message??``)])}function KF(e,t){return WF(`comment`,[e,ZF(t),String(t.message??``)])}function qF(e){return WF(`fix`,[e.uri,cI(e),e.code,e.message,lI(e)])}function JF(e){return WF(`intent`,[e.key,e.text,e.active])}function YF(e,t,n,r=[],i=null){let a=[...n].map(([e,t])=>WF(`hand`,[e,t])).sort(),o=new Set;for(let r of[...e.keys(),...t.keys(),...n.keys()])o.add(WF(`document`,[r]));for(let[t,n]of e)for(let e of n)o.add(GF(t,e));for(let[e,n]of t)for(let t of n)o.add(KF(e,t));for(let e of r)o.add(qF(e));for(let e of wF(i,null,0))e.hasText&&o.add(JF(e));let s=[...o].sort();return{signature:[...a,...s].join(HF),handEntries:a,contentEntries:s}}function XF(e,t){let n=new Set(t.split(HF));return e.handEntries.some(e=>!n.has(e))?BF:e.contentEntries.some(e=>!n.has(e))?VF:null}function ZF(e){let t=Number(e?.line);return!Number.isFinite(t)||t<1?`L?`:`L${Math.floor(t)}`}function QF(e){return Array.isArray(e?.diagnostics)?e.diagnostics:[]}function $F(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=QF(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function eI(e){return Array.isArray(e?.comments)?e.comments:[]}function tI(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=eI(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function nI(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.diagnostics)?e.diagnostics:[];n&&r.length!==0&&t.set(n,r)}return t}function rI(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.comments)?e.comments:[];n&&r.length!==0&&t.set(n,r)}return t}function iI(e,t=new Map,n=new Map){let r=[],i=new Set([...e.keys(),...t.keys(),...n.keys()]);for(let a of i){let i=e.get(a),o=t.get(a),s=n.get(a)||null,c=Array.isArray(i)?i:[],l=Array.isArray(o)?o:[];(c.length!==0||l.length!==0||s)&&r.push({uri:a,name:jF(a)||a,hand:s,findings:[...c].sort((e,t)=>AF(e)-AF(t)||kF(e)-kF(t)),comments:[...l].sort((e,t)=>(Number(e?.line)||0)-(Number(t?.line)||0))})}return r.sort((e,t)=>aI(e.name,t.name)||aI(e.uri,t.uri)),r}function aI(e,t){return e<t?-1:+(e>t)}var oI=`No fixes yet. Silent fixes appear here once the lane applies or is refused one.`;function sI(e){let t=MF(e);return t===1?`1 fix`:`${t} fixes`}function cI(e){let t=Number(e?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function lI(e){return e?.applied===!0?`applied`:`refused`}function uI(e,{uri:t=``,ts:n=0}={}){if(!e||typeof e!=`object`)return null;let r=e,i=typeof r.message==`string`?r.message.trim():``;if(!i)return null;let a=Number(r.line),o=Number(r.ts??n);return{uri:typeof r.uri==`string`&&r.uri?r.uri:t,code:typeof r.code==`string`?r.code:``,line:Number.isFinite(a)&&a>0?Math.floor(a):0,message:i,applied:r.applied===!0,ts:Number.isFinite(o)&&o>0?o:0}}function dI(e){let t=typeof e?.uri==`string`?e.uri:``,n=Number(e?.ts);return uI(e?.fix,{uri:t,ts:Number.isFinite(n)?n:0})}function fI(e,t,{max:n=20}={}){let r=dI(t);return r?[r,...e].slice(0,Math.max(0,Math.floor(n))):[...e]}function pI(e,{max:t=20}={}){let n=Array.isArray(e?.fixes)?e.fixes:[],r=[];for(let e of n){let t=uI(e);t&&r.push(t)}return r.slice(0,Math.max(0,Math.floor(t)))}var mI=`No activity yet. The ingest lane reports what your sessions and tools are doing.`,hI={terminal:`terminal`,agentLogs:`agent`,git:`git`,fs:`files`,shellHistory:`shell`,editor:`editor`};function gI(e){let t=typeof e==`string`?e:``;return hI[t]||t||`source`}function _I(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:xl(Number(t)-n,_l)}function vI(e){if(!e||typeof e!=`object`)return null;let t=e,n=Number(t.seq);if(!Number.isFinite(n))return null;let r=typeof t.summary==`string`?t.summary.trim():``;if(!r)return null;let i=Number(t.ts),a=t.scope&&typeof t.scope==`object`?t.scope:{};return{seq:Math.floor(n),source:typeof t.source==`string`?t.source:``,kind:typeof t.kind==`string`?t.kind:``,ts:Number.isFinite(i)&&i>0?i:0,summary:r,root:typeof a.root==`string`&&a.root?a.root:null,sessionId:typeof a.sessionId==`string`&&a.sessionId?a.sessionId:null}}function yI(e){let t=Array.isArray(e?.events)?e.events:[],n=[];for(let e of t){let t=vI(e);t&&n.push(t)}return n}function bI(e){let t=Number(e?.overflow);return!Number.isFinite(t)||t<=0?0:Math.floor(t)}function xI(e){let t=MF(e);return t<=0?``:t===1?`1 more event not shown`:`${t} more events not shown`}function SI(e,t){return[...e].sort((e,t)=>t.seq-e.seq).slice(0,Math.max(0,Math.floor(t)))}function CI(e,t,{max:n=100}={}){let r=yI(t);if(r.length===0)return SI(e,n);let i=new Map;for(let t of e)i.set(t.seq,t);for(let e of r)i.set(e.seq,e);return SI([...i.values()],n)}function wI(e,{max:t=100}={}){return SI(yI(e),t)}function TI(e){let t=MF(e);return t===1?`1 event`:`${t} events`}function EI(e){if(!e?.root)return`machine`;let t=e.root.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var DI=new Map,OI=new Map,kI=new Map,AI=gF(),jI=new Map,MI=null,NI=null,PI=null,FI=null,II=null,LI=[],RI=0,zI=null,BI=[],VI=null,HI=YF(DI,OI,kI,BI,AI),UI=Oc(),WI=Al({getAck:()=>UI,setAck:e=>{UI=e,kc(e)},signature:()=>HI.signature,isLooking:()=>!vr(MI)});function GI(){let e=M(`section`,`visions-intent`);e.append(M(`h2`,`visions-intent-title`,`Intent`));let t=M(`div`,`visions-intent-list`);return e.append(t),PI={list:t},e}function KI(e){let t=M(`div`,`visions-intent-item`),n=M(`div`,`visions-intent-head`);n.append(M(`span`,`visions-intent-scope`,e.label),M(`span`,`visions-intent-meta`,e.meta));let r=M(`p`,`visions-intent-text`,e.text);return r.classList.toggle(`visions-intent-none`,!e.hasText),t.classList.toggle(`visions-intent-active`,e.active===!0),t.append(n,r),t}function qI(){PI&&PI.list.replaceChildren(...wF(AI,jI).map(KI))}function JI(e){jI=e instanceof Map?e:new Map,qI()}function YI(e){let t=M(`section`,`visions-doc`),n=M(`div`,`visions-doc-head`),r=M(`h2`,`visions-doc-name`);if(r.textContent=e.name,r.title=e.uri,n.append(r,M(`span`,`visions-doc-count`,FF(e))),t.append(n),e.hand&&t.append(XI(e.hand)),e.findings.length>0){let n=M(`div`,`visions-findings`);for(let t of e.findings)n.append(QI(t));t.append(n)}if(e.comments.length>0){let n=M(`div`,`visions-comments`);for(let t of e.comments)n.append(ZI(t));t.append(n)}return t}function XI(e){let t=M(`div`,`visions-hand`);return t.textContent=IF(e),t}function ZI(e){let t=M(`div`,`visions-comment`),n=M(`div`,`visions-comment-head`);n.append(M(`span`,`visions-comment-chip`,`visions`)),n.append(M(`span`,`visions-comment-line`,ZF(e))),t.append(n);let r=M(`p`,`visions-comment-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function QI(e){let t=M(`div`,`visions-finding`);t.append(M(`span`,`visions-finding-line`,OF(e)));let n=e?.code==null?``:String(e.code);n&&t.append(M(`span`,`visions-finding-code`,n));let r=M(`span`,`visions-finding-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function $I({force:e=!1}={}){if(!NI||!e&&vr(MI))return;NI.textContent=``;let t=iI(DI,OI,kI);if(t.length===0){let e=M(`p`,`visions-empty`,fF);if(II===!1){let t=Dp(`lanes-visions`,`visions-enabled`,`Enable Visions`);e.append(document.createTextNode(` `),t)}NI.append(e)}else for(let e of t)NI.append(YI(e))}function eL(e){II=e?.visions?.enabled===!0,$I()}function tL(){let e=M(`section`,`visions-activity`),t=M(`div`,`visions-activity-head`);t.append(M(`h2`,`visions-activity-title`,`Activity`));let n=M(`span`,`visions-activity-count`);t.append(n),e.append(t);let r=M(`div`,`visions-activity-list`);e.append(r);let i=M(`p`,`visions-activity-overflow`);return e.append(i),zI={count:n,list:r,overflow:i},e}function nL(e,t){let n=M(`div`,`visions-activity-row`);n.append(M(`span`,`visions-activity-source`,gI(e.source))),n.append(M(`span`,`visions-activity-age`,_I(e.ts,t))),n.append(M(`span`,`visions-activity-scope`,EI(e)));let r=M(`span`,`visions-activity-summary`);return r.textContent=e.summary,n.append(r),n}function rL({force:e=!1}={}){if(!zI||!e&&vr(MI))return;let{count:t,list:n,overflow:r}=zI;if(t.textContent=TI(LI.length),n.textContent=``,LI.length===0){n.append(M(`p`,`visions-empty`,mI)),r.textContent=``;return}let i=Date.now();for(let e of LI)n.append(nL(e,i));r.textContent=xI(RI)}function iL(){let e=M(`section`,`visions-fixes`),t=M(`div`,`visions-fixes-head`);t.append(M(`h2`,`visions-fixes-title`,`Fixes`));let n=M(`span`,`visions-fixes-count`);t.append(n),e.append(t);let r=M(`div`,`visions-fixes-list`);return e.append(r),VI={count:n,list:r},e}function aL(e){let t=M(`div`,`visions-fix-row`);t.dataset.applied=e.applied?`yes`:`no`;let n=M(`span`,`visions-fix-file`);n.textContent=jF(e.uri)||e.uri,n.title=e.uri,t.append(n),t.append(M(`span`,`visions-fix-line`,cI(e))),t.append(M(`span`,`visions-fix-outcome`,lI(e))),t.append(M(`span`,`visions-fix-code`,e.code||``));let r=M(`span`,`visions-fix-message`);return r.textContent=e.message,t.append(r),t}function oL({force:e=!1}={}){if(!VI||!e&&vr(MI))return;let{count:t,list:n}=VI;if(t.textContent=sI(BI.length),n.textContent=``,BI.length===0)n.append(M(`p`,`visions-empty`,oI));else for(let e of BI)n.append(aL(e))}function sL(){HI=YF(DI,OI,kI,BI,AI),HI.signature!==``&&WI.refresh(),FI&&FI(XF(HI,UI))}function cL(e){FI=e,sL()}var lL=Od(`visions-connection-status`);function uL(e){e?lL.clear():lL.show(`error`,`${G} What you see below is from before the connection dropped.`)}function dL(e){if(MI)return MI;let t=M(`div`,`visions-content`);t.append(lL.element,GI());let n=M(`div`,`visions-feed`);return t.append(n),t.append(iL()),t.append(tL()),e.appendChild(t),MI=t,NI=n,qI(),$I({force:!0}),oL({force:!0}),rL({force:!0}),t}function fL(){qI(),$I({force:!0}),oL({force:!0}),rL({force:!0})}function pL(){HI.signature!==``&&WI.acknowledge(),sL()}function mL(e){BI=fI(BI,e),oL(),sL()}function hL(e){DI=$F(DI,e),$I(),sL()}function gL(e){OI=tI(OI,e),$I(),sL()}function _L(e){kI=RF(kI,e),$I(),sL()}function vL(e){AI=xF(AI,e),qI(),sL()}function yL(e){LI=CI(LI,e),RI=bI(e),rL(),sL()}function bL(e){LI=wI(e),RI=0,rL(),sL()}function xL(e){DI=nI(e),OI=rI(e),kI=zF(e),AI=yF(e),BI=pI(e),qI(),$I(),oL(),sL()}var SL=i(l(),e());g({glimmervoidId:l().min(1),event:l().min(1),token:l().nullable().optional(),payload:SL}),g({id:l().min(1),name:l().min(1),event:l().min(1),matcher:l().optional(),type:u([`command`,`http`]),command:l().optional(),url:l().optional(),timeout:c().int().positive().optional(),enabled:t(),projects:p(l()).optional()}).passthrough();var CL=`Claude Code hooks injected into every session Glimmervoid spawns.`,wL=`Loading hooks`,TL=`No hooks yet. A hook runs a command, or calls a URL, when a Claude Code event fires in a Glimmervoid session. Start from one of these, or add your own.`,EL=`Start from`,DL=`Filter by name, event or command`,OL=`Nothing matches that filter.`,kL=`Preview`,AL=`The entry this becomes in the per-session settings file.`,jL=`Duplicate`,ML=`Discard changes`,NL=`Close the editor and lose the unsaved changes?`,PL=`Esc cancels. Ctrl+Enter saves.`,FL=`A change reaches a session at its next start or restart. Claude Code sessions only; Codex and Grok sessions do not read this file.`,IL=`Glimmervoid's own hooks`,LL=`Always present, read-only. Status detection depends on them.`,RL=`Your hooks`,zL=`New hook`,BL=`Edit hook`,VL=`Saved to config.json.`,HL=`All projects`,UL=`This event takes no matcher.`,WL=`Blank uses Claude Code's default for the event.`,GL=Object.freeze([{value:`command`,label:`Command`,hint:`Run a shell command. It receives the event JSON on stdin.`},{value:`http`,label:`HTTP`,hint:`POST the event JSON to a URL.`}]),KL=Object.freeze([{id:`lint`,label:`Lint after edits`,summary:`PostToolUse on Edit|Write`,draft:{name:`Lint after edits`,event:`PostToolUse`,matcher:`Edit|Write`,type:`command`,command:`npx biome check --write "$(jq -r .tool_input.file_path)"`}},{id:`notify`,label:`Notify on Stop`,summary:`Stop, command`,draft:{name:`Notify on Stop`,event:`Stop`,matcher:``,type:`command`,command:`command -v notify-send >/dev/null 2>&1 && notify-send "Claude finished a turn" || { command -v osascript >/dev/null 2>&1 && osascript -e 'display notification "Claude finished a turn" with title "Claude Code"'; }`}},{id:`guard`,label:`Guard destructive Bash`,summary:`PreToolUse on Bash, exit 2 blocks`,draft:{name:`Guard destructive Bash`,event:`PreToolUse`,matcher:`Bash`,type:`command`,command:`jq -r .tool_input.command | grep -Eq "rm -rf|git push --force" && exit 2 || exit 0`}},{id:`log`,label:`Log every prompt`,summary:`UserPromptSubmit, appends JSON`,draft:{name:`Log every prompt`,event:`UserPromptSubmit`,matcher:``,type:`command`,command:`cat >> ~/.claude/prompts.jsonl`}}]),qL=Object.freeze({hooks:[],builtin:[],events:[]});function JL(e){return!e||typeof e.error==`string`}function YL(e){return!e||typeof e.error!=`string`?``:e.error}function XL(e,t){let n=e?.[t];return Array.isArray(n)?n:qL[t]}var ZL=e=>XL(e,`hooks`),QL=e=>XL(e,`builtin`),$L=e=>XL(e,`events`);function eR(e){let t=e?.limits?.maxTimeoutSec;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:600}function tR(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function nR(e){let t=ZL(e),n=t.filter(e=>e.enabled!==!1).length;return[{label:`yours`,value:String(t.length),tone:null},{label:`enabled`,value:String(n),tone:t.length>0&&n===0?`warn`:null},{label:`built in`,value:String(QL(e).length),tone:null}]}function rR(e,t){let n=new Map(t.map((e,t)=>[e.name,t])),r=e=>n.get(e.event)??t.length;return[...e].sort((e,t)=>{let n=r(e)-r(t);return n===0?String(e.name).localeCompare(String(t.name)):n})}function iR(e,t){let n=String(t||``).trim().toLowerCase();return n?e.filter(e=>[e.name,e.event,e.matcher,e.command,e.url].some(e=>typeof e==`string`&&e.toLowerCase().includes(n))):e}function aR(e){return e.length>=4}function oR(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.event===n.event?e.hooks.push(n):t.push({event:n.event,hooks:[n]})}return t}function sR(e){let t=e.type===`http`?{type:`http`,url:e.url||``}:{type:`command`,command:e.command||``};Number.isInteger(e.timeout)&&Number(e.timeout)>0&&(t.timeout=e.timeout);let n=e.matcher?{matcher:e.matcher,hooks:[t]}:{hooks:[t]};return JSON.stringify({hooks:{[e.event]:[n]}},null,2)}function cR(e){return`${e} copy`}function lR(e,t){return e.find(e=>e.name===t)||null}function uR(e,t){let n=lR(e,t);return n?n.matcher?`Matches ${n.matcher}. Blank matches every ${n.name}.`:UL:``}function dR(e){return e.type===`http`?e.url||``:e.command||``}function fR(e){let t=GL.find(t=>t.value===e);return t?t.label:String(e||``)}function pR(e){return!Number.isInteger(e.timeout)||Number(e.timeout)<=0?``:`${e.timeout}s timeout`}function mR(e,t){let n=Array.isArray(e.projects)?e.projects:[];return n.length===0?HL:n.map(e=>{let n=t.find(t=>t.id===e);return n?n.name:e}).join(`, `)}function hR(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function gR(e){return hR(e)}function _R(e,t){let n=Array.isArray(e.projects)?e.projects:[],r=new Set(t.map(e=>e.id));return n.filter(e=>!r.has(e))}function vR(e){let t=e[0];return{id:null,name:``,event:t?t.name:``,matcher:``,type:`command`,command:``,url:``,timeout:``,enabled:!0,projects:[]}}function yR(e){return{id:e.id??null,name:e.name||``,event:e.event||``,matcher:e.matcher||``,type:e.type===`http`?`http`:`command`,command:e.command||``,url:e.url||``,timeout:Number.isInteger(e.timeout)?String(e.timeout):``,enabled:e.enabled!==!1,projects:Array.isArray(e.projects)?[...e.projects]:[]}}function bR(e,t,n=600){if(!e.name.trim())return`Give the hook a name.`;let r=lR(t,e.event);if(!r)return`Pick an event.`;if(e.matcher.trim()&&!r.matcher)return`${r.name} takes no matcher.`;if(e.type===`http`&&r.http===!1)return`${r.name} does not support HTTP hooks.`;if(e.type===`command`&&!e.command.trim())return`Enter the command to run.`;if(e.type===`http`&&!/^https?:\/\/\S+$/i.test(e.url.trim()))return`Enter a URL starting with http:// or https://.`;if(e.timeout.trim()!==``){let t=Number(e.timeout);if(!Number.isInteger(t)||t<1||t>n)return`Timeout must be a whole number of seconds from 1 to ${n}.`}return null}function xR(e){let t={name:e.name.trim(),event:e.event,type:e.type,enabled:e.enabled!==!1};return e.id&&(t.id=e.id),e.matcher.trim()&&(t.matcher=e.matcher.trim()),e.type===`command`&&(t.command=e.command.trim()),e.type===`http`&&(t.url=e.url.trim()),e.timeout.trim()!==``&&(t.timeout=Number(e.timeout)),e.projects.length>0&&(t.projects=[...e.projects]),t}function SR(e,t){let n={...vR(t),...e.draft};return lR(t,n.event)||(n.event=vR(t).event),n}function CR(e,t){return JSON.stringify(xR(e))!==JSON.stringify(t)}function wR(e){return{...e,enabled:e.enabled===!1}}function TR(e){return`Delete the hook "${e.name}"? Sessions already running keep it until they restart.`}var ER=null,DR=null,OR=null,kR=!1,AR=null,jR=null,MR=null,NR=null,PR=null,FR=null,IR=!1,LR=``,RR=new Set,zR=new Set,BR=new Map,VR=!1,HR=(e,t)=>hr(`hooks`,e,t);function UR(e,t,n){let r=M(`p`,e,t);return n&&(r.dataset.tone=n),r}function WR(e,t,n,r){let i=M(`button`,e,t);return i.type=`button`,r&&i.setAttribute(`aria-label`,r),i.addEventListener(`click`,n),i}async function GR(e,t){try{let n=await _d(e,t,{timeoutMs:q});if((n.type===`save-hook-result`||n.type===`delete-hook-result`)&&n.ok)return null;let r=e===`save-hook`?`Could not save the hook.`:`Could not delete the hook.`;return`error`in n&&typeof n.error==`string`&&n.error?n.error:r}catch(e){return Ad(e,q)}}async function KR(e,t,n,r){zR.add(e),BR.set(e,{tone:`busy`,text:r}),gz({force:!0});let i=await GR(t,n);zR.delete(e),i&&BR.set(e,{tone:`error`,text:i}),i||BR.delete(e),gz({force:!0}),vz()}function qR(e,t,n){let r=M(`label`,`hooks-field`);return r.append(M(`span`,`hooks-field-label`,e),t),n&&r.append(M(`span`,`hooks-field-hint`,n)),r}function JR(e,t,n){let r=M(`input`,`settings-view-input`);return r.type=`text`,r.value=e,r.autocomplete=`off`,r.spellcheck=!1,t&&(r.placeholder=t),r.addEventListener(`input`,()=>n(r.value)),r}function YR(e,t){let n=M(`textarea`,`settings-view-input hooks-command`);return n.rows=3,n.value=e,n.spellcheck=!1,n.addEventListener(`input`,()=>t(n.value)),n}function XR(e,t,n){let r=M(`select`,`settings-view-input hooks-select`);for(let n of t){let t=M(`option`,null,n.name);t.value=n.name,t.title=n.description,n.name===e.event&&(t.selected=!0),r.append(t)}return r.addEventListener(`change`,()=>n(r.value)),r}function ZR(e,t){let n=M(`div`,`hooks-type-row`);n.setAttribute(`role`,`radiogroup`);for(let r of GL){let i=M(`label`,`settings-view-toggle hooks-choice`),a=M(`input`,`settings-view-checkbox`);a.type=`radio`,a.name=`hooks-type`,a.value=r.value,a.checked=e.type===r.value,a.title=r.hint,a.addEventListener(`change`,()=>{a.checked&&t(r.value)}),i.append(a,M(`span`,null,r.label)),n.append(i)}return n}function QR(e,t){let n=M(`div`,`hooks-projects`);if(t.length===0)return n.append(M(`span`,`hooks-field-hint`,HL)),n;let r=M(`label`,`settings-view-project-choice hooks-choice`),i=M(`input`,`settings-view-checkbox`);i.type=`checkbox`,i.checked=e.projects.length===0,r.append(i,M(`span`,null,HL)),n.append(r);let a=[];for(let r of t){let t=M(`label`,`settings-view-project-choice hooks-choice`),o=M(`input`,`settings-view-checkbox`);o.type=`checkbox`,o.value=r.id,o.checked=e.projects.includes(r.id),o.addEventListener(`change`,()=>{e.projects=a.filter(e=>e.checked).map(e=>e.value),i.checked=e.projects.length===0}),a.push(o),t.append(o,M(`span`,null,r.name)),r.agent!==`claude-code`&&(t.append(M(`span`,`hooks-choice-note`,r.agent)),t.title=`Not a Claude Code project: this hook will not reach its sessions.`),n.append(t)}return i.addEventListener(`change`,()=>{if(!i.checked)i.checked=e.projects.length===0;else{for(let e of a)e.checked=!1;e.projects=[]}}),n}function $R(e){let t=M(`div`,`hooks-templates`);t.append(M(`span`,`hooks-templates-label`,EL));for(let n of KL){let r=WR(`hooks-chip`,n.label,()=>nz(null,SR(n,e)));r.title=n.summary,t.append(r)}return t}function ez(e){PR&&(e?PR.show(`error`,e):PR.clear())}function tz(e){let t=$L(ER),n=_r(ER),r=HR(e.id?BL:zL,VL);r.classList.add(`hooks-editor`);let i=M(`form`,`hooks-form`);i.addEventListener(`submit`,e=>{e.preventDefault(),az()}),i.addEventListener(`keydown`,e=>{e.key===`Escape`?(e.preventDefault(),iz()):e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),az())}),e.id||i.append($R(t));let a=M(`span`,`hooks-field-hint`,uR(t,e.event)),o=JR(e.matcher,``,t=>{e.matcher=t}),s=qR(`Command`,YR(e.command,t=>{e.command=t}),`Runs through the shell with the event JSON on stdin. Exit 2 blocks the action where the event allows it.`),c=qR(`URL`,JR(e.url,`http://127.0.0.1:8080/hook`,t=>{e.url=t}),`Claude Code POSTs the event JSON to it.`),l=()=>{s.hidden=e.type!==`command`,c.hidden=e.type!==`http`};l();let u=qR(`Matcher`,o,null);u.append(a);let d=()=>{let n=t.find(t=>t.name===e.event);a.textContent=uR(t,e.event),o.disabled=!!n&&!n.matcher,o.disabled&&(o.value=``,e.matcher=``)};d();let f=M(`input`,`settings-view-input hooks-timeout`);f.type=`number`,f.inputMode=`numeric`,f.min=`1`,f.max=String(eR(ER)),f.value=e.timeout,f.addEventListener(`input`,()=>{e.timeout=f.value});let p=M(`label`,`settings-view-toggle hooks-choice`),m=M(`input`,`settings-view-checkbox`);m.type=`checkbox`,m.checked=e.enabled,m.addEventListener(`change`,()=>{e.enabled=m.checked}),p.append(m,M(`span`,null,`Enabled`)),i.append(qR(`Name`,JR(e.name,`Lint after edits`,t=>{e.name=t}),null),qR(`Event`,XR(e,t,t=>{e.event=t,d()}),null),u,qR(`Type`,ZR(e,t=>{e.type=t,l()}),null),s,c,qR(`Timeout (seconds)`,f,WL),qR(`Projects`,QR(e,n),null),qR(``,p,null)),PR=Od(`hooks-editor-status`);let h=M(`div`,`hooks-editor-footer`),g=M(`span`,`hooks-editor-shortcut`,PL),_=WR(`btn-dialog btn-dialog-cancel`,`Cancel`,iz),v=M(`button`,`btn-dialog btn-dialog-confirm`,e.id?`Save changes`:`Add hook`);return v.type=`submit`,FR=v,h.append(PR.element,g,_,v),i.append(h),r.append(i),r}function nz(e,t=null){jR=t||(e?yR(e):vR($L(ER))),MR=xR(e?yR(e):vR($L(ER))),NR=tz(jR),gz({force:!0}),NR.scrollIntoView({block:`nearest`});let n=NR.querySelector(`input[type=text]`);n instanceof HTMLInputElement&&n.focus()}function rz(){jR=null,MR=null,NR=null,PR=null,FR=null,IR=!1,VR=!0,gz({force:!0})}function iz(){!jR||!MR||!CR(jR,MR)?rz():rf({title:ML,message:NL,confirmLabel:`Discard`,danger:!0,onConfirm:rz})}async function az(){if(!jR||IR)return;let e=bR(jR,$L(ER),eR(ER));if(e){ez(e);return}let t=PR,n=FR;IR=!0,t?.show(`busy`,`Saving the hook.`),n&&(n.disabled=!0);let r=await GR(`save-hook`,{hook:xR(jR)});IR=!1,n&&(n.disabled=!1),t===PR&&(r?ez(r):(rz(),vz()))}function oz(e){let t=M(`details`,`hooks-preview`);t.open=RR.has(e.id),t.addEventListener(`toggle`,()=>{t.open?RR.add(e.id):RR.delete(e.id)});let n=M(`summary`,`hooks-preview-summary`,kL);n.title=AL;let r=M(`pre`,`hooks-preview-code`,sR(e));return t.append(n,r),t}function sz(e,{grouped:t=!1}={}){let n=_r(ER),r=M(`article`,`hooks-row`);r.setAttribute(`aria-label`,e.name),e.enabled===!1&&(r.dataset.state=`off`);let i=M(`div`,`hooks-row-main`),a=M(`div`,`hooks-row-head`);a.append(M(`span`,`hooks-row-name`,e.name));let o=t?e.matcher||``:hR(e);o&&a.append(M(`span`,`hooks-row-event`,o));let s=M(`code`,`hooks-row-target`,dR(e));s.title=dR(e);let c=M(`p`,`hooks-row-meta`,[fR(e.type),pR(e),mR(e,n)].filter(Boolean).join(` / `));i.append(a,s,c);let l=_R(e,n);l.length>0&&i.append(UR(`hooks-row-meta`,`Scoped to a project no longer in config: ${l.join(`, `)}`,`warn`)),i.append(oz(e));let u=BR.get(e.id);if(u){let e=Od(`hooks-row-status`);e.show(u.tone,u.text),i.append(e.element)}let d=M(`div`,`hooks-row-actions`),f=M(`label`,`settings-view-toggle hooks-choice`),p=M(`input`,`settings-view-checkbox`);p.type=`checkbox`,p.checked=e.enabled!==!1,p.disabled=zR.has(e.id),p.setAttribute(`aria-label`,`${e.name} enabled`),p.addEventListener(`change`,()=>{KR(e.id,`save-hook`,{hook:wR(e)},p.checked?`Turning the hook on.`:`Turning the hook off.`)}),f.append(p,M(`span`,null,`On`));let m=WR(`hooks-btn`,`Edit`,()=>nz(e),`Edit ${e.name}`),h=WR(`hooks-btn`,jL,()=>{let t=yR({...e,name:cR(e.name)});t.id=null,nz(null,t)},`Duplicate ${e.name}`),g=WR(`hooks-btn hooks-btn-danger`,`Delete`,()=>{rf({title:`Delete hook`,message:TR(e),confirmLabel:`Delete`,danger:!0,onConfirm:()=>{KR(e.id,`delete-hook`,{id:e.id},`Deleting the hook.`)}})},`Delete ${e.name}`);return g.disabled=zR.has(e.id),d.append(f,m,h,g),r.append(i,d),r}function cz(e){let t=M(`article`,`hooks-row hooks-row-builtin`),n=M(`div`,`hooks-row-main`);return n.append(M(`span`,`hooks-row-event`,gR(e)),M(`p`,`hooks-row-meta`,e.purpose)),t.append(n),t}function lz(){let e=HR(`Hooks`,CL),t=M(`div`,`hooks-stats`);for(let e of nR(ER))t.append(gr(`hooks`,e.label,e.value,e.tone));return e.append(t,UR(`hooks-meta`,FL)),e}function uz(){let e=M(`input`,`settings-view-input hooks-filter`);return e.type=`search`,e.value=LR,e.placeholder=DL,e.setAttribute(`aria-label`,DL),e.addEventListener(`input`,()=>{LR=e.value;let t=DR?.querySelector(`.hooks-list-yours`);t&&t.replaceWith(fz())}),e}function dz(){let e=M(`div`,`hooks-empty-state`);return e.append(UR(`hooks-empty`,TL),$R($L(ER))),e}function fz(){let e=M(`div`,`hooks-list-yours`),t=ZL(ER);if(t.length===0)return e.append(dz()),e;let n=iR(rR(t,$L(ER)),LR);if(n.length===0)return e.append(UR(`hooks-empty`,OL)),e;for(let t of oR(n)){let n=M(`div`,`hooks-group`);n.append(M(`h3`,`hooks-group-title`,t.event));let r=M(`div`,`hooks-list`);for(let e of t.hooks)r.append(sz(e,{grouped:!0}));n.append(r),e.append(n)}return e}function pz(){let e=HR(RL,null),t=WR(`hooks-btn hooks-btn-add`,`+ New hook`,()=>nz(null));t.disabled=!!jR;let n=e.querySelector(`.hooks-section-head`);return n&&n.append(t),aR(ZL(ER))&&e.append(uz()),e.append(fz()),e}function mz(){let e=M(`details`,`hooks-builtin`),t=M(`summary`,`hooks-builtin-summary`);t.append(M(`span`,`hooks-section-title`,`${IL} (${QL(ER).length})`),M(`span`,`hooks-section-hint`,LL));let n=M(`div`,`hooks-list`);for(let e of QL(ER))n.append(cz(e));return e.append(t,n),e}function hz(){let e=M(`div`,`hooks-content`);return ER?JL(ER)?(e.append(UR(`hooks-warning`,YL(ER))),e):(e.append(lz()),NR&&e.append(NR),e.append(pz(),mz()),e):(e.append(kR?UR(`hooks-warning`,G):UR(`hooks-empty`,wL)),e)}function gz({force:e=!1}={}){if(!DR||!e&&vr(DR)||(DR.replaceChildren(hz()),!VR))return;VR=!1;let t=DR.querySelector(`.hooks-btn-add`);t instanceof HTMLButtonElement&&t.focus()}function _z(e){OR=e}function vz(){if(!OR)return;AR=gd(`hooks-report`);let e=OR({type:`request-hooks-report`,requestId:AR});e!==!kR&&(kR=!e,gz())}function yz(e){DR||(DR=M(`div`,`hooks-panel`),e.append(DR),gz({force:!0}))}function bz(){gz({force:!0})}function xz(e){tR(e,AR)&&(ER=e,kR=!1,gz())}function Sz(){vz()}function Cz(e){return e.filter(e=>!e.hasOwnPhoneScreen).map(e=>{let t=e.label.trim();return{id:e.view,label:t,glyph:e.glyph||t.charAt(0).toUpperCase(),el:e.el}})}var wz=e=>e.ui.path;function Tz({onSelectSession:e}){let t=M(`div`,`phone-board`),n=M(`header`,`phone-topbar`),r=null,i=M(`button`,`btn-dialog`,`Next`);i.type=`button`,i.addEventListener(`click`,()=>{let t=Eg(Pg(b()),r);t&&(r=t,e?.(t))});let a=oP(i),o=M(`div`,`phone-board-list`),s=M(`div`,`phone-empty`),c=M(`p`,`phone-empty-title`,`No sessions`),l=M(`p`,`phone-empty-desc`,`Spawn a session to start watching.`);s.append(c,l),t.append(n,a,o,s);let u=new Map,d=new Map,f=new WeakMap,p=new WeakMap,m=new WeakMap,h=0;mr(n);function g(t){let{row:n,refs:r}=vv(`button`);n.type=`button`,n.dataset.id=t,n.addEventListener(`click`,()=>e?.(t));let{item:i}=yv(n,()=>Yv(t));return i.setAttribute(`role`,`listitem`),f.set(n,{refs:r,item:i}),n}function _(){let e=M(`section`,`phone-board-group`),t=rP({onAdd:Jv,onForget:e=>{Fv(e),x()}}),n=M(`div`,`phone-board-group-rows`);return n.setAttribute(`role`,`list`),e.append(t.header,n),p.set(e,{...t,rows:n}),e}function v(e,t){let n=f.get(e);if(!n)return;let{ui:r,state:i,name:a}=t;Cv(e,n.refs,{ui:r,state:i,name:a,mergeStatus:r.card?.dataset.merge||``})}function y(e,t){let n=p.get(e);n&&(iP(n,t,`Board`),n.rows.setAttribute(`aria-label`,`${t.label} sessions`))}function b(){return wg(Gv())}function x(){let e=b(),t=tP(e,wz,Pv(e,wz)),n=Fg(e);h=Ig(n),sP(a,n);let r=new Set(t.order),i=t.order.join(`,`),x=m.get(o)===i&&o.childElementCount===t.groups.length;for(let e of t.groups){let t=d.get(e.key);t||(t=_(),d.set(e.key,t)),y(t,e),x||o.appendChild(t);let n=e.rows.map(e=>e.id).join(`,`),r=p.get(t);if(!r)continue;let i=m.get(r.rows)===n&&r.rows.childElementCount===e.rows.length;for(let t of e.rows){let e=u.get(t.id);e||(e=g(t.id),u.set(t.id,e)),v(e,t);let n=f.get(e);n&&(i||r.rows.appendChild(n.item))}m.set(r.rows,n)}m.set(o,i);for(let[e,t]of[...d])r.has(e)||(t.remove(),d.delete(e));let S=new Set(nP(t));for(let[e,t]of[...u]){if(S.has(e))continue;let n=f.get(t);n&&n.item.remove(),u.delete(e)}let ee=t.groups.length>0,te=F.size===0;o.hidden=!ee,s.hidden=ee,gm(s,te),c.hidden=te,l.hidden=te}function S(e,t){let n=e.card?.dataset.id,r=n?u.get(n):void 0;r&&(t===`flag`?r.dataset.activity=e._activity||``:Cf(f.get(r)?.refs.glyph))}return jf(()=>{for(let[e,t]of u){let n=F.get(e),r=f.get(t);n&&r&&(r.refs.elapsed.textContent=kf(n))}}),{el:t,topBarEl:n,refresh:x,renderActivity:S,getAttentionCount:()=>h}}var Ez=`clipboard`,Dz=`upload`,Oz=24,kz=Object.freeze([Object.freeze({id:`esc`,label:`Esc`,bytes:`\x1B`,title:`Send Escape`}),Object.freeze({id:`tab`,label:`Tab`,bytes:` `,title:`Send Tab`}),Object.freeze({id:`left`,label:`←`,bytes:`\x1B[D`,isArrow:!0,title:`Arrow left`}),Object.freeze({id:`up`,label:`↑`,bytes:`\x1B[A`,isArrow:!0,title:`Arrow up`}),Object.freeze({id:`down`,label:`↓`,bytes:`\x1B[B`,isArrow:!0,title:`Arrow down`}),Object.freeze({id:`right`,label:`→`,bytes:`\x1B[C`,isArrow:!0,title:`Arrow right`}),Object.freeze({id:`paste`,label:`Paste`,bytes:null,action:Ez,title:`Paste from the clipboard`}),Object.freeze({id:`attach`,label:`Attach`,bytes:null,action:Dz,title:`Upload a photo or file to this session`})]);function Az(e){let t=kz.find(t=>t.id===e);return t?t.bytes:null}function jz(e){return!!e&&e.action===Ez}function Mz(e){return!!e&&e.action===`upload`}function Nz(e,t,n=Oz){let r=Math.abs(e)>=Math.abs(t),i=r?e:t;return Math.abs(i)<n?null:r?i>0?`right`:`left`:i>0?`down`:`up`}function Pz(e,t,n=Oz){let r=Nz(e,t,n);if(!r)return null;let i=r===`left`||r===`right`,a=i?e:t,o=Math.floor(Math.abs(a)/n),s=Math.sign(a)*o*n;return{arrowKeyId:r,stepCount:o,consumedX:i?s:e,consumedY:i?t:s}}var Fz={" ":`\0`,"@":`\0`,"[":`\x1B`,"\\":``,"]":``,"^":``,_:``,"?":``};function Iz(e){if(e.length!==1)return null;let t=e.toLowerCase();return t>=`a`&&t<=`z`?String.fromCharCode(t.charCodeAt(0)-96):Fz[e]??null}function Lz({send:e,getSessionId:t,reportProblem:n}){let r=M(`div`,`phone-key-strip`);r.setAttribute(`role`,`toolbar`),r.setAttribute(`aria-label`,`Terminal keys`);let i=null,a=null,o=M(`button`,`phone-key phone-key-ctrl`,`Ctrl`);o.type=`button`,o.title=`Hold Ctrl for the next key you type`,o.setAttribute(`aria-pressed`,`false`),o.addEventListener(`pointerdown`,e=>e.preventDefault()),o.addEventListener(`click`,()=>c(!s())),r.appendChild(o);function s(){return o.getAttribute(`aria-pressed`)===`true`}function c(e){o.setAttribute(`aria-pressed`,String(e))}function l(){return s()?(c(!1),!0):!1}for(let t of kz){t.id===`left`&&r.appendChild(Rz(e));let n=M(`button`,t.isArrow?`phone-key phone-key-arrow`:`phone-key`,t.label);n.type=`button`,n.dataset.key=t.id,n.title=t.title,t.isArrow&&n.setAttribute(`aria-label`,t.title),n.addEventListener(`pointerdown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>u(t,n)),r.appendChild(n)}function u(t,r){Mz(t)?d(r):jz(t)?Bz(e,n):e(Az(t.id))}function d(e){a=e,i||(i=M(`input`,`phone-file-picker`),i.type=`file`,i.hidden=!0,i.addEventListener(`change`,f),r.appendChild(i)),i.click()}function f(){let e=i;if(!e)return;let r=e.files?e.files[0]:null;if(e.value=``,!r)return;let o=t?.();o?p(o,r,a):n(`No session is open to upload to.`)}async function p(e,t,n){n&&(n.disabled=!0),await sS(e,t),n&&(n.disabled=!1)}return{element:r,takeHeldControl:l}}function Rz(e){let t=M(`button`,`phone-key phone-arrow-pad`,`Arrows`);t.type=`button`,t.title=`Swipe to send arrow keys`;let n=null,r=null;t.addEventListener(`pointerdown`,e=>{e.preventDefault(),r===null&&(t.setPointerCapture(e.pointerId),r=e.pointerId,n={x:e.clientX,y:e.clientY})}),t.addEventListener(`pointermove`,t=>{if(t.pointerId!==r||!n)return;let i=Pz(t.clientX-n.x,t.clientY-n.y);if(i){for(let t=0;t<i.stepCount;t++)e(Az(i.arrowKeyId));n={x:n.x+i.consumedX,y:n.y+i.consumedY}}});let i=e=>{e.pointerId===r&&(r=null,n=null)};return t.addEventListener(`pointerup`,i),t.addEventListener(`pointercancel`,i),t}var zz=`Paste needs clipboard permission.`;function Bz(e,t){let n=null;try{n=navigator.clipboard?.readText?.()}catch{t(zz);return}n?n.then(t=>{t&&e(t)}).catch(()=>t(zz)):t(`Paste is unavailable in this browser.`)}var Vz=`‹`;function Hz({onBack:e}){let t=M(`div`,`phone-terminal`),n=M(`header`,`phone-topbar phone-terminal-bar`),r=M(`button`,`phone-back`,Vz);r.type=`button`,r.setAttribute(`aria-label`,`Back to board`),r.addEventListener(`click`,()=>e?.());let i=M(`div`,`phone-terminal-identity`),a=M(`span`,`phone-terminal-name`);a.title=`Double-tap to rename`,a.addEventListener(`dblclick`,()=>ee());let o=M(`span`,`session-task-title phone-terminal-title`);L_(o,()=>te());let s=M(`span`,`phone-terminal-badge`);s.innerHTML=`<span class="phone-terminal-glyph" aria-hidden="true"></span><span class="phone-terminal-label"></span><span class="phone-terminal-elapsed" aria-hidden="true"></span>`;let c=N(s,`.phone-terminal-glyph`,`span`),l=N(s,`.phone-terminal-label`,`span`),u=N(s,`.phone-terminal-elapsed`,`span`);l.before(a),i.append(o,s);let d=M(`div`,`phone-terminal-actions`);n.append(r,i,d);let f=M(`div`,`phone-card-slot`),p=M(`div`,`phone-empty`);p.innerHTML=`<p class="phone-empty-title">No session selected</p><p class="phone-empty-desc">Select a session from the board to watch it here.</p>`;let m=Od(`phone-key-status m-0 px-3 py-1`),{element:h,takeHeldControl:g}=Lz({send:b,getSessionId:()=>_,reportProblem:e=>m.show(`error`,e)});t.append(n,f,p,m.element,h);let _=null,v=null,y=null;function b(e){let t=_?F.get(_):null;t&&(PC(t,e)?m.clear():m.show(`error`,G))}function x(){let e=_?F.get(_):null;e?.term&&e.term.focus()}f.addEventListener(`click`,x);function S(e){let t=Iz(e);return!t||!g()?!1:(b(t),!0)}f.addEventListener(`keydown`,e=>{e.ctrlKey||e.metaKey||e.altKey||S(e.key)&&(e.preventDefault(),e.stopPropagation())},!0),f.addEventListener(`input`,e=>{e instanceof InputEvent&&e.data&&S(e.data.slice(-1))&&(e.stopPropagation(),(_?F.get(_):null)?._resetSoftKeyboardBuffer?.())},!0);function ee(){let e=_?F.get(_):null;e&&_&&U_(e,_,{returnsFocusToTerminal:!1})}function te(){let e=_?F.get(_):null;e&&_&&B_(e,_)}function C(){let e=_?F.get(_):null,t=!!e;if(p.hidden=t,f.hidden=!t,h.hidden=!t,i.hidden=!t,!t){n.removeAttribute(`data-state`),n.removeAttribute(`data-monitoring`),n.removeAttribute(`data-prompt`);return}let r=e.currentState||j.DORMANT;bv(n,{glyph:c,label:l},r,e.awaitingBackgroundTasks,e.pendingPromptKind);let s=e.card?.dataset.session||_;H_(a)||(a.textContent=s),o.dataset.sessionName=s??``,z_(o,e.taskTitle),u.textContent=kf(e)}function ne(){y&&=(delete y.renameTargetEl,delete y.titleTargetEl,null),a.replaceChildren(),v&&=(xr(v),v.parentElement===d&&v.remove(),null)}function w(e){let t=F.get(e);t&&(_===e&&jr()===e&&t.card.parentElement===f||(ne(),_=e,Mr(t,e,f,{className:`phone-centered`}),v=N(t.card,`.session-actions`,`div`),br(v,d),t.renameTargetEl=a,t.titleTargetEl=o,y=t),C())}function re(){ne(),jr()===_&&Nr(),_=null,C()}function ie(){if(!_){C();return}let e=F.get(_);e?e.card.parentElement===f?C():(w(_),t.hidden||UC(e,_,!0)):re()}function ae(){let e=_;e&&UC(F.get(e),e,!1)}function oe(){ie();let e=_;if(!e)return;let t=F.get(e);t&&(UC(t,e,!0),XN(e))}return jf(()=>{let e=_?F.get(_):null;e&&(u.textContent=kf(e))}),C(),{el:t,show:w,clear:re,refresh:ie,reveal:oe,unview:ae,getSessionId:()=>_}}var Uz=`board`,Wz=Object.freeze([{id:Uz,label:`Board`,glyph:`▤`},{id:`terminal`,label:`Terminal`,glyph:`▸`},{id:`review`,label:`Review`,glyph:`◫`}]),Gz=[],Kz=new Map,qz=null,Jz=new Map,Yz=new Map,Xz=new Map,Zz=null,Qz=null,$z=null,eB=null,tB=null,nB=new Map,rB=new Set,iB={},aB=!1,oB=120,sB=0,cB=0,lB=0,uB=null;function dB(){sB=0,cB=0}function fB(){let e=window.visualViewport;qz&&(!aB||!e?qz.removeAttribute(`data-keyboard`):(qz.style.setProperty(`--phone-vh`,`${e.height}px`),qz.style.setProperty(`--phone-vv-top`,`${e.offsetTop}px`),e.width!==cB&&(cB=e.width,sB=0),sB=Math.max(sB,e.height),sB-e.height>oB?qz.dataset.keyboard=`open`:qz.removeAttribute(`data-keyboard`)))}function pB(e,t,n=`phone-nav-item`,r=`phone-nav-dot`){let i=M(`button`,n);i.type=`button`;let a=M(`span`,`phone-nav-glyph`,t);a.setAttribute(`aria-hidden`,`true`),i.append(a,M(`span`,`phone-nav-label`,e));let o=M(`span`,r);return o.setAttribute(`aria-hidden`,`true`),o.hidden=!0,i.appendChild(o),i}function mB(e){return e?.querySelector(`.phone-nav-dot`)||null}function hB(e,t){e&&(e.hidden=!t,typeof t==`string`&&(e.dataset.attention=t),typeof t!=`string`&&delete e.dataset.attention)}function gB(){let e=[];for(let t of Gz){if(rB.has(t.id))continue;let n=Xz.get(t.id)||!1;e.push(n),hB(mB(nB.get(t.id)),n)}hB(mB(eB),Ug(e))}function _B(){let e=M(`div`,`phone-nav-more-menu`);e.hidden=!0;for(let t of Gz){let n=pB(t.label,t.glyph,`phone-nav-menu-item`,`phone-nav-dot phone-nav-menu-dot`);n.dataset.screen=t.id,n.hidden=rB.has(t.id),n.addEventListener(`click`,()=>{vB(!1),FB(t.id)}),nB.set(t.id,n),e.appendChild(n)}return e}function vB(e){tB&&eB&&(tB.hidden=!e,eB.setAttribute(`aria-expanded`,String(e)))}function yB(){return!!tB&&!tB.hidden}function bB(){let e=M(`nav`,`phone-nav`);e.setAttribute(`aria-label`,`Screens`);for(let t of Wz){let n=pB(t.label,t.glyph);n.dataset.screen=t.id,n.addEventListener(`click`,()=>FB(t.id)),Jz.set(t.id,n),e.appendChild(n)}return eB=pB(`More`,`⋯`),eB.setAttribute(`aria-expanded`,`false`),eB.addEventListener(`click`,()=>vB(!yB())),e.appendChild(eB),tB=_B(),e.appendChild(tB),e}function xB(e,t,n){let r=M(`section`,`phone-screen`);return r.dataset.screen=e,r.setAttribute(`aria-label`,t),r.hidden=!0,n&&r.appendChild(n),Yz.set(e,r),r}function SB(){if(qz)return;Zz=Tz({onSelectSession:CB}),bf((e,t)=>{aB&&Zz?.renderActivity(e,t)}),Qz=Hz({onBack:()=>FB(Uz)}),$z=M(`div`,`phone-review`);let e=M(`div`,`phone-screens`),t={[Uz]:Zz.el,terminal:Qz.el,review:$z};for(let n of Wz)e.appendChild(xB(n.id,n.label,t[n.id]));for(let t of Gz){let n=M(`div`,`phone-panel phone-${t.id}`);Kz.set(t.id,n),e.appendChild(xB(t.id,t.label,n))}qz=M(`div`,`phone-shell`),qz.id=`phone-shell`,qz.append(e,bB()),document.body.appendChild(qz),gB(),window.visualViewport?.addEventListener(`resize`,fB),window.visualViewport?.addEventListener(`scroll`,fB),window.addEventListener(`popstate`,jB),document.addEventListener(`click`,e=>{yB()&&tB&&eB&&e.target instanceof Node&&(tB.contains(e.target)||eB.contains(e.target)||vB(!1))}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&yB()&&vB(!1)})}function CB(e){if(F.has(e)){if(!Zz||!Qz)throw Error(`Phone shell is not built`);Hv(e,`dormant-fallback`),Uv(e),Qz.show(e),FB(`terminal`)}}function wB(e,t){return t?{glimmervoidScreen:e,glimmervoidNested:!0}:{glimmervoidScreen:e}}function TB(e){let t=e?.glimmervoidScreen;return typeof t==`string`?t:null}function EB(e){return TB(e)?e.glimmervoidNested===!0?2:1:0}function DB(e){return e===Uz?0:iB.canGoBack?.(e)?2:1}function OB(e,t){return TB(history.state)===e&&EB(history.state)===(t?2:1)}function kB(){if(!aB||uB!==null)return;let e=kr.snapshot().phoneScreen||Uz,t=DB(e);if(lB>t){uB=location.href,history.go(t-lB),lB=t;return}let n=lB===2;lB>0&&!OB(e,n)&&history.replaceState(wB(e,n),``),lB===0&&t>0&&(history.pushState(wB(e,!1),``),lB=1),lB===1&&t===2&&(history.pushState(wB(e,!0),``),lB=2)}function AB(){let e=TB(history.state);return e&&PB(e)?(lB=EB(history.state),e):(e&&history.replaceState(null,``),lB=0,Uz)}function jB(e){if(!aB)return;if(uB!==null){history.replaceState(history.state,``,uB),uB=null,kB();return}let t=TB(e.state),n=t&&PB(t)?t:Uz;lB=EB(e.state);let r=kr.snapshot().phoneScreen;lB<2&&n===r&&iB.canGoBack?.(r)&&iB.onBack?.(r),NB(n),kB()}function MB(e,t){for(let[n,r]of e)n===t?r.setAttribute(`aria-current`,`page`):r.removeAttribute(`aria-current`)}function NB(e){if(!eB||!Qz)throw Error(`Phone shell is not built`);kr.dispatch(`setPhoneScreen`,e),vB(!1);for(let[t,n]of Yz)n.hidden=t!==e;iB.onScreenShown?.(e),MB(Jz,e);let t=nB.has(e);t&&eB.setAttribute(`aria-current`,`page`),t||eB.removeAttribute(`aria-current`),MB(nB,e),e===`terminal`?Qz.reveal():Qz.unview()}function PB(e){return Yz.has(e)&&!rB.has(e)}function FB(e){qz&&PB(e)&&(NB(e),kB())}function IB(e){iB=e||{},Gz=iB.panels||[]}function LB({sessionId:e,linkedScreenId:t}={}){if(aB)return;if(SB(),!qz||!Zz||!Qz)throw Error(`Phone shell is not built`);aB=!0,qz.hidden=!1;for(let e of iB.headerControls||[])br(e,Zz.topBarEl);BE($z);for(let e of Gz)br(e.el,Kz.get(e.id)),e.el.hidden=!1;fB(),e&&Qz.show(e);let n=AB();HB(),t&&PB(t)?FB(t):e&&n===Uz?FB(`terminal`):(NB(n),kB())}function RB(){if(aB){if(!qz||!Qz)throw Error(`Phone shell is not built`);aB=!1,Qz.clear(),BE(null);for(let e of Gz)xr(e.el);for(let e of iB.headerControls||[])xr(e);vB(!1),qz.hidden=!0,qz.removeAttribute(`data-keyboard`),dB(),lB>0&&history.go(-lB),lB=0,uB=null}}function zB(e){return!aB||!Zz||!Qz||!F.has(e)?!1:(CB(e),bN(e))}function BB(){return aB}function VB(){return aB&&Qz?Qz.getSessionId():null}function HB(){if(!aB)return;if(!Zz||!Qz)throw Error(`Phone shell is not built`);qB(),Zz.refresh(),Qz.refresh(),kr.snapshot().phoneScreen===`terminal`&&!Qz.getSessionId()&&FB(Uz);let e=mB(Jz.get(Uz));e&&(e.hidden=Zz.getAttentionCount()===0)}function UB(e){return aB?(CB(e),!0):!1}function WB(e){return!aB||!PB(e)?!1:(FB(e),!0)}function GB(e,t){t&&rB.delete(e),t||rB.add(e);let n=nB.get(e);n&&(n.hidden=!t);let r=Yz.get(e);r&&!t&&(r.hidden=!0),gB(),!t&&aB&&kr.snapshot().phoneScreen===e&&FB(Uz)}function KB(e,t){Xz.set(e,typeof t==`string`&&t?t:t===!0),gB()}function qB(){if(!Qz)throw Error(`Phone shell is not built`);if(Qz.getSessionId())return;let e=Wv();e&&(Qz.show(e),Uv(e,{rememberFocus:!1}))}function JB(e,t){return!!e?.error&&!e.isRefreshing&&typeof e.nextAttemptAt==`number`&&e.nextAttemptAt>t}function YB(e,t){if(!e?.error)return null;let n=`Could not reach GitHub: ${e.error.trim().replace(/[.!]+$/,``)}.`;if(e.isRefreshing)return`${n} Refreshing.`;if(typeof e.nextAttemptAt!=`number`)return n;let r=Math.max(0,Math.ceil((e.nextAttemptAt-t)/1e3));return r===0?`${n} Retrying now.`:e.retry?`${n} Retrying in ${r}s (${e.retry.attempt} of ${e.retry.limit}).`:`${n} Next try in ${r>=60?`${Math.ceil(r/60)} min`:`${r}s`}.`}function XB(e,t,n){return e?.refreshNotice&&e.isRefreshing?e.refreshNotice:t||e?.isRefreshing?`Refreshing`:n||e?.refreshNotice||``}var ZB={minPx:220,maxPx:720},QB=16,$B=new Set,eV=0;function tV(e){let t=cc();e.toggleAttribute(`data-queue-collapsed`,t),e.querySelector(`.pr-queue-toggle`)?.setAttribute(`aria-expanded`,String(!t));let n=oc();n===null?e.style.removeProperty(`--pr-queue-width`):e.style.setProperty(`--pr-queue-width`,`${n}px`)}function nV(){for(let e of $B)e.isConnected?tV(e):$B.delete(e)}function rV(e,t){let n=M(`div`,`pr-queue-head`);return e&&n.append(e),t&&n.append(t),n}function iV(e){let t=M(`div`,`pr-queue-foot`);return e&&t.append(e),t}function aV({queueLabel:e,scopeTabs:t,resizerLabel:n}){let r=M(`div`,`pr-columns`),i=M(`div`,`pr-queue-pane`),a=M(`nav`,`pr-queue`);a.id=`pr-queue-${++eV}`,a.setAttribute(`aria-label`,e);let o=M(`button`,`pr-queue-toggle`);o.type=`button`,o.setAttribute(`aria-label`,`Review queue`),o.setAttribute(`aria-controls`,a.id),o.title=`Collapse or expand the review queue`;let s=l_(16,16);s.append(c_(`rect`,{x:`1.5`,y:`2`,width:`13`,height:`12`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),s.append(c_(`path`,{d:`M5.5 2V14`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`}));let c=c_(`path`,{d:`M11 6L9 8L11 10`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linecap":`round`,"stroke-linejoin":`round`});c.classList.add(`pr-queue-chevron`),s.append(c),o.append(s),o.addEventListener(`click`,()=>{lc(!cc()),nV()});let l=iV(null);i.append(rV(t,o),a,l);let u=M(`div`,`pr-queue-resizer`);u.setAttribute(`role`,`separator`),u.setAttribute(`aria-orientation`,`vertical`),u.setAttribute(`aria-label`,n),u.tabIndex=0;let d=M(`main`,`pr-detail-host`);return r.append(i,u,d),tV(r),$B.add(r),n_({resizer:u,column:i,widthHost:r,widthProperty:`--pr-queue-width`,bounds:ZB,keyStepPx:QB,getStoredWidth:oc,setStoredWidth:sc}),{columns:r,queue:a,foot:l,detail:d}}var oV=1.2,sV=1.55,cV=.12,lV=523.25,uV=2,dV=8,Y=(e,t,n)=>({semitone:e,startBeat:t,beats:n}),fV={melody:[Y(7,4,.5),Y(11,4.5,.5),Y(12,5,3)],bass:[Y(-5,4,1),Y(-12,5,3)]},pV=[{melody:[Y(0,0,1),Y(4,1,1),Y(7,2,1),Y(9,3,1)],bass:[Y(-12,0,2),Y(-8,2,2)]},{melody:[Y(7,0,.67),Y(7,.67,.67),Y(7,1.33,.67),Y(9,2,1),Y(5,3,1)],bass:[Y(-12,0,2),Y(-7,2,2)]},{melody:[Y(5,0,1),Y(9,1,1),Y(7,2,1),Y(4,3,1)],bass:[Y(-7,0,2),Y(-12,2,2)]},{melody:[Y(12,0,.5),Y(7,.5,.5),Y(12,1,.5),Y(16,1.5,.5),Y(16,2,1),Y(14,3,1)],bass:[Y(-12,0,2),Y(-3,2,2)]},{melody:[Y(4,0,1),Y(7,1,1),Y(4,2,.5),Y(5,2.5,.5),Y(7,3,.5),Y(4,3.5,.5)],bass:[Y(-8,0,2),Y(-12,2,2)]}].map(e=>({melody:[...e.melody,...fV.melody],bass:[...e.bass,...fV.bass]}));function mV(e,t){return lV*2**((e+t)/12)}function hV(e,t){let n=(e,n,r)=>e.map(e=>({frequency:mV(e.semitone,t),startSeconds:sV+e.startBeat*cV,durationSeconds:e.beats*cV,waveform:n,gain:r}));return[...n(e.melody,`square`,.2),...n(e.melody,`triangle`,.5),...n(e.bass,`triangle`,.6)]}var gV=[{frequency:220,endFrequency:880,startSeconds:0,durationSeconds:.32,waveform:`triangle`,gain:.25},{frequency:160,endFrequency:45,startSeconds:oV,durationSeconds:.28,waveform:`sine`,gain:1},{frequency:1400,endFrequency:380,startSeconds:oV,durationSeconds:.06,waveform:`square`,gain:.12}];function _V(e){let t=pV[e%pV.length],n=Math.min(e*uV,dV);return{peakGain:.1,tones:[...gV,...hV(t,n)]}}function vV(e){return Math.round(Math.sqrt(2*e/780)*1e3)}function yV(e,t,n=Math.random){return Math.round(e+n()*(t-e))}function bV(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var xV=.6,SV=.25,CV=1.6;function wV(e){return Math.min(xV+e*SV,CV)}var TV=[`var(--accent)`,`var(--state-running)`,`var(--state-idle)`,`var(--state-waiting)`,`var(--state-failed)`];function EV(e,t=Math.random){let n=yV(320,520,t),r=yV(1800,2800,t);return[[`--confetti-start-x`,`${yV(4,96,t)}%`],[`--confetti-x`,`${yV(-140,140,t)}px`],[`--confetti-rise`,`${-yV(20,55,t)}px`],[`--confetti-fall`,`${yV(45,70,t)}vh`],[`--confetti-rise-ms`,`${n}ms`],[`--confetti-fall-ms`,`${r}ms`],[`--confetti-flight-ms`,`${n+r}ms`],[`--confetti-tilt`,`${yV(0,180,t)}deg`],[`--confetti-spin`,`${yV(-360,360,t)}deg`],[`--confetti-flutter-ms`,`${yV(160,340,t)}ms`],[`--confetti-delay`,`${yV(0,160,t)}ms`],[`--confetti-color`,TV[e%TV.length]]]}var DV=`<svg viewBox="0 0 36 36" aria-hidden="true"><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="17"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="13"/><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="9"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="5"/></svg>`,OV=`<svg viewBox="0 0 26 8" aria-hidden="true"><path class="merge-bullseye-dart-flight" d="M0 0L7 3V5L0 8L2 4Z"/><rect class="merge-bullseye-dart-shaft" x="6" y="3.3" width="8" height="1.4"/><rect class="merge-bullseye-dart-barrel" x="13" y="2.5" width="7" height="3" rx="1"/><path class="merge-bullseye-dart-tip" d="M20 3L26 4L20 5Z"/></svg>`;function kV(){let e=sr(`div`,`merge-bullseye-target`,DV);return e.append(M(`span`,`merge-bullseye-ripple`)),e}function AV(){let e=M(`div`,`merge-bullseye-dart-drift`),t=M(`div`,`merge-bullseye-dart-arc`),n=M(`div`,`merge-bullseye-dart-aim`);return n.append(sr(`div`,`merge-bullseye-dart`,OV)),t.append(n),e.append(t),e}function jV(){let e=M(`div`,`merge-bullseye-range`),t=M(`div`,`merge-bullseye-track`);return t.append(AV()),e.append(kV(),t),e}var MV={title:`BULLSEYE!`,buildScene:jV},NV=6,PV=30,FV=-14,IV=16;function LV(e=Math.random){return[[`--crosshair-start-left`,`${yV(NV,PV,e)}%`],[`--crosshair-start-offset-y`,`${yV(FV,IV,e)}px`]]}var RV=`<svg viewBox="0 0 26 40" aria-hidden="true"><path class="merge-headshot-target-body" d="M9 13H17L18 16Q25 18 25 24V40H1V24Q1 18 8 16Z"/><circle class="merge-headshot-target-head" cx="13" cy="7" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="7" r="3"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="2.5"/></svg>`,zV=`<svg viewBox="0 0 22 22" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M11 0V5M11 17V22M0 11H5M17 11H22"/><circle class="merge-headshot-crosshair-dot" cx="11" cy="11" r="1"/></svg>`,BV=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3L8 8M21 3L16 8M3 21L8 16M21 21L16 16"/></svg>`;function VV(){let e=M(`div`,`merge-headshot-sweep`);cr(e,LV());let t=M(`div`,`merge-headshot-aim`);t.append(sr(`div`,`merge-headshot-crosshair`,zV));let n=M(`div`,`merge-headshot-bob`);return n.append(t,sr(`div`,`merge-headshot-hitmarker`,BV)),e.append(n),e}function HV(){let e=M(`div`,`merge-headshot-range`),t=M(`div`,`merge-headshot-track`);return t.append(VV()),e.append(sr(`div`,`merge-headshot-target`,RV),t),e}var UV={title:`HEADSHOT!`,buildScene:HV},WV=[`10`,`J`,`Q`,`K`,`A`],GV=19,KV=5,qV=9,JV=780,YV=70,XV=70,ZV=35;function QV(e){let t=WV.length-1,n=e-t/2;return{offsetPx:n*GV,titleSpreadFraction:n/t,tiltDegrees:n*KV,bottomPx:qV-n**2,dealLeadMs:JV-e*YV,flipLeadMs:160+(t-e)*XV,waveDelayMs:e*ZV}}function $V(e){return[[`--card-offset`,`${e.offsetPx}px`],[`--card-title-spread`,String(e.titleSpreadFraction)],[`--card-tilt`,`${e.tiltDegrees}deg`],[`--card-bottom`,`${e.bottomPx}px`],[`--card-deal-lead-ms`,`${e.dealLeadMs}ms`],[`--card-flip-lead-ms`,`${e.flipLeadMs}ms`],[`--card-wave-delay-ms`,`${e.waveDelayMs}ms`]]}function eH(){return[[`--card-flip-ms`,`160ms`]]}var tH=`<svg viewBox="0 0 10 9" aria-hidden="true"><path d="M5 8.5C5 8.5 0 5.3 0 2.6C0 1.1 1.2 0 2.6 0C3.6 0 4.5 .6 5 1.4C5.5 .6 6.4 0 7.4 0C8.8 0 10 1.1 10 2.6C10 5.3 5 8.5 5 8.5Z"/></svg>`;function nH(e,t){let n=M(`div`,`merge-flush-deal`);cr(n,$V(QV(t)));let r=M(`div`,`merge-flush-hop`),i=M(`div`,`merge-flush-card`),a=M(`div`,`merge-flush-face`);return a.append(M(`span`,`merge-flush-rank`,e)),a.insertAdjacentHTML(`beforeend`,tH),i.append(M(`div`,`merge-flush-back`),a),r.append(i),n.append(r),n}function rH(){let e=M(`div`,`merge-flush-table`);return cr(e,eH()),e.append(...WV.map(nH)),e}var iH={title:`ROYAL FLUSH!`,buildScene:rH},aH=[1,2,3,4],oH=14,sH=3,cH=3,lH=10,uH=20,dH=2,fH=28,pH=18,mH=.01,hH=1.5,gH=2200,_H=1,vH=120,yH=.35,bH=4,xH=65,SH=145;function CH(e){return Math.round(e/(Math.PI*pH)*360)}function wH(e){return uH-e*dH}function TH(e){return e.rowIndex*oH+e.depthIndex*sH}function EH(e,t,n){return Array.from({length:n},(r,i)=>e+(t-e)*i/(n-1))}function DH(){return aH.flatMap((e,t)=>Array.from({length:e},(n,r)=>({rowIndex:t,depthIndex:e-1-r})))}function OH(e,t){let n=bV(EH(15,105,e),t),r=bV(EH(xH,SH,e),t);return n.map((e,n)=>({angleDegrees:e+yV(-4,bH,t),depthScalePercent:Math.round(r[n])}))}function kH(e,t,n){let r=yV(240,380,n),i=t.angleDegrees*Math.PI/180,a=r*Math.cos(i),o=(r*Math.sin(i))**2/1560,s=yV(15,45,n),c=vV(o),l=vV(o+s),u=c+l,d=yV(540,1080,n),f=a>=0?1:-1,p=TH(e);return{depthIndex:e.depthIndex,launchAngleDegrees:t.angleDegrees,distanceFromHeadPinPx:p,layer:wH(e.depthIndex),flyXPx:Math.round(a*u/1e3),peakRisePx:Math.round(o),landingDropPx:s,riseMs:c,fallMs:l,flightMs:u,spinDegrees:Math.round(f*d*u/1e3),glintMs:Math.round(180/d*1e3),depthScalePercent:t.depthScalePercent,delayMs:Math.round(p/yH)}}function AH(e=Math.random){let t=DH(),n=OH(t.length,e);return t.map((t,r)=>kH(t,n[r],e))}function jH(e){return[[`--pin-left`,`${e.distanceFromHeadPinPx}px`],[`--pin-raise`,`${e.depthIndex*cH}px`],[`--pin-shade`,`${100-e.depthIndex*12}%`],[`--pin-fly-x`,`${e.flyXPx}px`],[`--pin-peak-y`,`${-e.peakRisePx}px`],[`--pin-land-y`,`${e.landingDropPx}px`],[`--pin-rise-ms`,`${e.riseMs}ms`],[`--pin-fall-ms`,`${e.fallMs}ms`],[`--pin-flight-ms`,`${e.flightMs}ms`],[`--pin-spin`,`${e.spinDegrees}deg`],[`--pin-glint-ms`,`${e.glintMs}ms`],[`--pin-depth-scale`,`${e.depthScalePercent}%`],[`--pin-depth-shade`,`${e.depthScalePercent-10}%`],[`--pin-delay`,`${e.delayMs}ms`],[`--pin-layer`,String(e.layer)]]}function MH(){return wH(hH)}function NH(){return Math.max(...DH().map(TH))+lH}function PH(){let e=NH(),t=fH+e+pH-_H;return[[`--ball-follow-px`,`${vH}px`],[`--ball-follow-ms`,`${Math.round(vH/yH)}ms`],[`--ball-follow-spin`,`${CH(vH)}deg`],[`--ball-size`,`${pH}px`],[`--ball-approach-spin`,`${gH}deg`],[`--ball-impact-inset`,`${t}px`],[`--ball-layer`,String(MH())],[`--rack-right`,`${fH}px`],[`--rack-width`,`${e}px`],[`--pin-width`,`${lH}px`]]}function FH(e=Math.random){return e()>=mH?null:Go[Math.floor(e()*Go.length)].sprite}var IH=`<svg viewBox="0 0 10 24" aria-hidden="true"><path class="merge-strike-pin-body" d="M5 0C7 0 7.6 2 7.2 4C6.9 5.6 6.3 6.6 6.4 8C6.6 10 9.6 12 9.6 16C9.6 19.5 8.4 22 7.6 24H2.4C1.6 22 .4 19.5 .4 16C.4 12 3.4 10 3.6 8C3.7 6.6 3.1 5.6 2.8 4C2.4 2 3 0 5 0Z"/><path class="merge-strike-pin-stripe" d="M3.1 5.2H6.9V6.2H3.1ZM3.4 7H6.6V8H3.4Z"/></svg>`;function LH(e){let t=M(`span`,`merge-strike-pin`);return t.append(sr(`span`,`merge-strike-pin-arc`,IH)),cr(t,jH(e)),t}function RH(){let e=FH();if(!e)return M(`span`,`merge-strike-ball`);let t=M(`span`,`merge-strike-ball is-animal`);return t.append(M(`span`,`nyan-sprite ${e}`)),t}function zH(){let e=M(`div`,`merge-strike-lane`);cr(e,PH());let t=M(`div`,`merge-strike-rack`);t.append(...AH().map(LH));let n=M(`div`,`merge-strike-track`);return n.append(RH()),e.append(t,n),e}var BH={title:`STRIKE!`,buildScene:zH},VH=20,HH=92,UH=23,WH=7,GH=-40;function KH(){let e=vV(72),t=vV(69),n=780*t/1e3;return{launchHeightPx:VH,peakHeightPx:HH,heightThroughRimPx:UH,heightLeavingNetPx:WH,heightOutOfCardPx:GH,riseMs:e,fallToRimMs:t,speedThroughRimPxPerSecond:n,netCatchMs:Math.round(32/n*1e3),dropMs:vV(47)}}function qH(e=KH()){return[[`--ball-launch-y`,`${-e.launchHeightPx}px`],[`--ball-peak-y`,`${-e.peakHeightPx}px`],[`--ball-rim-y`,`${-e.heightThroughRimPx}px`],[`--ball-net-exit-y`,`${-e.heightLeavingNetPx}px`],[`--ball-drop-out-y`,`${-e.heightOutOfCardPx}px`],[`--ball-rise-ms`,`${e.riseMs}ms`],[`--ball-fall-to-rim-ms`,`${e.fallToRimMs}ms`],[`--ball-to-rim-ms`,`${e.riseMs+e.fallToRimMs}ms`],[`--ball-net-catch-ms`,`${e.netCatchMs}ms`],[`--ball-drop-ms`,`${e.dropMs}ms`]]}var JH=`<svg viewBox="0 0 40 48" aria-hidden="true"><rect class="merge-swish-pole" x="36" y="28" width="2" height="20"/><rect class="merge-swish-backboard" x="35" y="2" width="3" height="26" rx="1"/><path class="merge-swish-rim" d="M31 18H35M7 18A12 2.5 0 0 1 31 18"/></svg>`,YH=`<svg viewBox="0 0 40 48" aria-hidden="true"><g class="merge-swish-net"><path d="M8 18L12 32M13.5 18L15.5 32M19 18V32M24.5 18L22.5 32M30 18L26 32M9.5 23Q19 25 28.5 23M11 28Q19 29.5 27 28"/></g><path class="merge-swish-rim" d="M7 18A12 2.5 0 0 0 31 18"/></svg>`;function XH(){let e=M(`div`,`merge-swish-ball-drift`),t=M(`div`,`merge-swish-ball-arc`);return t.append(M(`span`,`merge-swish-ball`)),e.append(t),e}function ZH(){let e=M(`div`,`merge-swish-court`);cr(e,qH());let t=M(`div`,`merge-swish-track`);return t.append(XH()),e.append(sr(`div`,`merge-swish-hoop-back`,JH),t,sr(`div`,`merge-swish-hoop-front`,YH)),e}var QH=[BH,{title:`SWISH!`,buildScene:ZH},MV,UV,iH],$H=48,eU=5600,tU=20,nU=null,rU=[],iU=null,aU=!1,oU=0;function sU(e){let t=M(`span`,`merge-confetti-piece`),n=M(`span`,`merge-confetti-arc`);return n.append(M(`span`,`merge-confetti-paper`)),t.append(n),cr(t,EV(e)),t}function cU(e){let t=M(`p`,`merge-celebration-title`);return t.setAttribute(`aria-hidden`,`true`),Array.from(e).forEach((e,n)=>{let r=M(`span`,`merge-celebration-letter`,e);r.style.setProperty(`--letter-delay`,`${n*45}ms`),t.append(r)}),t}function lU(e,t,n){let r=t.firstElementChild,i=t.lastElementChild;r instanceof HTMLElement&&i instanceof HTMLElement&&(e.style.setProperty(`--celebration-title-width`,`${i.offsetLeft+i.offsetWidth-r.offsetLeft}px`),e.style.setProperty(`--celebration-title-center-y`,`${t.offsetTop+t.offsetHeight/2-n.offsetTop}px`))}function uU(e){let t=M(`div`,`merge-celebration-scene`);return t.setAttribute(`aria-hidden`,`true`),t.append(e.buildScene()),t}function dU(){return QH[Math.floor(Math.random()*QH.length)]}function fU(e){if(Rs())try{yb(_V(e))}catch{}}function pU(e){let t=M(`ul`,`merge-celebration-details`);for(let n of e)t.append(M(`li`,`merge-celebration-detail`,n));return t}function mU(e,t,n){nU?.remove(),fU(n);let r=M(`div`,`merge-celebration`);r.setAttribute(`role`,`status`);let i=M(`div`,`merge-celebration-card`),a=M(`div`,`merge-celebration-stage`),o=cU(t.title),s=uU(t);a.append(o,M(`p`,`merge-celebration-message`,e.message),pU(e.detailLines),s);let c=M(`div`,`merge-confetti`);c.style.setProperty(`--confetti-scale`,String(wV(n)));for(let e=0;e<$H;e+=1)c.append(sU(e));i.append(c,a),r.append(i),document.body.append(r),lU(a,o,s),nU=r,window.setTimeout(()=>{r.remove(),nU===r&&(nU=null)},eU)}function hU(e){return aU?`playing`:e?`queued`:`empty`}function gU(){if(!iU)return;let e=rU.length>0;iU.tray.dataset.state=hU(e),iU.count.textContent=e?String(rU.length):``,iU.button.disabled=aU||!e}function _U(){let e=rU.shift();aU=e!==void 0,gU(),e&&(mU(e.text,e.scene,oU),oU+=1,window.setTimeout(_U,eU))}function vU(e,t,n){iU={tray:e,button:t,count:n},t.addEventListener(`click`,()=>{oU=0,_U()}),gU()}function yU(e,t=dU()){rU.push({text:e,scene:t}),rU.length>tU&&rU.shift(),gU()}var bU={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},xU=new Set([`FAILURE`,`ERROR`]);function SU(e){return bU[e]}function CU(e){return e.state===`MERGED`?`Already merged`:e.state===`OPEN`?e.isDraft?`Drafts cannot be merged`:e.isInMergeQueue?`Already in the merge queue`:e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?`Resolve the merge conflicts first`:e.checks.failing.length>0||e.checks.state!==null&&xU.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function wU(e){return e.state===`MERGED`?`merged`:e.isDraft?`draft`:e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?`conflicts`:e.mergeStateStatus===`BEHIND`?`behind`:e.checks.state===`FAILURE`||e.checks.state===`ERROR`?`checks-failing`:e.reviewDecision===`CHANGES_REQUESTED`?`changes-requested`:e.unresolvedThreads>0?`unresolved-threads`:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?`checks-pending`:e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?`needs-approval`:e.mergeable===`MERGEABLE`&&[`CLEAN`,`HAS_HOOKS`,`UNSTABLE`].includes(e.mergeStateStatus)?`ready`:`unknown`}function TU(e){let t=k.parse({...e,key:`${e.repo}#${e.number}`,stage:`unknown`});return{...t,stage:wU(t)}}function EU(e,t,n,r,i,a){return{isVisible:a&&(e.state===`OPEN`||t),isPressed:t,isDisabled:n,statusText:r||(n?`Saving`:i)}}function DU(e,t,n=``){if(!t||!e.keepMergeable)return null;let r=OU(e,!1,``,!0,n).statusText;if(e.isKeepMergeableFixInFlight)return{text:`Repairing`,tone:`warn`,title:r};let i=e.keepMergeableAttempt;return!i||i.outcome===`pushed`||i.outcome===`stopped`?null:{text:`Repair failed`,tone:`danger`,title:r}}function OU(e,t,n=``,r=!0,i=``){let a=e.keepMergeableAttempt,o=e.keepMergeable?`On`:`Off`;if(e.keepMergeable&&a&&a.outcome!==`pushed`&&a.outcome!==`stopped`){let e=i?` (${i})`:``;o=`Keep mergeable failed: ${a.reason??`The attempt produced no repair`}${e}`}return e.isKeepMergeableFixInFlight&&(o=`Keep mergeable is running`),EU(e,!!e.keepMergeable,t,n,o,r)}function kU(e){return e?.isKeepMergeableEnabled!==!1}function AU(e){return e?.isMergeQueueEnabled!==!1}function jU(e,t,n){return e?t?`Repair pushed, waiting for you`:n?`On, the last merge failed and retries an hour later once it is ready`:`On, merges as soon as it is ready`:`Not queued`}function MU(e,t,n=``,r=!0){let i=e.mergeQueuePosition!==null&&e.mergeQueuePosition!==void 0;return EU(e,i,t,n,jU(i,!!e.isMergeQueueHeldForRepairPush,!!e.mergeQueueFailure),r)}var NU=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],PU=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],FU={conflicts:`Needs you`,behind:`Needs you`,"checks-failing":`Needs you`,"changes-requested":`Needs you`,"unresolved-threads":`Needs you`,"checks-pending":`Waiting`,"needs-approval":`Waiting`,unknown:`Waiting`,ready:`Ready to merge`,draft:`Drafts`,merged:`Merged today`},IU={merged:`Merged`,draft:`Draft`,conflicts:`Merge conflicts`,behind:`Behind base`,"checks-failing":`Checks failing`,"changes-requested":`Changes requested`,"unresolved-threads":`Unresolved threads`,"checks-pending":`Checks running`,"needs-approval":`Needs approval`,ready:`Ready to merge`,unknown:`Status unknown`},LU={merged:`muted`,draft:`muted`,conflicts:`danger`,behind:`warn`,"checks-failing":`danger`,"changes-requested":`warn`,"unresolved-threads":`warn`,"checks-pending":`wait`,"needs-approval":`wait`,ready:`ok`,unknown:`muted`},RU={merged:`merged`,draft:`draft`,conflicts:`conflict`,behind:`behind`,"checks-failing":`failed`,"changes-requested":`changes-requested`,"unresolved-threads":`thread`,"checks-pending":`running`,"needs-approval":`reviewer`,ready:`ready`,unknown:`unknown`};function zU(e){let t=ft.safeParse(e);return t.success?t.data:null}function BU(e){let t=e.filter(e=>e.state===`OPEN`&&!e.isCrossRepository),n=new Map(t.map(e=>[JSON.stringify([e.repo.toLowerCase(),e.headRefName]),e])),r=new Map,i=[];for(let t of e){let e=t.state===`OPEN`?n.get(JSON.stringify([t.repo.toLowerCase(),t.baseRefName])):void 0;if(!e||e.key===t.key){i.push(t);continue}let a=r.get(e.key)??[];a.push(t),r.set(e.key,a)}let a=[],o=new Set;for(let t of[...i,...e]){if(o.has(t.key))continue;let e=[],n=[{pr:t,parentKey:null,depth:0}];for(;n.length>0;){let t=n.pop();if(!t||o.has(t.pr.key))continue;o.add(t.pr.key),e.push(t);let i=r.get(t.pr.key)??[];for(let e=i.length-1;e>=0;--e)n.push({pr:i[e],parentKey:t.pr.key,depth:t.depth+1})}a.push({root:t,rows:e})}return a}function VU(e){return NU[e.rows.reduce((e,{pr:t})=>Math.min(e,NU.indexOf(FU[t.stage])),NU.length-1)]}function HU(e){let t=new Map(NU.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of BU(e)){let e=t.get(VU(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return PU.flatMap(e=>t.get(e)??[])}function UU(e){return IU[e]}function WU(e){return LU[e]}function GU(e){return RU[e]}function KU(e){if(e.checks.failing.length>0){let t=e.checks.failing.length-3;return{label:`Checks`,tone:`danger`,icon:`failed`,text:`${e.checks.failing.length} failing: ${e.checks.failing.slice(0,3).join(`, `)}${t>0?` and ${t} more`:``}`}}return e.checks.state===`FAILURE`||e.checks.state===`ERROR`?{label:`Checks`,tone:`danger`,icon:`failed`,text:`Failing`}:e.checks.pendingCount>0?{label:`Checks`,tone:`wait`,icon:`running`,text:`${e.checks.pendingCount} running`}:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?{label:`Checks`,tone:`wait`,icon:`running`,text:`Running`}:e.checks.state===`SUCCESS`?{label:`Checks`,tone:`ok`,icon:`passed`,text:`Passing`}:{label:`Checks`,tone:`muted`,icon:`none`,text:`No checks`}}function qU(e){return`${e} ${e===1?`approval`:`approvals`}`}function JU(e){return e.reviewRequests.map(e=>e.name).join(`, `)}function YU(e){let t=e.reviewRequests.length>0?`Requested: ${JU(e)}`:`Approval required`;return e.approvals>0?`${t}, ${qU(e.approvals)}`:t}function XU(e){let t=e.approvals>0?qU(e.approvals):`Approved`;return e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`${t}, merge blocked`}:{label:`Review`,tone:`ok`,icon:`passed`,text:t}}function ZU(e){return e.reviewDecision===`CHANGES_REQUESTED`?{label:`Review`,tone:`warn`,icon:`changes-requested`,text:`Changes requested`}:e.reviewDecision===`APPROVED`?XU(e):e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:YU(e)}:e.reviewRequests.length>0?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`Requested: ${JU(e)}`}:{label:`Review`,tone:`muted`,icon:`none`,text:`No review requested`}}function QU(e,t){return t?e.lastAuthor!==t:null}function $U(e){let t=e.line===null?e.path:`${e.path}:${e.line}`;return e.isOutdated?`${t} (outdated)`:t}function eW(e){let t=e.commentCount-1;return t===0?`No replies`:`${t} ${t===1?`reply`:`replies`}, last by ${e.lastAuthor??`a deleted account`}`}function tW(e,t){let n=QU(e,t);return n===null?null:n?{tone:`warn`,icon:`your-turn`,text:`Waiting on you`}:{tone:`wait`,icon:`reviewer`,text:`Waiting on reviewer`}}function nW(e,t){return[...e.threads].sort((e,n)=>{let r=Number(QU(n,t)===!0)-Number(QU(e,t)===!0);return r===0?(Date.parse(n.lastActivityAt)||0)-(Date.parse(e.lastActivityAt)||0):r}).map(e=>({location:$U(e),url:e.url,author:e.author??`a deleted account`,excerpt:e.excerpt,replySummary:eW(e),lastActivityAt:e.lastActivityAt,waiting:tW(e,t)}))}function rW(e,t){if(e.unresolvedThreads===0)return{label:`Threads`,tone:`ok`,icon:`passed`,text:`None open`};let n=`${e.unresolvedThreads} unresolved`;if(!t||e.threads.length===0)return{label:`Threads`,tone:`warn`,icon:`thread`,text:n};let r=e.threads.filter(e=>QU(e,t)).length;return r===0?{label:`Threads`,tone:`wait`,icon:`thread`,text:`${n}, all waiting on reviewers`}:{label:`Threads`,tone:`warn`,icon:`your-turn`,text:`${n}, ${r} waiting on you`}}function iW(e){return e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?{label:`Conflicts`,tone:`danger`,icon:`conflict`,text:`Conflicts with ${e.baseRefName}`}:e.mergeable===`MERGEABLE`?{label:`Conflicts`,tone:`ok`,icon:`passed`,text:`None`}:{label:`Conflicts`,tone:`muted`,icon:`unknown`,text:`Not computed yet`}}function aW(e){let t=e.behindBy!==null&&e.behindBy>0;return e.mergeStateStatus===`BEHIND`?{label:`Base`,tone:`warn`,icon:`behind`,text:t?`${e.behindBy} behind ${e.baseRefName}`:`Behind ${e.baseRefName}`}:e.behindBy===null?{label:`Base`,tone:`muted`,icon:`unknown`,text:`Unknown`}:t?{label:`Base`,tone:`muted`,icon:`behind`,text:`${e.behindBy} behind ${e.baseRefName}, update not required`}:{label:`Base`,tone:`ok`,icon:`passed`,text:`Up to date with ${e.baseRefName}`}}var oW={APPROVED:{text:`Approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{text:`Requested changes`,tone:`warn`,icon:`changes-requested`},COMMENTED:{text:`Commented`,tone:`muted`,icon:`thread`},DISMISSED:{text:`Dismissed`,tone:`muted`,icon:`discarded`},PENDING:{text:`Pending`,tone:`wait`,icon:`running`}};function sW(e){return[...e.reviews].sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).map(e=>{let t=oW[e.state]??{text:e.state.toLowerCase().replaceAll(`_`,` `),tone:`muted`,icon:`unknown`};return{reviewer:e.reviewer??`a deleted account`,text:t.text,tone:t.tone,icon:t.icon,submittedAt:e.submittedAt}})}function cW(e,t=null){if(e.state===`MERGED`)return[];let n=[KU(e),ZU(e),rW(e,t),iW(e),aW(e)],r=e.autoRebase?[lW(e,e.autoRebase)]:[],i=e.mergeQueueFailure?[{label:`Merge when ready`,tone:`danger`,icon:`failed`,text:`Merge failed: ${e.mergeQueueFailure.message}`}]:[];return[...n,...r,...i]}function lW(e,t){return t.outcome===`rebased`?{label:`Auto-rebase`,tone:`ok`,icon:`passed`,text:t.message}:{label:`Auto-rebase`,tone:e.mergeStateStatus===`BEHIND`?`danger`:`warn`,icon:`failed`,text:t.message}}function uW(e){return e?e.configured?e.error&&e.prs.length===0?`Pull requests will show here once GitHub answers.`:`No open or recently merged pull requests found.`:`Enable Team review and set its GitHub organization in settings to see your pull requests.`:`Waiting for your pull requests.`}function dW(e,t=0){if(!e)return[];let n=YB(e,t),r=n?[{text:n,tone:`error`}]:[];return e.truncatedNote?[...r,{text:e.truncatedNote,tone:`info`}]:r}function fW(e,t){return e.flatMap(e=>{let n=t(e.key);if(!n)return[];let r=e.key.slice(0,e.key.lastIndexOf(`#`));return[{...TU({...n,repo:r}),...e}]})}function pW(e){let t=new Map;for(let n of e)for(let e of n.links){let r=In(e),i=t.get(r)??[];i.at(-1)?.id!==n.id&&(i.push({id:n.id,title:n.title}),t.set(r,i))}return t}function mW(e,t){let n=e.flatMap(e=>e.prs);return t&&n.some(e=>e.key===t)?t:n[0]?.key??null}function hW(e,t){if(!e)return[];let n=new Set(e.filter(e=>e.state===`OPEN`).map(e=>e.key));return t.filter(e=>e.state===`MERGED`&&n.has(e.key))}var gW=3;function _W(e){if(e.length===1)return{message:`Merged ${e[0].key}`,detailLines:[e[0].title]};let t=e.slice(0,gW).map(e=>`${e.key} ${e.title}`),n=e.length-t.length,r=n>0?[...t,`and ${n} more`]:t;return{message:`Merged ${e.length} pull requests`,detailLines:r}}var vW={isVisible:!1,isDisabled:!0,statusText:``,tone:null},yW={merged:{statusText:`Merged on GitHub. Refreshing the list.`,tone:`ok`},queued:{statusText:`Added to the merge queue. Refreshing the list.`,tone:`ok`},"auto-merge":{statusText:`Auto-merge enabled. GitHub merges it once its requirements pass.`,tone:`ok`},unconfirmed:{statusText:`GitHub accepted the request but did not confirm a merge. Check GitHub.`,tone:null}};function bW(e,t){if(e.state!==`OPEN`)return vW;let n=t?.head===e.headRefOid?t:void 0;if(n?.phase===`pending`)return{isVisible:!0,isDisabled:!0,statusText:`Merging on GitHub`,tone:`busy`};if(n&&n.phase!==`failed`)return{isVisible:!0,isDisabled:!0,...yW[n.phase]};let r=CU(e);return r?{isVisible:!0,isDisabled:!0,statusText:r,tone:null}:n?.phase===`failed`?{isVisible:!0,isDisabled:!1,statusText:n.text,tone:`error`}:{isVisible:!0,isDisabled:!1,statusText:`Merges into ${e.baseRefName} with ${SU(e.mergeMethod)}`,tone:null}}function xW(e){return`Merge ${e.key} "${e.title}" into ${e.baseRefName} with ${SU(e.mergeMethod)}, your default for this repository. Glimmervoid does not delete the branch.`}function SW(e){let t=ht.safeParse(e);if(!t.success)return null;let n=e&&typeof e==`object`&&`requestId`in e?e.requestId:null;return typeof n==`string`?{...t.data,requestId:n}:null}var CW=null,wW=null,TW=null,EW=null,DW=null,OW=null,kW=null,AW=null,jW=new Map,MW=new Set,NW=new Map,PW=new Map,FW=!1,IW=null,LW={label:`Keep mergeable`,pendingKeys:new Set,errorsByKey:new Map,controlState:(e,t,n,r)=>OU(e,t,n,r,Pf(e.keepMergeableAttempt?.at)),isFeatureEnabled:kU,save:async(e,t)=>{let n=await _d(`my-pr-keep-mergeable`,{repo:e.repo,number:e.number,keepMergeable:t},{timeoutMs:q});if(n.type!==`my-pr-keep-mergeable-result`||n.key!==e.key)throw Error(`Unexpected keep mergeable reply.`);return n.ok?null:n.error??`Could not save Keep mergeable.`}},RW={label:`Merge when ready`,pendingKeys:new Set,errorsByKey:new Map,controlState:MU,isFeatureEnabled:AU,save:async(e,t)=>{let n=await _d(`my-pr-merge-when-ready`,{repo:e.repo,number:e.number,mergeWhenReady:t},{timeoutMs:q});if(n.type!==`my-pr-merge-when-ready-result`||n.key!==e.key)throw Error(`Unexpected merge when ready reply.`);return n.ok?null:n.error??`Could not save Merge when ready.`}},zW=6e4,BW=6e4,VW=`The server did not answer within ${zW/1e3} s. Check GitHub before trying again.`,HW=`${G} Check GitHub before trying again.`;function UW(e,t){let n=M(`div`,`reviews-refresh-control`),r=M(`button`,`pr-action pr-action-ghost reviews-refresh-button`,`Refresh`);r.type=`button`;let i=M(`span`,`reviews-refresh-status`);i.setAttribute(`role`,`status`);let a=M(`p`,`my-pr-error reviews-retry-notice`);n.append(r,i);let o=null,s=!1,c=``,l=null;function u(){a.textContent=YB(o,Date.now()),a.hidden!==!o?.error&&(a.hidden=!o?.error);let e=a.isConnected&&!vr(t)&&!document.hidden&&a.getClientRects().length>0&&JB(o,Date.now());!e&&l!==null&&(window.clearInterval(l),l=null),e&&l===null&&(l=window.setInterval(u,1e3))}function d(e){e!==o&&(c=``),o=e,r.disabled=s||!!e?.isRefreshing||!e?.configured,i.textContent=XB(e,s,c),i.hidden=!i.textContent,u()}r.addEventListener(`click`,async()=>{if(!s){s=!0,c=``,d(o);try{let t=await _d(`github-polling-refresh`,{lane:e},{timeoutMs:BW});t.type===`github-polling-refresh-result`&&(c=t.ok?`Refreshed.`:t.error??`Could not refresh from GitHub.`)}catch(e){c=Ad(e,BW)}finally{s=!1,d(o)}}});let f=new MutationObserver(u);f.observe(t,{attributes:!0,subtree:!0,attributeFilter:[`hidden`,`data-queue-collapsed`]});for(let e=t.parentElement;e;e=e.parentElement)f.observe(e,{attributes:!0,attributeFilter:[`hidden`,`data-queue-collapsed`]});return document.addEventListener(`visibilitychange`,u),{control:n,notice:a,update:d}}function WW(e,t,n,r){jW.set(e,{head:t,phase:n,text:r}),sG()}function GW(e){if(NW.has(e.key))return;let t=gd(`my-pr-merge`);if(!K({type:`my-pr-merge`,requestId:t,repo:e.repo,number:e.number,headRefOid:e.headRefOid})){WW(e.key,e.headRefOid,`failed`,G);return}let n=window.setTimeout(()=>{NW.delete(e.key),WW(e.key,e.headRefOid,`failed`,VW)},zW);NW.set(e.key,{requestId:t,head:e.headRefOid,timer:n}),jW.set(e.key,{head:e.headRefOid,phase:`pending`,text:``}),sG()}function KW(e){let t=bW(e,jW.get(e.key));if(!t.isVisible)return null;let n=M(`div`,`my-pr-merge`),r=M(`button`,`pr-action`,`Merge`);r.type=`button`,r.disabled=t.isDisabled;let i=M(`span`,`pr-action-status`,t.statusText);return i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`),t.tone&&(i.dataset.tone=t.tone),r.addEventListener(`click`,()=>{rf({title:`Merge pull request`,message:xW(e),confirmLabel:`Merge`,onConfirm:()=>GW(e)})}),n.append(r,i),n}function qW(e,t){let n=t.controlState(e,t.pendingKeys.has(e.key),t.errorsByKey.get(e.key),t.isFeatureEnabled(DW));if(!n.isVisible)return null;let r=M(`div`,`my-pr-merge`),i=M(`button`,`pr-action`,t.label);i.type=`button`,i.disabled=n.isDisabled,i.setAttribute(`aria-pressed`,String(n.isPressed));let a=M(`span`,`pr-action-status`,n.statusText);return a.setAttribute(`role`,`status`),a.setAttribute(`aria-live`,`polite`),i.addEventListener(`click`,async()=>{if(!t.pendingKeys.has(e.key)){t.pendingKeys.add(e.key),t.errorsByKey.delete(e.key),sG();try{let r=await t.save(e,!n.isPressed);r&&t.errorsByKey.set(e.key,r)}catch(n){t.errorsByKey.set(e.key,Ad(n,q))}finally{t.pendingKeys.delete(e.key),sG()}}}),r.append(i,a),r}function JW(e,{hasGlyph:t}){let n=M(`span`,`my-pr-stage`);return n.dataset.tone=WU(e.stage),t&&n.append(iv(GU(e.stage),WU(e.stage))),n.append(UU(e.stage)),n}function YW(e,t){let n=M(`span`,`my-pr-requested`);n.append(M(`span`,null,`Requested`));let r=M(`span`,`avatar-stack`);for(let t of e.reviewRequests){let e=lr({login:t.name,url:t.isTeam?t.avatarUrl:void 0,cssPx:16});e.title=t.name,e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,t.name),r.append(e)}return n.append(r,M(`span`,`my-pr-requested-names`,t.slice(11))),n}function XW(){if(!CW||!wW||TW?.isConnected)return;let e=aV({queueLabel:`My pull requests`,scopeTabs:wW,resizerLabel:`Resize pull request list`});TW=e.queue,EW=e.detail,CW.replaceChildren(e.columns),AW&&e.foot.append(AW.control)}function ZW(e){if(!EW)return;if(!e){EW.replaceChildren(M(`p`,`pr-empty`,uW(DW)));return}let t=M(`article`,`pr-detail`),n=M(`div`,`pr-detail-heading`),r=M(`div`,`pr-detail-title`);r.append(dr(`pr-link`,e.key,e.url),M(`h2`,null,e.title)),n.append(r,JW(e,{hasGlyph:!0})),t.append(n);for(let n of[LW,RW]){let r=qW(e,n);r&&t.append(r)}let i=cW(e,DW?.viewer??null);if(i.length>0){let n=M(`section`,`pr-readiness-section`);n.append(M(`h3`,`pr-section-heading`,`Merge readiness`));let r=M(`ul`,`pr-readiness`);for(let t of i){let n=M(`li`,`pr-readiness-row`),i=M(`span`,`pr-readiness-value`);t.label===`Review`&&t.text.startsWith(`Requested: `)&&i.append(YW(e,t.text)),i.childNodes.length===0&&(i.textContent=t.text),n.append(iv(t.icon,t.tone),M(`span`,`pr-readiness-label`,t.label),i),r.append(n)}n.append(r);let a=KW(e);a&&n.append(a),t.append(n)}if(e.checks.failing.length>0){let n=M(`section`,`my-pr-failures`);n.append(M(`h3`,`pr-section-heading`,`Failing checks`));let r=M(`ul`,`my-pr-facts`);for(let t of e.checks.failing)r.append(M(`li`,null,t));n.append(r),t.append(n)}let a=sW(e);if(a.length>0){let e=M(`section`,`pr-readiness-section`);e.append(M(`h3`,`pr-section-heading`,`Reviews`));let n=M(`ul`,`pr-readiness`);for(let e of a){let t=M(`li`,`pr-readiness-row`),r=Date.parse(e.submittedAt??``),i=Number.isFinite(r)?`${e.text} ${Pf(r)}`:e.text,a=M(`span`,`my-pr-reviewer`);a.append(ur([{login:e.reviewer,tone:e.tone,title:e.reviewer,url:e.reviewer===`a deleted account`?null:void 0}],16),M(`span`,null,e.reviewer)),t.append(iv(e.icon,e.tone),a,M(`span`,`pr-readiness-value`,i)),n.append(t)}e.append(n),t.append(e)}let o=nW(e,DW?.viewer??null);if(o.length>0){let e=M(`section`,`my-pr-threads-section`);e.append(M(`h3`,`pr-section-heading`,`Unresolved threads`));let n=M(`ul`,`my-pr-threads`);for(let e of o){let t=M(`li`,`my-pr-thread`),r=M(`div`,`my-pr-thread-heading`);if(r.append(dr(`my-pr-thread-location`,e.location,e.url)),e.waiting){let t=M(`span`,`my-pr-stage`);t.dataset.tone=e.waiting.tone,t.append(iv(e.waiting.icon,e.waiting.tone),e.waiting.text),r.append(t)}let i=M(`p`,`my-pr-thread-excerpt`);i.append(M(`strong`,null,e.author),` ${e.excerpt}`);let a=Date.parse(e.lastActivityAt),o=M(`p`,`my-pr-thread-meta`,Number.isFinite(a)?`${e.replySummary}, ${Pf(a)}`:e.replySummary);t.append(r,i,o),n.append(t)}e.append(n),t.append(e)}let s=M(`p`,`pr-detail-meta`);s.append(M(`span`,null,`Opened ${Pf(Date.parse(e.createdAt))}`),M(`span`,null,`${e.state===`MERGED`?`Merged`:`Updated`} ${Pf(Date.parse(e.state===`MERGED`?e.mergedAt??``:e.updatedAt))}`)),t.append(s),EW.replaceChildren(t)}function QW(){return[...PW].flatMap(([e,t])=>{let n=F.get(e);return!n||t.length===0?[]:[{id:e,title:Sr(n)||e,links:t}]})}function $W(e){let t=e.dataset.sessionId??``,n=F.get(t),r=P(e,`.session-row-name`);n&&(r.textContent=Sr(n)||t);let i=bv(e,{glyph:P(e,`.session-row-glyph`),label:P(e,`.session-row-label`)},n?.currentState||j.DORMANT,n?.awaitingBackgroundTasks,n?.pendingPromptKind),a=`Focus session ${r.textContent}, ${i}`;e.title=a,e.setAttribute(`aria-label`,a)}function eG(e){let{row:t,refs:n}=vv(`button`,`my-pr-session-pill`);return t.type=`button`,t.dataset.sessionId=e.id,n.name.textContent=e.title,$W(t),t.addEventListener(`click`,()=>IW?.(e.id)),t}function tG(e){if(!e||e.length===0)return null;let t=M(`div`,`my-pr-session-focus`);return t.append(...e.map(eG)),t}function nG(){for(let e of TW?.querySelectorAll(`.my-pr-session-pill`)??[])$W(e)}function rG(){FW||(FW=!0,queueMicrotask(()=>{FW=!1,sG()}))}function iG(e){PW=e,rG()}function aG(e){let t=fW(DW?.prs??[],Hn).find(t=>In(t)===e.toLowerCase());return t?oG(t.key):null}function oG(e){return TW?[...TW.querySelectorAll(`button[data-pr-key]`)].find(t=>t.dataset.prKey===e)??null:null}function sG(){let e=fW(DW?.prs??[],Hn),t=hW(OW,e);if(OW=e,uG(t),XW(),!TW)return;let n=HU(e);kW=mW(n,kW);let r=document.activeElement instanceof HTMLElement&&TW.contains(document.activeElement)?document.activeElement.dataset.prKey:null,i=pW(QW()),a=n.filter(e=>e.rows.length>0).map(e=>{let t=M(`section`,`pr-queue-section`);t.append(M(`h3`,`pr-section-heading`,`${e.title} ${e.rows.length}`));for(let{pr:n,parentKey:r,depth:a}of e.rows){let e=M(`button`,`pr-queue-row`);e.type=`button`,e.dataset.prKey=n.key,r&&(e.style.paddingInlineStart=`${12+Math.min(a,6)*16}px`),e.setAttribute(`aria-current`,String(n.key===kW)),e.title=`${n.key}: ${UU(n.stage)}`;let o=M(`span`,`pr-queue-glyph`);o.append(iv(GU(n.stage),WU(n.stage)));let s=M(`span`,`pr-queue-top`);s.append(M(`strong`,`pr-queue-ref`,n.key),M(`span`,`pr-queue-title`,n.title));let c=M(`span`,`pr-queue-bottom`);r&&c.append(M(`span`,`my-pr-stage`,`Stacked on ${r}`));let l=n.state===`MERGED`?n.mergedAt:null,u=l?`merged ${Pf(Date.parse(l))}`:`opened ${Pf(Date.parse(n.createdAt))}`;c.append(JW(n,{hasGlyph:!1}),M(`span`,`pr-queue-elapsed`,u));let d=DU(n,LW.isFeatureEnabled(DW),Pf(n.keepMergeableAttempt?.at));if(d){let e=M(`span`,`my-pr-stage`,d.text);e.dataset.tone=d.tone,e.title=d.title,c.append(e)}e.append(o,s,c),e.addEventListener(`click`,()=>{kW=n.key;for(let e of TW?.querySelectorAll(`button[data-pr-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.prKey===kW));ZW(n),document.documentElement.dataset.layout===`phone`&&EW?.scrollIntoView({block:`start`,behavior:`smooth`})});let f=M(`div`,`my-pr-row-group`);f.append(e),t.append(f);let p=tG(i.get(In(n)));p&&(r&&(p.style.paddingInlineStart=`${36+Math.min(a,6)*16}px`),f.append(p))}return t});if(a.length===0&&TW.replaceChildren(M(`p`,`pr-empty`,uW(DW))),a.length>0){let e=dW(DW,Date.now()).filter(e=>e.tone!==`error`).map(e=>M(`p`,e.tone===`error`?`my-pr-error`:`my-pr-note`,e.text));TW.replaceChildren(...e,...a)}AW&&(TW.prepend(AW.notice),AW.update(DW)),r&&oG(r)?.focus({preventScroll:!0}),ZW(e.find(e=>e.key===kW))}function cG(e,t,n){return IW=n?.openTerminal??null,CW||(wW=t,CW=M(`div`,`pr-content`),e.append(CW),AW=UW(`my-prs`,CW),sG(),CW)}function lG(e){let t=zU(e);t&&(DW=t,sG())}function uG(e){let t=e.filter(e=>!MW.has(e.key));if(t.length!==0){for(let e of t)MW.add(e.key);yU(_W(t))}}function dG(e){if(!e){for(let[e,t]of NW)window.clearTimeout(t.timer),jW.set(e,{head:t.head,phase:`failed`,text:HW});NW.size!==0&&(NW.clear(),sG())}}function fG(e){let t=SW(e);if(!t)return;let n=NW.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),NW.delete(t.key),!t.ok){WW(t.key,n.head,`failed`,t.error||`The merge failed.`);return}if(WW(t.key,n.head,t.kind??`unconfirmed`,``),t.kind!==`merged`)return;let r=fW(DW?.prs??[],Hn).find(e=>e.key===t.key);r&&uG([r])}Un(rG);var pG=ue.options.join(`|`),mG=String.raw`\*\*(?:\[([^\]\n]+)\]\s+)?(${pG})\*\*`;function hG(e){return[...e.matchAll(new RegExp(mG,`g`))].flatMap(e=>{let t=ue.safeParse(e[2]);return t.success?[t.data]:[]})}function gG(e){let t=new RegExp(String.raw`^${mG}\s*(?:\r?\n|$)`).exec(e);if(!t)return null;let n=ue.safeParse(t[2]);return n.success?{reviewer:t[1]??null,severity:n.data,length:t[0].length}:null}function _G(e){let t=e.trimStart();return t.startsWith(`> [!NOTE]
166
- > Automated review. Not written by a human.`)?t.slice(53).trim():e.trim()}function vG(e,t){if(!e)return null;let n=e=>{let n=t(e.key);return n?{...e,checksState:n.rollupState,reviewDecision:xe(n.reviewDecision,n.opinionatedWriterReviewStates),isDraft:n.isDraft,liveHead:n.headRefOid,prStage:TU(n).stage}:e};return{...e,drafts:e.drafts.map(n),inFlight:e.inFlight.map(n),queued:e.queued.map(n),handReview:e.handReview.map(n)}}var yG={"direct-request":`Needs you`,"team-request":`Ready`,"changes-requested":`Author to fix`,"checks-failing":`Checks failing`,"checks-pending":`Checks running`,draft:`Draft`,"review-available":`Ready`,approved:`Approved`};function bG(e){return e.isDraft?{band:`not-ready`,reason:`draft`}:e.reviewDecision===`CHANGES_REQUESTED`?{band:`waiting-on-author`,reason:`changes-requested`}:e.checksState===`FAILURE`||e.checksState===`ERROR`?{band:`waiting-on-author`,reason:`checks-failing`}:e.checksState===`PENDING`||e.checksState===`EXPECTED`?{band:`not-ready`,reason:`checks-pending`}:e.requestSource===`direct`&&e.reviewDecision===`REVIEW_REQUIRED`?{band:`blocking-others`,reason:`direct-request`}:e.reviewDecision===`APPROVED`?{band:`actionable`,reason:`approved`}:{band:`actionable`,reason:e.requestSource===`direct`?`review-available`:`team-request`}}var xG={APPROVE:{label:`You approved`,tone:`ok`,icon:`passed`},COMMENT:{label:`You commented`,tone:`muted`,icon:`thread`}},SG={APPROVED:{label:`You approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{label:`You requested changes`,tone:`wait`,icon:`changes-requested`},COMMENTED:{label:`You commented`,tone:`muted`,icon:`thread`}};function CG(e){let t=(e.githubReviews??[]).filter(e=>e.isViewer).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!e.postedEvent)return t?SG[t.state]:null;if(!t)return xG[e.postedEvent];let n=Date.parse(t.submittedAt??``);return Number.isNaN(n)||e.postedAt!==void 0&&e.postedAt>n?xG[e.postedEvent]:SG[t.state]}var wG={"changes-requested":`changes-requested`,"checks-failing":`failed`,"checks-pending":`running`,draft:`draft`};function TG(e){let{reason:t}=bG(e),n=wG[t];return n?{text:yG[t],icon:n}:null}function EG(e){return TG(e)?.text??null}var DG={discarded:{tone:`muted`,icon:`discarded`,meaning:`Not mine`},handReview:{tone:`warn`,icon:`fork`,meaning:`From a fork`}};function OG(e,t){let n=EG(t);return n?`${e}, ${n}`:e}function kG(e){if(Se(e))return!0;let t=(e.githubReviews??[]).filter(e=>e.isViewer);return t.length===0||t.some(t=>t.commit===aK(e))}var AG={tone:`warn`,icon:`your-turn`,meaning:`Comments resolved`};function jG(e,t){if(e.prStage)return{tone:WU(e.prStage),icon:GU(e.prStage),meaning:UU(e.prStage)};let n=DG[t];if(n)return n;if(t===`inReview`)return{tone:`wait`,icon:`running`,meaning:OG(`In review`,e)};if(t===`queued`)return{tone:`muted`,icon:`queued`,meaning:OG(`Queued`,e)};if(t===`settled`&&`reviewedHead`in e){let t=kG(e)?CG(e):null;return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`ok`,icon:`passed`,meaning:`Others reviewed`}}if(t===`posted`&&`reviewedHead`in e){let t=CG(e);return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`muted`,icon:`none`,meaning:`Posted`}}if(t===`attention`&&`status`in e)return e.status===`error`?{tone:`danger`,icon:`failed`,meaning:`Review failed`}:{tone:`warn`,icon:`stale`,meaning:`Out of date`};let r=TG(e);return r?{tone:`wait`,icon:r.icon,meaning:r.text}:t===`ready`&&`reviewedHead`in e&&PG(e)?AG:{tone:`warn`,icon:`your-turn`,meaning:`Waits on you`}}function MG(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function NG(e){return e.status===`posted`&&PG(e)}function PG(e){if(!MG(e)||Se(e))return!1;let t=aK(e);return e.status===`posted`&&e.postedEvent===`APPROVE`&&e.reviewedHead===t?!1:!(e.githubReviews??[]).some(e=>e.isViewer&&e.state===`APPROVED`&&e.commit===t)}function FG(e){return!e||e.total===0?null:e.total===1?e.resolved===1?`Your 1 comment resolved`:`Your 1 comment unresolved`:e.resolved===e.total?`All ${e.total} of your comments resolved`:`${e.resolved} of ${e.total} of your comments resolved`}function IG(e){return`${e} ${e===1?`comment`:`comments`}`}function LG(e,t,n){let r=[`${IK(e.repo,e.number)}: ${e.title}`],i=`reviewedHead`in e?e.assessment?.goal.trim():``;if(i&&r.push(i),r.push(jG(e,t).meaning),n.opened&&r.push(`Opened ${n.opened}`),n.reviewed&&r.push(`Reviewed ${n.reviewed}`),n.posted&&r.push(`Posted ${n.posted}`),!(`reviewedHead`in e))return r.join(`
167
- `);let a=FG(e.viewerThreads);a&&r.push(a);let o=e.comments.length;e.status!==`error`&&r.push(`Automated review: ${ZG(e.verdict)}, ${IG(o)}`);let s=pK(e);s&&r.push(`You ${$G[s.state]} at ${T(s.approvedCommit)}${n.viewerApproval?` ${n.viewerApproval}`:``}; new commits since.`),(t===`attention`||t===`discarded`)&&r.push(nq(e));let c=_K(e,{isViewerShown:t!==`posted`});for(let[e,t]of c.entries())r.push(gK(t.text,n.githubReviews?.[e]??null));return r.join(`
168
- `)}function RG(e){let t=e.inReview.length+e.queued.length;return t===0?``:` ${t} ${t===1?`review is`:`reviews are`} still running.`}function zG(e){return e.ready.length+e.attention.length+e.handReview.length>0?null:`Nothing needs you right now.${RG(e)}`}function BG(e,t){return[...e.ready,...e.attention].filter(e=>e.key!==t).length>0?{kind:`banner`,title:`New pull requests need you`,detail:`Pick one from the queue.`}:e.handReview.length>0?{kind:`handReview`,detail:`From a fork, so the agent cannot check out its branch. Review on GitHub.${RG(e)}`}:{kind:`banner`,title:`All caught up`,detail:zG({...e,ready:[],attention:[]})??``}}function VG(e){let t=e.trim();return t.endsWith(`.`)?t:`${t}.`}function HG({action:e,pullRequest:t,warning:n,isActedSelected:r}){let i=pq(e),a=`${t}: ${VG(i)}`;return n.trim()?{statusText:i,shouldAdvance:!1,notice:{text:`${a} ${VG(n)}`,tone:`error`}}:{statusText:i,shouldAdvance:r,notice:null}}function UG(e){let t=[...e.ready,...e.noReviewNeeded,...e.inReview,...e.queued,...e.handReview,...e.attention,...e.posted,...e.discarded];return new Set(t.map(e=>e.repo)).size>1}function WG(e,t,n){return n?IK(e,t):`#${t}`}var GG={CRITICAL:{filledCount:3,colorToken:`--state-failed`},HIGH:{filledCount:3,colorToken:`--state-waiting`},MEDIUM:{filledCount:2,colorToken:`--accent`},LOW:{filledCount:1,colorToken:`--text-dim`}},KG={APPROVE:`check`,"APPROVE WITH NITS":`dot`,"REQUEST CHANGES":`bar`,BLOCKED:`cross`},qG=`lanes-team-review`,JG=`team-review-enabled`,YG=Object.freeze({APPROVE:`approve`,"APPROVE WITH NITS":`approve with nits`,"REQUEST CHANGES":`request changes`,BLOCKED:`blocked`}),XG={APPROVE:`Approve`,"APPROVE WITH NITS":`Nits`,"REQUEST CHANGES":`Changes`,BLOCKED:`Blocked`};function ZG(e){return XG[e]}var QG=Object.freeze({APPROVE:`ok`,"APPROVE WITH NITS":`info`,"REQUEST CHANGES":`warn`,BLOCKED:`crit`}),$G=Object.freeze({APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`commented`}),eK=Object.freeze({preparing:`fetching the diff`,checkout:`checking out the head`,reviewing:`agent reviewing`}),tK=Object.freeze({approve:`Approved on GitHub`,"approve-only":`Approved on GitHub`,comment:`Comment posted on GitHub`,discard:`Marked not mine. Not reviewed again until queued.`,requeue:`Queued. The review starts as soon as a slot is free.`,"resolve-thread":`Thread resolved on GitHub`}),nK=Object.freeze({approve:`Posting the approval`,"approve-only":`Posting the approval`,comment:`Posting the comment`,discard:`Marking not mine`,requeue:`Queueing the review`,"resolve-thread":`Resolving thread`});function rK(e){let t={ready:[],noReviewNeeded:[],inReview:[],queued:[],handReview:[],attention:[],posted:[],discarded:[]};if(!e)return t;let n={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},r={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},i=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`],a=new Set(e.inFlight.map(e=>e.key));t.inReview.push(...e.inFlight);let o=new Set(e.drafts.filter(e=>oK(e).length>0).map(e=>e.key));t.handReview.push(...e.handReview.filter(e=>!a.has(e.key)&&!o.has(e.key)));let s=new Set(t.handReview.map(e=>e.key));for(let t of e.queued)a.has(t.key)||s.has(t.key)||r[bG(t).band].push(t);for(let e of i)t.queued.push(...r[e]);let c=new Set(t.queued.map(e=>e.key));for(let r of e.drafts){if(a.has(r.key)||c.has(r.key)||s.has(r.key))continue;if(oK(r).length>0||NG(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!dK(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[bG(r).band].push(r),(r.status===`stale`||r.status===`error`)&&!e&&t.attention.push(r),r.status===`posted`&&t.posted.push(r),r.status===`discarded`&&t.discarded.push(r)}for(let e of i)t.ready.push(...n[e]);return t}function iK(e,t){return e.commit===t?e.isViewer||ge.has(e.state):!1}function aK(e){return e.liveHead??e.reviewedHead}function oK(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function sK(e,t){if(e.isNit)return{label:`Automatic resolution failed`,reason:``,tone:`warn`};let n=e.judgement?.head===t&&e.judgement.lastReplyAt===e.lastReplyAt?e.judgement:void 0;if(n)return{label:n.addressed?`Addressed`:`Not addressed`,reason:n.reason,tone:n.addressed?`ok`:`warn`};let r=e.unjudgeable?.head===t&&e.unjudgeable.lastReplyAt===e.lastReplyAt?e.unjudgeable:void 0;return r?{label:`Auto-check skipped`,reason:r.reason,tone:`muted`}:{label:`Auto-check pending`,reason:``,tone:`muted`}}function cK(e){return(e.threads??[]).filter(e=>!e.isResolved&&(!e.isNit||e.resolveError)).map(t=>{let n=sK(t,aK(e));return{thread:t,location:t.line===null?t.path:`${t.path}:${t.line}`,judgementLabel:n.label,judgementReason:n.reason,judgementTone:n.tone,judgementText:n.reason?`${n.label}: ${n.reason}`:n.label,canResolve:t.viewerCanResolve}})}var lK=40;function uK(e,t){return e.split(`
169
- `).reduce((e,t)=>e+Math.max(1,Math.ceil(t.length/lK)),0)>t}function dK(e){return oK(e).length>0?!0:Se(e)?!1:PG(e)?!0:!(e.githubReviews??[]).some(t=>iK(t,aK(e)))}function fK(e,t){let n=$G[e.state];return e.isViewer?e.commit===t?`you ${n}`:`you ${n} (older commit)`:`${n} by ${e.login}`}function pK(e){if(Se(e))return null;let t=(e.githubReviews??[]).filter(e=>e.isViewer&&ge.has(e.state)).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!t?.commit||t.commit===aK(e)||t.state===`COMMENTED`)return null;let n=Date.parse(t.submittedAt??``);return e.reviewedAt!==void 0&&n>e.reviewedAt?null:{approvedCommit:t.commit,submittedAt:t.submittedAt,state:t.state,isReviewScopeSinceDecision:e.priorReviewedHead===t.commit}}function mK(e,t){let n=e.state===`APPROVED`?`approved this`:`requested changes`,r=e.state===`APPROVED`?`your approval`:`your request for changes`,i=`You ${n} at ${T(e.approvedCommit)}${t?` ${t}`:``}. It has new commits since`;return e.isReviewScopeSinceDecision?`${i}, so this review covers what changed after ${r}.`:`${i}.`}function hK(e){return e===`APPROVED`?`ok`:e===`CHANGES_REQUESTED`?`warn`:`muted`}function gK(e,t){return t?`${e}, ${t}`:e}function _K(e,{isViewerShown:t=!0}={}){return(e.githubReviews??[]).filter(e=>t||!e.isViewer).sort((e,t)=>Number(t.isViewer)-Number(e.isViewer)).map(t=>({login:t.login,tone:hK(t.state),text:fK(t,aK(e)),submittedAt:t.submittedAt}))}function vK(e){return e.ready.length+e.noReviewNeeded.length+e.inReview.length+e.queued.length+e.handReview.length+e.attention.length+e.posted.length+e.discarded.length>0}function yK(e){return[...e.ready,...e.attention].map(e=>e.key)}function bK({capturedOrder:e,actedKey:t,groups:n}){let r=yK(n).filter(e=>e!==t),i=new Set(r);return e.slice(e.indexOf(t)+1).find(e=>i.has(e))||(e.find(e=>i.has(e))??r[0]??null)}function xK(e,t,n=!1){if(n&&t===null)return null;let r=[...e.ready,...e.inReview,...e.queued,...e.noReviewNeeded,...e.attention,...e.posted,...e.discarded];return t&&r.some(e=>e.key===t)?t:r[0]?.key??null}function SK(e){return GG[e]}function CK(e){return KG[e]}function wK(e){let t=hG(e.body);return t.length>0?t:e.severity?[e.severity]:[]}function TK(e){let t=wK(e);return ue.options.find(e=>t.includes(e))??null}function EK(e){return TK(e)!==`LOW`}var DK=new Set(`ts.tsx.js.jsx.mjs.cjs.json.jsonc.css.scss.less.html.md.mdx.py.go.rs.rb.java.kt.kts.swift.c.h.cc.cpp.hpp.cs.php.sh.bash.zsh.yml.yaml.toml.ini.sql.vue.svelte.astro.lock.txt.ex.exs.erl.scala.dart.lua.tf.proto.graphql.gql.xml.gradle`.split(`.`)),OK=/^([\w.@~/-]+):\d+(?:-\d+)?$/;function kK(e){let t=OK.exec(e)?.[1];if(t===void 0)return!1;let n=t.slice(t.lastIndexOf(`/`)+1),r=n.lastIndexOf(`.`);return r<0?!1:DK.has(n.slice(r+1).toLowerCase())}var AK=/^```([^\n`]*)\n([\s\S]*?)^```[ \t]*(?=\r?$)/gm;function jK(e){let t=[],n=0;for(let r of e.matchAll(/`([^`\n]+)`/g)){let i=r.index??0;i>n&&t.push({text:e.slice(n,i),kind:`text`});let a=r[1]??``;t.push({text:a,kind:kK(a)?`citation`:`code`}),n=i+r[0].length}return n<e.length&&t.push({text:e.slice(n),kind:`text`}),t}function MK(e){return e.split(/\r?\n\s*\r?\n/).filter(Boolean).map(e=>{let t=e.match(/^(Suggested fix:|Fix:|Open question[.,:])\s*/),n=t?.[1]??``;return{kind:`prose`,lead:n,leadKind:n.startsWith(`Open question`)?`question`:n?`fix`:null,segments:jK(e.slice(t?.[0].length??0))}})}function NK(e){let t=_G(e),n=gG(t),r=n?t.slice(n.length).trim():t,i=[],a=0;for(let e of r.matchAll(AK)){let t=e.index??0;i.push(...MK(r.slice(a,t).trim()));let n=(e[1]??``).trim().split(/\s+/)[0]||null;i.push({kind:`code`,language:n,code:(e[2]??``).replace(/\r?\n$/,``)}),a=t+e[0].length}return i.push(...MK(r.slice(a).trim())),{tag:n?.reviewer??null,severity:n?.severity??null,paragraphs:i}}function PK(e){let t=e.find(e=>e.kind===`prose`);if(!t)return`Open comment`;let n=`${t.lead} ${t.segments.map(e=>e.text).join(``)}`.trim(),r=n.search(/[.!?](?=\s|$)/);return(r<0?n:n.slice(0,r+1))||`Open comment`}function FK(e){let t=[`Fetch the diff`,`Check out the head`,`Review`,`Draft ready`],n={preparing:0,checkout:1,reviewing:2}[e];return t.map((e,t)=>({label:e,state:t<n?`done`:t===n?`active`:`todo`}))}function IK(e,t){return`${e}#${t}`}function LK(e){return e===`full`?`full`:`light`}function RK(e){return e.priorReviewedHead?`${LK(e.tier)} review of changes since ${T(e.priorReviewedHead)}`:`${LK(e.tier)} review`}function zK(e){return e.reasons.join(`, `)}function BK(e){if(!e)return[];let t=[],n=e.goal.trim(),r=e.change.trim();return n&&t.push({kind:`goal`,text:n}),r&&t.push({kind:`change`,text:r}),t}function VK(e){if(!e)return`No coverage notes`;let t=e.checked.length,n=e.gaps.length,r=[];return t>0&&r.push(`${t} ${t===1?`check`:`checks`}`),n>0&&r.push(`${n} not covered`),r.join(`, `)||`No coverage notes`}function HK(e){return e?{label:`Coverage`,preview:VK(e)}:{label:`Review audit`,preview:``}}var UK=`This review ran before plain summaries existed, so only its verdict and findings remain. The audit log shows what it checked. Queue review to get a plain summary.`,WK=new Set([`error`,`stale`,`discarded`,`posted`]);function GK(e){return WK.has(e)}function KK(e){return e.liveHead&&e.liveHead!==e.reviewedHead?e.liveHead:null}function qK(e){let t=KK(e);return t?`Reviewed at ${T(e.reviewedHead)}. The pull request is now at ${T(t)}.`:null}function JK(e){let t=KK(e);return t?`https://github.com/${e.repo}/compare/${e.reviewedHead}...${t}`:null}function YK(e){let t=[`at ${T(e.head)}`,IG(e.comments.length)];return e.wasPosted&&t.push(`posted`),t.join(`, `)}function XK(e){let t=ZK(e);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function ZK(e){return YG[e]??String(e).toLowerCase()}function QK(e){return QG[e]??`dim`}function $K(e){return eK[e]??e}function eq(e,t){return`${Zl(t-e.startedAt)} elapsed`}function tq(e,t){let n=[eq(e,t)],r=e.deadlineAt===null?0:e.deadlineAt-t;return r>0&&n.push(`times out in ${Zl(r)}`),e.phase===`reviewing`&&n.push(`${e.toolCalls} ${e.toolCalls===1?`tool call`:`tool calls`}`),n.join(`, `)}function nq(e){return e.status===`stale`&&e.earlierReview?`Out of date. New commits landed after this review, so its findings may not match the code any more. Automatic review runs after the configured wait; Queue review starts it now and hands it these findings.`:e.status===`stale`?`Out of date. New commits landed after this review, so its findings may not match the code any more. Automatic review runs after the configured wait; Queue review starts it now.`:e.status===`discarded`?`Marked not mine. Not reviewed again until queued.`:e.error||e.summary||`The review failed.`}function rq(e,t){let n=t.side===`LEFT`?` (old)`:``;return`${e}:${t.line}${n}`}function iq(e){return rq(e.path,e)}function aq(e){return rq(e.path.split(`/`).filter(Boolean).at(-1)??e.path,e)}function oq(e,t){let n=e.trim();return n?t.trim()?`${n}\n\n${t}`:n:t}function sq(e){return{key:e,action:`discard`,body:``,comments:[]}}function cq(e,t,n,r,i){return t===`approve-only`?{key:e.key,head:e.reviewedHead,action:t,body:``,comments:[]}:{key:e.key,head:e.reviewedHead,action:t,body:n,...i?{threadId:i}:{},comments:r.map(({path:e,line:t,side:n,body:r})=>({path:e,line:t,side:n,body:r}))}}var lq=Object.freeze({approve:`Approve and comment`,"approve-only":`Approve`,comment:`Comment`,discard:`Not mine`,requeue:`Queue review`,"resolve-thread":`Resolve`});function uq(e){return lq[e]}function dq(e){return e.status===`ready`?{footer:[`comment`,`approve-only`,`approve`],more:[`requeue`,`discard`]}:je(e)?{footer:[`approve-only`],more:[`requeue`]}:e.status===`error`||e.status===`stale`?{footer:[`requeue`],more:[`discard`]}:GK(e.status)?{footer:[`requeue`],more:[]}:{footer:[],more:[]}}function fq(e){return nK[e]}function pq(e){return tK[e]}function mq(e){return e===0?`Picked for review. It starts on the next poll.`:`Waiting for a free review slot. It starts as soon as ${e===1?`the review`:`one of the ${e} reviews`} in progress finishes.`}function hq(e){return e?e.configured?e.error?`Review drafts will show here once GitHub answers.`:`No review drafts yet. New teammate pull requests show up here after the next poll.`:e.reason?`Team review is not running: ${e.reason}.`:`Team review is off.`:`Waiting for the team review lane.`}function gq(e){return e?.configured&&e.reason||null}function _q(e){return rK(e).ready.map(e=>`${e.key}@${e.reviewedHead}`)}function vq(e){return Ol(_q(e))}function yq({readyEntries:e,acknowledged:t,unseen:n,isLooking:r}){let i=new Set(e),a=new Set(t.split(`|`).filter(e=>i.has(e))),o=new Set(n.split(`|`).filter(e=>i.has(e))),s=[...i].filter(e=>!a.has(e));if(r)return{isShown:!1,acknowledged:Ol([...i]),unseen:Ol([...o])};for(let e of s)o.add(e);return{isShown:s.length>0,acknowledged:Ol([...a]),unseen:Ol([...o])}}function bq(e){return`${e.key}@${e.reviewedHead}:${e.status}:${e.summary}:${_K(e).map(e=>e.text).join(`, `)}`}function xq(e){return`reviewedHead`in e?JSON.stringify([e.prCreatedAt,e.reviewedAt,e.postedAt,e.githubReviews,e.liveHead,e.priorReviewedHead,e.viewerThreads]):JSON.stringify([e.prCreatedAt,e.priorReviewedHead])}function Sq(e,t){return!e||e.error!==t.error||e.nextAttemptAt!==t.nextAttemptAt||JSON.stringify(e.retry)!==JSON.stringify(t.retry)||e.isRefreshing!==t.isRefreshing||e.refreshNotice!==t.refreshNotice||JSON.stringify(e.team)!==JSON.stringify(t.team)||e.configured!==t.configured||e.reason!==t.reason||e.inFlight.map(e=>e.key).join(`
170
- `)!==t.inFlight.map(e=>e.key).join(`
171
- `)||JSON.stringify(e.handReview)!==JSON.stringify(t.handReview)||JSON.stringify(e.queued)!==JSON.stringify(t.queued)?!1:JSON.stringify(e.drafts)===JSON.stringify(t.drafts)}var Cq=12e4,wq=`The server did not answer within ${Cq/1e3} s. Check GitHub before trying again.`,Tq=`${G} Check GitHub before trying again.`,Eq=`M4.5 0.5L8.5 5.5L4.5 10.5L0.5 5.5Z`,Dq=`GitHub review`,Oq=null,kq=null,Aq=null,jq=null,Mq=null,Nq=null,Pq=null,Fq=null,Iq=null,Lq=null,Rq=null,zq=null,Bq=null,Vq=null,Hq=null,Uq=null,Wq=null,Gq=new Map,Kq=If(()=>Aq),qq=If(()=>Aq),Jq=If(()=>Aq),Yq=new WeakMap,Xq=new Map,Zq=new Map,Qq=new Map,$q=Sc(),eJ=wc(),tJ=new Set(eJ.split(`|`).filter(Boolean));function nJ(e){let t=SK(e),n=M(`span`,`pr-severity-meter`);if(n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,`${e.toLowerCase()} severity`),n.style.color=`var(${t.colorToken})`,e===`CRITICAL`){let e=l_(14,17);e.classList.add(`pr-severity-halo`),e.setAttribute(`viewBox`,`0 0 9 11`),e.append(c_(`path`,{d:Eq,fill:`currentColor`})),n.append(e)}for(let e=0;e<3;e+=1){let r=l_(9,11),i=e<t.filledCount;r.append(c_(`path`,{d:Eq,fill:i?`currentColor`:`none`,stroke:i?`currentColor`:`var(--border-hover)`,"stroke-width":`1`})),n.append(r)}return n}function rJ({verdict:e}){let t=M(`span`,`pr-verdict-seal`);t.dataset.tone=QK(e);let n=l_(20,20),r=CK(e);return n.append(c_(`circle`,{cx:`10`,cy:`10`,r:`8.5`,fill:r===`cross`?`currentColor`:`none`,stroke:`currentColor`,"stroke-width":`1.5`})),r===`check`&&n.append(c_(`path`,{d:`M6 10.5L8.7 13L14 7.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),r===`dot`&&n.append(c_(`circle`,{cx:`10`,cy:`10`,r:`2.4`,fill:`currentColor`})),r===`bar`&&n.append(c_(`path`,{d:`M6 10H14`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})),r===`cross`&&n.append(c_(`path`,{d:`M7 7L13 13M13 7L7 13`,stroke:`var(--bg)`,"stroke-width":`1.8`,"stroke-linecap":`round`})),t.append(n,M(`span`,null,XK(e))),t}function iJ(){let e=l_(16,16);return e.append(c_(`rect`,{x:`1`,y:`1`,width:`14`,height:`14`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),e.append(c_(`path`,{d:`M6 6.2C6 4.9 7 4.2 8 4.2C9.1 4.2 10 5 10 6C10 7.4 8 7.4 8 9.2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linecap":`round`})),e.append(c_(`circle`,{cx:`8`,cy:`11.6`,r:`0.9`,fill:`currentColor`})),e}function aJ(e){return dr(`pr-link`,IK(e.repo,e.number),e.url)}function oJ(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?null:t}function sJ(e,t){let n=oJ(t);if(n===null)return null;let r=M(`span`,null,`${e}${e?` `:``}${Pf(n)}`);return r.dataset.ageAt=String(n),r.dataset.ageLabel=e,r}function cJ(e){let t=Yq.get(e);t&&(e.title=`${t()}${e.dataset.unseen?`
172
- New ready review`:``}`,e.setAttribute(`aria-label`,e.title))}function lJ(){Jq.reset(),uJ(Aq)}ch(lJ);function uJ(e){if(e){for(let t of e.querySelectorAll(`.pr-queue-row`))Yq.has(t)&&(cJ(t),Jq.onTick(()=>cJ(t)));for(let t of e.querySelectorAll(`.pr-rereview-notice`)){let e=kq?.drafts.find(e=>e.key===t.dataset.reviewKey),n=e?pK(e):null;if(!n)continue;let r=()=>{t.textContent=mK(n,fJ(n.submittedAt))};r(),Jq.onTick(r)}for(let t of e.querySelectorAll(`[data-review-title]`)){let e=t.dataset.reviewTitle??``,n=t.dataset.ageAt===void 0?null:Number(t.dataset.ageAt),r=()=>{let r=n===null?null:Pf(n),i=oh()?gK(Dq,r):gK(e,r);t.title=i,t.setAttribute(`aria-label`,i)};r(),Jq.onTick(r)}for(let t of e.querySelectorAll(`[data-age-at]`)){if(t.dataset.reviewTitle!==void 0)continue;let e=Number(t.dataset.ageAt),n=t.dataset.ageLabel??``;Jq.track(t,e,()=>`${n}${n?` `:``}${Pf(e)}`)}}}function dJ(e,t,n,r=!0){let i=_K(e,{isViewerShown:r});if(i.length===0)return null;let a=M(`span`,t),o=ur(i.map(e=>({login:e.login,tone:e.tone,title:gK(oh()?Dq:e.text,fJ(e.submittedAt))})),n);for(let[e,t]of i.entries()){let n=o.children[e];if(!(n instanceof HTMLElement))continue;n.dataset.reviewTitle=t.text;let r=oJ(t.submittedAt);r!==null&&(n.dataset.ageAt=String(r))}return a.append(o),a}function fJ(e){let t=oJ(e);return t===null?null:Pf(t)}function pJ(e,t,n){let r=M(`span`,n);return r.append(lr({login:e,cssPx:t}),M(`span`,`pr-author-login`,e)),r}function mJ(e,t){return`${IK(e.repo,e.number)}\n${jG(e,t).meaning}`}function hJ(e,t,n){let r=M(`button`,`pr-queue-row pr-queue-row-quiet`);r.type=`button`,r.dataset.reviewKey=e.key;let i=t===`ready`&&`reviewedHead`in e?`${e.key}@${e.reviewedHead}`:null;if(i&&tJ.has(i)){let e=M(`span`,`tab-activity active pr-queue-unseen`);e.setAttribute(`aria-hidden`,`true`),r.dataset.unseen=i,r.append(e)}r.setAttribute(`aria-current`,String(e.key===Lq));let a=`reviewedHead`in e?pK(e):null;Yq.set(r,()=>oh()?mJ(e,t):LG(e,t,{opened:fJ(e.prCreatedAt),reviewed:`reviewedHead`in e?fJ(e.reviewedAt):null,posted:`reviewedHead`in e?fJ(e.postedAt):null,viewerApproval:fJ(a?.submittedAt),githubReviews:`reviewedHead`in e?_K(e,{isViewerShown:t!==`posted`}).map(e=>fJ(e.submittedAt)):[]})),cJ(r);let o=bJ(e,n);if(t===`inReview`){let t=e,n=M(`span`,`pr-queue-elapsed`);Kq.track(n,t.startedAt,()=>eq(t,Date.now())),o.append(n)}if(t===`queued`){let t=sJ(``,e.prCreatedAt);t&&(t.classList.add(`pr-queue-elapsed`),o.append(t))}if(t!==`inReview`&&t!==`queued`){let t=e,n=sJ(``,t.reviewedAt)??sJ(``,t.prCreatedAt);n&&(n.classList.add(`pr-queue-elapsed`),o.append(n))}if(t===`discarded`)return r.classList.add(`pr-queue-row-compact`),r.append(o),gJ(r,e.key,i),r;r.classList.remove(`pr-queue-row-quiet`);let s=jG(e,t),c=M(`span`,`pr-queue-glyph`);c.append(iv(s.icon,s.tone));let l=M(`span`,`pr-queue-bottom`);if(l.append(yJ(s),pJ(e.author,16,`pr-queue-author`)),e.requestSource===`direct`){let e=M(`span`,`pr-queue-direct`,`@`);e.title=`Requested from you directly`,l.append(e)}t===`inReview`&&l.append(M(`span`,`pr-phase-label`,$K(e.phase))),r.append(c,o,l);let u=t===`inReview`||t===`queued`?null:dJ(e,`pr-queue-reviewers`,16,t!==`posted`);return u&&l.append(u),gJ(r,e.key,i),r}function gJ(e,t,n){e.addEventListener(`click`,()=>{n&&tJ.delete(n)&&(xY(Ol([...tJ])),e.querySelector(`.pr-queue-unseen`)?.remove(),delete e.dataset.unseen,cJ(e)),Lq=t,Rq=null,wJ(null);for(let e of Nq?.querySelectorAll(`button[data-review-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.reviewKey===Lq));dY(rK(kq)),Jq.reset(),uJ(Aq),document.documentElement.dataset.layout===`phone`&&Fq?.scrollIntoView({block:`start`,behavior:`smooth`})})}function _J(e){let t=Object.values(rK(kq)).flat().find(t=>In(t)===e.toLowerCase());return t?vJ(t.key):null}function vJ(e){return Nq?[...Nq.querySelectorAll(`button[data-review-key]`)].find(t=>t.dataset.reviewKey===e)??null:null}function yJ(e){let t=M(`span`,`my-pr-stage pr-queue-state`,e.meaning);return t.dataset.tone=e.tone,t}function bJ(e,t){let n=M(`span`,`pr-queue-top`);return n.append(M(`strong`,`pr-queue-ref`,WG(e.repo,e.number,t)),M(`strong`,`pr-queue-ref-compact`,WG(e.repo,e.number,!1)),M(`span`,`pr-queue-title`,e.title)),n}function xJ(e,t){let n=M(`section`,`pr-queue-section`);n.append(M(`h3`,`pr-section-heading`,`Review by hand ${e.length}`));for(let r of e){let e=dr(`pr-queue-row`,``,r.url);Yq.set(e,()=>oh()?mJ(r,`handReview`):LG(r,`handReview`,{opened:fJ(r.prCreatedAt)})),cJ(e);let i=jG(r,`handReview`),a=M(`span`,`pr-queue-glyph`);a.append(iv(i.icon,i.tone));let o=M(`span`,`pr-queue-bottom`);o.append(yJ(i),pJ(r.author,16,`pr-queue-author`)),e.append(a,bJ(r,t),o),n.append(e)}return n}function SJ({title:e,detail:t}){let n=M(`section`,`pr-caught-up`);n.setAttribute(`role`,`status`);let r=M(`strong`,`pr-caught-up-title`);return r.append(iv(`ready`,`ok`),M(`span`,null,e)),n.append(r,M(`p`,`pr-caught-up-detail`,t)),n}function CJ(e,t){return e.kind===`banner`?[SJ(e)]:[M(`p`,`my-pr-note`,e.detail),xJ(t.handReview,UG(t))]}function wJ(e){zq=e,Bq&&(Bq.hidden=e===null,Bq.textContent=e?.text??``,e&&(Bq.dataset.tone=e.tone))}function TJ(e,t,n,r){let i=M(`section`,`pr-queue-section`);i.append(M(`h3`,`pr-section-heading`,`${e} ${t.length}`));for(let e of t)i.append(hJ(e,n,r));return i}var EJ=`Open in session`,DJ=`Preparing the branch and session.`;function OJ(e,t,n){for(let r of document.querySelectorAll(`.pr-session-open-status`)){if(r.dataset.reviewKey!==e)continue;r.textContent=t,n&&(r.dataset.tone=n),n||delete r.dataset.tone;let i=r.parentElement?.querySelector(`.pr-session-open-button`);i&&(i.disabled=!1)}}function kJ(e,t){let n=Gq.get(e);n&&window.clearTimeout(n.timer),Gq.set(e,{requestId:null,timer:0,text:t,tone:`error`}),OJ(e,t,`error`)}function AJ(e,t,n){if(Gq.get(e)?.requestId)return;let r=gd(`open-team-review-session`);if(!K({type:`open-team-review-session`,requestId:r,key:e})){n.dataset.tone=`error`,n.textContent=G;return}let i=window.setTimeout(()=>kJ(e,`The server did not answer within ${Cq/1e3} s.`),Cq);Gq.set(e,{requestId:r,timer:i,text:DJ,tone:`busy`}),t.disabled=!0,n.dataset.tone=`busy`,n.textContent=DJ}function jJ(e){let t=M(`div`,`pr-session-open`),n=M(`button`,`pr-action pr-session-open-button`,EJ);n.type=`button`;let r=Gq.get(e.key);n.disabled=!!r?.requestId;let i=M(`span`,`pr-action-status pr-session-open-status`,r?.text??``);return i.dataset.reviewKey=e.key,r&&(i.dataset.tone=r.tone),i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`),n.addEventListener(`click`,()=>AJ(e.key,n,i)),t.append(n,i),t}function MJ(e){let t=M(`div`,`pr-detail-heading`);t.dataset.signature=xq(e);let n=M(`div`,`pr-detail-title`);n.append(aJ(e),M(`h2`,null,e.title));let r=M(`div`,`pr-detail-meta`);r.append(pJ(e.author,20,`pr-detail-author`));let i=M(`span`,null,RK(e));i.title=zK(e),r.append(i);let a=sJ(`Opened`,e.prCreatedAt);if(a&&r.append(a),`reviewedHead`in e){let t=sJ(`Reviewed`,e.reviewedAt);t&&r.append(t);let n=sJ(`Posted`,e.postedAt);n&&r.append(n)}let o=`reviewedHead`in e?dJ(e,`pr-detail-github`,20):null;if(o&&r.append(o),t.append(n,r,jJ(e)),`reviewedHead`in e){let n=FG(e.viewerThreads);if(n){let r=M(`p`,`pr-viewer-threads`,n);MG(e)&&(r.dataset.state=`all-resolved`),t.append(r)}}let s=`reviewedHead`in e?pK(e):null;if(s){let n=M(`p`,`pr-rereview-notice`,mK(s,fJ(s.submittedAt)));n.dataset.reviewKey=e.key,t.append(n)}return t}function NJ(e,t){let n=e.querySelector(`:scope > .pr-detail-heading`);if(!n||n.dataset.signature===xq(t))return e;let r=MJ(t),i=n.querySelector(`:scope > .pr-detail-title > .pr-detail-more`);return i&&r.querySelector(`:scope > .pr-detail-title`)?.append(i),n.replaceWith(r),e}function PJ(e){return`${JSON.stringify(e.threads)}:${e.liveHead}:${e.status}:${e.reviewedHead}:${e.error??``}:${e.postedEvent??``}:${e.earlierReview?.head??``}`}function FJ(e,t){for(let n of t){if(n.kind===`text`){e.append(document.createTextNode(n.text));continue}if(n.kind===`code`){e.append(M(`code`,null,n.text));continue}let t=M(`span`,`pr-citation`,n.text);t.title=n.text,e.append(t)}return e}function IJ(e,t){return FJ(e,jK(t))}function LJ(e,t,n){let r=M(`div`,`pr-assessment-part`);return n&&(r.dataset.tone=n),r.append(M(`h4`,`pr-assessment-title`,e),t),r}function RJ(e){let t=M(`ul`,`pr-assessment-list`);for(let n of e)t.append(IJ(M(`li`,null),n));return t}function zJ(e){let t=BK(e.assessment);if(t.length===0)return[];let n=M(`section`,`pr-about-box`);n.setAttribute(`aria-label`,`About this PR`),n.append(M(`h3`,`pr-assessment-title`,`About this PR`));for(let e of t){let t=e.kind===`goal`?`pr-verdict-summary pr-about-goal`:`pr-verdict-summary`;n.append(IJ(M(`p`,t),e.text))}return[n]}function BJ(e){let t=M(`section`,`pr-verdict-box`);t.setAttribute(`aria-label`,`Verdict`);let n=M(`div`,`pr-verdict-line`);return n.append(rJ(e)),t.append(n),e.assessment?(t.append(IJ(M(`p`,`pr-verdict-summary pr-verdict-reason`),e.summary)),t):(t.append(M(`p`,`pr-verdict-legacy`,UK)),t)}function VJ(e){let t=M(`details`,`pr-disclosure pr-coverage`),n=M(`summary`,`pr-disclosure-summary`),r=HK(e.assessment);n.append(M(`span`,`pr-disclosure-label`,r.label),M(`span`,`pr-disclosure-preview`,r.preview)),t.append(n);let{assessment:i}=e;return i?(i.checked.length>0&&t.append(LJ(`What the review checked`,RJ(i.checked))),i.gaps.length>0&&t.append(LJ(`Not covered`,RJ(i.gaps),`warning`)),t):(t.append(IJ(M(`p`,`pr-verdict-summary`),e.summary)),t)}function HJ(e){if(e.kind===`code`){let t=M(`pre`,`pr-comment-code`),n=M(`code`,null);return n.textContent=e.code,t.append(n),t}let t=M(`p`,`pr-comment-paragraph`);if(e.lead){let n=M(`strong`,`pr-comment-lead pr-comment-lead-${e.leadKind}`);e.leadKind===`question`&&n.append(iJ()),n.append(e.lead),t.append(n,` `)}return FJ(t,e.segments)}function UJ(e){let t=M(`details`,`pr-comment-content`),n=M(`summary`,`pr-comment-header`),r=NK(e.body),i=TK(e);i&&n.append(nJ(i));let a=M(`span`,`pr-comment-location`,aq(e));a.title=iq(e),n.append(a),n.append(M(`span`,`pr-comment-preview`,PK(r.paragraphs))),t.append(n);let o=M(`div`,`pr-comment-paragraphs`);for(let e of r.paragraphs)o.append(HJ(e));return t.append(o),t.open=i===`HIGH`||i===`CRITICAL`,t}function WJ(e,t){let n=M(`details`,`pr-disclosure pr-earlier-review`),r=M(`summary`,`pr-disclosure-summary`);r.append(M(`span`,`pr-disclosure-label`,`Earlier review`),M(`span`,`pr-disclosure-preview`,YK(e)));let i=M(`div`,`pr-earlier-review-body`),a=M(`div`,`pr-verdict-line`);a.append(rJ(e)),i.append(a),e.summary.trim()&&i.append(IJ(M(`p`,`pr-verdict-summary`),e.summary));for(let t of e.comments){let e=M(`article`,`pr-comment-card pr-comment-card-readonly`);e.append(UJ(t)),i.append(e)}return n.append(r,i),n.open=t,n}function GJ(e){let t=qK(e);if(!t)return[];let n=M(`p`,`pr-changed-since`,t);return n.append(` `,dr(`pr-changed-since-link`,`Compare changes`,JK(e),`Open the commits since this review on GitHub`)),[n]}function KJ(e){let t=kq?.drafts.find(t=>t.key===e.key)?.earlierReview??null;if(!t)return Hq=null,[];if(Hq?.key===e.key&&Hq.head===t.head)return[Hq.element];let n=WJ(t,!1);return Hq={key:e.key,head:t.head,element:n},[n]}function qJ(e,t,n,r){let i=M(`article`,`pr-comment-card`),a=M(`input`,`pr-comment-checkbox`);return a.type=`checkbox`,a.checked=n.has(t),a.setAttribute(`aria-label`,`Include comment on ${iq(e)}`),a.addEventListener(`change`,()=>{a.checked&&n.add(t),a.checked||n.delete(t),i.dataset.included=String(a.checked),r()}),i.dataset.included=String(a.checked),i.append(a,UJ(e)),i}var JJ=`More review actions`,YJ=`Your comments are on GitHub. Approve adds an approval without posting them again.`;function XJ(e,t,n,r){let i=yK(rK(kq));wJ(null);let a=gd(`team-review-action`);if(!K({type:`team-review-action`,requestId:a,...n}))return!1;let o=window.setTimeout(()=>{Qq.delete(t.key),r(!1,wq)},Cq);return Qq.set(t.key,{requestId:a,action:n.action,origin:e,capturedOrder:i,pullRequest:IK(t.repo,t.number),timer:o,settle:r}),!0}function ZJ(e){let t=M(`footer`,`pr-footer`),n=eY(`discard`,()=>{Qq.has(e.key)||(n.disabled=!0,i.dataset.tone=`busy`,i.textContent=fq(`discard`),!XJ(`other`,e,sq(e.key),a)&&a(!1,G))}),r=Qq.has(e.key);n.disabled=r;let i=M(`span`,`pr-action-status`,r?fq(`discard`):``);i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`);let a=(t,r)=>{n.disabled=t,i.dataset.tone=t?`ok`:`error`,i.textContent=r,t||wJ({text:`${IK(e.repo,e.number)}: ${r}`,tone:`error`})};return t.append(n,i),t}var QJ=0;function $J(e,t){let n=M(`div`,`pr-detail-more`),r=M(`button`,`review-icon-button review-more-button`);r.type=`button`,r.title=JJ,r.setAttribute(`aria-label`,JJ),r.setAttribute(`aria-haspopup`,`menu`),r.setAttribute(`aria-expanded`,`false`),r.append(m_(p_)),QJ+=1;let i=M(`div`,`review-more-menu`);i.id=`pr-more-menu-${QJ}`,i.setAttribute(`role`,`menu`),i.setAttribute(`aria-label`,JJ),i.hidden=!0,r.setAttribute(`aria-controls`,i.id);let a=e=>{e.key===`Escape`&&(e.preventDefault(),s(),r.focus())},o=e=>{e.target instanceof Node&&n.contains(e.target)||s()};function s(){i.hidden=!0,r.setAttribute(`aria-expanded`,`false`),document.removeEventListener(`keydown`,a),document.removeEventListener(`pointerdown`,o)}let c=()=>{i.hidden=!1,r.setAttribute(`aria-expanded`,`true`),document.addEventListener(`keydown`,a),document.addEventListener(`pointerdown`,o),i.querySelector(`button:not(:disabled)`)?.focus()};r.addEventListener(`click`,()=>{i.hidden?c():s()});let l=[r];for(let n of e){let e=M(`button`,`review-btn`,uq(n));e.type=`button`,e.dataset.action=n,e.setAttribute(`role`,`menuitem`),e.addEventListener(`click`,()=>{s(),t(n)}),l.push(e),i.append(e)}return n.append(r,i),{element:n,controls:l}}function eY(e,t){let n=M(`button`,`pr-action`,uq(e));return n.type=`button`,n.dataset.action=e,n.addEventListener(`click`,()=>t(e)),n}function tY(e,t){e.querySelector(`:scope > .pr-detail-heading > .pr-detail-title`)?.append(t)}function nY(e){let t=M(`article`,`pr-detail`),n=M(`div`);n.dataset.reviewThreads=``,t.append(MJ(e),...zJ(e),n,BJ(e)),oY(t,e);let r=M(`section`,`pr-posts`);r.setAttribute(`aria-label`,`Inline comments`);let i=M(`div`,`pr-posts-heading`);i.append(M(`h3`,null,`Inline comments`),M(`span`,null,String(e.comments.length))),r.append(i);let a=M(`details`,`pr-disclosure`),o=M(`summary`,`pr-disclosure-summary`),s=M(`span`,`pr-disclosure-preview`);o.append(M(`span`,`pr-disclosure-label`,`Review body`),s),a.append(o);let c=M(`textarea`,`pr-body-input`);c.setAttribute(`aria-label`,`Review body`),c.value=e.body,c.rows=Math.min(10,Math.max(3,e.body.split(`
173
- `).length+1)),c.spellcheck=!0;let l=()=>{s.textContent=_G(c.value).split(/\r?\n/).map(e=>e.trim()).find(Boolean)||`No review body`};c.addEventListener(`input`,l),l(),a.append(c);let u=M(`details`,`pr-disclosure`);u.append(M(`summary`,`pr-disclosure-summary`,`Add a note`));let d=M(`textarea`,`pr-body-input pr-note-input`);d.setAttribute(`aria-label`,`Your note`),d.rows=2,d.spellcheck=!0,d.placeholder=`Posts above the automated-review note`,u.append(d);let f=new Set(e.comments.flatMap((e,t)=>EK(e)?[t]:[])),p=M(`footer`,`pr-footer`),m=M(`span`,`pr-action-status`);m.setAttribute(`role`,`status`),m.setAttribute(`aria-live`,`polite`);let h=()=>{Qq.has(e.key)||m.dataset.tone===`ok`||(m.textContent=``,delete m.dataset.tone)};for(let[t,n]of e.comments.entries())r.append(qJ(n,t,f,h));t.append(r,a,u,VJ(e)),e.earlierReview&&t.append(WJ(e.earlierReview,!1));let g=[],_=e=>{for(let t of g)t.disabled=e;t.dataset.busy=String(e)},v=(e,t)=>{_(e),m.dataset.tone=e?`ok`:`error`,m.textContent=t},y=t=>{if(Qq.has(e.key))return;_(!0),m.dataset.tone=`busy`,m.textContent=fq(t);let n=e.comments.filter((e,t)=>f.has(t));XJ(`ready`,e,cq(e,t,oq(d.value,c.value),n),v)||v(!1,G)},b=dq(e),x=b.footer.map(e=>eY(e,y)),S=$J(b.more,y);return g.push(...x,...S.controls),tY(t,S.element),p.append(...x,m),t.append(p),{signature:bq(e),element:t,settle:v}}function rY(e){let t=Xq.get(e.key);if(t&&(Qq.has(e.key)||t.signature===bq(e)))return oY(t.element,e),NJ(t.element,e);let n=nY(e);return Xq.set(e.key,n),n.element}function iY(e,t){let n=M(`article`,`pr-detail`),r=M(`div`,`pr-detail-heading`),i=M(`div`,`pr-detail-title`);i.append(aJ(e),M(`h2`,null,e.title));let a=M(`div`,`pr-detail-meta`);a.append(pJ(e.author,20,`pr-detail-author`));let o=sJ(`Opened`,e.prCreatedAt);return o&&a.append(o),r.append(i,a,jJ(e)),n.append(r,M(`p`,`pr-attention-detail`,mq(t)),ZJ(e)),n}function aY(e){let t=M(`article`,`pr-detail`);t.append(MJ(e));let n=M(`section`,`pr-progress`);n.setAttribute(`aria-label`,`Review progress`);let r=M(`ol`,`pr-progress-tracker`);for(let t of FK(e.phase)){let e=M(`li`,`pr-progress-stage`);e.dataset.state=t.state,e.append(M(`span`,`pr-progress-bar`),M(`span`,null,t.label)),r.append(e)}let i=M(`div`,`pr-progress-text`);qq.track(i,e.startedAt,()=>tq(e,Date.now())),n.append(r,i),t.append(n);let a=M(`section`,`pr-steps`);a.append(M(`h3`,null,`Latest agent steps`));let o=M(`ol`,`pr-step-list`);for(let t of e.recentSteps){let n=M(`li`,`pr-step`),r=M(`span`,`pr-step-detail`,t.detail);r.title=t.detail,n.append(M(`span`,`pr-step-at`,Ql(e.startedAt,t.at)),M(`span`,`pr-step-tool`,t.tool),r),o.append(n)}return a.append(o),t.append(a,...KJ(e),ZJ(e)),t}function oY(e,t){if(Qq.has(t.key))return;let n=e.querySelector(`:scope > [data-review-threads]`),r=JSON.stringify([t.liveHead,t.threads]);n&&n.dataset.reviewThreads!==r&&(n.replaceChildren(...cY(t)),n.dataset.reviewThreads=r)}function sY(e,t,n,r){let i=M(`div`,t?`pr-thread-message pr-thread-message-muted`:`pr-thread-message`);if(i.append(M(`p`,`pr-thread-body pr-thread-preview`,e)),!n&&!uK(e,t?3:8))return i;let a=M(`details`,`pr-thread-disclosure`);return a.append(M(`summary`,`pr-thread-expand`,t?`Expand comment`:`Expand reply`),M(`p`,`pr-thread-body`,e)),n&&a.append(dr(`pr-link pr-thread-continues`,t?`Comment continues on GitHub`:`Reply continues on GitHub`,r)),i.append(a),i}function cY(e){let t=cK(e);if(t.length===0)return[];let n=M(`section`,`my-pr-threads-section`);n.append(M(`h3`,`pr-section-heading`,`Answered threads`));let r=M(`div`,`my-pr-threads`);for(let n of t){let t=M(`div`,`my-pr-thread pr-thread-card`),i=M(`div`,`my-pr-thread-heading pr-thread-heading`),a=M(`span`,`pr-thread-chip`,n.judgementLabel);a.dataset.tone=n.judgementTone,i.append(dr(`pr-link my-pr-thread-location`,n.location,n.thread.url),a),t.append(i),n.judgementReason&&t.append(M(`p`,`my-pr-thread-meta`,n.judgementReason)),n.thread.viewerComment&&t.append(M(`div`,`my-pr-thread-meta`,`Your comment`),sY(n.thread.viewerComment,!0,n.thread.viewerCommentTruncated===!0,n.thread.url));let o=M(`div`,`pr-detail-meta pr-thread-reply-meta`);o.append(M(`span`,`pr-author-login`,n.thread.lastReplyAuthor),` replied`);let s=sJ(``,n.thread.lastReplyAt);s&&o.append(s);let c=M(`span`,`pr-action-status`);c.setAttribute(`role`,`status`);let l=M(`button`,`pr-action`,`Resolve`);l.type=`button`,l.disabled=!n.canResolve||Qq.has(e.key);let u=(e,t)=>{l.disabled=e||!n.canResolve,c.textContent=t,c.dataset.tone=e?`ok`:`error`};l.addEventListener(`click`,()=>{Qq.has(e.key)||(l.disabled=!0,c.textContent=fq(`resolve-thread`),!XJ(`other`,e,cq(e,`resolve-thread`,``,[],n.thread.id),u)&&u(!1,G))}),t.append(o),n.thread.lastReplyBody&&t.append(sY(n.thread.lastReplyBody,!1,n.thread.lastReplyTruncated===!0,n.thread.url));let d=M(`footer`,`pr-thread-footer`);d.append(c,l),t.append(d),n.thread.resolveError&&t.append(M(`p`,`pr-attention-detail`,n.thread.resolveError)),r.append(t)}return n.append(r),[n]}function lY(e){let t=M(`article`,`pr-detail`);if(t.append(MJ(e),...zJ(e),...cY(e)),e.status===`posted`&&t.append(BJ(e),VJ(e)),e.status!==`posted`&&t.append(M(`p`,`pr-attention-detail`,nq(e))),e.status===`stale`&&t.append(...GJ(e)),e.earlierReview&&t.append(WJ(e.earlierReview,e.status===`stale`)),!GK(e.status))return Zq.set(e.key,{signature:PJ(e),element:t,settle:()=>{}}),t;let n=M(`footer`,`pr-footer`),r=dq(e),i=M(`span`,`pr-action-status`,r.footer.includes(`approve-only`)?YJ:``);i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`);let a=[],o=(e,t)=>{for(let t of a)t.disabled=e;i.dataset.tone=e?`ok`:`error`,i.textContent=t},s=t=>{if(!Qq.has(e.key)){for(let e of a)e.disabled=!0;i.dataset.tone=`busy`,i.textContent=fq(t),!XJ(`other`,e,cq(e,t,``,[]),o)&&o(!1,G)}},c=r.footer.map(e=>eY(e,s));if(a.push(...c),r.more.length>0){let e=$J(r.more,s);a.push(...e.controls),tY(t,e.element)}return n.append(...c,i),t.append(n),Zq.set(e.key,{signature:PJ(e),element:t,settle:o}),t}function uY(e){if(!GK(e.status)&&cK(e).length===0)return lY(e);let t=Zq.get(e.key);return t&&(Qq.has(e.key)||t.signature===PJ(e))?NJ(t.element,e):lY(e)}function dY(e){if(!Fq)return;if(Lq=xK(e,Lq,Rq!==null),!Lq){let t=Rq?.actedKey??null,n=t&&[...e.ready,...e.attention].some(e=>e.key===t)?t:null;Rq&&={actedKey:n},Fq.replaceChildren(...CJ(BG(e,n),e)),Vq=null;return}let t=e.ready.find(e=>e.key===Lq&&(oK(e).length>0||NG(e)));if(t&&t.status!==`ready`){let e=`threads:${PJ(t)}`,n=uY(t);if(Vq===e&&Fq.firstElementChild===n)return;Fq.replaceChildren(n),Vq=e;return}let n=[...e.ready,...e.noReviewNeeded].find(e=>e.key===Lq&&e.status===`ready`);if(n){let e=`ready:${bq(n)}`,t=rY(n);if(Vq===e)return;Fq.replaceChildren(t),Vq=e;return}let r=e.inReview.find(e=>e.key===Lq);if(r){qq.reset(),Fq.replaceChildren(aY(r)),Vq=`inReview:${r.key}`;return}let i=e.queued.find(e=>e.key===Lq);if(i){let t=`queued:${i.key}:${e.inReview.length}`;if(Vq===t)return;Fq.replaceChildren(iY(i,e.inReview.length)),Vq=t;return}let a=[...e.noReviewNeeded,...e.attention,...e.posted,...e.discarded].find(e=>e.key===Lq);a&&(Fq.replaceChildren(uY(a)),Vq=`${a.status}:${a.key}`)}function fY(){let e=M(`p`,`pr-empty`,hq(kq));return kq&&!kq.configured&&e.append(` `,Dp(qG,JG,`Open Team review settings`)),e}function pY(){let e=gq(kq);return e?[M(`p`,`my-pr-note`,e)]:[]}function mY(e){for(let t of[...Xq.keys()])e.has(t)||Qq.has(t)||Xq.delete(t);let t=new Set(kq?.drafts.filter(e=>GK(e.status)).map(e=>e.key)??[]);for(let e of Zq.keys())t.has(e)||Qq.has(e)||Zq.delete(e)}function hY(){if(!Aq||!jq||Nq?.isConnected)return;let e=aV({queueLabel:`Review queue`,scopeTabs:jq,resizerLabel:`Resize review queue`});Nq=e.queue,Bq=M(`p`,`pr-action-status pr-action-notice`),Bq.setAttribute(`role`,`status`),Bq.setAttribute(`aria-live`,`polite`),Fq=M(`div`,`pr-detail-body`),e.detail.append(Bq,Fq),wJ(zq),Mq&&e.foot.append(Mq.control),Aq.replaceChildren(e.columns),Vq=null,Pq=null}function gY(e){if(!e)return;e.querySelector(`.pr-team-chip`)?.remove();let t=kq?.team;if(!t)return;let n=M(`span`,`pr-team-chip`);n.append(lr({login:t.slug,url:t.avatarUrl,cssPx:16}),M(`span`,null,t.name)),e.insertBefore(n,e.querySelector(`.pr-queue-toggle`))}function _Y(){let e=document.activeElement;return!(e instanceof HTMLElement)||!Nq?.contains(e)?null:e.dataset.reviewKey??null}function vY(e){e&&vJ(e)?.focus({preventScroll:!0})}function yY(){if(!Aq)return;let e=_Y(),t=rK(kq);if(mY(new Set([...t.ready,...t.noReviewNeeded].map(e=>e.key))),Jq.reset(),!kq?.configured||!vK(t)&&Rq===null){Kq.reset(),qq.reset();let e=rV(jq);gY(e),Aq.replaceChildren(e,...Mq?[Mq.notice]:[],...pY(),fY(),iV(Mq?.control??null)),Mq?.update(kq),Nq=null,Pq=null,Fq=null,Bq=null,Iq=null,Vq=null;return}if(hY(),!Nq)return;gY(Aq.querySelector(`.pr-queue-head`)),Lq=xK(t,Lq,Rq!==null);let n=UG(t),r=JSON.stringify([t,n,Lq,gq(kq)]);if(r===Pq){Mq?.update(kq),dY(t),uJ(Aq);return}Pq=r,Kq.reset();let i=[],a=zG(t);a&&i.push(SJ({title:`All caught up`,detail:a})),t.ready.length&&i.push(TJ(`Ready`,t.ready,`ready`,n)),t.inReview.length&&(Iq=TJ(`In review`,t.inReview,`inReview`,n),i.push(Iq)),t.queued.length&&i.push(TJ(`Queued`,t.queued,`queued`,n)),t.noReviewNeeded.length&&i.push(TJ(`Already reviewed`,t.noReviewNeeded,`settled`,n)),t.handReview.length&&i.push(xJ(t.handReview,n)),t.attention.length&&i.push(TJ(`Needs attention`,t.attention,`attention`,n)),t.posted.length&&i.push(TJ(`Waiting on author`,t.posted,`posted`,n)),t.discarded.length&&i.push(TJ(`Not mine`,t.discarded,`discarded`,n)),Nq.replaceChildren(...Mq?[Mq.notice]:[],...pY(),...i),Mq?.update(kq),vY(e),dY(t),uJ(Aq)}function bY(e){e!==$q&&($q=e,Cc(e))}function xY(e){e!==eJ&&(eJ=e,Tc(e))}function SY(){if(!kq)return;let e=yq({readyEntries:_q(kq),acknowledged:$q,unseen:eJ,isLooking:!vr(Aq)});bY(e.acknowledged),xY(e.unseen),tJ=new Set(e.unseen.split(`|`).filter(Boolean)),Uq?.(e.isShown);for(let t of document.querySelectorAll(`.pr-scope-tab[data-scope="team"] .tab-activity`))t.classList.toggle(`active`,e.isShown)}function CY(){kq&&(bY(vq(kq)),SY())}function wY(e){Uq=e,SY()}function TY(e,t,n){return Wq=n?.openTerminal??Wq,Aq||(jq=t,Aq=M(`div`,`pr-content`),e.append(Aq),Mq=UW(`team-review`,Aq),Kq.ensure(),qq.ensure(),Jq.ensure(),yY(),Aq)}function EY(e){let t=He.safeParse(e);if(!t.success)return;let n=kq;Oq=t.data,kq=vG(Oq,Hn),SY(),!(kq&&Sq(n,kq)&&DY())&&yY()}function DY(){if(!kq||!Iq?.isConnected)return!1;Kq.reset(),Jq.reset();let e=_Y(),t=rK(kq),n=TJ(`In review`,t.inReview,`inReview`,UG(t));return Iq.replaceWith(n),Iq=n,vY(e),t.inReview.some(e=>e.key===Lq)&&dY(t),uJ(Aq),!0}function OY(e){let t=e.key;if(!t)return;let n=Gq.get(t);n&&n.requestId===e.requestId&&(!e.ok||!e.sessionId?kJ(t,e.error||`Could not open a session.`):(window.clearTimeout(n.timer),Gq.delete(t),OJ(t,``,null),Wq?.(e.sessionId)))}function kY(e){if(e)return;for(let[e,t]of Gq)t.requestId&&kJ(e,G);let t=[...Qq.values()];Qq.clear();for(let e of t)window.clearTimeout(e.timer),e.settle?.(!1,Tq)}function AY(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.key!=`string`)return;let n=Qq.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),Qq.delete(t.key),n.action===`resolve-thread`){n.settle?.(t.ok===!0,typeof t.error==`string`?t.error:pq(n.action)),Zq.delete(t.key),Vq=null,t.ok===!0&&yY();return}let r=(n.origin===`ready`?Xq:Zq).get(t.key);if(t.ok===!0){n.origin===`other`&&Zq.delete(t.key);let e=HG({action:n.action,pullRequest:n.pullRequest,warning:typeof t.warning==`string`?t.warning:``,isActedSelected:Lq===t.key});if((r?.settle??n.settle)?.(!0,e.statusText),(e.notice||e.shouldAdvance)&&wJ(e.notice),!e.shouldAdvance)return;Lq=bK({capturedOrder:n.capturedOrder,actedKey:t.key,groups:rK(kq)}),Lq===null&&(Rq={actedKey:t.key}),yY()}else(r?.settle??n.settle)?.(!1,typeof t.error==`string`&&t.error?t.error:`The action failed.`)}Un(()=>{kq=vG(Oq,Hn),SY(),yY()});function jY(e,t){let n=document.createElement(`div`);n.className=`pr-scope-tabs`,n.setAttribute(`role`,`tablist`),n.setAttribute(`aria-label`,`Reviews scope`);let r=[`team`,`mine`];for(let i of r){let a=document.createElement(`button`);if(a.className=`pr-scope-tab`,a.type=`button`,a.dataset.scope=i,a.setAttribute(`role`,`tab`),a.setAttribute(`aria-selected`,String(i===e)),a.tabIndex=i===e?0:-1,a.textContent=i===`team`?`Team`:`Mine`,i===`team`){let e=document.createElement(`span`);e.className=`tab-activity`,e.setAttribute(`aria-hidden`,`true`),a.append(e)}a.addEventListener(`click`,()=>t(i,!1)),a.addEventListener(`keydown`,e=>{e.key===`ArrowLeft`?(e.preventDefault(),t(r[(r.indexOf(i)+r.length-1)%r.length],!0)):e.key===`ArrowRight`&&(e.preventDefault(),t(r[(r.indexOf(i)+1)%r.length],!0))}),n.append(a)}return n}var MY=null;function NY(e){return MY?.(e)??!1}function PY(){uc()===`team`&&CY()}function FY(e,t){let n=(e,t)=>{if(s(e),PY(),!t)return;let n=(e===`team`?r:i).querySelector(`[aria-selected="true"]`);n&&n.getClientRects().length>0?n.focus():(e===`team`?a:o).querySelector(`.pr-queue-toggle`)?.focus()},r=jY(`team`,n),i=jY(`mine`,n),a=document.createElement(`div`);a.className=`pr-mode-root`;let o=document.createElement(`div`);o.className=`pr-mode-root`,e.append(a,o),TY(a,r,t),cG(o,i,t);function s(e){nV(),a.hidden=e!==`team`,o.hidden=e!==`mine`,dc(e)}MY=e=>{let n=aG(e),r=n??_J(e);return!r||!t?.openReviews()?!1:(s(n?`mine`:`team`),r.click(),r.focus({preventScroll:!0}),r.scrollIntoView({block:`nearest`}),PY(),!0)},s(uc())}var IY={OPEN:0,MERGED:1,CLOSED:2};function LY(e){return e?IY[e.state]:IY.OPEN}function RY(e,t){let n=`${e.repo}#${e.number}`,r=`#${e.number}`;if(!t)return{key:n,text:r,url:e.url,hoverText:e.repo,look:null,tier:Rh(void 0)};let i=WU(t.stage);return{key:n,text:r,url:t.url,hoverText:`${e.repo}: ${t.title} (${UU(t.stage)})`,look:{icon:GU(t.stage),tone:i},tier:Rh(i)}}function zY(e,t){let n=e.map(e=>{let n=t(In(e));return{link:e,pr:n?TU(n):void 0}});return n.sort((e,t)=>LY(e.pr)-LY(t.pr)||t.link.linkedAt-e.link.linkedAt),n.map(({link:e,pr:t})=>RY(e,t))}var BY=new Map;function VY(e){return document.querySelectorAll(`[data-pr-chips-for="${CSS.escape(e)}"]`)}function HY(e){return zY(BY.get(e)??[],Hn).map(e=>({...e,className:`session-pr-chip`,linkUrl:e.url,ariaLabel:`Show pull request ${e.key} in Reviews`,hoverText:`${e.hoverText}. Show in Reviews; Cmd/Ctrl-click opens GitHub`,onActivate:()=>{NY(e.key)||pg(e.url)}}))}function UY(e,t){let n=av(e,e),r=M(`button`,`session-pr-chip-unlink`);r.append(m_(u_)),r.type=`button`,r.title=`Unlink ${e.key} from this session`,r.setAttribute(`aria-label`,`Unlink pull request ${e.key}`),r.addEventListener(`click`,n=>{n.stopPropagation(),n.preventDefault(),rf({title:`Unlink pull request`,message:`Unlink ${e.key} from this session? Its checks and reviews stop showing here until you link it again.`,confirmLabel:`Unlink`,danger:!0,onConfirm:()=>{Kv(t,{type:`unlink-session-pr`,id:t,key:e.key})}})});let i=M(`span`,`session-pr-chip-item`);return i.append(n,r),i}function WY(e,t){e.dataset.prChipsFor=t,uv(e,HY(t),e=>UY(e,t))}function GY(e){for(let t of e){let e=t.dataset.prChipsFor;e&&WY(t,e)}_v()}function KY(e,t){let n=et.shape.links.safeParse(t??[]);BY.set(e,n.success?n.data:[]),GY(VY(e)),iG(BY)}function qY(e){BY.delete(e),iG(BY)}Un(()=>GY(document.querySelectorAll(`[data-pr-chips-for]`)));var JY=null,YY=new Set;function XY(){JY?.setAttribute(`aria-pressed`,String(!Rs()))}function ZY(e){zs(e),XY();for(let t of YY)t(e)}function QY(e){YY.add(e)}function $Y(e){JY=e,XY(),e.addEventListener(`click`,()=>ZY(!Rs()))}var eX={mine:`Mine`,run:`Run`,cancel:`Cancel`},tX={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},nX=null,rX=null,iX=null,aX=!0,oX=new Map,sX=new Map;function cX(e){return e===null?`n/a`:`${Math.round(e*100)}%`}function lX(e){if(e===null)return`n/a`;let t=Math.round(e*100);return t>0?`+${t}`:String(t)}function uX(e,t){iX?.({type:`benchmark-action`,requestId:gd(`benchmark`),suiteId:e,action:t})===!0?(oX.set(e,t),sX.set(e,tX[t]),gX()):(sX.set(e,G),gX())}function dX(e,t,n){let r=M(`button`,`bench-action-button`,eX[t]);return r.type=`button`,r.disabled=n,r.addEventListener(`click`,()=>uX(e.id,t)),r}function fX(e){let t=rX?.inFlight;if(!t||t.suiteId!==e.id)return``;let n=t.caseId?`case ${t.caseId}, `:``;return`Cell ${t.cellIndex+1} of ${t.cellCount}: ${n}arm ${t.armId}, trial ${t.trial}, ${t.phase}.`}function pX(e){let t=M(`td`,`bench-score`,cX(e?.recall??null));return e&&e.invalid>0&&(t.title=`${e.invalid} invalid or failed cell(s)`),e&&e.degraded>0&&(t.dataset.degraded=`true`),t}function mX(e){let t=e.armIds.filter(t=>t!==e.baselineArm),n=M(`table`,`bench-table`),r=M(`tr`);r.append(M(`th`,null,`Case`),...e.armIds.map(t=>M(`th`,null,t===e.baselineArm?`${t} (baseline)`:t))),r.append(...t.map(e=>M(`th`,null,`${e} vs baseline`))),n.append(r);for(let r of e.rows){let i=M(`tr`);i.append(M(`td`,`bench-case`,r.caseId),...e.armIds.map(e=>pX(r.arms[e]))),i.append(...t.map(e=>M(`td`,`bench-delta`,lX(r.deltaVsBaseline[e]??null)))),n.append(i)}let i=[...new Set(e.armIds.flatMap(t=>Object.keys(e.totals[t]?.recallByTag??{})))].sort(),a=M(`tr`,`bench-total`);a.append(M(`td`,`bench-case`,`Paired recall`),...e.armIds.map(t=>pX(e.totals[t]))),n.append(a);for(let t of i){let r=M(`tr`,`bench-total`);r.append(M(`td`,`bench-case`,`Recall, ${t}`),...e.armIds.map(n=>M(`td`,`bench-score`,cX(e.totals[n]?.recallByTag[t]??null)))),n.append(r)}return n}function hX(e){let t=M(`div`,`bench-suite`),n=rX?.inFlight?.suiteId===e.id,r=!!rX?.inFlight&&!n,i=oX.has(e.id)||!aX,a=M(`div`,`bench-summary`);a.append(M(`span`,`bench-suite-title`,e.title),gr(`bench`,e.caseCount===1?`case`:`cases`,String(e.caseCount)),gr(`bench`,e.candidateCount===1?`candidate`:`candidates`,String(e.candidateCount)),gr(`bench`,`arms`,String(e.armIds.length))),t.append(a);let o=M(`div`,`bench-controls`),s=rX?.configured===!0&&e.error===null;o.append(dX(e,`mine`,!s||i||n),dX(e,`run`,!s||i||n||r||e.caseCount===0),dX(e,`cancel`,i||!n));let c=M(`span`,`bench-status`,(aX?``:`Not connected to the server. Reconnecting.`)||fX(e)||sX.get(e.id)||``);if(c.setAttribute(`role`,`status`),o.append(c),t.append(o),e.error)return t.append(M(`p`,`bench-error`,e.error)),t;let l=e.latestReport;return l?(t.append(M(`p`,`bench-run-line`,`Latest run ${l.runId}: ${l.status}. Only cases every arm scored count toward paired recall.`)),l.rows.length>0&&t.append(mX(l)),t):(t.append(M(`p`,`bench-empty`,e.caseCount===0?`Move approved candidates into the cases folder, then choose Run.`:`No run yet.`)),t)}function gX(){if(!nX)return;nX.textContent=``;let e=hr(`bench`,`Benchmarks`,`Suites from the benchmarks folder of the Glimmervoid home, one run at a time.`);if(nX.append(e),!rX)nX.append(M(`p`,`bench-empty`,`Waiting for the server.`));else if(!rX.configured)nX.append(M(`p`,`bench-empty`,rX.reason||`Benchmarks are off.`));else if(rX.suites.length===0)nX.append(M(`p`,`bench-empty`,`No suites yet. Create a folder holding suite.json under benchmarks in the Glimmervoid home.`));else for(let e of rX.suites)nX.append(hX(e))}function _X(e){iX=e}function vX(e){return nX||(nX=M(`div`,`bench-content`),e.append(nX),gX(),nX)}function yX(e){if(aX=e,!e){for(let e of oX.keys())sX.delete(e);oX.clear()}gX()}function bX(e){rX=e,gX()}function xX(e){oX.delete(e.suiteId);let t=rX?.suites.find(t=>t.id===e.suiteId)?.candidateCount??0,n={mine:`Mining finished. ${t} candidate${t===1?``:`s`} awaiting approval in the candidates folder.`,run:`Run ${e.runId??``} started.`,cancel:`Run cancelled.`};sX.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),gX()}function SX(e){return e?e.configured?`No open issues.`:e.reason??`Loading issues.`:`Loading issues.`}function CX(e,t){return t===`all`||e.sources.includes(t)}function wX(e){return{all:e.length,me:e.filter(e=>CX(e,`me`)).length,team:e.filter(e=>CX(e,`team`)).length,project:e.filter(e=>CX(e,`project`)).length}}function TX(e,t,n){let r=t.query.trim().toLowerCase().split(/\s+/).filter(Boolean),i=e.filter(e=>{if(!CX(e,t.scope)||t.repo&&e.repo!==t.repo||t.label&&!e.labels.includes(t.label)||t.hasSession&&(!e.sessionId||!n.has(e.sessionId))||t.hasPr&&e.pullRequests.length===0||t.isUnassignedOnly&&e.assignees.length>0)return!1;let i=[e.title,`#${e.number}`,e.repo,e.author,...e.labels,...e.assignees,...e.teams].join(` `).toLowerCase();return r.every(e=>i.includes(e))}),a=e=>Date.parse(e)||0,o=e=>t.sort===`comments`?e.comments:t.sort===`created`?a(e.createdAt):a(e.updatedAt);return i.sort((e,t)=>o(t)-o(e)||e.key.localeCompare(t.key))}function EX(e){let t=new Map;for(let n of e){let e=t.get(n.repo)??[];e.push(n),t.set(n.repo,e)}return t}function DX(e){return{repos:[...new Set(e.map(e=>e.repo))].sort(),labels:[...new Set(e.flatMap(e=>e.labels))].sort()}}function OX(e){let t=[e.query.trim()&&`search "${e.query.trim()}"`,e.repo,e.label,e.hasSession&&`has session`,e.hasPr&&`has PR`,e.isUnassignedOnly&&`unassigned`].filter(Boolean);return t.length===0?``:`Filtered by ${t.join(`, `)}.`}function kX(e,t){let n=typeof e==`number`?e:Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.round(Math.max(0,t-n)/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.round(r/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function AX(e,t){let n=kX(e,t);return n===`now`?`just now`:n===`unknown`?`at an unknown time`:`${n} ago`}function jX(e,t){let n=so(e.url),r=n?t(n.toLowerCase()):void 0;return r?Lr(r):e.state}var MX=45e3,NX=`The server did not answer within ${MX/1e3} s.`,PX=`Select the issue to load its description.`,FX=[{id:`all`,label:`All`},{id:`me`,label:`Mine`},{id:`team`,label:`Team`},{id:`project`,label:`Projects`}],IX={scope:`all`,repo:``,label:``,sort:`updated`,query:``,hasSession:!1,hasPr:!1,isUnassignedOnly:!1},LX=null,RX=null,zX=null,BX=null,VX=null,HX=null,UX=null,WX=null,GX=null,KX=null,qX=new Map,JX=!1,YX=null,XX=null,ZX=new Map,QX=new Map,$X=new Map,eZ=new Map,tZ=new Map;function nZ(e){return`${e.key}:${e.updatedAt}`}function rZ(e){return e.sessionId?F.get(e.sessionId):void 0}function iZ(e,t,n){let r=rZ(t),i=r?.currentState??j.DORMANT,a=pr(i,r?.awaitingBackgroundTasks),o=r?`Session: ${a.label}`:`No session yet`,s=n?a.label:``;if(e.dataset.state===i&&e.title===o&&e.dataset.icon===a.icon&&e.textContent===s)return;e.dataset.state=i,e.dataset.icon=a.icon,e.title=o,e.setAttribute(`aria-label`,o);let c=M(`span`,`issues-state-icon`);nv(c,a.icon),e.replaceChildren(c),n&&e.append(s)}function aZ(e,t=!1){let n=M(`span`,t?`issues-state`:`pr-queue-glyph issues-state`);return iZ(n,e,t),n}function oZ(e){let t=rZ(e);return t?Sr(t):`none yet`}function sZ(e){return[...ZX.values()].some(t=>t.issueKey===e.key)}function cZ(e){let t=ZX.get(e);t&&(ZX.delete(e),QX.set(t.issueKey,NX),_Z())}function lZ(e){let t=ZX.get(e);return t?(clearTimeout(t.timeoutHandle),ZX.delete(e),t):null}function uZ(e){let t=nZ(e);if(eZ.has(t)||[...$X.values()].some(e=>e.cacheKey===t))return;let n=gd(`issue-detail`);tZ.delete(t),XX?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})?$X.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{$X.delete(n),tZ.set(t,`${NX} ${PX}`),_Z()},MX)}):tZ.set(t,`${G} ${PX}`)}function dZ(e){let t=e.projectId;if(!t||rZ(e)||sZ(e))return;let n=gd(`open-issue-session`);XX?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})?(ZX.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>cZ(n),MX)}),QX.set(e.key,`Opening session.`),_Z()):(QX.set(e.key,G),_Z())}function fZ(e){let t=M(`button`,`pr-queue-row issue-row`);t.type=`button`,t.dataset.issueKey=e.key,t.setAttribute(`aria-current`,String(e.key===GX));let n=M(`span`,`pr-queue-top`);n.append(M(`span`,`pr-queue-ref`,`#${e.number}`),M(`span`,`pr-queue-title`,e.title||`Untitled issue`));let r=M(`span`,`pr-queue-bottom`);e.sources.includes(`me`)&&r.append(M(`span`,`issues-why`,`you`)),r.append(M(`span`,`issues-row-labels`,e.labels.join(`, `)));for(let t of e.pullRequests){let e=jX(t,Hn),n=M(`span`,`issues-row-pr`,`PR #${t.number} ${e}`);n.dataset.prState=e,r.append(n)}let i=M(`span`,`pr-queue-elapsed`,kX(e.updatedAt,Date.now()));return i.dataset.issueAge=e.updatedAt,r.append(i),t.append(aZ(e),n,r),t.addEventListener(`click`,()=>{CZ(`select`),GX=e.key,LX&&(LX.dataset.detailOpen=`true`),uZ(e),yZ(),BX&&(BX.scrollTop=0)}),t}function pZ(e,t,n){let r=M(`dd`);r.append(...n),e.append(M(`dt`,null,t),r)}function mZ(e){let t=M(`footer`,`pr-footer issues-detail-footer`),n=rZ(e);if(n&&e.sessionId){let n=e.sessionId,r=M(`button`,`pr-action`,`Go to session`);r.type=`button`,r.addEventListener(`click`,()=>{CZ(`go-to-session`),Uv(n)}),t.append(r)}if(e.projectId&&!n){let n=M(`button`,`pr-action`,`Open session`);n.type=`button`,n.disabled=sZ(e),n.addEventListener(`click`,()=>dZ(e)),t.append(n)}t.append(dr(`pr-action pr-action-ghost`,`View on GitHub`,e.url));let r=QX.get(e.key),i=e.projectId?``:`Add a project for ${e.repo} in Settings to open sessions from here.`,a=M(`span`,`pr-action-status issue-open-status`,r??i);return a.setAttribute(`role`,`status`),sZ(e)&&a.prepend(M(`span`,`issues-spinner`)),t.append(a),t}function hZ(e,t){let n=M(`span`,null,AX(e,t));return n.dataset.issueAgo=e,n}function gZ(){let e=BX?.querySelector(`.issues-detail`),t=GX?qX.get(GX):void 0;if(!e||!t)return;let n=e.querySelector(`.issues-facts .issues-state`);n&&iZ(n,t,!0);let r=e.querySelector(`.issues-session-name`),i=oZ(t);r&&r.textContent!==i&&(r.textContent=i);let a=String(!!rZ(t));e.dataset.hasLiveSession!==a&&(e.dataset.hasLiveSession=a,e.querySelector(`.issues-detail-footer`)?.replaceWith(mZ(t)))}function _Z(){if(!BX)return;let e=KX?.issues.find(e=>e.key===GX);if(!e){BX.replaceChildren(M(`p`,`pr-empty`,`Pick an issue from the queue.`));return}let t=M(`article`,`pr-detail issues-detail`),n=M(`button`,`pr-action pr-action-ghost issues-back`,`Back to issues`);n.type=`button`,n.addEventListener(`click`,()=>{CZ(`back`),LX&&(LX.dataset.detailOpen=`false`),[...zX?.querySelectorAll(`[data-issue-key]`)??[]].find(e=>e.dataset.issueKey===GX)?.focus({preventScroll:!0})});let r=M(`header`,`pr-detail-heading`),i=M(`div`,`pr-detail-title`);i.append(dr(`pr-link`,`${e.repo}#${e.number}`,e.url),M(`h2`,null,e.title||`Untitled issue`));let a=Date.now(),o=M(`div`,`pr-detail-meta`),s=M(`span`,null,`opened by ${e.author||`unknown`} `),c=M(`span`,null,`updated `);s.append(hZ(e.createdAt,a)),c.append(hZ(e.updatedAt,a)),o.append(s,c,M(`span`,null,`${e.comments} comments`)),e.sources.includes(`me`)&&o.append(M(`span`,`issues-why`,`assigned to you`));for(let t of e.teams)o.append(M(`span`,null,`mentions ${t}`));r.append(i,o);let l=M(`dl`,`issues-facts`);pZ(l,`Repository`,[e.repo]),pZ(l,`Labels`,[e.labels.join(`, `)||`none`]),pZ(l,`Assignees`,[e.assignees.join(`, `)||`unassigned`]),t.dataset.hasLiveSession=String(!!rZ(e)),pZ(l,`Session`,[aZ(e,!0),M(`span`,`issues-session-name`,oZ(e))]);let u=e.pullRequests.flatMap(e=>{let t=jX(e,Hn),n=M(`span`,`issues-pr-state`,t);return n.dataset.prState=t,[n,dr(`issues-inline-link`,`#${e.number} ${e.title}`,e.url)]});pZ(l,`Pull request`,u.length>0?u:[`none linked`]);let d=M(`section`,`issues-body-section`),f=nZ(e),p=M(`div`,`issue-body`,eZ.get(f)??tZ.get(f)??`Loading description.`);eZ.get(f)===``&&(p.textContent=`No description.`),p.setAttribute(`role`,`status`),d.append(M(`h3`,`pr-section-heading`,`Description`),p),t.append(n,r,l,d,mZ(e)),BX.replaceChildren(t)}function vZ(e,t,n,r){if(!e)return;let i=r&&!n.includes(r)?[...n,r].sort():n;e.replaceChildren(...[``,...i].map(e=>{let n=M(`option`,null,e||t);return n.value=e,n})),e.value=r}function yZ(){JX=!1,bZ(),_Z()}function bZ(){if(!LX||!zX||!RX)return;let e=KX?.issues??[],t=wX(e);for(let e of FX){RX.querySelector(`[data-scope="${e.id}"]`)?.setAttribute(`aria-selected`,String(e.id===IX.scope));let n=RX.querySelector(`[data-scope-count="${e.id}"]`);n&&(n.textContent=String(t[e.id]))}let n=DX(e);vZ(HX,`All repos`,n.repos,IX.repo),vZ(UX,`All labels`,n.labels,IX.label),VX&&(VX.textContent=OX(IX));let r=TX(e,IX,new Set(F.keys())),i=document.activeElement instanceof HTMLElement&&zX.contains(document.activeElement)?document.activeElement.dataset.issueKey:null,a=[...EX(r)].map(([e,t])=>{let n=M(`section`,`pr-queue-section`),r=M(`h3`,`pr-section-heading issues-repo-heading`,e);return t.some(e=>e.projectId)||r.append(M(`span`,`issues-repo-note`,`view only`)),r.append(M(`span`,`issues-repo-count`,String(t.length))),n.append(r,...t.map(fZ)),n});zX.replaceChildren(...a),r.length===0&&zX.append(M(`p`,`pr-empty`,e.length>0?`No open issues match these filters. Clear the search or pick All.`:SX(KX))),i&&[...zX.querySelectorAll(`[data-issue-key]`)].find(e=>e.dataset.issueKey===i)?.focus({preventScroll:!0}),GX&&!e.some(e=>e.key===GX)&&(GX=null,LX.dataset.detailOpen=`false`),YX?.update(KX),SZ()}function xZ(){let e=M(`div`,`issues-filters`),t=M(`div`,`issues-search-row`),n=M(`input`,`issues-search`);n.type=`search`,n.placeholder=`Search issues`,n.autocomplete=`off`,n.setAttribute(`aria-label`,`Search issues`),n.addEventListener(`input`,()=>{IX.query=n.value,yZ()}),n.addEventListener(`change`,()=>CZ(`search`));let r=M(`button`,`pr-action pr-action-ghost`,`Filters`);r.type=`button`,r.setAttribute(`aria-expanded`,`false`),r.setAttribute(`aria-controls`,`issues-filters-panel`);let i=M(`div`,`issues-filters-panel`);i.id=`issues-filters-panel`,i.hidden=!0,r.addEventListener(`click`,()=>{CZ(`filters-toggle`),i.hidden=!i.hidden,r.setAttribute(`aria-expanded`,String(!i.hidden))}),t.append(n,r);let a=M(`div`,`issues-filter-row`);function o(e){let t=M(`select`,`issues-field`);return t.setAttribute(`aria-label`,e),a.append(t),t}HX=o(`Repository`),HX.addEventListener(`change`,()=>{CZ(`filter`),IX.repo=HX?.value??``,yZ()}),UX=o(`Label`),UX.addEventListener(`change`,()=>{CZ(`filter`),IX.label=UX?.value??``,yZ()});let s=o(`Sort`);for(let[e,t]of[[`updated`,`Updated`],[`created`,`Newest`],[`comments`,`Most discussed`]]){let n=M(`option`,null,t);n.value=e??``,s.append(n)}s.addEventListener(`change`,()=>{CZ(`filter`),IX.sort=s.value,yZ()});let c=M(`div`,`issues-filter-row`);for(let[e,t]of[[`hasSession`,`Has session`],[`hasPr`,`Has PR`],[`isUnassignedOnly`,`Unassigned`]]){let n=M(`label`,`issues-toggle`),r=M(`input`);r.type=`checkbox`,r.addEventListener(`change`,()=>{CZ(`filter`),IX[e]=r.checked,yZ()}),n.append(r,` ${t}`),c.append(n)}return VX=M(`span`,`issues-filter-summary`),VX.setAttribute(`role`,`status`),i.append(a,c),e.append(t,VX,i),e}function SZ(){if(!LX||LX.closest(`[hidden]`)||document.hidden)return;let e=Date.now();WX&&(WX.textContent=KX?.lastSyncAt?`Synced ${AX(KX.lastSyncAt,e)}.`:`Not synced yet.`);for(let t of LX.querySelectorAll(`[data-issue-age]`))t.textContent=kX(t.dataset.issueAge??``,e);for(let t of LX.querySelectorAll(`[data-issue-ago]`))t.textContent=AX(t.dataset.issueAgo??``,e)}function CZ(e){XX?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`issues`,action:e}})}function wZ(e){XX=e}function TZ(e){if(LX)return LX;LX=M(`div`,`issues-content`),LX.dataset.detailOpen=`false`,e.append(LX),YX=UW(`issues`,LX);let t=M(`div`,`pr-columns issues-columns`),n=M(`section`,`pr-queue-pane`);n.setAttribute(`aria-label`,`Issue queue`),RX=M(`div`,`pr-scope-tabs issues-scope-tabs`),RX.setAttribute(`role`,`tablist`),RX.setAttribute(`aria-label`,`Issue scope`);for(let e of FX){let t=M(`span`,`issues-scope`);t.setAttribute(`role`,`presentation`);let n=M(`button`,`pr-scope-tab`,e.label);n.type=`button`,n.dataset.scope=e.id,n.setAttribute(`role`,`tab`),n.addEventListener(`click`,()=>{CZ(`scope`),IX.scope=e.id,yZ()});let r=M(`span`,`issues-scope-count`);r.dataset.scopeCount=e.id,t.append(n,r),RX.append(t)}zX=M(`nav`,`pr-queue`),zX.setAttribute(`aria-label`,`Issues`);let r=iV(YX.control);return WX=M(`span`,`issues-sync`),WX.setAttribute(`role`,`status`),r.prepend(WX),r.append(YX.notice),n.append(rV(RX),xZ(),zX,r),BX=M(`section`,`pr-detail-host`),BX.setAttribute(`aria-label`,`Issue detail`),t.append(n,BX),LX.append(t),window.setInterval(SZ,3e4),yZ(),LX}function EZ(){JX&&DZ(),SZ()}function DZ(){if(vr(LX))JX=!0;else if(JX=!1,gZ(),IX.hasSession)bZ();else for(let e of zX?.querySelectorAll(`[data-issue-key]`)??[]){let t=qX.get(e.dataset.issueKey??``),n=e.querySelector(`.issues-state`);t&&n&&iZ(n,t,!1)}}function OZ(e){if(!e){for(let e of ZX.values())clearTimeout(e.timeoutHandle),QX.set(e.issueKey,G);ZX.clear();for(let e of $X.values())clearTimeout(e.timeoutHandle),tZ.set(e.cacheKey,`${G} ${PX}`);$X.clear(),yZ()}}function kZ(e){let t=KX?.issues.find(e=>e.key===GX);KX=e,qX=new Map(e.issues.map(e=>[e.key,e]));let n=e.issues.find(e=>e.key===GX);n&&n.updatedAt!==t?.updatedAt&&uZ(n),yZ()}function AZ(e){let t=$X.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),$X.delete(e.requestId),e.ok&&e.body!==null&&eZ.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&tZ.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),_Z())}function jZ(e){if(typeof e.requestId!=`string`)return;let t=lZ(e.requestId);if(!t)return;let n=t.issueKey;if(e.ok===!0){let r=typeof e.sessionName==`string`?e.sessionName:`issue #${t.issueNumber}`,i=e.pending===!0?` Prompt queued.`:``,a=e.existing===!0?`already open`:`created`;QX.set(n,`Session "${r}" ${a}.${i}`);let o=KX?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),yZ();return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;QX.set(n,r),_Z()}Un(yZ);var MZ=4e3;function NZ({render:e,holdMs:t=MZ,setTimer:n=setTimeout,clearTimer:r=clearTimeout}){let i=new Set,a=!1,o=null;function s(e){(o===null||e)&&(o!==null&&r(o),o=n(c,t))}function c(){o=null,i.size>0?s(!1):a&&(a=!1,e())}return{begin(e){i.add(e)},settle(e){i.delete(e),s(!0)},request(){i.size===0&&o===null?e():(a=!0,s(!1))},_state(){return{pending:i.size,held:a,armed:o!==null}}}}var PZ=null,FZ=null,IZ=null,LZ=null,RZ=`http://www.w3.org/2000/svg`,zZ=Al({getAck:bc,setAck:xc,signature:()=>Eu({posthog:PZ}),isLooking:()=>!vr(FZ)}),BZ=NZ({render:MQ}),VZ=new Set,HZ=null,UZ=new Map,WZ=new WeakMap,GZ=`this issue`,KZ=If(()=>FZ),qZ={spiking:`spiking`,regressed:`regressed`,worsened:`worsened`,new:`new`,quiet:`quiet`},JZ=[{columnId:`stripe`,headText:``,cellClass:`radar-stripe`,track:`auto`,phoneTrack:`auto`,isMagnitude:!1,startsActionCluster:!1},{columnId:`change`,headText:``,cellClass:`radar-change`,track:`auto`,phoneTrack:`minmax(68px, auto)`,isMagnitude:!1,startsActionCluster:!1},{columnId:`copy`,headText:``,cellClass:`radar-issue-copy`,track:`minmax(0, 1fr)`,phoneTrack:`minmax(0, 1fr)`,isMagnitude:!1,startsActionCluster:!0},{columnId:`occurrences`,headText:`Occurrences`,cellClass:`radar-metric`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1},{columnId:`users`,headText:`Users`,cellClass:`radar-metric`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1},{columnId:`trend`,headText:`Trend`,cellClass:`radar-issue-trend`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1}],YZ=JZ.map(e=>e.track).join(` `),XZ=JZ.filter(e=>!e.isMagnitude).map(e=>e.phoneTrack).join(` `),ZZ=JZ.findIndex(e=>e.startsActionCluster)+1,QZ=3e4;function $Z(e){let t=M(`div`,e);return t.style.setProperty(`--radar-issue-grid`,YZ),t.style.setProperty(`--radar-issue-grid-phone`,XZ),t.style.setProperty(`--radar-issue-actions-start`,String(ZZ)),t}function eQ(e,t){let n=M(`span`,`radar-issue-magnitudes`),r=!1;for(let i of JZ){let a=t(i);i.isMagnitude?(r||=(e.append(n),!0),n.append(a)):e.append(a)}}function tQ(e){return Number.isFinite(e)?String(e):`0`}function nQ(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?``:`elapsed ${Nf(Date.now()-e)}`}function rQ(e){return typeof e?.issueId==`string`?e.issueId:``}function iQ(e,t){return[String(e??``),String(t??``)].join(`::`)}function aQ(e,t,n){let r=UZ.get(iQ(e,t));if(!r||!r.copy.isConnected)return!1;let i=Ul(n);return i?(r.summary||(r.summary=M(`span`,`radar-issue-summary`),r.copy.insertBefore(r.summary,r.copy.querySelector(`.radar-issue-meta`))),r.summary.textContent=i,!0):(r.summary?.remove(),r.summary=null,!0)}function oQ(e,t,n){let r=rQ(e);if(!r)return;HZ?.dialog.close();let i=np({issueTitle:String(e.title||r),projectLabel:n,onOpenReport:()=>cQ(e)});HZ={projectId:String(t??``),issueId:r,dialog:i},i.update(Wl(e))}function sQ(){if(!HZ)return;if(!HZ.dialog.isOpen()){HZ=null;return}let e=Gl(PZ,HZ.projectId,HZ.issueId);e&&HZ.dialog.update(Wl(e))}function cQ(e){let t=rQ(e);t&&_d(`get-radar-report`,{issueId:t},{timeoutMs:q}).then(n=>{n.ok?n.found?tp({issueId:t,issueTitle:String(e.title??``),format:String(n.format??``),content:String(n.content||``)}):tp({issueId:t,issueTitle:String(e.title??``),message:String(n.message||`Report not found`)}):tp({issueId:t,issueTitle:String(e.title??``),error:String(n.error||`Could not read report`)})}).catch(n=>{tp({issueId:t,issueTitle:String(e.title??``),error:Ad(n,q)})})}function lQ(){let e=M(`div`,`radar-issue-actions`),t=M(`span`,`radar-issue-action-status`);t.setAttribute(`role`,`status`),e.append(t);let n=[],r=null,i=()=>{r?.remove(),r=null},a=t=>{i(),r=t,e.append(t)},o=e=>{for(let t of n)t.disabled=e};return{addButton:(r,i,a)=>{let o=M(`button`,`radar-issue-action`,r);return o.type=`button`,o.title=i,o.addEventListener(`click`,e=>{e.stopPropagation(),a()}),n.push(o),e.insertBefore(o,t),o},request:(e,n,r,a,s,c=null)=>{BZ.begin(e),o(!0),i(),t.dataset.tone=`busy`,t.textContent=a;let l=(n,r)=>{o(!1),i(),t.dataset.tone=n,t.textContent=r,BZ.settle(e)};_d(n,r,{timeoutMs:QZ}).then(e=>{e.ok?(l(`ok`,s(e)),c&&c(e)):l(`error`,String(e.error||`Request failed`))}).catch(e=>l(`error`,Ad(e,QZ)))},showFollowUp:a,wrap:e}}function uQ(e){let t=M(`button`,`radar-issue-action radar-open-trace`,`Open trace`);return t.type=`button`,t.title=`Open the session trace`,t.addEventListener(`click`,t=>{t.stopPropagation(),jQ(e)}),t}function dQ(e,t,n){let{addButton:r,request:i,showFollowUp:a,wrap:o}=lQ(),s=(n,r,a,o,s=null)=>i(`${n}:${e.issueId}`,n,{projectId:t,issueId:e.issueId,...r},a,o,s);return e.inFlight&&r(`View investigation`,`Watch the running investigation`,()=>oQ(e,t,n)),!e.inFlight&&e.verdict&&rQ(e)&&r(`Open report`,`Open the investigation report for this issue`,()=>cQ(e)),e.inFlight||r(`Open session`,`Paste an investigation prompt into the mapped project session`,()=>{s(`radar-open-session`,{},`Opening session`,e=>e.pending?`Starting ${String(e.sessionName||`session`)}; the prompt lands when it is up`:`Prompt pasted into ${String(e.sessionName||`the session`)}; press Enter there`,e=>{typeof e.sessionId==`string`&&LZ&&a(uQ(e.sessionId))})}),r(`Resolve`,`Mark this issue resolved in PostHog`,()=>{s(`radar-issue-action`,{action:`resolve`},`Resolving in PostHog`,()=>`Marked resolved`)}),r(`Suppress`,`Suppress this issue in PostHog`,()=>{rf({title:`Suppress issue`,message:`This marks the issue suppressed in PostHog for everyone on the project.`,confirmLabel:`Suppress`,danger:!0,onConfirm:()=>s(`radar-issue-action`,{action:`suppress`},`Suppressing in PostHog`,()=>`Marked suppressed`)})}),o}function fQ(e){return oh()?GZ:e}function pQ(e){let t=WZ.get(e);t&&(e.title=t())}function mQ(){if(FZ)for(let e of FZ.querySelectorAll(`.radar-issue-reportable`))pQ(e)}ch(mQ);function hQ(e,t,n){e.classList.add(`radar-issue-reportable`),WZ.set(e,t),pQ(e),e.addEventListener(`click`,e=>{e.target instanceof Element&&(e.target.closest(`a, button`)||n())})}function gQ(e,t,n){let r=M(`div`,`radar-issue`);r.dataset.severity=iu(e.change);let i=M(`span`,`radar-stripe`);i.setAttribute(`aria-hidden`,`true`);let a=M(`span`,`radar-change`,qZ[e.change??``]||String(e.change||`unknown`)),o=dr(`radar-issue-title`,String(e.title||`Untitled issue`),e.url,String(e.title||``)),s=M(`span`,`radar-metric`);s.append(M(`span`,`radar-metric-value`,tQ(e.occurrences)),M(`span`,`radar-metric-label`,`occ`));let c=M(`span`,`radar-metric`);c.append(M(`span`,`radar-metric-value`,tQ(e.users)),M(`span`,`radar-metric-label`,`users`));let l=cu(e.history),u=lu(l,64,16),d=u?document.createElementNS(RZ,`svg`):null;if(d){d.classList.add(`radar-sparkline`),d.setAttribute(`viewBox`,`0 0 64 16`),d.setAttribute(`width`,`64`),d.setAttribute(`height`,`16`),d.setAttribute(`role`,`img`),d.setAttribute(`focusable`,`false`);let e=document.createElementNS(RZ,`title`);e.textContent=du(l);let t=document.createElementNS(RZ,`polyline`);t.setAttribute(`points`,u),d.append(e,t)}let f=Ul(e),p=M(`span`,`radar-issue-copy`);p.append(o);let m=null;f&&(m=M(`span`,`radar-issue-summary`),m.textContent=f,p.append(m)),UZ.set(iQ(t,e.issueId),{copy:p,summary:m});let h=M(`span`,`radar-issue-meta`),g=au(e);if(g!==null){let e=M(`span`,`radar-issue-seen`);e.title=new Date(g).toLocaleString(),KZ.track(e,g,Pf),h.append(e)}let _=ou(e);_&&h.append(M(`span`,`radar-issue-status`,_));let v=String(e.title||e.issueId);if(e.inFlight){let i=M(`span`,`radar-verdict`,`investigating`);i.dataset.verdict=`INVESTIGATING`,h.append(i);let a=typeof e.startedAt==`number`?e.startedAt:null;if(a!==null&&Number.isFinite(a)&&a>0){let e=M(`span`,`radar-issue-elapsed`);KZ.track(e,a,nQ),h.append(e)}rQ(e)&&hQ(r,()=>`Watch the investigation of ${fQ(v)}`,()=>oQ(e,t,n))}if(!e.inFlight&&e.verdict){let t=M(`span`,`radar-verdict`,Xl(e.verdict));t.dataset.verdict=e.verdict,h.append(t),rQ(e)&&hQ(r,()=>`View investigation report for ${fQ(v)}`,()=>cQ(e))}h.childElementCount>0&&p.append(h);let y=M(`span`,`radar-issue-trend`);d&&y.append(d);let b=uu(l);if(b){let e=M(`span`,`radar-delta`,`${b.direction===`up`?`+`:b.direction===`down`?`-`:`=`}${b.percent}%`);e.dataset.direction=b.direction,y.append(e)}let x={stripe:i,change:a,copy:p,occurrences:s,users:c,trend:y};return eQ(r,e=>x[e.columnId]),rQ(e)&&r.append(dQ(e,t,n)),r}var _Q=(e,t,n)=>gr(`radar`,e,t,n);function vQ(e){return e.error?`poll failed: ${e.error}`:e.staleMs>0?`stale ${Nf(e.staleMs)}`:``}function yQ(e,t,{showHost:n,nameTag:r,nameClass:i,hostClass:a}){let o=M(r,i,gu(t));o.title=String(t.name||``),e.append(o);let s=n?_u(t.host):``;s&&e.append(M(`span`,a,s))}function bQ(){let e=$Z(`radar-column-heads`);for(let t of JZ){if(!t.headText){e.append(M(`span`));continue}let n=M(`span`,`radar-column-head`,t.headText);n.dataset.column=t.columnId,e.append(n)}return e}function xQ(e,t){let n=e.project,r=M(`div`,`radar-project`),i=Ou(n.issues),a=fu(i),o=M(`div`,`radar-project-head`);yQ(o,n,{showHost:t,nameTag:`h3`,nameClass:`radar-project-name`,hostClass:`radar-project-host`}),r.append(o);let s=M(`div`,`radar-project-summary`);s.append(_Q(a.active===1?`active issue`:`active issues`,tQ(a.active))),s.append(_Q(`spiking`,tQ(a.spiking),a.spiking>0?`crit`:null)),s.append(_Q(`needs you`,tQ(a.needsHuman),a.needsHuman>0?`warn`:null));let c=vQ(e);if(c){let t=M(`span`,`radar-project-alert`,c);t.dataset.tone=e.error?`crit`:`warn`,s.append(t)}if(r.append(s),i.length===0)return r;r.append(bQ());let l=$Z(`radar-issues`);for(let e of i)l.append(gQ(e,n.projectId,gu(n)));return r.append(l),r}function SQ(e,t){let n=e.project,r=M(`div`,`radar-quiet-row`),i=M(`span`,`radar-quiet-dot`);return i.setAttribute(`aria-hidden`,`true`),r.append(i),yQ(r,n,{showHost:t,nameTag:`span`,nameClass:`radar-quiet-name`,hostClass:`radar-quiet-host`}),r.append(M(`span`,`radar-quiet-count`,`0 issues`)),r}var CQ=(e,t)=>hr(`radar`,e,t);function wQ(){let e=M(`div`,`radar-issue`);return e.dataset.skeleton=``,eQ(e,e=>M(`span`,e.cellClass)),e}function TQ(){let e=$Z(`radar-issues`);e.setAttribute(`aria-busy`,`true`),e.setAttribute(`aria-label`,`Loading issues`);for(let t=0;t<5;t+=1)e.append(wQ());return e}function EQ(e){return e?.configured===!1?typeof e.reason==`string`&&e.reason.trim()!==``?`Fix it in`:`Switch it on in`:``}function DQ(e,t=`ready`){let n=CQ(`Errors`);if(t===`pending`)return n.append(TQ()),n;if(t===`placeholder`||e.length===0){let e=M(`p`,`radar-unconfigured`,tu(PZ)),t=Dp(`lanes-posthog`,`posthog-enabled`,`PostHog settings`),r=EQ(PZ);return e.append(document.createTextNode(r?` ${r} `:` `),t),n.append(e),n}let r=M(`div`,`radar-global-tick`),i=Number(PZ?.intervalMinutes);KZ.track(r,PZ?.ts,e=>{let t=`polled ${Pf(e)}`;return!Number.isFinite(i)||i<=0?t:`${t}, every ${i}m`}),n.append(r);let a=i>0?i*6e4:0,{loud:o,quiet:s}=bu(e,Date.now(),{intervalMs:a}),c=vu(e);for(let e of o)n.append(xQ(e,c));if(s.length===0)return n;let l=M(`div`,`radar-quiet`);for(let e of s)l.append(SQ(e,c));return n.append(l),n}function OQ(e){let{addButton:t,request:n,wrap:r}=lQ();return e.issueId&&t(`Open report`,`Open the investigation report for this issue`,()=>{cQ({issueId:e.issueId,title:e.title})}),t(`Archive`,`Remove this investigation from the inbox`,()=>{n(`archive:${e.id}`,`radar-archive-investigation`,{id:e.id},`Archiving`,()=>`Archived`,()=>VZ.add(e.id))}),r}function kQ(e){let t=M(`div`,`radar-investigation`),n=M(`span`,`radar-verdict`,Xl(e.verdict));n.dataset.verdict=e.verdict;let r=dr(`radar-issue-title`,e.title,e.url),i=M(`span`,`radar-issue-copy`);if(i.append(r),e.summaryLine){let t=M(`span`,`radar-issue-summary`);t.textContent=e.summaryLine,i.append(t)}if(e.prUrl){let t=M(`a`,`radar-investigation-pr`,`fix PR`);t.href=e.prUrl,t.target=`_blank`,t.rel=`noopener`,t.title=e.prUrl,i.append(t)}if(t.append(n),e.mode===`fix`){let e=M(`span`,`radar-verdict`,`fix`);e.dataset.mode=`fix`,t.append(e)}if(t.append(i),e.projectLabel){let n=M(`span`,`radar-investigation-project`);n.textContent=e.projectLabel,t.append(n)}if(e.at>0){let n=M(`span`,`radar-investigation-time`,Pf(e.at));n.title=new Date(e.at).toLocaleString(),t.append(n)}return t.append(OQ(e)),t}function AQ(e){let t=CQ(`Investigations`,`completed, not yet archived`),n=M(`div`,`radar-investigations`);for(let t of e)n.append(kQ(t));return t.append(n),t}function jQ(e){LZ&&LZ(e)}function MQ(){if(!FZ)return;FZ.textContent=``,UZ.clear(),KZ.reset();let e=_r(PZ),t=xu(PZ,VZ),n=ru(PZ,e.length);FZ.append(DQ(e,n)),t.length>0&&FZ.append(AQ(t))}function NQ(){BZ.request()}function PQ(){IZ&&IZ(zZ.refresh())}function FQ(){zZ.acknowledge(),PQ()}function IQ(e){IZ=e,PQ()}function LQ(e){LZ=e}function RQ(e){if(FZ)return FZ;let t=M(`div`,`radar-content`);return e.appendChild(t),FZ=t,KZ.ensure(),MQ(),t}function zQ(e){PZ=e,Su(PZ,VZ),NQ(),PQ(),sQ()}function BQ(e){let t=Gl(PZ,e.projectId,e.issueId)?.inFlight===!0;if(!Kl(PZ,e))return;sQ();let n=Gl(PZ,e.projectId,e.issueId);t&&aQ(e.projectId,e.issueId,n)||NQ()}function VQ(e){HZ?.dialog.isOpen()&&Jl(HZ,e)&&HZ.dialog.update(ql(e))}function HQ(e){Yl(PZ,e)?(sQ(),NQ(),PQ()):VQ(e)}var UQ=Ph({requestPrefix:`session-setup`,dialogClass:`dialog coherence-journal-drawer session-setup-dialog`,titleText:`Session setup`,unavailableLabel:`Session setup unavailable`,timeoutMs:15e3});function WQ(e){let t=M(`ul`,`session-setup-list`);return t.append(...e.map(e=>M(`li`,null,e))),t}function GQ(e,t){e.replaceChildren();function n(t,n){if(n.length===0)return;let r=hr(`session-setup`,t);r.append(...n),e.append(r)}n(`Model`,t.model?[M(`p`,null,t.model)]:[]),n(`Plugins`,t.plugins.map(e=>{let t=M(`div`,`session-setup-plugin`);return t.append(M(`h3`,null,e.name)),e.skills.length>0&&t.append(M(`p`,`session-setup-label`,`Skills`),WQ(e.skills)),e.agents.length>0&&t.append(M(`p`,`session-setup-label`,`Agents`),WQ(e.agents)),t})),n(`MCP servers`,t.mcpServers.length>0?[WQ(t.mcpServers)]:[]),n(`Hooks`,[...t.hookEvents.map(e=>{let t=M(`p`,`session-setup-hook`);return t.append(M(`span`,null,e.event),M(`span`,`session-setup-label`,`${e.runCount} runs`)),t}),...t.hookCommands.map(e=>M(`pre`,`coherence-command`,e))]),n(`Skills`,t.skills.length>0?[WQ(t.skills)]:[]),n(`Agents`,t.agents.length>0?[WQ(t.agents)]:[])}function KQ(e){let t=M(`p`,`coherence-journal-status`,`Loading session setup`);t.setAttribute(`role`,`status`);let n=M(`div`,`session-setup-sections`);UQ.open({sessionId:e,status:t,body:[t,n],parts:{sections:n},buildRequest:t=>({type:`session-setup`,id:e,requestId:t})})}function qQ(e){let t=UQ.settleResponse(e);if(!t)return;if(!e.ok||!e.setup){t.status.textContent=e.error||`Could not read session setup`;return}let n=t.parts.sections;GQ(n,e.setup),t.status.textContent=n.childElementCount>0?``:`No session setup recorded yet`,t.status.hidden=n.childElementCount>0}function JQ(e){return{skipPerms:e.skipPerms??e.dangerouslySkipPermissions??!1,saneYolo:e.saneYolo===!0,worktree:e.worktree??e.isWorktree??!1,workspace:e.workspace??e.isWorkspace??!1,guarded:e.guarded??e.isGuarded??!1,guardrailsReleased:e.guardrailsReleased??e.isGuardrailsReleased??!1,ephemeral:e.ephemeral===!0,ownerId:e.ownerId??null,path:e.path,stateSince:e.stateSince,taskTitle:typeof e.taskTitle==`string`?e.taskTitle:null,taskTitleIsCustom:e.taskTitleIsCustom===!0}}var YQ=null,XQ=null,ZQ=null,QQ=null,$Q=null,e$=null,t$=-1,n$=null,r$={isRightToLeft:!1,arcProgress:0},i$=1,a$=3;function o$(){if(!YQ||n$===null)return;let e=us({viewportWidthPx:document.documentElement.clientWidth,viewportHeightPx:document.documentElement.clientHeight,verticalProgress:n$,...r$});cr(YQ,fs(e,i$,window.devicePixelRatio))}function s$(){e$!==null&&(clearTimeout(e$),e$=null)}function c$(e=Xs()){return es({isEnabled:e,hasReducedMotion:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,isPhone:Ky(),options:Vc()})}function l$(e){e.onanimationend=null,e.style.animation=`none`,QQ&&(QQ.style.animation=`none`),e.hidden=!0}function u$(e,t){if(!YQ||!XQ||!ZQ||!QQ||c$())return;let n=Vc();s$();let r=$o(n,t$,Math.random,t);if(l$(YQ),!r){e$=setTimeout(()=>u$(!1),1e3);return}n$=r.verticalProgress,r$={isRightToLeft:r.isRightToLeft,arcProgress:r.arcProgress},i$=n.flyingAnimalsScale,o$();let i=Go[r.animalIndex];XQ.className=`nyan-sprite ${i.sprite}`,ZQ.className=`nyan-trail ${i.trail}`,t$=r.animalIndex,$Q?.classList.remove(`is-booped`),YQ.hidden=!1,YQ.offsetWidth,YQ.style.animation=`nyan-fly ${r.durationSeconds}s linear`,QQ.style.animation=`nyan-trail-hold ${r.durationSeconds}s linear`,e&&(YQ.style.animationDelay=`-${r.firstDelaySeconds}s`,QQ.style.animationDelay=`-${r.firstDelaySeconds}s`),YQ.onanimationend=e=>{YQ&&e.target===YQ&&(l$(YQ),e$=setTimeout(()=>u$(!1),r.gapMs))}}function d$(){if(YQ&&QQ&&$Q){$Q.classList.remove(`is-booped`),$Q.offsetWidth,$Q.classList.add(`is-booped`);for(let e of[...YQ.getAnimations(),...QQ.getAnimations()])e.playbackRate=a$}}function f$(){if(YQ||c$())return;YQ=document.createElement(`div`),YQ.className=`nyan-flight`,YQ.setAttribute(`aria-hidden`,`true`);let e=document.createElement(`div`);e.className=`nyan-trail-window`,QQ=document.createElement(`div`),QQ.className=`nyan-trail-hold`,ZQ=document.createElement(`div`),QQ.append(ZQ),e.append(QQ),XQ=document.createElement(`div`),$Q=document.createElement(`div`),$Q.className=`nyan-boop`,$Q.append(XQ),$Q.addEventListener(`pointerdown`,d$),YQ.append(e,$Q),document.body.appendChild(YQ),window.addEventListener(`resize`,o$),window.addEventListener(`orientationchange`,o$),u$(!0)}function p$(e){f$(),u$(!1,e)}function m$(){s$(),window.removeEventListener(`resize`,o$),window.removeEventListener(`orientationchange`,o$),YQ?.remove(),YQ=null,XQ=null,ZQ=null,QQ=null,$Q=null,t$=-1,n$=null}var h$=!1;function g$(e){let t=document.documentElement;if(h$||(h$=!0,qy(()=>g$(Xs())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>g$(Xs()))),e){if(t.dataset.flyingAnimals=`true`,c$(e)){m$();return}f$()}else delete t.dataset.flyingAnimals,m$()}function _$(){let e=M(`div`),t=M(`p`,`flying-animals-status`);t.id=`flying-animals-gallery-status`,t.setAttribute(`role`,`status`);let n=M(`div`,`flying-animals-gallery`);n.setAttribute(`aria-label`,`Animal gallery`);let r=[],i=()=>{let e=c$(),n=Zo(Vc().flyingAnimalsExcludedSprites);t.textContent=[e,n?``:`No animals are included, so automatic flights are paused.`].filter(Boolean).join(` `);for(let t of r)t.disabled=e!==null},a=Vc();for(let e of Go){let o=M(`article`,`flying-animal-tile`),s=Gc(e),c=M(`label`,`flying-animal-include`),l=M(`input`,`settings-view-checkbox`);l.type=`checkbox`,l.checked=!a.flyingAnimalsExcludedSprites.includes(e.sprite),l.setAttribute(`aria-label`,`Include ${e.name}`),l.addEventListener(`change`,()=>{let t=new Set(Vc().flyingAnimalsExcludedSprites);l.checked&&t.delete(e.sprite),l.checked||t.add(e.sprite),Bc([...t]),g$(Xs()),i()}),c.append(l,document.createTextNode(`Include`));let u=M(`button`,`btn-dialog btn-dialog-cancel`,`Fly now`);u.type=`button`,u.setAttribute(`aria-describedby`,t.id),u.addEventListener(`click`,()=>p$(e.sprite)),r.push(u),o.append(s,M(`h2`,`flying-animal-name`,e.name),c,u),n.append(o)}return i(),e.append(t,n),e}var v$=`johncwaters/glimmervoid`,y$={maxConcurrentInvestigations:Math.ceil,minUsersToInvestigate:Math.ceil,userEscalationThreshold:Math.ceil,trafficSpikeMinUsers:Math.ceil,trafficSpikeBaselineDays:Math.floor};[...Object.entries(y$).map(([e,t])=>({path:[`posthog`,e],min:1,round:t}))];var b$=Object.freeze([`auto`,`calculate`,`display`]),x$=Object.freeze([`codex`,`grok`]),S$=Object.freeze([`dailyUsd`,`monthlyUsd`]),C$=e=>t({error:`${e} must be a boolean`}).optional(),w$=(e,t=!1)=>{let n=l({error:`${e} must be a string`});return(t?n.transform(e=>e.trim()):n).optional()},T$=e=>e.label?e.label:e.max==null?e.exclusiveMin?`greater than ${e.min}`:`at least ${e.min}`:`between ${e.min} and ${e.max}`,E$=(e,t=A)=>c({error:`${e} must be ${T$(t)}`}).finite().refine(e=>!t.exclusiveMin||e>t.min,{message:`${e} must be ${T$(t)}`}).refine(e=>t.exclusiveMin||e>=t.min,{message:`${e} must be ${T$(t)}`}).refine(e=>t.max==null||e<=t.max,{message:`${e} must be ${T$(t)}`}).optional(),D$=(e,t)=>E$(e,t).unwrap().int({error:`${e} must be a whole number ${T$(t)}`}).optional(),O$=(e,t)=>c({error:`${e} must be an integer between ${t.min} and ${t.max}`}).int({error:`${e} must be an integer between ${t.min} and ${t.max}`}).min(t.min,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).max(t.max,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).optional(),k$=(e,t)=>g(t,{error:`${e} must be an object`}).nullable().optional(),A$=Object.freeze([`claude`,`codex`]),j$=Object.freeze([`release`,`main`]),M$=Object.freeze([`report`,`fix`]);k$(`changeMap`,{narrator:k$(`changeMap.narrator`,{enabled:C$(`changeMap.narrator.enabled`),engine:u(A$,{error:`changeMap.narrator.engine must be one of ${A$.join(`, `)}`}).optional(),model:w$(`changeMap.narrator.model`,!0),timeoutSeconds:O$(`changeMap.narrator.timeoutSeconds`,rn)})}),g({refiner:g({enabled:C$(`taskTitle.refiner.enabled`),model:w$(`taskTitle.refiner.model`,!0),minIntervalSeconds:E$(`taskTitle.refiner.minIntervalSeconds`,{min:0}),timeoutSeconds:E$(`taskTitle.refiner.timeoutSeconds`,At)},{error:`taskTitle.refiner must be an object`}).nullable().optional()},{error:`taskTitle must be an object`}).nullable().optional();var N$={enabled:C$(`branchGc.enabled`),worktrees:C$(`branchGc.worktrees`),prefixes:p(l({error:`branchGc.prefixes must be an array of strings`}).min(1,{error:`branchGc.prefixes entries must be non-empty strings`}),{error:`branchGc.prefixes must be an array of strings`}).optional(),dryRun:C$(`branchGc.dryRun`),staleDays:E$(`branchGc.staleDays`,jt),deleteUnmerged:C$(`branchGc.deleteUnmerged`),intervalMs:E$(`branchGc.intervalMs`,Mt)},P$=g(N$,{error:`branchGc must be an object`});k$(`branchGc`,N$),P$.omit({prefixes:!0,dryRun:!0,worktrees:!0}).nullable().optional(),Object.freeze([`enabled`,`deleteUnmerged`]),Object.freeze([`staleDays`,`intervalMs`]),k$(`postTurnChecks`,{mode:u(M$,{error:`postTurnChecks.mode must be one of report, fix`}).optional()}),k$(`visions`,{enabled:C$(`visions.enabled`),autoFix:C$(`visions.autoFix`),projects:p(l({error:`visions.projects must be an array of strings`}),{error:`visions.projects must be an array of strings`}).optional(),dispatch:k$(`visions.dispatch`,{enabled:C$(`visions.dispatch.enabled`),model:w$(`visions.dispatch.model`,!0),quietMs:D$(`visions.dispatch.quietMs`,Nt),cooldownMs:D$(`visions.dispatch.cooldownMs`,Pt),maxPerHour:D$(`visions.dispatch.maxPerHour`,Ft),activityMaxPerHour:D$(`visions.dispatch.activityMaxPerHour`,It),dispatchTimeoutSeconds:D$(`visions.dispatch.dispatchTimeoutSeconds`,Lt)}),intent:k$(`visions.intent`,{threadTtlMs:D$(`visions.intent.threadTtlMs`,Rt)})}),g({teams:p(l({error:`github.teams must be an array of org/slug strings`}).refine(e=>ie(e)!==null,{message:`github.teams entries must be org/slug with valid GitHub segments`}),{error:`github.teams must be an array of org/slug strings`}).optional()},{error:`github must be an object`}).nullable().optional(),k$(`teamReview`,{enabled:C$(`teamReview.enabled`),autoRebaseMyPrs:C$(`teamReview.autoRebaseMyPrs`),keepMergeableEnabled:C$(`teamReview.keepMergeableEnabled`),mergeQueueEnabled:C$(`teamReview.mergeQueueEnabled`),keepMergeableTimeoutMinutes:O$(`teamReview.keepMergeableTimeoutMinutes`,an),org:w$(`teamReview.org`,!0),team:w$(`teamReview.team`,!0),skill:w$(`teamReview.skill`,!0),reReviewAfterHours:E$(`teamReview.reReviewAfterHours`),skipIdleAfterDays:E$(`teamReview.skipIdleAfterDays`)}),k$(`benchmarks`,{enabled:C$(`benchmarks.enabled`)}),k$(`coherence`,{enabled:C$(`coherence.enabled`)});var F$={intervalMinutes:zt,maxConcurrentInvestigations:Bt,investigationTimeoutSeconds:Vt,fixTimeoutSeconds:Kt,minUsersToInvestigate:Ht,userEscalationThreshold:Ut,recurrenceWindowDays:Wt,transientRecurrenceLimit:Gt,trafficSpikeMultiplier:qt,trafficSpikeMinUsers:Jt,trafficSpikeCooldownMinutes:Yt,trafficSpikeBaselineDays:Xt};k$(`posthog`,{enabled:C$(`posthog.enabled`),recurrenceDedupe:C$(`posthog.recurrenceDedupe`),trafficSpikeEnabled:C$(`posthog.trafficSpikeEnabled`),autoFix:C$(`posthog.autoFix`),host:w$(`posthog.host`,!0).refine(e=>e==null||!e||/^https?:\/\//i.test(e),{message:`posthog.host must be an http(s) URL`}),apiKey:w$(`posthog.apiKey`,!0),repoPath:w$(`posthog.repoPath`,!0),projects:a([m(`all`),p(c({error:`posthog.projects must be "all" or an array of positive integer project ids`}).int({error:`posthog.projects must be "all" or an array of positive integer project ids`}).positive({error:`posthog.projects must be "all" or an array of positive integer project ids`}),{error:`posthog.projects must be "all" or an array of positive integer project ids`})],{error:`posthog.projects must be "all" or an array of positive integer project ids`}).optional(),projectMap:i(l(),e(),{error:`posthog.projectMap must be an object`}).optional(),...Object.fromEntries(Object.entries(F$).map(([e,t])=>[e,Object.hasOwn(y$,e)?D$(`posthog.${e}`,t):E$(`posthog.${e}`,t)]))}),`${b$.join(`, `)}`,Object.fromEntries(x$.map(e=>[e,C$(`usage.vendors.${e}`)])),Object.fromEntries(S$.map(e=>[e,c({error:`usage.budget.${e} must be a positive number or null`}).positive({error:`usage.budget.${e} must be a positive number or null`}).nullable().optional()])),k$(`telegram`,{botToken:w$(`telegram.botToken`,!0),chatId:w$(`telegram.chatId`,!0)}),g({enabled:C$(`ingest.enabled`)},{error:`ingest must be an object`}).passthrough().optional(),g({enabled:C$(`trace.enabled`)},{error:`trace must be an object`}).optional(),g({enabled:C$(`planReview.enabled`)},{error:`planReview must be an object`}).optional();var I$=e=>p(l({error:`${e} must be an array of paths`}).trim().min(1,{error:`${e} must be an array of paths`}),{error:`${e} must be an array of paths`}).optional(),L$={unguardedRepos:I$(`guardrails.unguardedRepos`),blockedPaths:I$(`guardrails.blockedPaths`),unreadablePaths:I$(`guardrails.unreadablePaths`)};g(L$,{error:`guardrails must be an object`}).passthrough().optional();var R$={enabled:C$(`telemetry.enabled`)};g(R$,{error:`telemetry must be an object`}).strict().optional(),g(R$,{error:`telemetry must be an object`}).passthrough().optional();var z$={scope:`browser`,access:`editable`,takesEffect:`now`},B$={scope:`browser`,access:`advanced`,takesEffect:`now`},X={scope:`machine`,access:`editable`,takesEffect:`now`},V$={scope:`machine`,access:`editable`,takesEffect:`new-sessions`},H$={scope:`machine`,access:`readout`,takesEffect:`now`},Z={scope:`machine`,access:`file-only`},U$=1e3,W$=60,G$=60,K$=U$*W$,q$=K$*G$,J$=q$*24,Y$={label:`investigations`,storedPerDisplay:1},X$={label:`sessions`,storedPerDisplay:1},Z$={label:`recurrences`,storedPerDisplay:1},Q$={label:`actions`,storedPerDisplay:1},$$={label:`seconds`,storedPerDisplay:1},e1={label:`minutes`,storedPerDisplay:1},t1={label:`hours`,storedPerDisplay:1},n1={label:`days`,storedPerDisplay:1},r1={label:`seconds`,storedPerDisplay:U$,storedLabel:`ms`},i1={label:`minutes`,storedPerDisplay:K$,storedLabel:`ms`},a1={label:`minutes`,storedPerDisplay:W$,storedLabel:`seconds`},o1={label:`hours`,storedPerDisplay:q$,storedLabel:`ms`},s1={label:`hours`,storedPerDisplay:G$,storedLabel:`minutes`},c1={label:`days`,storedPerDisplay:J$,storedLabel:`ms`},l1={label:`USD`,storedPerDisplay:1},u1={label:`users`,storedPerDisplay:1},d1={label:`reviews per hour`,storedPerDisplay:1},f1={label:`times`,storedPerDisplay:1},Q=`A tuning knob kept out of the Settings view; the default suits almost every install.`,p1=`A diagnostic switch kept out of the Settings view; change it in config.json while investigating.`,m1=`Changes how the server process or its worktrees behave, so it is set in config.json with a restart or new sessions in mind.`,h1=`A structured value with no dashboard control; edit it in config.json.`,g1=`Never editable from the dashboard by rule; edit it in config.json.`;function _1(e){return e.map(e=>({value:e,label:e[0].toUpperCase()+e.slice(1)}))}var v1=Object.freeze({"machine-terminal":{title:`Terminal`,description:`Terminal behavior shared by dashboard clients.`},"machine-detection-sessions":{title:`Detection and sessions`,description:`Config-file-only detection, timing, worktree and process settings.`},"lanes-ingest":{title:`Ingest`,description:`The machine-context sources behind Visions.`}}),y1=Object.freeze([{id:`browser-appearance`,level:`browser`,title:`Appearance`,description:`How this browser draws the dashboard.`,legacyIds:[`browser-flying-animals`,`animals`,`flying-animals`],settings:[{id:`theme`,path:`pref:themeId`,title:`Theme`,description:`Color scheme for the dashboard.`,control:`select`,optionsFrom:`themes`,keywords:[`color`,`palette`],defaultValue:`phyrexian`,...z$},{id:`session-usage-chips`,path:`pref:sessionUsageChips`,title:`Show usage on session cards`,description:`Shows each card's transcript token count and CLI-reported cost when available, otherwise a calculated API list-price estimate.`,control:`toggle`,keywords:[`usage`,`cost`,`tokens`,`card`,`price`],defaultValue:!1,...z$},{id:`phone-arrow-pad`,path:`pref:phoneArrowPad`,title:`Swipe arrow pad on phone (experimental)`,description:`Replace the four arrow keys above the phone keyboard with one pad: swipe on it to send arrow keys, one per short drag.`,control:`toggle`,keywords:[`experimental`,`mobile`,`keys`,`arrows`,`swipe`,`gesture`],defaultValue:!1,...z$},{id:`flying-animals`,path:`pref:flyingAnimalsEnabled`,title:`Flying animals`,description:`Show animated animals flying across the dashboard.`,control:`toggle`,keywords:[`animation`,`motion`,`animals`],defaultValue:!1,...z$},{id:`animals-min-gap`,path:`pref:flyingAnimalsMinGapSeconds`,title:`Time between flights: minimum`,description:`Shortest pause between flights.`,control:`number`,integer:!1,step:.1,range:Ct,unit:$$,maximumSettingId:`animals-max-gap`,keywords:[`animals`,`frequency`],defaultValue:Et.flyingAnimalsMinGapSeconds,...B$},{id:`animals-max-gap`,path:`pref:flyingAnimalsMaxGapSeconds`,title:`Time between flights: maximum`,description:`Longest pause between flights.`,control:`number`,integer:!1,step:.1,range:Ct,unit:$$,keywords:[`animals`,`frequency`],defaultValue:Et.flyingAnimalsMaxGapSeconds,...B$},{id:`animals-min-duration`,path:`pref:flyingAnimalsMinDurationSeconds`,title:`Flight duration: minimum`,description:`Shortest flight, for faster animals.`,control:`number`,integer:!1,step:.1,range:wt,unit:$$,maximumSettingId:`animals-max-duration`,keywords:[`animals`,`speed`],defaultValue:Et.flyingAnimalsMinDurationSeconds,...B$},{id:`animals-max-duration`,path:`pref:flyingAnimalsMaxDurationSeconds`,title:`Flight duration: maximum`,description:`Longest flight, for slower animals.`,control:`number`,integer:!1,step:.1,range:wt,unit:$$,keywords:[`animals`,`speed`],defaultValue:Et.flyingAnimalsMaxDurationSeconds,...B$},{id:`animals-scale`,path:`pref:flyingAnimalsScale`,title:`Size multiplier`,description:`Scale applied on top of the viewport size.`,control:`number`,integer:!1,step:.1,range:Tt,unit:f1,keywords:[`animals`,`size`],defaultValue:Et.flyingAnimalsScale,...B$},{id:`animals-on-phone`,path:`pref:flyingAnimalsOnPhone`,title:`Show on phone layout`,description:`Allow flights on the phone layout.`,control:`toggle`,keywords:[`animals`,`mobile`],defaultValue:Et.flyingAnimalsOnPhone,...B$}]},{id:`browser-notifications`,level:`browser`,title:`Notifications`,description:`How this browser, and the Telegram bot shared by every lane, get your attention.`,settings:[{id:`alert-sounds-enabled`,path:`pref:soundEnabled`,title:`Alert sounds`,legacyIds:[{sectionId:`browser-appearance`,settingId:`alert-sounds-enabled`}],description:`Play sounds when a session needs attention and when a merge celebration plays. The same switch as the note button in the desktop header.`,control:`toggle`,keywords:[`audio`,`mute`,`sound`,`notification`],defaultValue:!0,...z$},{id:`alert-sound`,path:`pref:soundId`,title:`Alert sound`,legacyIds:[{sectionId:`browser-appearance`,settingId:`alert-sound`}],description:`Sound played when a session needs attention. Your own .ogg, .mp3, .wav, .m4a or .webm files dropped into the sounds folder of the Glimmervoid home (~/.glimmervoid/sounds/, or $GLIMMERVOID_HOME/sounds/) are listed after the built-in sounds. Glimmervoid never creates that folder, so make it yourself; new files show up the next time Settings opens.`,control:`select`,optionsFrom:`sounds`,keywords:[`audio`,`notification`,`custom`],defaultValue:`chime`,...z$},{id:`desktop-notifications`,path:`pref:notificationsEnabled`,title:`Desktop notifications`,legacyIds:[{sectionId:`browser-appearance`,settingId:`desktop-notifications`}],description:`Raise a browser notification when a session needs attention while this dashboard is in the background.`,control:`toggle`,keywords:[`browser`,`attention`],defaultValue:!0,...z$}]},{id:`machine-telegram`,level:`machine`,parent:`browser-notifications`,title:`Telegram`,description:`One bot shared by session, PR review and PostHog notifications.`,legacyIds:[`telegram`,`notifications`],settings:[{id:`telegram-bot-token`,path:`telegram.botToken`,title:`Bot token`,description:`Credential used by the shared Telegram bot. Create a bot by messaging @BotFather in Telegram and sending /newbot; it replies with this token. When GLIMMERVOID_TELEGRAM_BOT_TOKEN supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`api`],defaultValue:``,...X},{id:`telegram-chat-id`,path:`telegram.chatId`,title:`Chat id`,description:`Destination chat for enabled Telegram lanes. Send your bot any message, then open https://api.telegram.org/bot<token>/getUpdates in a browser and copy the number under message.chat.id.`,control:`text`,keywords:[`destination`,`channel`],defaultValue:``,...X},{id:`telegram-session-notifications`,path:`telegramNotifications`,title:`Send session notifications`,description:`Send session completion, input and failure alerts when no dashboard is open. Unacknowledged alerts also escalate after the phone escalation delay while a dashboard remains open.`,control:`toggle`,keywords:[`phone`,`off dashboard`,`test`],defaultValue:!1,status:`telegram-delivery`,...X}]},{id:`machine-sessions`,level:`machine`,title:`Sessions`,description:`How sessions start, where projects are found, and what the dashboard shows for them.`,legacyIds:[`machine-general`,`general`,`machine-repositories`,`repos`,`repositories`],settings:[{id:`auto-resume`,path:`autoResume`,title:`Auto-resume sessions on startup`,description:`Resume conversations that were live when Glimmervoid last shut down or crashed, and tell sessions that were mid-turn, or had a background agent, monitor or scheduled wakeup in flight, to continue.`,control:`toggle`,keywords:[`startup`,`conversation`],defaultValue:!0,...X},{id:`conversation-view`,path:`conversationView`,title:`Conversation view (experimental)`,description:`Let each Claude Code and Codex session turn on a Conversation face from its card menu, which renders the transcript as messages, approvals and a composer. Sessions stay on the terminal until you turn it on for them. A Claude Code session started while this is on can answer its permission prompts and questions there. A Codex session connects on its next start, through a local app-server so approvals can be answered from the dashboard; guarded Codex sessions and those that bypass Codex hook trust keep the terminal only.`,control:`toggle`,keywords:[`experimental`,`transcript`,`chat`,`codex`,`claude`],defaultValue:!1,...X},{id:`zen-view`,path:`zenView`,title:`Zen view (experimental)`,description:`Add a Zen tab that shows no terminal until a session needs you, then shows only that session and what it needs.`,control:`toggle`,keywords:[`experimental`,`calm`,`focus`,`attention`,`needs you`],defaultValue:!1,...X},{id:`remote-sessions`,path:`remoteSessions`,title:`Remote Coder sessions (experimental)`,description:`Offer the Coder environments in config.json when adding a session, so the session runs in its own Coder workspace instead of on this machine. Off refuses new remote sessions; ones already running keep working until closed.`,control:`toggle`,keywords:[`experimental`,`coder`,`remote`,`workspace`,`cloud`],defaultValue:!1,...X},{id:`streamer-mode`,path:`streamerMode`,title:`Streamer mode`,description:`Hide sensitive details in the dashboard while screen sharing or streaming.`,control:`toggle`,keywords:[`streaming`,`screen share`,`privacy`],defaultValue:!1,...X},{id:`repository-roots`,path:`repoRoots`,title:`Repository roots`,description:`Directories scanned for projects when adding sessions.`,control:`list`,keywords:[`folders`,`project discovery`],defaultValue:[],listPlaceholder:`Repository root path`,listEmptyText:`No repository roots configured.`,...X},{id:`custom-agents`,path:`status:custom-agents`,title:`Custom agents`,description:`Extra agent CLIs a session can be spawned with, declared under customAgents in config.json.`,control:`readonly`,keywords:[`adapters`,`cli`],status:`custom-agents`,...H$},{id:`agent-logins`,path:`status:agent-logins`,title:`Agent logins`,description:`How Claude Code and Codex sign in inside a Coder workspace. Each uses the login already on this machine; Connect signs one in for Glimmervoid alone when there is none.`,control:`readonly`,keywords:[`claude`,`codex`,`sign in`,`login`,`coder`,`remote`],status:`agent-logins`,...H$}]},{id:`machine-guardrails`,level:`machine`,title:`Guardrails and unattended`,description:`What a guarded session may touch, and which unattended actions automated work may take. Claude Code sessions on Linux and macOS write anywhere this account can, except credentials, Glimmervoid's own state and the blocked folders here.`,legacyIds:[`lanes-unattended`,`unattended`],settings:[{id:`skip-permissions-by-default`,path:`skipPermissionsByDefault`,title:`Skip permission prompts by default`,description:`Start sessions whose project sets no permission choice with the agent CLI permission bypass flag.`,control:`toggle`,keywords:[`permissions`,`yolo`,`dangerously`],danger:!0,warning:`Enabling this control lets agents edit files and run shell commands without asking, and restarts running sessions that inherit it.`,defaultValue:!1,...X},{id:`sane-yolo`,path:`saneYolo`,title:`Sane YOLO`,description:`Block catastrophic commands in sessions that skip permission prompts when the cc-safety-net executable is available and trusted hooks are installed. Missing or untrusted hooks leave a session unprotected.`,control:`toggle`,keywords:[`permissions`,`yolo`,`safety`],defaultValue:!0,...V$},{id:`rtk-compression`,path:`rtk`,title:`rtk output compression`,description:`Compress Bash output with the rtk executable.`,control:`toggle`,keywords:[`bash`,`tokens`],danger:!0,status:`rtk-install`,warning:`Enabling this control permits Glimmervoid to install the pinned rtk executable automatically.`,defaultValue:!1,...V$},{id:`post-turn-checks-mode`,path:`postTurnChecks.mode`,title:`Post-turn checks mode`,description:`Default mode for post-turn checks. Project and individual rule modes override it, so Report can still allow file fixes.`,control:`select`,options:_1(M$),keywords:[`quality`,`fixes`],defaultValue:`report`,...X},{id:`branch-gc-delete-unmerged`,path:`branchGc.deleteUnmerged`,title:`Delete unmerged branches`,description:`Also delete stale remote branches with no merge proof. Off keeps every unmerged branch.`,control:`toggle`,keywords:[`git`,`cleanup`,`orphan`],danger:!0,warning:`Enabling this control lets branch cleanup delete stale remote branches without merge proof.`,defaultValue:!1,...X},{id:`guardrails-unguarded-repos`,path:`guardrails.unguardedRepos`,title:`Unguarded repositories`,description:`Folders whose sessions run without guardrails. A session started in one of these folders, or below it, is not guarded.`,control:`list`,keywords:[`guardrails`,`opt out`,`dotfiles`],danger:!0,warning:`A session without guardrails can read credentials and write anywhere this account can.`,defaultValue:[],listPlaceholder:`Folder path`,listEmptyText:`Every repository is guarded.`,...V$},{id:`guardrails-blocked-paths`,path:`guardrails.blockedPaths`,title:`Blocked folders`,description:`Extra folders and files a guarded session cannot write, on top of credentials and Glimmervoid's own state. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`block`,`protect`],defaultValue:[],listPlaceholder:`~/folder`,listEmptyText:`Only the built-in list is blocked.`,...V$},{id:`guardrails-unreadable-paths`,path:`guardrails.unreadablePaths`,title:`Unreadable folders`,description:`Extra folders and files a guarded session cannot read, on top of the built-in credential list. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`secrets`,`credentials`],defaultValue:[],listPlaceholder:`~/folder`,listEmptyText:`Only the built-in credential list is unreadable.`,...V$}]},{id:`machine-updates`,level:`machine`,title:`Updates`,description:`See which Glimmervoid version is running, which one is newest, and update in one step.`,legacyIds:[`updates`],settings:[{id:`update-actions`,path:`status:update-actions`,title:`Status and actions`,legacyIds:[`update-summary`,`update-installed`,`update-latest`,`update-last-checked`].map(e=>({sectionId:`machine-updates`,settingId:e})),description:`Whether this install is up to date, the running and newest versions, the last check, and the update and restart actions.`,control:`readonly`,keywords:[`version`,`available`,`current`,`check`,`restart`,`commit`,`installed`,`release`,`failure`],status:`update-actions`,...H$},{id:`update-channel`,path:`updateChannel`,title:`Channel`,description:`Track tagged releases or the upstream of the checked-out branch.`,control:`select`,options:_1(j$),keywords:[`release`,`branch`],defaultValue:`release`,...X},{id:`check-updates`,path:`checkForUpdates`,title:`Check for updates automatically`,description:`Check for a newer Glimmervoid at launch, while a dashboard is connected, and when this page opens.`,control:`toggle`,keywords:[`release`,`github`],defaultValue:!0,...X}]},{id:`machine-usage`,level:`machine`,title:`Usage`,description:`Local transcript accounting and estimated-cost budgets.`,legacyIds:[`usage`],settings:[{id:`usage-enabled`,path:`usage.enabled`,title:`Track token usage`,description:`Read local CLI transcripts and roll them into the Usage view and session chips.`,control:`toggle`,keywords:[`tokens`,`cost`],defaultValue:!0,status:`usage-last-report`,...X},{id:`usage-retain-days`,path:`usage.retainDays`,title:`Retain transcript detail`,description:`How long live transcript detail stays available. A monthly budget keeps detail from the start of the current month when that is longer.`,control:`number`,range:Qt,unit:n1,keywords:[`history`,`retention`],defaultValue:90,...X},{id:`usage-daily-budget`,path:`usage.budget.dailyUsd`,title:`Daily budget`,description:`Estimated daily spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:tn,unit:l1,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01,...X},{id:`usage-monthly-budget`,path:`usage.budget.monthlyUsd`,title:`Monthly budget`,description:`Estimated monthly spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:tn,unit:l1,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01,...X}]},{id:`lanes-visions`,level:`lanes`,title:`Visions`,description:`Editor-buffer findings, bounded model comments, and the machine-context ingest behind them.`,legacyIds:[`lanes`,`visions`,`lanes-ingest`,`ingest`],settings:[{id:`visions-enabled`,path:`visions.enabled`,title:`Enable Visions`,description:`Set up supported editors detected on this machine, then show their buffer findings in the Visions view.`,control:`toggle`,keywords:[`editor`,`findings`,`lsp`],defaultValue:!1,...X},{id:`visions-dispatch-enabled`,path:`visions.dispatch.enabled`,title:`Enable model comments`,description:`Start bounded review sessions for local editor buffers.`,control:`toggle`,keywords:[`review`,`dispatch`],defaultValue:!1,...X},{id:`visions-max-per-hour`,path:`visions.dispatch.maxPerHour`,title:`Max per hour`,description:`Maximum review sessions dispatched per hour. One slot is reserved for edit reviews; activity-driven reviews take the rest, up to the activity cap set by visions.dispatch.activityMaxPerHour.`,control:`number`,range:A,unit:d1,keywords:[`rate limit`,`reviews`],defaultValue:6,...X},{id:`visions-model`,path:`visions.dispatch.model`,title:`Model override`,description:`Leave blank to use the opus model alias.`,control:`text`,keywords:[`claude`,`override`],defaultValue:``,...X},{id:`visions-projects`,path:`visions.projects`,title:`Projects`,description:`Clear every selection, including unavailable projects, to accept buffers from every configured project.`,control:`projects`,keywords:[`repositories`,`filter`],defaultValue:[],...X},{id:`visions-auto-fix`,path:`visions.autoFix`,title:`Apply tier 1 fixes`,description:`Allow Visions to edit eligible open Markdown buffers, including inactive buffers, without asking.`,control:`toggle`,keywords:[`automatic`,`edits`],danger:!0,warning:`Enabling this control lets Visions edit eligible buffers without a carbon unit present.`,defaultValue:!1,...X},{id:`ingest-enabled`,path:`ingest.enabled`,title:`Enable machine context ingest`,description:`Enable the local activity feed behind Visions. Turning Visions on enables ingest unless ingest.enabled is explicitly false.`,control:`toggle`,keywords:[`events`,`activity`,`ingest`],defaultValue:!1,...X}]},{id:`lanes-posthog`,level:`lanes`,title:`PostHog`,description:`Error monitoring, investigations and traffic-spike alerts.`,legacyIds:[`posthog`],settings:[{id:`posthog-enabled`,path:`posthog.enabled`,title:`Enable PostHog monitoring`,description:`Poll PostHog error tracking and investigate issues that move.`,control:`toggle`,keywords:[`errors`,`monitoring`],defaultValue:!1,...X},{id:`posthog-host`,path:`posthog.host`,title:`Host`,description:`PostHog cloud or self-hosted HTTP URL.`,control:`text`,keywords:[`url`,`server`],defaultValue:`https://us.posthog.com`,...X},{id:`posthog-api-key`,path:`posthog.apiKey`,title:`Personal API key`,description:`Credential with read access to PostHog projects. When GLIMMERVOID_POSTHOG_API_KEY supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`token`],defaultValue:``,...X},{id:`posthog-projects`,path:`posthog.projects`,title:`Projects`,description:`PostHog project ids to monitor. config.json holds "all" or an array of ids, and an empty array monitors no project. In Settings that empty array shows as none, and an empty list saves "all".`,control:`list`,keywords:[`project ids`,`filter`],defaultValue:`all`,valueKind:`posthog-projects`,listPlaceholder:`Project id`,listEmptyText:`Every project the key can read.`,...X},{id:`posthog-interval`,path:`posthog.intervalMinutes`,title:`Poll interval`,description:`Delay between PostHog polling passes.`,control:`number`,integer:!1,step:`any`,range:A,unit:e1,keywords:[`refresh`,`schedule`],defaultValue:15,...X},{id:`posthog-max-investigations`,path:`posthog.maxConcurrentInvestigations`,title:`Max concurrent investigations`,description:`Maximum investigation sessions running together.`,control:`number`,range:A,unit:Y$,keywords:[`parallel`,`workers`],defaultValue:2,...X},{id:`posthog-min-users`,path:`posthog.minUsersToInvestigate`,title:`Min users to investigate`,description:`Minimum affected users for a new issue investigation. Regressions, worsening issues and eligible error spikes bypass this minimum.`,control:`number`,range:A,unit:u1,keywords:[`threshold`,`affected`],defaultValue:1,...X},{id:`posthog-traffic-enabled`,path:`posthog.trafficSpikeEnabled`,title:`Traffic spike alerts`,description:`Ping when recent unique users exceed a project baseline.`,control:`toggle`,keywords:[`analytics`,`alert`],defaultValue:!0,...X},{id:`posthog-auto-fix`,path:`posthog.autoFix`,title:`Attempt fixes for major issues`,description:`Allow an isolated agent to fix an issue, push a branch and open a pull request.`,control:`toggle`,keywords:[`automatic`,`pull request`],danger:!0,warning:`Enabling this control lets PostHog fixes commit, push and open pull requests automatically.`,defaultValue:!1,...X}]},{id:`lanes-team-review`,level:`lanes`,title:`Team review`,description:`Draft reviews of teammates' pull requests for you to post from the Reviews tab.`,legacyIds:[`team-review`,`reviews`],settings:[{id:`team-review-enabled`,path:`teamReview.enabled`,title:`Enable team review`,description:`Poll open pull requests from the team and draft a review of each one. Nothing is posted until you choose Approve or Comment.`,control:`toggle`,keywords:[`pull requests`,`github`],defaultValue:!1,...X},{id:`github-teams`,path:`github.teams`,title:`GitHub teams`,description:`Teams to search for review requests and members, one org/slug per entry. Leave empty to fall back to the legacy teamReview.org and teamReview.team keys in config.json.`,control:`list`,keywords:[`github`,`teams`,`review requests`],defaultValue:[],listPlaceholder:`org/team-slug`,listEmptyText:`No GitHub teams configured.`,...X},{id:`team-review-re-review-after-hours`,path:`teamReview.reReviewAfterHours`,title:`Re-review after`,description:`When a reviewed PR has a new head, review it again after this long since its last review. Queue review runs it at any time.`,control:`number`,range:A,unit:t1,keywords:[`review`,`delay`],defaultValue:24,integer:!1,step:.5,...X},{id:`team-review-skip-idle-after-days`,path:`teamReview.skipIdleAfterDays`,title:`Skip PRs idle for`,description:`Leave pull requests without GitHub activity for this long out of automatic review.`,control:`number`,range:A,unit:n1,keywords:[`idle`,`activity`],defaultValue:14,integer:!1,step:.5,...X},{id:`team-review-skill`,path:`teamReview.skill`,title:`Review skill`,description:`Name of a Claude Code skill installed for the review agent, for example your own PR review skill. Leave empty to let the agent review with whatever skills it has.`,control:`text`,keywords:[`skill`,`claude code`,`pr review`],defaultValue:``,...X},{id:`team-review-auto-rebase-my-prs`,path:`teamReview.autoRebaseMyPrs`,title:`Keep my pull requests rebased`,description:`On each poll, rebase your open, non-draft pull requests that are behind their base branch. A pull request with conflicts or checks still running is left alone, and a failed rebase is not retried until you push again.`,control:`toggle`,keywords:[`rebase`,`update branch`,`behind`,`my prs`],danger:!0,warning:`Enabling this control rewrites your pull request branches on GitHub. Pull before you push from a local checkout of one.`,defaultValue:!1,...X},{id:`team-review-keep-mergeable-enabled`,path:`teamReview.keepMergeableEnabled`,title:`Keep mergeable`,description:`Offer Keep mergeable on your pull requests: a guarded agent repairs conflicts and failing checks and pushes the repair. Off hides the control and starts no repair; the pull requests you chose stay chosen for when you turn it back on.`,control:`toggle`,keywords:[`repair`,`conflicts`,`my prs`],defaultValue:!0,...X},{id:`team-review-keep-mergeable-timeout`,path:`teamReview.keepMergeableTimeoutMinutes`,title:`Keep mergeable deadline`,description:`Longest a Keep mergeable repair session may run before it is stopped and nothing is pushed.`,control:`number`,range:an,unit:e1,keywords:[`timeout`,`repair`],defaultValue:30,...X},{id:`team-review-merge-queue-enabled`,path:`teamReview.mergeQueueEnabled`,title:`Merge when ready`,description:`Offer Merge when ready on your pull requests: queued pull requests are rebased when behind and merged once ready, one per repository per poll. Off hides the control and merges nothing; the queue is kept for when you turn it back on.`,control:`toggle`,keywords:[`merge queue`,`auto merge`,`my prs`],defaultValue:!0,...X}]},{id:`lanes-workflows`,level:`lanes`,title:`Workflows`,description:`Rules that act on pull request events in the repositories you choose.`,legacyIds:[`workflows`],settings:[{id:`workflows-enabled`,path:`workflows.enabled`,title:`Run workflows`,description:`Poll the repositories your enabled rules watch and run their actions. Off stops polling and every action, whatever each rule says.`,control:`toggle`,keywords:[`pull requests`,`automation`,`master switch`],defaultValue:!0,...X},{id:`workflows-max-concurrent-sessions`,path:`workflows.maxConcurrentSessions`,title:`Concurrent agent sessions`,description:`Most workflow agent sessions running at once. Up to twenty later spawns wait for a free slot; additional spawns are dropped and logged.`,control:`number`,range:on,unit:X$,keywords:[`parallel`,`spawn`],defaultValue:2,...X},{id:`workflows-rules`,path:`status:workflow-rules`,title:`Workflow rules`,description:`Each rule watches repositories for one pull request event (opened, checks-failed, review-requested, approved, commented or merged), narrows it by author, labels, base branch, your own pull requests or a review request to your team, and then notifies you, labels or comments on the pull request, or starts a guarded agent session that pushes nothing. Rules start disabled. Turn each rule on or off here; everything else about a rule is set in config.json under workflows.rules.`,control:`readonly`,keywords:[`pull requests`,`automation`,`github`,`rules`],status:`workflows`,...H$}]},{id:`lanes-benchmarks`,level:`lanes`,title:`Benchmarks`,description:`Compare agent setups on frozen cases from the suites in the benchmarks folder of the Glimmervoid home.`,legacyIds:[`benchmarks`],settings:[{id:`benchmarks-enabled`,path:`benchmarks.enabled`,title:`Enable benchmarks`,description:`Show the Bench tab. Nothing runs until you choose Mine or Run there.`,control:`toggle`,keywords:[`eval`,`arms`,`recall`,`compare`],defaultValue:!1,...X}]},{id:`lanes-coherence`,level:`lanes`,title:`Coherence (experimental)`,description:`Per-session Coherence hook status and decision journal for agent sessions.`,settings:[{id:`coherence-enabled`,path:`coherence.enabled`,title:`Show session Coherence`,description:`Shows each session's Coherence hook status and decision journal when the repository installed @posthog/coherence 1.8 or newer. Off by default.`,control:`toggle`,keywords:[`experimental`,`coherence`,`journal`,`decisions`],defaultValue:!1,...X}]},{id:`lanes-change-map`,level:`lanes`,title:`Change map`,description:`Optional model narration for deterministic change facts.`,legacyIds:[`change-map`],settings:[{id:`change-map-narrator-enabled`,path:`changeMap.narrator.enabled`,title:`Enable narration`,description:`Add cited model claims to the change map.`,control:`toggle`,keywords:[`review`,`claims`],defaultValue:!1,...X},{id:`change-map-narrator-engine`,path:`changeMap.narrator.engine`,title:`Narrator engine`,description:`CLI used to generate change map claims.`,control:`select`,options:_1(A$),keywords:[`claude`,`codex`],defaultValue:`claude`,...X},{id:`change-map-narrator-model`,path:`changeMap.narrator.model`,title:`Narrator model`,description:`Blank uses the engine default: haiku for Claude, the configured Codex model for Codex.`,control:`text`,keywords:[`claude`,`codex`,`haiku`],defaultValue:``,...X}]},{id:`machine-privacy`,level:`machine`,title:`Privacy`,description:`What Glimmervoid sends about itself.`,legacyIds:[`privacy`,`telemetry`],settings:[{id:`telemetry-enabled`,path:`telemetry.enabled`,title:`Send anonymous usage and error data`,description:`Version, platform, app starts, daily activity, session starts and ends with agent kind, exit kind and duration, errors as their type, error code and scrubbed stack frames, per session token counts, models and estimated costs from the usage scan, under a random install id. Never error messages, paths, repository or branch names, prompts, objectives or terminal output. GLIMMERVOID_TELEMETRY=0, DO_NOT_TRACK=1 or CI=true turn it off regardless.`,control:`toggle`,keywords:[`telemetry`,`analytics`,`tracking`,`opt out`],defaultValue:!0,...X}]},{id:`browser-shortcuts`,level:`browser`,title:`Shortcuts and about`,description:`Keyboard reference and build information.`,legacyIds:[`shortcuts`],settings:[]}]),b1=Object.freeze([{id:`file-debug-mode`,path:`debugMode`,title:`Debug mode`,group:`machine-sessions`,description:`Show session-card diagnostics for state, transitions and detection signals.`,control:`toggle`,keywords:[`diagnostics`,`state`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:p1,...Z},{id:`file-replay-buffer`,path:`replayBufferKB`,title:`Replay buffer`,group:`machine-terminal`,description:`PTY output retained for clients that reconnect or join late.`,control:`number`,range:Dt,unit:{label:`KB`,storedPerDisplay:1},keywords:[`history`,`backfill`],defaultValue:512,takesEffect:`new-sessions`,fileOnlyReason:Q,...Z},{id:`file-session-memory-reserve`,path:`sessionMemoryReserveMB`,title:`Session memory reserve`,group:`machine-sessions`,description:`Free memory an automatic session start waits for; 0 starts sessions without checking.`,control:`number`,range:Ot,unit:{label:`MB`,storedPerDisplay:1},keywords:[`memory`,`headroom`],defaultValue:600,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-cursor-blink`,path:`cursorBlink`,title:`Cursor blink`,group:`machine-terminal`,description:`Blink the cursor in every terminal.`,control:`toggle`,keywords:[`caret`,`terminal`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-detect-background-agents`,path:`detectBackgroundAgents`,title:`Detect background agents`,group:`machine-detection-sessions`,description:`Hold completion while tracked background work is active.`,control:`toggle`,keywords:[`subagents`,`completion`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:p1,...Z},{id:`file-record-signals`,path:`recordSignals`,title:`Record structural signals`,group:`machine-detection-sessions`,description:`Keep forensic status and hook recordings for each session. Full capture (capture.enabled) records these signals even when this is off.`,control:`toggle`,keywords:[`recordings`,`diagnostics`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:p1,...Z},{id:`file-trace-enabled`,path:`trace.enabled`,title:`Capture session traces`,group:`machine-detection-sessions`,description:`Keep normalized Claude transcript traces for session debugging.`,control:`toggle`,keywords:[`transcripts`,`diagnostics`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:p1,...Z},{id:`file-detect-scheduled-wakeups`,path:`detectScheduledWakeups`,title:`Detect scheduled wakeups`,group:`machine-detection-sessions`,description:`Surface advisory wakeup timing for scheduled sessions.`,control:`toggle`,keywords:[`schedule`,`sleep`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:p1,...Z},{id:`file-worktree-auto-rebase`,path:`worktreeAutoRebase`,title:`Worktree auto-rebase`,group:`machine-detection-sessions`,description:`Rebase eligible session worktrees when the integration branch moves.`,control:`toggle`,keywords:[`git`,`branch`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:m1,...Z},{id:`file-worktree-sync-on-start`,path:`worktreeSyncOnStart`,title:`Worktree sync on start`,group:`machine-detection-sessions`,description:`Fetch origin and fast-forward the local integration branch before a session starts its worktree.`,control:`toggle`,keywords:[`git`,`fetch`,`fast-forward`],defaultValue:!0,takesEffect:`new-sessions`,fileOnlyReason:m1,...Z},{id:`file-worktree-rerere`,path:`worktreeRerere`,title:`Worktree rerere`,group:`machine-detection-sessions`,description:`Reuse recorded Git conflict resolutions.`,control:`toggle`,keywords:[`git`,`conflicts`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:m1,...Z},{id:`file-integration-branch`,path:`integrationBranch`,title:`Integration branch`,group:`machine-detection-sessions`,description:`Base branch for session worktrees. Empty = each repo's default branch. Existing sessions are never retargeted.`,control:`text`,nullable:!0,keywords:[`git`,`merge`],defaultValue:null,takesEffect:`new-sessions`,fileOnlyReason:m1,...Z},{id:`file-worktree-root`,path:`worktreeRoot`,title:`Worktree root`,group:`machine-detection-sessions`,description:`Directory that contains session worktrees. Existing worktrees are never relocated.`,control:`text`,keywords:[`git`,`directory`],defaultValue:``,takesEffect:`new-sessions`,fileOnlyReason:m1,...Z},{id:`file-worktree-share`,path:`worktreeShare`,title:`Shared worktree paths`,group:`machine-detection-sessions`,description:`Local paths copied or linked during worktree preparation.`,control:`list`,keywords:[`files`,`context`],defaultValue:[`node_modules`,`.env`,`.env.local`,`.claude`],takesEffect:`new-sessions`,fileOnlyReason:g1,...Z},{id:`file-port`,path:`port`,title:`Local port`,group:`machine-detection-sessions`,description:`Port used by the local dashboard listener.`,control:`number`,range:kt,unit:{label:`port`,storedPerDisplay:1},keywords:[`server`,`listener`],defaultValue:3e3,takesEffect:`restart`,fileOnlyReason:g1,...Z},{id:`file-notify-debounce-ms`,path:`notifyDebounceMs`,title:`Notification debounce`,group:`machine-detection-sessions`,description:`Delay used to coalesce notification state changes.`,control:`number`,integer:!1,step:`any`,range:A,unit:r1,keywords:[`timer`,`alerts`],defaultValue:3e3,takesEffect:`new-sessions`,fileOnlyReason:Q,...Z},{id:`file-phone-escalation-ms`,path:`phoneEscalationMs`,title:`Phone escalation delay`,group:`machine-detection-sessions`,description:`Delay before off-dashboard escalation.`,control:`number`,integer:!1,step:`any`,range:A,unit:i1,keywords:[`timer`,`telegram`],defaultValue:3e5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-post-turn-checks`,path:`postTurnChecks`,title:`Post-turn checks`,group:`machine-detection-sessions`,description:`Deterministic checks run after eligible turns. The global mode is a default; project and individual rule modes can select fixes even when the global mode is report.`,control:`json`,keywords:[`quality`,`fixes`],defaultValue:{enabled:!0,mode:`report`,rules:{trailingWs:!0,finalNewline:!0,bom:!0,slop:!1}},takesEffect:`now`,fileOnlyReason:h1,...Z},{id:`file-branch-gc-enabled`,path:`branchGc.enabled`,title:`Branch cleanup`,group:`machine-detection-sessions`,description:`Enable cleanup of eligible session branches.`,control:`toggle`,keywords:[`git`,`cleanup`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:m1,...Z},{id:`file-branch-gc-worktrees`,path:`branchGc.worktrees`,title:`Local worktree cleanup`,group:`machine-detection-sessions`,description:`Enable cleanup of eligible local worktrees.`,control:`toggle`,keywords:[`git`,`worktree`,`cleanup`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:m1,...Z},{id:`file-branch-gc-prefixes`,path:`branchGc.prefixes`,title:`Branch cleanup prefixes`,group:`machine-detection-sessions`,description:`Branch prefixes that filter both remote branch cleanup and local worktree cleanup.`,control:`list`,keywords:[`git`,`branch`],defaultValue:[`glimmervoid/session/`,`worktree-agent-`],takesEffect:`now`,fileOnlyReason:m1,...Z},{id:`file-branch-gc-dry-run`,path:`branchGc.dryRun`,title:`Branch cleanup dry run`,group:`machine-detection-sessions`,description:`Report planned cleanup without deleting remote branches.`,control:`toggle`,keywords:[`git`,`safety`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:m1,...Z},{id:`file-branch-gc-stale-days`,path:`branchGc.staleDays`,title:`Branch stale days`,group:`machine-detection-sessions`,description:`Age threshold for orphan branch cleanup when unmerged deletion is on.`,control:`number`,integer:!1,step:`any`,range:A,unit:n1,keywords:[`git`,`retention`],defaultValue:14,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-branch-gc-interval-ms`,path:`branchGc.intervalMs`,title:`Branch cleanup interval`,group:`machine-detection-sessions`,description:`Delay between branch cleanup passes.`,control:`number`,integer:!1,step:`any`,range:A,unit:o1,keywords:[`git`,`schedule`],defaultValue:216e5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-custom-agents`,path:`customAgents`,title:`Custom agents`,group:`machine-detection-sessions`,description:`Extra agent CLIs a session can be spawned with. The Sessions section lists the declared agents and whether each command resolves.`,control:`json`,keywords:[`adapters`,`cli`],defaultValue:[],takesEffect:`new-sessions`,fileOnlyReason:g1,...Z},{id:`file-task-title-refiner-enabled`,path:`taskTitle.refiner.enabled`,title:`Refine task titles`,group:`machine-detection-sessions`,description:`Keep session card titles useful when prompts change topic by asking a model for a short title.`,control:`toggle`,keywords:[`title`,`refiner`,`card`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-task-title-refiner-model`,path:`taskTitle.refiner.model`,title:`Task title model`,group:`machine-detection-sessions`,description:`Claude model alias the title refiner asks.`,control:`text`,keywords:[`title`,`refiner`,`model`],defaultValue:`haiku`,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-task-title-refiner-min-interval`,path:`taskTitle.refiner.minIntervalSeconds`,title:`Task title refresh interval`,group:`machine-detection-sessions`,description:`Shortest pause between two title refinements of one session.`,control:`number`,integer:!1,step:`any`,range:St,unit:$$,keywords:[`title`,`refiner`,`interval`],defaultValue:60,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-task-title-refiner-timeout`,path:`taskTitle.refiner.timeoutSeconds`,title:`Task title timeout`,group:`machine-detection-sessions`,description:`Maximum time allowed for one title refinement.`,control:`number`,integer:!1,step:`any`,range:At,unit:$$,keywords:[`title`,`refiner`,`deadline`],defaultValue:60,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-codex`,path:`usage.vendors.codex`,title:`Track Codex usage`,group:`machine-usage`,description:`Include local Codex CLI transcripts in usage reports.`,control:`toggle`,keywords:[`openai`,`vendor`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-grok`,path:`usage.vendors.grok`,title:`Track Grok usage`,group:`machine-usage`,description:`Include local Grok CLI transcripts in usage reports.`,control:`toggle`,keywords:[`xai`,`vendor`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-fetch-pricing`,path:`usage.fetchPricing`,title:`Fetch current model prices`,group:`machine-usage`,description:`Load public model prices when usage tracking starts, using a cached table for up to one day. Falls back to cached or bundled prices if the fetch fails; no daily refresh runs while tracking continues.`,control:`toggle`,keywords:[`rates`,`models`],defaultValue:!0,takesEffect:`restart`,fileOnlyReason:Q,...Z},{id:`file-usage-plan-limits`,path:`usage.planLimits`,title:`Show plan limits`,group:`machine-usage`,description:`Read the Claude plan limit the CLI reports and show it beside usage.`,control:`toggle`,keywords:[`plan`,`limits`,`quota`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-rtk-savings`,path:`usage.rtkSavings`,title:`Estimate rtk savings`,group:`machine-usage`,description:`Estimate the tokens rtk output compression saved and show it in the Usage view.`,control:`toggle`,keywords:[`rtk`,`savings`,`tokens`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-scan-interval`,path:`usage.scanIntervalMinutes`,title:`Scan interval`,group:`machine-usage`,description:`Periodic transcript polling interval. Session activity can also trigger scans between timer ticks.`,control:`number`,range:Zt,unit:e1,keywords:[`poll`,`refresh`],defaultValue:5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-warehouse-retain-days`,path:`usage.warehouseRetainDays`,title:`Retain usage history`,group:`machine-usage`,description:`How long the daily usage warehouse keeps rolled-up totals after transcript detail expires.`,control:`number`,range:nn.warehouseRetainDays,unit:n1,keywords:[`history`,`warehouse`,`retention`],defaultValue:365,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-session-block-hours`,path:`usage.sessionBlockHours`,title:`Session block length`,group:`machine-usage`,description:`Length of the rolling block the Usage view groups activity into.`,control:`number`,range:nn.sessionBlockHours,unit:t1,keywords:[`block`,`window`,`hours`],defaultValue:5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-cost-mode`,path:`usage.costMode`,title:`Cost mode`,group:`machine-usage`,description:`Choose whether recorded costs, calculated costs or both can appear.`,control:`select`,options:_1(b$),keywords:[`pricing`,`estimate`],defaultValue:`auto`,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-usage-extra-projects-dirs`,path:`usage.extraProjectsDirs`,title:`Extra transcript folders`,group:`machine-usage`,description:`Absolute paths of additional Claude projects folders the usage scan reads.`,control:`list`,keywords:[`transcripts`,`folders`,`scan`],defaultValue:[],takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-change-map-narrator-timeout`,path:`changeMap.narrator.timeoutSeconds`,title:`Narrator timeout`,group:`lanes-change-map`,description:`Maximum time allowed for one narration.`,control:`number`,range:rn,unit:$$,keywords:[`deadline`,`narration`],defaultValue:90,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-quiet-delay`,path:`visions.dispatch.quietMs`,title:`Quiet delay`,group:`lanes-visions`,description:`Editor quiet time before a scheduled review. Saves and blank-line boundaries can dispatch immediately, subject to the other review limits.`,control:`number`,range:A,unit:r1,keywords:[`debounce`,`idle`],defaultValue:3e4,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-cooldown`,path:`visions.dispatch.cooldownMs`,title:`Cooldown`,group:`lanes-visions`,description:`Minimum delay between reviews of the same document. Initial orientation reviews bypass this delay.`,control:`number`,range:A,unit:i1,keywords:[`rate limit`,`delay`],defaultValue:3e5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-activity-max-per-hour`,path:`visions.dispatch.activityMaxPerHour`,title:`Activity max per hour`,group:`lanes-visions`,description:`Maximum activity-driven reviews dispatched per hour, capped at the overall hourly limit minus one to reserve an edit-review slot.`,control:`number`,range:St,unit:d1,keywords:[`rate limit`,`events`],defaultValue:2,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-dispatch-timeout`,path:`visions.dispatch.dispatchTimeoutSeconds`,title:`Dispatch timeout`,group:`lanes-visions`,description:`Maximum time allowed for one review session.`,control:`number`,range:A,unit:a1,keywords:[`deadline`,`review`],defaultValue:180,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-visions-intent-thread-ttl`,path:`visions.intent.threadTtlMs`,title:`Intent thread lifetime`,group:`lanes-visions`,description:`How long an intent thread nobody advanced stays live before it retires.`,control:`number`,range:A,unit:c1,keywords:[`intent`,`decay`,`thread`],defaultValue:2592e5,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-terminal`,path:`ingest.sources.terminal.enabled`,title:`Terminal output source`,group:`lanes-ingest`,description:`Include terminal output in the ingest feed.`,control:`toggle`,keywords:[`pty`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-agent-logs`,path:`ingest.sources.agentLogs.enabled`,title:`Agent logs source`,group:`lanes-ingest`,description:`Include local agent logs in the ingest feed.`,control:`toggle`,keywords:[`transcript`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-git`,path:`ingest.sources.git.enabled`,title:`Git activity source`,group:`lanes-ingest`,description:`Include local Git activity in the ingest feed.`,control:`toggle`,keywords:[`commits`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-fs`,path:`ingest.sources.fs.enabled`,title:`File changes source`,group:`lanes-ingest`,description:`Include watched file changes in the ingest feed.`,control:`toggle`,keywords:[`filesystem`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-shell-history`,path:`ingest.sources.shellHistory.enabled`,title:`Shell history source`,group:`lanes-ingest`,description:`Include local shell history in the ingest feed.`,control:`toggle`,keywords:[`commands`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-ingest-editor`,path:`ingest.sources.editor.enabled`,title:`Editor events source`,group:`lanes-ingest`,description:`Include local editor events in the ingest feed.`,control:`toggle`,keywords:[`buffers`,`source`],defaultValue:!1,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-investigation-timeout`,path:`posthog.investigationTimeoutSeconds`,title:`Investigation timeout`,group:`lanes-posthog`,description:`Maximum time allowed for one investigation.`,control:`number`,integer:!1,step:`any`,range:A,unit:a1,keywords:[`deadline`,`session`],defaultValue:900,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-escalation`,path:`posthog.userEscalationThreshold`,title:`Escalation threshold`,group:`lanes-posthog`,description:`Affected-user count that escalates an issue.`,control:`number`,range:A,unit:u1,keywords:[`threshold`,`severity`],defaultValue:25,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-fix-timeout`,path:`posthog.fixTimeoutSeconds`,title:`Fix timeout`,group:`lanes-posthog`,description:`Maximum time allowed for one fix session.`,control:`number`,integer:!1,step:`any`,range:Kt,unit:a1,keywords:[`deadline`,`repair`],defaultValue:1800,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-traffic-multiplier`,path:`posthog.trafficSpikeMultiplier`,title:`Spike multiplier`,group:`lanes-posthog`,description:`Baseline multiplier required to classify a traffic spike.`,control:`number`,integer:!1,step:`any`,range:qt,unit:f1,keywords:[`baseline`,`ratio`],defaultValue:3,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-traffic-min-users`,path:`posthog.trafficSpikeMinUsers`,title:`Min users to alert`,group:`lanes-posthog`,description:`Minimum recent unique users for an initial traffic-spike alert. Escalation and recovery alerts bypass this minimum.`,control:`number`,range:Jt,unit:u1,keywords:[`threshold`,`analytics`],defaultValue:10,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-traffic-cooldown`,path:`posthog.trafficSpikeCooldownMinutes`,title:`Spike cooldown`,group:`lanes-posthog`,description:`Cooldown for new traffic spikes. Escalation and recovery alerts bypass it. Zero removes the time delay; repeated active-spike alerts are still suppressed.`,control:`number`,integer:!1,step:`any`,range:St,unit:s1,keywords:[`silence`,`delay`],defaultValue:360,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-traffic-baseline`,path:`posthog.trafficSpikeBaselineDays`,title:`Baseline window`,group:`lanes-posthog`,description:`Historical window used to calculate normal hourly traffic.`,control:`number`,range:Xt,unit:n1,keywords:[`history`,`analytics`],defaultValue:7,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-recurrence-dedupe`,path:`posthog.recurrenceDedupe`,title:`Deduplicate recurring issues`,group:`lanes-posthog`,description:`Treat an issue seen again inside the recurrence window as the same investigation instead of opening a new one.`,control:`toggle`,keywords:[`recurrence`,`dedupe`,`issues`],defaultValue:!0,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-recurrence-window-days`,path:`posthog.recurrenceWindowDays`,title:`Recurrence window`,group:`lanes-posthog`,description:`How far back an issue counts as a recurrence of an investigated one.`,control:`number`,integer:!1,step:`any`,range:A,unit:n1,keywords:[`recurrence`,`window`],defaultValue:7,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-transient-recurrence-limit`,path:`posthog.transientRecurrenceLimit`,title:`Transient recurrence limit`,group:`lanes-posthog`,description:`How many times a transient issue may recur before it is investigated again.`,control:`number`,integer:!1,step:`any`,range:A,unit:Z$,keywords:[`recurrence`,`transient`,`limit`],defaultValue:3,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-repo-path`,path:`posthog.repoPath`,title:`Repository path`,group:`lanes-posthog`,description:`Absolute path of the local checkout investigations read and fixes branch from, for every project the project map does not name.`,control:`text`,keywords:[`repository`,`checkout`,`path`],defaultValue:``,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-posthog-project-map`,path:`posthog.projectMap`,title:`Project map`,group:`lanes-posthog`,description:`PostHog project id to a label: the name shown for that project, and, when it is an absolute path to a checkout, the repository its issues are investigated in.`,control:`json`,keywords:[`projects`,`repositories`,`map`],defaultValue:{},takesEffect:`now`,fileOnlyReason:h1,...Z},{id:`file-team-review-org`,path:`teamReview.org`,title:`GitHub organization (legacy)`,group:`lanes-team-review`,description:`Organization login that owns the team, for example PostHog. Read only when github.teams is empty.`,control:`text`,keywords:[`github`,`owner`,`legacy`],defaultValue:``,takesEffect:`now`,fileOnlyReason:`A legacy key: github.teams names teams as org/slug entries and wins whenever it is set.`,...Z},{id:`file-team-review-team`,path:`teamReview.team`,title:`GitHub team (legacy)`,group:`lanes-team-review`,description:`Team slug whose members and review requests are polled. Read only when github.teams is empty.`,control:`text`,keywords:[`github`,`slug`,`legacy`],defaultValue:``,takesEffect:`now`,fileOnlyReason:`A legacy key: github.teams names teams as org/slug entries and wins whenever it is set.`,...Z},{id:`file-workflows-max-actions-per-poll`,path:`workflows.maxActionsPerPoll`,title:`Actions per poll`,group:`lanes-workflows`,description:`Most actions run in one poll. The rest are dropped and logged.`,control:`number`,range:sn,unit:Q$,keywords:[`cap`,`rate limit`],defaultValue:20,takesEffect:`now`,fileOnlyReason:Q,...Z},{id:`file-workflows-rules`,path:`workflows.rules`,title:`Workflow rule definitions`,group:`lanes-workflows`,description:`The rules the Workflows section switches on and off: each names its repositories, one pull request event, its filters and its actions.`,control:`json`,keywords:[`pull requests`,`automation`,`rules`],defaultValue:[],takesEffect:`now`,fileOnlyReason:`Rule definitions are written in config.json; the Workflows section only switches each rule on or off.`,...Z}]),x1=Object.freeze({sections:y1,fileOnly:b1}),S1=Object.freeze(Object.fromEntries(y1.flatMap(e=>(e.legacyIds??[]).map(t=>[t,e.id])))),C1=Object.freeze(y1.reduce((e,t)=>{for(let n of t.settings)for(let r of n.legacyIds??[])e[r.sectionId]={...e[r.sectionId],[r.settingId]:t.id};return e},{}));function w1(e){let t=[],n=e=>{if(!e||typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};return t.push([e,n]),n},r=n(e);for(let e=t.pop();e;e=t.pop()){let[t,r]=e;for(let[e,i]of Object.entries(t))Object.defineProperty(r,e,{value:n(i),writable:!0,enumerable:!0,configurable:!0})}return r}function T1(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function E1(e,t){let n=t.split(`.`),r=e;for(let e of n.slice(0,-1)){if(!r||typeof r!=`object`)return;r=r[e]}r&&typeof r==`object`&&delete r[n.at(-1)]}function D1(e,t,n){let r=t.split(`.`),i=e;for(let e of r.slice(0,-1))(!i[e]||typeof i[e]!=`object`||Array.isArray(i[e]))&&(i[e]={}),i=i[e];i[r.at(-1)]=w1(n)}function O1(e){return e.flatMap(e=>e.settings)}function k1(e){return e.access===`file-only`||e.control===`readonly`}function A1(e){let t=String(e??``).trim().toLowerCase();if(!t||t===`all`)return`all`;if(t===`none`)return[];let n=t.split(`,`).map(e=>e.trim());return n.every(e=>/^\d+$/.test(e)&&Number.isSafeInteger(Number(e))&&Number(e)>0)?n.map(Number):null}var j1=6;function M1(e,t){return e.control===`number`&&typeof t==`number`?t/(e.unit?.storedPerDisplay??1):e.valueKind===`posthog-projects`?Array.isArray(t)?t.length===0?[`none`]:t.map(String):[]:w1(t)}function N1(e){return e.control===`number`&&(e.unit?.storedPerDisplay??1)!==1}function P1(e){return String(Number(e.toFixed(j1)))}function F1(e,t){let n=M1(e,t);return e.valueKind===`posthog-projects`&&Array.isArray(n)?n.join(`, `)||`all`:typeof n==`number`&&e.unit?`${P1(n)} ${e.unit.label}`:JSON.stringify(n??null)}function I1(e,t){if(e.control===`number`){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=Number(t);if(e.zeroIsNull&&n<=0)return null;let r=n*(e.unit?.storedPerDisplay??1);return e.integer===!1?r:Math.round(r)}if(e.valueKind===`posthog-projects`)return A1(Array.isArray(t)?t.join(`,`):t);if(e.control===`text`||e.control===`password`){let n=String(t??``).trim();return e.nullable&&!n?null:n}return w1(t)}function L1(e){return String(e||``).toLowerCase().match(/[a-z0-9]+/g)||[]}var R1=3,z1=2,B1=1,V1=3,H1=30,U1=16;function W1(e,t){return e===t?R1:e.startsWith(t)?z1:t.length>=V1&&e.includes(t)?B1:0}function G1(e,t,n){let r=0;for(let n of t){let t=Math.max(0,...e.map(e=>W1(e,n)));if(t===0)return 0;r+=t}return r*n}function K1(e){return e.options?.map(e=>e.label).join(`, `)??``}function q1(e){return t0(e.group??``)?.title??``}function J1(e,t,n){let r=G1(L1(e.title),n,1e3),i=G1(L1(e.keywords.join(` `)),n,100),a=G1(t,n,10),o=G1(L1(e.path),n,10),s=G1(L1(K1(e)),n,10),c=G1(L1(e.description),n,1);return r+i+a+o+s+c}function Y1(e){return e.section?.title??``}function X1(e,t){return Number(e.section===null)-Number(t.section===null)}function Z1(e,t,n){return[[`title`,e.title],[`keywords`,e.keywords.join(` `)],[`section`,t?.title??q1(e)],[`description`,e.description],[`path`,e.path],[`options`,K1(e)]].flatMap(([e,t])=>{let r=[];for(let e of t.matchAll(/[a-z0-9]+/gi)){let t=e[0].toLowerCase();for(let i of n){if(W1(t,i)===0)continue;let n=e.index+t.indexOf(i);r.push({start:n,end:n+i.length})}}let i=[];for(let e of r.sort((e,t)=>e.start-t.start||e.end-t.end)){let t=i.at(-1);t&&e.start<=t.end?t.end=Math.max(t.end,e.end):i.push({...e})}return i.length?[{field:e,text:t,spans:i}]:[]})}function Q1(e,t,n=[]){let r=L1(t).slice(0,U1);if(r.length===0)return[];let i=[];for(let t of e){let e=L1(t.title);for(let n of t.settings){let a=J1(n,e,r);a!==0&&i.push({section:t,setting:n,score:a,matches:Z1(n,t,r)})}}for(let e of n){let t=J1(e,L1(q1(e)),r);t!==0&&i.push({section:null,setting:e,score:t,matches:Z1(e,null,r)})}return i.sort((e,t)=>t.score-e.score||X1(e,t)||Y1(e).localeCompare(Y1(t))||e.setting.title.localeCompare(t.setting.title)).slice(0,H1)}function $1(e,t,n={},r={}){let i=/^#settings\/([^/]+)(?:\/([^/]+))?$/.exec(String(e||``));if(!i)return null;let a,o;try{a=decodeURIComponent(i[1]),o=i[2]?decodeURIComponent(i[2]):null}catch{return null}let s=n[a]||a,c=(o?r[s]?.[o]:void 0)||s,l=t.find(e=>e.id===c);if(!l)return null;let u=o?l.settings.find(e=>e.id===o||e.legacyIds?.some(e=>e.settingId===o&&e.sectionId===s)):null;return o&&!u?null:{sectionId:c,settingId:u?.id||null,hash:`#settings/${c}${u?`/${u.id}`:``}`}}function e0(e){let t=new Map,n=new Map;for(let r of[...O1(e.sections),...e.fileOnly])t.set(r.id,r),n.set(r.path,r);return{byId:t,byPath:n}}e0(x1);function t0(e,t=x1){let n=t.sections.find(t=>t.id===e);return n?{title:n.title,description:n.description}:v1[e]??null}function n0({checked:e=[],stored:t=[],rendered:n=[]}={}){let r=new Set(n),i=[...e];for(let e of t)typeof e==`string`&&e.trim()&&(r.has(e)||i.includes(e)||i.push(e));return i}function r0(e,t){let n=new Set(e.map(e=>e.id)),r=[...new Set(t)].filter(e=>!n.has(e));return[...e,...r.map(e=>({id:e,name:`Unavailable project (${e})`}))]}var i0=new WeakMap,a0=`Configured`,o0=`•`.repeat(12),s0=`Each line must be a positive whole-number PostHog project id, or the one word none.`,c0=3,l0=200,u0=new Set([`customAgents`]),d0=1e-9,f0=`Lanes`,p0=Object.freeze({now:`Applies now`,"new-sessions":`New sessions`,restart:`After restart`}),m0=Object.freeze({browser:`This browser`,machine:`This machine`});function h0(e,t){let n=t.secretSources;if(!n||typeof n!=`object`)return null;let r=n[e.path];return typeof r==`string`?r:null}function g0(e){let t=e.rtkInstall;return t?.status===`installing`?`No rtk binary found. Glimmervoid is installing it into ~/.glimmervoid/bin now.`:e.rtkInstallSupported===!1?`No rtk binary found. Automatic installation is unavailable on this server platform; install a compatible binary manually.`:t?.status===`failed`?`No rtk binary found. The last install attempt failed: ${t.reason||`unknown reason`}. A save can retry after the ten-minute failure cooldown; saves during the cooldown skip installation.`:`No rtk binary found. Saving requests installation into ~/.glimmervoid/bin on supported server platforms, subject to installer eligibility.`}function _0(e){return e.control===`password`}function v0(e){return`${e.path}${a0}`}function y0(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>y0(e,t[n]));if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&y0(e[n],t[n]))}function b0(e){return i0.get(e)||null}function x0(e){return Array.isArray(e)?e.map(e=>String(e)):[]}function S0(e){return e.split(`
174
- `).map(e=>e.trim()).filter(e=>e!==``)}function C0(e){let t=e.range;if(!t)return null;let n={min:Number(M1(e,t.min))};return t.max!=null&&(n.max=Number(M1(e,t.max))),t.exclusiveMin&&(n.exclusiveMin=!0),n}function w0(e){let t=`Default ${F1(e,e.defaultValue)}`;return N1(e)?`${t}, stored as ${JSON.stringify(e.defaultValue)} ${e.unit?.storedLabel??``}`.trimEnd():t}function T0(e,t){let n=w0(e),r=u0.has(e.path)?void 0:T1(t,e.path);if(r===void 0)return{currentText:null,defaultText:n,jsonFragment:null};let i={};return D1(i,e.path,r),{currentText:`Current ${F1(e,r)}`,defaultText:n,jsonFragment:JSON.stringify(i,null,2)}}function E0(e,t,n){let r=t??e.find(e=>e.id===n.group);if(!r)return t0(n.group??``)?.title??`config.json`;let i=e.find(e=>e.id===r.parent);return i?`${i.title} / ${r.title}`:r.level===`lanes`?`${f0} / ${r.title}`:r.title}function D0(e){let t=/^#settings(?:\?(.*))?$/.exec(String(e??``));if(!t)return null;let n=new URLSearchParams(t[1]??``).get(`q`)??``;return{query:Array.from(n.trim()).slice(0,l0).join(``).trim()}}function O0(e,t){return e.filter(e=>e.parent===t)}function k0(e,t){let n=e.find(e=>e.id===t);return n?n.parent?e.find(e=>e.id===n.parent)??n:n:null}function A0(e){return e.filter(e=>!e.parent)}function j0(e){let t=e.filter(e=>e.level===`lanes`);return[{heading:null,sections:e.filter(e=>e.level!==`lanes`)},{heading:f0,sections:t}].filter(e=>e.sections.length>0)}function M0(e,t,n,r){return r?`hidden`:n.trim()?`search`:t&&k0(e,t)?`section`:`list`}function N0(e,t={}){let n={};for(let r of O1(e)){if(k1(r))continue;if(r.path.startsWith(`pref:`)){let e=r.path.slice(5),i=t.prefs?.[e]??t[r.path];n[r.path]=M1(r,i??r.defaultValue);continue}if(_0(r)){let e=T1(t,v0(r))===!0;n[r.path]=e?o0:``;continue}let e=T1(t,r.path);n[r.path]=M1(r,e??r.defaultValue)}return i0.set(n,w1(t)),n}function P0(e,t,n){let r=O1(e).filter(e=>k1(e)||e.path.startsWith(`pref:`)||h0(e,b0(t)||{})||_0(e)&&n[e.path]===o0?!1:!y0(t[e.path],n[e.path]));if(r.length===0)return{};let i=b0(t)||{},a=(Array.isArray(i.projectChoices)?i.projectChoices:[]).map(e=>e.id).filter(e=>typeof e==`string`),o={},s=new Set;for(let e of r){let[r]=e.path.split(`.`);if(!e.path.includes(`.`)){o[r]=I1(e,n[e.path]);continue}if(!s.has(r)){let e=i[r];o[r]=e&&typeof e==`object`&&!Array.isArray(e)?w1(e):{},s.add(r)}let c=I1(e,n[e.path]);if(e.control===`projects`){let n=t[e.path];c=n0({checked:Array.isArray(c)?c:[],stored:Array.isArray(n)?n:[],rendered:r0(a.map(e=>({id:e,name:e})),Array.isArray(n)?n:[]).map(e=>e.id)})}D1(o,e.path,c)}for(let t of O1(e))_0(t)&&E1(o,v0(t));return delete o.secretSources,o}function F0(e,t,n,r){return d2(P0(e,t,{...t,[n.path]:r}))}function I0(e){let t=e.unit?.label;return t?` of ${t}`:``}function L0(e){let t=C0(e);if(!t)return`Allowed range is unavailable.`;let n=`${e.integer!==!1&&!N1(e)?`whole number`:`number`}${I0(e)}`;return t.exclusiveMin&&t.min===0?`Must be a positive ${n}.`:t.max==null?`Must be a ${n} ${t.exclusiveMin?`above`:`of at least`} ${P1(t.min)}.`:`Must be a ${n} between ${P1(t.min)} and ${P1(t.max)}.`}function R0(e){return`Must be a multiple of ${F1(e,1)}.`}function z0(e){return Math.abs(e-Math.round(e))<d0&&Number.isSafeInteger(Math.round(e))}function B0(e,t){return Number(I1({...e,integer:!1,nullable:!1,zeroIsNull:!1},t))}function V0(e,t){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=e.range;if(!n)return`Allowed range is unavailable.`;if(t==null||String(t).trim()===``)return L0(e);let r=Number(t);if(!Number.isFinite(r))return L0(e);if(e.zeroIsNull&&r<=0)return null;let i=B0(e,r);if(e.integer!==!1&&!z0(i))return N1(e)?R0(e):L0(e);let a=Number(I1(e,r));return n.exclusiveMin&&a<=n.min||!n.exclusiveMin&&a<n.min||n.max!=null&&a>n.max?L0(e):null}function H0(e,t,n=!1){return n?L0(e):V0(e,t.trim())}function U0(e,t){let n=t.trim();if(e.nullable&&n===``)return null;let r=Number(n);return e.zeroIsNull&&r<=0?null:r}function W0(e){if(e==null||e===``)return``;let t=Number(e);return Number.isFinite(t)?P1(t):String(e)}function G0(e,t){return Array.isArray(t)?e.valueKind===`posthog-projects`&&I1(e,t)===null?s0:null:`Must be a list.`}function K0(e,t){let n={};for(let r of O1(e)){if(k1(r))continue;let e=null;r.control===`number`&&(e=V0(r,t[r.path])),r.control===`list`&&(e=G0(r,t[r.path])),r.control===`select`&&r.options&&!r.options.some(e=>e.value===t[r.path])&&(e=`Choose one of the available options.`),e&&(n[r.id]=e)}return q0(O1(e),t,n),n}function q0(e,t,n){for(let r of e){let i=e.find(e=>e.id===r.maximumSettingId);if(!i||n[r.id]||n[i.id])continue;let a=t[r.path],o=t[i.path];Number(I1(r,a))>Number(I1(i,o))&&(n[r.id]=`Minimum must not exceed the maximum (${W0(o)}).`,n[i.id]=`Maximum must not be below the minimum (${W0(a)}).`)}}function J0(e,t){return O1(e).find(e=>e.id===t.maximumSettingId||e.maximumSettingId===t.id)}function Y0(e,t,n){let r=J0(e,t);return K0([{id:`scoped`,level:`machine`,title:``,description:``,settings:r?[t,r]:[t]}],n)[t.id]??null}function X0(e,t){return e.control===`number`?U0(e,t):e.control===`list`?S0(t):t}function Z0(e,t){return I1(e,e.control===`list`?x0(t):t)}function Q0(e){return e?.isDirty===!0}function $0(e,t,n,r,i,a=!1){if(!Q0(n))return{kind:`unchanged`};let o=t.control===`number`?H0(t,r,a):null;if(o)return{kind:`invalid`,error:o};let s=X0(t,r);if(y0(I1(t,s),Z0(t,n.base)))return{kind:`unchanged`};let c=Y0(e,t,{...i,[t.path]:s});return c?{kind:`invalid`,error:c}:{kind:`changed`,value:s}}function e2(e){return _0(e)?``:M1(e,e.defaultValue)}function t2(e,t){return y0(t,e2(e))}function n2(e){return e.presentation?e.presentation:(e.options?.length??0)<=c0?`segmented`:`select`}function r2(e){return Array.isArray(e)?e.length>0:typeof e==`string`?e.trim()!==``:e===!0}function i2(e,t){return e.danger===!0&&!!e.warning&&r2(t)}function a2(e,t){return i2(e,t)}function o2(e){return e.title.charAt(0).toLowerCase()+e.title.slice(1)}function s2(e){return _0(e)?`Reset removes the stored ${o2(e)}. Anything that relies on it stops until a new one is saved.`:a2(e,e2(e))?e.warning??``:null}function c2(e){return[e.repos.join(`, `),e.trigger,e.actions.map(e=>e.type).join(`, `)].join(` `)}function l2(e){if(e==null)return[`No rules. Add workflows.rules to config.json.`];let t=On.safeParse(e);return t.success?t.data.rules.length===0?[`No rules. Add workflows.rules to config.json.`]:t.data.rules.map(e=>[e.name,e.enabled?`enabled`:`disabled`,c2(e)].join(` `)):[`The workflows block is invalid, so no rule runs: ${t.error.issues[0]?.message??`unknown problem`}`]}function u2(e){let t=On.safeParse(e??{});return t.success?t.data.rules.map(e=>({id:e.id,name:e.name,isEnabled:e.enabled,summary:c2(e)})):[]}function d2(e){let t=e.workflows;return typeof t!=`object`||!t||Array.isArray(t)?e:{...e,workflows:Object.fromEntries(Object.entries(t).filter(([e])=>e!==`rules`))}}var f2={teamReview:e=>e?.teamReview?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,visions:e=>e?.visions?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,benchmarks:e=>e?.benchmarks?.enabled===!0,zenView:e=>e?.zenView===!0},p2=[{rule:`teamReview`,sectionId:`lanes-team-review`,settingId:`team-review-enabled`},{rule:`usage`,sectionId:`machine-usage`,settingId:`usage-enabled`},{rule:`posthog`,sectionId:`lanes-posthog`,settingId:`posthog-enabled`},{rule:`visions`,sectionId:`lanes-visions`,settingId:`visions-enabled`},{rule:`benchmarks`,sectionId:`lanes-benchmarks`,settingId:`benchmarks-enabled`},{rule:`zenView`,sectionId:`machine-sessions`,settingId:`zen-view`}],m2=2e4,$=null,h2=null,g2={claude:null,codex:null},_2=null,v2=null,y2=null,b2=null,x2=`all`,S2=!1,C2=null,w2=null,T2=!0,E2=jM,D2=AM,O2=kM,k2=!1,A2=null,j2=`day`,M2=new Set,N2=Al({getAck:Ec,setAck:Dc,signature:()=>iM($,g2.claude),isLooking:()=>!vr(_2)}),P2=null,F2=null,I2=null,L2=null,R2=null,z2=null,B2=null,V2=If(()=>_2),H2=(e,t)=>hr(`usage`,e,t);function U2(e,t,n,r){let i=M(`div`,`usage-tile`);r&&r!==`ok`&&(i.dataset.tone=r);let a=M(`span`,`usage-tile-value`,t);i.append(a,M(`span`,`usage-tile-label`,e));let o=n?M(`span`,`usage-tile-sub`,n):null;return o&&i.append(o),{tile:i,valueEl:a,subEl:o}}function W2(e){let t=Number(e);return Number.isFinite(t)?Math.min(Math.max(t,0),100):0}function G2(e,t,n){let r=M(`div`,`usage-meter`);r.dataset.tone=String(t),r.setAttribute(`role`,`progressbar`),r.setAttribute(`aria-valuemin`,`0`),r.setAttribute(`aria-valuemax`,`100`),r.setAttribute(`aria-label`,n);let i=M(`span`,`usage-meter-fill`);return r.append(i),K2(r,e),r}function K2(e,t){if(!e)return;let n=W2(t);e.setAttribute(`aria-valuenow`,String(Math.round(n)));let r=e.querySelector(`.usage-meter-fill`);r&&(r.style.width=`${n}%`)}function q2(e,t,n,r){let i=M(`div`,`usage-table-scroll`);i.dataset.usageTable=r;let a=M(`table`,`usage-table`),o=M(`thead`),s=M(`tr`);for(let i of e){let e=M(`th`,i.numeric?`usage-num`:null);if(e.scope=`col`,!i.key){e.textContent=i.label,s.append(e);continue}let a=i.key;e.setAttribute(`aria-sort`,OM(t,a));let o=M(`button`,`usage-sort`,i.label);o.type=`button`,o.dataset.sortKey=a,o.addEventListener(`click`,()=>{L4(`sort`),A2={kind:`sort`,table:r,key:a},n(a)}),e.append(o),s.append(e)}o.append(s);let c=M(`tbody`);return a.append(o,c),i.append(a),{wrap:i,body:c}}function J2(e,t){for(let n of t){let t=M(`td`,n.numeric?`usage-num`:n.className||null,n.node?null:n.text);n.node&&t.append(n.node),n.title&&(t.title=n.title),n.span&&(t.colSpan=n.span),e.append(t)}}function Y2(e){let t=M(`div`,`usage-share`);if(!Number.isFinite(e))return t.append(M(`span`,`usage-share-text`,xA(e))),t;let n=M(`span`,`usage-share-bar`),r=M(`span`,`usage-share-fill`);return r.style.width=`${W2(e)}%`,n.append(r),t.append(n,M(`span`,`usage-share-text`,xA(e))),t}function X2(){if(!P2?.isConnected)return;let e=Number($?.ts);P2.textContent=Number.isFinite(e)&&e>0?`Report ${Pf(e)}`:``}function Z2(){if(!F2?.isConnected)return;let e=Number(h2?.ts);F2.textContent=Number.isFinite(e)&&e>0?`Sessions ${Pf(e)}`:``}function Q2(){let e=FA($?.activeBlock);e&&(I2?.isConnected&&(I2.textContent=`${e.pct}%`),L2?.isConnected&&(L2.textContent=`${jA(e.remainingMinutes)} left`),R2?.isConnected&&K2(R2,e.pct))}function $2(e){let t=dA.find(t=>t.value===e);return t?t.days:null}function e4(){let e=M(`div`,`usage-controls`),t=M(`label`,`usage-control`);t.append(M(`span`,`usage-control-label`,`Range`));let n=M(`select`,`usage-select`);for(let e of dA){let t=M(`option`,null,e.label);t.value=e.value,n.append(t)}n.value=x2,n.addEventListener(`change`,()=>{L4(`range`),x2=n.value,z4()}),t.append(n);let r=M(`button`,`usage-refresh`,`Refresh`);r.type=`button`,r.title=`Re-read every transcript from the start`,r.addEventListener(`click`,()=>{L4(`refresh`),z4({force:!0})});let i=M(`span`,`usage-refresh-status`,``);return z2=r,B2=i,P4(),e.append(t,r,i),e}function t4(){let e=H2(`Usage`,EA($?.daily||[]));e.append(e4()),P2=M(`p`,`usage-meta`,``),e.append(P2),X2(),V2.onTick(X2);let t=gM($);t&&e.append(M(`p`,`usage-warning`,t));let n=fM($?.pricing?.missing);return n&&e.append(M(`p`,`usage-warning`,n)),e}function n4(){let e=Zj.filter(({vendor:e})=>eM(g2[e]));if(e.length===0)return null;let t=H2(`Plan limits`,$j(e.map(({vendor:e})=>e),$?.totals)),n=e.length>1,r=M(`div`,`usage-plan-vendors`);for(let{vendor:t,label:i}of e)r.append(r4(g2[t],n?i:null));return t.append(r),t}function r4(e,t){let n=M(`div`,`usage-plan-vendor`);t&&n.append(M(`p`,`usage-plan-vendor-label`,t));let r=lM(e?.ts);if(r){let e=M(`p`,`usage-meta`,r);e.dataset.tone=`warn`,n.append(e)}let i=M(`div`,`usage-plan`);for(let t of Yj){let n=Xj(e,t.key);n&&i.append(i4(t,n))}let a=M(`p`,`usage-meta`,``);n.append(i,a);let o=()=>{if(!a.isConnected)return;let t=sM(e?.ts);a.textContent=t?`Plan ${t}`:``};return o(),V2.onTick(o),n}function i4(e,t){let n=M(`div`,`usage-plan-window`),r=M(`div`,`usage-plan-head`);r.append(M(`span`,`usage-plan-label`,e.label)),r.append(M(`span`,`usage-plan-used`,aM(t)));let i=M(`span`,`usage-plan-reset`,``);r.append(i),n.append(r),Number.isFinite(t.pct)&&n.append(G2(t.pct,IA(t.pct),`${e.label} plan limit used`));let a=()=>{i.isConnected&&(i.textContent=oM(t.resetsAtMs))};return a(),V2.onTick(a),n}function a4(){let e=ej($,g2.claude),t=o4();if(e.length===0&&!t)return null;let n=H2(`Glimmervoid overhead`,e.length>0?KA:null);if(e.length>0){let t=M(`div`,`usage-tiles`);for(let n of e){let e=[tj(n),yA(n.costUSD)].filter(Boolean).join(`, `);t.append(U2(`${n.label}, share of Claude use`,xA(n.sharePct),e).tile)}n.append(t);for(let t of e){let e=nj(t);e&&n.append(M(`p`,`usage-meta`,`${t.label}: ${e}`))}}return t&&(n.append(M(`p`,`usage-meta`,`Selected range by lane. ${GA}`)),n.append(t)),n}function o4(){if(!XA($))return null;let e=JA($),t=e.reduce((e,t)=>e+(typeof t.costUSD==`number`&&Number.isFinite(t.costUSD)?t.costUSD:0),0),{wrap:n,body:r}=q2([{label:`Lane`},{label:`Cost`,numeric:!0},{label:`Tokens`,numeric:!0},{label:`Sessions`,numeric:!0},{label:`Share`,numeric:!0}],null,()=>{},`lane`);for(let n of e){let e=M(`tr`,`usage-row`);n.lane===`other`&&(e.dataset.lane=`other`),J2(e,[{text:qA(n.lane),className:`usage-lane-cell`},{text:yA(n.costUSD),numeric:!0},{text:bA(n.tokens),numeric:!0},{text:aj(n.sessions),numeric:!0},{node:Y2(wA(n.costUSD,t)),className:`usage-share-cell`}]),r.append(e)}return n}function s4(){let e=$?.activeBlock,t=$?.blockHours,n=typeof t==`number`&&Number.isFinite(t)?t:5,r=qj($?.totals),i=H2(`Current block`,r?`${n}h window, ${r}`:`${n}h window`);if(!e){i.append(M(`p`,`usage-empty`,`No active block.`));let e=c4();return e&&i.append(e),i}let a=rM($,g2.claude),o=M(`div`,`usage-tiles`);o.append(U2(`block tokens`,bA(e.tokens??0),yA(e.costUSD??0),a).tile);for(let t of NA(e.burn))o.append(U2(t.label,t.value,t.sub,a).tile);let s=FA(e);if(s){let e=U2(`elapsed`,`${s.pct}%`,`${jA(s.remainingMinutes)} left`);I2=e.valueEl,L2=e.subEl,o.append(e.tile)}i.append(o),s&&(R2=G2(s.pct,`ok`,`Elapsed share of the current block window`),i.append(R2),V2.onTick(Q2));let c=PA(e.projection);if(c){let e=M(`p`,`usage-projection`,c);e.dataset.tone=a,i.append(e)}let l=c4();l&&i.append(l);let u=BA($?.tokenLimit);if(!u)return i;let d=RA($?.tokenLimit),f=rM($);i.append(G2(d,f,`Share of the largest completed block seen, estimated`));let p=M(`p`,`usage-meta`,u);p.dataset.tone=f,i.append(p),i.append(M(`p`,`usage-provenance`,nM(`estimated`)));let m=VA(e.projection,$?.tokenLimit);if(m){let e=M(`p`,`usage-meta`,m);e.dataset.tone=f,i.append(e)}return i}function c4(){let e=$?.anomaly;if(!zj(e))return null;let t=M(`p`,`usage-meta`,Lj(e));return t.dataset.tone=Rj(e),t}function l4(){let e=RM($?.blocks);if(e.length===0)return null;let t=qj($?.totals),n=H2(`Recent blocks`,t?`newest first, ${t}`:`newest first`),r=M(`div`,`usage-blocks`),i=e.reduce((e,t)=>Math.max(e,t.tokens),0);for(let t of e){let e=M(`div`,`usage-block`);t.isActive&&(e.dataset.active=`true`),e.append(M(`span`,`usage-block-label`,MA(t.startTs)));let n=M(`span`,`usage-block-bar`),a=M(`span`,`usage-block-fill`);a.style.width=`${W2(wA(t.tokens,i)??0)}%`,n.append(a),e.append(n),e.append(M(`span`,`usage-block-value`,`${bA(t.tokens)} ${yA(t.costUSD)}`)),r.append(e)}return n.append(r),n}function u4(){let e=$?.totals||{},t=LM($?.daily,OA($)),n=H2(`Totals`,[lA,$?.tz?`TZ ${$.tz}`:``].filter(Boolean).join(` `)),r=rM($,g2.claude),i=M(`div`,`usage-tiles`);i.append(U2(`today`,bA(t?.tokens??0),yA(t?.costUSD??0),r).tile),i.append(U2(`range total`,bA(e.tokens??0),yA(e.costUSD??0)).tile);let a=ij($);a&&i.append(U2(a.label,a.value,a.sub).tile),n.append(i);let o=d4(e);o&&n.append(o);let s=Gj(e)?Wj(e):[];if(s.length>0){let e=M(`div`,`usage-tiles usage-vendor-tiles`);for(let t of s)e.append(U2(t.label,bA(t.tokens),yA(t.costUSD)).tile);n.append(e)}return F2=M(`p`,`usage-meta`,``),n.append(F2),Z2(),V2.onTick(Z2),n}function d4(e){let t=UA(e);if(t.length===0)return null;let n=M(`div`,`usage-compo`),r=M(`div`,`usage-compo-bar`);r.setAttribute(`aria-hidden`,`true`);for(let e of t){if(e.pct<=0)continue;let t=M(`span`,`usage-compo-fill`);t.dataset.part=e.key,t.style.width=`${e.pct}%`,t.title=e.title,r.append(t)}let i=M(`div`,`usage-compo-legend`);for(let e of t){let t=M(`span`,`usage-compo-item`),n=M(`span`,`usage-compo-swatch`);n.dataset.part=e.key,t.append(n,M(`span`,`usage-compo-label`,e.label),M(`span`,`usage-compo-value`,e.value)),i.append(t)}return n.append(r,i),n}function f4(){let e=$?.savings;if(!cj(e))return null;let t=H2(`Savings`,``),n=M(`div`,`usage-tiles`),r=lj(e);r&&n.append(U2(`rtk compression`,r.value,r.sub).tile);let i=uj(e);return i&&n.append(U2(`Prompt cache`,i.value,i.sub).tile),t.append(n),t}function p4(){let e=dj($);if(e.length===0)return null;let t=H2(`Budgets`,`your own ceilings`),n=M(`div`,`usage-budgets`),r=Dp(`machine-usage`,`usage-daily-budget`,`Budget settings`);n.appendChild(r);for(let t of e){let e=M(`div`,`usage-budget`),r=M(`div`,`usage-budget-head`);r.append(M(`span`,`usage-budget-label`,fj(t.scope))),r.append(M(`span`,`usage-budget-value`,pj(t))),r.append(M(`span`,`usage-budget-pct`,xA(mj(t)))),e.append(r),e.append(G2(mj(t),t.tone,hj(t))),n.append(e)}return t.append(n),t}function m4(){let e=$?.daily||[],t=j2,n=IM(Ej(e,t),E2),r=gj.find(e=>e.value===t)?.label||`Day`,i=H2(`Over time`,[kj(e)].filter(Boolean).join(`, `));if(i.append(h4()),n.length===0)return i.append(M(`p`,`usage-empty`,`No usage.`)),i;let a=_4(e);a&&i.append(a);let{wrap:o,body:s}=q2([{label:r,key:`day`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Models`}],E2,e=>{E2=DM(E2,e),E4()},`day`);for(let e of n){let n=String(e.day??``),r=M(`tr`,`usage-row`);e.source===`history`&&(r.dataset.source=`history`);let i=FM(e.models),a=`${t}:${n}`,o=v4(a,i.length);J2(r,[{node:g4(e,t),title:n},{text:bA(e.tokens),numeric:!0},{text:yA(e.costUSD),numeric:!0},{node:o,className:`usage-toggle-cell`}]),s.append(r),i.length!==0&&M2.has(a)&&s.append(y4(i))}return i.append(o),i}function h4(){let e=M(`div`,`usage-period`);e.setAttribute(`role`,`group`),e.setAttribute(`aria-label`,`Period`);for(let t of gj){let n=M(`button`,`usage-period-button`,t.label);n.type=`button`,n.dataset.periodView=t.value,n.setAttribute(`aria-pressed`,t.value===j2?`true`:`false`),n.addEventListener(`click`,()=>{j2!==t.value&&(L4(`period`),j2=t.value,A2={kind:`period`,view:t.value},E4())}),e.append(n)}return e}function g4(e,t){let n=M(`span`,`usage-period-cell`);return n.append(M(`span`,null,Oj(e.day,t))),e.source===`history`&&n.append(M(`span`,`usage-history-tag`,`history`)),n}function _4(e){let{cells:t,max:n}=Nj(e,{today:OA($)});if(t.length===0||n<=0)return null;let r=M(`div`,`usage-heatmap-scroll`),i=M(`div`,`usage-heatmap`);i.setAttribute(`role`,`img`),i.setAttribute(`aria-label`,`Daily usage for the trailing ${Math.max(...t.map(e=>e.week))+1} weeks`);let a=M(`div`,`usage-heatmap-days`);for(let e of jj)a.append(M(`span`,`usage-heatmap-day`,e));for(let e of t){let t=M(`span`,`usage-heatmap-cell`);t.dataset.tone=String(e.tone),e.noData&&(t.dataset.noData=`true`),e.source===`history`&&(t.dataset.source=`history`),t.style.gridColumn=String(e.week+1),t.style.gridRow=String(e.weekday+1),t.title=Pj(e),i.append(t)}return r.append(a,i),r}function v4(e,t){if(t===0)return null;let n=M(`button`,`usage-toggle`,`Models`);return n.type=`button`,n.dataset.usageDay=e,n.setAttribute(`aria-expanded`,M2.has(e)?`true`:`false`),n.addEventListener(`click`,()=>{L4(`expand`),A2={kind:`day`,day:e},M2.has(e)?(M2.delete(e),E4()):(M2.add(e),E4())}),n}function y4(e){let t=M(`tr`,`usage-row-breakdown`),n=M(`td`,`usage-models`);n.colSpan=4;for(let t of e){let e=M(`span`,`usage-model-chip`);e.append(M(`span`,`usage-model-name`,SM(t)),M(`span`,`usage-model-value`,`${bA(t.tokens)} ${yA(t.costUSD)}`)),n.append(e)}return t.append(n),t}function b4(e,t){let n=M(`span`,`usage-model-name-wrap`),r=Uj(e,t);return r&&n.append(M(`span`,`usage-vendor-tag`,r)),n.append(M(`span`,null,SM(e))),n}function x4(){let e=FM($?.models,D2),t=$?.totals||{},n=SA(t),r=H2(`By model`,CA(n));if(e.length===0)return r.append(M(`p`,`usage-empty`,`No models.`)),r;let{wrap:i,body:a}=q2([{label:`Model`,key:`model`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Share`,numeric:!0},{label:`Input`,numeric:!0,key:`input`},{label:`Output`,numeric:!0,key:`output`},{label:`Cache write`,numeric:!0,key:`cacheCreate`},{label:`Cache read`,numeric:!0,key:`cacheRead`}],D2,e=>{D2=DM(D2,e),E4()},`model`);for(let r of e){let e=M(`tr`,`usage-row`);J2(e,[{node:b4(r,t),className:`usage-model-cell`,title:SM(r)},{text:bA(r.tokens),numeric:!0},{text:yA(r.costUSD),numeric:!0},{node:Y2(wA(r[n],t[n])),className:`usage-share-cell`},{text:bA(r.input),numeric:!0},{text:bA(r.output),numeric:!0},{text:bA(r.cacheCreate),numeric:!0},{text:bA(r.cacheRead),numeric:!0}]),a.append(e)}return r.append(i),r}function S4(){let e=MM($?.sessions,O2),t=NM(e,k2),n=$?.totals||{},r=SA(n),i=H2(`By session`,CA(r));if(e.length===0)return i.append(M(`p`,`usage-empty`,`No sessions.`)),i;let{wrap:a,body:o}=q2([{label:`Session`,key:`label`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Share`,numeric:!0},{label:`Last activity`,numeric:!0,key:`lastTs`}],O2,e=>{O2=DM(O2,e),E4()},`session`);for(let e of t.rows){let t=M(`tr`,`usage-row`);bM(e)&&(t.dataset.managed=`true`);let i=xM(e),a=M(`span`,`usage-ago`,``);J2(t,[{text:i,className:`usage-session-cell`,title:e.project?String(e.project):i},{text:bA(e.tokens),numeric:!0},{text:yA(e.costUSD),numeric:!0},{node:Y2(wA(e[r],n[r])),className:`usage-share-cell`},{node:a,numeric:!0}]),V2.track(a,Number(e.lastTs),Pf),o.append(t)}return i.append(a),e.length>10&&i.append(C4(t.hiddenCount)),i}function C4(e){let t=M(`div`,`usage-overflow`),n=PM(e);n&&t.append(M(`p`,`usage-meta`,n));let r=M(`button`,`usage-toggle`,`All sessions`);return r.type=`button`,r.dataset.usageSessionsToggle=`true`,r.setAttribute(`aria-expanded`,k2?`true`:`false`),r.addEventListener(`click`,()=>{L4(`expand`),A2={kind:`sessions-toggle`},k2=!k2,E4()}),t.append(r),t}function w4(){let e=H2(`Not available`,``);return e.append(M(`p`,`usage-empty`,hM($))),e.append(M(`p`,`usage-empty`,uA)),e}function T4(){P2=null,F2=null,I2=null,L2=null,R2=null,z2=null,B2=null}function E4({force:e=!1}={}){if(!_2||!e&&vr(_2))return;let t=_2.parentElement,n=t?t.scrollTop:0;V2.reset(),T4(),_2.textContent=``,k4(),t&&(t.scrollTop=n),D4()}function D4(){let e=A2;if(A2=null,!e)return;let t=O4(e);if(!t||!_2)return;let n=_2.querySelector(t);n instanceof HTMLElement&&n.focus()}function O4(e){return e.kind===`day`?`.usage-toggle[data-usage-day="${CSS.escape(e.day)}"]`:e.kind===`period`?`.usage-period-button[data-period-view="${CSS.escape(e.view)}"]`:e.kind===`sessions-toggle`?`.usage-toggle[data-usage-sessions-toggle="true"]`:e.kind===`sort`?`[data-usage-table="${CSS.escape(e.table)}"] .usage-sort[data-sort-key="${CSS.escape(e.key)}"]`:null}function k4(){if(!_2)return;_2.append(t4());let e=n4();if(_M($)){e&&_2.append(e),_2.append(w4());return}if(!$){e&&_2.append(e),_2.append(M(`p`,`usage-empty`,`Waiting for scan.`));return}let t=[e,p4()].filter(e=>e!==null);_2.append(A4(`usage-band-now`,s4(),t,{sideFirst:!0}));let n=[f4()].filter(e=>e!==null);_2.append(A4(`usage-band-spend`,u4(),n));let r=[l4()].filter(e=>e!==null);_2.append(A4(`usage-band-trend`,m4(),r));let i=a4();i&&_2.append(i),_2.append(x4(),S4())}function A4(e,t,n,{sideFirst:r=!1}={}){if(n.length===0)return t;let i=M(`div`,`usage-band ${e}`),a=M(`div`,`usage-band-col`);for(let e of n)a.append(e);return r?(i.append(a,t),i):(i.append(t,a),i)}function j4(){v2&&v2(N2.refresh())}function M4(){N2.acknowledge(),j4()}function N4(){return T2?S2?`Refreshing`:w2??``:$?`${G} The figures below are from before the connection dropped.`:G}function P4(){z2&&(z2.disabled=S2),B2&&(B2.textContent=N4(),!T2||!S2&&w2!==null?B2.dataset.tone=`error`:delete B2.dataset.tone)}function F4(e){S2=e,P4(),C2&&=(clearTimeout(C2),null),e&&(C2=setTimeout(()=>{C2=null,S2=!1,w2=`Usage did not answer within ${Math.round(m2/1e3)} s. Refresh to try again.`,P4()},m2))}function I4(e){v2=e,j4()}function L4(e){y2?.({type:`dashboard-telemetry`,event:`operator_action`,properties:{surface:`usage`,action:e}})}function R4(e){y2=e}function z4({force:e=!1}={}){if(!y2)return;b2=gd(`usage`);let t={type:`request-usage-report`,requestId:b2};e&&(t.force=!0);let n=$2(x2);n!==null&&(t.days=n),w2=null,F4(!0),!y2(t)&&(w2=G,F4(!1))}function B4(e){T2=e,P4()}function V4(e){if(_2)return _2;let t=M(`div`,`usage-content`);return e.appendChild(t),_2=t,V2.ensure(),E4({force:!0}),t}function H4(){E4({force:!0})}function U4(e){h2=e,$&&!_M($)&&F2?.isConnected?Z2():E4()}function W4(e){let t=e;g2={...g2,[Qj(t)]:t},E4(),j4()}function G4(e){vM(e,b2)&&(w2=null,F4(!1),$=e,E4(),j4())}function K4(){let e=$?.pricing||(h2?{source:h2.pricingSource}:null),t=dM(e?.fetchedAt),n=[uM(e,t!==null&&t>0?Pf(t):``)],r=hM($);r&&n.push(r);let i=mM($?.scan);return i&&n.push(i),n}var q4=Object.freeze({sounds:()=>pb(),themes:Fb}),J4=2200,Y4=1600,X4=`browser-appearance`,Z4=`browser-shortcuts`,Q4=`lanes-features`,$4=Object.freeze({id:Q4,level:`lanes`,title:`Features`,description:`Optional tabs, each hidden until its own toggle is on.`,settings:[]}),e3=`flying-animals`,t3=Object.freeze({ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1});function n3(e){if(!e.optionsFrom)return e;let t=q4[e.optionsFrom]?.()??[];return{...e,options:t.map(e=>({value:e.id,label:e.label}))}}function r3(){let e=x1.sections.map(e=>({...e,settings:e.settings.map(n3)})),t=e.findIndex(e=>e.level===`lanes`);return Object.freeze([...e.slice(0,t),$4,...e.slice(t)])}var i3=r3(),a3=!1,o3=null,s3=null,c3=null,l3=null,u3=null,d3=null,f3=null,p3=null,m3=i3[0],h3={},g3={},_3=new Map,v3=new Map,y3=new Map,b3=new WeakMap,x3=Promise.resolve(),S3=new Map,C3=``,w3=null,T3=null,E3=Mu,D3=()=>{},O3=null,k3=!1,A3=!1,j3=null,M3=new Set,N3=new Map;function P3(){return{themeId:Js(),flyingAnimalsEnabled:Xs(),...Hc(),soundEnabled:Rs(),soundId:mb(Bs()),notificationsEnabled:Hs(),sessionUsageChips:Ws(),phoneArrowPad:Ks()}}function F3(e){g3=N0(i3,{...e,prefs:P3()}),Wf(e.agentLogins)}function I3(e){return y3.has(e.id)?y3.get(e.id):g3[e.path]}function L3(e){return[e,...O0(i3,e.id)]}function R3(e){return L3(e).flatMap(e=>e.settings)}function z3(e){return i3.find(t=>t.settings.some(t=>t.id===e.id))??m3}function B3(e,t=null){history.replaceState(history.state,``,wp(e,t))}function V3(e){requestAnimationFrame(()=>{let t=document.getElementById(e),n=t?.closest(`.settings-view-advanced-panel`);n&&(a3=!0,n.hidden=!1,p3?.querySelector(`.settings-view-advanced-toggle`)?.setAttribute(`aria-expanded`,`true`));let r=t?.closest(`.settings-view-setting`);r&&(r.scrollIntoView({block:`center`}),r.classList.remove(`settings-view-setting-flash`),requestAnimationFrame(()=>r.classList.add(`settings-view-setting-flash`)))})}function H3(e){for(let t of Yp(Xp)){let n=M(`div`,`shortcut-group`);n.appendChild(M(`div`,`shortcut-group-title`,t.title));let r=M(`dl`,`shortcut-rows`);for(let e of t.items){let t=M(`dt`,`shortcut-keys`);e.combos.forEach((e,n)=>{n>0&&t.appendChild(M(`span`,`shortcut-sep`,`/`)),Zp(t,e)}),r.append(t,M(`dd`,`shortcut-label`,e.label))}n.appendChild(r),e.appendChild(n)}}var U3=[];function W3(e){U3=e}function G3(e){return U3.find(t=>t.gate!==void 0&&`fromSettings`in t.gate&&t.gate.fromSettings===e)?.label}function K3(e){let t=M(`ul`,`settings-view-stack settings-features`);for(let e of p2){let n=i3.find(t=>t.id===e.sectionId),r=J3(e.settingId),i=G3(f2[e.rule]);if(!n||!r||!i)continue;let a=I3(r)===!0,o=M(`li`,`settings-feature`),s=M(`div`,`settings-feature-head`);s.append(M(`span`,`settings-feature-name`,i),Z6(`feature`,a?`On`:`Off`)),o.append(s,M(`p`,`settings-view-section-description`,n.description),Dp(e.sectionId,e.settingId,r.title)),t.appendChild(o)}e.appendChild(t)}function q3(e){let t=M(`div`,`settings-about`),n=M(`span`,`settings-about-version`,`GLIMMERVOID `);n.appendChild(M(`span`,`settings-about-v`,`v0.41.1`));let r=M(`span`,`settings-about-links`),i=M(`a`,`settings-about-link`,`GitHub`);i.href=`https://github.com/${v$}`,i.target=`_blank`,i.rel=`noopener`;let a=M(`a`,`settings-about-link`,`Changelog`);a.href=`https://github.com/${v$}/blob/main/CHANGELOG.md`,a.target=`_blank`,a.rel=`noopener`,r.append(i,a),t.append(n,r),e.appendChild(t)}function J3(e){return i3.flatMap(e=>e.settings).find(t=>t.id===e)??null}function Y3(e){if(g3[`pref:soundEnabled`]===e)return;g3[`pref:soundEnabled`]=e;let t=J3(`alert-sounds-enabled`);t&&u8(t)}var X3={"pref:flyingAnimalsMinGapSeconds":e=>Pc(Number(e)),"pref:flyingAnimalsMaxGapSeconds":e=>Fc(Number(e)),"pref:flyingAnimalsMinDurationSeconds":e=>Ic(Number(e)),"pref:flyingAnimalsMaxDurationSeconds":e=>Lc(Number(e)),"pref:flyingAnimalsScale":e=>Rc(Number(e)),"pref:flyingAnimalsOnPhone":e=>zc(e===!0)};function Z3(e,t){if(e.path===`pref:sessionUsageChips`){Gs(t===!0),Mb(t===!0);return}if(e.path===`pref:phoneArrowPad`){qs(t===!0),Nb(t===!0);return}if(e.path===`pref:themeId`){Ys(String(t)),jb(String(t));return}if(e.path===`pref:flyingAnimalsEnabled`){Zs(t===!0),g$(t===!0);return}let n=X3[e.path];n?(n(t),g$(Xs())):e.path===`pref:soundEnabled`?ZY(t===!0):e.path===`pref:soundId`?(Vs(String(t)),Tb(String(t))):e.path===`pref:notificationsEnabled`&&(Us(t===!0),t===!0&&pp().then(()=>u8(e,{force:!0})))}function Q3(e,t){let n=v3.get(e.id);n!==void 0&&clearTimeout(n),v3.delete(e.id),t&&_3.set(e.id,t),t||_3.delete(e.id),d8(e)}function $3(e){Q3(e,{tone:`saved`,text:`Saved`}),v3.set(e.id,window.setTimeout(()=>Q3(e,null),J4))}function e6(e,t){S3.delete(e.id),e.path.startsWith(`pref:`)?(g3[e.path]=t,Z3(e,t),u8(e),$3(e)):y3.has(e.id)&&JSON.stringify(y3.get(e.id))===JSON.stringify(t)||(y3.set(e.id,t),Q3(e,{tone:`saving`,text:`Saving`}),x3=x3.then(()=>t6(e,t)))}async function t6(e,t){let n=F0(i3,g3,e,t);if(Object.keys(n).length===0)y3.delete(e.id),Q3(e,null),u8(e);else{Q3(e,{tone:`saving`,text:`Saving`});try{let r=await _d(`update-settings`,{settings:n});if(y3.get(e.id)===t&&y3.delete(e.id),r.type===`settings-error`){Q3(e,{tone:`error`,text:String(r.message)}),u8(e,{force:!0});return}if(r.type!==`settings-updated`){Q3(e,{tone:`error`,text:`The server did not confirm the save.`}),u8(e,{force:!0});return}U8(r.settings),$3(e)}catch(n){y3.get(e.id)===t&&y3.delete(e.id),Q3(e,{tone:`error`,text:n?.message||`Failed to save the setting.`}),u8(e,{force:!0})}}}function n6(e,t){t&&S3.set(e.id,t),t||S3.delete(e.id),d8(e)}function r6(e,t){if(!t.exclusiveMin)return t.min;if(e.integer!==!1)return t.min+1}function i6(e){return e?`On`:`Off`}function a6(e){let t=M(`div`,`settings-view-toggle-wrap`),n=M(`label`,`settings-view-toggle`),r=M(`input`,`settings-view-checkbox`);r.type=`checkbox`,r.checked=I3(e)===!0,e.id===`desktop-notifications`&&!dp()&&(r.checked=!1,r.disabled=!0),r.setAttribute(`aria-labelledby`,e.id);let i=M(`span`,`settings-view-toggle-state`,i6(r.checked));return r.addEventListener(`change`,()=>{let t=r.checked;a2(e,t)?(r.checked=!1,i.textContent=i6(!1),rf({title:e.title,message:e.warning??``,confirmLabel:`Turn on`,danger:!0,onConfirm:()=>e6(e,!0)})):(i.textContent=i6(t),e6(e,t))}),n.append(r,i),t.appendChild(n),t}function o6(e,t,n){e.addEventListener(`blur`,t),e.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),t()):e.key===`Escape`&&(e.preventDefault(),n())})}function s6(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&[`text`,`number`,`password`].includes(e.type)}function c6(e,t){b3.set(t,{base:I3(e),isDirty:!1}),t.addEventListener(`input`,()=>{let e=b3.get(t);e&&(e.isDirty=!0)})}function l6(e,t,n){t.value!==n&&(t.value=n),b3.set(t,{base:I3(e),isDirty:!1}),n6(e,null)}function u6(e,t,n,r=!1){let i=b3.get(t);if(!i)return;let a=$0(i3,e,i,t.value,g3,r);a.kind===`invalid`?n6(e,a.error):a.kind===`unchanged`?l6(e,t,n):a2(e,a.value)?(l6(e,t,n),rf({title:e.title,message:e.warning??``,confirmLabel:`Save`,danger:!0,onConfirm:()=>e6(e,a.value)})):(b3.set(t,{base:a.value,isDirty:!1}),e6(e,a.value))}function d6(e){let t=M(`input`,`settings-view-input`);t.type=e.control===`password`?`password`:`text`;let n=()=>String(I3(e)??``);t.value=n(),e.control===`password`&&(t.value=``,t.placeholder=n()?`Configured`:`Not configured`);let r=h0(e,h3);return r&&(t.disabled=!0,t.setAttribute(`aria-description`,`Supplied by ${r}`)),t.autocomplete=`off`,t.spellcheck=!1,t.setAttribute(`aria-labelledby`,e.id),c6(e,t),o6(t,()=>{if(e.control===`password`){let n=t.value;if(n===``)return;l6(e,t,``),e6(e,n)}else u6(e,t,n())},()=>l6(e,t,e.control===`password`?``:n())),t}function f6(e){let t=M(`input`,`settings-view-input`),n=C0(e);t.type=`number`;let r=()=>W0(I3(e));t.value=r(),t.step=e.integer===!1?String(e.step??`any`):`1`;let i=n?r6(e,n):void 0;i!=null&&(t.min=String(i)),n?.max!=null&&(t.max=String(n.max)),t.autocomplete=`off`,t.setAttribute(`aria-labelledby`,e.id),c6(e,t),o6(t,()=>u6(e,t,r(),t.validity.badInput),()=>l6(e,t,r()));let a=e.unit?.label;if(!a)return t;let o=M(`div`,`settings-view-number`),s=M(`span`,`settings-view-unit`,a);return s.setAttribute(`aria-hidden`,`true`),t.setAttribute(`aria-description`,a),o.append(t,s),o}function p6(e,t){let n=[...e.querySelectorAll(`[role="radio"]`)],r=n.some(e=>e.dataset.value===t);for(let[e,i]of n.entries()){let n=i.dataset.value===t;i.setAttribute(`aria-checked`,String(n)),i.tabIndex=n||!r&&e===0?0:-1}}function m6(e,t,n){n!==String(I3(e))&&(p6(t,n),e6(e,n),p6(t,String(I3(e))))}function h6(e){let t=M(`div`,`settings-view-segmented`);t.setAttribute(`role`,`radiogroup`),t.setAttribute(`aria-labelledby`,e.id);let n=e.options??[];for(let r of n){let n=M(`button`,`settings-view-segment`,r.label);n.type=`button`,n.dataset.value=r.value,n.setAttribute(`role`,`radio`),n.addEventListener(`click`,()=>m6(e,t,r.value)),t.appendChild(n)}return t.addEventListener(`keydown`,r=>{let i=t3[r.key];if(!i||n.length===0)return;r.preventDefault();let a=Math.max(0,n.findIndex(t=>t.value===String(I3(e)))),o=n[(a+i+n.length)%n.length];m6(e,t,o.value),t.querySelector(`[data-value="${CSS.escape(o.value)}"]`)?.focus()}),p6(t,String(I3(e))),t}function g6(e){let t=M(`select`,`settings-view-input`);t.setAttribute(`aria-labelledby`,e.id);for(let n of e.options??[]){let e=M(`option`,null,n.label);e.value=n.value,t.appendChild(e)}return t.value=String(I3(e)),t.addEventListener(`change`,()=>e6(e,t.value)),t}function _6(e,t){let n=e.valueKind===`posthog-projects`?`One project id per line, or none for no project. Shift+Enter adds a line.`:`One entry per line. Shift+Enter adds a line.`;return t.length>0||!e.listEmptyText?n:`${e.listEmptyText} ${n}`}function v6(e){let t=M(`textarea`,`settings-view-input settings-view-list-input`),n=()=>x0(I3(e)),r=()=>n().join(`
175
- `);t.rows=3,t.value=r(),t.autocomplete=`off`,t.spellcheck=!1,t.placeholder=e.listPlaceholder??``,t.setAttribute(`aria-labelledby`,e.id),c6(e,t),t.addEventListener(`blur`,()=>u6(e,t,r())),t.addEventListener(`keydown`,n=>{n.key===`Escape`?(n.preventDefault(),l6(e,t,r())):n.key!==`Enter`||n.shiftKey||(n.preventDefault(),u6(e,t,r()))});let i=M(`div`,`settings-view-list`);return i.append(t,M(`span`,`settings-view-list-hint`,_6(e,n()))),i}function y6(e){let t=M(`div`,`settings-view-projects`),n=I3(e),r=new Set(Array.isArray(n)?n:[]),i=Array.isArray(h3.projectChoices)?h3.projectChoices:[];i.length===0&&t.appendChild(M(`div`,`settings-empty`,`No configured projects are available.`));for(let n of r0(i,[...r])){let i=M(`label`,`settings-view-project-choice`),a=M(`input`,`settings-view-checkbox`);a.type=`checkbox`,a.checked=r.has(n.id),a.addEventListener(`change`,()=>{let t=I3(e),r=new Set(Array.isArray(t)?t:[]);a.checked&&r.add(n.id),a.checked||r.delete(n.id),e6(e,[...r])}),i.append(a,document.createTextNode(n.name)),t.appendChild(i)}return t}function b6(e,t,{isPrimary:n=!1,isEnabled:r=!0}={}){let i=M(`button`,`btn-dialog ${n?`btn-dialog-confirm`:`btn-dialog-cancel`} settings-update-button`,e);return i.type=`button`,i.disabled=!r,i.addEventListener(`click`,t),i}function x6(e){let t=M(`span`,`settings-update-action-status`,e??``);return t.setAttribute(`role`,`status`),t}function S6(e){let t=Pu(E3,e);t!==E3&&(E3=t,q8())}function C6(){S6(K({type:`update-apply`})?`request-sent`:`request-unsent`)}function w6(){O3=Date.now();let e=K({type:`update-check`});A3=e,j3=e?null:G,q8()}function T6(){return A3?`Checking for updates.`:j3}function E6(){w3?(k3=!1,td({status:w3,checkForUpdates:h3.checkForUpdates,now:Date.now(),lastAutoCheckAt:O3})&&w6()):k3=!0}function D6(e){return e===`update`?b6(`Update`,C6,{isPrimary:!0}):e===`restart`?b6(`Restart`,D3,{isPrimary:!0}):b6(`Check for updates`,w6,{isEnabled:!A3})}function O6(){let e=Ru({status:w3,journal:T3,request:E3}),t=M(`div`,`settings-update-actions`);if(e.actions.length>0){let n=M(`div`,`settings-update-buttons`);n.append(...e.actions.map(D6)),t.appendChild(n)}let n=T6();return n&&t.appendChild(x6(n)),e.note&&t.appendChild(x6(e.note)),e.command&&t.appendChild(M(`code`,`settings-update-command`,e.command)),t}function k6(e,...t){let n=M(`div`,`settings-update-fact`);return n.append(M(`span`,`settings-update-fact-label`,e),...t),n}function A6(){let e=Yu(T3);if(!e)return null;let t=M(`div`,`settings-update-progress`);t.dataset.state=e.state,t.setAttribute(`role`,`status`),e.terminalLine&&t.appendChild(M(`div`,`settings-update-terminal`,e.terminalLine));let n=M(`ol`,`settings-update-steps`);for(let t of e.steps){let e=M(`li`,`settings-update-step`);e.dataset.status=t.status,e.append(M(`span`,`settings-update-step-state`,t.status),M(`span`,`settings-update-step-label`,t.label)),n.appendChild(e)}if(t.appendChild(n),e.outputTail.length===0)return t;let r=M(`pre`,`settings-update-output`,e.outputTail.join(`
176
- `));if(e.outputStepId&&(r.dataset.step=e.outputStepId),!e.outputStepLabel)return t.appendChild(r),t;let i=`Output from ${e.outputStepLabel}`;return r.setAttribute(`aria-label`,i),t.append(M(`div`,`settings-update-output-label`,i),r),t}function j6(){let e=ed(w3),t=[e.label];if(e.behind&&t.push(M(`span`,`settings-update-behind`,e.behind)),e.releaseUrl){let n=M(`a`,`settings-link`,`View release`);n.href=e.releaseUrl,n.target=`_blank`,n.rel=`noopener noreferrer`,t.push(n)}return k6(`Latest`,...t)}function M6(){let e=M(`div`,`settings-view-status-block settings-update-status`),t=Qu(w3,T3),n=M(`div`,`settings-update-summary`,t.headline);n.dataset.tone=t.tone,e.appendChild(n),e.appendChild(k6(`Running`,$u(w3))),w3?.updateAvailable&&e.appendChild(j6());let r=typeof w3?.lastCheckAt==`number`?w3.lastCheckAt:null,i=k6(`Last checked`,nd({status:w3,checkForUpdates:h3.checkForUpdates,relativeTime:Pf(r)}));r&&(i.title=new Date(r).toLocaleString()),e.appendChild(i),e.appendChild(O6());let a=A6();return a&&e.appendChild(a),e}function N6(e){return e===null?`not probed yet`:e?`resolved`:`not found on PATH`}function P6(){let e=Array.isArray(h3.customAgents)?h3.customAgents:[];return e.length===0?[`None declared. Add customAgents to config.json.`]:e.map(e=>{let t=e.args.length>0?`${e.command} ${e.args.join(` `)}`:e.command;return`${e.id} ${e.label} ${t} ${N6(e.resolvable)}`})}function F6(){let e=M(`div`,`settings-view-status-block`);e.appendChild(M(`div`,`settings-section-title`,`Declared agents`));for(let t of P6())e.appendChild(M(`div`,`settings-readonly`,t));return e}function I6(e){N3.set(e,{tone:`ok`,text:`Saved`}),window.setTimeout(()=>{N3.get(e)?.tone===`ok`&&(N3.delete(e),K8())},J4)}async function L6(e,t){M3.add(e.id),N3.delete(e.id),K8();try{let n=await _d(`update-settings`,{settings:{workflows:{rules:[{id:e.id,enabled:t}]}}},{timeoutMs:q});if(M3.delete(e.id),n.type===`settings-error`&&N3.set(e.id,{tone:`error`,text:String(n.message)}),n.type===`settings-updated`){I6(e.id),U8(n.settings);return}}catch(t){N3.set(e.id,{tone:`error`,text:Ad(t,q)})}M3.delete(e.id),K8()}function R6(e){let t=Od(`settings-workflow-rule-status`);if(M3.has(e.id))return t.show(`busy`,`Saving`),t.element;let n=N3.get(e.id);return n&&t.show(n.tone,n.text),t.element}function z6(e){let t=M(`div`,`settings-view-toggle-wrap`),n=M(`label`,`settings-view-toggle`),r=M(`input`,`settings-view-checkbox`);return r.type=`checkbox`,r.checked=e.isEnabled,r.disabled=M3.has(e.id),r.setAttribute(`aria-label`,`Run rule ${e.name}`),r.addEventListener(`change`,()=>{L6(e,r.checked)}),n.append(r,M(`span`,`settings-view-toggle-state`,i6(e.isEnabled)),M(`span`,`settings-readonly`,`${e.name} ${e.summary}`)),t.append(n,R6(e)),t}function B6(){let e=M(`div`,`settings-view-status-block`);e.appendChild(M(`div`,`settings-section-title`,`Rules`));let t=u2(h3.workflows);if(t.length>0){for(let n of t)e.appendChild(z6(n));return e}for(let t of l2(h3.workflows))e.appendChild(M(`div`,`settings-readonly`,t));return e}function V6(){let e=M(`div`,`settings-view-status-block`);e.appendChild(M(`div`,`settings-section-title`,`Last report`));for(let t of K4())e.appendChild(M(`div`,`settings-readonly`,t));return e}function H6(){let e=M(`div`,`settings-view-status-block`);if((y3.get(`remote-sessions`)??g3.remoteSessions)!==!0)return e.appendChild(M(`div`,`settings-readonly`,`Turn on Remote Coder sessions (experimental) to connect agent logins for them.`)),e;for(let t of[`claude-code`,`codex`]){let n=M(`div`,`settings-telegram-test`),r=M(`button`,`btn-dialog btn-dialog-cancel`,`Connect`);r.type=`button`,r.addEventListener(`click`,()=>Xf(t)),n.append(M(`div`,`settings-readonly`,Jf(Gf(t),t)),r),e.appendChild(n)}return e}function U6(e){return e.status===`agent-logins`?H6():e.status===`update-actions`?M6():e.status===`custom-agents`?F6():e.status===`workflows`?B6():M(`div`,`settings-readonly`,`Not available`)}function W6(e){return e.control===`readonly`?U6(e):e.control===`toggle`?a6(e):e.control===`number`?f6(e):e.control===`select`?n2(e)===`segmented`?h6(e):g6(e):e.control===`list`?v6(e):e.control===`projects`?y6(e):d6(e)}function G6(e){let t=h0(e,h3);return t?`Supplied by ${t}. Change the server environment and restart to replace this credential.`:e.status!==`rtk-install`||I3(e)!==!0||h3.rtkAvailable?``:g0(h3)}function K6(e){if(e.control===`readonly`)return null;if(e.status===`usage-last-report`){let e=V6();return e.classList.add(`settings-view-status-slot`),e}if(e.id===`desktop-notifications`)return X6(e);if(e.status===`telegram-delivery`)return Y6();let t=G6(e);return t?M(`div`,`settings-view-warning settings-view-status-slot`,t):null}function q6(){let e=So.safeParse(h3.telegramDelivery);if(!e.success)return[];let{setupWarning:t,lastFailure:n}=e.data,r=t?[t]:[];return n&&r.push(`The last Telegram send failed at ${new Date(n.failedAt).toLocaleString()}: ${n.message}`),r}function J6(e){e.replaceChildren(...q6().map(e=>M(`p`,`settings-view-warning`,e)))}function Y6(){let e=M(`div`,`settings-view-status-slot settings-telegram-delivery`),t=M(`div`,`settings-telegram-delivery-lines`);J6(t);let n=M(`button`,`btn-dialog btn-dialog-cancel`,`Send test message`);n.type=`button`;let r=Od(`settings-telegram-test-status`);n.addEventListener(`click`,async()=>{n.disabled=!0;let e=await jd(`telegram-test`,{},r,{busyText:`Sending a test message to Telegram.`});n.disabled=!1,e?.type===`telegram-test-result`&&(h3={...h3,telegramDelivery:e.telegramDelivery},J6(t),e.ok?r.show(`ok`,`Sent. Check the Telegram chat for the test message.`):r.show(`error`,`Not sent: ${e.error??`Telegram refused the message.`}`))});let i=M(`div`,`settings-telegram-test`);return i.append(n,r.element),e.append(t,i),e}function X6(e){let t=gp(()=>u8(e,{force:!0}));return t.element.hidden?null:(t.element.classList.add(`settings-view-status-slot`),t.element)}function Z6(e,t){let n=M(`span`,`settings-view-chip`,t);return n.dataset.chip=e,n}function Q6(e,t){let n=yr(e);return n?n.then(()=>t,()=>`Copy failed`):Promise.resolve(`Copy failed`)}function $6(e,t,{copiedText:n,textToCopy:r}){let i=M(`span`,`settings-view-copy-status`);i.setAttribute(`role`,`status`),t.type=`button`,t.addEventListener(`click`,async()=>{i.textContent=await Q6(r(),n),setTimeout(()=>{i.textContent=``},Y4)}),e.append(t,i)}function e8(e){let t=M(`div`,`settings-view-setting-heading`),n=z3(e),r=M(`h2`,`settings-view-setting-title`,e.title);r.id=e.id,r.addEventListener(`click`,()=>B3(n.id,e.id));let i=M(`button`,`settings-view-copy-link`,`#`);return i.setAttribute(`aria-label`,`Copy link`),t.appendChild(r),$6(t,i,{copiedText:`Link copied`,textToCopy:()=>new URL(wp(n.id,e.id),location.href).href}),t}function t8(e){let t=M(`div`,`settings-view-chips`);return t.append(Z6(`scope`,m0[e.scope]),Z6(`effect`,p0[e.takesEffect])),t}function n8(e){return e.control===`readonly`||h0(e,h3)?!1:!t2(e,I3(e))}function r8(e){let t=M(`div`,`settings-view-control-foot`),n=M(`span`,`settings-view-save-status`);n.setAttribute(`role`,`status`);let r=M(`button`,`settings-view-reset`,`Reset`);return r.type=`button`,r.title=`Reset to the default value`,r.addEventListener(`click`,()=>{let t=e2(e),n=s2(e);n===null?e6(e,t):rf({title:e.title,message:n,confirmLabel:`Reset`,danger:!0,onConfirm:()=>e6(e,t)})}),t.append(n,r),t}function i8(e,t){let n=e.querySelector(`.settings-view-save-status`),r=_3.get(t.id);n&&(n.textContent=r?.text??``,r&&(n.dataset.tone=r.tone),r||delete n.dataset.tone);let i=e.querySelector(`.settings-view-reset`);i&&(i.disabled=!n8(t));let a=e.querySelector(`.settings-view-field-error`),o=S3.get(t.id);a&&!o&&a.remove(),a&&o&&(a.textContent=o),!a&&o&&e.querySelector(`.settings-view-setting-control`)?.appendChild(M(`div`,`settings-view-field-error`,o))}function a8(e){let t=M(`article`,`settings-view-setting`);t.dataset.settingId=e.id,e.control===`readonly`&&(t.dataset.readout=`true`);let n=M(`div`,`settings-view-setting-text`);n.append(e8(e),M(`p`,`settings-view-setting-description`,e.description),t8(e));let r=M(`div`,`settings-view-setting-control`);r.appendChild(W6(e)),e.control!==`readonly`&&r.appendChild(r8(e)),t.append(n,r),i2(e,I3(e))&&t.appendChild(M(`div`,`settings-view-warning settings-warning`,e.warning));let i=K6(e);return i&&t.appendChild(i),i8(t,e),t}function o8(e){return p3?.querySelector(`[data-setting-id="${e.id}"]`)??null}function s8(e){let t=e.querySelector(`.settings-view-setting-control`);t&&(t.querySelector(`[role="radio"][aria-checked="true"]`)??t.querySelector(`input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled])`))?.focus()}function c8(e,t){if(!s6(e)||!s6(t))return;e.disabled=t.disabled,e.placeholder=t.placeholder;let n=b3.get(t);n&&!Q0(b3.get(e))&&(b3.set(e,{base:n.base,isDirty:!1}),e.value!==t.value&&(e.value=t.value))}function l8(e,t,n){if(e===n){c8(e,t);return}let r=[...e.children],i=[...t.children];for(let[t,a]of i.entries()){let i=r[t];i?i.contains(n)?l8(i,a,n):i.replaceWith(a):e.appendChild(a)}for(let e of r.slice(i.length))e.remove()}function u8(e,{force:t=!1}={}){let n=o8(e);if(!n)return;let r=document.activeElement,i=n.contains(r),a=i&&!t&&s6(r)?r:null;(!a||!Q0(b3.get(a)))&&S3.delete(e.id);let o=a8(e);a?l8(n,o,a):(n.replaceWith(o),i&&s8(o))}function d8(e){let t=o8(e);t&&i8(t,e)}function f8(e){o8(e)?.querySelector(`.settings-view-setting-control`)?.replaceChildren(U6(e))}function p8(){for(let e of R3(m3))e.control===`readonly`?f8(e):u8(e)}function m8(){let e=M(`button`,`btn-dialog btn-dialog-cancel`,`Reset all to defaults`);return e.type=`button`,e.addEventListener(`click`,()=>{Uc(),F3(h3),g$(Xs()),y8()}),e}function h8(e){let t=M(`div`,`settings-view-advanced`),n=M(`button`,`dialog-advanced-toggle settings-view-advanced-toggle`,`Advanced`);n.type=`button`,n.setAttribute(`aria-expanded`,String(a3)),n.setAttribute(`aria-controls`,`settings-view-advanced-panel`);let r=M(`div`,`dialog-advanced-panel settings-view-advanced-panel`);r.id=`settings-view-advanced-panel`,r.hidden=!a3,n.addEventListener(`click`,()=>{a3=!a3,r.hidden=!a3,n.setAttribute(`aria-expanded`,String(a3))});for(let t of e)r.append(a8(t));return m3.id===X4&&r.append(m8()),t.append(n,r),t}function g8(e){let t=M(`div`,`settings-view-streamer-placeholder`),n=M(`button`,`btn-dialog btn-dialog-confirm`,`Turn off streamer mode`);n.type=`button`;let r=M(`span`,`settings-view-copy-status`,``);r.setAttribute(`role`,`status`),n.addEventListener(`click`,async()=>{n.disabled=!0,r.textContent=``;let e=await lh(!1);n.disabled=!1,r.textContent=e}),t.append(M(`p`,`settings-view-section-description`,`Settings are hidden in streamer mode.`),n,r),e.appendChild(t)}ch(()=>y8());function _8(e){let t=M(`header`,`settings-view-subsection`),n=M(`h2`,`settings-view-subsection-title`,e.title);return n.addEventListener(`click`,()=>B3(e.id)),t.append(n,M(`p`,`settings-view-section-description`,e.description)),t}function v8(e,t){for(let n of t.settings.filter(e=>e.access!==`advanced`))e.appendChild(a8(n)),n.id===e3&&e.appendChild(_$());let n=t.settings.filter(e=>e.access===`advanced`);n.length>0&&e.append(h8(n))}function y8(){if(j8(),C3){D8();return}if(!p3)return;if(p3.textContent=``,oh()){g8(p3);return}let e=M(`header`,`settings-view-section-header`),t=M(`h1`,`settings-view-section-title`,m3.title);if(t.tabIndex=-1,t.addEventListener(`click`,()=>B3(m3.id)),e.append(t,M(`p`,`settings-view-section-description`,m3.description)),p3.appendChild(e),m3.id===Z4){let e=M(`div`,`shortcut-groups settings-view-shortcuts`);H3(e),p3.appendChild(e),p3.appendChild(kv()),p3.appendChild(Av()),q3(p3);return}if(m3.id===Q4){K3(p3);return}let n=M(`div`,`settings-view-stack`);for(let e of L3(m3))e.id!==m3.id&&n.appendChild(_8(e)),v8(n,e);p3.appendChild(n)}function b8(e,{focusContent:t=!1,settingId:n=null,updateHash:r=!0,openPhoneSection:i=!0}={}){r&&C3&&(C3=``,u3&&(u3.value=``));let a=k0(i3,e)??m3;m3.id!==a.id&&(a3=!1),m3=a;let o=i3.find(t=>t.id===e)??a;x8(l3),i&&Ky()&&(d3=o.id),y8(),z8(m3)&&R8(),m3.id===`machine-updates`&&E6(),r&&B3(o.id,n),n&&V3(n),t&&p3?.querySelector(`h1`)?.focus()}function x8(e){for(let t of e?.querySelectorAll(`[data-settings-section]`)||[]){let e=t.dataset.settingsSection===m3.id;t.setAttribute(`aria-current`,e?`page`:`false`)}}function S8(e){return e.section!==null}function C8(e){u3&&(u3.value=``,C3=``,P8(),b8(e.section.id,{settingId:e.setting.id}))}function w8(e){return Q1(x1.sections,e,x1.fileOnly)}function T8(e,t,n,r,i){let a=M(e,t),o=r.matches.find(e=>e.field===i),s=o?n.indexOf(o.text):-1;if(!o||s<0)return a.textContent=n,a;let c=0;for(let e of o.spans)a.append(n.slice(c,s+e.start),M(`mark`,`settings-view-search-highlight`,n.slice(s+e.start,s+e.end))),c=s+e.end;return a.append(n.slice(c)),a}function E8(e,t){let{currentText:n,defaultText:r,jsonFragment:i}=T0(t.setting,h3);if(n!==null&&e.appendChild(M(`span`,`settings-view-search-current`,n)),e.append(M(`span`,`settings-view-search-default`,r),t8(t.setting),M(`p`,`settings-view-list-hint`,`Edit in config.json or with glimmervoid settings set.`)),i===null)return;let a=M(`div`,`settings-view-control-foot`);$6(a,M(`button`,`settings-view-copy-json`,`Copy as JSON`),{copiedText:`JSON copied`,textToCopy:()=>i}),e.appendChild(a)}function D8(){if(!p3)return;if(p3.textContent=``,oh()){g8(p3);return}let e=w8(C3),t=M(`div`,`settings-view-section-header`);if(t.append(M(`h1`,`settings-view-section-title`,`Settings search`),M(`p`,`settings-view-section-description`,`${e.length} ${e.length===1?`result`:`results`} for "${C3}"`)),p3.appendChild(t),e.length===0){p3.appendChild(M(`p`,`settings-empty settings-view-search-empty`,`No settings found.`));return}let n=M(`ol`,`settings-view-search-results`);n.setAttribute(`aria-label`,`Settings search results`);for(let t of e){let e=M(`li`,`settings-view-search-result`);e.tabIndex=-1;let r=E0(i3,t.section,t.setting);e.appendChild(T8(`p`,`settings-view-search-breadcrumb`,r,t,`section`));let i=T8(`span`,`settings-view-setting-title`,t.setting.title,t,`title`);if(S8(t)){let n=M(`button`,`settings-view-search-open`);n.type=`button`,n.appendChild(i),n.addEventListener(`click`,()=>C8(t)),e.appendChild(n)}S8(t)||(e.classList.add(`settings-view-search-file-only`),e.appendChild(i)),e.append(T8(`p`,`settings-view-setting-description`,t.setting.description,t,`description`),T8(`code`,`settings-view-key-path`,t.setting.path,t,`path`));let a=new Set([`title`,`description`,`path`,`section`]);if(!t.matches.some(e=>a.has(e.field))){let n=t.matches.find(e=>e.field===`options`)??t.matches.find(e=>e.field===`keywords`);n&&e.appendChild(T8(`p`,`settings-view-list-hint`,n.text,t,n.field))}S8(t)||E8(e,t),n.appendChild(e)}p3.appendChild(n)}function O8(){return M0(i3,d3,C3,oh())}var k8=new Set;function A8(e){k8.add(e)}function j8(){if(!c3)return;let e=O8(),t=c3.dataset.settingsScreen!==e;if(c3.dataset.settingsScreen=e,f3&&(f3.hidden=e!==`section`),t)for(let e of k8)e()}function M8(){return Ky()&&O8()===`section`}function N8(){if(!M8())return;let e=m3.id;F8(``),l3?.querySelector(`[data-settings-section="${e}"]`)?.focus()}function P8(){if(l3&&c3){l3.textContent=``;for(let e of j0(A0(i3))){let t=M(`div`,`settings-view-nav-group`);e.heading&&t.appendChild(M(`div`,`settings-view-nav-heading`,e.heading));for(let n of e.sections){let e=M(`button`,`settings-view-nav-item`,n.title);e.type=`button`,e.dataset.settingsSection=n.id,e.addEventListener(`click`,()=>b8(n.id,{focusContent:Ky()})),t.appendChild(e)}l3.appendChild(t)}C3?(j8(),D8()):b8(m3.id,{updateHash:!1,openPhoneSection:!1})}}function F8(e,{updateHash:t=!0}={}){C3=e.trim(),u3&&(u3.value=e),d3=null,t&&history.replaceState(history.state,``,Ep(C3)),P8()}function I8(e){if(C3&&e.key===`Enter`&&e.target===u3){let t=w8(C3).find(S8);if(!t)return;e.preventDefault(),C8(t);return}if(e.key===`Escape`&&C3){if(!u3)return;e.preventDefault(),F8(``),u3.focus();return}if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`||!l3)return;let t=[...l3.querySelectorAll(`[data-settings-section]`)].filter(e=>e instanceof HTMLElement),n=document.activeElement;if(!(n instanceof HTMLElement))return;let r=t.indexOf(n);r<0||(e.preventDefault(),t[(r+(e.key===`ArrowDown`?1:-1)+t.length)%t.length].focus())}function L8(e,{onRestart:t=()=>{}}={}){D3=t,QY(Y3),o3=e,o3.textContent=``,c3=M(`div`,`settings-view-shell`);let n=M(`div`,`settings-view-sidebar`);u3=M(`input`,`settings-view-search`),u3.type=`search`,u3.placeholder=`Search settings`,u3.setAttribute(`aria-label`,`Search settings`),l3=M(`nav`,`settings-view-nav`),l3.setAttribute(`role`,`navigation`),l3.setAttribute(`aria-label`,`Settings sections`),f3=M(`button`,`settings-view-back`,`Back`),f3.type=`button`,f3.hidden=!0,f3.setAttribute(`aria-label`,`Back to settings sections`),f3.addEventListener(`click`,N8),p3=M(`div`,`settings-view-content`),p3.setAttribute(`aria-live`,`polite`),u3.addEventListener(`input`,()=>{let e=u3;e&&F8(e.value)}),u3.addEventListener(`keydown`,I8),l3.addEventListener(`keydown`,I8),n.append(u3,f3,l3),c3.append(n,p3),o3.appendChild(c3),F3(h3),P8(),R8(),s3?.disconnect(),s3=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&R8()}),s3.observe(o3)}function R8(){hb().then(B8)}function z8(e){return R3(e).some(e=>e.path===`pref:soundId`)}function B8(){if(i3=r3(),m3=k0(i3,m3.id)??i3[0],g3[`pref:soundId`]=mb(Bs()),C3){D8();return}let e=J3(`alert-sound`);e&&z8(m3)&&u8(e)}function V8(e=null,t=null){let n=D0(e??location.hash);n?F8(n.query):(F8(``,{updateHash:!1}),Ky()&&!e?history.replaceState(history.state,``,Ep(``)):b8(e||m3.id,{settingId:t}))}function H8(e){let t=D0(e);if(t){let e=Ep(t.query);return{sectionId:e,settingId:null,hash:e}}return $1(e,i3,S1,C1)}function U8(e){e&&(h3=e,F3(h3),C3?D8():p8())}function W8(e){K8()}function G8(e,t){let n=t.querySelector(`.settings-view-status-slot`),r=K6(e);n&&r&&n.replaceWith(r),n&&!r&&n.remove(),!n&&r&&t.appendChild(r)}function K8(){for(let e of R3(m3)){if(!e.status)continue;let t=o8(e);t&&(e.control===`readonly`?f8(e):G8(e,t))}}function q8(){if(m3.id!==`machine-updates`)return;let e=J3(`update-actions`);e&&f8(e)}function J8(e){w3=e,A3=!1,j3=null,E3=Pu(E3,`status-frame`),q8(),k3&&m3.id===`machine-updates`&&E6()}function Y8(e){T3=e,E3=Pu(E3,`progress-frame`),q8()}function X8(e){if(e.scope!==`update`)return!1;let t=Nu(e.message),n=E3.requested;return E3=Pu(E3,`error-frame`,t),A3=!1,n||(j3=t),q8(),!0}function Z8(){m3.id===X4&&y8()}window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,Z8),qy(()=>{d3=null,j8(),Z8()}),Kf(K8);function Q8(e,t){return typeof t!=`string`||t===``?{knownBuild:e,reload:!1}:e==null?{knownBuild:t,reload:!1}:e===t?{knownBuild:e,reload:!1}:{knownBuild:t,reload:!0}}var $8=`•`.repeat(8),e5=`[^/\\\\\\s"'\`<>:]+`,t5=RegExp(`(?<![\\w./\\\\-])(?:/home/${e5}|/Users/${e5}|[A-Za-z]:[\\\\/]Users[\\\\/]${e5}|/root(?![\\w.-]))`,`g`);function n5(e){let t=Bx(e);if(t.length===0)return e;let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+$8,r=i.end;return n+e.slice(r)}function r5(e){return e.replace(t5,`~`)}function i5(e){return r5(n5(e))}var a5=`.xterm, input, textarea, script, style, [contenteditable]:not([contenteditable="false"])`,o5=[`title`,`label`],s5=new WeakMap,c5=new WeakMap,l5=null;function u5(e){let t=e instanceof Element?e:e.parentElement;return!t||t.closest(a5)!==null}function d5(e){let t=e.parentElement?.closest(`option`);return t!=null&&!t.hasAttribute(`value`)}function f5(e,t){if(t&&e===t.masked)return t;let n=i5(e);return n===e?null:{original:e,masked:n}}function p5(e){let t=d5(e)?null:f5(e.data,s5.get(e));t?(s5.set(e,t),e.data!==t.masked&&(e.data=t.masked)):s5.delete(e)}function m5(e,t){let n=e.getAttribute(t),r=c5.get(e),i=n===null?null:f5(n,r?.get(t));if(!i){r?.delete(t);return}let a=r??new Map;a.set(t,i),c5.set(e,a),n!==i.masked&&e.setAttribute(t,i.masked)}function h5(e){for(let t of o5)m5(e,t)}function g5(e){return e instanceof Element&&e.matches(a5)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function _5(e){h5(e);let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,g5);for(let e=t.nextNode();e;e=t.nextNode())e instanceof Text&&p5(e),e instanceof Element&&h5(e)}function v5(e){u5(e)||(e instanceof Text&&p5(e),e instanceof Element&&_5(e))}function y5(e){e instanceof Element&&!u5(e)&&h5(e)}function b5(e){let t=new Set,n=new Set;for(let r of e){if(r.type===`childList`)for(let e of r.addedNodes)t.add(e);r.type===`characterData`&&t.add(r.target),r.type===`attributes`&&n.add(r.target)}for(let e of t)e.isConnected&&v5(e);for(let e of n)e.isConnected&&y5(e)}function x5(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);S5(e);for(let e=t.nextNode();e;e=t.nextNode())S5(e)}function S5(e){if(e instanceof Text){let t=s5.get(e);t&&e.data===t.masked&&(e.data=t.original);return}if(!(e instanceof Element))return;let t=c5.get(e);if(t)for(let[n,r]of t)e.getAttribute(n)===r.masked&&e.setAttribute(n,r.original)}function C5(){if(l5)return;let e=new MutationObserver(t=>{b5(t),e.takeRecords()});_5(document.body),e.observe(document.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:o5}),l5=e}function w5(){l5&&(l5.disconnect(),l5=null,x5(document.body),s5=new WeakMap,c5=new WeakMap)}function T5(e){e?C5():w5()}function E5(){T5(oh()),ch(T5)}function D5(e){if(typeof e!=`object`||!e||!(`telemetry`in e))return!1;let{telemetry:t}=e;return typeof t!=`object`||!t||!(`enabled`in t)?!1:t.enabled===!0}function O5(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function k5(e,t){return t||O5(e)?!1:D5(e)}var A5=2500;function j5({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}var M5=new Set([j.RUNNING,j.STARTING,j.INITIALIZING]),N5=null,P5=!1,F5=null;function I5(e){let t=M(`div`,`zen-calm`),n=M(`div`,`zen-status-line`);n.setAttribute(`role`,`status`);let r=M(`span`,`zen-working-count`);n.append(M(`h2`,`zen-all-clear`,`ALL CLEAR`),r);let i=M(`ul`,`zen-working-list`);i.setAttribute(`aria-label`,`Working sessions`),t.append(n,i);let a=M(`div`,`zen-stage`),o=M(`div`,`zen-reason-line`);o.setAttribute(`role`,`status`);let s=M(`span`,`zen-staged-need`),c=M(`span`,`zen-queued-behind`);o.append(s,c);let l=M(`button`,`btn-dialog`,`Next`);l.type=`button`,l.addEventListener(`click`,V5);let u=M(`div`,`zen-stage-bar`);u.append(o,l,Qp(Kp(`next-attention`,Xp)));let d=M(`div`,`zen-card-slot`);a.append(u,d),a.hidden=!0,e.append(t,a),N5={calm:t,workingCount:r,workingList:i,stage:a,stagedNeed:s,queuedBehind:c,cardSlot:d}}function L5(){return P5}function R5(){N5&&(P5=!0,B5())}function z5(){P5&&=(W5(),!1)}function B5(){if(!P5)return;let e=H5();U5(Dg(e,F5),e)}function V5(){if(!P5)return;let e=F5,t=e!==null&&F.get(e)?.currentState===j.COMPLETE;e!==null&&t&&XN(e);let n=H5().filter(n=>!t||n!==e);U5(Eg(n,e),n)}function H5(){return Pg(wg(Gv()))}function U5(e,t){if(!N5)return;let n=e===null?void 0:F.get(e);if(e===null||!n){W5(),K5(N5);return}let r=F5!==e;F5=e,N5.calm.hidden=!0,N5.stage.hidden=!1,G5(N5,n,t.filter(t=>t!==e).length),(jr()!==e||n.card.parentElement!==N5.cardSlot)&&(Mr(n,e,N5.cardSlot,{className:`zen-staged`}),UC(n,e,!0),r&&q5(n,e))}function W5(){F5!==null&&jr()===F5&&Nr(),F5=null}function G5(e,t,n){e.stagedNeed.textContent=kg(t.currentState,t.pendingPromptKind),e.stagedNeed.dataset.state=t.currentState,e.queuedBehind.textContent=`${n} more waiting`,e.queuedBehind.hidden=n===0}function K5(e){e.stage.hidden=!0,e.calm.hidden=!1;let t=wg(Gv()).filter(e=>M5.has(e.state));e.workingCount.textContent=`${t.length} working`,e.workingList.replaceChildren(...t.map(e=>{let t=M(`li`,`zen-working-session`),n=M(`span`,`zen-working-dot`);return n.setAttribute(`aria-hidden`,`true`),t.append(n,M(`span`,`zen-working-name`,e.name),M(`span`,`zen-working-project`,eP(e.ui.path))),t}))}function q5(e,t){requestAnimationFrame(()=>requestAnimationFrame(()=>{P5&&F5===t&&!document.hidden&&document.hasFocus()&&e.term?.focus()}))}function J5(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function Y5(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function X5(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function Z5(e,t){e?.refreshOn?.includes(t)&&e.refresh?.(t)}function Q5(e,t,n){for(let r of e)J5(r.view,t)&&Z5(r,n)}function $5(e){let t=[{view:`focus`,label:`Focus`,panelClass:`focus-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,hasReviewSidebar:!0,mount:()=>PP({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:sF,deactivate:uF},{view:`zen`,label:`Zen`,panelClass:`zen-view`,hasOwnPhoneScreen:!0,hasPanelChrome:!1,gate:{fromSettings:f2.zenView},mount:I5,activate:R5,deactivate:z5},{view:`prs`,label:`Reviews`,glyph:`⇅`,panelClass:`pr-view`,gate:{fromSettings:f2.teamReview},mount:t=>FY(t,{openTerminal:e.openTerminal,openReviews:e.openReviews}),attention:{subscribe:wY,acknowledge:PY},onConnectionChange:e=>{dG(e),kY(e)}},{view:`issues`,label:`Issues`,glyph:`#`,panelClass:`issues-view`,mount:TZ,refreshOn:[`shown`],refresh:EZ,onConnectionChange:OZ},{view:`usage`,label:`Usage`,glyph:`◔`,panelClass:`usage-view`,gate:{fromSettings:f2.usage},mount:V4,attention:{subscribe:I4,acknowledge:M4},onConnectionChange:B4,refreshOn:[`shown`,`connected`,`usage-sessions`],refresh:e=>{e===`shown`&&H4(),z4()}},{view:`radar`,label:`Radar`,glyph:`◎`,panelClass:`radar-view`,gate:{fromSettings:f2.posthog},mount:RQ,attention:{subscribe:IQ,acknowledge:FQ}},{view:`visions`,label:`Visions`,glyph:`◇`,panelClass:`visions-view`,gate:{fromSettings:f2.visions},mount:dL,attention:{subscribe:cL,acknowledge:()=>{pL(),fL()}},onConnectionChange:uL},{view:`hooks`,label:`Hooks`,glyph:`◈`,panelClass:`hooks-view`,mount:yz,refreshOn:[`shown`,`connected`,`hooks-updated`],refresh:e=>{e===`shown`&&bz(),vz()}},{view:`trace`,label:`Trace`,panelClass:`trace-view`,gate:{subscribe:x_},mount:$k,refreshOn:[`shown`],refresh:iA,onAvailabilityChange:e=>LQ(e?nA:null),onConnectionChange:cA},{view:`benchmarks`,label:`Bench`,panelClass:`bench-view`,gate:{fromSettings:f2.benchmarks},mount:vX,onConnectionChange:yX},{view:`settings`,label:`Settings`,glyph:`@`,panelClass:`settings-view`,hasPanelChrome:!1,mount:t=>L8(t,{onRestart:e.onRestart})}],n=N(document,`#app-main`,`main`),r=t.map(t=>{let r=M(`button`,`header-tab`,t.label);r.id=`tab-${t.view}`,r.type=`button`;let i=`view-${t.view}`;r.setAttribute(`role`,`tab`),r.setAttribute(`aria-controls`,i);let a=t.view===`focus`;r.setAttribute(`aria-selected`,String(a)),r.tabIndex=a?0:-1,t.glyph&&(r.dataset.phoneGlyph=t.glyph);let o=document.getElementById(i)??M(`section`);if(o.classList.add(t.panelClass),o.id=i,o.setAttribute(`role`,`tabpanel`),o.setAttribute(`aria-labelledby`,r.id),o.hidden=!0,o.parentElement||n.append(o),r.hidden=t.gate!==void 0,o.classList.toggle(`view-panel`,t.hasPanelChrome!==!1),t.attention){let n=M(`span`,`tab-activity`);n.id=`tab-${t.view}-activity`,n.setAttribute(`aria-hidden`,`true`),r.append(n),t.attention.subscribe(r=>{let{isActive:i,level:a}=X5(r);n.classList.toggle(`active`,i),a===null&&n.removeAttribute(`data-attention`),a!==null&&n.setAttribute(`data-attention`,a),e.setPhoneAttention(t.view,r)})}return{...t,tab:r,el:o}});return N(document,`#header-tabs`,`div`).replaceChildren(...r.map(e=>e.tab)),r}jb(Js()),Mb(Ws()),Nb(Ks()),g$(Xs()),Gy(),hg(document);var e7=N(document,`#connection-status`,`span`),t7=N(e7,`.connection-label`,`span`),n7=N(document,`#loading-screen`,`div`),r7=N(document,`#loading-status`,`div`),i7=N(document,`#loading-detail`,`div`),a7=N(document,`#shutdown-screen`,`div`),o7=N(document,`#shutdown-status`,`div`),s7=!1,c7=null,l7=!1;function u7(){let e=Kc(),t=n7.querySelector(`.loading-spinner`);e&&t&&t.replaceWith(Gc(e,`loading-animal`))}u7();function d7(){s7||c7===null||j5({hasSnapshot:l7,connectingTerminalCount:CC(),msSinceConnected:performance.now()-c7})===`reveal`&&f7()}SC(d7);function f7(){if(s7)return;s7=!0,n7.classList.add(`fade-out`);let e=()=>n7.remove();n7.addEventListener(`transitionend`,e,{once:!0}),setTimeout(e,1e3)}function p7(e,t){e7.dataset.state=`shutdown`,t7.textContent=e,e7.title=e,n9.disabled=!0,o7.textContent=t,a7.classList.add(`active`)}var m7=new Set([`disconnected`,`connecting`]);function h7(e,t,n){e7.dataset.state=e,e7.toggleAttribute(`data-reconnected`,n),t7.textContent=t,e7.title=t}function g7(e,t){h7(e,t,e===`connected`&&m7.has(e7.dataset.state??``))}function _7(e,t){e7.dataset.state!==`shutdown`&&h7(e===`verified`?`connected`:e,t,!1)}var v7=1e4,y7=`The server is not answering. Check the terminal running Glimmervoid for errors, or start it again with glimmervoid. This page reconnects on its own.`,b7=`Server not answering. Check the Glimmervoid terminal for errors, or run glimmervoid. This page retries on its own.`,x7=null,S7=!1;function C7(){r7.textContent=`Reconnecting to server...`,i7.textContent=b7,i7.hidden=!S7}function w7(){x7=null,S7=!0,s7?Nd(y7,{hidesInStreamerMode:!1}):C7()}function T7(){x7!==null||S7||(x7=window.setTimeout(w7,v7))}function E7(){x7!==null&&window.clearTimeout(x7),x7=null,S7=!1,i7.hidden=!0,Pd(y7)}md((e,t)=>{if(e===`connecting`||e===`verified`)_7(e,t);else{g7(e,t),EN(e===`connected`);for(let t of f9)t.onConnectionChange?.(e===`connected`);if(e===`connected`){if(E7(),v9&&y9(v9),a7.classList.contains(`active`)){location.reload();return}_m(),document.body.classList.add(`app-ready`),!s7&&c7===null&&(c7=performance.now(),r7.textContent=`Connecting to sessions...`,setTimeout(f7,A5)),d7(),z9(),R7(`connected`),_d(`get-settings`,{}).then(e=>{e.settings&&(w9(e.settings),Ar()===`settings`&&s9(location.hash))}).catch(()=>{})}else e===`disconnected`&&a7.classList.contains(`active`)?o7.textContent=`Waiting for server...`:(T7(),s7||C7())}});function D7(){B5(),DZ(),nG(),HB()}function O7(){GP(),D7()}var k7=null;function A7(e){let t=Q8(k7,e);k7=t.knownBuild,t.reload&&location.reload()}function j7(e){JI(new Map(e.filter(e=>!e.ephemeral).map(e=>[e.id,e.name]))),W8(e.filter(e=>!e.ephemeral).map(e=>({id:e.id,name:e.name,agent:e.agent,permissionMode:e.dangerouslySkipPermissions?`Skip permissions`:`Default`})));for(let t of e){Jh(t.id,t.coherenceHooks),t.ephemeral||Nv(t.path),KY(t.id,t.linkedPrs);let e=fN(t.id);e&&QN(t.id,t.state,t.stateSince),e&&N_(t.id,!!t.saneYolo),e&&AN(t.id,t.isGuarded,t.isGuardrailsReleased),e||_N(t.id,t.name,t.state,JQ(t)),JN(t.id,t.failureReason),dN(t.id,t.taskTitle,t.taskTitleIsCustom),ON(t.id,t.agent),HN(t.id,t.mergeStatus,t.mergeReason),DN(t.id,t.effectiveBase),NN(t.id,t.activeAgents,t.awaitingBackgroundTasks),RN(t.id,t.pendingWakeup),IN(t.id,t.pendingPromptKind,t.isCompacting,t.isWaitingForMemory),iN(t.id,t),xN(t.id,t.hasPlan),L7(t.id)}gN(),$g(F),GP(),lF(),D7(),M7(),l9(location.hash),l7=!0,d7()}function M7(){rA([...F].map(([e,t])=>({id:e,name:Sr(t)||e})))}function N7(e,t){xN(e,t?.hasPlan===!0),L7(e)}function P7(e){if(!fN(e.id))_N(e.id,e.session,e.to,JQ({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),$g(F),DZ();else if(e.to===j.DORMANT&&e.from!==j.DORMANT){let t=F.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;GN(e.id),_N(e.id,e.session,j.DORMANT,JQ({skipPerms:i,saneYolo:a,worktree:r?.dataset.worktree!==void 0,workspace:r?.dataset.workspace!==void 0,guarded:r?.dataset.guarded!==void 0,guardrailsReleased:r?.dataset.guardrailsReleased!==void 0,ephemeral:r?.dataset.ephemeral!==void 0,path:o,stateSince:e.timestamp,taskTitle:t?.taskTitle,taskTitleIsCustom:t?.taskTitleIsCustom})),ON(e.id,t?.agent),N7(e.id,t),O7(),tD(e.id),$g(F)}else QN(e.id,e.to,e.timestamp,e.event),JN(e.id,e.failureReason),e.saneYolo!==void 0&&N_(e.id,e.saneYolo),$g(F),tD(e.id),O7(),ev(e.id),e.to===j.INITIALIZING&&(e.from===j.DONE||e.from===j.FAILED)&&MC(e.id)}var F7=new Map;function I7(e){let t=new Set;for(let n of e){if(!n?.id)continue;t.add(n.id);let e={tokens:n.tokens,costUSD:n.costUSD,officialCostUSD:n.officialCostUSD};F7.set(n.id,e),PN(n.id,e)}for(let e of[...F7.keys()])t.has(e)||(F7.delete(e),PN(e,null))}function L7(e){let t=F7.get(e);t&&PN(e,t)}R4(K),_z(K),eA(K),wZ(K),_X(K),w_(WY),mv(Qh),mv(HY),E_({isReadable:$h,open:tg}),O_(KQ);function R7(e){Q5(f9,{isPhoneShellActive:BB(),activeView:Ar(),phoneScreen:kr.snapshot().phoneScreen},e)}ch(()=>R7(`settings-updated`));var z7={snapshot:e=>{A7(e.serverBuild),j7(e.sessions)},"hooks-report":e=>xz(e),"save-hook-result":()=>Sz(),"delete-hook-result":()=>Sz(),"state-change":e=>P7(e),"session-added":e=>{e.ephemeral||Nv(e.path),KY(e.id,e.linkedPrs),fN(e.id)||(_N(e.id,e.session,e.state,JQ(e)),ON(e.id,e.agent),L7(e.id)),$g(F),O7(),M7()},"session-removed":e=>{GN(e.id),Yh(e.id),rD(e.id),qY(e.id),$g(F),O7(),M7()},"session-title":e=>{dN(e.id,e.taskTitle,e.isCustom),O7()},"session-prs":e=>KY(e.id,e.linkedPrs),"session-renamed":e=>{WN(e.id,e.newName),O7(),M7()},"session-modified":e=>{e.ephemeral||Nv(e.path);let t=F.get(String(e.id));Jh(e.id,null),GN(e.id),rD(e.id),KY(e.id,e.linkedPrs),_N(e.id,e.session,e.state,JQ(e)),ON(e.id,e.agent),N7(e.id,t),$g(F),O7(),M7()},"session-git":e=>kN(e.id,!!e.worktree),"session-agents":e=>{NN(e.id,e.activeAgents,e.awaitingBackgroundTasks),O7(),ev(e.id)},"session-wakeup":e=>RN(e.id,e.pendingWakeup),"session-prompt":e=>{IN(e.id,e.pendingPromptKind,e.isCompacting===!0,e.isWaitingForMemory===!0),D7()},"session-merge-status":e=>{VN(e.id,e.mergeStatus,e.reason),nF(e.id,e.mergeStatus),D7()},"session-worktree-blocked":e=>{Nd(`${e.session}: ${e.notice||`integration branch not found`}`)},"session-worktree-warning":e=>{Nd(`${e.session}: ${e.notice||`base branch warning`}`)},"session-worktree-ready":e=>{DN(e.id,e.base)},"session-diff":e=>{UN(e.id,{committed:e.committed,uncommitted:e.uncommitted,hasCommits:e.hasCommits})},"session-diff-error":e=>{KE(e.id,e.message)},"change-map":e=>qE(e.id,e.map),"branch-sync-status":e=>QE(e.id,e),"session-changed":e=>eD(e.id),"post-turn-result":e=>zN(e.id,e),"debug-state-response":e=>$_(e),"session-trace-response":e=>{aN(e)||aA(e)},"session-trace-changed":e=>{sN(e.id),oA(e)},"session-conversation":e=>{iN(e.id,e),D7()},"session-plan-changed":e=>{SN(e),D7()},"session-plan-draft":e=>{CN(e)},"session-plan-response":e=>{wN(e)},"session-docs-changed":e=>jh(e),"session-docs-snapshot":e=>Mh(e),"session-coherence-hooks":e=>{Jh(e.id,e.coherenceHooks),O7()},"session-coherence":e=>{Xh(e),O7()},"session-coherence-snapshot":e=>{Zh(e),O7()},"session-coherence-journal-response":e=>ng(e),"session-setup-response":e=>qQ(e),notify:e=>{Cp(e),ev(e.session)},"update-status":e=>{K7(e),J8(e)},"update-progress":e=>Y8(e.journal),"post-turn-leftovers":e=>J7(e),error:e=>{let t=X8(e),n=sA(e);oN(e);let r=TN(e);t||n||r||Nd(e.message)},"session-error":e=>{UE(e.id),!TN(e)&&qN(e.id,e.message)},"settings-updated":e=>{e.settings&&w9(e.settings),_m()},"agent-logins":e=>Wf(e.logins),"health-snapshot":e=>{e.stats&&ww(e.stats)},"radar-status":e=>zQ(e),"radar-investigation-activity":e=>BQ(e),"radar-investigation-finished":e=>HQ(e),"team-review-status":e=>EY(e),"github-prs":e=>Vn(e),"my-prs-status":lG,"benchmark-status":e=>bX(e),"benchmark-action-result":e=>xX(e),"my-pr-merge-result":e=>fG(e),"team-review-action-result":e=>AY(e),"open-team-review-session-result":e=>OY(e),"issues-status":e=>kZ(e),"issue-detail-result":e=>AZ(e),"open-issue-session-result":e=>jZ(e),"usage-sessions":e=>{I7(e.sessions),U4(e)},"usage-report":e=>{G4(e),K8()},"plan-limits":e=>W4(e),"usage-budget-alert":e=>Cp({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0}),"visions-findings":e=>hL(e),"visions-comments":e=>gL(e),"visions-hand":e=>_L(e),"visions-intent":e=>vL(e),"visions-fix":e=>mL(e),"visions-snapshot":e=>xL(e),"ingest-activity":e=>yL(e),"ingest-snapshot":e=>bL(e),"client-trust":e=>N9(e.trust),"shutting-down":()=>p7(`Shutting down...`,`Shutting down sessions...`),restarting:()=>p7(`Restarting...`,`Restarting server...`)};function B7(e){let t=z7[e.type];t&&t(e)}hd(e=>{B7(e),R7(e.type)});var V7,H7=null;function U7(e,t,n){e.onclick=()=>{let e=yr(n);e?e.then(()=>{t.textContent=`Copied`}).catch(()=>{t.textContent=`Copy failed`}):t.textContent=`Copy failed`}}var W7=Dp(Ml,Nl,`Update`).href;function G7(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function K7(e){let t=N(document,`#update-banner`,`div`),{mode:n,tone:r,text:i}=Uu(e),a=r===`security`;if(!e.updateAvailable&&!a){t.hidden=!0;return}let o=G7(e),s=o&&n===`restart`?`${o}:ready`:o;if(a&&i===H7||!a&&V7!==void 0&&s===V7||!a&&s&&gc()===s)return;t.classList.toggle(`update-banner-security`,a);let c=String(e.command??``);N(document,`#update-banner-text`,`span`).textContent=i,N(document,`#update-banner-cmd`,`code`).textContent=c;let l=N(document,`#update-banner-update`,`a`);l.href=W7,l.hidden=n!==`link`;let u=N(document,`#update-banner-restart`,`button`);u.hidden=n!==`restart`,u.onclick=M9;let d=N(document,`#update-banner-cmd`,`code`);d.hidden=n!==`command`;let f=N(document,`#update-banner-copy`,`button`);f.hidden=n!==`command`;let p=N(document,`#update-banner-copy-status`,`span`);p.hidden=n!==`command`,p.textContent=``;let m=N(document,`#update-banner-link`,`a`);m.hidden=!e.releaseUrl,m.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,U7(f,p,c),N(document,`#update-banner-dismiss`,`button`).onclick=()=>{t.hidden=!0,a?H7=i:(V7=s,_c(s))}}var q7=!1;function J7({repositories:e,command:t}){let n=N(document,`#post-turn-leftovers-banner`,`div`);if(e.length===0){n.hidden=!0;return}if(q7)return;let r=N(document,`#post-turn-leftovers-copy-status`,`span`);N(document,`#post-turn-leftovers-text`,`span`).textContent=$n(e.length),N(document,`#post-turn-leftovers-cmd`,`code`).textContent=t,r.textContent=``,n.hidden=!1,U7(N(document,`#post-turn-leftovers-copy`,`button`),r,t),N(document,`#post-turn-leftovers-dismiss`,`button`).onclick=()=>{q7=!0,n.hidden=!0}}var Y7=N(document,`#telemetry-banner`,`div`);function X7(){yc(!0),Y7.hidden=!0}function Z7(e){Y7.hidden=!k5(e,vc())}var Q7=N(document,`#telemetry-banner-settings`,`a`);Q7.href=Dp(`privacy`,`telemetry-enabled`,`Open settings`).href,Q7.addEventListener(`click`,X7),N(document,`#telemetry-banner-dismiss`,`button`).addEventListener(`click`,X7),N(document,`#btn-add-session-header`,`button`).addEventListener(`click`,Qf);var $7=N(document,`#btn-mute`,`button`);$Y($7);var e9=N(document,`#btn-streamer`,`button`);fh(e9),E5();var t9=N(document,`#power-menu`,`div`),n9=N(document,`#btn-power`,`button`);function r9(){n9.setAttribute(`aria-expanded`,t9.classList.contains(`open`)?`true`:`false`)}n9.addEventListener(`click`,e=>{e.stopPropagation(),t9.classList.toggle(`open`),r9()}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(t9.contains(e.target)||(t9.classList.remove(`open`),r9()))}),mr(document.querySelector(`.header`));function i9(e){e&&V8(e),!WB(`settings`)&&x9(`settings`,{section:e})}function a9(){Tp(location.hash)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}function o9(e){return e?(V8(e.sectionId,e.settingId),WB(`settings`)||x9(`settings`,{section:e.sectionId,setting:e.settingId,persist:!1}),!0):!1}function s9(e){return o9(H8(e))}var c9=`No plan is stored for this session yet.`;function l9(e){let t=lp(e);return t?!fN(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),BB()?(zB(t)||Nd(c9),!0):(x9(`focus`,{persist:!1}),iF(t)||Nd(c9),!0)):!1}function u9(e){return l9(e)?!0:s9(e)}function d9(e){e.newURL===location.href&&u9(location.hash)}document.addEventListener(`click`,e=>{if(!BB()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&u9(t.hash)&&e.preventDefault()}),vU(N(document,`#celebration-tray`,`div`),N(document,`#btn-celebrations`,`button`),N(document,`#celebration-tray-count`,`span`)),N(document,`#btn-help`,`button`).addEventListener(`click`,()=>{i9(`browser-shortcuts`)});var f9=$5({onRestart:M9,openTerminal:e=>{UB(e)||(x9(`focus`),rF(e))},openPlan:e=>{x9(`focus`),iF(e)},openReviews:()=>m9(`prs`)?(WB(`prs`)||x9(`prs`),!0):!1,setPhoneAttention:KB});W3(f9),zE({panel:document.getElementById(`review-sidebar`)});for(let e of f9)e.mount(e.el);function p9(e){return f9.find(t=>t.view===e)}function m9(e){return f9.some(t=>t.view===e&&!t.tab.hidden)}var h9=!0,g9=null;function _9(e){p9(e)?.attention?.acknowledge()}var v9=null;function y9(e){v9=K({type:`dashboard-telemetry`,event:`view_shown`,properties:{view:e}})?null:e}function b9(e){let t=p9(e);Z5(t,`shown`),t&&y9(e)}function x9(e,{section:t,setting:n,persist:r=!0}={}){if(!m9(e))return;let i=Ar();kr.dispatch(`setActiveView`,e),h9=r,r&&(g9=null),document.body.dataset.activeView=e,document.body.dataset.reviewSidebarHidden=String(p9(e)?.hasReviewSidebar!==!0),r&&$s(e);for(let t of f9){let n=t.view===e;t.el&&(t.el.hidden=!n),t.tab.setAttribute(`aria-selected`,String(n)),t.tab.tabIndex=n?0:-1}i!==e&&p9(i)?.deactivate?.(),p9(e)?.activate?.(),b9(e),i===`settings`&&e!==`settings`&&a9(),e===`settings`&&t&&V8(t,n??null),_9(e)}function S9(e,t){let{view:n}=e;e.tab.hidden=!t,GB(n,t),e.onAvailabilityChange?.(t),!BB()&&(!t&&Ar()===n&&x9(`focus`),t&&g9===n&&x9(n))}function C9(e){for(let{view:t,isAvailable:n}of Y5(f9,e))S9(t,n)}function w9(e){mN(e),U8(e),eL(e),C9(e),Z7(e),sh(e.streamerMode===!0),nN(e.conversationView===!0)}for(let e of f9)e.gate&&(S9(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>S9(e,t)));tA(()=>{m9(`trace`)&&(WB(`trace`)||x9(`trace`))});function T9(e,t){let n=f9.filter(e=>!e.tab.hidden),r=n[(n.findIndex(t=>t.view===e)+t+n.length)%n.length];return x9(r.view),r.tab}function E9(e){f9.some(e=>e.tab===document.activeElement)&&e.focus()}for(let e=0;e<f9.length;e++){let{view:t,tab:n}=f9[e];n.addEventListener(`click`,()=>x9(t)),n.addEventListener(`keydown`,e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),T9(Ar(),e.key===`ArrowRight`?1:-1).focus()))})}var D9=Qs(),O9=H8(location.hash),k9=lp(location.hash);if(O9&&x9(`settings`,{section:O9.sectionId,setting:O9.settingId,persist:!1}),k9&&x9(`focus`,{persist:!1}),!O9&&!k9){let e=m9(D9);e||(g9=D9),x9(e?D9:`focus`,{persist:e})}IB({panels:Cz(f9),onScreenShown:e=>{b9(e),e!==`settings`&&a9(),e===`settings`&&!Tp(location.hash)&&V8(),_9(e)},canGoBack:e=>e===`settings`&&M8(),onBack:e=>{e===`settings`&&N8()},headerControls:[N(document,`.header-title`,`h1`),N(document,`#status-indicator`,`div`),N(document,`#celebration-tray`,`div`),N(document,`#btn-add-session-header`,`button`),N(document,`#btn-help`,`button`),$7,N(document,`#streamer-badge`,`span`),e9,t9]}),A8(kB);function A9(e){if(e===`phone`){let e=NP();for(let e of f9)e.deactivate?.();let t=H8(location.hash);LB({sessionId:e??void 0,linkedScreenId:t?`settings`:void 0}),t&&V8(t.sectionId,t.settingId);return}let t=VB();RB();let n=Ar();x9(m9(n)?n:`focus`,{persist:h9}),t&&rF(t)}Ky()&&A9(`phone`),qy(A9),window.addEventListener(`hashchange`,d9);function j9({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){t9.classList.remove(`open`),r9();let o=pN();rf({title:t,message:o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i,confirmLabel:n,danger:r||o>0,onConfirm:()=>K({type:e})})}function M9(){j9({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}N(document,`#btn-restart`,`button`).addEventListener(`click`,M9);function N9(e){let t=Gn(`shutdown`,e);N(document,`#btn-shutdown`,`button`).hidden=!t,N(document,`#menu-divider-shutdown`,`div`).hidden=!t}N(document,`#btn-shutdown`,`button`).addEventListener(`click`,()=>{j9({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})});var P9=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`]);function F9(e,t){return e.value!==``&&P9.has(t.key)}function I9(e){let t=document.activeElement;return t instanceof HTMLElement?t.isContentEditable?!0:t instanceof HTMLTextAreaElement&&t.dataset.dashboardShortcuts===`allowed`?F9(t,e):(t.tagName===`INPUT`||t.tagName===`TEXTAREA`)&&!t.classList.contains(`xterm-helper-textarea`):!1}function L9({action:e,step:t}){switch(e){case`merge`:return iD(),!0;case`resolve-or-resync`:return oD()||lD(),!0;case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`next-attention`:return Ky()?!1:L5()?(V5(),!0):MP()?(YP(),!0):(cF(()=>x9(`focus`)),!0);case`rail-step`:return MP()?(oF(t),!0):!1;case`view-step`:return!Ky()&&(E9(T9(Ar(),t)),!0);case`session-nth`:return MP()?(aF(t),!0):!1;case`streamer-mode`:return dh(),!0}}document.addEventListener(`keydown`,e=>{if(e.repeat||I9(e))return;let t=Hp(e,Xp,{isTerminalFocused:document.activeElement?.classList.contains(`xterm-helper-textarea`)??!1});t&&L9(t)&&e.preventDefault()});var R9=Jn({mode:`trailing`,delayMs:150,run:()=>{K({type:`focus-change`,focused:document.hasFocus()})}});function z9(){R9.schedule()}function B9(){z9(),VC(I(jr()))}window.addEventListener(`focus`,B9),window.addEventListener(`blur`,B9),document.addEventListener(`visibilitychange`,B9);var V9=!1;async function H9(){if(!V9){V9=!0,AC();try{if(await Sd()===`ok`)return;for(let e of F.keys())MC(e)}finally{jC(),V9=!1}}}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&(NS(),H9())}),window.addEventListener(`online`,H9);var U9=Wo(K);window.addEventListener(`error`,e=>U9(e.error)),window.addEventListener(`unhandledrejection`,e=>U9(e.reason)),window.addEventListener(`pageshow`,e=>{e.persisted&&(NS(),H9())}),Cw(N(document,`#health-footer-mount`,`div`)),rb(hN),T7(),xd();