ryco-cli 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.cjs +2 -2
- package/dist/bin.mjs +2 -2
- package/dist/client/assets/{AccountSettings-Cey-16wq.js → AccountSettings-CkFq28pN.js} +1 -1
- package/dist/client/assets/AiFocusSettings-BI9AgQUi.js +1 -0
- package/dist/client/assets/BranchToolbar.logic-6LRTxcuo.js +1 -0
- package/dist/client/assets/ChatRightPanel-BSNsAFtv.js +27 -0
- package/dist/client/assets/{ChatThreadRouteView-tEo-zoCf.js → ChatThreadRouteView-Daox0F74.js} +1 -1
- package/dist/client/assets/CommandPaletteDialog-CIZnwgK9.js +1 -0
- package/dist/client/assets/{ConnectionsSettings-B0-Hkwof.js → ConnectionsSettings-DFBNmvfL.js} +2 -2
- package/dist/client/assets/DiagnosticsSettings-DhuLK993.js +2 -0
- package/dist/client/assets/{DraftChatThreadRouteView-BU2IGTR6.js → DraftChatThreadRouteView-BmVyawpM.js} +1 -1
- package/dist/client/assets/{HostedConnectionControls-Cux_sRCM.js → HostedConnectionControls-BvHq5iCa.js} +1 -1
- package/dist/client/assets/{HostedHubRoot-CyySCdJV.js → HostedHubRoot-CB5TRXg5.js} +1 -1
- package/dist/client/assets/{HostedNativeAuthorizationRoute-490iDXmk.js → HostedNativeAuthorizationRoute-Cb5WJuEG.js} +1 -1
- package/dist/client/assets/{HostedRelayTrustNotice-CcDOAwgS.js → HostedRelayTrustNotice-DFcgMZlL.js} +1 -1
- package/dist/client/assets/{IntegrationsSettingsPanel-BFTAvxtn.js → IntegrationsSettingsPanel-BIy-rKDv.js} +1 -1
- package/dist/client/assets/{KeybindingsSettings-VYgbhiZF.js → KeybindingsSettings-u3yB7Cob.js} +1 -1
- package/dist/client/assets/{McpServersSettings-DSDCjoTn.js → McpServersSettings-V32mLD4v.js} +2 -2
- package/dist/client/assets/{NewWorktreeDialog-C65Aifeb.js → NewWorktreeDialog-B64WGjQj.js} +2 -2
- package/dist/client/assets/{NoActiveThreadState-DehHNgAp.js → NoActiveThreadState-C0MwHtMx.js} +1 -1
- package/dist/client/assets/{NodeSecuritySettings-DW9GJ-kU.js → NodeSecuritySettings-CWlThhfV.js} +1 -1
- package/dist/client/assets/OpinionatedPluginsSettings-CVzfv5nP.js +1 -0
- package/dist/client/assets/{PhoneGetAppInterstitial-CbyVrtDn.js → PhoneGetAppInterstitial-CylfsDBD.js} +1 -1
- package/dist/client/assets/{PhoneHome-c0j_TBEC.js → PhoneHome-DBwwEeaI.js} +1 -1
- package/dist/client/assets/{PhoneSettingsSurface-5LFRIx_5.js → PhoneSettingsSurface-sDCNEVkR.js} +1 -1
- package/dist/client/assets/{ProjectFavicon-CeVJCQCy.js → ProjectFavicon-BjXJxNbQ.js} +1 -1
- package/dist/client/assets/{ProviderModelPicker-MFRYAv_3.js → ProviderModelPicker-BTFj53Qv.js} +1 -1
- package/dist/client/assets/{ProvidersSettingsPanel-FYBEqSr_.js → ProvidersSettingsPanel-IhzMeM1F.js} +1 -1
- package/dist/client/assets/RootAppShell-CG06ruyc.js +6 -0
- package/dist/client/assets/{SettingsDialog-CpwoqGS8.js → SettingsDialog-ByR9PwEc.js} +1 -1
- package/dist/client/assets/{SettingsPanels-COWRB29-.js → SettingsPanels-CwsCgdds.js} +3 -3
- package/dist/client/assets/{SourceControlSettings-DvBNelcO.js → SourceControlSettings-5w4N9XII.js} +1 -1
- package/dist/client/assets/{StatisticsPage-DxAKqvVX.js → StatisticsPage-jRyjIh52.js} +1 -1
- package/dist/client/assets/{StatisticsPanel-C0xGLlMA.js → StatisticsPanel-CV5eFeO_.js} +1 -1
- package/dist/client/assets/{ThreadStatusIndicators-CIOM98q2.js → ThreadStatusIndicators-C40TYVEC.js} +0 -0
- package/dist/client/assets/{ThreadTerminalDrawer-DRelLlEP.js → ThreadTerminalDrawer-flv5ZDel.js} +3 -3
- package/dist/client/assets/{ThreadWorkspacePanel-CktVSliZ.js → ThreadWorkspacePanel-B-cBAWFz.js} +6 -6
- package/dist/client/assets/{WorkItemsTab-CahU_t_S.js → WorkItemsTab-0DE4S4n0.js} +5 -5
- package/dist/client/assets/{branding-B7DcCXjn.js → branding-Ck4g7yv3.js} +1 -1
- package/dist/client/assets/{capabilities-B1FHGoov.js → capabilities-xa5Ll0KT.js} +1 -1
- package/dist/client/assets/{desktopUpdateAtoms-CPlZiFRm.js → desktopUpdateAtoms-hP0oc_If.js} +1 -1
- package/dist/client/assets/desktopWorkspace-hOxsGVFz.js +1 -0
- package/dist/client/assets/{device-CHdXzvhB.js → device-DIfzlguu.js} +1 -1
- package/dist/client/assets/{editorPreferences-B4GvqMiF.js → editorPreferences-B54y5_sx.js} +1 -1
- package/dist/client/assets/{index-Gre6bNC8.js → index-Dp3JRlOK.js} +1 -1
- package/dist/client/assets/main-B6n7O_N3.js +9 -0
- package/dist/client/assets/{projectPaths-D6fHIU1b.js → projectPaths-D8b4yLOe.js} +1 -1
- package/dist/client/assets/{providerIconUtils-DiDJeNtT.js → providerIconUtils-Cq0fezxt.js} +1 -1
- package/dist/client/assets/{runtime-CPM0EUhb.js → runtime-QZPKtH2P.js} +1 -1
- package/dist/client/assets/{session-logic-BalPN1Sc.js → session-logic-BuGYhZKZ.js} +1 -1
- package/dist/client/assets/{sidebarProjectFolders-bhNsO9Z_.js → sidebarProjectFolders-Dlo6McCj.js} +2 -2
- package/dist/client/assets/storeSelectors-_h41wnN2.js +1 -0
- package/dist/client/assets/{threadPinning-BLqwZebi.js → threadPinning-D2e9MEDr.js} +1 -1
- package/dist/client/assets/{threadPriorityRefreshRuntime-BoNAlBXK.js → threadPriorityRefreshRuntime-DbEFchoL.js} +1 -1
- package/dist/client/assets/types-_h41wnN2.js +1 -0
- package/dist/client/assets/{useAtlassian-CoHKzu-e.js → useAtlassian-Zb2Kkt0_.js} +0 -0
- package/dist/client/assets/useHandleNewThread-ByVfL71G.js +1 -0
- package/dist/client/assets/{usePhoneThreadActions-BIDUSWSI.js → usePhoneThreadActions-BhTVcLtf.js} +1 -1
- package/dist/client/assets/{useStatistics-B91973jb.js → useStatistics-Dbp94K5j.js} +1 -1
- package/dist/client/assets/{useThreadActions-BCH01d6u.js → useThreadActions-CPL4dO-X.js} +1 -1
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
- package/dist/client/assets/AiFocusSettings-CaHQXDaQ.js +0 -1
- package/dist/client/assets/BranchToolbar.logic-DILAA3Cz.js +0 -1
- package/dist/client/assets/ChatRightPanel-D-AL07IU.js +0 -27
- package/dist/client/assets/CommandPaletteDialog-s7yf5Y2S.js +0 -1
- package/dist/client/assets/DiagnosticsSettings-DX5LH9Bt.js +0 -2
- package/dist/client/assets/OpinionatedPluginsSettings-DbxPOokL.js +0 -1
- package/dist/client/assets/RootAppShell-5HrP6N8H.js +0 -6
- package/dist/client/assets/desktopWorkspace-DEZ30LlY.js +0 -1
- package/dist/client/assets/main-Dz0zookE.js +0 -9
- package/dist/client/assets/storeSelectors-Cf2WDMfx.js +0 -1
- package/dist/client/assets/types-Cf2WDMfx.js +0 -1
- package/dist/client/assets/useHandleNewThread-Bw460iXT.js +0 -1
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ThreadTerminalDrawer-BrP-ENHg.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e,t}from"./react-SIfiwpqq.js";import{t as n}from"./index-Gre6bNC8.js";import{t as r}from"./compiler-runtime-qmuS0Svy.js";import{_ as i,c as a,g as o,h as s,l as c,n as l,s as u,t as d,y as f}from"./env-Bcq9YR3B.js";import{Di as p,Ea as m,Ir as h,Jc as g,K as _,Lr as v,Mi as y,Ta as b,V as x,X as S,Z as C,Zc as w,c as T,ct as E,f as D,j as O,k,l as A,mi as j,ot as M,p as N,pi as P,q as F,st as I,t as ee,u as L,wa as R}from"./src-DmPIm3ie.js";import{$ as te,Bn as z,Et as ne,Fn as B,Ft as re,G as V,H,In as ie,It as ae,J as U,Jt as oe,K as se,Kt as ce,Lt as le,Ot as ue,Pn as de,Q as fe,Rn as pe,Rt as me,Sn as he,St as ge,U as _e,Un as ve,Ut as ye,V as be,Vn as xe,Vt as Se,W as Ce,X as we,Y as Te,Z as Ee,Zn as De,_t as Oe,at as ke,b as Ae,bn as je,ct as Me,d as Ne,et as Pe,f as Fe,g as Ie,gn as Le,gt as Re,h as ze,hn as Be,ht as Ve,it as He,lt as Ue,mn as We,mt as Ge,p as Ke,q as qe,st as Je,tt as Ye,u as Xe,v as Ze,wt as Qe,xt as $e,yn as et}from"./runtime-CPM0EUhb.js";import{Y as tt,a as nt,n as rt}from"./primary-CiDY2oUi.js";import{t as it}from"./useDebouncedValue-s0BC8Yyp.js";import{$ as at,A as ot,At as st,B as ct,C as lt,Ct as ut,D as dt,Dt as ft,E as pt,F as mt,Ft as ht,H as gt,I as _t,It as vt,L as yt,M as bt,N as xt,Nt as St,O as Ct,Ot as wt,P as Tt,Q as Et,R as Dt,S as Ot,St as kt,T as At,X as jt,Y as Mt,Z as Nt,_ as Pt,a as Ft,at as It,b as Lt,c as Rt,ct as zt,d as Bt,dt as Vt,et as Ht,f as Ut,ft as Wt,g as Gt,h as Kt,ht as qt,i as Jt,it as Yt,j as Xt,jt as Zt,k as Qt,kt as $t,l as en,lt as tn,m as nn,mt as rn,ot as an,p as on,q as sn,s as cn,st as ln,tt as un,u as dn,ut as fn,v as pn,w as mn,wt as hn,x as gn,xt as _n,y as vn,yt as yn,z as bn}from"./composerDraftStore-TYv9j3vY.js";import{Et as xn,Mn as Sn,N as Cn,Rn as wn,Sn as Tn,Tt as En,Xn as Dn,in as On,j as kn,on as An}from"./usePopupViewport-8F-J1h5f.js";import{c as jn,s as Mn}from"./useSwipeDismiss-D22_vuiH.js";import{C as Nn,F as Pn,c as Fn,l as In,s as Ln,u as Rn}from"./useHandleNewThread-Bw460iXT.js";import{_ as zn,a as Bn,c as Vn,d as Hn,g as Un,h as Wn,i as Gn,l as Kn,n as qn,o as Jn,r as Yn,s as Xn,u as Zn}from"./rightPanelRouteSearch-BS8CkNS6.js";import{t as Qn}from"./useNavigate-2tVq4iZ2.js";import{A as $n,B as er,F as tr,G as nr,H as rr,I as ir,K as ar,O as W,U as or,V as sr,W as cr,Y as lr,c as ur,g as dr,h as fr,j as pr,m as mr,q as hr,r as gr,t as _r,u as vr,v as yr}from"./ThreadStatusIndicators-CIOM98q2.js";import{n as br,t as xr}from"./visibilityPolling-BwzZdaSN.js";import{i as Sr,r as Cr}from"./perfInstrumentation-BT27w4tn.js";import{t as wr}from"./settingsDialogStore-LxRFC5hh.js";import{i as Tr}from"./uiStateStore-DzUrk2GS.js";import{i as Er,n as Dr,o as Or}from"./desktopWorkspace-DEZ30LlY.js";import{a as kr,i as Ar,l as jr,n as Mr,o as Nr,r as Pr,s as Fr,t as Ir}from"./BranchToolbar.logic-DILAA3Cz.js";import{d as Lr,f as Rr,l as zr,o as Br,r as Vr,s as Hr,t as Ur,u as Wr}from"./useRenderElement-DchFnsR8.js";import{n as Gr,t as Kr}from"./arrow-up-CTcWIlqV.js";import{t as qr}from"./arrow-left-Dtj9PfsA.js";import{t as Jr}from"./bot-DJp0cuhK.js";import{n as Yr,t as Xr}from"./loader-circle-CrtHFAvM.js";import{t as Zr}from"./chevron-down-B7C6FKzM.js";import{a as Qr,c as $r,i as ei,o as ti,r as ni,s as ri}from"./tabSwitchInstrumentation-CLDM7g1_.js";import{t as ii}from"./chevron-right-BWYGybX9.js";import{n as ai}from"./useFloatingRootContext-CLCaQEJk.js";import{A as oi,C as si,D as ci,E as li,I as ui,M as di,N as fi,O as pi,P as mi,S as hi,T as gi,a as _i,b as vi,f as yi,i as bi,j as xi,k as Si,o as Ci,p as wi,s as Ti,t as Ei,w as Di}from"./WorkItemsTab-CahU_t_S.js";import{t as Oi}from"./circle-alert-BWvs6IOn.js";import{a as ki,i as Ai,o as ji,r as Mi}from"./toast-C-0Ft2jD.js";import{t as Ni}from"./external-link-fbvzDWM7.js";import{n as Pi,t as Fi}from"./tokenModePresentation-lVM0-Wi3.js";import{t as Ii}from"./clock-nNA05brA.js";import{t as Li}from"./copy-UQjKGt7t.js";import{a as Ri,i as zi,n as Bi,o as Vi,r as Hi,t as Ui}from"./NewWorktreeDialog-C65Aifeb.js";import{t as Wi}from"./eye-CUSPj-gd.js";import{n as Gi,t as Ki}from"./layers-BYi0v17h.js";import{C as qi,S as Ji}from"./lib-DgOYoged.js";import{t as Yi}from"./folder-DtsQoI9_.js";import{t as Xi}from"./git-branch-BKr-Ij4u.js";import{t as Zi}from"./git-pull-request-DIYyPsg5.js";import{$t as Qi,C as $i,D as ea,E as ta,O as na,Qt as ra,S as ia,T as aa,_ as oa,a as sa,b as ca,c as la,d as ua,en as da,f as fa,i as pa,in as ma,k as ha,l as ga,n as _a,nn as va,o as ya,rn as ba,s as xa,t as Sa,tn as Ca,v as wa,w as Ta,x as Ea,y as Da}from"./device-CHdXzvhB.js";import{n as Oa,r as ka,v as Aa}from"./HostedConnectionControls-Cux_sRCM.js";import{t as ja}from"./loader-zHASMrUy.js";import{n as Ma,t as Na}from"./play-DYDxlTKo.js";import{t as Pa}from"./pencil-B69ERoVM.js";import{t as Fa}from"./plus-B2h-VEqh.js";import{t as Ia}from"./refresh-cw-DopCMrtR.js";import{t as La}from"./search-BGQsenCM.js";import{t as Ra}from"./shield-alert-DY9uVP5G.js";import{t as za}from"./shield-check-dQ-4cMKk.js";import{t as Ba}from"./sparkles-CAf3oJ5S.js";import{c as Va,i as Ha}from"./terminal-links-CzJomeox.js";import{a as Ua,i as Wa,n as Ga,r as Ka,t as qa}from"./ProviderModelPicker-MFRYAv_3.js";import{t as Ja}from"./terminal-C_CyIsDD.js";import{t as Ya}from"./trash-2-CM1zXPGb.js";import{t as Xa}from"./triangle-alert-RL_T3KLo.js";import{t as Za}from"./undo-2-x37tfI3V.js";import{t as Qa}from"./wrench-D0IetWa1.js";import{t as $a}from"./x-C1Cemsov.js";import{t as eo}from"./shallow-DWZCFNun.js";import{a as to,c as no,i as ro,l as io,n as ao,o as oo,t as G}from"./utils-CV2fJJxC.js";import{_ as so,a as co,c as lo,d as uo,h as fo,i as po,l as mo,m as ho,o as go,p as _o,s as vo,t as yo,u as bo}from"./session-logic-BalPN1Sc.js";import"./storeSelectors-Cf2WDMfx.js";import{i as xo,n as So,s as Co}from"./timestampFormat-8uPXS812.js";import{_ as wo,g as To,n as Eo,o as Do,p as Oo,r as ko,s as Ao,t as jo,v as Mo}from"./keybindings-BPE3eEAM.js";import{n as No,t as Po}from"./useButton-BmvYhoMC.js";import{i as Fo,n as Io,t as Lo}from"./tooltip-C_-9XEfA.js";import{t as Ro}from"./react-dom-x9LNwWQc.js";import{t as zo}from"./useValueChanged-EkWF0C3k.js";import{n as Bo}from"./clamp-CgH0Dl6R.js";import{i as Vo,n as Ho,r as Uo,s as Wo,u as Go}from"./useLabelableId-CB_9OReR.js";import{c as Ko,d as qo,p as Jo,s as Yo,t as Xo,u as Zo}from"./command-Cyn6yIEa.js";import{a as Qo,c as $o,d as es,f as ts,l as ns,o as rs,p as is,s as as,u as os}from"./providerIconUtils-DiDJeNtT.js";import{a as ss,d as cs,f as ls,l as us,n as ds,o as fs,r as ps,s as ms,t as hs,u as gs}from"./radio-group-BuuTEtdC.js";import{n as _s,t as vs}from"./switch-BZjA7VT9.js";import{t as ys}from"./input-BZz4eLRl.js";import{t as bs}from"./scroll-area-C0yF015F.js";import{a as xs,c as Ss,d as Cs,f as ws,i as Ts,r as Es,u as Ds}from"./Icons-BEtED8P8.js";import{t as Os}from"./ProjectFavicon-CeVJCQCy.js";import{t as K}from"./button-DG8WqjNn.js";import{t as ks}from"./useCopyToClipboard-BTpWxumf.js";import{t as As}from"./toastHelpers-CSQRKo4F.js";import{n as js}from"./composerHandleContext-BrQ6d8r9.js";import{t as Ms}from"./capabilities-B1FHGoov.js";import{a as Ns,n as Ps,t as Fs}from"./motion-thOBhZyM.js";import{o as Is,t as Ls}from"./sheet-BNfImQ-7.js";import{t as Rs}from"./usePresentationTier-B_SCFvN7.js";import{m as zs,p as Bs,t as Vs}from"./sidebar-CFGg5Tkr.js";import"./types-Cf2WDMfx.js";import{i as Hs,n as Us,r as Ws,t as Gs}from"./alert-DomE7dAt.js";import{a as Ks,c as qs,i as Js,o as Ys,r as Xs,s as Zs,t as Qs}from"./dialog-BNmFD6Nh.js";import{a as $s,c as ec,d as tc,f as nc,i as rc,l as ic,o as ac,p as oc,s as sc,u as cc}from"./menu-B6UEFcn0.js";import{t as lc}from"./spinner-ClQu8SdC.js";import{t as uc}from"./textarea-DHdmRD1r.js";import{a as dc,i as fc,n as pc,o as mc,r as hc,s as gc,t as _c}from"./alert-dialog-9Jyh0e8u.js";import{a as vc,i as yc,n as bc,o as xc,r as Sc,s as Cc,t as wc}from"./select-CZukJlTn.js";import{n as Tc,r as Ec,t as Dc}from"./popover-BuYzXGwl.js";import{i as Oc,n as kc,t as Ac}from"./editorPreferences-B4GvqMiF.js";import{t as jc}from"./badge-w43sx8eF.js";import{t as Mc}from"./label-DZf4lbNF.js";import"./providerInstances-vd2eZtHx.js";import{t as Nc}from"./RycoLetterMark-CZYntY8t.js";import{a as Pc,c as Fc,i as Ic,n as Lc,o as Rc,r as zc,s as Bc,t as Vc}from"./MobileSheet-BDvnUC5W.js";import{t as Hc}from"./GlassSurface-CDok2tTN.js";import{t as Uc}from"./useLongPress-OGlhYKlH.js";import{t as Wc}from"./useTheme-By1kfyiU.js";import{t as Gc}from"./toggle-DsnOFDbJ.js";import{n as Kc,t as qc}from"./NoActiveThreadState-DehHNgAp.js";import"./providerModels-vd2eZtHx.js";import{n as Jc,t as Yc}from"./pathEntry-BR9vr7Ug.js";import{n as Xc,r as Zc,t as Qc}from"./usePhoneThreadActions-BIDUSWSI.js";import{i as $c,n as el,o as tl,r as nl,s as rl,t as il}from"./liquidGlass-yFkZrRk5.js";import{r as al}from"./SettingsPanels.editor-lbLEbllb.js";import{t as ol}from"./AnimatedHeight-BC-qaTJY.js";import{n as sl,t as cl}from"./group-CzdKmc45.js";var q=e(t(),1),J=r(),Y=vt();function ll(e){if(typeof e!=`object`||!e||!(`file`in e))throw Error(`Expected a composer attachment.`);return e}var ul={encode:async e=>{let t=ll(e);return{id:t.id,mime:t.file.type||`application/octet-stream`,size:t.file.size,bytes:new Uint8Array(await t.file.arrayBuffer())}},decode:async e=>{if(`uri`in e)return e.uri;let t=new Uint8Array(e.bytes.byteLength);return t.set(e.bytes),new File([t],e.id,{type:e.mime})}},dl=Rr(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),fl=Rr(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),pl=Rr(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),ml=Rr(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),hl=Rr(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),gl=Rr(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),_l=Rr(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),vl=Rr(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),yl=Rr(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),bl=Rr(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),xl=Rr(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),Sl=Rr(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),Cl=Rr(`git-branch-plus`,[[`path`,{d:`M6 3v12`,key:`qpgusn`}],[`path`,{d:`M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`1d02ji`}],[`path`,{d:`M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`chk6ph`}],[`path`,{d:`M15 6a9 9 0 0 0-9 9`,key:`or332x`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),wl=Rr(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),Tl=Rr(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),El=Rr(`lock-open`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),Dl=Rr(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ol=Rr(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),kl=Rr(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Al=Rr(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),jl=Rr(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Ml=Rr(`zap`,[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]),Nl={message:0,"proposed-plan":1,work:2,"context-compaction":3,"context-handoff":4};function Pl(e,t){return e.entry.createdAt.localeCompare(t.entry.createdAt)||e.sourceRank-t.sourceRank||e.sourceIndex-t.sourceIndex||e.key.localeCompare(t.key)}function Fl(e,t){return e.source===t.source&&e.sourceRank===t.sourceRank}function Il(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>>1,a=e[i];a&&Pl(a,t)<=0?n=i+1:r=i}e.splice(n,0,t)}function Ll(e){for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(n&&r&&Pl(n,r)>0)return!1}return!0}function Rl(e,t){let n=`${t.sourceKind}:${t.entry.id}`,r=e.get(n),i=r?.source===t.source&&r.entry.createdAt===t.entry.createdAt&&r.entry.kind===t.entry.kind?r.entry:t.entry;return{key:n,sourceKind:t.sourceKind,sourceRank:Nl[t.sourceKind],sourceIndex:t.sourceIndex,source:t.source,entry:i}}function zl(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])?e:t}function Bl(){let e=new Map,t=[],n=[],r=`full`;return{update:i=>{let a=new Set(i.messages.map(e=>e.id)),o=new Map,s=new Map,c=new Map,l=(e,t)=>{o.set(e.key,e),t&&s.set(e.key,e)};i.messages.forEach((t,n)=>l(Rl(e,{sourceKind:`message`,sourceIndex:n,source:t,entry:{id:t.id,kind:`message`,createdAt:t.createdAt,message:t}}),!0)),i.proposedPlans.forEach((t,n)=>l(Rl(e,{sourceKind:`proposed-plan`,sourceIndex:n,source:t,entry:{id:t.id,kind:`proposed-plan`,createdAt:t.createdAt,proposedPlan:t}}),!0)),i.workEntries.forEach((t,n)=>l(Rl(e,{sourceKind:`work`,sourceIndex:n,source:t,entry:{id:t.id,kind:`work`,createdAt:t.createdAt,entry:t}}),!0)),i.contextCompactionEntries.forEach((t,n)=>l(Rl(e,{sourceKind:`context-compaction`,sourceIndex:n,source:t,entry:{id:t.id,kind:`context-compaction`,createdAt:t.createdAt,marker:t}}),!0)),i.contextHandoffEntries.forEach((t,n)=>{let r=Rl(e,{sourceKind:`context-handoff`,sourceIndex:n,source:t,entry:{id:t.id,kind:`context-handoff`,createdAt:t.createdAt,marker:t}});if(l(r,!a.has(t.targetMessageId)),a.has(t.targetMessageId)){let e=c.get(t.targetMessageId);e?e.push(r):c.set(t.targetMessageId,[r])}});let u=new Map;for(let e of s.values()){let t=`${e.sourceKind}:${e.entry.createdAt}`;u.set(t,(u.get(t)??0)+1)}let d=new Set(t.map(e=>e.key)),f=[...s.values()].filter(t=>{if(!d.has(t.key))return!0;let n=e.get(t.key);return!n||!Fl(n,t)||n.sourceIndex!==t.sourceIndex&&(u.get(`${t.sourceKind}:${t.entry.createdAt}`)??0)>1}),p=t.reduce((e,t)=>e+ +!s.has(t.key),0),m=f.length+p,h=Math.max(32,Math.ceil(s.size/3));if(t.length===0||m>h)t=[...s.values()].toSorted(Pl),r=`full`;else if(m===0)r=`reuse`;else{let e=new Set(f.map(e=>e.key)),n=t.filter(t=>s.has(t.key)&&!e.has(t.key));for(let e of f)Il(n,e);t=Ll(n)?n:[...s.values()].toSorted(Pl),r=Ll(n)?`incremental`:`full`}let g=[];for(let e of t){if(e.entry.kind===`message`){let t=c.get(e.entry.message.id);t&&g.push(...t.map(e=>e.entry))}g.push(e.entry)}return e=o,n=zl(n,g),n},inspect:()=>({mode:r,indexedEntries:e.size})}}function Vl(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=t=>bn(t,e)??_t,t[0]=e,t[1]=n),Jt(n)}function Hl(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=t=>{let n=bn(t,e);return n?{activeProvider:n.activeProvider,modelSelectionByProvider:n.modelSelectionByProvider}:mt},t[0]=e,t[1]=n),Jt(eo(n))}function Ul(e){let t=(0,J.c)(11),n;t[0]!==e.draftId||t[1]!==e.threadRef?(n=e.threadRef??e.draftId??Tt.make(``),t[0]=e.draftId,t[1]=e.threadRef,t[2]=n):n=t[2];let r=Hl(n),i;return t[3]!==r||t[4]!==e.projectModelSelection||t[5]!==e.providers||t[6]!==e.selectedInstanceId||t[7]!==e.selectedProvider||t[8]!==e.settings||t[9]!==e.threadModelSelection?(i=Dt({draft:r,providers:e.providers,selectedProvider:e.selectedProvider,selectedInstanceId:e.selectedInstanceId,threadModelSelection:e.threadModelSelection,projectModelSelection:e.projectModelSelection,settings:e.settings}),t[3]=r,t[4]=e.projectModelSelection,t[5]=e.providers,t[6]=e.selectedInstanceId,t[7]=e.selectedProvider,t[8]=e.settings,t[9]=e.threadModelSelection,t[10]=i):i=t[10],i}function Wl(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=t=>t.getDraftSession(e),t[0]=e,t[1]=n),Jt(n)}function Gl(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.getDraftThreadByRef(e):null,t[0]=e,t[1]=n),Jt(n)}function Kl(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.getDraftThreadByRef(e)!==null:!1,t[0]=e,t[1]=n),Jt(n)}function ql(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.hasDraftThreadsInEnvironment(e):!1,t[0]=e,t[1]=n),Jt(n)}function Jl(e,t){return e===t?null:t}function Yl(e){return e.open&&e.canMaximize&&e.maximizedThreadKey!==null&&e.maximizedThreadKey===e.threadKey}function Xl(e){return!e.open&&e.maximizedThreadKey!==null&&e.maximizedThreadKey===e.threadKey}function Zl(e){let t=(0,J.c)(17),{canMaximize:n,open:r,threadKey:i}=e,[a,o]=(0,q.useState)(null),s,c;t[0]!==a||t[1]!==r||t[2]!==i?(s=()=>{Xl({maximizedThreadKey:a,open:r,threadKey:i})&&o(null)},c=[a,r,i],t[0]=a,t[1]=r,t[2]=i,t[3]=s,t[4]=c):(s=t[3],c=t[4]),(0,q.useEffect)(s,c);let l;t[5]!==n||t[6]!==r||t[7]!==i?(l=()=>{!r||!n||o(e=>Jl(e,i))},t[5]=n,t[6]=r,t[7]=i,t[8]=l):l=t[8];let u=l,d;t[9]!==n||t[10]!==a||t[11]!==r||t[12]!==i?(d=Yl({canMaximize:n,maximizedThreadKey:a,open:r,threadKey:i}),t[9]=n,t[10]=a,t[11]=r,t[12]=i,t[13]=d):d=t[13];let f;return t[14]!==d||t[15]!==u?(f={maximized:d,toggleMaximized:u},t[14]=d,t[15]=u,t[16]=f):f=t[16],f}var Ql=new Map;function $l(e){let t=Ql.get(e);return t?{...t}:void 0}function eu(e,t){Ql.set(e,nu(t))}function tu(e,t){let{diff:n,diffTurnId:r,diffFilePath:i,preview:a,workspaceOpen:o,workspaceTab:s,workspaceAgentKey:c,...l}=e;return{...l,...t}}function nu(e){return iu({diff:e.diff,diffTurnId:e.diffTurnId,diffFilePath:e.diffFilePath,preview:e.preview,workspaceOpen:e.workspaceOpen,workspaceTab:e.workspaceTab,workspaceAgentKey:e.workspaceAgentKey})}function ru(e,t){let n=Ql.get(e);n&&Ql.set(t,{...n})}function iu(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function au(e){let t=(0,q.useRef)(null),n=(0,q.useRef)(null),r=t.current!==e.threadKey;if(r){let t=e.threadKey?$l(e.threadKey):void 0;n.current=e.threadKey&&t&&qn(t)?{threadKey:e.threadKey,search:t}:null}else qn(e.search)&&(n.current=null);let i=n.current?.threadKey===e.threadKey&&!qn(e.search)?n.current.search:void 0,a=r&&i!==void 0,o=i?tu(e.search,i):e.search;return(0,q.useLayoutEffect)(()=>{if(t.current=e.threadKey,e.threadKey){if(a){e.replaceSearch(o);return}i||eu(e.threadKey,e.search)}},[e,i,o,a]),o}var ou=`(max-width: 980px)`,su=`w-[min(42vw,28rem)] min-w-80 max-w-[28rem] p-0 phone:w-[min(88vw,24rem)] phone:min-w-0 wco:mt-[env(titlebar-area-height)] wco:h-[calc(100%-env(titlebar-area-height))] wco:max-h-[calc(100%-env(titlebar-area-height))]`;function cu(e,t=50){let n=e.trim();return n.length<=t?n:`${n.slice(0,t)}...`}function lu(e){let t=typeof e.createdAt==`object`&&e.createdAt!==null&&`toJSON`in e.createdAt?e.createdAt.toJSON():String(e.createdAt);return`- ${e.author} (${t}): ${e.body}`}function uu(e){let t=[];if(t.push(`### Issue #${e.number}: ${e.title}`),t.push(`URL: ${e.url}`),t.push(`State: ${e.state}`),e.author&&t.push(`Author: ${e.author}`),e.labels&&e.labels.length>0&&t.push(`Labels: ${e.labels.join(`, `)}`),t.push(``),t.push(e.body),e.comments.length>0){t.push(``),t.push(`Recent comments:`);for(let n of e.comments)t.push(lu(n))}return e.truncated&&(t.push(``),t.push(`> Note: this context was truncated by the server.`)),t.join(`
|
|
3
|
-
`)}function du(e){let t=[];if(t.push(`### Change Request #${e.number}: ${e.title}`),t.push(`URL: ${e.url}`),t.push(`State: ${e.state}`),t.push(`Base: ${e.baseRefName}`),t.push(`Head: ${e.headRefName}`),t.push(``),t.push(e.body),e.comments.length>0){t.push(``),t.push(`Recent comments:`);for(let n of e.comments)t.push(lu(n))}return e.truncated&&(t.push(``),t.push(`> Note: this context was truncated by the server.`)),t.join(`
|
|
4
|
-
`)}function fu(e){return e.length===0?``:`## Attached source-control context\n\n${e.map(e=>e.kind===`issue`?uu(e.detail):du(e.detail)).join(`
|
|
5
|
-
|
|
6
|
-
`)}`}function pu(e){let t=e.match(/^\s{0,3}#{1,6}\s+(.+)$/m)?.[1]?.trim();return t&&t.length>0?t:null}function mu(e){let t=e.trimEnd().split(/\r?\n/),n=t[0]&&/^\s{0,3}#{1,6}\s+/.test(t[0])?t.slice(1):[...t];for(;n[0]?.trim().length===0;)n.shift();if((n[0]?.match(/^\s{0,3}#{1,6}\s+(.+)$/))?.[1]?.trim().toLowerCase()===`summary`)for(n.shift();n[0]?.trim().length===0;)n.shift();return n.join(`
|
|
7
|
-
`)}function hu(e,t){let n=t?.maxLines??8,r=mu(e).trimEnd().split(/\r?\n/).map(e=>e.trimEnd()),i=[],a=0,o=!1;for(let e of r){let t=e.trim().length>0;if(t&&a>=n){o=!0;break}i.push(e),t&&(a+=1)}for(;i.length>0&&i.at(-1)?.trim().length===0;)i.pop();return i.length===0?pu(e)??`Plan preview unavailable.`:(o&&i.push(``,`...`),i.join(`
|
|
8
|
-
`))}function gu(e){let t=e.toLowerCase().replace(/[`'".,!?()[\]{}]+/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t.length>0?t:`plan`}function _u(e){return`PLEASE IMPLEMENT THIS PLAN:\n${e.trim()}`}function vu(e){let t=e.draftText.trim();return t.length>0?{text:t,interactionMode:`plan`}:{text:_u(e.planMarkdown),interactionMode:`default`}}function yu(e){let t=pu(e);return t?`Implement ${t}`:`Implement plan`}function bu(e){return`${gu(pu(e)??`plan`)}.md`}function xu(e){return`${e.trimEnd()}\n`}function Su(e,t){let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),window.setTimeout(()=>{URL.revokeObjectURL(r)},0)}function Cu(e,t){let n=(0,J.c)(4),[r,i]=(0,q.useState)(e),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(e){i(!0);return}if(t<=0){i(!1);return}let n=window.setTimeout(()=>i(!1),t);return()=>window.clearTimeout(n)},o=[t,e],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,q.useEffect)(a,o),r}function wu(e){let t=(0,J.c)(20),{environmentId:n,cwd:r,query:i}=e,a=se({environmentId:n,cwd:r,query:i}),o,s;t[0]!==r||t[1]!==n||t[2]!==i?(o=()=>Pe({environmentId:n,cwd:r,query:i}),s=[n,r,i],t[0]=r,t[1]=n,t[2]=i,t[3]=o,t[4]=s):(o=t[3],s=t[4]),(0,q.useEffect)(o,s);let c=De(V(a)),l;t[5]===c.pages?l=t[6]:(l=Ce(c.pages),t[5]=c.pages,t[6]=l);let u=l,d=c.pages[c.pages.length-1],f=d?d.nextCursor!==null:!1,p=c.pages[0]?.totalCount??0,m;t[7]===a?m=t[8]:(m=()=>_e(a),t[7]=a,t[8]=m);let h=m,g;t[9]===a?g=t[10]:(g=()=>te(a),t[9]=a,t[10]=g);let _=g,v;return t[11]!==h||t[12]!==f||t[13]!==_||t[14]!==u||t[15]!==c.error||t[16]!==c.isFetchingNextPage||t[17]!==c.isPending||t[18]!==p?(v={refs:u,totalCount:p,hasNextPage:f,isFetchingNextPage:c.isFetchingNextPage,isPending:c.isPending,error:c.error,fetchNextPage:h,refresh:_},t[11]=h,t[12]=f,t[13]=_,t[14]=u,t[15]=c.error,t[16]=c.isFetchingNextPage,t[17]=c.isPending,t[18]=p,t[19]=v):v=t[19],v}function Tu(e){let t=(0,J.c)(5),{environmentId:n,cwd:r,reference:i}=e,a=Te({environmentId:n,cwd:r,reference:i}),o,s;return t[0]!==r||t[1]!==n||t[2]!==i?(o=()=>Ye({environmentId:n,cwd:r,reference:i}),s=[n,r,i],t[0]=r,t[1]=n,t[2]=i,t[3]=o,t[4]=s):(o=t[3],s=t[4]),(0,q.useEffect)(o,s),De(U(a))}function Eu(e){let t=(0,J.c)(5),{environmentId:n,cwd:r,reference:i}=e,a,o;if(t[0]!==r||t[1]!==n||t[2]!==i){let e=Te({environmentId:n,cwd:r,reference:i});a=De,o=U(e),t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o}else a=t[3],o=t[4];return a(o).data}function Du(e){let[t,n]=(0,q.useState)(!1),[r,i]=(0,q.useState)(null),a=(0,q.useRef)(e);a.current=e;let o=(0,q.useRef)(!0);(0,q.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let s=(0,q.useCallback)(async e=>{let t=a.current,r=t.trackingKey??null,s=t.invalidateOn??`success`,c=t.invalidates??[];n(!0),i(null),r!==null&&be(r);try{let r=await t.mutationFn(e);return c.length>0&&Ee(c),o.current&&n(!1),r}catch(e){let t=e instanceof Error?e:Error(`Mutation failed.`);throw s===`settled`&&c.length>0&&Ee(c),o.current&&(n(!1),i(t)),t}finally{r!==null&&H(r)}},[]);return{mutate:(0,q.useCallback)(e=>{s(e).catch(()=>void 0)},[s]),mutateAsync:s,isPending:t,error:r,reset:(0,q.useCallback)(()=>{n(!1),i(null)},[])}}function Ou(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n=qe(e),t[0]=e,t[1]=n),De(n)>0}function ku(e,t,n){return`git-mutation:${e}:${t??``}:${n??``}`}var Au=/^https:\/\/github\.com\/[^/\s]+\/[^/\s]+\/pull\/(\d+)(?:[/?#].*)?$/i,ju=/^https:\/\/[^/\s]*gitlab[^/\s]*\/.+\/-\/merge_requests\/(\d+)(?:[/?#].*)?$/i,Mu=/^https:\/\/[^/\s]+\/[^/\s]+\/[^/\s]+\/pulls\/(\d+)(?:[/?#].*)?$/i,Nu=/^https:\/\/(?:dev\.azure\.com\/[^/\s]+\/[^/\s]+|[^/\s]+\.visualstudio\.com\/[^/\s]+)\/_git\/[^/\s]+\/pullrequest\/(\d+)(?:[/?#].*)?$/i,Pu=/^#?(\d+)$/,Fu=/^gh\s+pr\s+checkout\s+(.+)$/i,Iu=/^glab\s+mr\s+checkout\s+(.+)$/i,Lu=/^az\s+repos\s+pr\s+checkout\s+(.+)$/i;function Ru(e){let t=e.trim().split(/\s+/).filter(Boolean);for(let[e,n]of t.entries()){if(n===`--id`||n===`-i`)return t[e+1]??null;if(n.startsWith(`--id=`))return n.slice(5)||null}return t.find(e=>!e.startsWith(`-`))??null}function zu(e){let t=e.trim();if(t.length===0)return null;let n=Fu.exec(t),r=Iu.exec(t),i=Lu.exec(t),a=n?.[1]?.trim()??r?.[1]?.trim()??(i?.[1]?Ru(i[1]):null)??t;if(a.length===0)return null;if((Au.exec(a)??ju.exec(a)??Mu.exec(a)??Nu.exec(a))?.[1])return a;let o=Pu.exec(a);return o?.[1]?o[1]:null}function Bu(e){return e instanceof Error?e.message:`An error occurred.`}function Vu(e){let{activeWorktreePath:t,effectiveEnvMode:n,resolvedActiveBranch:r}=e;return r?n===`worktree`&&!t&&!e.omitBasePrefix?`From ${r}`:r:`Select ref`}function Hu({className:e,appearance:t=`default`,environmentId:n,threadId:r,draftId:a,envLocked:s,activeThreadBranchOverride:c,onActiveThreadBranchOverrideChange:l,onCheckoutPullRequestRequest:d,onComposerFocusRequest:f,omitBasePrefix:p=!1}){let m=(0,q.useMemo)(()=>i(n,r),[n,r]),h=(0,q.useMemo)(()=>ue(m),[m]),g=oe(h),_=g?.session??null,v=oe(e=>e.setThreadBranch),y=Jt(e=>a?e.getDraftSession(a):e.getDraftThreadByRef(m)),b=Jt(e=>e.setDraftThreadContext),x=g?o(g.environmentId,g.projectId):y?o(y.environmentId,y.projectId):null,C=(0,q.useMemo)(()=>ne(x),[x]),w=oe(C),T=g?.id??(y?r:void 0),E=c===void 0?g?.branch??y?.branch??null:c,D=g?.worktreePath??y?.worktreePath??null,O=w?.cwd??null,k=D??O,A=g!==void 0,j=kr({activeWorktreePath:D,hasServerThread:A,draftThreadEnvMode:y?.envMode}),M=(0,q.useCallback)((e,t)=>{if(!T||!w)return;let r=Be(n);if(_&&t!==D&&r&&r.orchestration.dispatchCommand({type:`thread.session.stop`,commandId:ro(),threadId:T,createdAt:new Date().toISOString()}).catch(()=>void 0),r&&A){let n=new Date().toISOString();r.orchestration.dispatchCommand({type:`thread.meta.update`,commandId:ro(),threadId:T,branch:e,worktreePath:t}),e&&g.worktreeId&&r.orchestration.dispatchCommand({type:`worktree.meta.update`,commandId:ro(),worktreeId:S.make(g.worktreeId),branch:e,changedAt:n})}if(A){l?.(e),v(m,e,t);return}let i=Ar({nextWorktreePath:t,currentWorktreePath:D,effectiveEnvMode:j});b(a??m,{branch:e,worktreePath:t,envMode:i,projectRef:o(n,w.id)})},[T,w,_,g,D,A,l,v,b,a,m,n,j]),[N,P]=(0,q.useState)(!1),[F,I]=(0,q.useState)(``),ee=(0,q.useDeferredValue)(F),L=ie({environmentId:n,cwd:k}),R=F.trim(),te=ee.trim();(0,q.useEffect)(()=>{k&&fe({environmentId:n,cwd:k,query:``})},[k,n]);let{refs:z,totalCount:B,fetchNextPage:re,hasNextPage:V,isFetchingNextPage:H,isPending:ae}=wu({environmentId:n,cwd:k,query:te}),U=L.data?.refName??z.find(e=>e.current)?.name??null,se=(0,q.useMemo)(()=>vr(L.data?.sourceControlProvider),[L.data?.sourceControlProvider]),ce=se.Icon,le=L.data?.sourceControlProvider?.kind??null,de=le!==null&&le!==`unknown`,pe=de?ce:Cs,me=(0,q.useMemo)(()=>Ir(w?.repositoryIdentity),[w?.repositoryIdentity]),ge=(0,q.useCallback)(()=>{if(!me)return;let e=he();e&&e.shell.openExternal(me).catch(()=>void 0)},[me]),_e=Pr({envMode:j,activeWorktreePath:D,activeThreadBranch:E,currentGitBranch:U}),ve=(0,q.useMemo)(()=>z.map(e=>e.name),[z]),ye=(0,q.useMemo)(()=>new Map(z.map(e=>[e.name,e])),[z]),be=te.toLowerCase(),xe=zu(R),Se=j===`worktree`&&!s&&!D,Ce=xe&&d?`__checkout_pull_request__:${xe}`:null,Te=!Se&&R.length>0,De=ye.has(R),Oe=Te?`__create_new_branch__:${R}`:null,ke=$n({environmentId:Se?n:null,cwd:Se?k:null,state:`open`,limit:50}),Ae=(0,q.useMemo)(()=>{let e=new Map;if(!Se)return e;for(let t of ke.data??[])ye.has(t.headRefName)||e.set(`__pull_request_base__:${t.number}`,t);return e},[ye,Se,ke.data]),je=(0,q.useMemo)(()=>{let e=[...ve];return Oe&&!De&&e.push(Oe),e.push(...Ae.keys()),Ce&&e.unshift(Ce),e},[ve,Ce,Oe,De,Ae]),Me=(0,q.useMemo)(()=>new Map(Array.from(Ae,([e,t])=>[e,`#${t.number} ${t.title} ${t.headRefName}`])),[Ae]),Ne=(0,q.useMemo)(()=>be.length===0?je:je.filter(e=>Fr({itemValue:e,normalizedQuery:be,createBranchItemValue:Oe,checkoutPullRequestItemValue:Ce,searchTextByItemValue:Me})),[je,Ce,Oe,be,Me]),[Pe,Fe]=(0,q.useOptimistic)(_e,(e,t)=>t),[Ie,Le]=(0,q.useTransition)(),Re=Ne.length>40,ze=ae?`Loading refs...`:H?`Loading more refs...`:V?`Showing ${z.length} of ${B} refs`:null,Ve=e=>{Le(async()=>{await e().catch(()=>void 0),Ee([we(k)])})},He=e=>{let t=Be(n);if(!t||!k||!O||Ie)return;if(Se){M(e.name,null),P(!1),f?.();return}let r=Mr({activeProjectCwd:O,activeWorktreePath:D,refName:e});if(r.reuseExistingWorktree){M(e.name,r.nextWorktreePath),P(!1),f?.();return}let i=e.isRemote?u(e.name):e.name;P(!1),f?.(),Ve(async()=>{let n=Pe;Fe(i);try{let n=await t.vcs.switchRef({cwd:r.checkoutCwd,refName:e.name}),a=e.isRemote?n.refName??i:i;Fe(a),M(a,r.nextWorktreePath)}catch(e){Fe(n),Ai.add(As({type:`error`,title:`Failed to switch ref.`,description:Bu(e)}))}})},Ue=e=>{let t=e.trim(),r=Be(n);!r||!k||!t||Ie||(P(!1),f?.(),Ve(async()=>{let e=Pe;Fe(t);try{let e=await r.vcs.createRef({cwd:k,refName:t,switchRef:!0});Fe(e.refName),M(e.refName,D)}catch(t){Fe(e),Ai.add(As({type:`error`,title:`Failed to create and switch ref.`,description:Bu(t)}))}}))};(0,q.useEffect)(()=>{j!==`worktree`||D||E||!U||M(U,null)},[E,D,U,j,M]);let We=(0,q.useCallback)(e=>{if(P(e),!e){I(``);return}Ee([we(k)])},[k]),Ge=(0,q.useRef)(null),Ke=(0,q.useCallback)(()=>{if(!N||!V||H)return;let e=Ge.current;e&&(e.scrollHeight-e.scrollTop-e.clientHeight>96||re())},[re,V,N,H]),qe=(0,q.useRef)(null),Je=(0,q.useCallback)(e=>{Ge.current=e?.parentElement??null},[]);(0,q.useEffect)(()=>{N&&(Re?qe.current?.scrollToOffset?.({offset:0,animated:!1}):Ge.current?.scrollTo({top:0}))},[te,N,Re]),(0,q.useEffect)(()=>{let e=Ge.current;if(!e||!N)return;let t=()=>{Ke()};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{e.removeEventListener(`scroll`,t)}},[N,Ke]),(0,q.useEffect)(()=>{Re||Ke()},[z.length,Ke,Re]);let Ye=Vu({activeWorktreePath:D,effectiveEnvMode:j,resolvedActiveBranch:Pe,omitBasePrefix:p});function Xe(e,t){if(Ce&&e===Ce)return(0,Y.jsx)($o,{hideIndicator:!0,index:t,value:e,onClick:()=>{!xe||!d||(P(!1),I(``),f?.(),d(xe))},children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-1`,children:[(0,Y.jsx)(ce,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start`,children:[(0,Y.jsxs)(`span`,{className:`truncate font-medium`,children:[`Checkout `,se.terminology.singular]}),(0,Y.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:xe})]})]})},e);if(Oe&&e===Oe)return(0,Y.jsx)($o,{hideIndicator:!0,index:t,value:e,onClick:()=>Ue(R),children:(0,Y.jsxs)(`span`,{className:`truncate`,children:[`Create new ref "`,R,`"`]})},e);let n=Ae.get(e);if(n)return(0,Y.jsx)($o,{hideIndicator:!0,index:t,value:e,onClick:()=>{M(n.headRefName,null),P(!1),I(``),f?.()},children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-1`,children:[(0,Y.jsx)(ce,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start`,children:[(0,Y.jsxs)(`span`,{className:`truncate`,children:[`#`,n.number,` `,n.title]}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-muted-foreground text-[10px]`,children:n.headRefName})]})]})},e);let r=ye.get(e);if(!r)return null;let i=r.worktreePath&&O&&r.worktreePath!==O,a=r.current?`current`:i?`worktree`:r.isRemote?`remote`:r.isDefault?`default`:null;return(0,Y.jsx)($o,{hideIndicator:!0,index:t,value:e,onClick:()=>He(r),children:(0,Y.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e}),a&&(0,Y.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/45`,children:a})]})},e)}return(0,Y.jsxs)(Qo,{items:je,filteredItems:Ne,autoHighlight:!0,virtualized:Re,onItemHighlighted:(e,t)=>{!N||t.index<0||t.reason!==`keyboard`||qe.current?.scrollIndexIntoView?.({index:t.index,animated:!1})},onOpenChange:We,open:N,value:Pe,children:[t===`pill`||t===`panelRow`?(0,Y.jsxs)(`div`,{"data-appearance":t,className:G(`min-w-0 items-center overflow-hidden`,t===`pill`?`inline-flex h-[30px] rounded-[9px] border border-input bg-popover shadow-xs`:`flex h-9 w-full bg-transparent`,e),children:[me?(0,Y.jsx)(`button`,{type:`button`,onClick:ge,title:de?`Open on ${se.providerName}`:`Open repository remote`,"aria-label":`Open repository remote`,className:G(`grid h-full shrink-0 place-items-center text-foreground/80 transition-colors hover:bg-accent`,t===`pill`?`pr-1 pl-2.5`:`w-[37px]`),children:t===`pill`?(0,Y.jsx)(pe,{className:`size-3.5`}):(0,Y.jsx)(`span`,{className:`grid size-5 place-items-center rounded-md bg-secondary text-muted-foreground [&_svg]:size-3`,children:(0,Y.jsx)(pe,{})})}):(0,Y.jsx)(`span`,{className:G(`grid h-full shrink-0 place-items-center text-foreground/80`,t===`pill`?`pr-1 pl-2.5`:`w-[37px]`),children:t===`pill`?(0,Y.jsx)(pe,{className:`size-3.5`}):(0,Y.jsx)(`span`,{className:`grid size-5 place-items-center rounded-md bg-secondary text-muted-foreground [&_svg]:size-3`,children:(0,Y.jsx)(pe,{})})}),(0,Y.jsxs)(is,{render:(0,Y.jsx)(K,{variant:`ghost`,size:`sm`}),className:G(`h-full min-w-0 gap-1.5 rounded-none border-0 bg-transparent text-foreground shadow-none before:shadow-none`,t===`pill`?`pr-2.5 pl-1 text-[13px] font-medium`:`flex-1 justify-start pr-2.5 pl-0 text-[11.5px] font-semibold hover:bg-accent`),disabled:ae&&z.length===0||Ie,children:[(0,Y.jsx)(`span`,{className:G(`min-w-0 truncate font-mono`,t===`pill`?`max-w-[170px]`:`flex-1 text-left`),children:Ye}),Pe===U&&((L.data?.aheadCount??0)>0||(L.data?.behindCount??0)>0)?(0,Y.jsxs)(`span`,{className:G(`flex shrink-0 items-center gap-1 font-mono font-semibold text-muted-foreground tabular-nums`,t===`pill`?`text-[11px]`:`text-[10px]`),children:[(L.data?.aheadCount??0)>0?(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Y.jsx)(Kr,{className:`size-[11px]`}),L.data?.aheadCount]}):null,(L.data?.behindCount??0)>0?(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Y.jsx)(Gr,{className:`size-[11px]`}),L.data?.behindCount]}):null]}):null,(0,Y.jsx)(Zr,{className:G(`shrink-0 text-muted-foreground`,t===`pill`?`size-3.5`:`size-3`)})]})]}):(0,Y.jsxs)(is,{render:(0,Y.jsx)(K,{variant:`ghost`,size:`xs`}),className:G(`min-w-0 text-muted-foreground/70 hover:text-foreground/80`,e),disabled:ae&&z.length===0||Ie,children:[(0,Y.jsx)(`span`,{className:`min-w-0 max-w-[240px] truncate`,children:Ye}),(0,Y.jsx)(Zr,{className:`shrink-0`})]}),(0,Y.jsxs)(es,{align:`end`,side:`top`,className:`w-80 data-ending-style:translate-y-1 data-starting-style:translate-y-1`,children:[(0,Y.jsx)(`div`,{className:`border-b p-1`,children:(0,Y.jsx)(as,{className:`[&_input]:font-sans rounded-md`,inputClassName:`ring-0`,placeholder:`Search refs...`,showTrigger:!1,size:`sm`,value:F,onChange:e=>I(e.target.value)})}),(0,Y.jsx)(rs,{children:`No refs found.`}),Re?(0,Y.jsx)(os,{children:(0,Y.jsx)(Bi,{ref:qe,data:Ne,keyExtractor:e=>e,renderItem:({item:e,index:t})=>Xe(e,t),estimatedItemSize:28,drawDistance:336,onEndReached:()=>{V&&!H&&re()},style:{maxHeight:`14rem`}})}):(0,Y.jsx)(ns,{ref:Je,className:`max-h-56`,children:Ne.map((e,t)=>Xe(e,t))}),ze?(0,Y.jsx)(ts,{children:ze}):null]})]})}var Uu=(0,q.memo)(function(e){let t=(0,J.c)(28),{envLocked:n,environmentId:r,availableEnvironments:i,onEnvironmentChange:a}=e,o;t[0]!==i||t[1]!==r?(o=i.find(e=>e.environmentId===r)??null,t[0]=i,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===i?c=t[4]:(c=i.map(Wu),t[3]=i,t[4]=c);let l=c;if(n){let e;t[5]===s?.isPrimary?e=t[6]:(e=s?.isPrimary?(0,Y.jsx)(Ol,{className:`size-3`}):(0,Y.jsx)(dr,{className:`size-3`}),t[5]=s?.isPrimary,t[6]=e);let n=s?.label??`Run on`,r;return t[7]!==e||t[8]!==n?(r=(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 border border-transparent px-[calc(--spacing(3)-1px)] text-sm font-medium text-muted-foreground/70 sm:text-xs`,children:[e,n]}),t[7]=e,t[8]=n,t[9]=r):r=t[9],r}let u;t[10]===a?u=t[11]:(u=e=>a(e),t[10]=a,t[11]=u);let d;t[12]===s?.isPrimary?d=t[13]:(d=s?.isPrimary?(0,Y.jsx)(Ol,{className:`size-3`}):(0,Y.jsx)(dr,{className:`size-3`}),t[12]=s?.isPrimary,t[13]=d);let f;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Y.jsx)(Cc,{}),t[14]=f):f=t[14];let p;t[15]===d?p=t[16]:(p=(0,Y.jsxs)(xc,{variant:`ghost`,size:`xs`,className:`font-medium`,"aria-label":`Run on`,children:[d,f]}),t[15]=d,t[16]=p);let m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Y.jsx)(Sc,{children:`Run on`}),t[17]=m):m=t[17];let h;t[18]===i?h=t[19]:(h=i.map(Gu),t[18]=i,t[19]=h);let g;t[20]===h?g=t[21]:(g=(0,Y.jsx)(vc,{children:(0,Y.jsxs)(bc,{children:[m,h]})}),t[20]=h,t[21]=g);let _;return t[22]!==r||t[23]!==l||t[24]!==u||t[25]!==p||t[26]!==g?(_=(0,Y.jsxs)(wc,{modal:!1,value:r,onValueChange:u,items:l,children:[p,g]}),t[22]=r,t[23]=l,t[24]=u,t[25]=p,t[26]=g,t[27]=_):_=t[27],_});function Wu(e){return{value:e.environmentId,label:e.label}}function Gu(e){return(0,Y.jsx)(yc,{value:e.environmentId,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e.isPrimary?(0,Y.jsx)(Ol,{className:`size-3`}):(0,Y.jsx)(dr,{className:`size-3`}),e.label]})},e.environmentId)}var Ku=[{value:`local`,label:`Local`},{value:`worktree`,label:`New worktree`}],qu=(0,q.memo)(function(e){let t=(0,J.c)(12),{value:n,onChange:r}=e,i;t[0]===r?i=t[1]:(i=e=>r(e),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=n===`worktree`?(0,Y.jsx)(Cl,{className:`size-3`}):(0,Y.jsx)(Ol,{className:`size-3`}),t[2]=n,t[3]=a);let o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Y.jsx)(Cc,{}),t[4]=o):o=t[4];let s;t[5]===a?s=t[6]:(s=(0,Y.jsxs)(xc,{variant:`ghost`,size:`xs`,className:`font-medium`,"aria-label":`Run in`,children:[a,o]}),t[5]=a,t[6]=s);let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Y.jsx)(vc,{children:(0,Y.jsxs)(bc,{children:[(0,Y.jsx)(Sc,{children:`Run in`}),Ku.map(Ju)]})}),t[7]=c):c=t[7];let l;return t[8]!==i||t[9]!==s||t[10]!==n?(l=(0,Y.jsxs)(wc,{modal:!1,value:n,onValueChange:i,items:Ku,children:[s,c]}),t[8]=i,t[9]=s,t[10]=n,t[11]=l):l=t[11],l});function Ju(e){return(0,Y.jsx)(yc,{value:e.value,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e.value===`worktree`?(0,Y.jsx)(Cl,{className:`size-3`}):(0,Y.jsx)(Ol,{className:`size-3`}),e.label]})},e.value)}function Yu(e,t){return`${e}\u0000${t}`}function Xu(e){let t=(0,J.c)(70),{activeProjectId:n,activeProjectEnvironmentId:r,appearance:i,draftId:a,label:s,className:c}=e,l=Jt(td),u=pe(ed),d=oe(eo($u)),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(``),g=(0,q.useRef)(null),_;t[0]===d?_=t[1]:(_=d.map(Qu),t[0]=d,t[1]=_);let v=_,y;t[2]===d?y=t[3]:(y=new Map(d.map(Zu)),t[2]=d,t[3]=y);let b=y,x;t[4]===m?x=t[5]:(x=m.trim().toLowerCase(),t[4]=m,t[5]=x);let S=x,C;bb0:{if(S.length===0){C=v;break bb0}let e;if(t[6]!==v||t[7]!==S||t[8]!==b){let n;t[10]!==S||t[11]!==b?(n=e=>{let t=b.get(e);return t?t.name.toLowerCase().includes(S)||t.cwd.toLowerCase().includes(S):!1},t[10]=S,t[11]=b,t[12]=n):n=t[12],e=v.filter(n),t[6]=v,t[7]=S,t[8]=b,t[9]=e}else e=t[9];C=e}let w=C,T;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{p(e),e||h(``)},t[13]=T):T=t[13];let E=T,D;t[14]!==r||t[15]!==n||t[16]!==a||t[17]!==l||t[18]!==b||t[19]!==u?(D=e=>{let t=b.get(e);p(!1),h(``),!(!t||t.id===n&&t.environmentId===r)&&l(a,{projectRef:o(t.environmentId,t.id),logicalProjectKey:Ae(t,u)})},t[14]=r,t[15]=n,t[16]=a,t[17]=l,t[18]=b,t[19]=u,t[20]=D):D=t[20];let O=D,k;t[21]!==r||t[22]!==n?(k=Yu(r,n),t[21]=r,t[22]=n,t[23]=k):k=t[23];let A=k,j;t[24]!==A||t[25]!==b?(j=b.get(A)??null,t[24]=A,t[25]=b,t[26]=j):j=t[26];let M=j,N=`Switch project (currently ${s})`,P=i===`headline`&&`rounded-sm text-foreground underline decoration-foreground decoration-dotted decoration-2 underline-offset-[7px] transition-colors hover:text-foreground/55 hover:decoration-foreground/40 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,F=i===`sentence`&&`inline-flex min-w-0 items-center gap-1.5 rounded-md px-1 py-0.5 font-medium text-foreground/85 transition-colors hover:bg-accent hover:text-foreground`,I=i===`chip`&&`inline-flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1 font-medium text-muted-foreground/70 text-xs transition-colors hover:bg-accent hover:text-foreground/80`,ee;t[27]!==c||t[28]!==P||t[29]!==F||t[30]!==I?(ee=G(`cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,P,F,I,c),t[27]=c,t[28]=P,t[29]=F,t[30]=I,t[31]=ee):ee=t[31];let L;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Y.jsx)(`button`,{type:`button`}),t[32]=L):L=t[32];let R;t[33]!==M||t[34]!==i?(R=i!==`headline`&&M?(0,Y.jsx)(Os,{environmentId:M.environmentId,cwd:M.cwd,projectId:M.id,customAvatarContentHash:M.customAvatarContentHash??null,className:`size-3.5 shrink-0`}):null,t[33]=M,t[34]=i,t[35]=R):R=t[35];let te=i===`headline`?void 0:`min-w-0 truncate`,z;t[36]!==s||t[37]!==te?(z=(0,Y.jsx)(`span`,{className:te,children:s}),t[36]=s,t[37]=te,t[38]=z):z=t[38];let ne;t[39]!==ee||t[40]!==R||t[41]!==z||t[42]!==N?(ne=(0,Y.jsxs)(is,{ref:g,"aria-label":N,className:ee,render:L,children:[R,z]}),t[39]=ee,t[40]=R,t[41]=z,t[42]=N,t[43]=ne):ne=t[43];let B=i===`chip`?`top`:`bottom`,re;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>h(e.target.value),t[44]=re):re=t[44];let V;t[45]===m?V=t[46]:(V=(0,Y.jsx)(`div`,{className:`border-b p-1`,children:(0,Y.jsx)(as,{className:`[&_input]:font-sans rounded-md`,inputClassName:`ring-0`,placeholder:`Search projects...`,showTrigger:!1,size:`sm`,value:m,onChange:re})}),t[45]=m,t[46]=V);let H;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Y.jsx)(rs,{children:`No projects found.`}),t[47]=H):H=t[47];let ie;if(t[48]!==A||t[49]!==w||t[50]!==b||t[51]!==O){let e;t[53]!==A||t[54]!==b||t[55]!==O?(e=(e,t)=>{let n=b.get(e);return n?(0,Y.jsx)($o,{hideIndicator:!0,index:t,value:e,onClick:()=>O(e),children:(0,Y.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 py-0.5 text-left`,children:[(0,Y.jsx)(Os,{environmentId:n.environmentId,cwd:n.cwd,projectId:n.id,customAvatarContentHash:n.customAvatarContentHash??null,className:`size-4 shrink-0`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:G(`truncate text-sm`,e===A&&`font-medium text-foreground`),children:n.name}),(0,Y.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:n.cwd})]})]})},e):null},t[53]=A,t[54]=b,t[55]=O,t[56]=e):e=t[56],ie=w.map(e),t[48]=A,t[49]=w,t[50]=b,t[51]=O,t[52]=ie}else ie=t[52];let ae;t[57]===ie?ae=t[58]:(ae=(0,Y.jsx)(ns,{className:`max-h-64`,children:ie}),t[57]=ie,t[58]=ae);let U;t[59]!==B||t[60]!==V||t[61]!==ae?(U=(0,Y.jsxs)(es,{anchor:g,align:`start`,side:B,className:`w-80 overflow-hidden`,children:[V,H,ae]}),t[59]=B,t[60]=V,t[61]=ae,t[62]=U):U=t[62];let se;return t[63]!==A||t[64]!==w||t[65]!==v||t[66]!==f||t[67]!==ne||t[68]!==U?(se=(0,Y.jsxs)(Qo,{items:v,filteredItems:w,autoHighlight:!0,open:f,value:A,onOpenChange:E,children:[ne,U]}),t[63]=A,t[64]=w,t[65]=v,t[66]=f,t[67]=ne,t[68]=U,t[69]=se):se=t[69],se}function Zu(e){return[Yu(e.environmentId,e.id),e]}function Qu(e){return Yu(e.environmentId,e.id)}function $u(e){return re(e)}function ed(e){return{sidebarProjectGroupingMode:e.sidebarProjectGroupingMode,sidebarProjectGroupingOverrides:e.sidebarProjectGroupingOverrides}}function td(e){return e.moveDraftThreadToProject}var nd=(0,q.memo)(function(e){let t=(0,J.c)(66),{environmentId:n,threadId:r,draftId:a,activeThreadBranchOverride:s,onActiveThreadBranchOverrideChange:c,envLocked:l,onCheckoutPullRequestRequest:u,onComposerFocusRequest:d,onOpenWorktreeSources:f,contextControlsHoisted:p,availableEnvironments:m,onEnvironmentChange:h,terminalAvailable:g,terminalOpen:_,terminalToggleShortcutLabel:v,onToggleTerminal:y,terminalCount:b}=e,x=p!==void 0&&p,S;t[0]!==n||t[1]!==r?(S=i(n,r),t[0]=n,t[1]=r,t[2]=S):S=t[2];let C=S,w;t[3]===C?w=t[4]:(w=ue(C),t[3]=C,t[4]=w);let T=oe(w),E;t[5]!==a||t[6]!==C?(E=e=>a?e.getDraftSession(a):e.getDraftThreadByRef(C),t[5]=a,t[6]=C,t[7]=E):E=t[7];let D=Jt(E),O=Jt(rd),k;t[8]!==D||t[9]!==T?(k=T?o(T.environmentId,T.projectId):D?o(D.environmentId,D.projectId):null,t[8]=D,t[9]=T,t[10]=k):k=t[10];let A=k,j;t[11]===A?j=t[12]:(j=ne(A),t[11]=A,t[12]=j);let M=oe(j),N=T!==void 0,P=N||D!==null,F=!!(m&&m.length>1&&h),I=!N&&D!==null&&!l,ee=T?.worktreePath??D?.worktreePath??null,L=D?.envMode,R;t[13]!==N||t[14]!==ee||t[15]!==L?(R=kr({activeWorktreePath:ee,hasServerThread:N,draftThreadEnvMode:L}),t[13]=N,t[14]=ee,t[15]=L,t[16]=R):R=t[16];let te=R,z;t[17]!==a||t[18]!==d||t[19]!==O||t[20]!==C?(z=e=>{O(a??C,{envMode:e,worktreePath:null}),d?.()},t[17]=a,t[18]=d,t[19]=O,t[20]=C,t[21]=z):z=t[21];let B=z;if(!P||!M)return null;let re;t[22]!==M||t[23]!==m||t[24]!==I||t[25]!==x||t[26]!==a||t[27]!==l||t[28]!==te||t[29]!==n||t[30]!==B||t[31]!==h||t[32]!==F?(re=x?null:(0,Y.jsxs)(`div`,{className:`flex min-w-0 shrink items-center gap-0.5`,children:[I&&a?(0,Y.jsx)(Xu,{activeProjectId:M.id,activeProjectEnvironmentId:M.environmentId,appearance:`chip`,draftId:a,label:M.name}):(0,Y.jsx)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 px-2 py-1 font-medium text-muted-foreground/70 text-xs`,children:(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:M.name})}),F&&m&&h&&(0,Y.jsx)(Uu,{envLocked:l,environmentId:n,availableEnvironments:m,onEnvironmentChange:h}),I?(0,Y.jsx)(qu,{value:te,onChange:B}):null]}),t[22]=M,t[23]=m,t[24]=I,t[25]=x,t[26]=a,t[27]=l,t[28]=te,t[29]=n,t[30]=B,t[31]=h,t[32]=F,t[33]=re):re=t[33];let V=!g,H;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Y.jsx)(Va,{className:`size-3 shrink-0`}),t[34]=H):H=t[34];let ie=_?`Close Terminal`:`Open Terminal`,ae;t[35]===ie?ae=t[36]:(ae=(0,Y.jsx)(`span`,{children:ie}),t[35]=ie,t[36]=ae);let U;t[37]===b?U=t[38]:(U=b>=2&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground/70 tabular-nums`,"aria-label":`${b} open terminals`,children:[`· `,b]}),t[37]=b,t[38]=U);let se;t[39]!==y||t[40]!==V||t[41]!==ae||t[42]!==U||t[43]!==_?(se=(0,Y.jsx)(Fo,{render:(0,Y.jsxs)(K,{variant:`ghost`,size:`xs`,className:`font-medium text-muted-foreground/70 hover:text-foreground/80`,disabled:V,onClick:y,"aria-label":`Toggle terminal drawer`,"aria-pressed":_,children:[H,ae,U]})}),t[39]=y,t[40]=V,t[41]=ae,t[42]=U,t[43]=_,t[44]=se):se=t[44];let ce=g?v?`Toggle terminal drawer (${v})`:`Toggle terminal drawer`:`Terminal is unavailable until this thread has an active project.`,le;t[45]===ce?le=t[46]:(le=(0,Y.jsx)(Io,{side:`top`,children:ce}),t[45]=ce,t[46]=le);let de;t[47]!==se||t[48]!==le?(de=(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center gap-1 phone:hidden`,children:(0,Y.jsxs)(Lo,{children:[se,le]})}),t[47]=se,t[48]=le,t[49]=de):de=t[49];let fe;t[50]!==s||t[51]!==I||t[52]!==x||t[53]!==a||t[54]!==l||t[55]!==n||t[56]!==c||t[57]!==u||t[58]!==d||t[59]!==f||t[60]!==r?(fe=x?null:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-0.5 md:ml-auto md:flex-none`,children:[I&&f?(0,Y.jsxs)(Lo,{children:[(0,Y.jsx)(Fo,{render:(0,Y.jsxs)(K,{variant:`ghost`,size:`xs`,className:`shrink-0 font-medium text-muted-foreground/70 hover:text-foreground/80 phone:hidden`,onClick:f,"data-testid":`branch-toolbar-worktree-sources`,children:[(0,Y.jsx)(Zi,{className:`size-3 shrink-0`}),(0,Y.jsx)(`span`,{children:`From PR / issue`})]})}),(0,Y.jsx)(Io,{side:`top`,children:`Create a worktree from a pull request, issue, or Jira item`})]}):null,(0,Y.jsx)(Hu,{className:`min-w-0`,environmentId:n,threadId:r,...a?{draftId:a}:{},envLocked:l,...s===void 0?{}:{activeThreadBranchOverride:s},...c?{onActiveThreadBranchOverrideChange:c}:{},...u?{onCheckoutPullRequestRequest:u}:{},...d?{onComposerFocusRequest:d}:{}})]}),t[50]=s,t[51]=I,t[52]=x,t[53]=a,t[54]=l,t[55]=n,t[56]=c,t[57]=u,t[58]=d,t[59]=f,t[60]=r,t[61]=fe):fe=t[61];let pe;return t[62]!==re||t[63]!==de||t[64]!==fe?(pe=(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-208 items-center gap-1 px-2.5 pb-3 pt-1 sm:px-3`,children:[re,de,fe]}),t[62]=re,t[63]=de,t[64]=fe,t[65]=pe):pe=t[65],pe});function rd(e){return e.setDraftThreadContext}var id=(0,q.memo)(function(e){let t=(0,J.c)(16),n=e.liveness===`working`,r=n?e.liveCount>0?`${e.liveCount} ${e.liveCount===1?`agent`:`agents`} working in the background`:`Background work running`:`Monitoring in the background`,i=n&&`animate-status-pulse`,a;t[0]===i?a=t[1]:(a=G(`size-3.5 shrink-0`,i),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,Y.jsx)(Jr,{className:a,"aria-hidden":!0}),t[2]=a,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:r}),t[4]=r,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Y.jsx)(`span`,{className:`text-muted-foreground/45`,"aria-hidden":!0,children:`·`}),t[6]=c):c=t[6];let l=e.stopping?`Stopping…`:`Stop`,u;t[7]!==e.onStop||t[8]!==e.stopping||t[9]!==l?(u=(0,Y.jsx)(`button`,{type:`button`,onClick:e.onStop,disabled:e.stopping,className:`shrink-0 font-medium text-foreground/85 transition-colors hover:text-foreground disabled:cursor-default disabled:text-muted-foreground/60`,children:l}),t[7]=e.onStop,t[8]=e.stopping,t[9]=l,t[10]=u):u=t[10];let d;return t[11]!==r||t[12]!==o||t[13]!==s||t[14]!==u?(d=(0,Y.jsxs)(`div`,{role:`status`,"aria-label":r,"data-background-liveness-chip":`true`,className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-[11px] leading-4 text-muted-foreground shadow-sm backdrop-blur-xs`,children:[o,s,c,u]}),t[11]=r,t[12]=o,t[13]=s,t[14]=u,t[15]=d):d=t[15],d}),ad=[`in the simulator`,`on the simulator`,`the simulator`,`simulator screen`,`ios simulator`,`on the device`,`device screen`,`nel simulatore`,`sul simulatore`,`schermo del simulatore`,`sul dispositivo`],od=[`look at`,`what do you see`,`read`,`describe`,`summarize`,`inspect`,`screenshot`,`screen`,`check`,`guarda`,`vedi`,`dimmi cosa vedi`,`leggi`,`descrivi`,`riassumi`,`ispeziona`];function sd(e){let t=e.toLowerCase().replace(/\s+/g,` `).trim();return ad.some(e=>t.includes(e))&&od.some(e=>t.includes(e))}function cd(e){return e.name.trim().length>0?e.name:`simulator-${Date.now()}.png`}function ld(e){let t=atob(e.bytesBase64);if(t.length===0)throw Error(`Simulator screenshot is empty.`);let n=Uint8Array.from(t,e=>e.charCodeAt(0)),r=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),i=new File([r],cd(e),{type:e.mimeType});if(i.size>10485760)throw Error(`Simulator screenshot exceeds the image attachment limit.`);return i}async function ud(e){if(!sd(e.prompt))return{requested:!1,image:null};if(!e.api.device)return{requested:!0,image:null,reason:`no-attached-device`};try{let t=await e.api.device.getThreadState({threadId:e.threadId}),n=t.attachedDeviceUdid?t.devices.find(e=>e.udid===t.attachedDeviceUdid):void 0;if(!n)return{requested:!0,image:null,reason:`no-attached-device`};if(n.state!==`booted`)return{requested:!0,image:null,reason:`device-not-booted`};let r=ld(await e.api.device.screenshot({udid:n.udid}));return{requested:!0,image:{type:`image`,id:crypto.randomUUID(),name:r.name,mimeType:r.type,sizeBytes:r.size,previewUrl:URL.createObjectURL(r),file:r}}}catch{return{requested:!0,image:null,reason:`attachment-processing-failed`}}}var dd=`ryco:last-invoked-script-by-project`,fd=P(v,j);function pd(e){return e.workspacePanelOpen&&e.workspaceTab===`agents`?0:e.liveCount}function md(e,t,n,r){return{id:e,environmentId:t.environmentId,codexThreadId:null,projectId:t.projectId,title:`New thread`,modelSelection:n,runtimeMode:t.runtimeMode,interactionMode:t.interactionMode,tokenMode:t.tokenMode??`balanced`,session:null,messages:[],error:r,createdAt:t.createdAt,archivedAt:null,settledOverride:null,settledAt:null,latestTurn:null,branch:t.branch,worktreePath:t.worktreePath,turnDiffSummaries:[],activities:[],proposedPlans:[]}}function hd(e){return!!(e.serverThread&&e.targetThreadId===e.routeThreadRef.threadId&&e.serverThread.environmentId===e.routeThreadRef.environmentId&&e.serverThread.id===e.targetThreadId)}function gd(e){let t=new Set(e.openThreadIds),n=e.currentThreadIds.filter(n=>n!==e.activeThreadId&&t.has(n)),r=Math.max(0,e.maxHiddenThreadCount??10),i=n.length>r?n.slice(-r):n;return e.activeThreadId&&e.activeThreadTerminalOpen&&!i.includes(e.activeThreadId)&&i.push(e.activeThreadId),i}function _d(e){!e||typeof URL>`u`||!e.startsWith(`blob:`)||URL.revokeObjectURL(e)}function vd(e){if(!(e.role!==`user`||!e.attachments))for(let t of e.attachments)t.type===`image`&&_d(t.previewUrl)}function yd(e){if(e.role!==`user`||!e.attachments)return[];let t=[];for(let n of e.attachments)n.type===`image`&&(!n.previewUrl||!n.previewUrl.startsWith(`blob:`)||t.push(n.previewUrl));return t}function bd(e){return e.isGitRepo?e.requestedEnvMode:`local`}function xd(e){let t=e.isServerThread&&!e.isFirstMessage&&e.threadWorktreePath===null&&e.activeThreadBranch!==null&&e.currentGitRefName!==null&&e.currentGitRefName!==e.activeThreadBranch;return{shouldMaterializeLegacyBranchWorktree:t,baseBranchForWorktree:e.isFirstMessage&&e.sendEnvMode===`worktree`&&!e.threadWorktreePath||t?e.activeThreadBranch:null,shouldCreateWorktree:e.isFirstMessage&&e.sendEnvMode===`worktree`&&!e.threadWorktreePath||t}}function Sd(e){let t=e.trimmedPrompt.trim();return t.length>0?t:e.firstImageName?`Attachment: ${e.firstImageName}`:e.firstTerminalContextLabel?e.firstTerminalContextLabel:`New thread`}function Cd(e){if(typeof URL>`u`||!e.previewUrl.startsWith(`blob:`))return e;try{return{...e,previewUrl:URL.createObjectURL(e.file)}}catch{return e}}function wd(e){let t=Wt(e.prompt).trim(),n=an(e.terminalContexts),r=e.terminalContexts.length-n.length,i=e.sourceControlContexts?.length??0;return{trimmedPrompt:t,sendableTerminalContexts:n,expiredTerminalContextCount:r,hasSendableContent:t.length>0||e.imageCount>0||n.length>0||i>0}}function Td(e,t){let n=Math.max(1,Math.floor(e))===1?`Expired terminal context`:`Expired terminal contexts`;return t===`empty`?{title:`${n} won't be sent`,description:`Remove it or re-add it to include terminal output.`}:{title:`${n} omitted from message`,description:`Re-add it if you want that terminal output included.`}}async function Ed(e,t){let n=R(new Date);return Promise.all(e.map(async e=>{if(!b(e.staleAfter,n))return e;try{return await t.fetcher(e)}catch{return e}}))}function Dd(e){return!!(e&&(e.latestTurn!==null||e.messages.length>0||e.session!==null))}function Od(e){return!!(e&&(e.latestTurn!==null||e.messages.length>0))}async function kd(e,t=1e3){let n=()=>ye(oe.getState(),e);return Dd(n())?!0:await new Promise(r=>{let i=!1,a=null,o=e=>{i||(i=!0,a!==null&&globalThis.clearTimeout(a),s(),r(e))},s=oe.subscribe(t=>{Dd(ye(t,e))&&o(!0)});if(Dd(n())){o(!0);return}a=globalThis.setTimeout(()=>{o(!1)},t)})}function Ad(e,t){let n=e?.latestTurn??null,r=e?.session??null;return{startedAt:new Date().toISOString(),preparingWorktree:!!t?.preparingWorktree,latestTurnTurnId:n?.turnId??null,latestTurnRequestedAt:n?.requestedAt??null,latestTurnStartedAt:n?.startedAt??null,latestTurnCompletedAt:n?.completedAt??null,sessionOrchestrationStatus:r?.orchestrationStatus??null,sessionUpdatedAt:r?.updatedAt??null}}function jd(e){if(!e.localDispatch)return!1;if(e.hasPendingApproval||e.hasPendingUserInput||e.threadError)return!0;let t=e.latestTurn??null,n=e.session??null,r=e.localDispatch.latestTurnTurnId!==(t?.turnId??null)||e.localDispatch.latestTurnRequestedAt!==(t?.requestedAt??null)||e.localDispatch.latestTurnStartedAt!==(t?.startedAt??null)||e.localDispatch.latestTurnCompletedAt!==(t?.completedAt??null);return e.phase===`running`?!(!r||t?.startedAt===null||t===null||n?.activeTurnId!==void 0&&n.activeTurnId!==null&&t?.turnId!==n.activeTurnId):r||e.localDispatch.sessionOrchestrationStatus!==(n?.orchestrationStatus??null)||e.localDispatch.sessionUpdatedAt!==(n?.updatedAt??null)}function Md(e){return e.hasThread&&e.messageCount===0&&e.optimisticMessageCount===0&&e.timelineEntryCount===0&&e.presentationTier!==`phone`}function Nd(e){return e.phase===`running`||e.isSendBusy||e.isConnecting||!e.hasSendableContent}function Pd(e){return!e.isMobileViewport||e.isSendBusy||e.isConnecting||e.phase===`running`?!1:e.pendingProgress?e.pendingProgress.isLastQuestion&&e.hasResolvedAnswers:e.showPlanFollowUpPrompt||e.hasSendableContent}function Fd(e){return e.pendingProgress?`pending:${e.pendingProgress.questionIndex}:${e.pendingProgress.isLastQuestion}:${e.pendingIsResponding}`:e.phase===`running`?`running`:e.showPlanFollowUpPrompt?e.promptHasText?`plan:refine`:`plan:implement`:`idle:${e.hasSendableContent}:${e.isSendBusy}:${e.isConnecting}:${e.isPreparingWorktree}`}var Id=(0,q.memo)(function(e){let t=(0,J.c)(16),n;t[0]===e.className?n=t[1]:(n=G(`inline-flex min-w-0 items-center`,e.className),t[0]=e.className,t[1]=n);let r=e.collapsed?`true`:`false`,i;t[2]===e.icon?i=t[3]:(i=(0,Y.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center`,"aria-hidden":`true`,children:e.icon}),t[2]=e.icon,t[3]=i);let a;t[4]!==e.collapsed||t[5]!==e.expanded||t[6]!==e.labelClassName?(a=G(`block overflow-hidden whitespace-nowrap transition-[margin-left,max-width,opacity] duration-300 ease-out motion-reduce:transition-none`,e.collapsed?[`ml-0 max-w-0 opacity-0`,`group-hover/composer-label-control:ml-1 group-hover/composer-label-control:max-w-40 group-hover/composer-label-control:opacity-100`,`group-focus-visible/composer-label-control:ml-1 group-focus-visible/composer-label-control:max-w-40 group-focus-visible/composer-label-control:opacity-100`,`group-focus-within/composer-label-control:ml-1 group-focus-within/composer-label-control:max-w-40 group-focus-within/composer-label-control:opacity-100`,`group-data-[pressed]/composer-label-control:ml-1 group-data-[pressed]/composer-label-control:max-w-40 group-data-[pressed]/composer-label-control:opacity-100`,e.expanded?`ml-1 max-w-40 opacity-100`:void 0]:`ml-1 max-w-40 opacity-100`,e.labelClassName),t[4]=e.collapsed,t[5]=e.expanded,t[6]=e.labelClassName,t[7]=a):a=t[7];let o;t[8]!==e.label||t[9]!==a?(o=(0,Y.jsx)(`span`,{className:a,"data-composer-expandable-label":`true`,children:e.label}),t[8]=e.label,t[9]=a,t[10]=o):o=t[10];let s;return t[11]!==n||t[12]!==r||t[13]!==i||t[14]!==o?(s=(0,Y.jsxs)(`span`,{className:n,"data-composer-expandable-label-control":`true`,"data-collapsed":r,children:[i,o]}),t[11]=n,t[12]=r,t[13]=i,t[14]=o,t[15]=s):s=t[15],s}),Ld=e=>e.isResponding?`Submitting...`:e.compact?e.isLastQuestion?`Submit`:`Next`:e.isLastQuestion?e.questionIndex>0?`Submit answers`:`Submit answer`:`Next question`,Rd=e=>{e.preventDefault()},zd=(0,q.memo)(function(e){let t=(0,J.c)(66),{compact:n,pendingAction:r,isRunning:i,showPlanFollowUpPrompt:a,promptHasText:o,isSendBusy:s,isConnecting:c,isEnvironmentUnavailable:l,isPreparingWorktree:u,hasSendableContent:d,preserveComposerFocusOnPointerDown:f,onPreviousPendingQuestion:p,onInterrupt:m,onImplementPlanInNewThread:h}=e,g=f!==void 0&&f,_;t[0]===g?_=t[1]:(_=g?{onPointerDown:Rd}:void 0,t[0]=g,t[1]=_);let v=_;if(r){let e=n?`gap-1.5`:`gap-2`,i;t[2]===e?i=t[3]:(i=G(`flex items-center justify-end`,e),t[2]=e,t[3]=i);let a;t[4]!==n||t[5]!==p||t[6]!==r.isResponding||t[7]!==r.questionIndex||t[8]!==v?(a=r.questionIndex>0?n?(0,Y.jsx)(K,{size:`icon-sm`,variant:`outline`,...v,onClick:p,disabled:r.isResponding,"aria-label":`Previous question`,children:(0,Y.jsx)($r,{className:`size-3.5`})}):(0,Y.jsx)(K,{size:`sm`,variant:`outline`,...v,onClick:p,disabled:r.isResponding,children:`Previous`}):null,t[4]=n,t[5]=p,t[6]=r.isResponding,t[7]=r.questionIndex,t[8]=v,t[9]=a):a=t[9];let o=n?`px-3`:`px-4`,s;t[10]===o?s=t[11]:(s=G(o),t[10]=o,t[11]=s);let c=l||r.isResponding||(r.isLastQuestion?!r.isComplete:!r.canAdvance),u;t[12]!==n||t[13]!==r.isLastQuestion||t[14]!==r.isResponding||t[15]!==r.questionIndex?(u=Ld({compact:n,isLastQuestion:r.isLastQuestion,isResponding:r.isResponding,questionIndex:r.questionIndex}),t[12]=n,t[13]=r.isLastQuestion,t[14]=r.isResponding,t[15]=r.questionIndex,t[16]=u):u=t[16];let d;t[17]!==v||t[18]!==s||t[19]!==c||t[20]!==u?(d=(0,Y.jsx)(K,{type:`submit`,size:`sm`,className:s,...v,disabled:c,children:u}),t[17]=v,t[18]=s,t[19]=c,t[20]=u,t[21]=d):d=t[21];let f;return t[22]!==d||t[23]!==i||t[24]!==a?(f=(0,Y.jsxs)(`div`,{className:i,children:[a,d]}),t[22]=d,t[23]=i,t[24]=a,t[25]=f):f=t[25],f}if(i){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,Y.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})}),t[26]=e):e=t[26];let n;return t[27]!==m||t[28]!==v?(n=(0,Y.jsx)(`button`,{type:`button`,className:`flex size-8 cursor-pointer items-center justify-center rounded-lg bg-rose-500/90 text-white transition-all duration-150 hover:bg-rose-500 hover:scale-105 sm:h-8 sm:w-8`,...v,onClick:m,"aria-label":`Stop generation`,children:e}),t[27]=m,t[28]=v,t[29]=n):n=t[29],n}if(a){if(o){let e=n?`h-9 px-3 sm:h-8`:`h-9 px-4 sm:h-8`,r;t[30]===e?r=t[31]:(r=G(e),t[30]=e,t[31]=r);let i=s||c||l,a=c||s?`Sending...`:`Refine`,o;return t[32]!==v||t[33]!==r||t[34]!==i||t[35]!==a?(o=(0,Y.jsx)(K,{type:`submit`,size:`sm`,className:r,...v,disabled:i,children:a}),t[32]=v,t[33]=r,t[34]=i,t[35]=a,t[36]=o):o=t[36],o}let e=s||c||l,r=c||s?`Sending...`:`Implement`,i;t[37]!==v||t[38]!==e||t[39]!==r?(i=(0,Y.jsx)(K,{type:`submit`,size:`sm`,className:`h-9 rounded-l-lg rounded-r-none px-4 sm:h-8`,...v,disabled:e,children:r}),t[37]=v,t[38]=e,t[39]=r,t[40]=i):i=t[40];let a=s||c||l,u;t[41]!==v||t[42]!==a?(u=(0,Y.jsx)(K,{size:`sm`,variant:`default`,className:`h-9 rounded-l-none rounded-r-lg border-l-white/12 px-2 sm:h-8`,"aria-label":`Implementation actions`,...v,disabled:a}),t[41]=v,t[42]=a,t[43]=u):u=t[43];let d;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Y.jsx)(Zr,{className:`size-3.5`}),t[44]=d):d=t[44];let f;t[45]===u?f=t[46]:(f=(0,Y.jsx)(oc,{render:u,children:d}),t[45]=u,t[46]=f);let p=s||c||l,m;t[47]===h?m=t[48]:(m=()=>void h(),t[47]=h,t[48]=m);let g;t[49]!==p||t[50]!==m?(g=(0,Y.jsx)(ec,{align:`end`,side:`top`,children:(0,Y.jsx)(sc,{disabled:p,onClick:m,children:`Implement in a new thread`})}),t[49]=p,t[50]=m,t[51]=g):g=t[51];let _;t[52]!==g||t[53]!==f?(_=(0,Y.jsxs)(rc,{children:[f,g]}),t[52]=g,t[53]=f,t[54]=_):_=t[54];let y;return t[55]!==_||t[56]!==i?(y=(0,Y.jsxs)(`div`,{"data-chat-composer-implement-actions":`true`,className:`flex items-center justify-end`,children:[i,_]}),t[55]=_,t[56]=i,t[57]=y):y=t[57],y}let y=s||c||l||!d,b=l?`Environment disconnected`:c?`Connecting`:u?`Preparing worktree`:s?`Sending`:`Send message`,x;t[58]!==c||t[59]!==s?(x=c||s?(0,Y.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,className:`animate-spin`,"aria-hidden":`true`,children:(0,Y.jsx)(`circle`,{cx:`7`,cy:`7`,r:`5.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeDasharray:`20 12`})}):(0,Y.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,Y.jsx)(`path`,{d:`M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})}),t[58]=c,t[59]=s,t[60]=x):x=t[60];let S;return t[61]!==v||t[62]!==y||t[63]!==b||t[64]!==x?(S=(0,Y.jsx)(`button`,{type:`submit`,className:`flex h-9 w-9 enabled:cursor-pointer items-center justify-center rounded-lg bg-primary/90 text-primary-foreground transition-all duration-150 hover:bg-primary hover:scale-105 disabled:pointer-events-none disabled:opacity-30 disabled:hover:scale-100 sm:h-8 sm:w-8`,...v,disabled:y,"aria-label":b,children:x}),t[61]=v,t[62]=y,t[63]=b,t[64]=x,t[65]=S):S=t[65],S}),Bd=`Not supported by this provider.`,Vd=(0,q.memo)(function(e){let t=(0,J.c)(20),n=e.tokenMode??`balanced`,r=e.showSessionPolicy??!0,i=e.runtimeMode===`full-access`?`text-orange-700 hover:text-orange-800 dark:text-orange-400 dark:hover:text-orange-300`:void 0,a;t[0]===i?a=t[1]:(a=G(`shrink-0 text-muted-foreground/70 hover:text-foreground/80`,i),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,Y.jsx)(K,{size:`icon-xs`,variant:`ghost`,className:a,"aria-label":`More composer controls`}),t[2]=a,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Y.jsx)(Vi,{"aria-hidden":`true`,className:`size-4`}),t[4]=s):s=t[4];let c;t[5]===o?c=t[6]:(c=(0,Y.jsx)(oc,{render:o,children:s}),t[5]=o,t[6]=c);let l;t[7]!==e.traitsMenuContent||t[8]!==r?(l=e.traitsMenuContent?(0,Y.jsxs)(Y.Fragment,{children:[e.traitsMenuContent,r?(0,Y.jsx)(tc,{}):null]}):null,t[7]=e.traitsMenuContent,t[8]=r,t[9]=l):l=t[9];let u;t[10]!==e||t[11]!==r||t[12]!==n?(u=r?(0,Y.jsxs)(Y.Fragment,{children:[e.showInteractionModeToggle?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`px-2 py-1.5 font-medium text-muted-foreground text-xs`,children:`Mode`}),(0,Y.jsxs)(ic,{value:e.interactionMode,onValueChange:t=>{!t||t===e.interactionMode||e.onInteractionModeChange(t)},children:[(0,Y.jsx)(cc,{value:`default`,children:`Chat`}),(0,Y.jsx)(cc,{value:`plan`,children:`Plan`}),(0,Y.jsx)(cc,{value:`ask`,disabled:!e.askModeSupported,children:e.askModeSupported?`Ask`:(0,Y.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,Y.jsx)(`span`,{children:`Ask`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground text-xs leading-4`,children:Bd})]})})]}),(0,Y.jsx)(tc,{})]}):null,(0,Y.jsx)(`div`,{className:`px-2 py-1.5 font-medium text-muted-foreground text-xs`,children:`Access`}),(0,Y.jsxs)(ic,{value:e.runtimeMode,onValueChange:t=>{!t||t===e.runtimeMode||e.onRuntimeModeChange(t)},children:[(0,Y.jsx)(cc,{value:`approval-required`,children:`Supervised`}),(0,Y.jsx)(cc,{value:`auto-accept-edits`,children:`Auto-accept edits`}),(0,Y.jsx)(cc,{value:`auto`,children:`Auto`}),(0,Y.jsx)(cc,{value:`full-access`,children:`Full access`})]}),(0,Y.jsx)(tc,{}),(0,Y.jsx)(`div`,{className:`px-2 py-1.5 font-medium text-muted-foreground text-xs`,children:`Tokens`}),(0,Y.jsxs)(ic,{value:n,onValueChange:t=>{!t||t===n||e.onTokenModeChange?.(t)},children:[(0,Y.jsx)(cc,{value:`off`,children:`Off`}),(0,Y.jsx)(cc,{value:`balanced`,children:`Balanced`}),(0,Y.jsx)(cc,{value:`aggressive`,children:`Aggressive`})]}),e.activePlan?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(tc,{}),(0,Y.jsxs)(sc,{onClick:e.onTogglePlanSidebar,children:[(0,Y.jsx)(Tl,{className:`size-4 shrink-0`}),e.planSidebarOpen?`Hide ${e.planSidebarLabel.toLowerCase()} sidebar`:`Show ${e.planSidebarLabel.toLowerCase()} sidebar`]})]}):null]}):null,t[10]=e,t[11]=r,t[12]=n,t[13]=u):u=t[13];let d;t[14]!==l||t[15]!==u?(d=(0,Y.jsxs)(ec,{align:`start`,children:[l,u]}),t[14]=l,t[15]=u,t[16]=d):d=t[16];let f;return t[17]!==c||t[18]!==d?(f=(0,Y.jsxs)(rc,{children:[c,d]}),t[17]=c,t[18]=d,t[19]=f):f=t[19],f}),Hd=new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`numeric`,day:`numeric`});function Ud(e){return!e||w(e)?``:Hd.format(m(e.value))}var Wd=(0,q.memo)(function(e){let t=(0,J.c)(7);if(e.isLoading&&e.items.length===0){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:`Loading…`}),t[0]=e):e=t[0],e}if(e.items.length===0){let n;return t[1]===e.emptyText?n=t[2]:(n=(0,Y.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:e.emptyText}),t[1]=e.emptyText,t[2]=n),n}let n;t[3]===e?n=t[4]:(n=e.items.map(t=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>e.onSelect(t),className:G(`flex w-full items-center gap-2 px-3 py-2 text-left text-sm`,`hover:bg-accent`),children:[(0,Y.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`#`,t.number]}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:Ud(t.updatedAt)})]})},`${t.provider}:${t.number}`)),t[3]=e,t[4]=n);let r;return t[5]===n?r=t[6]:(r=(0,Y.jsx)(`ul`,{className:`max-h-72 overflow-y-auto`,role:`listbox`,children:n}),t[5]=n,t[6]=r),r});function Gd(e){let t=(0,J.c)(64),[n,r]=(0,q.useState)(`issues`),[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={wait:200},t[0]=l):l=t[0];let[u]=it(i,l),d;t[1]!==e.cwd||t[2]!==e.environmentId?(d={environmentId:e.environmentId,cwd:e.cwd,state:`open`},t[1]=e.cwd,t[2]=e.environmentId,t[3]=d):d=t[3];let f=tr(d),p;t[4]!==e.cwd||t[5]!==e.environmentId?(p={environmentId:e.environmentId,cwd:e.cwd,state:`open`},t[4]=e.cwd,t[5]=e.environmentId,t[6]=p):p=t[6];let m=$n(p),h;t[7]===f.data?h=t[8]:(h=f.data??[],t[7]=f.data,t[8]=h);let g=h,_;t[9]===m.data?_=t[10]:(_=m.data??[],t[9]=m.data,t[10]=_);let v=_,y;t[11]!==g||t[12]!==i?(y=Ti(g,i),t[11]=g,t[12]=i,t[13]=y):y=t[13];let b=y,x=v,S;t[14]!==i||t[15]!==x?(S=Ti(x,i),t[14]=i,t[15]=x,t[16]=S):S=t[16];let C=S,w=n===`issues`&&b.length===0&&u.length>=2,T=n===`prs`&&C.length===0&&u.length>=2,E;t[17]!==u||t[18]!==w||t[19]!==e.cwd||t[20]!==e.environmentId?(E={environmentId:e.environmentId,cwd:e.cwd,query:u,enabled:w},t[17]=u,t[18]=w,t[19]=e.cwd,t[20]=e.environmentId,t[21]=E):E=t[21];let D=ir(E),O;t[22]!==u||t[23]!==T||t[24]!==e.cwd||t[25]!==e.environmentId?(O={environmentId:e.environmentId,cwd:e.cwd,query:u,enabled:T},t[22]=u,t[23]=T,t[24]=e.cwd,t[25]=e.environmentId,t[26]=O):O=t[26];let k=pr(O),A;t[27]!==b||t[28]!==w||t[29]!==D?(A=w?D.data??[]:b,t[27]=b,t[28]=w,t[29]=D,t[30]=A):A=t[30];let j=A,M;t[31]!==C||t[32]!==T||t[33]!==k?(M=T?k.data??[]:C,t[31]=C,t[32]=T,t[33]=k,t[34]=M):M=t[34];let N=M,P=f.isLoading||w&&D.isLoading,F=m.isLoading||T&&k.isLoading,I;t[35]===e?I=t[36]:(I=function(t){let n=t.target.files?.[0];n&&e.onAttachFile(n),t.target.value=``},t[35]=e,t[36]=I);let ee=I,L;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(e){e.preventDefault(),s(!0)},t[37]=L):L=t[37];let R=L,te;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(te=function(){s(!1)},t[38]=te):te=t[38];let z=te,ne;t[39]===e?ne=t[40]:(ne=function(t){t.preventDefault(),s(!1);let n=t.dataTransfer.files[0];n&&e.onAttachFile(n)},t[39]=e,t[40]=ne);let B=ne,re=o||void 0,V;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:`Add context`}),t[41]=V):V=t[41];let H;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Attach file`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>c.current?.click(),children:(0,Y.jsx)(Al,{className:`size-4`})}),t[42]=H):H=t[42];let ie;t[43]===ee?ie=t[44]:(ie=(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[V,H,(0,Y.jsx)(`input`,{ref:c,type:`file`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:ee})]}),t[43]=ee,t[44]=ie);let ae;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>a(e.target.value),t[45]=ae):ae=t[45];let U;t[46]===i?U=t[47]:(U=(0,Y.jsx)(`div`,{className:`px-3 py-2 border-b border-border`,children:(0,Y.jsx)(`input`,{type:`text`,className:`w-full rounded-md bg-muted px-2 py-1 text-sm outline-none placeholder:text-muted-foreground`,placeholder:`Search…`,value:i,onChange:ae})}),t[46]=i,t[47]=U);let oe;t[48]!==n||t[49]!==g||t[50]!==v||t[51]!==j||t[52]!==N||t[53]!==P||t[54]!==F||t[55]!==e||t[56]!==i?(oe=e.hasSourceControlRemote?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(vi,{tabs:[{id:`issues`,label:`Issues`,count:g.length},{id:`prs`,label:`PRs`,count:v.length}],activeId:n,onSelect:e=>r(e)}),n===`issues`?(0,Y.jsx)(Wd,{items:j,isLoading:P,emptyText:i.length>0?`No matching issues`:`No open issues`,onSelect:e.onSelectIssue}):(0,Y.jsx)(Wd,{items:N,isLoading:F,emptyText:i.length>0?`No matching PRs`:`No open PRs`,onSelect:t=>e.onSelectChangeRequest(t)})]}):(0,Y.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:`No source-control remote detected. File attach is still available above.`}),t[48]=n,t[49]=g,t[50]=v,t[51]=j,t[52]=N,t[53]=P,t[54]=F,t[55]=e,t[56]=i,t[57]=oe):oe=t[57];let se;return t[58]!==B||t[59]!==re||t[60]!==ie||t[61]!==U||t[62]!==oe?(se=(0,Y.jsxs)(`div`,{className:`flex w-80 flex-col`,onDragOver:R,onDragLeave:z,onDrop:B,"data-drag-over":re,children:[ie,U,oe]}),t[58]=B,t[59]=re,t[60]=ie,t[61]=U,t[62]=oe,t[63]=se):se=t[63],se}function Kd(e){let t=(0,J.c)(15),[n,r]=(0,q.useState)(!1),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Y.jsxs)(Lo,{children:[(0,Y.jsx)(Fo,{render:(0,Y.jsx)(Ec,{render:(0,Y.jsx)(K,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":`Add context`,className:`text-muted-foreground/70 hover:text-foreground/80`})}),children:(0,Y.jsx)(Al,{className:`size-4`})}),(0,Y.jsx)(Io,{side:`top`,children:`Add context`})]}),t[0]=i):i=t[0];let a,o,s;t[1]===e?(a=t[2],o=t[3],s=t[4]):(a=t=>{e.onSelectIssue(t),r(!1)},o=t=>{e.onSelectChangeRequest(t),r(!1)},s=t=>{e.onAttachFile(t),r(!1)},t[1]=e,t[2]=a,t[3]=o,t[4]=s);let c;t[5]!==e.cwd||t[6]!==e.environmentId||t[7]!==e.hasSourceControlRemote||t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,Y.jsx)(Tc,{align:`start`,side:`top`,className:`p-0`,children:(0,Y.jsx)(Gd,{environmentId:e.environmentId,cwd:e.cwd,hasSourceControlRemote:e.hasSourceControlRemote,onSelectIssue:a,onSelectChangeRequest:o,onAttachFile:s})}),t[5]=e.cwd,t[6]=e.environmentId,t[7]=e.hasSourceControlRemote,t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11];let l;return t[12]!==n||t[13]!==c?(l=(0,Y.jsxs)(Dc,{open:n,onOpenChange:r,children:[i,c]}),t[12]=n,t[13]=c,t[14]=l):l=t[14],l}function qd(e){return e&&typeof e==`object`?e:null}function Jd(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Yd(e){return typeof e==`boolean`?e:null}function Xd(e){let t=e?.trim().match(/^(\d+(?:\.\d+)?)\s*([km]?)$/i);if(!t)return null;let n=Number(t[1]),r=t[2]?.toLowerCase()??``;if(!Number.isFinite(n)||n<=0||r===``&&!Number.isInteger(n))return null;let i=Math.round(n*(r===`m`?1e6:r===`k`?1e3:1));return Number.isSafeInteger(i)&&i>0?i:null}function Zd(e){let t=e!==null&&Number.isSafeInteger(e)&&e>0?e:null;return{usedTokens:0,totalProcessedTokens:null,maxTokens:t,remainingTokens:t,usedPercentage:t===null?null:0,remainingPercentage:t===null?null:100,inputTokens:null,cachedInputTokens:null,outputTokens:null,reasoningOutputTokens:null,lastUsedTokens:null,lastInputTokens:null,lastCachedInputTokens:null,lastOutputTokens:null,lastReasoningOutputTokens:null,toolUses:null,durationMs:null,compactsAutomatically:!1}}function Qd(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(!n||n.kind!==`context-window.updated`)continue;let r=qd(n.payload),i=Jd(r?.usedTokens);if(i===null||i<=0)continue;let a=Jd(r?.maxTokens),o=a!==null&&a>0?Math.min(100,i/a*100):null,s=a===null?null:Math.max(0,Math.round(a-i)),c=o===null?null:Math.max(0,100-o);return{usedTokens:i,totalProcessedTokens:Jd(r?.totalProcessedTokens),maxTokens:a,remainingTokens:s,usedPercentage:o,remainingPercentage:c,inputTokens:Jd(r?.inputTokens),cachedInputTokens:Jd(r?.cachedInputTokens),outputTokens:Jd(r?.outputTokens),reasoningOutputTokens:Jd(r?.reasoningOutputTokens),lastUsedTokens:Jd(r?.lastUsedTokens),lastInputTokens:Jd(r?.lastInputTokens),lastCachedInputTokens:Jd(r?.lastCachedInputTokens),lastOutputTokens:Jd(r?.lastOutputTokens),lastReasoningOutputTokens:Jd(r?.lastReasoningOutputTokens),toolUses:Jd(r?.toolUses),durationMs:Jd(r?.durationMs),compactsAutomatically:Yd(r?.compactsAutomatically)??!1,updatedAt:n.createdAt}}return null}function $d(e,t){return Qd(e)??Zd(Xd(t))}function ef(e){return e===null||!Number.isFinite(e)?`0`:e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}m`}function tf(e){return e===null||!Number.isFinite(e)?null:e<10?`${e.toFixed(1).replace(/\.0$/,``)}%`:`${Math.round(e)}%`}function nf(e){let t=(0,J.c)(5);if(e.percent===null)return null;let n=Math.max(0,Math.min(100,e.percent)),r=n>=95?`h-full rounded-full bg-destructive`:n>=80?`h-full rounded-full bg-warning`:`h-full rounded-full bg-foreground/60`,i=`${n}%`,a;t[0]===i?a=t[1]:(a={width:i},t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,Y.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:r,style:a})}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function rf(e){let t=(0,J.c)(21),n;t[0]===e.window?n=t[1]:(n=gs(e.window),t[0]=e.window,t[1]=n);let r=n,i=e.window.windowDurationMins===void 0?e.fallbackLabel:r.label,a;t[2]===e.window.usedPercent?a=t[3]:(a=us(e.window.usedPercent),t[2]=e.window.usedPercent,t[3]=a);let o=a,s;t[4]===e.window.resetsAt?s=t[5]:(s=cs(e.window.resetsAt),t[4]=e.window.resetsAt,t[5]=s);let c=s,l;t[6]===i?l=t[7]:(l=(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:i}),t[6]=i,t[7]=l);let u;t[8]===c?u=t[9]:(u=c?(0,Y.jsxs)(`span`,{className:`ml-1`,children:[`· `,c]}):null,t[8]=c,t[9]=u);let d;t[10]!==u||t[11]!==o?(d=(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[o,`% used`,u]}),t[10]=u,t[11]=o,t[12]=d):d=t[12];let f;t[13]!==l||t[14]!==d?(f=(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 whitespace-nowrap text-xs`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15];let p;t[16]===o?p=t[17]:(p=(0,Y.jsx)(nf,{percent:o}),t[16]=o,t[17]=p);let m;return t[18]!==f||t[19]!==p?(m=(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[f,p]}),t[18]=f,t[19]=p,t[20]=m):m=t[20],m}function af(e){let t=(0,J.c)(47),{usage:n,rateLimits:r}=e,i=!!(r&&(r.primary||r.secondary)),a;t[0]===n.usedPercentage?a=t[1]:(a=tf(n.usedPercentage),t[0]=n.usedPercentage,t[1]=a);let o=a,s=Math.max(0,Math.min(100,n.usedPercentage??0)),c=2*Math.PI*9.75,l=c-s/100*c,u;t[2]!==n.maxTokens||t[3]!==n.usedTokens||t[4]!==o?(u=n.maxTokens!==null&&o?`Context window ${o} used`:`Context window ${ef(n.usedTokens)} tokens used`,t[2]=n.maxTokens,t[3]=n.usedTokens,t[4]=o,t[5]=u):u=t[5];let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Y.jsx)(`circle`,{cx:`12`,cy:`12`,r:9.75,fill:`none`,stroke:`color-mix(in oklab, var(--color-muted) 70%, transparent)`,strokeWidth:`3`}),t[6]=d):d=t[6];let f;t[7]===l?f=t[8]:(f=(0,Y.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:`-rotate-90 absolute inset-0 h-full w-full`,"aria-hidden":`true`,children:[d,(0,Y.jsx)(`circle`,{cx:`12`,cy:`12`,r:9.75,fill:`none`,stroke:`var(--color-muted-foreground)`,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:c,strokeDashoffset:l,className:`transition-[stroke-dashoffset] duration-500 ease-out motion-reduce:transition-none`})]}),t[7]=l,t[8]=f);let p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=G(`relative flex h-[15px] w-[15px] items-center justify-center rounded-full bg-background text-[8px] font-medium`,`text-muted-foreground`),t[9]=p):p=t[9];let m;t[10]!==n.usedPercentage||t[11]!==n.usedTokens?(m=n.usedPercentage===null?ef(n.usedTokens):Math.round(n.usedPercentage),t[10]=n.usedPercentage,t[11]=n.usedTokens,t[12]=m):m=t[12];let h;t[13]===m?h=t[14]:(h=(0,Y.jsx)(`span`,{className:p,children:m}),t[13]=m,t[14]=h);let g;t[15]!==f||t[16]!==h?(g=(0,Y.jsxs)(`span`,{className:`relative flex h-6 w-6 items-center justify-center`,children:[f,h]}),t[15]=f,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==u||t[19]!==g?(_=(0,Y.jsx)(Ec,{openOnHover:!0,delay:150,closeDelay:0,render:(0,Y.jsx)(`button`,{type:`button`,className:`group inline-flex h-9 w-6 items-center justify-center rounded-full transition-opacity hover:opacity-85 sm:h-8`,"aria-label":u,children:g})}),t[18]=u,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Y.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Context window`}),t[21]=v):v=t[21];let y;t[22]!==n.maxTokens||t[23]!==n.usedTokens||t[24]!==o?(y=n.maxTokens!==null&&o?(0,Y.jsxs)(`div`,{className:`whitespace-nowrap text-xs font-medium text-foreground`,children:[(0,Y.jsx)(`span`,{children:o}),(0,Y.jsx)(`span`,{className:`mx-1`,children:`⋅`}),(0,Y.jsx)(`span`,{children:ef(n.usedTokens)}),(0,Y.jsx)(`span`,{children:`/`}),(0,Y.jsxs)(`span`,{children:[ef(n.maxTokens??null),` context used`]})]}):(0,Y.jsxs)(`div`,{className:`whitespace-nowrap text-xs font-medium text-foreground`,children:[ef(n.usedTokens),` context used`]}),t[22]=n.maxTokens,t[23]=n.usedTokens,t[24]=o,t[25]=y):y=t[25];let b=n.maxTokens!==null&&n.usedPercentage!==null?s:null,x;t[26]===b?x=t[27]:(x=(0,Y.jsx)(nf,{percent:b}),t[26]=b,t[27]=x);let S;t[28]!==n.totalProcessedTokens||t[29]!==n.usedTokens?(S=(n.totalProcessedTokens??null)!==null&&(n.totalProcessedTokens??0)>n.usedTokens?(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Total processed: `,ef(n.totalProcessedTokens??null),` `,`tokens`]}):null,t[28]=n.totalProcessedTokens,t[29]=n.usedTokens,t[30]=S):S=t[30];let C;t[31]===n.compactsAutomatically?C=t[32]:(C=n.compactsAutomatically?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Automatically compacts its context when needed.`}):null,t[31]=n.compactsAutomatically,t[32]=C);let w;t[33]!==y||t[34]!==x||t[35]!==S||t[36]!==C?(w=(0,Y.jsxs)(`div`,{className:`space-y-1.5 leading-tight`,children:[v,y,x,S,C]}),t[33]=y,t[34]=x,t[35]=S,t[36]=C,t[37]=w):w=t[37];let T;t[38]!==r||t[39]!==i?(T=i&&r?(0,Y.jsxs)(`div`,{className:`mt-2.5 space-y-1.5 border-t border-border/60 pt-2 leading-tight`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Usage limits`}),(0,Y.jsxs)(`div`,{className:`grid gap-1`,children:[r.primary?(0,Y.jsx)(rf,{window:r.primary,fallbackLabel:`Short window`}):null,r.secondary?(0,Y.jsx)(rf,{window:r.secondary,fallbackLabel:`Weekly`}):null]})]}):null,t[38]=r,t[39]=i,t[40]=T):T=t[40];let E;t[41]!==w||t[42]!==T?(E=(0,Y.jsxs)(Tc,{tooltipStyle:!0,surface:`glass`,side:`top`,align:`end`,className:`w-64 max-w-none px-3 py-2`,children:[w,T]}),t[41]=w,t[42]=T,t[43]=E):E=t[43];let D;return t[44]!==E||t[45]!==_?(D=(0,Y.jsxs)(Dc,{children:[_,E]}),t[44]=E,t[45]=_,t[46]=D):D=t[46],D}function of(e){let t=(0,J.c)(35),{label:n,value:r,options:i,disabled:a,disabledReason:o,onChange:s,className:c}=e,l=a!==void 0&&a,u=`${(0,q.useId)()}-reason`,d;t[0]!==l||t[1]!==o?(d=l&&o?Fc(o):null,t[0]=l,t[1]=o,t[2]=d):d=t[2];let f=d,p;if(t[3]!==i||t[4]!==r){let e=i.find(e=>e.id===r)??null;p=e?.disabled===!0&&e.disabledReason?Fc(e.disabledReason):e?.description??null,t[3]=i,t[4]=r,t[5]=p}else p=t[5];let m=p,h;t[6]===c?h=t[7]:(h=G(`flex min-w-0 flex-col gap-1.5`,c),t[6]=c,t[7]=h);let g;t[8]===n?g=t[9]:(g=(0,Y.jsx)(`div`,{className:`font-medium text-muted-foreground text-xs`,children:n}),t[8]=n,t[9]=g);let _;t[10]!==f||t[11]!==u?(_=f?{"aria-describedby":u}:{},t[10]=f,t[11]=u,t[12]=_):_=t[12];let v;if(t[13]!==l||t[14]!==s||t[15]!==i||t[16]!==r){let e;t[18]!==l||t[19]!==s||t[20]!==r?(e=e=>{let t=l||(e.disabled??!1),n=e.id===r;return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:t,"data-tone":e.tone??`default`,className:G(`flex min-h-11 min-w-0 basis-0 grow flex-col items-center justify-center gap-0.5 rounded-md px-1 text-center text-xs`,`transition-colors duration-[var(--app-motion-duration-chip)] ease-[var(--app-motion-ease)] motion-reduce:transition-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,`disabled:pointer-events-none disabled:text-muted-foreground/60`,n?`bg-background font-medium shadow-sm`:`text-muted-foreground`,e.tone===`caution`&&!t&&`text-orange-700 dark:text-orange-400`),"data-slot":`mobile-segmented-option`,onClick:()=>{t||s(e.id)},children:[e.icon,(0,Y.jsx)(`span`,{className:`w-full truncate`,children:e.label})]},e.id)},t[18]=l,t[19]=s,t[20]=r,t[21]=e):e=t[21],v=i.map(e),t[13]=l,t[14]=s,t[15]=i,t[16]=r,t[17]=v}else v=t[17];let y;t[22]!==n||t[23]!==_||t[24]!==v?(y=(0,Y.jsx)(`div`,{role:`group`,"aria-label":n,..._,className:`flex min-w-0 items-stretch gap-1 rounded-lg bg-muted/50 p-1`,"data-slot":`mobile-segmented-group`,children:v}),t[22]=n,t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;t[26]!==f||t[27]!==u||t[28]!==m?(b=f?(0,Y.jsx)(`p`,{id:u,className:`text-muted-foreground/80 text-xs`,"data-slot":`mobile-segmented-reason`,children:f}):m?(0,Y.jsx)(`p`,{className:`text-muted-foreground text-xs`,"data-slot":`mobile-segmented-description`,children:m}):null,t[26]=f,t[27]=u,t[28]=m,t[29]=b):b=t[29];let x;return t[30]!==h||t[31]!==g||t[32]!==y||t[33]!==b?(x=(0,Y.jsxs)(`div`,{className:h,"data-slot":`mobile-segmented`,children:[g,y,b]}),t[30]=h,t[31]=g,t[32]=y,t[33]=b,t[34]=x):x=t[34],x}var sf={"approval-required":{label:`Supervised`,triggerLabel:`Supervised`,description:`Ask before commands and file changes.`,icon:ba},"auto-accept-edits":{label:`Auto-accept edits`,triggerLabel:`Auto-accept`,description:`Auto-approve edits, ask before other actions.`,icon:Ri},auto:{label:`Auto`,triggerLabel:`Auto`,description:`Routine actions proceed without you; risky ones still ask.`,icon:za},"full-access":{label:`Full access`,triggerLabel:`Full access`,description:`Allow commands and edits without prompts.`,icon:El}},cf=Object.keys(sf),lf={default:{label:`Build`,triggerLabel:`Build`,description:`Make changes and run commands.`,icon:wl},plan:{label:`Plan`,triggerLabel:`Plan`,description:`Chat toward a plan before making changes.`,icon:gl},ask:{label:`Ask`,triggerLabel:`Ask`,description:`Read-only — answer questions without editing files.`,icon:Dl}},uf=Object.keys(lf),df=(0,q.memo)(function(e){let t=(0,J.c)(38),n=e.disabled??!1,r=n&&e.disabledReason?e.disabledReason:void 0,i=e.open,a=e.onOpenChange,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Y.jsx)(Ic,{children:(0,Y.jsx)(Rc,{children:`Session policy`})}),t[0]=o):o=t[0];let s;t[1]!==n||t[2]!==e||t[3]!==r?(s=e.showInteractionModeToggle?(0,Y.jsx)(of,{label:`Mode`,value:e.interactionMode,disabled:n,...r?{disabledReason:r}:{},options:uf.map(t=>{let n=lf[t];return t===`ask`&&!e.askModeSupported?{id:t,label:n.label,description:Bd,disabled:!0,disabledReason:Bd}:{id:t,label:n.label,description:n.description}}),onChange:t=>e.onInteractionModeChange(t)}):null,t[1]=n,t[2]=e,t[3]=r,t[4]=s):s=t[4];let c=e.runtimeMode,l;t[5]===r?l=t[6]:(l=r?{disabledReason:r}:{},t[5]=r,t[6]=l);let u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=cf.map(pf),t[7]=u):u=t[7];let d;t[8]===e?d=t[9]:(d=t=>e.onRuntimeModeChange(t),t[8]=e,t[9]=d);let f;t[10]!==n||t[11]!==e.runtimeMode||t[12]!==l||t[13]!==d?(f=(0,Y.jsx)(of,{label:`Access`,value:c,disabled:n,...l,options:u,onChange:d}),t[10]=n,t[11]=e.runtimeMode,t[12]=l,t[13]=d,t[14]=f):f=t[14];let p=e.tokenMode,m;t[15]===r?m=t[16]:(m=r?{disabledReason:r}:{},t[15]=r,t[16]=m);let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=Fi.map(mf),t[17]=h):h=t[17];let g;t[18]===e?g=t[19]:(g=t=>e.onTokenModeChange(t),t[18]=e,t[19]=g);let _;t[20]!==n||t[21]!==e.tokenMode||t[22]!==m||t[23]!==g?(_=(0,Y.jsx)(of,{label:`Tokens`,value:p,disabled:n,...m,options:h,onChange:g}),t[20]=n,t[21]=e.tokenMode,t[22]=m,t[23]=g,t[24]=_):_=t[24];let v;t[25]!==n||t[26]!==e||t[27]!==r?(v=e.showPlanToggle?(0,Y.jsx)(Bc,{label:e.planSidebarOpen?`Hide ${e.planSidebarLabel.toLowerCase()} sidebar`:`Show ${e.planSidebarLabel.toLowerCase()} sidebar`,icon:(0,Y.jsx)(Tl,{"aria-hidden":!0,className:`size-4 shrink-0`}),selected:e.planSidebarOpen,disabled:n,...r?{disabledReason:r}:{},onClick:()=>{n||(e.onOpenChange(!1),e.onTogglePlanSidebar())}}):null,t[25]=n,t[26]=e,t[27]=r,t[28]=v):v=t[28];let y;t[29]!==_||t[30]!==v||t[31]!==s||t[32]!==f?(y=(0,Y.jsx)(Pc,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 pb-2`,"data-slot":`phone-session-policy`,children:[s,f,_,v]})}),t[29]=_,t[30]=v,t[31]=s,t[32]=f,t[33]=y):y=t[33];let b;return t[34]!==e.onOpenChange||t[35]!==e.open||t[36]!==y?(b=(0,Y.jsxs)(Vc,{open:i,onOpenChange:a,label:`Session policy`,detent:`medium`,children:[o,y]}),t[34]=e.onOpenChange,t[35]=e.open,t[36]=y,t[37]=b):b=t[37],b}),ff=(0,q.memo)(function(e){let t=(0,J.c)(23),[n,r]=(0,q.useState)(!1),i=e.disabled??!1,a=sf[e.runtimeMode],o=a.icon,s=lf[e.interactionMode],c;t[0]!==i||t[1]!==e.disabledReason?(c=i&&e.disabledReason?Fc(e.disabledReason):null,t[0]=i,t[1]=e.disabledReason,t[2]=c):c=t[2];let l=c,u=e.runtimeMode===`full-access`&&`text-orange-700 hover:text-orange-800 dark:text-orange-400 dark:hover:text-orange-300`,d;t[3]===u?d=t[4]:(d=G(`min-h-11 shrink-0 gap-1 whitespace-nowrap px-1.5 font-medium text-muted-foreground/80 hover:text-foreground/80`,u),t[3]=u,t[4]=d);let f=`Session policy: ${s.triggerLabel}, ${a.triggerLabel}`,p=l??a.description,m;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>r(!0),t[5]=m):m=t[5];let h;t[6]===o?h=t[7]:(h=(0,Y.jsx)(o,{"aria-hidden":!0,className:`size-4`}),t[6]=o,t[7]=h);let g;t[8]===a.triggerLabel?g=t[9]:(g=(0,Y.jsx)(`span`,{className:`truncate`,children:a.triggerLabel}),t[8]=a.triggerLabel,t[9]=g);let _;t[10]!==i||t[11]!==d||t[12]!==f||t[13]!==p||t[14]!==h||t[15]!==g?(_=(0,Y.jsxs)(K,{size:`xs`,variant:`ghost`,type:`button`,"data-chat-session-policy-trigger":`true`,className:d,disabled:i,"aria-label":f,title:p,onClick:m,children:[h,g]}),t[10]=i,t[11]=d,t[12]=f,t[13]=p,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==n||t[18]!==e?(v=(0,Y.jsx)(df,{...e,open:n,onOpenChange:r}),t[17]=n,t[18]=e,t[19]=v):v=t[19];let y;return t[20]!==_||t[21]!==v?(y=(0,Y.jsxs)(Y.Fragment,{children:[_,v]}),t[20]=_,t[21]=v,t[22]=y):y=t[22],y});function pf(e){return e===`full-access`?{id:e,label:sf[e].label,description:sf[e].description,tone:`caution`}:{id:e,label:sf[e].label,description:sf[e].description}}function mf(e){return{id:e,label:Pi[e].label,description:Pi[e].description}}var hf=300,gf=(0,q.memo)(function(e){let t=(0,J.c)(76),n=sf[e.runtimeMode],r=n.icon,i=Pi[e.tokenMode],a=i.icon,o=lf[e.interactionMode],s=o.icon,c=Tr(yf),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(!1),x=(0,q.useRef)(0),S=(0,q.useRef)(0),C=(0,q.useRef)(0),w=(0,q.useRef)(null),T=(0,q.useRef)(null),E=(0,q.useRef)(null),D=bf,O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{x.current=performance.now()+hf,g(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{w.current=null,g(!1)},hf)},t[0]=O):O=t[0];let k=O,A;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{S.current=performance.now()+hf,v(!0),T.current!==null&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{T.current=null,v(!1)},hf)},t[1]=A):A=t[1];let j=A,M;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{C.current=performance.now()+hf,b(!0),E.current!==null&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{E.current=null,b(!1)},hf)},t[2]=M):M=t[2];let N=M,P;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{k(),window.setTimeout(()=>u(!1),0)},t[3]=P):P=t[3];let F=P,I;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{j(),window.setTimeout(()=>f(!1),0)},t[4]=I):I=t[4];let ee=I,L;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{N(),window.setTimeout(()=>m(!1),0)},t[5]=L):L=t[5];let R=L,te,z;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>()=>{w.current!==null&&window.clearTimeout(w.current),T.current!==null&&window.clearTimeout(T.current),E.current!==null&&window.clearTimeout(E.current)},z=[],t[6]=te,t[7]=z):(te=t[6],z=t[7]),(0,q.useEffect)(te,z);let ne;t[8]!==s||t[9]!==o.description||t[10]!==o.triggerLabel||t[11]!==l||t[12]!==h||t[13]!==e||t[14]!==c?(ne=e.showInteractionModeToggle?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(wc,{value:e.interactionMode,open:l,onOpenChange:e=>{e&&D(x)||u(e)},onValueChange:t=>{t&&(e.onInteractionModeChange(t),k(),u(!1))},children:[(0,Y.jsx)(xc,{variant:`ghost`,size:`xs`,className:G(`group/composer-label-control gap-1 px-1.5 font-medium text-muted-foreground/70 hover:text-foreground/80 sm:px-1.5`,c&&`min-w-7 justify-center px-1 sm:px-1 [&_[data-slot=select-icon]]:hidden`),"aria-label":`Interaction mode: ${o.triggerLabel}`,title:o.description,children:(0,Y.jsx)(Id,{collapsed:c,expanded:l||h,icon:(0,Y.jsx)(s,{className:`size-4 sm:size-3.5`}),label:(0,Y.jsx)(Cc,{children:o.triggerLabel})})}),(0,Y.jsx)(vc,{alignItemWithTrigger:!1,className:`w-56 p-0.5 [&_[data-slot=select-item]]:min-h-7`,children:uf.map(t=>{let n=lf[t],r=n.icon,i=t===`ask`&&!e.askModeSupported;return(0,Y.jsx)(yc,{value:t,disabled:i,className:`min-w-0 py-1.5`,onClick:F,children:(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-foreground`,children:[(0,Y.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),n.label]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground text-xs leading-4`,children:i?Bd:n.description})]})},t)})})]})}):null,t[8]=s,t[9]=o.description,t[10]=o.triggerLabel,t[11]=l,t[12]=h,t[13]=e,t[14]=c,t[15]=ne):ne=t[15];let B=e.runtimeMode,re;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>{e&&D(S)||f(e)},t[16]=re):re=t[16];let V;t[17]===e?V=t[18]:(V=t=>{t&&(e.onRuntimeModeChange(t),j(),f(!1))},t[17]=e,t[18]=V);let H=c&&`min-w-7 justify-center px-1 sm:px-1 [&_[data-slot=select-icon]]:hidden`,ie=e.runtimeMode===`full-access`&&`text-orange-700 hover:text-orange-800 dark:text-orange-400 dark:hover:text-orange-300`,ae;t[19]!==H||t[20]!==ie?(ae=G(`group/composer-label-control gap-1 px-1.5 font-medium sm:px-1.5`,H,ie),t[19]=H,t[20]=ie,t[21]=ae):ae=t[21];let U=`Runtime mode: ${n.triggerLabel}`,oe=d||_,se;t[22]===r?se=t[23]:(se=(0,Y.jsx)(r,{className:`size-4`}),t[22]=r,t[23]=se);let ce;t[24]===n.triggerLabel?ce=t[25]:(ce=(0,Y.jsx)(Cc,{children:n.triggerLabel}),t[24]=n.triggerLabel,t[25]=ce);let le;t[26]!==oe||t[27]!==se||t[28]!==ce||t[29]!==c?(le=(0,Y.jsx)(Id,{collapsed:c,expanded:oe,icon:se,label:ce}),t[26]=oe,t[27]=se,t[28]=ce,t[29]=c,t[30]=le):le=t[30];let ue;t[31]!==n.description||t[32]!==ae||t[33]!==U||t[34]!==le?(ue=(0,Y.jsx)(xc,{variant:`ghost`,size:`xs`,className:ae,"aria-label":U,title:n.description,children:le}),t[31]=n.description,t[32]=ae,t[33]=U,t[34]=le,t[35]=ue):ue=t[35];let de;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Y.jsx)(vc,{alignItemWithTrigger:!1,className:`w-56 p-0.5 [&_[data-slot=select-item]]:min-h-7`,children:cf.map(e=>{let t=sf[e],n=t.icon;return(0,Y.jsx)(yc,{value:e,className:`min-w-0 py-1.5`,onClick:ee,children:(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:G(`inline-flex items-center gap-1.5 font-medium text-foreground`,e===`full-access`&&`text-orange-700 hover:text-orange-800 dark:text-orange-400 dark:hover:text-orange-300`),"data-runtime-mode-option-label":e,children:[(0,Y.jsx)(n,{className:G(`size-3.5 shrink-0`,e!==`full-access`&&`text-muted-foreground`)}),t.label]}),(0,Y.jsx)(`span`,{className:G(`text-muted-foreground text-xs leading-4`,e===`full-access`&&`text-orange-700 hover:text-orange-800 dark:text-orange-400 dark:hover:text-orange-300`),"data-runtime-mode-option-description":e,children:t.description})]})},e)})}),t[36]=de):de=t[36];let fe;t[37]!==e.runtimeMode||t[38]!==d||t[39]!==V||t[40]!==ue?(fe=(0,Y.jsxs)(wc,{value:B,open:d,onOpenChange:re,onValueChange:V,children:[ue,de]}),t[37]=e.runtimeMode,t[38]=d,t[39]=V,t[40]=ue,t[41]=fe):fe=t[41];let pe=e.tokenMode,me;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>{e&&D(C)||m(e)},t[42]=me):me=t[42];let he;t[43]===e?he=t[44]:(he=t=>{t&&(e.onTokenModeChange(t),N(),m(!1))},t[43]=e,t[44]=he);let ge=c&&`min-w-7 justify-center px-1 sm:px-1`,_e=c&&`[&_[data-slot=select-icon]]:hidden`,ve;t[45]!==ge||t[46]!==_e?(ve=G(`group/composer-label-control gap-1 px-1.5 font-medium text-muted-foreground/80 hover:text-foreground/80 sm:px-1.5`,ge,_e),t[45]=ge,t[46]=_e,t[47]=ve):ve=t[47];let ye=`Token mode: ${i.triggerLabel}`,be;t[48]!==a||t[49]!==i.triggerLabel||t[50]!==p||t[51]!==y||t[52]!==c?(be=c?(0,Y.jsx)(Id,{collapsed:!0,expanded:p||y,icon:(0,Y.jsx)(a,{className:`size-4`}),label:(0,Y.jsx)(Cc,{children:i.triggerLabel})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(a,{className:`size-4`}),(0,Y.jsx)(Cc,{children:i.triggerLabel})]}),t[48]=a,t[49]=i.triggerLabel,t[50]=p,t[51]=y,t[52]=c,t[53]=be):be=t[53];let xe;t[54]!==ve||t[55]!==ye||t[56]!==be||t[57]!==i.description?(xe=(0,Y.jsx)(xc,{variant:`ghost`,size:`xs`,className:ve,"aria-label":ye,title:i.description,children:be}),t[54]=ve,t[55]=ye,t[56]=be,t[57]=i.description,t[58]=xe):xe=t[58];let Se;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Y.jsx)(vc,{alignItemWithTrigger:!1,className:`w-60 p-0.5 [&_[data-slot=select-item]]:min-h-7`,children:Fi.map(e=>{let t=Pi[e],n=t.icon;return(0,Y.jsx)(yc,{value:e,className:`min-w-0 py-1.5`,onClick:R,children:(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-foreground`,children:[(0,Y.jsx)(n,{className:`size-3.5 shrink-0 text-muted-foreground`}),t.label]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground text-xs leading-4`,children:t.description})]})},e)})}),t[59]=Se):Se=t[59];let Ce;t[60]!==e.tokenMode||t[61]!==he||t[62]!==xe||t[63]!==p?(Ce=(0,Y.jsxs)(wc,{value:pe,open:p,onOpenChange:me,onValueChange:he,children:[xe,Se]}),t[60]=e.tokenMode,t[61]=he,t[62]=xe,t[63]=p,t[64]=Ce):Ce=t[64];let we;t[65]!==e.onTogglePlanSidebar||t[66]!==e.planSidebarLabel||t[67]!==e.planSidebarOpen||t[68]!==e.showPlanToggle||t[69]!==c?(we=e.showPlanToggle?(0,Y.jsx)(K,{variant:`ghost`,className:G(`group/composer-label-control shrink-0 whitespace-nowrap px-1.5 sm:px-2`,e.planSidebarOpen?`text-blue-400 hover:text-blue-300`:`text-muted-foreground/70 hover:text-foreground/80`),size:`xs`,type:`button`,onClick:e.onTogglePlanSidebar,"aria-label":e.planSidebarLabel,title:e.planSidebarOpen?`Hide ${e.planSidebarLabel.toLowerCase()} sidebar`:`Show ${e.planSidebarLabel.toLowerCase()} sidebar`,children:(0,Y.jsx)(Id,{collapsed:c,icon:(0,Y.jsx)(Tl,{className:`size-4 sm:size-3.5`}),label:e.planSidebarLabel})}):null,t[65]=e.onTogglePlanSidebar,t[66]=e.planSidebarLabel,t[67]=e.planSidebarOpen,t[68]=e.showPlanToggle,t[69]=c,t[70]=we):we=t[70];let Te;return t[71]!==fe||t[72]!==Ce||t[73]!==we||t[74]!==ne?(Te=(0,Y.jsxs)(Y.Fragment,{children:[ne,fe,Ce,we]}),t[71]=fe,t[72]=Ce,t[73]=we,t[74]=ne,t[75]=Te):Te=t[75],Te}),_f=(0,q.memo)(function(e){let t=(0,J.c)(24),n;t[0]!==e.contextWindowRateLimits||t[1]!==e.contextWindowUsage?(n=(0,Y.jsx)(af,{usage:e.contextWindowUsage,rateLimits:e.contextWindowRateLimits}),t[0]=e.contextWindowRateLimits,t[1]=e.contextWindowUsage,t[2]=n):n=t[2];let r;t[3]===e.isPreparingWorktree?r=t[4]:(r=e.isPreparingWorktree?(0,Y.jsx)(`span`,{className:`text-muted-foreground/70 text-xs`,children:`Preparing worktree...`}):null,t[3]=e.isPreparingWorktree,t[4]=r);let i=e.preserveComposerFocusOnPointerDown??!1,a;t[5]!==e.compact||t[6]!==e.hasSendableContent||t[7]!==e.isConnecting||t[8]!==e.isEnvironmentUnavailable||t[9]!==e.isPreparingWorktree||t[10]!==e.isRunning||t[11]!==e.isSendBusy||t[12]!==e.onImplementPlanInNewThread||t[13]!==e.onInterrupt||t[14]!==e.onPreviousPendingQuestion||t[15]!==e.pendingAction||t[16]!==e.promptHasText||t[17]!==e.showPlanFollowUpPrompt||t[18]!==i?(a=(0,Y.jsx)(zd,{compact:e.compact,pendingAction:e.pendingAction,isRunning:e.isRunning,showPlanFollowUpPrompt:e.showPlanFollowUpPrompt,promptHasText:e.promptHasText,isSendBusy:e.isSendBusy,isConnecting:e.isConnecting,isEnvironmentUnavailable:e.isEnvironmentUnavailable,isPreparingWorktree:e.isPreparingWorktree,hasSendableContent:e.hasSendableContent,preserveComposerFocusOnPointerDown:i,onPreviousPendingQuestion:e.onPreviousPendingQuestion,onInterrupt:e.onInterrupt,onImplementPlanInNewThread:e.onImplementPlanInNewThread}),t[5]=e.compact,t[6]=e.hasSendableContent,t[7]=e.isConnecting,t[8]=e.isEnvironmentUnavailable,t[9]=e.isPreparingWorktree,t[10]=e.isRunning,t[11]=e.isSendBusy,t[12]=e.onImplementPlanInNewThread,t[13]=e.onInterrupt,t[14]=e.onPreviousPendingQuestion,t[15]=e.pendingAction,t[16]=e.promptHasText,t[17]=e.showPlanFollowUpPrompt,t[18]=i,t[19]=a):a=t[19];let o;return t[20]!==n||t[21]!==r||t[22]!==a?(o=(0,Y.jsxs)(Y.Fragment,{children:[n,r,a]}),t[20]=n,t[21]=r,t[22]=a,t[23]=o):o=t[23],o}),vf=(0,q.memo)(function(e){let t=(0,J.c)(81),n=Ms(x.dispatchCommand),r=!n.allowed,i=n.reason,a=Rs()===`phone`,o=e.isFooterCompact?`true`:`false`,s=e.isFooterCompact?`gap-1.5`:`sm:gap-0`,c=e.hideOnMobilePendingAnswers&&`phone:hidden`,l;t[0]!==s||t[1]!==c?(l=G(`flex min-w-0 flex-nowrap items-center justify-between gap-1.5 overflow-visible px-2 pb-2 sm:px-2.5 sm:pb-2.5`,s,c),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u=e.gitCwd??``,d;t[3]!==e.environmentId||t[4]!==e.hasSourceControlRemote||t[5]!==e.onAttachFile||t[6]!==e.onSelectChangeRequest||t[7]!==e.onSelectIssue||t[8]!==u?(d=(0,Y.jsx)(Kd,{environmentId:e.environmentId,cwd:u,hasSourceControlRemote:e.hasSourceControlRemote,onSelectIssue:e.onSelectIssue,onSelectChangeRequest:e.onSelectChangeRequest,onAttachFile:e.onAttachFile}),t[3]=e.environmentId,t[4]=e.hasSourceControlRemote,t[5]=e.onAttachFile,t[6]=e.onSelectChangeRequest,t[7]=e.onSelectIssue,t[8]=u,t[9]=d):d=t[9];let f;t[10]===i?f=t[11]:(f=i?{disabledReason:i}:{},t[10]=i,t[11]=f);let p;t[12]===e.modelPickerIconClassName?p=t[13]:(p=e.modelPickerIconClassName?{activeProviderIconClassName:e.modelPickerIconClassName}:{},t[12]=e.modelPickerIconClassName,t[13]=p);let m;t[14]!==r||t[15]!==e.isFooterCompact||t[16]!==e.isModelPickerOpen||t[17]!==e.keybindings||t[18]!==e.lockedContinuationGroupKey||t[19]!==e.lockedProvider||t[20]!==e.modelOptionsByInstance||t[21]!==e.onModelPickerOpenChange||t[22]!==e.onProviderModelSelect||t[23]!==e.providerInstanceEntries||t[24]!==e.selectedInstanceId||t[25]!==e.selectedModel||t[26]!==e.terminalOpen||t[27]!==f||t[28]!==p?(m=(0,Y.jsx)(qa,{compact:e.isFooterCompact,activeInstanceId:e.selectedInstanceId,model:e.selectedModel,lockedProvider:e.lockedProvider,lockedContinuationGroupKey:e.lockedContinuationGroupKey,instanceEntries:e.providerInstanceEntries,keybindings:e.keybindings,modelOptionsByInstance:e.modelOptionsByInstance,terminalOpen:e.terminalOpen,open:e.isModelPickerOpen,triggerSize:`xs`,phoneSheet:!0,disabled:r,...f,...p,onOpenChange:e.onModelPickerOpenChange,onInstanceModelChange:e.onProviderModelSelect}),t[14]=r,t[15]=e.isFooterCompact,t[16]=e.isModelPickerOpen,t[17]=e.keybindings,t[18]=e.lockedContinuationGroupKey,t[19]=e.lockedProvider,t[20]=e.modelOptionsByInstance,t[21]=e.onModelPickerOpenChange,t[22]=e.onProviderModelSelect,t[23]=e.providerInstanceEntries,t[24]=e.selectedInstanceId,t[25]=e.selectedModel,t[26]=e.terminalOpen,t[27]=f,t[28]=p,t[29]=m):m=t[29];let h;t[30]===e?h=t[31]:(h=(e.executionTargets?.length??0)>0&&e.selectedExecutionEnvironmentId?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(wc,{value:e.selectedExecutionEnvironmentId,disabled:e.executionTargetLocked,onValueChange:t=>{t&&e.onExecutionTargetChange?.(t)},children:[(0,Y.jsxs)(xc,{variant:`ghost`,size:`xs`,className:`max-w-40 gap-1 px-1.5 text-muted-foreground/80`,"aria-label":`Execution machine`,title:e.executionTargetLocked?`Existing threads stay on their owning machine`:`Execution machine`,children:[(0,Y.jsx)(Ol,{className:`size-3.5 shrink-0`}),(0,Y.jsx)(Cc,{children:e.executionTargets?.find(t=>t.environmentId===e.selectedExecutionEnvironmentId)?.label??`No verified machine`})]}),(0,Y.jsx)(vc,{alignItemWithTrigger:!1,className:`w-56 p-0.5`,children:e.executionTargets?.map(xf)})]}),!e.executionTargetLocked&&e.executionTargets?.find(t=>t.environmentId===e.selectedExecutionEnvironmentId)?.disabled?(0,Y.jsx)(`span`,{className:`shrink-0 text-destructive text-xs`,children:`No verified machine available`}):null]}):null,t[30]=e,t[31]=h);let g;t[32]!==a||t[33]!==r||t[34]!==i||t[35]!==e.askModeSupported||t[36]!==e.interactionMode||t[37]!==e.isFooterCompact||t[38]!==e.onInteractionModeChange||t[39]!==e.onRuntimeModeChange||t[40]!==e.onTogglePlanSidebar||t[41]!==e.onTokenModeChange||t[42]!==e.planSidebarLabel||t[43]!==e.planSidebarOpen||t[44]!==e.providerTraitsChips||t[45]!==e.providerTraitsMenuContent||t[46]!==e.runtimeMode||t[47]!==e.showInteractionModeToggle||t[48]!==e.showPlanSidebarToggle||t[49]!==e.tokenMode?(g=a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ff,{interactionMode:e.interactionMode,runtimeMode:e.runtimeMode,tokenMode:e.tokenMode,showInteractionModeToggle:e.showInteractionModeToggle,askModeSupported:e.askModeSupported,showPlanToggle:e.showPlanSidebarToggle,planSidebarLabel:e.planSidebarLabel,planSidebarOpen:e.planSidebarOpen,disabled:r,...i?{disabledReason:i}:{},onInteractionModeChange:e.onInteractionModeChange,onRuntimeModeChange:e.onRuntimeModeChange,onTokenModeChange:e.onTokenModeChange,onTogglePlanSidebar:e.onTogglePlanSidebar}),e.providerTraitsMenuContent?(0,Y.jsx)(Vd,{activePlan:e.showPlanSidebarToggle,interactionMode:e.interactionMode,planSidebarLabel:e.planSidebarLabel,planSidebarOpen:e.planSidebarOpen,runtimeMode:e.runtimeMode,tokenMode:e.tokenMode,showInteractionModeToggle:e.showInteractionModeToggle,askModeSupported:e.askModeSupported,showSessionPolicy:!1,traitsMenuContent:e.providerTraitsMenuContent,onInteractionModeChange:e.onInteractionModeChange,onTogglePlanSidebar:e.onTogglePlanSidebar,onRuntimeModeChange:e.onRuntimeModeChange,onTokenModeChange:e.onTokenModeChange}):null]}):e.isFooterCompact?(0,Y.jsx)(Vd,{activePlan:e.showPlanSidebarToggle,interactionMode:e.interactionMode,planSidebarLabel:e.planSidebarLabel,planSidebarOpen:e.planSidebarOpen,runtimeMode:e.runtimeMode,tokenMode:e.tokenMode,showInteractionModeToggle:e.showInteractionModeToggle,askModeSupported:e.askModeSupported,traitsMenuContent:e.providerTraitsMenuContent,onInteractionModeChange:e.onInteractionModeChange,onTogglePlanSidebar:e.onTogglePlanSidebar,onRuntimeModeChange:e.onRuntimeModeChange,onTokenModeChange:e.onTokenModeChange}):(0,Y.jsxs)(Y.Fragment,{children:[e.providerTraitsChips,(0,Y.jsx)(gf,{showInteractionModeToggle:e.showInteractionModeToggle,askModeSupported:e.askModeSupported,interactionMode:e.interactionMode,runtimeMode:e.runtimeMode,tokenMode:e.tokenMode,showPlanToggle:e.showPlanSidebarToggle,planSidebarLabel:e.planSidebarLabel,planSidebarOpen:e.planSidebarOpen,onInteractionModeChange:e.onInteractionModeChange,onRuntimeModeChange:e.onRuntimeModeChange,onTokenModeChange:e.onTokenModeChange,onTogglePlanSidebar:e.onTogglePlanSidebar})]}),t[32]=a,t[33]=r,t[34]=i,t[35]=e.askModeSupported,t[36]=e.interactionMode,t[37]=e.isFooterCompact,t[38]=e.onInteractionModeChange,t[39]=e.onRuntimeModeChange,t[40]=e.onTogglePlanSidebar,t[41]=e.onTokenModeChange,t[42]=e.planSidebarLabel,t[43]=e.planSidebarOpen,t[44]=e.providerTraitsChips,t[45]=e.providerTraitsMenuContent,t[46]=e.runtimeMode,t[47]=e.showInteractionModeToggle,t[48]=e.showPlanSidebarToggle,t[49]=e.tokenMode,t[50]=g):g=t[50];let _;t[51]!==g||t[52]!==d||t[53]!==m||t[54]!==h?(_=(0,Y.jsxs)(`div`,{className:`-m-0.5 flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto p-0.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:[d,m,h,g]}),t[51]=g,t[52]=d,t[53]=m,t[54]=h,t[55]=_):_=t[55];let v=e.isPrimaryActionsCompact?`true`:`false`,y;t[56]!==e.contextWindowRateLimits||t[57]!==e.contextWindowUsage||t[58]!==e.hasSendableContent||t[59]!==e.isConnecting||t[60]!==e.isEnvironmentUnavailable||t[61]!==e.isMobileViewport||t[62]!==e.isPreparingWorktree||t[63]!==e.isPrimaryActionsCompact||t[64]!==e.isRunning||t[65]!==e.isSendBusy||t[66]!==e.onImplementPlanInNewThread||t[67]!==e.onInterrupt||t[68]!==e.onPreviousPendingQuestion||t[69]!==e.pendingAction||t[70]!==e.promptHasText||t[71]!==e.showPlanFollowUpPrompt?(y=(0,Y.jsx)(_f,{compact:e.isPrimaryActionsCompact,contextWindowUsage:e.contextWindowUsage,contextWindowRateLimits:e.contextWindowRateLimits,pendingAction:e.pendingAction,isRunning:e.isRunning,showPlanFollowUpPrompt:e.showPlanFollowUpPrompt,promptHasText:e.promptHasText,isSendBusy:e.isSendBusy,isConnecting:e.isConnecting,isEnvironmentUnavailable:e.isEnvironmentUnavailable,isPreparingWorktree:e.isPreparingWorktree,hasSendableContent:e.hasSendableContent,preserveComposerFocusOnPointerDown:e.isMobileViewport,onPreviousPendingQuestion:e.onPreviousPendingQuestion,onInterrupt:e.onInterrupt,onImplementPlanInNewThread:e.onImplementPlanInNewThread}),t[56]=e.contextWindowRateLimits,t[57]=e.contextWindowUsage,t[58]=e.hasSendableContent,t[59]=e.isConnecting,t[60]=e.isEnvironmentUnavailable,t[61]=e.isMobileViewport,t[62]=e.isPreparingWorktree,t[63]=e.isPrimaryActionsCompact,t[64]=e.isRunning,t[65]=e.isSendBusy,t[66]=e.onImplementPlanInNewThread,t[67]=e.onInterrupt,t[68]=e.onPreviousPendingQuestion,t[69]=e.pendingAction,t[70]=e.promptHasText,t[71]=e.showPlanFollowUpPrompt,t[72]=y):y=t[72];let b;t[73]!==v||t[74]!==y?(b=(0,Y.jsx)(`div`,{"data-chat-composer-actions":`right`,"data-chat-composer-primary-actions-compact":v,className:`flex shrink-0 flex-nowrap items-start justify-end gap-2`,children:y}),t[73]=v,t[74]=y,t[75]=b):b=t[75];let S;return t[76]!==o||t[77]!==_||t[78]!==b||t[79]!==l?(S=(0,Y.jsxs)(`div`,{"data-chat-composer-footer":`true`,"data-chat-composer-footer-compact":o,className:l,children:[_,b]}),t[76]=o,t[77]=_,t[78]=b,t[79]=l,t[80]=S):S=t[80],S});function yf(e){return e.wideComposerControlsAutoCollapse}function bf(e){return performance.now()<e.current}function xf(e){return(0,Y.jsx)(yc,{value:e.environmentId,disabled:e.disabled,children:(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(Ol,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.environmentId)}function Sf(e,t){let{scope:n,search:r}=Ci(e),i=n===`mixed`||n===`issues`,a=n===`mixed`||n===`prs`;if(n===`jira`)return[];let o=i?Ti(t.issues,r).map(e=>({id:`source-control-issue:${e.provider}:${e.number}`,type:`source-control-issue`,summary:e,label:`#${e.number}`,description:e.title})):[],s=a?Cf(t.prs,r).map(e=>({id:`source-control-pr:${e.provider}:${e.number}`,type:`source-control-pr`,summary:e,label:`#${e.number}`,description:e.title})):[];return[...o,...s]}function Cf(e,t){let n=t.trim().toLowerCase();return n.length===0?e:e.filter(e=>{let t=String(e.number),r=e.title.toLowerCase();return t===n||t.startsWith(n)||r.includes(n)})}function wf(e){return e.items.length===0?null:e.currentSearchKey===e.highlightedSearchKey&&e.highlightedItemId&&e.items.some(t=>t.id===e.highlightedItemId)?e.highlightedItemId:e.items[0]?.id??null}function Tf(e,t){let n=e.type===`slash-command`?e.command.toLowerCase():e.command.name.toLowerCase(),r=e.description.toLowerCase(),i=[Wa({value:n,query:t,exactBase:0,prefixBase:2,boundaryBase:4,includesBase:6,fuzzyBase:100,boundaryMarkers:[`-`,`_`,`/`]}),Wa({value:r,query:t,exactBase:20,prefixBase:22,boundaryBase:24,includesBase:26})].filter(e=>e!==null);return i.length===0?null:Math.min(...i)}function Ef(e,t){let n=Ka(t,{trimLeadingPattern:/^\/+/});if(!n)return[...e];let r=[];for(let t of e){let e=Tf(t,n);e!==null&&Ga(r,{item:t,score:e,tieBreaker:t.type===`slash-command`?`0\u0000${t.command}`:`1\u0000${t.command.name}\u0000${t.provider}`},1/0)}return r.map(e=>e.item)}function Df(e,t){let n=e.name.toLowerCase(),r=ea(e).toLowerCase(),i=e.shortDescription?.toLowerCase()??``,a=e.description?.toLowerCase()??``,o=e.scope?.toLowerCase()??``,s=[Wa({value:n,query:t,exactBase:0,prefixBase:2,boundaryBase:4,includesBase:6,fuzzyBase:100,boundaryMarkers:[`-`,`_`,`/`]}),Wa({value:r,query:t,exactBase:1,prefixBase:3,boundaryBase:5,includesBase:7,fuzzyBase:110}),Wa({value:i,query:t,exactBase:20,prefixBase:22,boundaryBase:24,includesBase:26}),Wa({value:a,query:t,exactBase:30,prefixBase:32,boundaryBase:34,includesBase:36}),Wa({value:o,query:t,exactBase:40,prefixBase:42,includesBase:44})].filter(e=>e!==null);return s.length===0?null:Math.min(...s)}function Of(e,t,n=1/0){let r=e.filter(e=>e.enabled),i=Ka(t,{trimLeadingPattern:/^\$+/});if(!i)return r;let a=[];for(let e of r){let t=Df(e,i);t!==null&&Ga(a,{item:e,score:t,tieBreaker:`${ea(e).toLowerCase()}\u0000${e.name}`},n)}return a.map(e=>e.item)}function kf(e){let t=(0,J.c)(5),n,r,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Y.jsx)(`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}),r=(0,Y.jsx)(`path`,{d:`m3.3 7 8.7 5 8.7-5`}),i=(0,Y.jsx)(`path`,{d:`M12 22V12`}),t[0]=n,t[1]=r,t[2]=i):(n=t[0],r=t[1],i=t[2]);let a;return t[3]===e.className?a=t[4]:(a=(0,Y.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.85`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e.className,"aria-hidden":`true`,children:[n,r,i]}),t[3]=e.className,t[4]=a),a}function Af(e,t,n){if(t===`skill`)return e.length>0?[{id:`skills`,label:`Skills`,items:e}]:[];if(t!==`slash-command`||!n)return[{id:`default`,label:null,items:e}];let r=e.filter(e=>e.type===`slash-command`),i=e.filter(e=>e.type===`provider-slash-command`),a=[];return r.length>0&&a.push({id:`built-in`,label:`Built-in`,items:r}),i.length>0&&a.push({id:`provider`,label:`Provider`,items:i}),a}var jf=(0,q.memo)(function(e){let t=(0,J.c)(33),n=(0,q.useRef)(null),r=e.groupSlashCommandSections??!0,i;t[0]!==e.items||t[1]!==e.triggerKind||t[2]!==r?(i=Af(e.items,e.triggerKind,r),t[0]=e.items,t[1]=e.triggerKind,t[2]=r,t[3]=i):i=t[3];let a=i,o,s;t[4]===e.activeItemId?(o=t[5],s=t[6]):(o=()=>{!e.activeItemId||!n.current||n.current.querySelector(`[data-composer-item-id="${CSS.escape(e.activeItemId)}"]`)?.scrollIntoView({block:`nearest`})},s=[e.activeItemId],t[4]=e.activeItemId,t[5]=o,t[6]=s),(0,q.useLayoutEffect)(o,s);let c;t[7]===e?c=t[8]:(c=t=>{e.onHighlightedItemChange(typeof t==`string`?t:null)},t[7]=e,t[8]=c);let l;if(t[9]!==a||t[10]!==e.activeItemId||t[11]!==e.onHighlightedItemChange||t[12]!==e.onSelect||t[13]!==e.resolvedTheme){let n;t[15]!==e.activeItemId||t[16]!==e.onHighlightedItemChange||t[17]!==e.onSelect||t[18]!==e.resolvedTheme?(n=(t,n)=>(0,Y.jsxs)(`div`,{children:[n>0?(0,Y.jsx)(Jo,{className:`my-0.5`}):null,(0,Y.jsxs)(Yo,{children:[t.label?(0,Y.jsx)(Ko,{className:`px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground/55`,children:t.label}):null,t.items.map(t=>(0,Y.jsx)(Mf,{item:t,resolvedTheme:e.resolvedTheme,isActive:e.activeItemId===t.id,onHighlight:e.onHighlightedItemChange,onSelect:e.onSelect},t.id))]})]},t.id),t[15]=e.activeItemId,t[16]=e.onHighlightedItemChange,t[17]=e.onSelect,t[18]=e.resolvedTheme,t[19]=n):n=t[19],l=a.map(n),t[9]=a,t[10]=e.activeItemId,t[11]=e.onHighlightedItemChange,t[12]=e.onSelect,t[13]=e.resolvedTheme,t[14]=l}else l=t[14];let u;t[20]===l?u=t[21]:(u=(0,Y.jsx)(qo,{className:`max-h-[clamp(4.5rem,calc(var(--app-visible-viewport-height,9999px)-12.5rem),18rem)] phone:max-h-[clamp(4.5rem,calc(var(--app-visible-viewport-height,9999px)-13.5rem),18rem)]`,children:l}),t[20]=l,t[21]=u);let d;t[22]!==e.emptyStateText||t[23]!==e.isLoading||t[24]!==e.items.length||t[25]!==e.triggerKind?(d=e.items.length===0?(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:e.triggerKind===`skill`?(0,Y.jsxs)(Yo,{children:[(0,Y.jsx)(Ko,{className:`px-0 pt-0 pb-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground/55`,children:`Skills`}),(0,Y.jsx)(`p`,{className:`text-muted-foreground/70 text-xs`,children:e.isLoading?`Searching workspace skills...`:e.emptyStateText??`No skills found. Try / to browse provider commands.`})]}):(0,Y.jsx)(`p`,{className:`text-muted-foreground/70 text-xs`,children:e.isLoading?`Searching workspace files...`:e.emptyStateText??(e.triggerKind===`path`?`No matching files or folders.`:`No matching command.`)})}):null,t[22]=e.emptyStateText,t[23]=e.isLoading,t[24]=e.items.length,t[25]=e.triggerKind,t[26]=d):d=t[26];let f;t[27]!==u||t[28]!==d?(f=(0,Y.jsxs)(`div`,{ref:n,className:`relative overflow-hidden rounded-xl border border-border/80 bg-popover/96 shadow-lg/8 backdrop-blur-xs`,children:[u,d]}),t[27]=u,t[28]=d,t[29]=f):f=t[29];let p;return t[30]!==c||t[31]!==f?(p=(0,Y.jsx)(Xo,{autoHighlight:!1,mode:`none`,onItemHighlighted:c,children:f}),t[30]=c,t[31]=f,t[32]=p):p=t[32],p}),Mf=(0,q.memo)(function(e){let t=(0,J.c)(46),n;t[0]!==e.item.skill||t[1]!==e.item.type?(n=e.item.type===`skill`?na(e.item.skill):null,t[0]=e.item.skill,t[1]=e.item.type,t[2]=n):n=t[2];let r=n,i=e.item.id,a=e.item.id,o=e.isActive&&`bg-accent! text-accent-foreground!`,s;t[3]===o?s=t[4]:(s=G(`cursor-pointer select-none gap-2 hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit`,o),t[3]=o,t[4]=s);let c;t[5]===e?c=t[6]:(c=()=>{e.isActive||e.onHighlight(e.item.id)},t[5]=e,t[6]=c);let l;t[7]===e?l=t[8]:(l=()=>{e.onSelect(e.item)},t[7]=e,t[8]=l);let u;t[9]!==e.item.path||t[10]!==e.item.pathKind||t[11]!==e.item.type||t[12]!==e.resolvedTheme?(u=e.item.type===`path`?(0,Y.jsx)(ha,{pathValue:e.item.path,kind:e.item.pathKind,theme:e.resolvedTheme}):null,t[9]=e.item.path,t[10]=e.item.pathKind,t[11]=e.item.type,t[12]=e.resolvedTheme,t[13]=u):u=t[13];let d;t[14]===e.item.type?d=t[15]:(d=e.item.type===`slash-command`?(0,Y.jsx)(Jr,{className:`size-4 shrink-0 text-muted-foreground/80`}):null,t[14]=e.item.type,t[15]=d);let f;t[16]===e.item.type?f=t[17]:(f=e.item.type===`provider-slash-command`?(0,Y.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center text-muted-foreground/80`,children:(0,Y.jsx)(kf,{className:`size-3.5`})}):null,t[16]=e.item.type,t[17]=f);let p;t[18]===e.item.type?p=t[19]:(p=e.item.type===`skill`?(0,Y.jsx)(`span`,{className:`inline-flex size-4 shrink-0 items-center justify-center text-muted-foreground/80`,children:(0,Y.jsx)(kf,{className:`size-3.5`})}):null,t[18]=e.item.type,t[19]=p);let m;t[20]===e.item.type?m=t[21]:(m=e.item.type===`source-control-issue`?(0,Y.jsx)(yr,{className:`size-4 shrink-0 text-muted-foreground/80`}):null,t[20]=e.item.type,t[21]=m);let h;t[22]===e.item.type?h=t[23]:(h=e.item.type===`source-control-pr`?(0,Y.jsx)(Xi,{className:`size-4 shrink-0 text-muted-foreground/80`}):null,t[22]=e.item.type,t[23]=h);let g;t[24]===e.item.label?g=t[25]:(g=(0,Y.jsx)(`span`,{className:`shrink-0`,children:e.item.label}),t[24]=e.item.label,t[25]=g);let _;t[26]===e.item.description?_=t[27]:(_=(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground/70 text-xs`,children:e.item.description}),t[26]=e.item.description,t[27]=_);let v;t[28]!==g||t[29]!==_?(v=(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[g,_]}),t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;t[31]===r?y=t[32]:(y=r?(0,Y.jsx)(`span`,{className:`shrink-0 pl-2 text-muted-foreground/70 text-xs`,children:r}):null,t[31]=r,t[32]=y);let b;return t[33]!==e.item.id||t[34]!==p||t[35]!==m||t[36]!==h||t[37]!==v||t[38]!==y||t[39]!==s||t[40]!==c||t[41]!==l||t[42]!==u||t[43]!==d||t[44]!==f?(b=(0,Y.jsxs)(Zo,{value:i,"data-composer-item-id":a,className:s,onMouseMove:c,onMouseDown:Nf,onClick:l,children:[u,d,f,p,m,h,v,y]}),t[33]=e.item.id,t[34]=p,t[35]=m,t[36]=h,t[37]=v,t[38]=y,t[39]=s,t[40]=c,t[41]=l,t[42]=u,t[43]=d,t[44]=f,t[45]=b):b=t[45],b});function Nf(e){e.preventDefault()}var Pf=120,Ff=[];function If(e){let t=(0,J.c)(55),{composerTrigger:n,environmentId:r,gitCwd:i,selectedProvider:a,selectedProviderStatus:o,composerHighlightedItemId:s,composerHighlightedSearchKey:c}=e,l=n?.kind??null,u=n?.kind===`path`?n.query:``,d=l===`path`,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={wait:Pf},t[0]=f):f=t[0];let[p,m]=it(u,f,Rf),h=u.length>0?p:``,g;t[1]!==h||t[2]!==r||t[3]!==i||t[4]!==d?(g={environmentId:r,cwd:i,query:h,enabled:d,limit:80},t[1]=h,t[2]=r,t[3]=i,t[4]=d,t[5]=g):g=t[5];let _=jr(g),v=_.data?.entries??Ff,y=l===`source-control`,b;t[6]!==r||t[7]!==i||t[8]!==y?(b={environmentId:r,cwd:i,state:`open`,limit:50,enabled:y},t[6]=r,t[7]=i,t[8]=y,t[9]=b):b=t[9];let x=tr(b),S;t[10]!==r||t[11]!==i||t[12]!==y?(S={environmentId:r,cwd:i,state:`open`,limit:50,enabled:y},t[10]=r,t[11]=i,t[12]=y,t[13]=S):S=t[13];let C=$n(S),w;if(t[14]!==C.data||t[15]!==n||t[16]!==x.data||t[17]!==a||t[18]!==o?.skills||t[19]!==o?.slashCommands||t[20]!==v){bb0:{if(!n){let e;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[22]=e):e=t[22],w=e;break bb0}if(n.kind===`path`){let e;t[23]===v?e=t[24]:(e=v.map(Lf),t[23]=v,t[24]=e),w=e;break bb0}if(n.kind===`slash-command`){let e=[{id:`slash:model`,type:`slash-command`,command:`model`,label:`/model`,description:`Switch response model for this thread`},{id:`slash:goal`,type:`slash-command`,command:`goal`,label:`/goal`,description:`Set a persistent goal for this thread`},{id:`slash:plan`,type:`slash-command`,command:`plan`,label:`/plan`,description:`Switch this thread into plan mode`},{id:`slash:default`,type:`slash-command`,command:`default`,label:`/default`,description:`Switch this thread back to normal build mode`}],r;t[25]===a?r=t[26]:(r=e=>({id:`provider-slash-command:${a}:${e.name}`,type:`provider-slash-command`,provider:a,command:e,label:`/${e.name}`,description:e.description??e.input?.hint??`Run provider command`}),t[25]=a,t[26]=r);let i=(o?.slashCommands??[]).map(r),s=n.query.trim().toLowerCase(),c=[...e,...i];if(!s){w=c;break bb0}w=Ef(c,s);break bb0}if(n.kind===`skill`){let e;if(t[27]!==n.query||t[28]!==a||t[29]!==o?.skills){let r;t[31]===a?r=t[32]:(r=e=>({id:`skill:${a}:${e.name}`,type:`skill`,provider:a,skill:e,label:ea(e),description:e.shortDescription??e.description??(e.scope?`${e.scope} skill`:`Run provider skill`)}),t[31]=a,t[32]=r),e=Of(o?.skills??[],n.query).map(r),t[27]=n.query,t[28]=a,t[29]=o?.skills,t[30]=e}else e=t[30];w=e;break bb0}if(n.kind===`source-control`){let e;t[33]!==C.data||t[34]!==n.query||t[35]!==x.data?(e=[...Sf(n.query,{issues:x.data??[],prs:C.data??[]})],t[33]=C.data,t[34]=n.query,t[35]=x.data,t[36]=e):e=t[36],w=e;break bb0}let e;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[37]=e):e=t[37],w=e}t[14]=C.data,t[15]=n,t[16]=x.data,t[17]=a,t[18]=o?.skills,t[19]=o?.slashCommands,t[20]=v,t[21]=w}else w=t[21];let T=w,E=!!n,D;t[38]===n?D=t[39]:(D=n?`${n.kind}:${n.query.trim().toLowerCase()}`:null,t[38]=n,t[39]=D);let O=D,k;t[40]!==s||t[41]!==c||t[42]!==T||t[43]!==O?(k=wf({items:T,highlightedItemId:s,currentSearchKey:O,highlightedSearchKey:c}),t[40]=s,t[41]=c,t[42]=T,t[43]=O,t[44]=k):k=t[44];let A=k,j;t[45]!==A||t[46]!==T?(j=T.find(e=>e.id===A)??null,t[45]=A,t[46]=T,t[47]=j):j=t[47];let M=j,N=l===`path`&&(u.length>0&&m.state.isPending||_.isLoading||_.isFetching)||l===`source-control`&&(x.isLoading||C.isLoading),P;bb1:{if(l===`skill`){P=`No skills found. Try / to browse provider commands.`;break bb1}if(l===`source-control`){P=`No matching issues or pull requests.`;break bb1}P=l===`path`?`No matching files or folders.`:`No matching command.`}let F=P,I;return t[48]!==M||t[49]!==F||t[50]!==T||t[51]!==E||t[52]!==O||t[53]!==N?(I={composerMenuItems:T,composerMenuOpen:E,composerMenuSearchKey:O,activeComposerMenuItem:M,isComposerMenuLoading:N,composerMenuEmptyState:F},t[48]=M,t[49]=F,t[50]=T,t[51]=E,t[52]=O,t[53]=N,t[54]=I):I=t[54],I}function Lf(e){return{id:`path:${e.kind}:${e.path}`,type:`path`,path:e.path,pathKind:e.kind,label:Yc(e.path),description:e.parentPath??``}}function Rf(e){return{isPending:e.isPending}}function zf(e){let{environmentId:t,gitCwd:n,composerDraftTarget:r,addSourceControlContext:i}=e;return{handleSelectIssue:(0,q.useCallback)(async e=>{if(!t||!n)return;let a=`${e.provider}#${e.number}`;try{let o=await or({environmentId:t,cwd:n,reference:String(e.number)}),s=R(new Date),c=R(new Date(Date.now()+3e5)),l={id:io(),kind:`issue`,provider:e.provider,reference:a,detail:o,fetchedAt:s,staleAfter:c},u=i(r,l);!u.added&&u.reason===`duplicate`&&Ai.add({type:`info`,title:`Already attached.`})}catch(e){let t=e instanceof Error?e.message:`unknown error`;Ai.add({type:`error`,title:`Couldn't fetch ${a}: ${t}`})}},[t,n,r,i]),handleSelectChangeRequest:(0,q.useCallback)(async e=>{if(!t||!n)return;let a=`${e.provider}#${e.number}`;try{let o=await rr({environmentId:t,cwd:n,reference:String(e.number)}),s=R(new Date),c=R(new Date(Date.now()+3e5)),l={id:io(),kind:`change-request`,provider:e.provider,reference:a,detail:o,fetchedAt:s,staleAfter:c},u=i(r,l);!u.added&&u.reason===`duplicate`&&Ai.add({type:`info`,title:`Already attached.`})}catch(e){let t=e instanceof Error?e.message:`unknown error`;Ai.add({type:`error`,title:`Couldn't fetch ${a}: ${t}`})}},[t,n,r,i])}}function Bf(e){let t=(0,J.c)(10);if(!e.open)return null;let n;return t[0]!==e.activeItemId||t[1]!==e.emptyStateText||t[2]!==e.groupSlashCommandSections||t[3]!==e.isLoading||t[4]!==e.items||t[5]!==e.onHighlightedItemChange||t[6]!==e.onSelect||t[7]!==e.resolvedTheme||t[8]!==e.triggerKind?(n=(0,Y.jsx)(`div`,{className:`absolute inset-x-0 bottom-full z-20 mb-2 px-1`,children:(0,Y.jsx)(jf,{items:e.items,resolvedTheme:e.resolvedTheme,isLoading:e.isLoading,triggerKind:e.triggerKind,groupSlashCommandSections:e.groupSlashCommandSections,emptyStateText:e.emptyStateText,activeItemId:e.activeItemId,onHighlightedItemChange:e.onHighlightedItemChange,onSelect:e.onSelect})}),t[0]=e.activeItemId,t[1]=e.emptyStateText,t[2]=e.groupSlashCommandSections,t[3]=e.isLoading,t[4]=e.items,t[5]=e.onHighlightedItemChange,t[6]=e.onSelect,t[7]=e.resolvedTheme,t[8]=e.triggerKind,t[9]=n):n=t[9],n}function Vf(e,t){let n=t?.hasWideActions?780:620;return e!==null&&e<n}function Hf(e,t){return t?.hasWideActions?e!==null&&e<780:!1}var Uf=(0,q.memo)(function(e){let t=(0,J.c)(33),{requestId:n,isResponding:r,onRespondToApproval:i}=e,a=Ms(x.dispatchCommand),o=r||!a.allowed,s=a.reason??void 0,c;t[0]!==i||t[1]!==n?(c=()=>void i(n,`cancel`),t[0]=i,t[1]=n,t[2]=c):c=t[2];let l;t[3]!==o||t[4]!==s||t[5]!==c?(l=(0,Y.jsx)(K,{size:`sm`,variant:`ghost`,disabled:o,title:s,onClick:c,children:`Cancel turn`}),t[3]=o,t[4]=s,t[5]=c,t[6]=l):l=t[6];let u=a.reason??void 0,d;t[7]!==i||t[8]!==n?(d=()=>void i(n,`decline`),t[7]=i,t[8]=n,t[9]=d):d=t[9];let f;t[10]!==o||t[11]!==u||t[12]!==d?(f=(0,Y.jsx)(K,{size:`sm`,variant:`destructive-outline`,disabled:o,title:u,onClick:d,children:`Decline`}),t[10]=o,t[11]=u,t[12]=d,t[13]=f):f=t[13];let p=a.reason??void 0,m;t[14]!==i||t[15]!==n?(m=()=>void i(n,`acceptForSession`),t[14]=i,t[15]=n,t[16]=m):m=t[16];let h;t[17]!==o||t[18]!==p||t[19]!==m?(h=(0,Y.jsx)(K,{size:`sm`,variant:`outline`,disabled:o,title:p,onClick:m,children:`Always allow this session`}),t[17]=o,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g=a.reason??void 0,_;t[21]!==i||t[22]!==n?(_=()=>void i(n,`accept`),t[21]=i,t[22]=n,t[23]=_):_=t[23];let v;t[24]!==o||t[25]!==g||t[26]!==_?(v=(0,Y.jsx)(K,{size:`sm`,variant:`default`,disabled:o,title:g,onClick:_,children:`Approve once`}),t[24]=o,t[25]=g,t[26]=_,t[27]=v):v=t[27];let y;return t[28]!==v||t[29]!==l||t[30]!==f||t[31]!==h?(y=(0,Y.jsxs)(Y.Fragment,{children:[l,f,h,v]}),t[28]=v,t[29]=l,t[30]=f,t[31]=h,t[32]=y):y=t[32],y});function Wf(e){return e.requestKind===`command`?`Command approval requested`:e.requestKind===`file-read`?`File-read approval requested`:`File-change approval requested`}var Gf=(0,q.memo)(function(e){let t=(0,J.c)(15),{approval:n,pendingCount:r}=e,i;t[0]===n?i=t[1]:(i=Wf(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Y.jsx)(`span`,{className:`uppercase text-sm tracking-[0.2em]`,children:`PENDING APPROVAL`}),t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:a}),t[3]=a,t[4]=s);let c;t[5]===r?c=t[6]:(c=r>1?(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`1/`,r]}):null,t[5]=r,t[6]=c);let l;t[7]!==s||t[8]!==c?(l=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o,s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9];let u;t[10]===n.detail?u=t[11]:(u=n.detail?(0,Y.jsx)(`div`,{"data-testid":`pending-approval-detail`,className:`mt-2 max-h-[min(10rem,20dvh)] min-h-0 overflow-y-auto overscroll-contain whitespace-pre-wrap wrap-break-word text-sm text-muted-foreground select-text`,children:n.detail}):null,t[10]=n.detail,t[11]=u);let d;return t[12]!==l||t[13]!==u?(d=(0,Y.jsxs)(`div`,{className:`px-4 py-3.5 sm:px-5 sm:py-4`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14],d}),Kf=(0,q.memo)(function(e){let t=(0,J.c)(43),{approval:n,pendingCount:r,isResponding:i,onRespondToApproval:a}=e,o=Rs(),[s,c]=(0,q.useState)(null),l=o===`phone`&&s===n.requestId;o!==`phone`&&s!==null&&c(null);let u;t[0]!==n.requestId||t[1]!==i||t[2]!==a?(u=(0,Y.jsx)(Uf,{requestId:n.requestId,isResponding:i,onRespondToApproval:a}),t[0]=n.requestId,t[1]=i,t[2]=a,t[3]=u):u=t[3];let d=u,f;t[4]===n?f=t[5]:(f=Wf(n),t[4]=n,t[5]=f);let p;t[6]===f?p=t[7]:(p=(0,Y.jsx)(`p`,{role:`alert`,className:`sr-only`,children:f}),t[6]=f,t[7]=p);let m;t[8]!==n||t[9]!==r?(m=(0,Y.jsx)(Gf,{approval:n,pendingCount:r}),t[8]=n,t[9]=r,t[10]=m):m=t[10];let h;t[11]!==n.detail||t[12]!==n.requestId||t[13]!==o?(h=o===`phone`&&n.detail?(0,Y.jsx)(`div`,{className:`px-4 pb-1 sm:px-5`,children:(0,Y.jsxs)(K,{size:`sm`,variant:`ghost`,className:`min-h-11 text-muted-foreground`,onClick:()=>c(n.requestId),children:[(0,Y.jsx)(yl,{"aria-hidden":!0}),` Show full detail`]})}):null,t[11]=n.detail,t[12]=n.requestId,t[13]=o,t[14]=h):h=t[14];let g;t[15]!==d||t[16]!==l?(g=l?null:(0,Y.jsx)(`div`,{"data-testid":`approval-card-actions`,className:`flex flex-wrap items-center justify-end gap-2 px-3 pb-3 sm:px-4`,children:d}),t[15]=d,t[16]=l,t[17]=g):g=t[17];let _;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{e||c(null)},t[18]=_):_=t[18];let v;t[19]===n?v=t[20]:(v=Wf(n),t[19]=n,t[20]=v);let y;t[21]===v?y=t[22]:(y=(0,Y.jsx)(Rc,{children:v}),t[21]=v,t[22]=y);let b;t[23]===r?b=t[24]:(b=r>1?(0,Y.jsxs)(Lc,{children:[`1/`,r,` pending approvals`]}):(0,Y.jsx)(Lc,{className:`sr-only`,children:`Full approval detail`}),t[23]=r,t[24]=b);let x;t[25]!==b||t[26]!==y?(x=(0,Y.jsxs)(Ic,{children:[y,b]}),t[25]=b,t[26]=y,t[27]=x):x=t[27];let S;t[28]===n.detail?S=t[29]:(S=(0,Y.jsx)(Pc,{children:(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap wrap-break-word text-sm text-muted-foreground select-text`,children:n.detail})}),t[28]=n.detail,t[29]=S);let C;t[30]===d?C=t[31]:(C=(0,Y.jsx)(zc,{className:`flex-row flex-wrap justify-end gap-2`,"data-testid":`approval-card-actions`,children:d}),t[30]=d,t[31]=C);let w;t[32]!==l||t[33]!==x||t[34]!==S||t[35]!==C?(w=(0,Y.jsxs)(Vc,{open:l,onOpenChange:_,label:`Approval detail`,children:[x,S,C]}),t[32]=l,t[33]=x,t[34]=S,t[35]=C,t[36]=w):w=t[36];let T;return t[37]!==w||t[38]!==p||t[39]!==m||t[40]!==h||t[41]!==g?(T=(0,Y.jsxs)(`div`,{"data-testid":`approval-card`,children:[p,m,h,g,w]}),t[37]=w,t[38]=p,t[39]=m,t[40]=h,t[41]=g,t[42]=T):T=t[42],T});function qf(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Jf(e){if(!Array.isArray(e))return[];let t=e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0);return Array.from(new Set(t))}function Yf(e,t){let n=qf(t?.customAnswer);if(n)return n;let r=Jf(t?.selectedOptionLabels);return e.multiSelect?r.length>0?r:null:r[0]??null}function Xf(e,t){let n=t.trim().length>0?void 0:Jf(e?.selectedOptionLabels);return{customAnswer:t,...n&&n.length>0?{selectedOptionLabels:n}:{}}}function Zf(e,t,n){if(e.multiSelect){let e=Jf(t?.selectedOptionLabels),r=e.includes(n)?e.filter(e=>e!==n):[...e,n];return{customAnswer:``,...r.length>0?{selectedOptionLabels:r}:{}}}return{customAnswer:``,selectedOptionLabels:[n]}}function Qf(e,t){let n={};for(let r of e){let e=Yf(r,t[r.id]);if(!e)return null;n[r.id]=e}return n}function $f(e,t){return e.reduce((e,n)=>Yf(n,t[n.id])?e+1:e,0)}function ep(e,t,n){let r=e.length===0?0:Math.max(0,Math.min(n,e.length-1)),i=e[r]??null,a=i?t[i.id]:void 0,o=i?Yf(i,a):null,s=a?.customAnswer??``,c=$f(e,t),l=e.length===0||r>=e.length-1;return{questionIndex:r,activeQuestion:i,activeDraft:a,selectedOptionLabels:Jf(a?.selectedOptionLabels),customAnswer:s,resolvedAnswer:o,usingCustomAnswer:s.trim().length>0,answeredQuestionCount:c,isLastQuestion:l,isComplete:Qf(e,t)!==null,canAdvance:!!o}}var tp=(0,q.memo)(function(e){let t=(0,J.c)(10),{pendingUserInputs:n,respondingRequestIds:r,answers:i,questionIndex:a,onToggleOption:o,onAdvance:s}=e;if(n.length===0)return null;let c=n[0];if(!c)return null;let l=c.requestId,u;t[0]!==c.requestId||t[1]!==r?(u=r.includes(c.requestId),t[0]=c.requestId,t[1]=r,t[2]=u):u=t[2];let d;return t[3]!==c||t[4]!==i||t[5]!==s||t[6]!==o||t[7]!==a||t[8]!==u?(d=(0,Y.jsx)(np,{prompt:c,isResponding:u,answers:i,questionIndex:a,onToggleOption:o,onAdvance:s},l),t[3]=c,t[4]=i,t[5]=s,t[6]=o,t[7]=a,t[8]=u,t[9]=d):d=t[9],d}),np=(0,q.memo)(function(e){let t=(0,J.c)(25),{prompt:n,isResponding:r,answers:i,questionIndex:a,onToggleOption:o,onAdvance:s}=e,c=ep(n.questions,i,a),l=c.activeQuestion,u=(0,q.useRef)(null),d=(0,q.useRef)(s),f,p;t[0]===s?(f=t[1],p=t[2]):(f=()=>{d.current=s},p=[s],t[0]=s,t[1]=f,t[2]=p),(0,q.useEffect)(f,p);let m,h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>()=>{u.current!==null&&window.clearTimeout(u.current)},h=[],t[3]=m,t[4]=h):(m=t[3],h=t[4]),(0,q.useEffect)(m,h);let g=(0,q.useEffectEvent)((e,t)=>{o(e,t),!l?.multiSelect&&(u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{u.current=null,d.current()},200))}),_;if(t[5]!==l||t[6]!==r?(_=[l,r],t[5]=l,t[6]=r,t[7]=_):_=t[7],(0,q.useEffect)(()=>{if(!l||r)return;let e=e=>{if(Mo(e)||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLElement&&t.closest(`[contenteditable]:not([contenteditable="false"])`))return;let n=Number.parseInt(e.key,10);if(Number.isNaN(n)||n<1||n>9)return;let r=n-1;if(r>=l.options.length)return;let i=l.options[r];i&&(e.preventDefault(),g(l.id,i.label))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},_),!l)return null;let v;t[8]!==n.questions.length||t[9]!==a?(v=n.questions.length>1?(0,Y.jsxs)(`span`,{className:`flex h-5 items-center rounded-md bg-muted/60 px-1.5 text-[10px] font-medium tabular-nums text-muted-foreground/60`,children:[a+1,`/`,n.questions.length]}):null,t[8]=n.questions.length,t[9]=a,t[10]=v):v=t[10];let y;t[11]===l?y=t[12]:(y=(0,Y.jsx)(`span`,{className:`text-[11px] font-semibold tracking-widest text-muted-foreground/50 uppercase`,children:l.header}),t[11]=l,t[12]=y);let b;t[13]!==v||t[14]!==y?(b=(0,Y.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,y]})}),t[13]=v,t[14]=y,t[15]=b):b=t[15];let x;t[16]===l?x=t[17]:(x=(0,Y.jsx)(`p`,{className:`mt-1.5 text-sm text-foreground/90`,children:l.question}),t[16]=l,t[17]=x);let S=l.multiSelect?(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/65`,children:`Select one or more options.`}):null,C=l.options.map((e,t)=>{let n=c.selectedOptionLabels.includes(e.label),i=t<9?t+1:null;return(0,Y.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>g(l.id,e.label),className:G(`group flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-all duration-150`,n?`border-blue-500/40 bg-blue-500/8 text-foreground`:`border-transparent bg-muted/20 text-foreground/80 hover:bg-muted/40 hover:border-border/40`,r&&`opacity-50 cursor-not-allowed`),children:[i===null?null:(0,Y.jsx)(`kbd`,{className:G(`flex size-5 shrink-0 items-center justify-center rounded text-[11px] font-medium tabular-nums transition-colors duration-150 pointer-coarse:hidden`,n?`bg-blue-500/20 text-blue-400`:`bg-muted/40 text-muted-foreground/50 group-hover:bg-muted/60 group-hover:text-muted-foreground/70`),children:i}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),e.description&&e.description!==e.label?(0,Y.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground/50`,children:e.description}):null]}),n?(0,Y.jsx)(Yr,{className:`size-3.5 shrink-0 text-blue-400`}):null]},`${l.id}:${e.label}`)}),w;t[18]===C?w=t[19]:(w=(0,Y.jsx)(`div`,{className:`mt-3 space-y-1`,children:C}),t[18]=C,t[19]=w);let T;return t[20]!==x||t[21]!==S||t[22]!==w||t[23]!==b?(T=(0,Y.jsxs)(`div`,{className:`px-4 py-3 sm:px-5`,children:[b,x,S,w]}),t[20]=x,t[21]=S,t[22]=w,t[23]=b,t[24]=T):T=t[24],T}),rp=(0,q.memo)(function(e){let t=(0,J.c)(5),{planTitle:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Y.jsx)(`span`,{className:`uppercase text-sm tracking-[0.2em]`,children:`Plan ready`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=n?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}):null,t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,Y.jsx)(`div`,{className:`px-4 py-3.5 sm:px-5 sm:py-4`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r,i]})}),t[3]=i,t[4]=a),a}),ip=(0,q.memo)(function(e){let t=(0,J.c)(24),n=typeof e.descriptor.currentValue==`string`?e.descriptor.currentValue:``,r;t[0]!==e.descriptor.options||t[1]!==n?(r=e.descriptor.options.find(e=>e.id===n)?.label??n,t[0]=e.descriptor.options,t[1]=n,t[2]=r):r=t[2];let i=r,a=e.disabled??!1,o=`Agent: ${i}`,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=G(`gap-1 rounded-md px-1.5 font-medium`,`bg-muted/40 text-muted-foreground`),t[3]=s):s=t[3];let c;t[4]!==a||t[5]!==o?(c=(0,Y.jsx)(K,{size:`xs`,disabled:a,variant:`ghost`,"aria-label":o,title:`Agent`,className:s}),t[4]=a,t[5]=o,t[6]=c):c=t[6];let l;t[7]===i?l=t[8]:(l=(0,Y.jsx)(`span`,{children:i}),t[7]=i,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,Y.jsx)(oc,{render:c,children:l}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==e||t[13]!==n?(d=t=>{!t||t===n||e.onChangeDescriptors(ms(e.descriptors,e.descriptor.id,t))},t[12]=e,t[13]=n,t[14]=d):d=t[14];let f;t[15]===e.descriptor.options?f=t[16]:(f=e.descriptor.options.map(ap),t[15]=e.descriptor.options,t[16]=f);let p;t[17]!==d||t[18]!==f||t[19]!==n?(p=(0,Y.jsx)(ec,{align:`start`,children:(0,Y.jsx)(ic,{value:n,onValueChange:d,children:f})}),t[17]=d,t[18]=f,t[19]=n,t[20]=p):p=t[20];let m;return t[21]!==u||t[22]!==p?(m=(0,Y.jsxs)(rc,{children:[u,p]}),t[21]=u,t[22]=p,t[23]=m):m=t[23],m});function ap(e){return(0,Y.jsxs)(cc,{value:e.id,children:[e.label,e.isDefault?` (default)`:``]},e.id)}var op=(0,q.memo)(function(e){let t=(0,J.c)(24),n=typeof e.descriptor.currentValue==`string`?e.descriptor.currentValue:``,r;t[0]!==e.descriptor.options||t[1]!==n?(r=e.descriptor.options.find(e=>e.id===n)?.label??n,t[0]=e.descriptor.options,t[1]=n,t[2]=r):r=t[2];let i=r,a=e.disabled??!1,o=`Context window: ${i}`,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=G(`gap-1 rounded-md px-1.5 font-medium`,`bg-muted/40 text-muted-foreground`),t[3]=s):s=t[3];let c;t[4]!==a||t[5]!==o?(c=(0,Y.jsx)(K,{size:`xs`,disabled:a,variant:`ghost`,"aria-label":o,title:`Context window`,className:s}),t[4]=a,t[5]=o,t[6]=c):c=t[6];let l;t[7]===i?l=t[8]:(l=(0,Y.jsx)(`span`,{children:i}),t[7]=i,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,Y.jsx)(oc,{render:c,children:l}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==e||t[13]!==n?(d=t=>{!t||t===n||e.onChangeDescriptors(ms(e.descriptors,e.descriptor.id,t))},t[12]=e,t[13]=n,t[14]=d):d=t[14];let f;t[15]===e.descriptor.options?f=t[16]:(f=e.descriptor.options.map(sp),t[15]=e.descriptor.options,t[16]=f);let p;t[17]!==d||t[18]!==f||t[19]!==n?(p=(0,Y.jsx)(ec,{align:`start`,children:(0,Y.jsx)(ic,{value:n,onValueChange:d,children:f})}),t[17]=d,t[18]=f,t[19]=n,t[20]=p):p=t[20];let m;return t[21]!==u||t[22]!==p?(m=(0,Y.jsxs)(rc,{children:[u,p]}),t[21]=u,t[22]=p,t[23]=m):m=t[23],m});function sp(e){return(0,Y.jsxs)(cc,{value:e.id,children:[e.label,e.isDefault?` (default)`:``]},e.id)}var cp=(0,q.memo)(function(e){let t=(0,J.c)(20),n=e.descriptor.currentValue===!0,r=e.disabled??!1,i;t[0]!==n||t[1]!==e?(i=()=>{e.disabled||e.onChangeDescriptors(ms(e.descriptors,e.descriptor.id,!n))},t[0]=n,t[1]=e,t[2]=i):i=t[2];let a=n?`bg-yellow-500/15 text-yellow-800 hover:bg-yellow-500/25 dark:bg-yellow-500/20 dark:text-yellow-300 dark:hover:bg-yellow-500/30`:`text-muted-foreground/60 ring-1 ring-border ring-inset hover:bg-accent hover:text-foreground`,o;t[3]===a?o=t[4]:(o=G(`inline-flex h-7 cursor-pointer items-center justify-center gap-1 rounded-md px-1.5 font-medium text-xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 sm:h-6 sm:text-[11px]`,a),t[3]=a,t[4]=o);let s=n?`fill-current`:void 0,c;t[5]===s?c=t[6]:(c=G(`size-3`,s),t[5]=s,t[6]=c);let l;t[7]===c?l=t[8]:(l=(0,Y.jsx)(Ml,{"aria-hidden":`true`,className:c}),t[7]=c,t[8]=l);let u;t[9]!==n||t[10]!==r||t[11]!==i||t[12]!==o||t[13]!==l?(u=(0,Y.jsx)(Fo,{render:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Fast mode`,"aria-pressed":n,disabled:r,onClick:i,className:o,children:l})}),t[9]=n,t[10]=r,t[11]=i,t[12]=o,t[13]=l,t[14]=u):u=t[14];let d=n?`Fast mode on — click to disable`:`Fast mode off — click to enable`,f;t[15]===d?f=t[16]:(f=(0,Y.jsx)(Io,{side:`top`,children:d}),t[15]=d,t[16]=f);let p;return t[17]!==u||t[18]!==f?(p=(0,Y.jsxs)(Lo,{children:[u,f]}),t[17]=u,t[18]=f,t[19]=p):p=t[19],p}),lp=(0,q.memo)(function(e){let t=(0,J.c)(25),n=typeof e.descriptor.currentValue==`string`?e.descriptor.currentValue:``,r;t[0]!==e.descriptor.options||t[1]!==n?(r=e.descriptor.options.find(e=>e.id===n)?.label??n,t[0]=e.descriptor.options,t[1]=n,t[2]=r):r=t[2];let i=r,a=`${e.descriptor.label}: ${i}`,o=e.disabled??!1,s=e.descriptor.label,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=G(`gap-1 rounded-md px-1.5 font-medium`,`bg-muted/40 text-muted-foreground`),t[3]=c):c=t[3];let l;t[4]!==a||t[5]!==e.descriptor.label||t[6]!==o?(l=(0,Y.jsx)(K,{size:`xs`,disabled:o,variant:`ghost`,"aria-label":a,title:s,className:c}),t[4]=a,t[5]=e.descriptor.label,t[6]=o,t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=(0,Y.jsx)(`span`,{children:i}),t[8]=i,t[9]=u);let d;t[10]!==l||t[11]!==u?(d=(0,Y.jsx)(oc,{render:l,children:u}),t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==e||t[14]!==n?(f=t=>{!t||t===n||e.onChangeDescriptors(ms(e.descriptors,e.descriptor.id,t))},t[13]=e,t[14]=n,t[15]=f):f=t[15];let p;t[16]===e.descriptor.options?p=t[17]:(p=e.descriptor.options.map(up),t[16]=e.descriptor.options,t[17]=p);let m;t[18]!==f||t[19]!==p||t[20]!==n?(m=(0,Y.jsx)(ec,{align:`start`,children:(0,Y.jsx)(ic,{value:n,onValueChange:f,children:p})}),t[18]=f,t[19]=p,t[20]=n,t[21]=m):m=t[21];let h;return t[22]!==d||t[23]!==m?(h=(0,Y.jsxs)(rc,{children:[d,m]}),t[22]=d,t[23]=m,t[24]=h):h=t[24],h});function up(e){return(0,Y.jsxs)(cc,{value:e.id,children:[e.label,e.isDefault?` (default)`:``]},e.id)}var dp=(0,q.memo)(function(e){let t=(0,J.c)(12),n=e.descriptor.currentValue===!0,r=e.disabled??!1,i=n?`Thinking: on (click to disable)`:`Thinking: off (click to enable)`,a=n?`bg-sky-500/15 text-sky-800 dark:bg-sky-500/20 dark:text-sky-300`:`text-muted-foreground/60 ring-1 ring-border ring-inset hover:text-foreground`,o;t[0]===a?o=t[1]:(o=G(`gap-1 rounded-md px-1.5 font-medium`,a),t[0]=a,t[1]=o);let s;t[2]!==n||t[3]!==e?(s=()=>{e.onChangeDescriptors(ms(e.descriptors,e.descriptor.id,!n))},t[2]=n,t[3]=e,t[4]=s):s=t[4];let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Y.jsx)(ml,{"aria-hidden":`true`,className:`size-3`}),t[5]=c):c=t[5];let l;return t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==o||t[10]!==s?(l=(0,Y.jsx)(K,{size:`xs`,disabled:r,variant:`ghost`,"aria-label":`Thinking`,"aria-pressed":n,title:i,className:o,onClick:s,children:c}),t[6]=n,t[7]=r,t[8]=i,t[9]=o,t[10]=s,t[11]=l):l=t[11],l}),fp=new Set([`effort`,`reasoningEffort`,`reasoning`]),pp=new Set([...fp,`contextWindow`,`agent`]),mp=(0,q.memo)(function(e){let t=(0,J.c)(40),n=Jt(hp),r;t[0]!==e||t[1]!==n?(r=t=>{if(e.disabled)return;if(`onModelOptionsChange`in e&&typeof e.onModelOptionsChange==`function`){e.onModelOptionsChange(t);return}let r=e.threadRef??e.draftId;r&&n(r,e.provider,t,{...e.instanceId?{instanceId:e.instanceId}:{},model:e.model,persistSticky:!0})},t[0]=e,t[1]=n,t[2]=r):r=t[2];let i=r,a,o,s,c,l,u,d,f,p;if(t[3]!==e.disabled||t[4]!==e.disabledReason||t[5]!==e.model||t[6]!==e.modelOptions||t[7]!==e.models||t[8]!==e.onPromptChange||t[9]!==e.prompt||t[10]!==e.provider||t[11]!==i){p=Symbol.for(`react.early_return_sentinel`);bb0:{let n=at(e.models,e.model,e.provider),r=wt({caps:n,selections:e.modelOptions});if(r.length===0){p=null;break bb0}let m=r.find(gp),h=(m?.promptInjectedValues?.length??0)>0&&$t(e.prompt),g;t[21]!==e.prompt||t[22]!==h?(g=h&&$t(e.prompt.replace(/^Ultrathink:\s*/i,``)),t[21]=e.prompt,t[22]=h,t[23]=g):g=t[23];let _=g,v;t[24]===i?v=t[25]:(v=e=>{i(kt(e))},t[24]=i,t[25]=v);let y=v,b=e=>r.find(t=>t.id===e&&t.type===`select`),x=e=>r.find(t=>t.id===e&&t.type===`boolean`),S=r.find(_p),C=x(`fastMode`),w=b(`contextWindow`),T=x(`thinking`),E=b(`agent`),D=r.filter(vp),O=e.disabled??!1,k;t[26]!==O||t[27]!==e.disabledReason?(k=O&&e.disabledReason?Fc(e.disabledReason):null,t[26]=O,t[27]=e.disabledReason,t[28]=k):k=t[28],a=k,o=`flex flex-wrap items-center gap-1`,s=S?(0,Y.jsx)(fs,{descriptor:S,descriptors:r,prompt:e.prompt,primarySelectDescriptorId:m?.id,ultrathinkInBodyText:_,ultrathinkPromptControlled:h,onChangeDescriptors:y,onPromptChange:e.onPromptChange,disabled:O}):null,c=C?(0,Y.jsx)(cp,{descriptor:C,descriptors:r,onChangeDescriptors:y,disabled:O}):null,l=w?(0,Y.jsx)(op,{descriptor:w,descriptors:r,onChangeDescriptors:y,disabled:O}):null,u=T?(0,Y.jsx)(dp,{descriptor:T,descriptors:r,onChangeDescriptors:y,disabled:O}):null,d=E?(0,Y.jsx)(ip,{descriptor:E,descriptors:r,onChangeDescriptors:y,disabled:O}):null,f=D.map(e=>(0,Y.jsx)(lp,{descriptor:e,descriptors:r,onChangeDescriptors:y,disabled:O},e.id))}t[3]=e.disabled,t[4]=e.disabledReason,t[5]=e.model,t[6]=e.modelOptions,t[7]=e.models,t[8]=e.onPromptChange,t[9]=e.prompt,t[10]=e.provider,t[11]=i,t[12]=a,t[13]=o,t[14]=s,t[15]=c,t[16]=l,t[17]=u,t[18]=d,t[19]=f,t[20]=p}else a=t[12],o=t[13],s=t[14],c=t[15],l=t[16],u=t[17],d=t[18],f=t[19],p=t[20];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m;t[29]===a?m=t[30]:(m=a?(0,Y.jsx)(`span`,{className:`text-muted-foreground/80 text-xs`,"data-slot":`traits-disabled-reason`,children:a}):null,t[29]=a,t[30]=m);let h;return t[31]!==o||t[32]!==s||t[33]!==c||t[34]!==l||t[35]!==u||t[36]!==d||t[37]!==f||t[38]!==m?(h=(0,Y.jsxs)(`div`,{className:o,children:[s,c,l,u,d,f,m]}),t[31]=o,t[32]=s,t[33]=c,t[34]=l,t[35]=u,t[36]=d,t[37]=f,t[38]=m,t[39]=h):h=t[39],h});function hp(e){return e.setProviderModelOptions}function gp(e){return e.type===`select`}function _p(e){return e.type===`select`&&fp.has(e.id)}function vp(e){return e.type===`select`&&!pp.has(e.id)&&!fp.has(e.id)}function yp(e){let{provider:t,model:n,models:r,prompt:i,modelOptions:a}=e,o=at(r,n,t),s=wt({caps:o,selections:a}),c=s.find(e=>e.type===`select`),l=ft(c??null),u=typeof l==`string`?l:null,d=(c?.promptInjectedValues?.length??0)>0&&$t(i);return{provider:t,promptEffort:u,modelOptionsForDispatch:kt(s),...d?{composerFrameClassName:`ultrathink-frame`,composerSurfaceClassName:`shadow-[0_0_0_1px_rgba(255,255,255,0.04)_inset]`,modelPickerIconClassName:`ultrathink-chroma`}:{}}}function bp(e){let{provider:t,instanceId:n,threadRef:r,draftId:i,model:a,models:o,modelOptions:s,prompt:c,onPromptChange:l,disabled:u,disabledReason:d}=e;return r===void 0&&i===void 0||!ss({provider:t,models:o,model:a,modelOptions:s,prompt:c})?null:(0,Y.jsx)(ps,{disabled:u??!1,...d?{disabledReason:d}:{},provider:t,...n?{instanceId:n}:{},models:o,...r?{threadRef:r}:{},...i?{draftId:i}:{},model:a,modelOptions:s,prompt:c,onPromptChange:l})}function xp(e){let{provider:t,instanceId:n,threadRef:r,draftId:i,model:a,models:o,modelOptions:s,prompt:c,onPromptChange:l,disabled:u,disabledReason:d}=e;return r===void 0&&i===void 0||!ss({provider:t,models:o,model:a,modelOptions:s,prompt:c})?null:(0,Y.jsx)(mp,{disabled:u??!1,...d?{disabledReason:d}:{},provider:t,...n?{instanceId:n}:{},models:o,...r?{threadRef:r}:{},...i?{draftId:i}:{},model:a,modelOptions:s,prompt:c,onPromptChange:l})}var Sp=(0,q.createContext)(null);function Cp(e,t){let n=null;return e!=null&&(n=e[1]),{getTheme:function(){return t??(n==null?null:n.getTheme())}}}function wp(){let e=(0,q.useContext)(Sp);return e??function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),e}function X(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Tp(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var Ep=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Dp=Ep&&`documentMode`in document?document.documentMode:null,Op=Ep&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),kp=Ep&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Ap=!(!Ep||!(`InputEvent`in window)||Dp)&&`getTargetRanges`in new window.InputEvent(`input`),jp=Ep&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Mp=Ep&&/Android/.test(navigator.userAgent),Np=Ep&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Mp,Pp=Ep&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Fp=Ep&&Mp&&Pp,Ip=Ep&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Op&&!Pp,Lp=0,Rp=1,zp=2,Bp=1,Vp=2,Hp=3,Up=4,Wp=5,Gp=6,Kp=Np||jp||Ip?`\xA0`:``,qp=`
|
|
9
|
-
|
|
10
|
-
`,Jp=kp?`\xA0`:Kp,Yp={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Xp={directionless:1,unmergeable:2},Zp={center:2,end:6,justify:4,left:1,right:3,start:5},Qp={[Vp]:`center`,[Gp]:`end`,[Up]:`justify`,[Bp]:`left`,[Hp]:`right`,[Wp]:`start`},$p={normal:0,segmented:2,token:1},em={[Lp]:`normal`,[zp]:`segmented`,[Rp]:`token`},tm=`$config`;function nm(){return Mx()._blockCursorElement}function rm(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-slot`)}var im=class e{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}insertChild(e){let t=this.getInsertionAnchor();return t!==null&&t.parentElement!==this.element&&X(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&X(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&X(359),this.element.replaceChild(e,t),this}getFirstChild(){let e=this.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;return t===this.getInsertionAnchor()?null:t}getFirstChildAnchor(){return this.after}resolveLeafPosition(e,t,n){if(this.element===e)return t===e&&n===0?`before`:`after`;let r=am(e,this.element);if(r===null)return`after`;let i=Array.prototype.indexOf.call(e.childNodes,r);if(i<0)return`after`;if(t===e)return n<=i?`before`:`after`;let a=am(e,t);if(a===null)return`after`;let o=Array.prototype.indexOf.call(e.childNodes,a);return o>=0&&o<=i?`before`:`after`}getInsertionAnchor(){return this.before}};function am(e,t){let n=t;for(;n!==null&&n.parentNode!==e;)n=n.parentNode;return n}var om=class e extends im{withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()}getFirstChildAnchor(){let e=super.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;for(;rm(t);)e=t,t=t.nextSibling;let n=e?e.nextSibling:this.element.firstChild;return n!==null&&n===nm()?n:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(this.element.__lexicalLastChildKind=e,e===null)this.removeManagedLineBreak();else{let t=e===`decorator`&&(Ip||jp||Np);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){let e=this.getManagedLineBreak();if(e){let t=this.element,n=e.nodeName===`IMG`?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){let t=this.getManagedLineBreak();if(t){if(e===(t.nodeName===`IMG`))return;this.removeManagedLineBreak()}let n=this.element,r=this.before,i=mx().createElement(`br`);if(i.setAttribute(`data-lexical-managed-linebreak`,`true`),n.insertBefore(i,r),e){let e=mx().createElement(`img`);e.setAttribute(`data-lexical-managed-linebreak`,`true`),e.style.setProperty(`display`,`inline`,`important`),e.style.setProperty(`border`,`0px`,`important`),e.style.setProperty(`margin`,`0px`,`important`),e.alt=``,n.insertBefore(e,i),n.__lexicalLineBreak=e}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=this.getFirstChild(),t=this.getInsertionAnchor(),n=0;for(let r=this.element.firstChild;r!==null&&r!==e&&r!==t;r=r.nextSibling)n++;return n}resolveChildIndex(e,t,n,r){if(n===this.element){let t=this.getFirstChildOffset(),n=nm(),i=this.element.childNodes,a=Math.min(r,i.length),o=0;for(let e=t;e<a;e++)i[e]!==n&&o++;return[e,Math.min(o,e.getChildrenSize())]}let i=sm(t,n);i.push(r);let a=sm(t,this.element),o=e.getIndexWithinParent();for(let e=0;e<a.length;e++){let t=i[e],n=a[e];if(t===void 0||t<n)break;if(t>n){o+=1;break}}return[e.getParentOrThrow(),o]}};function sm(e,t){let n=[],r=t;for(;r!==e&&r!==null;r=r.parentNode){let e=0;for(let t=r.previousSibling;t!==null;t=t.previousSibling)e++;n.push(e)}return r!==e&&X(225),n.reverse()}var cm;try{cm=`0.49.0+prod.esm`}catch{}var lm=cm??`"<unknown>+source"`,um=class{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(e){return delete this._cache,this._front.has(e)||this._back.add(e),this}addFront(e){return delete this._cache,this._back.has(e)||this._front.add(e),this}delete(e){return delete this._cache,this._front.delete(e)||this._back.delete(e)}toArray(){let e=Array.from(this._front).reverse();for(let t of this._back)e.push(t);return e}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}},dm=null;function fm(e,t=1e3){return e instanceof pm?e.clone():e.size<t?new Map(e):new pm().init(new Map(e),void 0,e.size)}var pm=class e{_mutable=!1;_old=void 0;_nursery=void 0;_size=0;clone(){return this._mutable=!1,new e().init(this._old,this._nursery,this._size)}init(e,t,n){return this._old=e,this._nursery=t,this._size=n,this}get size(){return this._size}has(e){return this.get(e)!==void 0}getWithTombstone(e){let t=this._nursery&&this._nursery.get(e);return t===void 0?this._old&&this._old.get(e):t}get(e){let t=this.getWithTombstone(e);return t===dm?void 0:t}shouldCompact(){return this._nursery!==void 0&&2*this._nursery.size>this._size}getNursery(){return this._mutable&&this._nursery||(this.compact(),this._nursery=new Map(this._nursery),this._mutable=!0),this._nursery}compact(e=!1){if(this._nursery&&this._nursery.size>0&&(e||this.shouldCompact())){let e=new Map(this._old);for(let[t,n]of this._nursery)n===dm?e.delete(t):e.set(t,n);this._old=e,this._nursery=void 0}return this._mutable=!1,this}set(e,t){let n=this.getWithTombstone(e);if(n===t)return this;let r=this.getNursery();return n!==dm&&n!==void 0||(this._size++,n===dm&&r.delete(e)),r.set(e,t),this}delete(e){let t=this.has(e);return t&&(this.getNursery().set(e,dm),this._size--),t}getOrInsert(e,t){let n=this.get(e);return n===void 0?(this.set(e,t),t):n}getOrInsertComputed(e,t){let n=this.get(e);if(n!==void 0)return n;let r=t(e);return this.set(e,r),r}clear(){this._mutable=!1,this._old=void 0,this._nursery=void 0,this._size=0}*keys(){for(let e of this.entries())yield e[0]}*values(){for(let e of this.entries())yield e[1]}*entries(){let e=this._nursery,t=this._old;if(t)for(let n of t){let t=n[0],r=e?e.get(t):void 0;r!==dm&&(r!==void 0&&(n[1]=r),yield n)}if(e)for(let n of e)n[1]===dm||t&&t.has(n[0])||(yield n)}forEach(e,t){t!==void 0&&(e=e.bind(t));for(let[t,n]of this.entries())e(n,t,this)}get[Symbol.toStringTag](){return`GenMap`}[Symbol.iterator](){return this.entries()}};function mm(e,t,n,r,i,a){if($(e)){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&(($(o)||aS(o)&&o.__slots!==null)&&mm(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}for(let o of aS(e)&&e.__slots!==null?e.__slots.values():[]){let e=r.get(o);e!==void 0&&oS(e)&&e.__slotHost===t&&(($(e)||aS(e)&&e.__slots!==null)&&mm(e,o,n,r,i,a),n.has(o)||a.delete(o),i.push(o))}}var hm=!1,gm=0;function _m(e){gm=e.timeStamp}function vm(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&hb(e,n)!==void 0}function ym(e,t,n){let r=sx(Xb(n)),i=r&&_x(r,n._rootElement),a=null,o=null;i!==null&&i.anchorNode===e&&(a=i.anchorOffset,o=i.focusOffset);let s=e.nodeValue;s!==null&&Ob(t,s,a,o,!1)}function bm(e,t,n){if(Q(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return rb(t)&&n.isAttached()}function xm(e,t,n){for(let r=e;r&&!Kx(r);r=Wb(r)){let e=hb(r,t);if(e!==void 0){let t=fb(e,n);if(t)return hy(t)||!wx(r)?void 0:[r,t]}}}function Sm(e,t,n){hm=!0;let r=performance.now()-gm>100;try{uy(e,()=>{let i=yv()||function(e){return e.read(`latest`,()=>{let e=yv();return e===null?null:e.clone()})}(e),a=new Map,o=e._editorState,s=e._blockCursorElement,c=!1,l=``;for(let n=0;n<t.length;n++){let u=t[n],d=u.type,f=u.target,p=xm(f,e,o);if(!p)continue;let[m,h]=p;if(d===`characterData`)r&&Z(h)&&rb(f)&&bm(i,f,h)&&ym(f,h,e);else if(d===`childList`){c=!0;let t=u.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=pb(r),a=r.parentNode;if(!(a==null||r===s||i!==null||vm(r,a,e)||e._slotsUsed&&wx(r)&&r.hasAttribute(`data-lexical-slot`)||Kx(r))){if(kp){let e=(wx(r)?r.innerText:null)||r.nodeValue;e&&(l+=e)}a.removeChild(r)}}let n=u.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];(vm(r,f,e)||s===r)&&(f.appendChild(r),t++)}r!==t&&a.set(m,h)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let u=n.takeRecords();if(u.length>0){for(let t=0;t<u.length;t++){let n=u[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||vm(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(c&&bb(i),kp&&Vb(e)&&i.insertRawText(l))})}finally{hm=!1}}function Cm(e){let t=e._observer;t!==null&&Sm(e,t.takeRecords(),t)}function wm(e){(function(e){gm===0&&Xb(e).addEventListener(`textInput`,_m,!0)})(e),e._observer=new MutationObserver((t,n)=>{Sm(e,t,n)})}var Tm=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Nm).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=t.resetOnCopyNode||!1}};function Em(e,t){return new Tm(e,t)}function Dm(e){let t=new Map,n=new Set;for(let{ownNodeConfig:r}of $x(typeof e==`function`?e:e.replace))if(r&&r.stateConfigs)for(let e of r.stateConfigs){let r;`stateConfig`in e?(r=e.stateConfig,e.flat&&n.add(r.key)):r=e,t.set(r.key,r)}return{flatKeys:n,sharedConfigMap:t}}var Om=new Set([`__proto__`,`constructor`,`prototype`]),km=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState,o=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i;this.size=o}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return Mm(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){if(Om.has(i))continue;let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(let e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=Mm(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){if(Om.has(e))return;let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function Am(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new km(t,jm(t));return t.__state=n,n}function jm(e){return e.__state?e.__state.sharedNodeState:qy(Mx(),e.getType()).sharedNodeState}function Mm(e){if(e)for(let t in e)return e}function Nm(e){return e}function Pm(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function Fm(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function Im(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function Lm(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;let n=new Set;return!(e&&Pm(n,e,t)||t&&Pm(n,t,e)||e&&Fm(n,e,t)||t&&Fm(n,t,e))}(c,l))}function Rm(e,t){let n=e.mergeWithSibling(t),r=Yv()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function zm(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&Z(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(Lm(t,r)){r=Rm(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&Z(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(Lm(r,n)){r=Rm(r,n);break}break}n.remove()}}else r.remove()}function Bm(e){return Vm(e.anchor),Vm(e.focus),e}function Vm(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),Z(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!$(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}var Hm=Symbol.for(`@lexical/CachedTextSize`);function Um(e,t){return oh.read(()=>{let n=0,r=e;for(let e=0;e<t&&r!==null;e++){let i=ah.get(r);if(i===void 0&&X(345,r),$(i)){let a=sh.get(r);if(a!==void 0&&$(a)&&a.__parent!==i.__parent)n+=i.getTextContentSize();else{let e=ch.get(r),t=e&&e.__lexicalTextContent;typeof t!=`string`&&X(346,i.getType()),n+=t.length}e<t-1&&!i.isInline()&&(n+=2)}else{let e=i[Hm];e===void 0&&X(347,i.getType(),r),n+=e}r=i.__next}return n},{editor:qm})}function Wm(e){$(e)||e[Hm]===void 0&&(e[Hm]=Z(e)?e.__text.length:e.getTextContentSize())}var Gm=4,Km,qm,Jm,Ym=``,Xm=null,Zm=null,Qm=null;function $m(){return{firstTextKey:Qm,format:Xm,style:Zm}}function eh(e){e.firstTextKey!==null&&(Xm=e.format,Zm=e.style,Qm=e.firstTextKey)}function th(e){if(Qm!==null)return;let t=e.__lexicalFirstTextKey;if(t===void 0&&X(348),t===null)return;let n=sh.get(t);Z(n)&&(Xm=n.getFormat(),Zm=n.getStyle(),Qm=t)}var nh,rh,ih,ah,oh,sh,ch,lh,uh,dh,fh=!1,ph=!1;function mh(e,t){let n=ah.get(e),r=sh.has(e);if(t!==null){let n=Rh(e);n.parentNode===t&&t.removeChild(n)}if(!r){if(qm._keyToDOMMap.delete(e),$(n)){let e=nS(n,ah);hh(e,0,e.length-1,null)}if(n!==void 0){for(let e of wh(n).values()){let t=Eh(e);mh(e,null),t!==null&&t.remove()}Rb(uh,Jm,nh,n,`destroyed`)}}}function hh(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&mh(t,r)}}function gh(e,t){e.setProperty(`text-align`,t)}var _h=`40px`;function vh(e,t){let n=Km.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}e.style.setProperty(`padding-inline-start`,t===0?``:`calc(${t} * var(--lexical-indent-base-value, ${_h}))`)}function yh(e,t){let n=e.style;t===0?gh(n,``):t===1?gh(n,`left`):t===2?gh(n,`center`):t===3?gh(n,`right`):t===4?gh(n,`justify`):t===5?gh(n,`start`):t===6&&gh(n,`end`)}function bh(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(_y(e))return null;let n=e.getParent();return n===null||ex(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function xh(e){let t=mx().createElement(`div`);return t.setAttribute(`data-lexical-slot`,e),t.style.display=`none`,t}function Sh(e,t,n){t||e.contentEditable===`false`?qx(n,qm):n.removeAttribute(`contenteditable`)}function Ch(e,t,n){let r=Ym,i=$m();Ym=``;let a=``,o=hy(e);for(let[r,i]of n){let n=xh(r);Sh(t,o,n),t.appendChild(n),Ym=``;let s=$m();Oh(i,Px(e,n,qm)),eh(s),Th(e,r,t,n),a+=Ym}return eh(i),Ym=r,a}function wh(e){return aS(e)&&e.__slots!==null?e.__slots:iS}function Th(e,t,n,r){let i=dh.$getSlotTargetElement(e,t,n,qm);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display=``)}function Eh(e){let t=ch.get(e);return t===void 0?null:t.parentElement}function Dh(e,t,n){let r=wh(e),i=wh(t);for(let[e,t]of r)if(!i.has(e)){let e=Eh(t);mh(t,null),e!==null&&e.remove()}let a=Ym,o=$m(),s=``,c=null,l=hy(t);for(let[e,a]of i){let i=r.get(e),o=i===void 0?null:Eh(i);Ym=``;let u=$m();if(o===null){o=xh(e);let r=null;for(let e of n.children)if(!e.hasAttribute(`data-lexical-slot`)){r=e;break}n.insertBefore(o,r),Oh(a,Px(t,o,qm))}else i===a?Nh(a,o):(i!==void 0&&mh(i,o),Oh(a,Px(t,o,qm)));if(eh(u),Sh(n,l,o),Th(t,e,n,o),s+=Ym,o.parentElement===n){let e=c===null?n.firstChild:c.nextSibling;e!==o&&n.insertBefore(o,e),c=o}}return eh(o),Ym=a,s}function Oh(e,t){let n=sh.get(e);if(n===void 0&&X(60),t!==null){let r=ah.get(e);if(r!==void 0){let i=ch.get(e);if(i!==void 0){let a=oS(r)?r.__slotHost:null,o=oS(n)?n.__slotHost:null,s=r.__parent!==n.__parent||a!==o,c=o!==null&&i.parentElement!==t.element;if(s||c)return t.insertChild(i),Nh(e,t.element)}}}let r=dh.$createDOM(n,qm);if(function(e,t,n){let r=n._keyToDOMMap;mb(t,n,e),r.set(e,t)}(e,r,qm),Z(n)?r.setAttribute(`data-lexical-text`,`true`):hy(n)&&(r.setAttribute(`data-lexical-decorator`,`true`),Gx(r,{captureSelection:!0})),$(n)){let e=n.__indent,t=n.__size;bh(r,n),e!==0&&vh(r,e);let i=wh(n),a=i.size>0?Ch(n,r,i):``;if(t===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,Ym+=a,i.size>0&&(r.__lexicalSlotTextLength=a.length);else{let e=Ym,o=t-1;if(kh(nS(n,sh),n,0,o,Px(n,r,qm)),a!==``){let t=r.__lexicalTextContent||``;r.__lexicalTextContent=a+t,Ym=e+a+t}i.size>0&&(r.__lexicalSlotTextLength=a.length)}let o=n.__format;o!==0&&yh(r,o),n.isInline()||Ah(null,n,r)}else{let t=n.getTextContent();if(hy(n)){let t=n.decorate(qm,Km);t!==null&&Ph(e,t),r.contentEditable=`false`;let i=wh(n);i.size>0&&Ch(n,r,i)}Ym+=t}return t!==null&&t.insertChild(r),dh.$decorateDOM(n,null,r,qm),Wm(n),Rb(uh,Jm,nh,n,`created`),r}function kh(e,t,n,r,i){let a=Ym,o=$m();Ym=``,Xm=null,Zm=null,Qm=null;let s=n;for(;s<=r;++s){let t=$m();Oh(e[s],i);let n=sh.get(e[s]);n!==null&&Z(n)?Xm===null&&(Xm=n.getFormat(),Zm=n.getStyle(),Qm=n.__key):$(n)&&s<r&&!n.isInline()&&(Ym+=qp),eh(t)}let c=qm._keyToDOMMap.get(t.__key);c===void 0&&X(349,t.__key),c.__lexicalTextContent=Ym,c.__lexicalFirstTextKey=Qm,Ym=a+Ym,eh(o)}function Ah(e,t,n){let r=Px(t,n,qm),i=r.element.__lexicalLastChildKind??null,a=function(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return Dy(e)?`line-break`:hy(e)&&e.isInline()?`decorator`:null}return wh(e).size>0?null:`empty`}return null}(t,sh);i!==a&&r.setManagedLineBreak(a)}function jh(e,t,n){var r;Xm=null,Zm=null,Qm=null,function(e,t,n){let r=Ym,i=e.__size,a=t.__size;Ym=``;let o=n.element,s=qm._keyToDOMMap.get(t.__key);s===void 0&&X(351,t.__key);let c=a-i;if(!fh&&Math.abs(c)<=1&&i>=Gm&&e.__first===t.__first&&(c!==0||!qm._cloneNotNeeded.has(e.__key))){let i=s.__lexicalTextContent,l=lh.get(e.__key);if(!fh&&typeof i==`string`&&l!==void 0){let a=function(e,t){let n=t.size;if(n===0||n>=e.__size)return null;let r=e.__last,i=null,a=0;for(;r!==null&&a<n;){if(!t.has(r))return null;i=r;let e=sh.get(r);if(e===void 0)return null;r=e.__prev,a++}return a!==n||r!==null&&t.has(r)?null:i}(t,l);if(a!==null){let u=l.size;if(c===0){let e=Um(a,u),n=a,c=0;for(;n!==null&&c<u;){let e=sh.get(n);if(e===void 0)break;let t=$m();Nh(n,o),Z(e)&&Xm===null&&(Xm=e.getFormat(),Zm=e.getStyle(),Qm=e.__key),eh(t),n=e.__next,c++}let d=``;for(n=a,c=0;n!==null&&c<u;){let e=sh.get(n);if(e===void 0)break;let t;if($(e)){let r=qm._keyToDOMMap.get(n),i=r&&r.__lexicalTextContent;typeof i!=`string`&&X(352,e.getType()),t=i}else t=e.getTextContent();d+=t,c<u-1&&$(e)&&!e.isInline()&&(d+=qp),n=e.__next,c++}let f=s.__lexicalSlotTextLength||0,p=f>0?i.slice(f):i,m=p.slice(0,p.length-e)+d;s.__lexicalTextContent=m,Ym=r+m,Mh(t,s,l);return}if(function(e,t,n,r,i,a,o,s){if(s!==1&&s!==-1||o!==(s===1?2:1))return!1;let c=o-s,l=e.__last;for(let e=0;e<c-1;e++){if(l===null)return!1;let e=ah.get(l);if(e===void 0)return!1;l=e.__prev}if(l===null)return!1;let u=sh.get(a),d=ah.get(l);if(u===void 0||d===void 0||u.__prev!==d.__prev)return!1;let f=[],p=a;for(let e=0;e<o;e++){if(p===null)return!1;f.push(p);let e=sh.get(p);p=e?e.__next:null}let m=[];p=l;for(let e=0;e<c;e++){if(p===null)return!1;m.push(p);let e=ah.get(p);p=e?e.__next:null}let h=new Set(m),g=new Set(f),_=[],v=0,y=0;for(;v<c&&y<o;)if(f[y]===m[v])_.push({key:f[y],kind:`reconcile`}),v++,y++;else if(g.has(m[v])){if(h.has(f[y]))return!1;_.push({key:f[y],kind:`create`,nextIndex:y}),y++}else _.push({key:m[v],kind:`destroy`}),v++;for(;v<c;)_.push({key:m[v++],kind:`destroy`});for(;y<o;)_.push({key:f[y],kind:`create`,nextIndex:y}),y++;let b=Um(l,c);for(let e of _){let t=$m();if(e.kind===`reconcile`)Nh(e.key,n.element);else if(e.kind===`destroy`)mh(e.key,n.element);else{let t=null;for(let n=e.nextIndex+1;n<o;n++){let e=qm._keyToDOMMap.get(f[n]);if(e!==void 0){t=e;break}}Oh(e.key,n.withBefore(t??n.before))}if(e.kind!==`destroy`){let t=sh.get(e.key);t&&Z(t)&&Xm===null&&(Xm=t.getFormat(),Zm=t.getStyle(),Qm=t.__key)}eh(t)}let x=``;for(let e=0;e<o;e++){let t=sh.get(f[e]);if(t===void 0)return!1;let n;if($(t)){let r=qm._keyToDOMMap.get(f[e]),i=r&&r.__lexicalTextContent;typeof i!=`string`&&X(350,t.getType()),n=i}else n=t.getTextContent();x+=n,e<o-1&&$(t)&&!t.isInline()&&(x+=qp)}let S=r.__lexicalSlotTextLength||0,C=S>0?i.slice(S):i;return r.__lexicalTextContent=C.slice(0,C.length-b)+x,!0}(e,0,n,s,i,a,u,c)){let e=s.__lexicalTextContent;typeof e!=`string`&&X(353),Ym=r+e,Mh(t,s,l);return}}}if(c===0){let t=e.__first,n=0;for(;t!==null;){let e=sh.get(t);if(e===void 0)break;let r=fh||ih.has(t)||rh.has(t),i=$m();if(r)Nh(t,o);else{let n,r;if($(e)){r=ch.get(t);let i=r&&r.__lexicalTextContent;typeof i!=`string`&&X(354,e.getType()),n=i}else n=e.getTextContent();Ym+=n,r!==void 0&&th(r)}Z(e)?Xm===null&&(Xm=e.getFormat(),Zm=e.getStyle(),Qm=e.__key):$(e)&&n<a-1&&!e.isInline()&&(Ym+=qp),eh(i),t=e.__next,n++}s.__lexicalTextContent=Ym,s.__lexicalFirstTextKey=Qm,Ym=r+Ym;return}}if(i===1&&a===1){let r=e.__first,i=t.__first;if(r===i)Nh(r,o);else{let e=Rh(r),t=Oh(i,null);try{e.parentNode===o?o.replaceChild(t,e):n.insertChild(t)}catch(n){if(typeof n==`object`&&n){let a=`${n.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${i}}, old child: {tag: ${e.tagName}, key: ${r}}.`;throw Error(a)}throw n}mh(r,null)}let a=sh.get(i);Z(a)&&Xm===null&&(Xm=a.getFormat(),Zm=a.getStyle(),Qm=a.__key)}else{let r=nS(e,ah),s=nS(t,sh);if(r.length!==i&&X(227),s.length!==a&&X(228),i===0)a!==0&&kh(s,t,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&wh(t).size===0&&n.element.__lexicalLineBreak==null;hh(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else(function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f],i=$m();if(e===r)u=Fh(Nh(r,a.element)),d++,f++;else{if(l===void 0&&(l=Ih(n,f)),c===void 0)c=Ih(t,d);else if(!c.has(e)){d++,eh(i);continue}if(!l.has(e)){u=Fh(Rh(e)),mh(e,a.element),d++,c.delete(e),eh(i);continue}if(c.has(r)){let e=Ub(qm,r);e!==u&&a.withBefore(u??a.before).insertChild(e),u=Fh(Nh(r,a.element)),d++,f++}else Oh(r,a.withBefore(u??a.before)),f++}let o=sh.get(r);o!==null&&Z(o)?Xm===null&&(Xm=o.getFormat(),Zm=o.getStyle(),Qm=o.__key):$(o)&&f<=s&&!o.isInline()&&(Ym+=qp),eh(i)}let p=d>o,m=f>s;if(p&&!m){let t=n[s+1],r=t===void 0?null:qm.getElementByKey(t);kh(n,e,f,s,a.withBefore(r??a.before))}else m&&!p&&hh(t,d,o,a.element)})(t,r,s,i,a,n)}s.__lexicalTextContent=Ym,s.__lexicalFirstTextKey=Qm,Ym=r+Ym}(e,t,Px(t,n,qm)),ex(t)||(r=t,Xm==null||Xm===r.__textFormat||ph||r.setTextFormat(Xm),function(e){Zm==null||Zm===e.__textStyle||ph||e.setTextStyle(Zm)}(t))}function Mh(e,t,n){let r=t.__lexicalFirstTextKey;if(r!=null){let t=e.__key,i=r;for(;i!==null;){let e=sh.get(i);if(e===void 0){i=null;break}if(e.__parent===t)break;i=e.__parent}if(i!==null&&!n.has(i)){let e=sh.get(r);if(Z(e))return Xm=e.getFormat(),void(Zm=e.getStyle())}}t.__lexicalFirstTextKey=Qm}function Nh(e,t){let n=ah.get(e),r=sh.get(e);n!==void 0&&r!==void 0||X(61);let i=fh||ih.has(e)||rh.has(e),a=Ub(qm,e);if(n===r&&!i){let e;if($(n)){let t=a.__lexicalTextContent;typeof t!=`string`&&X(355,n.getType()),e=t,th(a)}else e=n.getTextContent();return Ym+=e,a}if(n!==r&&i&&Rb(uh,Jm,nh,r,`updated`),dh.$updateDOM(r,n,a,qm)){let n=Oh(e,null);return t===null&&X(62),t.replaceChild(n,a),mh(e,null),n}if($(n)){$(r)||X(334,e);let t=r.__indent;(fh||t!==n.__indent)&&vh(a,t);let o=r.__format;(fh||o!==n.__format)&&yh(a,o);let s=i&&(wh(r).size>0||wh(n).size>0)?Dh(n,r,a):``;if(i){let e=Ym;if(jh(n,r,a),_y(r)||r.isInline()||Ah(0,r,a),s!==``){let t=a.__lexicalTextContent||``;a.__lexicalTextContent=s+t,Ym=e+s+t,a.__lexicalSlotTextLength=s.length}else(wh(r).size>0||wh(n).size>0)&&(a.__lexicalSlotTextLength=0)}else{let e=a.__lexicalTextContent;typeof e!=`string`&&X(356,n.getType()),Ym+=e,th(a)}if((fh||r.__dir!==n.__dir||r.__parent!==n.__parent)&&(bh(a,r),_y(r)&&!fh))for(let e of r.getChildren())$(e)&&bh(Ub(qm,e.getKey()),e)}else{let t=r.getTextContent();if(hy(r)){let t=r.decorate(qm,Km);t!==null&&Ph(e,t),i&&(wh(r).size>0||wh(n).size>0)&&Dh(n,r,a)}Ym+=t}if(!ph&&_y(r)){let e=r.getLatest();if(e.__cachedText!==Ym){let t=e.getWritable();t.__cachedText=Ym,r=t}}return dh.$decorateDOM(r,n,a,qm),Wm(r),a}function Ph(e,t){let n=qm._pendingDecorators,r=qm._decorators;if(n===null){if(r[e]===t)return;n=_b(qm)}n[e]=t}function Fh(e){let t=e.nextSibling;return t!==null&&t===qm._blockCursorElement&&(t=t.nextSibling),t}function Ih(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Lh(e,t,n,r,i,a){Ym=``,Xm=null,Zm=null,Qm=null,fh=r===2,qm=n,Km=n._config,dh=n._config.dom||Ry,Jm=n._nodes,nh=qm._listeners.mutation,rh=i,ih=a,ah=e._nodeMap,oh=e,sh=t._nodeMap,ph=t._readOnly,ch=fm(n._keyToDOMMap),lh=function(){let e=new Map,t=t=>{for(let n of t){let t=sh.get(n);if(t===void 0)continue;let r=t.__parent;if(r===null)continue;let i=e.get(r);i===void 0&&(i=new Set,e.set(r,i)),i.add(n)}};return t(rh.keys()),t(ih),e}();let o=new Map;return uh=o,Nh(`root`,null),qm=void 0,Jm=void 0,rh=void 0,ih=void 0,ah=void 0,oh=void 0,sh=void 0,Km=void 0,ch=void 0,lh=void 0,uh=void 0,dh=Ry,o}function Rh(e){let t=ch.get(e);return t===void 0&&X(75,e),t}function zh(e){return{type:e}}var Bh=zh(`SELECTION_CHANGE_COMMAND`),Vh=zh(`CLICK_COMMAND`),Hh=zh(`BEFORE_INPUT_COMMAND`),Uh=zh(`INPUT_COMMAND`),Wh=zh(`COMPOSITION_START_COMMAND`),Gh=zh(`COMPOSITION_END_COMMAND`),Kh=zh(`DELETE_CHARACTER_COMMAND`),qh=zh(`INSERT_LINE_BREAK_COMMAND`),Jh=zh(`INSERT_PARAGRAPH_COMMAND`),Yh=zh(`CONTROLLED_TEXT_INSERTION_COMMAND`),Xh=zh(`PASTE_COMMAND`),Zh=zh(`REMOVE_TEXT_COMMAND`),Qh=zh(`DELETE_WORD_COMMAND`),$h=zh(`DELETE_LINE_COMMAND`),eg=zh(`FORMAT_TEXT_COMMAND`),tg=zh(`UNDO_COMMAND`),ng=zh(`REDO_COMMAND`),rg=zh(`KEYDOWN_COMMAND`),ig=zh(`KEY_ARROW_RIGHT_COMMAND`),ag=zh(`MOVE_TO_END`),og=zh(`KEY_ARROW_LEFT_COMMAND`),sg=zh(`MOVE_TO_START`),cg=zh(`KEY_ARROW_UP_COMMAND`),lg=zh(`KEY_ARROW_DOWN_COMMAND`),ug=zh(`KEY_ENTER_COMMAND`),dg=zh(`KEY_SPACE_COMMAND`),fg=zh(`KEY_BACKSPACE_COMMAND`),pg=zh(`KEY_ESCAPE_COMMAND`),mg=zh(`KEY_DELETE_COMMAND`),hg=zh(`KEY_TAB_COMMAND`),gg=zh(`DROP_COMMAND`),_g=zh(`DRAGSTART_COMMAND`),vg=zh(`DRAGOVER_COMMAND`),yg=zh(`DRAGEND_COMMAND`),bg=zh(`COPY_COMMAND`),xg=zh(`CUT_COMMAND`),Sg=zh(`SELECT_ALL_COMMAND`),Cg=zh(`CLEAR_EDITOR_COMMAND`),wg=zh(`CLEAR_HISTORY_COMMAND`),Tg=zh(`CAN_REDO_COMMAND`),Eg=zh(`CAN_UNDO_COMMAND`),Dg=zh(`FOCUS_COMMAND`),Og=zh(`BLUR_COMMAND`),kg=zh(`KEY_MODIFIER_COMMAND`);function Ag(e){let t=new Map;return{dispose(){for(let e of t.values())e.dispose();t.clear()},register(n,r){let i=t.get(n);i===void 0&&(i={dispose:e(n,r),holders:new Set},t.set(n,i));let a=()=>{let e=t.get(n);e&&e.holders.delete(a)&&e.holders.size===0&&(t.delete(n),e.dispose())};return i.holders.add(a),a}}}function jg(e,t,n,r){return e.addEventListener(t,n,r),e.removeEventListener.bind(e,t,n,r)}var Mg=Object.freeze({}),Ng=[[`keydown`,function(e,t){let n=t._inputState;n.lastKeyDownTimeStamp=e.timeStamp,n.lastKeyCode=e.key,e.key!==`Backspace`&&Wg(n),!t.isComposing()&&Hb(t,rg,e)}],[`pointerdown`,function(e,t){let n=Cx(e),r=e.pointerType;Tx(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&uy(t,()=>{Jx(n,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}],[`compositionstart`,function(e,t){Hb(t,Wh,e)}],[`compositionend`,function(e,t){let n=t._inputState;kp?n.compositionPhase=`ending-firefox`:jp||!Np&&!Ip?Hb(t,Gh,e):(n.compositionPhase=`ending-safari`,n.compositionEndData=e.data)}],[`input`,function(e,t){e.stopPropagation();let n=t._inputState;Wg(n),uy(t,()=>{Kg(e,t)||t.dispatchCommand(Uh,e)},{event:e}),n.unprocessedBeforeInputData=null}],[`click`,function(e,t){uy(t,()=>{let n=yv(),r=sx(Xb(t)),i=bv();if(r){if(Q(n)){let e=n.anchor,t=e.getNode();e.type===`element`&&e.offset===0&&n.isCollapsed()&&!_y(t)&&yb().getChildrenSize()===1&&t.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i)&&(r.removeAllRanges(),n.dirty=!0)}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=_x(r,t._rootElement).anchorNode;(wx(n)||rb(n))&&bb(vv(i,r,t,e))}}if(kp&&r!==null&&r.rangeCount===0){let n=t._rootElement;if(n!==null&&e.target===n){let a=e.clientY,o=n.childNodes.length;for(let e=0;e<n.childNodes.length;e++){let t=n.childNodes[e];if(wx(t)){let n=t.getBoundingClientRect();if(a<=(n.top+n.bottom)/2){o=e;break}}}r.setBaseAndExtent(n,o,n,o);let s=vv(i,r,t,e);s===null?r.removeAllRanges():bb(s)}}Hb(t,Vh,e)})}],[`cut`,Mg],[`copy`,Mg],[`dragstart`,Mg],[`dragover`,Mg],[`dragend`,Mg],[`paste`,Mg],[`focus`,Mg],[`blur`,Mg],[`drop`,Mg]];Ap&&Ng.push([`beforeinput`,(e,t)=>function(e,t){let n=e.inputType;n===`deleteCompositionText`||kp&&Vb(t)||n!==`insertCompositionText`&&uy(t,()=>{Kg(e,t)||Hb(t,Hh,e)},{event:e})}(e,t)]);var Pg=new WeakMap,Fg=new WeakMap,Ig=Ag(e=>(e.addEventListener(`selectionchange`,n_),()=>e.removeEventListener(`selectionchange`,n_)));function Lg(e,t,n,r,i,a){let o=e.anchor,s=e.focus,c=o.getNode(),l=Yv(),u;if(a!==void 0)u=a;else{let e=sx(Xb(l));u=e===null?null:_x(e,l._rootElement)}let d=u===null?null:u.anchorNode,f=o.key,p=l.getElementByKey(f),m=n.length;return f!==s.key||!Z(c)||(!i&&(!Ap||l._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&m<2||Cb(n))&&o.offset!==s.offset&&!c.isComposing()||nb(c)||c.isDirty()&&m>1||(i||!Ap)&&p!==null&&!c.isComposing()&&d!==Ix(c,p,l)||u!==null&&t!==null&&(!t.collapsed||t.startContainer!==u.anchorNode||t.startOffset!==u.anchorOffset)||!c.isComposing()&&(c.getFormat()!==e.format||c.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=tb(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(Z(t)||$(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,c)}function Rg(e,t){return rb(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function zg(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=_x(e,t._rootElement),s=t._inputState;s.isSelectionChangeFromDOMUpdate&&(s.isSelectionChangeFromDOMUpdate=!1,Rg(r,i)&&Rg(a,o)&&!s.postDeleteSelectionToRestore)||uy(t,()=>{if(!n)return void bb(null);if(!Zy(t,r,a))return;let c=yv();if(s.postDeleteSelectionToRestore&&Q(c)&&c.isCollapsed()){let e=c.anchor,t=s.postDeleteSelectionToRestore.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(c=s.postDeleteSelectionToRestore.clone(),bb(c))}if(s.postDeleteSelectionToRestore=null,Q(c)){let n=c.anchor,l=n.getNode();if(c.isCollapsed()){e.type===`Range`&&r===a&&(c.dirty=!0);let i=Xb(t).event,o=i?i.timeStamp:performance.now(),{format:u,style:d,offset:f,key:p,timeStamp:m}=s.collapsedSelectionFormat,h=yb(),g=!1===t.isComposing()&&h.getTextContent()===``;if(o<m+200&&n.offset===f&&n.key===p)Bg(c,u,d);else if(n.type===`text`)Z(l)||X(141),Vg(c,l);else if(n.type===`element`&&!g){$(l)||X(259);let e=n.getNode();e.isEmpty()?function(e,t){Bg(e,t.getTextFormat(),t.getTextStyle())}(c,e):Bg(c,c.format,``)}}else{let e=n.key,t=c.focus.key,r=c.getNodes(),a=r.length,s=c.isBackward(),l=s?o:i,u=s?i:o,d=s?t:e,f=s?e:t,p=2047,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(Z(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}c.format=m?p:0}}Hb(t,Bh)})}function Bg(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function Vg(e,t){Bg(e,t.getFormat(),t.getStyle())}function Hg(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function Ug(e){let{lastKeyCode:t}=Yv()._inputState;if(e==null||e.length<=1||t==null)return;let n=t.length===1?t:t===`Enter`?`
|
|
11
|
-
`:t===`Tab`?` `:null;if(!n)return;let r=yv();if(!Q(r)||!r.isCollapsed())return;let i=r.anchor.getNode();if(!Z(i))return;let{offset:a}=r.anchor;if(i.getTextContentSize()===a){let e=i.getNextSibling();if(n===`
|
|
12
|
-
`){if(Dy(e))e.selectEnd();else if(!e){let e=tS(i,mv),t=e&&e.getNextSibling();$(t)&&t.selectStart()}}else n===` `?B_(e)&&e.selectEnd():Z(e)&&e.getTextContent()[0]===n&&e.select(1,1)}else i.getTextContent()[a]===n&&i.select(a+1,a+1)}function Wg(e){e.isInsertTextAfterHandledSelectionCommand=!1,e.handledSelectionCommandTimeoutId!==null&&(clearTimeout(e.handledSelectionCommandTimeoutId),e.handledSelectionCommandTimeoutId=null)}function Gg(e){Wg(e),e.isInsertTextAfterHandledSelectionCommand=!0,e.handledSelectionCommandTimeoutId=setTimeout(()=>Wg(e),0)}function Kg(e,t){let n=Cx(e);if(wx(n)&&Jx(n,t))return!0;let r=t.getRootElement();if(r===null)return!1;let i=Sx(r.ownerDocument);return i!==null&&r.contains(i)&&Jx(i,t)}function qg(e){let t=e.inputType,n=Hg(e),r=Yv(),i=r._inputState,a=yv();if(t===`insertText`&&e.data&&i.isInsertTextAfterHandledSelectionCommand){if(Wg(i),e.preventDefault(),Q(a)&&!a.isCollapsed()){let e=a.isBackward()?a.anchor:a.focus;a.anchor.set(e.key,e.offset,e.type),a.focus.set(e.key,e.offset,e.type)}return!0}if(t===`deleteContentBackward`){if(a===null){let e=bv();if(!Q(e))return!0;bb(e.clone())}if(Q(a)){let t=a.anchor.key===a.focus.key;if(function(e,t){return e.lastKeyCode===`MediaLast`&&t<e.lastKeyDownTimeStamp+30}(i,e.timeStamp)&&r.isComposing()&&t){if(ub(null),i.lastKeyDownTimeStamp=0,setTimeout(()=>{uy(r,()=>{ub(null)})},30),Q(a)){let e=a.anchor.getNode();e.markDirty(),Z(e)||X(142),Vg(a,e)}}else{if(ub(null),jp&&n!==null&&!n.collapsed&&(a.applyDOMRange(n),!a.isCollapsed()))return e.preventDefault(),a.removeText(),!0;e.preventDefault();let o=a.anchor.getNode(),s=o.getTextContent(),c=o.canInsertTextAfter(),l=a.anchor.offset===0&&a.focus.offset===s.length,u=Fp&&t&&!l&&c;if(u&&a.isCollapsed()&&(u=!hy(Bb(a.anchor,!0))),!u){Hb(r,Kh,!0);let e=yv();Fp&&Q(e)&&e.isCollapsed()&&(i.postDeleteSelectionToRestore=e,setTimeout(()=>i.postDeleteSelectionToRestore=null))}}return!0}}if(!Q(a))return!0;let o=e.data;i.unprocessedBeforeInputData!==null&&Db(!1,r,i.unprocessedBeforeInputData),a.dirty&&i.unprocessedBeforeInputData===null||!a.isCollapsed()||_y(a.anchor.getNode())||n===null||a.applyDOMRange(n),i.unprocessedBeforeInputData=null;let s=a.anchor,c=a.focus,l=s.getNode(),u=c.getNode();if(t===`insertText`||t===`insertTranspose`){if(o===`
|
|
13
|
-
`)e.preventDefault(),Hb(r,qh,!1);else if(o===qp)e.preventDefault(),Hb(r,Jh);else if(o==null&&e.dataTransfer){let t=e.dataTransfer.getData(`text/plain`);e.preventDefault(),a.insertRawText(t)}else o!=null&&Lg(a,n,o,e.timeStamp,!0)?(e.preventDefault(),Hb(r,Yh,o),Ug(o)):i.unprocessedBeforeInputData=o;return i.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),t){case`insertFromYank`:case`insertFromDrop`:case`insertReplacementText`:Hb(r,Yh,e),Ug((e.dataTransfer?e.dataTransfer.getData(`text/plain`):null)??e.data);break;case`insertFromComposition`:{let t=i.hadOrphanedCompositionEvents;i.hadOrphanedCompositionEvents=!1;let n=r._compositionKey;ub(null),t||Hb(r,Yh,e),Zg(n);break}case`insertLineBreak`:ub(null),Hb(r,qh,!1);break;case`insertParagraph`:ub(null),i.isInsertLineBreak&&!jp?(i.isInsertLineBreak=!1,Hb(r,qh,!1)):Hb(r,Jh);break;case`insertFromPaste`:case`insertFromPasteAsQuotation`:Hb(r,Xh,e);break;case`deleteByComposition`:(function(e,t){return e!==t||$(e)||$(t)||!tb(e)||!tb(t)})(l,u)&&Hb(r,Zh,e);break;case`deleteByDrag`:Kb(m_),Hb(r,Zh,e);break;case`deleteByCut`:Hb(r,Zh,e);break;case`deleteContent`:Hb(r,Kh,!1);break;case`deleteWordBackward`:Hb(r,Qh,!0);break;case`deleteWordForward`:Hb(r,Qh,!1);break;case`deleteHardLineBackward`:case`deleteSoftLineBackward`:Hb(r,$h,!0);break;case`deleteContentForward`:case`deleteHardLineForward`:case`deleteSoftLineForward`:Hb(r,$h,!1);break;case`formatStrikeThrough`:Hb(r,eg,`strikethrough`);break;case`formatBold`:Hb(r,eg,`bold`);break;case`formatItalic`:Hb(r,eg,`italic`);break;case`formatUnderline`:Hb(r,eg,`underline`);break;case`historyUndo`:Hb(r,tg);break;case`historyRedo`:Hb(r,ng)}return!0}function Jg(e){let t=Yv(),n=t._inputState,r=yv(),i=e.data,a=Hg(e),o=!1;if(i!=null&&Q(r)){let s=sx(Xb(t)),c=s===null?null:_x(s,t._rootElement),l=e.inputType===`insertCompositionText`&&n.compositionPhase!==`ending-firefox`&&!t.isComposing();l&&(n.hadOrphanedCompositionEvents=!0);let u=r.anchor.getNode(),d=e.inputType===`insertCompositionText`&&n.compositionPhase!==`ending-firefox`&&t.isComposing()&&Z(u)&&nb(u);if(!l&&!d&&Lg(r,a,i,e.timeStamp,!1,c)){if(o=!0,n.compositionPhase===`ending-firefox`){let e=Qg(t,i);if(n.compositionPhase=`idle`,e)return Kb(h_),xb(),!0}let a=r.anchor.getNode();if(s===null||c===null)return!0;let l=r.isBackward(),u=l?r.anchor.offset:r.focus.offset,d=l?r.focus.offset:r.anchor.offset;Ap&&!r.isCollapsed()&&Z(a)&&c.anchorNode!==null&&a.getTextContent().slice(0,u)+i+a.getTextContent().slice(u+d)===Eb(c.anchorNode)||Hb(t,Yh,i);let f=i.length;kp&&f>1&&e.inputType===`insertCompositionText`&&!t.isComposing()&&(r.anchor.offset-=f,r._cachedNodes=null,r._cachedIsBackward=null),Fp&&t.isComposing()&&(n.lastKeyDownTimeStamp=0,ub(null))}}return o||(Db(!1,t,i===null?void 0:i),n.compositionPhase===`ending-firefox`&&(Qg(t,i||void 0),Kb(`composition-end`),n.compositionPhase=`idle`)),xb(),!0}function Yg(e){let t=Yv(),n=t._inputState,r=yv();if(Q(r)&&!t.isComposing()){n.compositionPhase=`composing`,n.hadOrphanedCompositionEvents=!1;let i=r.anchor,a=r.anchor.getNode();if(ub(i.key),Kb(`composition-start`),e.timeStamp<n.lastKeyDownTimeStamp+30||i.type===`element`||!r.isCollapsed()||!Fp&&(a.getFormat()!==r.format||Z(a)&&a.getStyle()!==r.style)||Z(a)&&(nb(a)||i.offset===0&&!a.canInsertTextBefore()||i.offset===a.getTextContentSize()&&!a.canInsertTextAfter())){Hb(t,Yh,Jp);let e=yv();Q(e)&&ub(e.anchor.key)}}return!0}function Xg(e){let t=Yv();return t._inputState.compositionPhase=`idle`,Qg(t,e.data),Kb(h_),!0}function Zg(e){if(e===null)return;let t=fb(e);if(!Z(t)||t.getType()===`text`||nb(t)||!t.isAttached())return;let n=yv(),r=Q(n)&&n.anchor.key===e?n.anchor.offset:null,i=I_(t.getTextContent());if(i.setFormat(t.getFormat()),i.setStyle(t.getStyle()),t.replace(i),r!==null){let e=Math.min(r,i.getTextContentSize());i.select(e,e)}}function Qg(e,t){let n=e._compositionKey;if(ub(null),n!==null&&t!=null){if(t===``){let t=fb(n),r=e.getElementByKey(n),i=r!==null&&Z(t)?Ix(t,r,e):null;if(i!==null&&i.nodeValue!==null&&Z(t)){let n=sx(Xb(e)),r=n&&_x(n,e._rootElement),a=null,o=null;r!==null&&r.anchorNode===i&&(a=r.anchorOffset,o=r.focusOffset),Ob(t,i.nodeValue,a,o,!0)}return Zg(n),!1}if(t[t.length-1]===`
|
|
14
|
-
`){let t=yv();if(Q(t)||X_(t)){if(Q(t)){let e=t.focus;t.anchor.set(e.key,e.offset,e.type)}return Hb(e,ug,null),Zg(n),!1}}let r=fb(n);if(r!==null&&Z(r)&&nb(r)){r.markDirty();let e=yv(),i=r.getTextContentSize(),a=Q(e)&&e.anchor.key===n?e.anchor.offset:i;return r.select(a,a).insertText(t),!0}}return Db(!0,e,t),Zg(n),!1}function $g(e){let t=Yv(),n=t._inputState;if(e.key==null)return!0;if(n.compositionPhase===`ending-safari`){let r=Fb(e);if(r&&uy(t,()=>{Qg(t,n.compositionEndData)}),n.compositionPhase=`idle`,n.compositionEndData=``,r)return!0}if(function(e){return Mb(e,`ArrowRight`,{shiftKey:`any`})}(e))Hb(t,ig,e);else if(function(e){return Mb(e,`ArrowRight`,{...Nb,shiftKey:`any`})}(e))Hb(t,ag,e);else if(function(e){return Mb(e,`ArrowLeft`,{shiftKey:`any`})}(e))Hb(t,og,e);else if(function(e){return Mb(e,`ArrowLeft`,{...Nb,shiftKey:`any`})}(e))Hb(t,sg,e);else if(function(e){return Mb(e,`ArrowUp`,{altKey:`any`,shiftKey:`any`})}(e))Hb(t,cg,e);else if(function(e){return Mb(e,`ArrowDown`,{altKey:`any`,shiftKey:`any`})}(e))Hb(t,lg,e);else if(function(e){return Mb(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`,shiftKey:!0})}(e))n.isInsertLineBreak=!0,Hb(t,ug,e);else if(function(e){return e.key===` `}(e))Hb(t,dg,e);else if(function(e){return Op&&Mb(e,`o`,{ctrlKey:!0})}(e))e.preventDefault(),n.isInsertLineBreak=!0,Hb(t,qh,!0);else if(function(e){return Mb(e,`Enter`,{altKey:`any`,ctrlKey:`any`,metaKey:`any`})}(e))n.isInsertLineBreak=!1,Hb(t,ug,e);else if(function(e){return Mb(e,`Backspace`,{shiftKey:`any`})||Op&&Mb(e,`h`,{ctrlKey:!0})}(e))Fb(e)?Hb(t,fg,e)&&Gg(n):(e.preventDefault(),Hb(t,Kh,!0));else if(function(e){return e.key===`Escape`}(e))Hb(t,pg,e);else if(function(e){return Mb(e,`Delete`,{})||Op&&Mb(e,`d`,{ctrlKey:!0})}(e))(function(e){return e.key===`Delete`})(e)?Hb(t,mg,e):(e.preventDefault(),Hb(t,Kh,!1));else if(function(e){return Mb(e,`Backspace`,Pb)}(e))e.preventDefault(),Hb(t,Qh,!0);else if(function(e){return Mb(e,`Delete`,Pb)}(e))e.preventDefault(),Hb(t,Qh,!1);else if(function(e){return Op&&Mb(e,`Backspace`,{metaKey:!0})}(e))e.preventDefault(),Hb(t,$h,!0);else if(function(e){return Op&&(Mb(e,`Delete`,{metaKey:!0})||Mb(e,`k`,{ctrlKey:!0}))}(e))e.preventDefault(),Hb(t,$h,!1);else if(function(e){return Mb(e,`b`,Nb)}(e))e.preventDefault(),Hb(t,eg,`bold`);else if(function(e){return Mb(e,`u`,Nb)}(e))e.preventDefault(),Hb(t,eg,`underline`);else if(function(e){return Mb(e,`i`,Nb)}(e))e.preventDefault(),Hb(t,eg,`italic`);else if(function(e){return Mb(e,`Tab`,{shiftKey:`any`})}(e))Hb(t,hg,e);else if(function(e){return Mb(e,`z`,Nb)}(e))e.preventDefault(),Hb(t,tg);else if(function(e){return Op?Mb(e,`z`,{metaKey:!0,shiftKey:!0}):Mb(e,`y`,{ctrlKey:!0})||Mb(e,`z`,{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),Hb(t,ng);else{let r=t._editorState._selection;(function(e){return Mb(e,`a`,Nb)})(e)?(e.preventDefault(),Hb(t,Sg,e)&&Gg(n)):r===null||Q(r)||(function(e){return Mb(e,`c`,Nb)}(e)?(e.preventDefault(),Hb(t,bg,e)):function(e){return Mb(e,`x`,Nb)}(e)&&(e.preventDefault(),Hb(t,xg,e)))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(e)&&t.dispatchCommand(kg,e),!0}function e_(e){let t=e.__lexicalEventHandles;return t===void 0&&(t=[],e.__lexicalEventHandles=t),t}var t_=new Map;function n_(e){let t=cx(e.target);if(t===null)return;let n=Gb(e.target),r=null,i=null,a=n===null?void 0:Fg.get(n);if(n!==null){if(a!==void 0){let e=a.editors,n=a.hasShadowEditor;if(n===void 0){n=!1;for(let t of e)if(t._rootElement!==null&&lx(t._rootElement.getRootNode())){n=!0;break}a.hasShadowEditor=n}if(n){let n=null,a=null;for(let o of e){let e=o._rootElement;if(e===null)continue;let s=_x(t,e).anchorNode;if(s!==null&&$y(s)===o){if(lx(e.getRootNode())){r=o,i=s;break}n===null&&(n=o,a=s)}}r===null&&n!==null&&(r=n,i=a)}else{let e=t.anchorNode;e===null||wx(e)&&e.shadowRoot!==null||(r=$y(e),r!==null&&(i=e))}}if(r===null){let e=Sx(n);r=e===null?null:$y(e)}}if(r===null)return;if(r._inputState.isSelectionChangeFromMouseDown){if(a!==void 0)for(let e of a.editors)e._inputState.isSelectionChangeFromMouseDown=!1;uy(r,()=>{let n=bv(),a=i??_x(t,r._rootElement).anchorNode;(wx(a)||rb(a))&&bb(vv(n,t,r,e))})}let o=wb(r),s=o[o.length-1],c=s._key,l=t_.get(c),u=l||s;u!==r&&zg(t,u,!1),zg(t,r,!0),r===s?l&&t_.delete(c):t_.set(c,r)}function r_(e){e._lexicalHandled=!0}function i_(e){return!0===e._lexicalHandled}function a_(e){let t=Pg.get(e);if(t===void 0)return;let n=Fg.get(t);if(n===void 0)return;Pg.delete(e);let r=eb(e);Qy(r)?(function(e){if(e._parentEditor!==null){let t=wb(e),n=t[t.length-1]._key;t_.get(n)===e&&t_.delete(n)}else t_.delete(e._key)}(r),n.editors.delete(r),n.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&X(198);let i=e_(e);for(let e=0;e<i.length;e++)i[e]();e.__lexicalEventHandles=[]}function o_(e,t,n){Gv();let r=e.__key,i=e.getParent();if(i===null)return void(sS(e)!==null&&X(367,r,String(sS(e))));let a=function(e){let t=yv();if(!Q(t)||!$(e))return t;let{anchor:n,focus:r}=t,i=n.getNode(),a=r.getNode();return Jb(i,e)&&n.set(e.__key,0,`element`),Jb(a,e)&&r.set(e.__key,0,`element`),t}(e),o=!1;if(Q(a)&&t){let t=a.anchor,n=a.focus;t.key===r&&(Cv(t,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0),n.key===r&&(Cv(n,e,i,e.getPreviousSibling(),e.getNextSibling()),o=!0)}else X_(a)&&t&&e.isSelected()&&e.selectPrevious();if(Q(a)&&t&&!o){let t=e.getIndexWithinParent();cb(e),xv(a,i,t,-1)}else cb(e);n||ex(i)||i.canBeEmpty()||!i.isEmpty()||o_(i,t),t&&a&&_y(i)&&i.isEmpty()&&i.selectEnd()}var s_=Symbol.for(`ephemeral`);function c_(e){return e[s_]||!1}var l_={configurable:!0,enumerable:!1,value:void 0,writable:!0},u_=class{__type;__key;__parent;__prev;__next;__state;[Hm];static getType(){let{ownNodeType:e}=Qx(this);return e===void 0&&X(64,this.name),e}static clone(e){X(65,this.name)}$config(){return{}}config(e,t){let n=t.extends||rS(this.constructor);return Object.assign(t,{extends:n}),typeof e==`string`&&Object.assign(t,{type:e}),{[e]:t}}afterCloneFrom(e){this.__key===e.__key?(this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev,this.__state=e.__state):e.__state&&(this.__state=e.__state.getWritable(this))}resetOnCopyNodeFrom(e){this.__state&&=this.__state.getWritable(this).resetOnCopyNode()}static importDOM;constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,"__state",l_),Object.defineProperty(this,Hm,l_),sb(this,e)}getType(){return this.__type}isInline(){X(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e===`root`)return!0;let t=fb(e);if(t===null)break;e=t.__parent===null?sS(t):t.__parent}return!1}isSelected(e){let t=e||yv();if(t==null)return!1;let n=t.getNodes().some(e=>e.__key===this.__key);if(Z(this))return n;if(Q(t)&&t.anchor.type===`element`&&t.focus.type===`element`){if(t.isCollapsed())return!1;let e=this.getParent();if(hy(this)&&this.isInline()&&e){let n=t.isBackward()?t.focus:t.anchor;if(e.is(n.getNode())&&n.offset===e.getChildrenSize()&&this.is(e.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){let e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){let e=this.getLatest().__parent;return e===null?null:fb(e)}getParentOrThrow(){let e=this.getParent();return e===null&&X(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){let t=e.getParent();if(ex(t)||sS(e)!==null)return $(e)||e===this&&hy(e)||X(194),e;e=t}return null}getTopLevelElementOrThrow(){let e=this.getTopLevelElement();return e===null&&X(67,this.__key),e}getParents(){let e=[],t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){let e=[],t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){let e=this.getLatest().__prev;return e===null?null:fb(e)}getPreviousSiblings(){let e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){let e=this.getLatest().__next;return e===null?null:fb(e)}getNextSiblings(){let e=[],t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){let t=$(this)?this:this.getParent(),n=$(e)?e:e.getParent(),r=t&&n?rC(t,n):null;return r?r.commonAncestor:null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){let t=rC(this,e);return t!==null&&(t.type===`descendant`||(t.type===`branch`?eC(t)===-1:(t.type!==`same`&&t.type!==`ancestor`&&X(279),!1)))}isParentOf(e){return Jb(e,this)}getNodesBetween(e){let t=this.isBefore(e),n=[],r=new Set,i=this;for(;i!==null;){let a=i.__key;if(r.has(a)||(r.add(a),n.push(i)),i===e)break;let o=$(i)?t?i.getFirstChild():i.getLastChild():null;if(o!==null){i=o;continue}let s=t?i.getNextSibling():i.getPreviousSibling();if(s!==null){i=s;continue}let c=i.getParentOrThrow();if(r.has(c.__key)||n.push(c),c===e)break;let l=null,u=c;do{if(u===null&&X(68),l=t?u.getNextSibling():u.getPreviousSibling(),u=u.getParent(),u===null)break;l!==null||r.has(u.__key)||n.push(u)}while(l===null);i=l}return t||n.reverse(),n}isDirty(){let e=Yv()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){if(c_(this))return this;let e=fb(this.__key);return e===null&&X(113),e}getWritable(){if(c_(this))return this;Gv();let e=qv(),t=Yv(),n=e._nodeMap,r=this.__key,i=this.getLatest(),a=t._cloneNotNeeded,o=yv();if(o!==null&&o.setCachedNodes(null),a.has(r))return lb(i),i;let s=Bx(i);return a.add(r),lb(s),n.set(r,s),s}getTextContent(){return bS(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){X(70)}updateDOM(e,t,n){X(71)}getDOMSlot(e){return new im(e)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){let e=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...e}}static importJSON(e){X(18,this.name)}updateFromJSON(e){return function(e,t){let n=e.getWritable(),r=t.$,i=r;for(let e of jm(n).flatKeys)e in t&&(i!==void 0&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&&Am(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){o_(this,!0,e)}replace(e,t){Gv();let n=yv();n!==null&&(n=n.clone()),rx(this,e);let r=this.getLatest(),i=this.__key,a=e.__key,o=e.getWritable(),s=this.getParentOrThrow().getWritable(),c=s.__size,l=o.getParent(),u=l===null?-1:o.getIndexWithinParent();cb(o),l!==null&&Q(n)&&xv(n,l,u,-1);let d=r.getPreviousSibling(),f=r.getNextSibling(),p=r.__prev,m=r.__next,h=r.__parent;o_(r,!1,!0),d===null?s.__first=a:d.getWritable().__next=a,o.__prev=p,f===null?s.__last=a:f.getWritable().__prev=a,o.__next=m,o.__parent=h,s.__size=c;let g=0;t&&($(this)&&$(o)||X(139),g=o.getChildrenSize(),o.splice(g,0,this.getChildren()));let _=fS(this);if(_.length>0){aS(this)&&aS(o)||X(368,this.__key,o.__key);for(let e of _){let t=pS(this,e);t!==null&&(wS(this,e),CS(o,e,t))}}if(Q(n)){bb(n);let e=n.anchor,r=n.focus;e.key===i&&(t&&e.type===`element`?e.set(o.__key,g+e.offset,`element`):W_(e,o)),r.key===i&&(t&&r.type===`element`?r.set(o.__key,g+r.offset,`element`):W_(r,o))}return db()===i&&ub(a),o}insertAfter(e,t=!0){Gv(),rx(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.getParent(),a=yv(),o=!1,s=!1;if(i!==null){let n=e.getIndexWithinParent();if(Q(a)){let e=i.__key,t=a.anchor,r=a.focus;o=t.type===`element`&&t.key===e&&t.offset===n+1,s=r.type===`element`&&r.key===e&&r.offset===n+1}cb(r),t&&Q(a)&&xv(a,i,n,-1)}else cb(r);let c=this.getNextSibling(),l=this.getParentOrThrow().getWritable(),u=r.__key,d=n.__next;if(c===null?l.__last=u:c.getWritable().__prev=u,l.__size++,n.__next=u,r.__next=d,r.__prev=n.__key,r.__parent=n.__parent,t&&Q(a)){let e=this.getIndexWithinParent();xv(a,l,e+1);let t=l.__key;o&&a.anchor.set(t,e+2,`element`),s&&a.focus.set(t,e+2,`element`)}return e}insertBefore(e,t=!0){Gv(),rx(this,e);let n=this.getWritable(),r=e.getWritable();this.getParentOrThrow();let i=r.__key,a=yv(),o=r.getParent(),s=o===null?-1:r.getIndexWithinParent();cb(r),o!==null&&t&&Q(a)&&xv(a,o,s,-1);let c=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),u=n.__prev,d=this.getIndexWithinParent();return c===null?l.__first=i:c.getWritable().__next=i,l.__size++,n.__prev=i,r.__prev=u,r.__next=n.__key,r.__parent=n.__parent,t&&Q(a)&&xv(a,this.getParentOrThrow(),d),e}isParentRequired(){return!1}createParentElementNode(){return Ny()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){Gv();let n=cS(this);if(n!==null)return n.selectPrevious(e,t);let r=this.getPreviousSibling(),i=this.getParentOrThrow();if(r===null)return i.select(0,0);if($(r))return r.select();if(!Z(r)){let e=r.getIndexWithinParent()+1;return i.select(e,e)}return r.select(e,t)}selectNext(e,t){Gv();let n=cS(this);if(n!==null)return n.selectNext(e,t);let r=this.getNextSibling(),i=this.getParentOrThrow();if(r===null)return i.select();if($(r))return r.select(0,0);if(!Z(r)){let e=r.getIndexWithinParent();return i.select(e,e)}return r.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}};function d_(e){return e instanceof u_}var f_=`history-push`,p_=`history-merge`,m_=`skip-selection-focus`,h_=`composition-end`,g_=`!important`;function __(e){let t={};if(!e)return t;let n=``,r=``,i=null,a=!1,o=!1,s=!1,c=0,l=e.length,u=-1;for(let d=0;d<l;d++){let l=e[d];if(a)l===`*`&&e[d+1]===`/`&&(a=!1,d++);else if(o)u===-1&&(u=d),o=!1;else if(i===null){if(l!==`/`||e[d+1]!==`*`){if(l!==`"`&&l!==`'`){if(l!==`(`){if(l!==`)`){if(s||l!==`:`||c!==0){if(l===`;`&&c===0){u!==-1&&(s?r+=e.slice(u,d):n+=e.slice(u,d),u=-1);let i=n.trim(),a=r.trim();i!==``&&a!==``&&(t[i]=a),n=``,r=``,s=!1;continue}u===-1&&(u=d)}else u!==-1&&(n+=e.slice(u,d),u=-1),s=!0}else u===-1&&(u=d),c=Math.max(0,c-1)}else u===-1&&(u=d),c++}else u===-1&&(u=d),i=l}else u!==-1&&(s?r+=e.slice(u,d):n+=e.slice(u,d),u=-1),a=!0,d++}else u===-1&&(u=d),l===`\\`?o=!0:l===i&&(i=null)}u!==-1&&(s?r+=e.slice(u,l):n+=e.slice(u,l));let d=n.trim(),f=r.trim();return d!==``&&f!==``&&(t[d]=f),t}function v_(e,t,n){let r=n.trimEnd(),i=r.length-10;i>=0&&r.slice(i).toLowerCase()===g_?e.setProperty(t,r.slice(0,i).trim(),`important`):e.setProperty(t,n,``)}function y_(e,t,n=``){if(t===n)return;let r=__(n),i=__(t);for(let t in i)delete r[t],v_(e,t,i[t]);for(let t in r)e.removeProperty(t)}function b_(e,t){return 16&t?`code`:t&128?`mark`:32&t?`sub`:64&t?`sup`:null}function x_(e,t){return 1&t?`strong`:2&t?`em`:`span`}function S_(e,t,n,r,i){let a=r.classList,o=Lb(i,`base`);o!==void 0&&a.add(...o),o=Lb(i,`underlineStrikethrough`);let s=!1,c=8&t&&4&t;o!==void 0&&(8&n&&4&n?(s=!0,c||a.add(...o)):c&&a.remove(...o));for(let e in Yp){let r=Yp[e];if(o=Lb(i,e),o!==void 0){if(n&r){if(s&&(e===`underline`||e===`strikethrough`)){t&r&&a.remove(...o);continue}((t&r)===0||c&&e===`underline`||e===`strikethrough`)&&a.add(...o)}else t&r&&a.remove(...o)}}}function C_(e,t,n){let r=n.isComposing(),i=e+(r?Kp:``),a=Mx(),o=Nx(a).$getDOMSlot(n,t,a),s=o.getFirstChild();if(s===null||s.nodeType!==Node.TEXT_NODE)return void o.insertChild(mx().createTextNode(i));let c=s,l=c.nodeValue;if(l!==i){if(r||kp){let[e,t,n]=function(e,t){let n=e.length,r=t.length,i=0,a=0;for(;i<n&&i<r&&e[i]===t[i];)i++;for(;a+i<n&&a+i<r&&e[n-a-1]===t[r-a-1];)a++;return[i,n-i-a,t.slice(i,r-a)]}(l,i);t!==0&&c.deleteData(e,t),c.insertData(e,n)}else c.nodeValue=i}}function w_(e,t,n,r,i,a){C_(i,e,t);let o=a.theme.text;o!==void 0&&S_(0,0,r,e,o)}function T_(e,t){let n=mx().createElement(t);return n.appendChild(e),n}function E_(e){return e!=null&&!0===e.__isInlineFormattable}var D_=class extends u_{__text;__format;__style;__mode;__detail;get __isInlineFormattable(){return!0}$config(){return this.config(`text`,{importDOM:{"#text":()=>({conversion:M_,priority:0}),b:()=>({conversion:k_,priority:0}),code:()=>({conversion:F_,priority:0}),em:()=>({conversion:F_,priority:0}),i:()=>({conversion:F_,priority:0}),mark:()=>({conversion:F_,priority:0}),s:()=>({conversion:F_,priority:0}),span:()=>({conversion:O_,priority:0}),strong:()=>({conversion:F_,priority:0}),sub:()=>({conversion:F_,priority:0}),sup:()=>({conversion:F_,priority:0}),u:()=>({conversion:F_,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text,this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e=``,t){super(t),this.__text=e,this.__format=0,this.__style=``,this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){return em[this.getLatest().__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===db()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){let t=Yp[e];return(this.getFormat()&t)!==0}isSimpleText(){return this.__type===`text`&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return ob(this.getLatest().__format,e,t)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,t){let n=this.__format,r=b_(0,n),i=x_(0,n),a=r===null?i:r,o=mx().createElement(a),s=o;this.hasFormat(`code`)&&o.setAttribute(`spellcheck`,`false`),r!==null&&(s=mx().createElement(i),o.appendChild(s)),w_(s,this,0,n,this.__text,e);let c=this.__style;return c!==``&&y_(o.style,c),o}updateDOM(e,t,n){let r=this.__text,i=e.__format,a=this.__format,o=b_(0,i),s=b_(0,a),c=x_(0,i),l=x_(0,a);if((o===null?c:o)!==(s===null?l:s))return!0;if(o===s&&c!==l){let e=t.firstChild;e??X(48);let i=mx().createElement(l);return w_(i,this,0,a,r,n),t.replaceChild(i,e),!1}let u=t;s!==null&&o!==null&&(u=t.firstChild,u??X(49)),C_(r,u,this);let d=n.theme.text;d!==void 0&&i!==a&&S_(0,i,a,u,d);let f=e.__style,p=this.__style;return f!==p&&y_(t.style,p,f),!1}updateFromJSON(e){return super.updateFromJSON(e).setTextContent(e.text).setFormat(e.format).setDetail(e.detail).setMode(e.mode).setStyle(e.style)}exportDOM(e){let{element:t}=super.exportDOM(e);return wx(t)||X(132),t.style.whiteSpace=`pre-wrap`,this.hasFormat(`lowercase`)?t.style.textTransform=`lowercase`:this.hasFormat(`uppercase`)?t.style.textTransform=`uppercase`:this.hasFormat(`capitalize`)&&(t.style.textTransform=`capitalize`),this.hasFormat(`bold`)&&(t=T_(t,`b`)),this.hasFormat(`italic`)&&(t=T_(t,`i`)),this.hasFormat(`strikethrough`)&&(t=T_(t,`s`)),this.hasFormat(`underline`)&&(t=T_(t,`u`)),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(e,t){}setFormat(e){let t=this.getWritable();return t.__format=typeof e==`string`?Yp[e]:e,t}setDetail(e){let t=this.getWritable();return t.__detail=typeof e==`string`?Xp[e]:e,t}setStyle(e){let t=this.getWritable();return t.__style=e,t}toggleFormat(e){let t=ob(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){let e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){let e=this.getWritable();return e.__detail^=2,e}setMode(e){let t=$p[e];if(this.__mode===t)return this;let n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;let t=this.getWritable();return t.__text=e,t}select(e,t){Gv();let n=e,r=t,i=yv(),a=this.getTextContent(),o=this.__key;if(typeof a==`string`){let e=a.length;n===void 0&&(n=e),r===void 0&&(r=e)}else n=0,r=0;if(!Q(i))return hv(o,n,o,r,`text`,`text`);{let e=db();e!==i.anchor.key&&e!==i.focus.key||ub(o),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){let e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,r){let i=this.getWritable(),a=i.__text,o=n.length,s=e;s<0&&(s=o+s,s<0&&(s=0));let c=yv();if(r&&Q(c)){let t=e+o;c.setTextNodeRange(i,t,i,t)}return i.__text=a.slice(0,s)+n+a.slice(s+t),i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){Gv();let t=this.getLatest(),n=t.getTextContent();if(n===``)return[];let r=t.__key,i=db(),a=n.length;e.sort((e,t)=>e-t),e.push(a);let o=[],s=e.length;for(let t=0,r=0;t<a&&r<=s;r++){let i=e[r];i>t&&(o.push(n.slice(t,i)),t=i)}let c=o.length;if(c===1)return[t];let l=o[0],u=t.getParent(),d,f=t.getFormat(),p=t.getStyle(),m=t.__detail,h=!1,g=null,_=null,v=yv();if(Q(v)){let[e,t]=v.isBackward()?[v.focus,v.anchor]:[v.anchor,v.focus];e.type===`text`&&e.key===r&&(g=e),t.type===`text`&&t.key===r&&(_=t)}t.isSegmented()?(d=I_(l),d.__format=f,d.__style=p,d.__detail=m,d.__state=Im(t,d),h=!0):d=t.setTextContent(l);let y=[d];for(let e=1;e<c;e++){let n=I_(o[e]);n.__format=f,n.__style=p,n.__detail=m,n.__state=Im(t,n);let a=n.__key;i===r&&ub(a),y.push(n)}let b=g?g.offset:null,x=_?_.offset:null,S=0;for(let e of y){if(!g&&!_)break;let t=S+e.getTextContentSize();if(g!==null&&b!==null&&b<=t&&b>=S&&(g.set(e.getKey(),b-S,`text`),b<t&&(g=null)),_!==null&&x!==null&&x<=t&&x>=S){_.set(e.getKey(),x-S,`text`);break}S=t}if(u!==null){(function(e){let t=e.getPreviousSibling(),n=e.getNextSibling();t!==null&&lb(t),n!==null&&lb(n)})(this);let e=u.getWritable(),t=this.getIndexWithinParent();h?(e.splice(t,0,y),this.remove()):e.splice(t,1,y),Q(v)&&xv(v,u,t,c-1)}return y}mergeWithSibling(e){let t=e===this.getPreviousSibling();t||e===this.getNextSibling()||X(50);let n=this.__key,r=e.__key,i=this.__text,a=i.length;db()===r&&ub(n);let o=yv();if(Q(o)){let i=o.anchor,s=o.focus;i!==null&&i.key===r&&wv(i,t,n,e,a),s!==null&&s.key===r&&wv(s,t,n,e,a)}let s=e.__text,c=t?s+i:i+s;this.setTextContent(c);let l=this.getWritable();return e.remove(),l}isTextEntity(){return!1}};function O_(e){return{forChild:L_(e.style),node:null}}function k_(e){let t=e,n=t.style.fontWeight===`normal`;return{forChild:L_(t.style,n?void 0:`bold`),node:null}}var A_=new WeakMap;function j_(e){if(!wx(e))return!1;if(e.nodeName===`PRE`)return!0;let t=e.style.whiteSpace;return typeof t==`string`&&t.startsWith(`pre`)}function M_(e){let t=e;e.parentElement===null&&X(129);let n=t.textContent||``;if(function(e){let t,n=e.parentNode,r=[e];for(;n!==null&&(t=A_.get(n))===void 0&&!j_(n);)r.push(n),n=n.parentNode;let i=t===void 0?n:t;for(let e=0;e<r.length;e++)A_.set(r[e],i);return i}(t)!==null)return{node:kv(n)};if(n=n.replace(/\r/g,``).replace(/[ \t\n]+/g,` `),n===``)return{node:null};if(n[0]===` `){let e=t,r=!0;for(;e!==null&&(e=N_(e,!1))!==null;){let t=e.textContent||``;if(t.length>0){/[ \t\n]$/.test(t)&&(n=n.slice(1)),r=!1;break}}r&&(n=n.slice(1))}if(n[n.length-1]===` `){let e=t,r=!0;for(;e!==null&&(e=N_(e,!0))!==null;)if((e.textContent||``).replace(/^( |\t|\r?\n)+/,``).length>0){r=!1;break}r&&(n=n.slice(0,n.length-1))}return n===``?{node:null}:{node:I_(n)}}function N_(e,t){let n=e;for(;;){let e;for(;(e=t?n.nextSibling:n.previousSibling)===null;){let e=n.parentElement;if(e===null)return null;n=e}if(n=e,wx(n)){let e=n.style.display;if(e===``&&!Ox(n)||e!==``&&!e.startsWith(`inline`))return null}let r=n;for(;(r=t?n.firstChild:n.lastChild)!==null;)n=r;if(rb(n))return n;if(n.nodeName===`BR`)return null}}var P_={code:`code`,em:`italic`,i:`italic`,mark:`highlight`,s:`strikethrough`,strong:`bold`,sub:`subscript`,sup:`superscript`,u:`underline`};function F_(e){let t=P_[e.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:L_(e.style,t),node:null}}function I_(e=``){return nx(new D_(e))}function Z(e){return e instanceof D_}function L_(e,t){let n=e.fontWeight,r=e.textDecoration.split(` `),i=n===`700`||n===`bold`,a=r.includes(`line-through`),o=e.fontStyle===`italic`,s=r.includes(`underline`),c=e.verticalAlign;return e=>Z(e)||E_(e)?(i&&!e.hasFormat(`bold`)&&e.toggleFormat(`bold`),a&&!e.hasFormat(`strikethrough`)&&e.toggleFormat(`strikethrough`),o&&!e.hasFormat(`italic`)&&e.toggleFormat(`italic`),s&&!e.hasFormat(`underline`)&&e.toggleFormat(`underline`),c!==`sub`||e.hasFormat(`subscript`)||e.toggleFormat(`subscript`),c!==`super`||e.hasFormat(`superscript`)||e.toggleFormat(`superscript`),t&&!e.hasFormat(t)&&e.toggleFormat(t),e):e}var R_=class extends D_{$config(){return this.config(`tab`,{extends:D_})}constructor(e=void 0){super(` `,e),this.__detail=2}createDOM(e){let t=super.createDOM(e),n=Lb(e.theme,`tab`);return n!==void 0&&t.classList.add(...n),t}setTextContent(e){return super.setTextContent(` `)}spliceText(e,t,n,r){return n===``&&t===0||n===` `&&t===1||X(286),this}setDetail(e){return e!==2&&X(127),this}setMode(e){return e!==`normal`&&X(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}};function z_(){return nx(new R_)}function B_(e){return e instanceof R_}var V_=class{key;offset;type;_selection;constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){return this.key===e.key?this.offset<e.offset:$S(pC(iC(this,`next`)),pC(iC(e,`next`)))<0}getNode(){let e=fb(this.key);return e===null&&X(20),e}set(e,t,n,r){let i=this._selection,a=this.key;r&&this.key===e&&this.offset===t&&this.type===n||(this.key=e,this.offset=t,this.type=n,Wv()||(db()===a&&ub(e),i!==null&&(i.setCachedNodes(null),Q(i)&&(i._cachedIsBackward=null),i.dirty=!0)))}};function H_(e,t,n){return new V_(e,t,n)}function U_(e,t){let n=t.__key,r=e.offset,i=`element`;if(Z(t)){i=`text`;let e=t.getTextContentSize();r>e&&(r=e)}else if(!$(t)){let e=t.getNextSibling();if(Z(e))n=e.__key,r=0,i=`text`;else{let e=t.getParent();e&&(n=e.__key,r=t.getIndexWithinParent()+1)}}e.set(n,r,i)}function W_(e,t){if($(t)){let n=t.getLastDescendant();$(n)||Z(n)?U_(e,n):U_(e,t)}else U_(e,t)}function G_(e,t,n,r){let i=e.getNode(),a=i.getChildAtIndex(e.offset),o=I_();if(o.setFormat(n),o.setStyle(r),Py(a))a.splice(0,0,[o]);else if(a!==null){let e=ex(i)?Ny().append(o):o;a.insertBefore(e)}else if(ex(i)){let e=i.getLastChild();$(e)&&!e.isInline()&&e.isEmpty()?e.append(o):i.append(Ny().append(o))}else i.append(o);e.is(t)&&t.set(o.__key,0,`text`),e.set(o.__key,0,`text`)}function K_(e,t,n,r){let i=e.anchor.getNode();Z(i)||X(398);let a=e.anchor.offset,o=I_(t);o.setFormat(n),o.setStyle(r);let s=i.getParentOrThrow();if(a===0)s.isInline()&&!i.__prev?s.insertBefore(o):i.insertBefore(o,!1);else if(a===i.getTextContentSize())s.isInline()&&!i.__next?s.insertAfter(o):i.insertAfter(o,!1);else{let[e]=i.splitText(a);e.insertAfter(o,!1)}i.getTextContent()===``&&i.isAttached()&&i.remove(),o.selectEnd(),o.isComposing()&&e.anchor.type===`text`&&e.anchor.set(e.anchor.key,e.anchor.offset-t.length,e.anchor.type)}var q_=class e{_nodes;_cachedNodes;dirty;constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!X_(e))return!1;let t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(e=>n.has(e))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new e(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){let t=this.getNodes().filter(e=>sS(e)===null),n=t.length;if(n===0)return;let r=t[n-1],i;if(Z(r))i=r.select();else{let e=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(e,e)}i.insertNodes(e);for(let e=0;e<n;e++)t[e].remove()}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=this._nodes,n=[];for(let e of t){let t=fb(e);t!==null&&n.push(t)}return Wv()||(this._cachedNodes=n),n}getTextContent(){let e=this.getNodes(),t=``;for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}deleteNodes(){let e=this.getNodes().filter(e=>sS(e)===null);if((yv()||bv())===this&&e[0]){let t=BS(e[0],`next`);oC(ZS(t,t))}for(let t of e)t.remove();J_()}};function J_(){let e=yb();if(e.isEmpty()){let t=Ny();e.append(t),t.select()}}function Q(e){return e instanceof Y_}var Y_=class e{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(e,t,n,r){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=r,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!Q(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){let e=this._cachedNodes;if(e!==null)return e;let t=function(e){let t=[],[n,r]=e.getTextSlices();n&&t.push(n.caret.origin);let i=new Set,a=new Set;for(let n of e)if(IS(n)){let{origin:e}=n;t.length===0?i.add(e):(a.add(e),t.push(e))}else{let{origin:e}=n;$(e)&&a.has(e)||t.push(e)}if(r&&t.push(r.caret.origin),FS(e.focus)&&$(e.focus.origin)&&e.focus.getNodeAtCaret()===null)for(let n=WS(e.focus.origin,`previous`);IS(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(t[t.length-1]);n=KS(n))i.delete(n.origin),t.pop();for(;t.length>1;){let e=t[t.length-1];if(!$(e)||a.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(t.length===0&&e.isCollapsed()){let n=pC(e.anchor),r=pC(e.anchor.getFlipped()),i=e=>PS(e)?e.origin:e.getNodeAtCaret(),a=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(a)}return t}(gC(cC(this),`next`));return Wv()||(this._cachedNodes=t),t}setTextNodeRange(e,t,n,r){return this.anchor.set(e.__key,t,`text`),this.focus.set(n.__key,r,`text`),this}getTextContent(){let e=this.getNodes();if(e.length===0)return``;let t=e[0],n=e[e.length-1],r=this.anchor,i=this.focus,a=r.isBefore(i),[o,s]=ev(this),c=``,l=!0;for(let u=0;u<e.length;u++){let d=e[u];if($(d)&&!d.isInline()){l||(c+=`
|
|
15
|
-
`);let e=``;for(let t of fS(d)){let n=pS(d,t);n!==null&&(e+=n.getTextContent())}e===``?l=!d.isEmpty():(c+=e,l=!1)}else if(l=!1,Z(d)){let e=d.getTextContent();d===t?d===n?r.type===`element`&&i.type===`element`&&i.offset!==r.offset||(e=o<s?e.slice(o,s):e.slice(s,o)):e=a?e.slice(o):e.slice(s):d===n&&(e=a?e.slice(0,s):e.slice(0,o)),c+=e}else!hy(d)&&!Dy(d)||d===n&&this.isCollapsed()||(c+=d.getTextContent())}return c}applyDOMRange(e){let t=Yv(),n=t.getEditorState()._selection,r=pv(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(r===null)return;let[i,a,o]=r;this.anchor.set(i.key,i.offset,i.type,!0),this.focus.set(a.key,a.offset,a.type,!0),o&&(this.dirty=!0),Bm(this)}clone(){let t=this.anchor,n=this.focus;return new e(H_(t.key,t.offset,t.type),H_(n.key,n.offset,n.type),this.format,this.style)}toggleFormat(e){this.format=ob(this.format,e,null),this.dirty=!0}setFormat(e){this.format=e,this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){let t=Yp[e];return(this.format&t)!==0}insertRawText(e){this.insertNodes(kv(e))}insertText(e){let t=this.format,n=this.style;if(!this.isCollapsed()){let r=(this.focus.isBefore(this.anchor)?this.focus:this.anchor).getNode();if(Z(r)&&(t=r.getFormat(),n=r.getStyle()),this.removeText(),this.format=t,this.style=n,e===``)return;if(db()===null)return this.anchor.type===`element`&&G_(this.anchor,this.focus,t,n),void K_(this,e,t,n)}this.anchor.type===`element`&&G_(this.anchor,this.focus,t,n);let r=this.anchor.getNode();Z(r)||X(398);let i=this.anchor.offset,a=r.getParentOrThrow(),o=r.getTextContentSize();if(nb(r)||i===0&&(!r.canInsertTextBefore()||!a.canInsertTextBefore()&&!r.__prev)||i===o&&(!r.canInsertTextAfter()||!a.canInsertTextAfter()&&!r.__next)){if(r.isSegmented()&&i!==0&&i!==o){if(db()!==null)r.setMode(`normal`).setFormat(t).setStyle(n);else{let e=I_(r.getTextContent());e.setFormat(t),e.setStyle(n),r.replace(e),e.select(i,i)}e!==``&&this.insertText(e);return}if(e===``)return;if(i===0){let i=r.getPreviousSibling();if(Z(i)&&i.canInsertTextAfter()&&!nb(i))i.select();else{let e=I_();e.setFormat(t),e.setStyle(n),a.canInsertTextBefore()?r.insertBefore(e):a.insertBefore(e),e.select()}this.insertText(e);return}if(i===o){let i=r.getNextSibling();if(Z(i)&&i.canInsertTextBefore()&&!nb(i))i.select(0,0);else{let e=I_();e.setFormat(t),e.setStyle(n),a.canInsertTextAfter()?r.insertAfter(e):a.insertAfter(e),e.select(0,0)}this.insertText(e);return}let s=I_(e);s.setFormat(t),s.setStyle(n),r.replace(s),s.select();return}if(e===``)return;let s=a.isInline()&&i===0&&!r.__prev,c=a.isInline()&&i===o&&!r.__next,l=r.getFormat()!==t||r.getStyle()!==n;if(s||c||l){if(r.getTextContent()!==``||s||c)return void K_(this,e,t,n);r.setFormat(t),r.setStyle(n)}r.spliceText(i,0,e,!0),r.isComposing()&&this.anchor.type===`text`&&this.anchor.set(this.anchor.key,this.anchor.offset-e.length,this.anchor.type)}removeText(){let e=yv()===this;sC(this,fC(cC(this))),e&&yv()!==this&&bb(this)}formatText(e,t=null){Q_(this,e,t)}insertNodes(e){if(e.length===0)return;this.isCollapsed()||this.removeText();let t=this.anchor.getNode();if(this.anchor.type===`element`&&$(t)&&sS(t)!==null){let n=t.isShadowRoot()?t.getFirstChild()??t.append(Ny()).getFirstChild():t.getFirstChild();if(t.isShadowRoot()&&n!==null&&!$(n)){let e=Ny();n.insertBefore(e),n=e}if(n!==null){n.selectStart();let t=yv();return Q(t)||X(369),t.insertNodes(e)}}if(this.anchor.type===`element`&&ex(t)){let n=Pv(e),r=n.getLastDescendant();t.splice(this.anchor.offset,0,n.getChildren()),r!==null&&r.selectEnd();return}let n=(this.isBackward()?this.focus:this.anchor).getNode(),r=tS(n,jx),i=e[e.length-1];if($(r)&&`__language`in r){if(`__language`in e[0])this.insertText(e[0].getTextContent());else{let t=jv(this);r.splice(t,0,e),i.selectEnd()}return}if(!e.some(e=>($(e)||hy(e))&&!e.isInline())){$(r)||X(211,n.constructor.name,n.getType());let t=jv(this);r.splice(t,0,e),i.selectEnd();return}if($(r)&&sS(r)!==null){let t=jv(this),n=Av(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}if(r===null){let t=Pv(e),n=t.getLastDescendant(),r=iC(this.anchor,`next`);for(let e of t.getChildren())r=xC(e,r);n!==null&&n.selectEnd();return}if($(r)&&!r.isParentRequired()&&!ex(r.getParentOrThrow())){let t=jv(this),n=Av(e);r.splice(t,0,n);let i=n[n.length-1];i===void 0?r.select(t,t):i.selectEnd();return}let a=Pv(e),o=a.getLastDescendant(),s=a.getChildren(),c=!$(r)||!r.isEmpty()?this.insertParagraph():null;c&&!r.isAttached()&&(n=this.anchor.getNode(),r=tS(n,jx));let l=s[s.length-1],u=s[0];var d;$(d=u)&&jx(d)&&!d.isEmpty()&&$(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&($(r)||X(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=s[1]),u&&(r===null&&X(212,n.constructor.name,n.getType()),function(e,t){let n=t.getParentOrThrow().getLastChild(),r=t,i=[t];for(;r!==n;)r.getNextSibling()||X(140),r=r.getNextSibling(),i.push(r);let a=e;for(let e of i)a=a.insertAfter(e)}(r,u));let f=tS(o,jx);c&&$(f)&&(c.canMergeWhenEmpty()||jx(l))&&(f.append(...c.getChildren()),c.remove()),$(r)&&r.isEmpty()&&r.remove(),o.selectEnd();let p=$(r)?r.getLastChild():null;Dy(p)&&f!==r&&p.remove()}insertParagraph(){let e=this.anchor.getNode();if(this.anchor.type===`element`&&ex(e)){let t=Ny();return e.splice(this.anchor.offset,0,[t]),t.select(),t}let t=jv(this),n=tS(this.anchor.getNode(),jx);if(n!==null&&sS(n)!==null)return null;$(n)||X(213);let r=n.getChildAtIndex(t),i=r?[r,...r.getNextSiblings()]:[],a=n.insertNewAfter(this,!1);return a?(a.append(...i),a.selectStart(),a):null}insertLineBreak(e){let t=Ey();if(this.insertNodes([t]),e){let e=t.getParentOrThrow(),n=t.getIndexWithinParent();e.select(n,n)}}extract(){let e=[...this.getNodes()],t=e.length,n=e[0],r=e[t-1],[i,a]=ev(this),o=this.isBackward(),[s,c]=o?[this.focus,this.anchor]:[this.anchor,this.focus],[l,u]=o?[a,i]:[i,a];if(t===0)return[];if(t===1){if(Z(n)&&!this.isCollapsed()){let e=n.splitText(l,u),t=l===0?e[0]:e[1];return t?(s.set(t.getKey(),0,`text`),c.set(t.getKey(),t.getTextContentSize(),`text`),[t]):[]}return[n]}if(Z(n)&&(l===n.getTextContentSize()?e.shift():l!==0&&([,n]=n.splitText(l),e[0]=n,s.set(n.getKey(),0,`text`))),Z(r)){let t=r.getTextContent().length;u===0?e.pop():u!==t&&([r]=r.splitText(u),e[e.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),`text`))}return e}modify(e,t,n){if(Fv(this,e,t,n))return;let r=e===`move`,i=Yv(),a=sx(Xb(i));if(!a)return;let o=i._blockCursorElement,s=i._rootElement,c=this.focus.getNode();s===null||o===null||!$(c)||c.isInline()||c.canBeEmpty()||ox(o,i,s);let l=Ub(i,this.focus.key),u=l;if(this.focus.type===`text`&&(u=Z(c)?Ix(c,l,i):null),this.dirty){let e=Ub(i,this.anchor.key),t=e;if(this.anchor.type===`text`){let n=this.anchor.getNode();t=Z(n)?Ix(n,e,i):null}t&&u&&Tv(a,t,this.anchor.offset,u,this.focus.offset)}if(n===`character`&&Z(c)&&c.isUnmergeable()&&(t?this.focus.offset===0:this.focus.offset===c.getTextContentSize())){let e=BS(c,t?`previous`:`next`).getNodeAtCaret();if(Z(e)){if(!r){let n=e.getTextContentSize();t?this.focus.set(e.__key,n-1,`text`):this.focus.set(e.__key,1,`text`),this.dirty=!0;return}{let n=i.getElementByKey(e.getKey()),r=n?Ix(e,n,i):null;if(r){let e=t?r.length:0;Tv(a,r,e,r,e)}}}}if(rv(a,e,t?`backward`:`forward`,n),a.rangeCount>0){let e=hx(a,i._rootElement),n=e||a.getRangeAt(0),o=this.anchor.getNode(),s=_y(o)?o:Qb(o);this.applyDOMRange(n),this.dirty=!0,!r&&(iv(this,t,s),(e?a.direction!==`backward`:a.anchorNode===n.startContainer&&a.anchorOffset===n.startOffset)||nv(this))}n===`lineboundary`&&Fv(this,e,t,n,`decorators`)}forwardDeletion(e,t,n){if(!n&&(e.type===`element`&&$(t)&&e.offset===t.getChildrenSize()||e.type===`text`&&e.offset===t.getTextContentSize())){let e=t.getParent(),n=t.getNextSibling()||(e===null?null:e.getNextSibling());if($(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){let t=this.isCollapsed();if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;let r=YS(iC(t,e?`previous`:`next`));if(r.getTextSlices().every(e=>e===null||e.distance===0)){let e={type:`initial`};for(let t of r.iterNodeCarets(`shadowRoot`))if(IS(t)){if(!t.origin.isInline()){if(t.origin.isShadowRoot()){if(e.type===`merge-block`)break;if($(r.anchor.origin)&&r.anchor.origin.isEmpty()){let e=pC(t);sC(this,ZS(e,e)),r.anchor.origin.remove()}return}e.type!==`merge-next-block`&&e.type!==`merge-block`||(e={block:e.block,caret:t,type:`merge-block`})}}else{if(e.type===`merge-block`)break;if(FS(t)){if($(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:`merge-next-block`};continue}if(hy(t.origin)){if(!t.origin.isIsolated()){if(fS(t.origin).length>0){if($(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=_v();e.add(t.origin.getKey()),bb(e)}}else if(e.type===`merge-next-block`&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&$(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();let e=_v();e.add(t.origin.getKey()),bb(e)}else t.origin.remove()}return}break}}if(e.type===`merge-block`){let{caret:t,block:n}=e;return fS(n).length>0?void 0:t.origin.isEmpty()&&!n.isEmpty()&&t.origin.getParent()===n.getParent()?void t.origin.remove(!0):(sC(this,ZS(!t.origin.isEmpty()&&n.isEmpty()?lC(BS(n,t.direction)):r.anchor,t)),this.removeText())}for(let e=t.getNode();e!==null;){if(sS(e)!==null)return;if($(e)&&e.isShadowRoot())break;e=e.getParent()}}let i=this.focus;if(av(this,e,`character`),this.isCollapsed()){if(e&&t.offset===0&&tv(this,t.getNode()))return}else{let r=i.type===`text`?i.getNode():null;if(n=t.type===`text`?t.getNode():null,r!==null&&r.isSegmented()){let t=i.offset,a=r.getTextContentSize();if(r.is(n)||e&&t!==a||!e&&t!==0)return void sv(r,e,t)}else if(n!==null&&n.isSegmented()){let i=t.offset,a=n.getTextContentSize();if(n.is(r)||e&&i!==0||!e&&i!==a)return void sv(n,e,i)}(function(e,t){let n=e.anchor,r=e.focus,i=n.getNode();if(i===r.getNode()&&n.type===`text`&&r.type===`text`){let e=n.offset,a=r.offset,o=e<a,s=o?e:a,c=o?a:e,l=c-1;s!==l&&(function(e){return!(Cb(e)||ov(e))})(i.getTextContent().slice(s,c))&&(t?r.set(r.key,l,r.type):n.set(n.key,l,n.type))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type===`element`&&this.anchor.offset===0){let e=this.anchor.getNode();e.isEmpty()&&_y(e.getParent())&&e.getPreviousSibling()===null&&tv(this,e),J_()}}deleteLine(e){let t=uv(this.anchor);if(t!==null&&hy(cS(t)))return this.isCollapsed()||this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),void this.deleteCharacter(e);this.isCollapsed()&&av(this,e,`lineboundary`),this.isCollapsed()?this.deleteCharacter(e):tS(this.anchor.getNode(),jx)===tS(this.focus.getNode(),jx)?this.removeText():(this.focus.set(this.anchor.key,this.anchor.offset,this.anchor.type),this.deleteCharacter(e))}deleteWord(e){if(this.isCollapsed()){let t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;av(this,e,`word`)}this.isCollapsed()?this.deleteCharacter(e):this.removeText()}isBackward(){let e=this._cachedIsBackward;if(e!==null)return e;let t=this.focus.isBefore(this.anchor);return Wv()||(this._cachedIsBackward=t),t}getStartEndPoints(){return[this.anchor,this.focus]}};function X_(e){return e instanceof q_}function Z_(e,t){if(X_(e)){for(let n of e.getNodes())E_(n)&&n.setFormat(t(n.getFormat()));return}if(e.isCollapsed())return e.setFormat(t(e.format)),void ub(null);let n=[];for(let r of e.getNodes())Z(r)?n.push(r):$(r)?r.setTextFormat(t(r.getTextFormat())):E_(r)&&r.setFormat(t(r.getFormat()));let r=n.length;if(r===0)return e.setFormat(t(e.format)),void ub(null);let i=e.anchor,a=e.focus,o=e.isBackward(),s=o?a:i,c=o?i:a,l=0,u=n[0],d=s.type===`element`?0:s.offset;if(s.type===`text`&&d===u.getTextContentSize()&&(l=1,u=n[1],d=0),u==null)return;let f=r-1,p=n[f],m=c.type===`text`?c.offset:p.getTextContentSize();if(u.is(p)){if(d===m)return;let n=t(u.getFormat());if(nb(u)||d===0&&m===u.getTextContentSize())u.setFormat(n);else{let e=u.splitText(d,m),t=d===0?e[0]:e[1];t.setFormat(n),s.type===`text`&&s.set(t.__key,0,`text`),c.type===`text`&&c.set(t.__key,m-d,`text`)}e.format=n;return}d===0||nb(u)||([,u]=u.splitText(d),d=0);let h=t(u.getFormat());u.setFormat(h);let g=t(p.getFormat());m>0&&(m===p.getTextContentSize()||nb(p)||([p]=p.splitText(m)),p.setFormat(g));for(let e=l+1;e<f;e++){let r=n[e];r.setFormat(t(r.getFormat()))}s.type===`text`&&s.set(u.__key,d,`text`),c.type===`text`&&c.set(p.__key,m,`text`),e.format=h|g}function Q_(e,t,n=null){let r=n===null&&Q(e)?ob(e.format,t,null):n;Z_(e,e=>ob(e,t,r))}function $_(e){let t=e.offset;if(e.type===`text`)return t;let n=e.getNode();return t===n.getChildrenSize()?n.getTextContent().length:0}function ev(e){let t=e.getStartEndPoints();if(t===null)return[0,0];let[n,r]=t;return n.type===`element`&&r.type===`element`&&n.key===r.key&&n.offset===r.offset?[0,0]:[$_(n),$_(r)]}function tv(e,t){for(let n=t;n;n=n.getParent()){if($(n)){if(n.collapseAtStart(e))return!0;if(ex(n))break}if(n.getPreviousSibling())break}return!1}function nv(e){let t=e.focus,n=e.anchor,r=n.key,i=n.offset,a=n.type;n.set(t.key,t.offset,t.type,!0),t.set(r,i,a,!0)}function rv(e,t,n,r){e.modify(t,n,r)}function iv(e,t,n){let r=e.getNodes(),i=r.filter(e=>Jb(e,n));if(i.length===0||i.length===r.length)return!1;let a=t?i[0]:i[i.length-1],o=$(a)?a:a.getParentOrThrow();return t?o.selectStart():o.selectEnd(),!0}function av(e,t,n){if(Fv(e,`extend`,t,n))return;let r=Yv(),i=sx(Xb(r));if(!i||typeof i.modify!=`function`)return;let a=r._blockCursorElement,o=r._rootElement,s=e.anchor,c=e.focus.getNode();o===null||a===null||!$(c)||c.isInline()||c.canBeEmpty()||ox(a,r,o);let l=e=>{let t=e.getNode(),n=r.getElementByKey(e.key);return n!==null&&e.type===`text`&&Z(t)?Ix(t,n,r):n},u=s.getNode(),d=l(s);if(d===null)return;let f=s.offset,p=e.isCollapsed(),m=e.focus,h=p?d:l(m);if(h===null)return;let g=m.offset;if(Tv(i,h,g,h,g),rv(i,`move`,t?`backward`:`forward`,n),i.rangeCount===0)return;let _=hx(i,o)||i.getRangeAt(0),v=_.startContainer,y=_.startOffset;if(p&&n===`character`&&s.type===`text`&&Z(u)&&u.isUnmergeable()&&f===(t?0:u.getTextContentSize())){let n=BS(u,t?`previous`:`next`).getNodeAtCaret();if(Z(n)){let r=t?n.getTextContentSize()-1:1;e.focus.set(n.__key,r,`text`),e.dirty=!0;return}}if(p&&n===`character`&&s.type===`text`){let n=t?0:u.getTextContentSize(),r=v===d?y:f===n?-1:n;if(r>=0)return void(r!==f&&(e.focus.set(s.key,r,`text`),e.dirty=!0))}let[b,x,S,C]=t?[v,y,d,f]:[d,f,v,y],w=_y(u)?u:Qb(u);e.applyDOMRange({collapsed:!1,endContainer:S,endOffset:C,startContainer:b,startOffset:x}),e.dirty=!0,!iv(e,t,w)&&t&&nv(e),n===`lineboundary`&&Fv(e,`extend`,t,n,`decorators`)}var ov=(()=>{try{let e=RegExp(`\\p{Emoji}`,`u`),t=e.test.bind(e);if(t(`❤️`)&&t(`#️⃣`)&&t(`👍`))return t}catch{}return()=>!1})();function sv(e,t,n){let r=e,i=r.getTextContent().split(/(?=\s)/g),a=i.length,o=0,s=0;for(let e=0;e<a;e++){let r=e===a-1;if(s=o,o+=i[e].length,t&&o===n||o>n||r){i.splice(e,1),r&&(s=void 0);break}}let c=i.join(``).trim();c===``?r.remove():(r.setTextContent(c),r.select(s,s))}function cv(e,t,n,r){let i,a=t,o=!1;if(wx(e)){let s=!1,c=e.childNodes,l=c.length,u=r._blockCursorElement;a===l&&l>0&&(s=!0,a=l-1),hb(e,r)!==void 0||Jx(e,r)||(o=!0);let d=c[a],f=!1;if(d===u)d=c[a+1],f=!0;else if(u!==null){let n=u.parentNode;e===n&&t>Array.prototype.indexOf.call(n.children,u)&&a--}if(i=Sb(d),Z(i))a=HS(i,s?`next`:`previous`);else{let c=Sb(e);if(c===null)return null;if($(c)){let o=r.getElementByKey(c.getKey());o===null&&X(214);let l=Px(c,o,r);[c,a]=l.resolveChildIndex(c,o,e,t),$(c)||X(215),s&&a>=c.getChildrenSize()&&(a=Math.max(0,c.getChildrenSize()-1));let u=c.getChildAtIndex(a);if($(u)&&function(e,t,n){let r=e.getParent();return n===null||r===null||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){let e=s?u.getLastDescendant():u.getFirstDescendant();e===null?c=u:(u=e,c=$(u)?u:u.getParentOrThrow()),a=0}Z(u)?(i=u,c=null,a=HS(u,s?`next`:`previous`)):u!==c&&s&&!f&&($(c)||X(216),a=Math.min(c.getChildrenSize(),a+1))}else{let n=cS(c),i=n===null?c:n,o=i.getIndexWithinParent(),s=r.getElementByKey(c.getKey()),l=`after`;if(s!==null&&Sb(e)===c){let n=Px(c,s,r);n.element===s?t===0&&hy(c)&&(l=`before`):l=n.resolveLeafPosition(s,e,t)}a=l===`before`?o:o+1,c=i.getParentOrThrow()}if($(c))return[H_(c.__key,a,`element`),o]}}else i=Sb(e);return Z(i)?[H_(i.__key,HS(i,a,`clamp`),`text`),o]:null}function lv(e,t,n){let r=e.offset,i=e.getNode();if(r===0){let r=i.getPreviousSibling(),a=i.getParent();if(t){if((n||!t)&&r===null&&$(a)&&a.isInline()){let t=a.getPreviousSibling();Z(t)&&e.set(t.__key,t.getTextContent().length,`text`)}}else $(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),`element`):Z(r)&&!i.isUnmergeable()&&e.set(r.__key,r.getTextContent().length,`text`)}else if(r===i.getTextContent().length){let r=i.getNextSibling(),a=i.getParent();if(t&&$(r)&&r.isInline())e.set(r.__key,0,`element`);else if((n||t)&&r===null&&$(a)&&a.isInline()&&!a.canInsertTextAfter()&&a.getTextContentSize()>1){let t=a.getNextSibling();Z(t)&&e.set(t.__key,0,`text`)}}}function uv(e){let t=fb(e.key);return t===null?null:uS(t)}function dv(e,t,n){let r=uv(e),i=uv(t);if(r===i||r!==null&&i!==null&&r.is(i))return!1;let a=n(r,i);if(r!==null)return $(r)?t.set(r.getKey(),a?r.getChildrenSize():0,`element`):t.set(r.getKey(),a?r.getTextContentSize():0,`text`),!0;let o=cS(i);if(o===null)return!1;let s=o.getParent();if(s===null)return!1;let c=o.getIndexWithinParent();return t.set(s.getKey(),a?c+1:c,`element`),!0}function fv(e){let t=dv(e.anchor,e.focus,(t,n)=>function(e,t,n,r){if(n!==null&&r!==null){let e=cS(n),t=cS(r);if(e!==null&&e.is(t)){for(let t of dS(e).values()){if(t===n.getKey())return!0;if(t===r.getKey())return!1}return!0}return e===null||t===null||e.isBefore(t)}if(n!==null){let e=cS(n),r=fb(t.key);return e===null||r===null||!(!e.is(r)&&!e.isParentOf(r))||e.isBefore(r)}let i=cS(r),a=fb(e.key);return i!==null&&a!==null&&!i.is(a)&&!i.isParentOf(a)&&a.isBefore(i)}(e.anchor,e.focus,t,n));return t&&(e.dirty=!0),t}function pv(e,t,n,r,i,a){if(e===null||n===null||!Zy(i,e,n))return null;let o=cv(e,t,Q(a)?a.anchor:null,i);if(o===null)return null;let s=cv(n,r,Q(a)?a.focus:null,i);if(s===null)return null;let[c,l]=o,[u,d]=s;if(c.type===`element`&&u.type===`element`){let t=Sb(e),r=Sb(n);if(hy(t)&&hy(r))return null}let f=i._slotsUsed&&dv(c,u,()=>(e.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return function(e,t){if(e.type===`text`&&t.type===`text`){let n=e.isBefore(t),r=e.is(t);lv(e,n,r),lv(t,!n,r),r&&t.set(e.key,e.offset,e.type)}}(c,u),[c,u,l||d||f]}function mv(e){return $(e)&&!e.isInline()}function hv(e,t,n,r,i,a){let o=qv(),s=new Y_(H_(e,t,i),H_(n,r,a),0,``);return s.dirty=!0,o._selection=s,s}function gv(){return new Y_(H_(`root`,0,`element`),H_(`root`,0,`element`),0,``)}function _v(){return new q_(new Set)}function vv(e,t,n,r){let i=n._window;if(i===null)return null;let a=r||i.event,o=a?a.type:void 0,s=o===`selectionchange`,c=!hm&&(s||o===`beforeinput`||o===`compositionstart`||o===`compositionend`||o===`click`&&a&&a.detail===3||o===`drop`||o===void 0),l,u,d,f;if(Q(e)&&!c)return e.clone();{if(t===null)return null;let r=_x(t,n._rootElement);if(l=r.anchorNode,u=r.focusNode,d=r.anchorOffset,f=r.focusOffset,(s||o===void 0)&&Q(e)&&!Zy(n,l,u))return e.clone()}let p=pv(l,d,u,f,n,e);if(p===null)return null;let[m,h,g]=p,_=0,v=``;if(Q(e)){let t=e.anchor;if(m.key===t.key)_=e.format,v=e.style;else{let e=m.getNode();Z(e)?(_=e.getFormat(),v=e.getStyle()):$(e)&&(_=e.getTextFormat(),v=e.getTextStyle())}}let y=new Y_(m,h,_,v);return g&&(y.dirty=!0),y}function yv(){return qv()._selection}function bv(){return Yv()._editorState._selection}function xv(e,t,n,r=1){let i=e.anchor,a=e.focus,o=i.getNode(),s=a.getNode();if(!t.is(o)&&!t.is(s))return;let c=t.__key;if(e.isCollapsed()){let t=i.offset;if(n<=t&&r>0||n<t&&r<0){let n=Math.max(0,t+r);i.set(c,n,`element`),a.set(c,n,`element`),Sv(e)}}else{let o=e.isBackward(),s=o?a:i,l=s.getNode(),u=o?i:a,d=u.getNode();if(t.is(l)){let e=s.offset;(n<=e&&r>0||n<e&&r<0)&&s.set(c,Math.max(0,e+r),`element`)}if(t.is(d)){let e=u.offset;(n<=e&&r>0||n<e&&r<0)&&u.set(c,Math.max(0,e+r),`element`)}}Sv(e)}function Sv(e){let t=e.anchor,n=t.offset,r=e.focus,i=r.offset,a=t.getNode(),o=r.getNode();if(e.isCollapsed()){if(!$(a))return;let e=a.getChildrenSize(),i=n>=e,o=i?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(Z(o)){let e=0;i&&(e=o.getTextContentSize()),t.set(o.__key,e,`text`),r.set(o.__key,e,`text`)}return}if($(a)){let e=a.getChildrenSize(),r=n>=e,i=r?a.getChildAtIndex(e-1):a.getChildAtIndex(n);if(Z(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,`text`)}}if($(o)){let e=o.getChildrenSize(),t=i>=e,n=t?o.getChildAtIndex(e-1):o.getChildAtIndex(i);if(Z(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,`text`)}}}function Cv(e,t,n,r,i){let a=null,o=0,s=null;r===null?i!==null&&(a=i.__key,Z(i)?s=`text`:$(i)&&(s=`element`)):(a=r.__key,Z(r)?(o=r.getTextContentSize(),s=`text`):$(r)&&(o=r.getChildrenSize(),s=`element`)),a!==null&&s!==null?e.set(a,o,s):(o=t.getIndexWithinParent(),o===-1&&(o=n.getChildrenSize()),e.set(n.__key,o,`element`))}function wv(e,t,n,r,i){e.type===`text`?e.set(n,e.offset+(t?0:i),`text`):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,`element`)}function Tv(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch{}}function Ev(e,t,n){let r=Ub(e,t.getKey());if($(t)){let i=Px(t,r,e);return[i.element,n+i.getFirstChildOffset()]}return[r,n]}function Dv(e,t,n,r,i,a){let o=a.getRootNode(),s=ib(o)||lx(o)?Sx(o):null;if(i.has(`collaboration`)&&s!==a||s!==null&&Xy(s,s))return;let c=_x(r,a),l;if(!Q(t))return void(e!==null&&Zy(n,c.anchorNode,c.focusNode)&&r.removeAllRanges());let u=t.anchor,d=t.focus,f=u.getNode(),p=d.getNode(),[m,h]=Ev(n,f,u.offset),[g,_]=Ev(n,p,d.offset),v=t.format,y=t.style,b=t.isCollapsed(),x=m,S=g,C=!1;if(u.type===`text`?(x=Z(f)?Ix(f,m,n):null,C=f.getFormat()!==v||f.getStyle()!==y):Q(e)&&e.anchor.type===`text`&&(C=!0),d.type===`text`&&(S=Z(p)?Ix(p,g,n):null),x!==null&&S!==null){if(b&&(e===null||C||Q(e)&&(e.format!==v||e.style!==y))&&function(e,t,n,r,i,a){e._inputState.collapsedSelectionFormat={format:t,key:i,offset:r,style:n,timeStamp:a}}(n,v,y,h,u.key,performance.now()),(r.type!==`Range`||!b)&&c.anchorOffset===h&&c.focusOffset===_&&c.anchorNode===x&&c.focusNode===S){if(s===null||!a.contains(s)){let e=s===null?null:$y(s);e!==null&&e!==n||i.has(`skip-selection-focus`)||a.focus({preventScroll:!0})}if(u.type!==`element`)return}if(Tv(r,x,h,S,_),kp&&t.isCollapsed()&&a!==null&&!i.has(`skip-selection-focus`)){let e=xx(a);if(e===null||!a.contains(e)){let e=Sx(a.ownerDocument),t=e===null?null:$y(e);t!==null&&t!==n||a.focus({preventScroll:!0})}}if(!i.has(`skip-scroll-into-view`)&&t.isCollapsed()&&a!==null&&a===xx(a)){let e=Q(t)&&t.anchor.type===`element`?x.childNodes[h]||null:(l===void 0&&(l=gx(r,a)),l);if(e!==null){let t;if(rb(e)){let n=e.ownerDocument.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();(function(e,t,n){let r=Gb(n),i=Yb(r);if(r===null||i===null)return;let a=n.getBoundingClientRect();if(t.bottom<a.top)return;let{top:o,bottom:s}=t,c=0,l=0,u=n;for(;u!==null;){let t=u===r.body;if(t){let t=i.visualViewport;if(t){let e=t.offsetTop;c=e,l=e+t.height}else c=0,l=Xb(e).innerHeight;let n=i.getComputedStyle(r.documentElement),a=parseFloat(n.scrollPaddingTop),o=parseFloat(n.scrollPaddingBottom);isFinite(a)&&(c+=a),isFinite(o)&&(l-=o)}else{let e=u===n?a:u.getBoundingClientRect();c=e.top,l=e.bottom}let d=0;if(o<c?d=-(c-o):s>l&&(d=s-l),d!==0){if(t)i.scrollBy(0,d);else{let e=u.scrollTop;u.scrollTop+=d;let t=u.scrollTop-e;o-=t,s-=t}}if(t)break;u=Wb(u)}})(n,t,a)}}(function(e){e._inputState.isSelectionChangeFromDOMUpdate=!0})(n)}}function Ov(e,t){for(let n of e.split(/(\r?\n|\t)/))n===`
|
|
16
|
-
`||n===`\r
|
|
17
|
-
`?t.linebreak():n===` `?t.tab():n!==``&&t.text(n)}function kv(e){let t=[];return Ov(e,{linebreak:()=>t.push(Ey()),tab:()=>t.push(z_()),text:e=>t.push(I_(e))}),t}function Av(e){let t=[];for(let n of e)Dy(n)||(!$(n)&&!hy(n)||n.isInline()?t.push(n):$(n)&&t.push(...Av(n.getChildren())));return t}function jv(e){let t=e;e.isCollapsed()||t.removeText();let n=yv();Q(n)&&(t=n),Q(t)||X(161);let r=t.anchor,i=r.getNode(),a=r.offset;for(;!jx(i)&&sS(i)===null;){let e=i;if([i,a]=Mv(i,a),e.is(i))break}return a}function Mv(e,t){let n=e.getParent();if(!n){let e=Ny();return yb().append(e),e.select(),[yb(),0]}if(Z(e)){let r=e.splitText(t);if(r.length===0)return[n,e.getIndexWithinParent()];let i=t===0?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!$(e)||t===0)return[n,e.getIndexWithinParent()];let r=e.getChildAtIndex(t);if(r){let n=new Y_(H_(e.__key,t,`element`),H_(e.__key,t,`element`),0,``),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function Nv(e){return Dy(e)||Zb(e)||Z(e)||e.isParentRequired()}function Pv(e){let t=Ny(),n=null;for(let r=0;r<e.length;r++){let i=e[r];if(Nv(i)){if(n===null){n=i.createParentElementNode(),t.append(n);let a=e[r+1];if(Dy(i)&&(a===void 0||!Nv(a)))continue}n.append(i)}else t.append(i),n=null}return t}function Fv(e,t,n,r,i=`decorators-and-blocks`){if(t===`move`&&r===`character`&&!e.isCollapsed()){let[t,r]=n===e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];return r.set(t.key,t.offset,t.type),!0}let a=iC(e.focus,n?`previous`:`next`),o=r===`lineboundary`,s=t===`move`,c=a,l=i===`decorators-and-blocks`;if(!mC(c)){for(let e of c){l=!1;let{origin:t}=e;if(!hy(t)||t.isIsolated()||(c=e,!o||!t.isInline()))break}if(l)for(let e of YS(a).iterNodeCarets(t===`extend`?`shadowRoot`:`root`)){if(IS(e))e.origin.isInline()||(c=e);else{if($(e.origin))continue;hy(e.origin)&&!e.origin.isInline()&&(c=e)}break}}if(c===a)return!1;if(s&&!o&&hy(c.origin)&&c.origin.isKeyboardSelectable()){let e=_v();return e.add(c.origin.getKey()),bb(e),!0}return c=pC(c),s&&aC(e.anchor,c),aC(e.focus,c),l||!o}var Iv=null,Lv=null,Rv=!1,zv=!1,Bv=!1,Vv=new Set,Hv=0,Uv={characterData:!0,childList:!0,subtree:!0};function Wv(){return Rv||Iv!==null&&Iv._readOnly}function Gv(){Rv&&X(13)}function Kv(){Hv>99&&X(14)}function qv(){return Iv===null&&X(195,Zv()),Iv}function Jv(e){qv()!==null&&Lv===null&&(Lv=e),Lv!==e&&Tp(378)}function Yv(){return Lv===null&&X(337,Zv()),Lv}function Xv(){Yv()._dirtyType=2}function Zv(){let e=0,t=new Set,n=Hy.version;if(typeof window<`u`)for(let r of fx(document)){let i=eb(r);if(Qy(i))e++;else if(i){let e=String(i.constructor.version||`<0.17.1`);e===n&&(e+=` (separately built, likely a bundler configuration issue)`),t.add(e)}}let r=` Detected on the page: ${e} compatible editor(s) with version ${n}`;return t.size&&(r+=` and incompatible editors with versions ${Array.from(t).join(`, `)}`),r}function Qv(){return Lv}function $v(e,t,n){let r=t.__type,i=qy(e,r),a=n.get(r);a===void 0&&(a=Array.from(i.transforms),n.set(r,a));let o=a.length;for(let e=0;e<o&&(a[e](t),t.isAttached());e++);}function ey(e,t){return e!==void 0&&e.__key!==t&&e.isAttached()}function ty(e,t){if(!t)return;let n=e._updateTags,r=t;Array.isArray(t)||(r=[t]);for(let e of r)n.add(e)}function ny(e,t){let n=e.type,r=t.get(n);r===void 0&&X(17,n);let i=r.klass;e.type!==i.getType()&&X(18,i.name);let a=i.importJSON(e),o=e.children;if($(a)&&Array.isArray(o))for(let e=0;e<o.length;e++){let n=ny(o[e],t);a.append(n)}let s=e.$slots;if(s){aS(a)||X(379,i.name);for(let e in s)CS(a,e,ny(s[e],t))}return a}function ry(e,t,n){let r=Iv,i=Rv,a=Lv;Iv=t,Rv=!0,Lv=e;try{return n()}finally{Iv=r,Rv=i,Lv=a}}function iy(e,t){let n=Bv;Bv=!0;try{(function(e,t){let n=e._pendingEditorState,r=e._rootElement,i=e._headless||r===null;if(n===null)return void(!e._updating&&e._deferred.length>0&&sy(e,e._deferred));let a=e._editorState,o=a._selection,s=n._selection,c=e._dirtyType!==0,l=Iv,u=Rv,d=Lv,f=e._updating,p=e._observer,m=null;if(e._pendingEditorState=null,e._editorState=n,!i&&c&&p!==null){Lv=e,Iv=n,Rv=!1,e._updating=!0;try{let t=e._dirtyType,r=e._dirtyElements,i=e._dirtyLeaves;p.disconnect(),m=Lh(a,n,e,t,r,i)}catch(t){if(t instanceof Error&&e._onError(t),zv)throw t;Iy(e,null,r,n),wm(e),e._dirtyType=2,zv=!0,iy(e,a),zv=!1;return}finally{p.observe(r,Uv),e._updating=f,Iv=l,Rv=u,Lv=d}}n._readOnly||=!0;let h=e._dirtyLeaves,g=e._dirtyElements,_=e._normalizedNodes,v=e._updateTags;c&&(e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements=new Map,e._normalizedNodes=new Set),e._updateTags=new Set,function(e,t){let n=e._decorators,r=e._pendingDecorators||n,i=t._nodeMap,a;for(a in r)i.has(a)||(r===n&&(r=_b(e)),delete r[a])}(e,n);let y=i?null:sx(Xb(e));if(e._editable&&y!==null&&(c||s===null||s.dirty||!s.is(o))&&r!==null&&!v.has(`skip-dom-selection`)){Lv=e,Iv=n;try{if(p!==null&&p.disconnect(),c||s===null||s.dirty){let t=e._blockCursorElement;t!==null&&ox(t,e,r),Dv(o,s,e,y,v,r)}(function(e,t,n){let r=e._blockCursorElement;if(Q(n)&&n.isCollapsed()&&n.anchor.type===`element`&&t.contains(xx(t))){let i=n.anchor,a=i.getNode(),o=i.offset,s=!1,c=null;if(o===a.getChildrenSize())ax(a.getChildAtIndex(o-1))&&(s=!0);else{let t=a.getChildAtIndex(o);if(t!==null&&ax(t)){let n=t.getPreviousSibling();(n===null||ax(n))&&(s=!0,c=e.getElementByKey(t.__key))}}if(s){let n=Px(a,e.getElementByKey(a.__key),e).element;r===null&&(e._blockCursorElement=r=function(e){let t=e.theme,n=mx().createElement(`div`);n.contentEditable=`false`,n.setAttribute(`data-lexical-cursor`,`true`);let r=t.blockCursor;return r!==void 0&&(typeof r==`string`&&(r=t.blockCursor=TC(r)),r!==void 0&&n.classList.add(...r)),n}(e._config)),t.style.caretColor=`transparent`,c===null?n.appendChild(r):n.insertBefore(r,c);return}}r!==null&&ox(r,e,t)})(e,r,s)}finally{p!==null&&p.observe(r,Uv),Lv=d,Iv=l}}m!==null&&function(e,t,n,r,i){let a=Array.from(e._listeners.mutation),o=a.length;for(let e=0;e<o;e++){let[o,s]=a[e];for(let e of s){let a=t.get(e);a!==void 0&&o(a,{dirtyLeaves:r,prevEditorState:i,updateTags:n})}}}(e,m,v,h,a),Q(s)||s===null||o!==null&&o.is(s)||e.dispatchCommand(Bh);let b=e._pendingDecorators;b!==null&&(e._decorators=b,e._pendingDecorators=null,ay(`decorator`,e,!0,b)),function(e,t,n){let r=vb(t),i=vb(n);r!==i&&ay(`textcontent`,e,!0,i)}(e,t||a,n),ay(`update`,e,!0,{dirtyElements:g,dirtyLeaves:h,editorState:n,mutatedNodes:m,normalizedNodes:_,prevEditorState:t||a,tags:v}),!f&&sy(e,e._deferred),(function(e){let t=e._updates;if(t.length===0)return void(e._cascadeCount=0);if(function(e){Vv.has(e)||(Vv.add(e),setTimeout(()=>{Vv.delete(e),e._cascadeCount=0},0))}(e),e._cascadeCount++>99)return e._updates=[],e._cascadeCount=0,void e._onWarn(Error(`One or more update listeners are endlessly enqueueing more updates. May have encountered infinite recursion caused by update listeners that trigger additional updates without a stop condition. Editor namespace: ${e._config.namespace}`));let n=t.shift();if(n){let[t,r]=n;ly(e,t,r)}})(e)})(e,t)}finally{Bv=n}}function ay(e,t,n,...r){let i=t._updating;t._updating=n;try{let n=t._listeners[e],i=Array.from(n);for(let[e,t]of i){t&&t();let i=e(...r);n.has(e)?n.set(e,i):i&&i()}}finally{t._updating=i}}function oy(e,t,n,r){let i=wb(e),a;if(!Bv)for(let e=0;e<i.length;e++)i[e]._updating||(i[e]._cascadeCount=0);for(let e=4;e>=0;e--)for(let o=0;o<i.length;o++){let s=i[o];if(o>0&&s._updating){a=s;break}let c=s._commands.get(t);if(c!==void 0){let t=c[e];if(t.size>0){let e=!1;if(uy(s,()=>{for(let i of t)if(i(n,r))return void(e=!0)}),e)return e}}}return a&&a.update(()=>{oy(a,t,n,r)}),!1}function sy(e,t){if(e._deferred=[],t.length!==0){let n=e._updating;e._updating=!0;try{for(let e=0;e<t.length;e++)t[e]()}finally{e._updating=n}}}function cy(e,t){let n=e._updates,r=t||!1;for(;n.length!==0;){let t=n.shift();if(t){let[n,i]=t,a=e._pendingEditorState,o;i!==void 0&&(o=i.onUpdate,i.skipTransforms&&(r=!0),i.discrete&&(a===null&&X(191),a._flushSync=!0),o&&e._deferred.push(o),ty(e,i.tag)),a==null?ly(e,n,i):n()}}return r}function ly(e,t,n){let r=e._updateTags,i,a=!1,o=!1;n!==void 0&&(i=n.onUpdate,ty(e,n.tag),a=n.skipTransforms||!1,o=n.discrete||!1),i&&e._deferred.push(i);let s=e._editorState,c=e._pendingEditorState,l=!1;(c===null||c._readOnly)&&(c=e._pendingEditorState=vy(c||s),l=!0),c._flushSync=o;let u=Iv,d=Rv,f=Lv,p=e._updating;Iv=c,Rv=!1,e._updating=!0,Lv=e;let m=e._headless||e.getRootElement()===null;Wy(null);try{l&&(m?s._selection!==null&&(c._selection=s._selection.clone()):c._selection=function(e,t){let n=e.getEditorState()._selection,r=sx(Xb(e));return Q(n)||n==null?vv(n,r,e,t):n.clone()}(e,n&&n.event||null));let r=e._compositionKey;t(),a=cy(e,a),function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(Q(r)){let e=r.anchor,t=r.focus,i;if(e.type===`text`&&(i=e.getNode(),i.selectionTransform(n,r)),t.type===`text`){let e=t.getNode();i!==e&&e.selectionTransform(n,r)}}}(c,e),e._dirtyType!==0&&(a?function(e,t){let n=t._dirtyLeaves,r=e._nodeMap;for(let e of n){let t=r.get(e);Z(t)&&t.isAttached()&&t.isSimpleText()&&!t.isUnmergeable()&&zm(t)}}(c,e):function(e,t){let n=t._dirtyLeaves,r=t._dirtyElements,i=e._nodeMap,a=db(),o=new Map,s=n,c=s.size,l=r,u=l.size;for(;c>0||u>0;){if(c>0){t._dirtyLeaves=new Set;for(let e of s){let r=i.get(e);Z(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&zm(r),r!==void 0&&ey(r,a)&&$v(t,r,o),n.add(e)}if(s=t._dirtyLeaves,c=s.size,c>0){Hv++;continue}}t._dirtyLeaves=new Set,t._dirtyElements=new Map,l.delete(`root`)&&l.set(`root`,!0);for(let e of l){let n=e[0],s=e[1];if(r.set(n,s),!s)continue;let c=i.get(n);c!==void 0&&ey(c,a)&&$v(t,c,o)}s=t._dirtyLeaves,c=s.size,l=t._dirtyElements,u=l.size,Hv++}t._dirtyLeaves=n,t._dirtyElements=r}(c,e),cy(e),function(e,t,n,r){let i=e._nodeMap,a=t._nodeMap,o=[];for(let[e]of r){let t=a.get(e);t!==void 0&&(t.isAttached()||($(t)&&mm(t,e,i,a,o,r),i.has(e)||r.delete(e),o.push(e)))}for(let e of n){let t=a.get(e);t===void 0||t.isAttached()||(aS(t)&&t.__slots!==null&&mm(t,e,i,a,o,n),i.has(e)||n.delete(e),o.push(e))}for(let e of o)a.delete(e);let s=Yv(),c=s._compositionKey;c===null||a.has(c)||(s._compositionKey=null)}(s,c,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(c._flushSync=!0);let i=c._selection;if(Q(i)){e._slotsUsed&&fv(i);let t=c._nodeMap,n=i.anchor.key,r=i.focus.key;t.get(n)!==void 0&&t.get(r)!==void 0||X(19)}else X_(i)&&i._nodes.size===0&&(c._selection=null)}catch(t){t instanceof Error&&e._onError(t),e._pendingEditorState=s,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),iy(e);return}finally{Iv=u,Rv=d,Lv=f,e._updating=p,Hv=0}e._dirtyType!==0||e._deferred.length>0||function(e,t){let n=t.getEditorState()._selection,r=e._selection;if(r!==null){if(r.dirty||!r.is(n))return!0}else if(n!==null)return!0;return!1}(c,e)?c._flushSync?(c._flushSync=!1,iy(e)):l&&Yy(()=>{iy(e)}):(c._flushSync=!1,l&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function uy(e,t,n){Lv===e&&n===void 0?Wv()?ly(e,t,n):t():ly(e,t,n)}function dy(e){if(ex(e)){let t=null;for(let n of e.getChildren())t=n.isInline()?(t||n.replace(n.createParentElementNode())).append(n):null}}var fy=class extends u_{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for(`ElementNode`),{$transform:dy,extends:u_})}constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style=``,this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=``,this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,this.__slotHost!==null&&this.__parent!==null&&X(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){return Qp[this.getFormat()]||``}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){let e=[],t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0&&fS(this).length===0}isDirty(){let e=Yv()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){let e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){let e=[];for(let t of fS(this)){let n=pS(this,t);$(n)&&e.push(...n.getAllTextNodes())}let t=this.getFirstChild();for(;t!==null;){if(Z(t)&&e.push(t),$(t)){let n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;$(e);){let t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;$(e);){let t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){let t=this.getChildren(),n=t.length;if(e>=n){let e=t[n-1];return $(e)&&e.getLastDescendant()||e||null}let r=t[e];return $(r)&&r.getFirstDescendant()||r||null}getFirstChild(){let e=this.getLatest().__first;return e===null?null:fb(e)}getFirstChildOrThrow(){let e=this.getFirstChild();return e===null&&X(45,this.__key),e}getLastChild(){let e=this.getLatest().__last;return e===null?null:fb(e)}getLastChildOrThrow(){let e=this.getLastChild();return e===null&&X(96,this.__key),e}getChildAtIndex(e){let t=this.getChildrenSize(),n,r;if(e<t/2){for(n=this.getFirstChild(),r=0;n!==null&&r<=e;){if(r===e)return n;n=n.getNextSibling(),r++}return null}for(n=this.getLastChild(),r=t-1;n!==null&&r>=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e=bS(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContent(),$(i)&&r!==n-1&&!i.isInline()&&(e+=qp)}return e}getTextContentSize(){let e=function(e){let t=0;for(let n of fS(e)){let r=pS(e,n);r!==null&&(t+=r.getTextContentSize())}return t}(this),t=this.getChildren(),n=t.length;for(let r=0;r<n;r++){let i=t[r];e+=i.getTextContentSize(),$(i)&&r!==n-1&&!i.isInline()&&(e+=2)}return e}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(e){if(e!==``){let t=Zp[e];return(this.getFormat()&t)!==0}return!1}hasTextFormat(e){let t=Yp[e];return(this.getTextFormat()&t)!==0}getFormatFlags(e,t){return ob(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}select(e,t){Gv();let n=yv(),r=e,i=t,a=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){let e=this.getFirstChild();if(Z(e)||$(e))return e.select(0,0)}else if(!(e!==void 0&&e!==a||t!==void 0&&t!==a)){let e=this.getLastChild();if(Z(e)||$(e))return e.select()}}r===void 0&&(r=a),i===void 0&&(i=a);let o=this.__key;return Q(n)?(n.anchor.set(o,r,`element`),n.focus.set(o,i,`element`),n.dirty=!0,n):hv(o,r,o,i,`element`,`element`)}selectStart(){let e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){let e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){let e=this.getWritable();return this.getChildren().forEach(e=>e.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){let t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==``&&Zp[e]||0,this}setStyle(e){return this.getWritable().__style=e||``,this}setTextFormat(e){let t=this.getWritable();return t.__textFormat=e,t}setTextStyle(e){let t=this.getWritable();return t.__textStyle=e,t}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){c_(this)&&X(324,this.__key,this.__type);let r=this.getChildrenSize(),i=this.getWritable();e+t<=r||X(226,String(e),String(t),String(r));for(let e of n);let a=i.__key,o=[],s=[],c=this.getChildAtIndex(e+t),l=null,u=r-t+n.length;if(e!==0){if(e===r)l=this.getLastChild();else{let t=this.getChildAtIndex(e);t!==null&&(l=t.getPreviousSibling())}}if(t>0){let e=l===null?this.getFirstChild():l.getNextSibling();for(let n=0;n<t;n++){e===null&&X(100);let t=e.getNextSibling(),n=e.__key;cb(e.getWritable()),s.push(n),e=t}}let d=l;for(let e of n){d!==null&&e.is(d)&&(l=d=d.getPreviousSibling());let t=e.getWritable();t.__parent===a&&u--,cb(t);let n=e.__key;if(d===null)i.__first=n,t.__prev=null;else{let e=d.getWritable();e.__next=n,t.__prev=e.__key}e.__key===a&&X(76),t.__parent=a,o.push(n),d=e}if(e+t===r)d!==null&&(d.getWritable().__next=null,i.__last=d.__key);else if(c!==null){let e=c.getWritable();if(d!==null){let t=d.getWritable();e.__prev=d.__key,t.__next=c.__key}else e.__prev=null}if(i.__size=u,s.length){let e=yv();if(Q(e)){let t=new Set(s),n=new Set(o),{anchor:r,focus:i}=e;py(r,t,n)&&Cv(r,r.getNode(),this,l,c),py(i,t,n)&&Cv(i,i.getNode(),this,l,c),u!==0||this.canBeEmpty()||ex(this)||this.remove()}}return i}getDOMSlot(e){return new om(e)}exportDOM(e){let{element:t}=super.exportDOM(e);if(wx(t)){let e=this.getIndent();e>0&&(t.style.paddingInlineStart=40*e+`px`,t.setAttribute(`data-lexical-indent`,String(e)));let n=this.getDirection();n&&(t.dir=n)}return{element:t}}exportJSON(){let e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},t=this.getTextFormat(),n=this.getTextStyle();return t===0&&n===``||ex(this)||this.getChildren().some(Z)||(t!==0&&(e.textFormat=t),n!==``&&(e.textStyle=n)),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||``)}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){let n=Px(this,e,t),r=n.getFirstChild();for(let e=this.getFirstChild();e;e=e.getNextSibling()){let i=t.getElementByKey(e.getKey());i!==null&&(r==null?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}};function $(e){return e instanceof fy}function py(e,t,n){let r=e.getNode();for(;r;){let e=r.__key;if(t.has(e)&&!n.has(e))return!0;r=r.getParent()}return!1}var my=class extends u_{__slotHost;__slots;constructor(e){super(e),this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__slotHost=e.__slotHost,this.__slotHost!==null&&this.__parent!==null&&X(383,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots)}decorate(e,t){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}};function hy(e){return e instanceof my}var gy=class extends fy{__cachedText;$config(){return this.config(`root`,{extends:fy})}constructor(){super(`root`),this.__cachedText=null}getTopLevelElementOrThrow(){X(51)}getTextContent(){let e=this.__cachedText;return e===null||!Wv()&&Yv()._dirtyType!==0?super.getTextContent():e}remove(){X(52)}replace(e){X(53)}insertBefore(e){X(54)}insertAfter(e){X(55)}updateDOM(e,t){return!1}splice(e,t,n){for(let e of n)$(e)||hy(e)||X(282);return super.splice(e,t,n)}static importJSON(e){return yb().updateFromJSON(e)}collapseAtStart(){return!0}};function _y(e){return e instanceof gy}function vy(e){return new Sy(fm(e._nodeMap),null,e._slotsUsed)}function yy(){return new Sy(new Map([[`root`,new gy]]),null,!1)}function by(e){let t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&X(130,n.name),$(e)){let r=t.children;Array.isArray(r)||X(59,n.name);let i=e.getChildren();for(let e=0;e<i.length;e++){let t=by(i[e]);r.push(t)}}let r=fS(e);if(r.length>0){let i={};for(let t of r){let r=pS(e,t);r===null&&X(366,n.name,t),i[t]=by(r)}t.$slots=i}return t}function xy(e){return e instanceof Sy}var Sy=class e{_nodeMap;_selection;_flushSync;_readOnly;_parsed;_slotsUsed;constructor(e,t=null,n=!1){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1,this._parsed=!1,this._slotsUsed=n}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return ry(t&&t.editor||null,this,e)}clone(t){let n=new e(this._nodeMap,t===void 0?this._selection:t,this._slotsUsed);return n._readOnly=!0,n}toJSON(){return ry(null,this,()=>({root:by(yb())}))}},Cy=class extends fy{$config(){return this.config(`artificial`,{extends:fy})}createDOM(e){return mx().createElement(`div`)}},wy=class extends u_{$config(){return this.config(`linebreak`,{importDOM:{br:e=>Oy(e)||ky(e)?null:{conversion:Ty,priority:0}}})}getTextContent(){return`
|
|
18
|
-
`}createDOM(){return mx().createElement(`br`)}updateDOM(){return!1}isInline(){return!0}};function Ty(e){return{node:Ey()}}function Ey(){return nx(new wy)}function Dy(e){return e instanceof wy}function Oy(e){let t=e.parentElement;if(t!==null&&Ax(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&Ay(n)){let n=t.lastChild;if(n===e||n.previousSibling===e&&Ay(n))return!0}}return!1}function ky(e){let t=e.parentElement;if(t!==null&&Ax(t)){let n=t.firstChild;if(n===e||n.nextSibling===e&&Ay(n))return!1;let r=t.lastChild;if(r===e||r.previousSibling===e&&Ay(r))return!0}return!1}function Ay(e){return rb(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||``)}var jy=class extends fy{$config(){return this.config(`paragraph`,{extends:fy,importDOM:{p:()=>({conversion:My,priority:0})}})}createDOM(e){let t=mx().createElement(`p`),n=Lb(e.theme,`paragraph`);return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}exportDOM(e){let{element:t}=super.exportDOM(e);if(wx(t)){this.isEmpty()&&t.append(mx().createElement(`br`));let e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}exportJSON(){let e=super.exportJSON();if(e.textFormat===void 0||e.textStyle===void 0){let t=this.getChildren().find(Z);t?(e.textFormat=t.getFormat(),e.textStyle=t.getStyle()):(e.textFormat=this.getTextFormat(),e.textStyle=this.getTextStyle())}return e}insertNewAfter(e,t){let n=Ny();n.setTextFormat(e.format),n.setTextStyle(e.style);let r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){let e=this.getChildren();if(e.length===0||Z(e[0])&&e[0].getTextContent().trim()===``){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}};function My(e){let t=Ny();if(Wx(t,e),Hx(e,t),t.getFormatType()===``){let n=e.getAttribute(`align`);n&&n&&n in Zp&&t.setFormat(n)}return Ux(t,e),{node:t}}function Ny(){return nx(new jy)}function Py(e){return e instanceof jy}function Fy(e){console.warn(e)}function Iy(e,t,n,r,i){let a=e._keyToDOMMap;a.clear(),e._editorState=yy(),e._pendingEditorState=r,e._compositionKey=null,e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),e._normalizedNodes=new Set,i&&i.preserveUpdateQueue||(e._updateTags=new Set,e._updates=[],e._cascadeCount=0),e._blockCursorElement=null,e._inputState.handledSelectionCommandTimeoutId!==null&&clearTimeout(e._inputState.handledSelectionCommandTimeoutId),e._inputState={collapsedSelectionFormat:{format:0,key:`root`,offset:0,style:``,timeStamp:0},compositionEndData:``,compositionPhase:`idle`,hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null};let o=e._observer;o!==null&&(o.disconnect(),e._observer=null),t!==null&&(t.textContent=``,function(e,t){let n=`__lexicalKey_${t._key}`;delete e[n]}(t,e)),n!==null&&(n.textContent=``,a.set(`root`,n),mb(n,e,`root`))}function Ly(e){let t=new Set,n=new Set;for(let{klass:r,ownNodeConfig:i}of $x(e)){let e=r.transform;if(!n.has(e)){n.add(e);let i=r.transform();i&&t.add(i)}if(i){let e=i.$transform;e&&t.add(e)}}return t}var Ry={$createDOM:(e,t)=>e.createDOM(t._config,t),$decorateDOM:(e,t,n,r)=>{},$exportDOM:(e,t)=>{let n=Jy(t,e.getType());return n&&n.exportDOM!==void 0?n.exportDOM(t,e):e.exportDOM(t)},$extractWithChild:(e,t,n,r,i)=>$(e)&&e.extractWithChild(t,n,r),$getDOMSlot:(e,t,n)=>e.getDOMSlot(t),$getSlotTargetElement:(e,t,n,r)=>null,$shouldExclude:(e,t,n)=>$(e)&&e.excludeFromCopy(`html`),$shouldInclude:(e,t,n)=>!t||e.isSelected(t),$updateDOM:(e,t,n,r)=>e.updateDOM(t,n,r._config)};function zy(e){let t=e||{},n=Qv(),r=t.theme||{},i=e===void 0?n:t.parentEditor||null,a=t.disableEvents||!1,o=yy(),s=t.namespace||(i===null?Tb():i._config.namespace),c=t.editorState,l=[gy,D_,wy,R_,jy,Cy,...t.nodes||[]],{onError:u,onWarn:d,html:f}=t,p=t.editable===void 0||t.editable,m;if(e===void 0&&n!==null)m=n._nodes;else{m=new Map;for(let e=0;e<l.length;e++){let n=l[e],r=null,i=null;if(n&&typeof n==`object`){let e=n;n=e.replace,r=e.with,i=e.withKlass||null}if(typeof n!=`function`||!n.prototype||!(n===u_||n.prototype instanceof u_)){let r=`<unknown>`;try{r=JSON.parse(lm)}catch{}X(365,String(e-l.length+(t.nodes?t.nodes.length:0)),typeof n==`function`?`${n.name}${typeof n.getType==`function`?` (type ${String(n.getType())})`:``}`:String(n),String(r))}Qx(n);let a=n.getType(),o=Ly(n);m.set(a,{exportDOM:f&&f.export?f.export.get(n):void 0,klass:n,replace:r,replaceWithKlass:i,sharedNodeState:Dm(l[e]),transforms:o})}}let h=new Hy(o,i,m,{disableEvents:a,dom:{...Ry,...e&&e.dom},namespace:s,theme:r},u||console.error,d||Fy,function(e,t){let n=new Map,r=new Set,i=e=>{Object.keys(e).forEach(t=>{let r=n.get(t);r===void 0&&(r=[],n.set(t,r)),r.push(e[t])})};return e.forEach(e=>{let t=e.klass.importDOM;if(t==null||r.has(t))return;r.add(t);let n=t.call(e.klass);n!==null&&i(n)}),t&&i(t),n}(m,f?f.import:void 0),p,e);return c!==void 0&&(h._pendingEditorState=c,h._dirtyType=2),function(e){e.registerCommand(Hh,qg,0),e.registerCommand(Uh,Jg,0),e.registerCommand(Wh,Yg,0),e.registerCommand(Gh,Xg,0),e.registerCommand(rg,$g,0)}(h),h}function By(e,t){let n=e.get(t);e.delete(t),n&&n()}function Vy(e,t,n){return e.set(t,n),By.bind(null,e,t)}var Hy=class{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_cascadeCount;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_onWarn;_htmlConversions;_window;_editable;_blockCursorElement;_slotsUsed;_inputState;_createEditorArgs;constructor(e,t,n,r,i,a,o,s,c){this._createEditorArgs=c,this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new pm,this._updates=[],this._updating=!1,this._cascadeCount=0,this._listeners={decorator:new Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Tb(),this._onError=i,this._onWarn=a,this._htmlConversions=o,this._editable=s,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null,this._slotsUsed=!1,this._inputState={collapsedSelectionFormat:{format:0,key:`root`,offset:0,style:``,timeStamp:0},compositionEndData:``,compositionPhase:`idle`,hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null}}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){return Vy(this._listeners.update,e)}registerEditableListener(e){return Vy(this._listeners.editable,e)}registerDecoratorListener(e){return Vy(this._listeners.decorator,e)}registerTextContentListener(e){return Vy(this._listeners.textcontent,e)}registerRootListener(e){let t=this._listeners.root;return DC(Vy(t,e,e(this._rootElement,null)||void 0),()=>function(e,t,n){let r=e.get(t);r&&r(),e.set(t,t(...n)||void 0)}(t,e,[null,this._rootElement]))}registerCommand(e,t,n){n===void 0&&X(35);let r=this._commands;r.has(e)||r.set(e,[new um,new um,new um,new um,new um]);let i=r.get(e);i===void 0&&X(36,String(e));let a=function(e){return 7&e}(n),o=i[a];return a===n?o.addBack(t):o.addFront(t),()=>{o.delete(t),i.every(e=>e.size===0)&&r.delete(e)}}registerMutationListener(e,t,n){let r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation,a=i.get(t);a===void 0&&(a=new Set,i.set(t,a)),a.add(r);let o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,r),()=>{a.delete(r),a.size===0&&i.delete(t)}}getRegisteredNode(e){let t=this._nodes.get(e.getType());return t===void 0&&X(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){let n=this._editorState,r=zx(n).get(t.getType());if(!r)return;let i=new Map;for(let e of r.keys())i.set(e,`created`);i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set([`registerMutationListener`])})}registerNodeTransformToKlass(e,t){let n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){let n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(i!=null){let e=this.registerNodeTransformToKlass(i,t);r.push(e)}return function(e,t){let n=zx(e.getEditorState()),r=[];for(let e of t){let t=n.get(e);t&&r.push(t)}r.length!==0&&e.update(()=>{for(let e of r)for(let t of e.keys()){let e=fb(t);e&&e.markDirty()}},e._pendingEditorState===null?{tag:p_}:void 0)}(this,r.map(e=>e.klass.getType())),()=>{r.forEach(e=>e.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,...t){return Hb(this,e,...t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){let t=this._rootElement;if(e!==t){let n=Lb(this._config.theme,`root`),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Iy(this,t,e,r,{preserveUpdateQueue:!0}),t!==null&&(this._config.disableEvents||a_(t),n!=null&&t.classList.remove(...n)),e!==null){let t=Yb(e),r=e.style;r.userSelect=`text`,r.whiteSpace=`pre-wrap`,r.wordBreak=`break-word`,e.setAttribute(`data-lexical-editor`,`true`),this._window=t,this._dirtyType=2,wm(this),this._updateTags.add(p_),iy(this),this._config.disableEvents||function(e,t){let n=e.ownerDocument;Pg.set(e,n);let r=Fg.get(n);r===void 0&&(r={editors:new Set,hasShadowEditor:void 0},Fg.set(n,r)),r.editors.add(t),r.hasShadowEditor=void 0,e.__lexicalEditor=t;let i=e_(e);i.push(Ig.register(n));for(let n=0;n<Ng.length;n++){let[r,a]=Ng[n],o=typeof a==`function`?e=>{i_(e)||(r_(e),(t.isEditable()||r===`click`)&&a(e,t))}:e=>{if(i_(e))return;r_(e);let n=t.isEditable();switch(r){case`cut`:return n&&Hb(t,xg,e);case`copy`:return Hb(t,bg,e);case`paste`:return n&&Hb(t,Xh,e);case`dragstart`:return n&&Hb(t,_g,e);case`dragover`:return n&&Hb(t,vg,e);case`dragend`:return n&&Hb(t,yg,e);case`focus`:return n&&Hb(t,Dg,e);case`blur`:return n&&Hb(t,Og,e);case`drop`:return n&&Hb(t,gg,e)}};i.push(jg(e,r,o))}}(e,this),n!=null&&e.classList.add(...n)}else this._window=null,this._updateTags.add(p_),iy(this);ay(`root`,this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&X(38);let n=e;n._readOnly&&(n=vy(e),n._selection=e._selection?e._selection.clone():null),Cm(this);let r=this._pendingEditorState,i=t===void 0?null:t.tag;r===null||r.isEmpty()||(i!=null&&this._updateTags.add(i),iy(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set(`root`,!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,uy(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(let[e,t]of n._nodeMap.entries())$(t)?this._dirtyElements.set(e,!0):this._dirtyLeaves.add(e)},{discrete:!this._updating||void 0})}parseEditorState(e,t){return function(e,t,n){let r=yy(),i=Iv,a=Rv,o=Lv,s=t._dirtyElements,c=t._dirtyLeaves,l=t._cloneNotNeeded,u=t._dirtyType;t._dirtyElements=new Map,t._dirtyLeaves=new Set,t._cloneNotNeeded=new Set,t._dirtyType=0,Iv=r,Rv=!1,Lv=t,Wy(null);try{let i=t._nodes;ny(e.root,i),n&&n(),r._readOnly=!0,r._parsed=!0}catch(e){e instanceof Error&&t._onError(e)}finally{t._dirtyElements=s,t._dirtyLeaves=c,t._cloneNotNeeded=l,t._dirtyType=u,Iv=i,Rv=a,Lv=o}return r}(typeof e==`string`?JSON.parse(e):e,this,t)}read(...e){let[t,n]=e.length===1?[`force-commit`,e[0]]:e;return t===`force-commit`&&iy(this),(t===`pending`?this._pendingEditorState||this._editorState:this.getEditorState()).read(n,{editor:this})}update(e,t){(function(e,t,n){e._updating?e._updates.push([t,n]):ly(e,t,n)})(this,e,t)}focus(e,t={}){let n=this._rootElement;n!==null&&(n.setAttribute(`autocapitalize`,`off`),uy(this,()=>{let r=yv(),i=yb();r===null?i.getChildrenSize()!==0&&(t.defaultSelection===`rootStart`?i.selectStart():i.selectEnd()):r.dirty||bb(r.clone()),Kb(`focus`),qb(()=>{n.removeAttribute(`autocapitalize`),e&&e()})}),this._pendingEditorState===null&&n.removeAttribute(`autocapitalize`))}blur(){let e=this._rootElement;e!==null&&e.blur();let t=sx(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,ay(`editable`,this,!0,e),this._slotsUsed&&this.update(()=>Xv()))}toJSON(){return{editorState:this._editorState.toJSON()}}};Hy.version=lm;var Uy=null;function Wy(e){Uy=e}var Gy=Symbol(`INTERNAL_SKIP_AFTER_CLONE_FROM`),Ky=1;function qy(e,t){let n=Jy(e,t);return n===void 0&&X(30,t),n}function Jy(e,t){return e._nodes.get(t)}var Yy=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)};function Xy(e,t){let n=t===void 0?(()=>{let t=e.getRootNode();return ib(t)||lx(t)?Sx(t):null})():t;if(!wx(n)||n.hasAttribute(`data-lexical-slot`))return!1;let r=gb(n),i=n.nodeName;return d_(r)&&(i===`INPUT`||i===`TEXTAREA`||n.contentEditable===`true`&&eb(n)==null)}function Zy(e,t,n){let r=e.getRootElement();if(!r)return!1;try{if(!t||!r.contains(t)||!r.contains(n))return!1}catch{return!1}return $y(t)===e&&e.read(`latest`,()=>!Xy(t))}function Qy(e){return e instanceof Hy}function $y(e){let t=e;for(;t!=null;){let e=eb(t);if(Qy(e))return e;t=Wb(t)}return null}function eb(e){return e?e.__lexicalEditor:null}function tb(e){return B_(e)||e.isToken()}function nb(e){return tb(e)||e.isSegmented()}function rb(e){return Tx(e)&&e.nodeType===3}function ib(e){return Tx(e)&&e.nodeType===9}function ab(e){let t=e;for(;t!=null;){if(rb(t))return t;t=t.firstChild}return null}function ob(e,t,n){let r=Yp[t];if(n!==null&&(e&r)===(n&r))return e;let i=e^r;return t===`subscript`?i&=~Yp.superscript:t===`superscript`?i&=~Yp.subscript:t===`lowercase`?(i&=~Yp.uppercase,i&=~Yp.capitalize):t===`uppercase`?(i&=~Yp.lowercase,i&=~Yp.capitalize):t===`capitalize`&&(i&=~Yp.lowercase,i&=~Yp.uppercase),i}function sb(e,t){let n=function(){let e=Uy;return Uy=null,e}();if((t||=n&&n.__key)!=null)return void(e.__key=t);Gv(),Kv();let r=Yv(),i=qv(),a=``+Ky++;i._nodeMap.set(a,e),$(e)?r._dirtyElements.set(a,!0):r._dirtyLeaves.add(a),r._cloneNotNeeded.add(a),r._dirtyType===0&&(r._dirtyType=1),e.__key=a}function cb(e){sS(e)!==null&&X(380,e.__key,String(sS(e)));let t=e.getParent();if(t!==null){let n=e.getWritable(),r=t.getWritable(),i=e.getPreviousSibling(),a=e.getNextSibling(),o=a===null?null:a.__key,s=i===null?null:i.__key,c=i===null?null:i.getWritable(),l=a===null?null:a.getWritable();i===null&&(r.__first=o),a===null&&(r.__last=s),c!==null&&(c.__next=o),l!==null&&(l.__prev=s),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function lb(e){Kv(),c_(e)&&X(323,e.__key,e.__type);let t=e.getLatest(),n=t.__parent===null?oS(t)?t.__slotHost:null:t.__parent,r=qv(),i=Yv(),a=r._nodeMap,o=i._dirtyElements;n!==null&&function(e,t,n){let r=e;for(;r!==null;){if(n.has(r))return;let e=t.get(r);if(e===void 0)break;n.set(r,!1),r=e.__parent===null?oS(e)?e.__slotHost:null:e.__parent}}(n,a,o);let s=t.__key;i._dirtyType===0&&(i._dirtyType=1),$(e)?o.set(s,!0):i._dirtyLeaves.add(s)}function ub(e){Gv();let t=Yv(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,n!==null){let e=fb(n);e!==null&&e.getWritable()}if(e!==null){let t=fb(e);t!==null&&t.getWritable()}}}function db(){return Wv()?null:Yv()._compositionKey}function fb(e,t){let n=(t||qv())._nodeMap.get(e);return n===void 0?null:n}function pb(e,t){let n=hb(e,Yv());return n===void 0?null:fb(n,t)}function mb(e,t,n){e[`__lexicalKey_${t._key}`]=n}function hb(e,t){return e[`__lexicalKey_${t._key}`]}function gb(e,t){let n=e;for(;n!=null;){let e=pb(n,t);if(e!==null)return e;n=Wb(n)}return null}function _b(e){let t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function vb(e){return e.read(()=>yb().getTextContent())}function yb(){return qv()._nodeMap.get(`root`)}function bb(e){Gv();let t=qv();e!==null&&(e.dirty=!0,e.setCachedNodes(null),Q(e)&&Yv()._slotsUsed&&fv(e)),t._selection=e}function xb(){Gv(),Cm(Yv())}function Sb(e){let t=function(e,t){let n=e;for(;n!=null;){let e=hb(n,t);if(e!==void 0)return e;n=Wb(n)}return null}(e,Yv());return t===null?null:fb(t)}function Cb(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function wb(e){let t=[];for(let n=e;n!==null;n=n._parentEditor)t.push(n);return t}function Tb(){return Math.random().toString(36).replace(/[^a-z]+/g,``).substring(0,5)}function Eb(e){return rb(e)?e.nodeValue:null}function Db(e,t,n){let r=sx(Xb(t));if(r===null)return;let i=_x(r,t._rootElement),a=i.anchorNode,{anchorOffset:o,focusOffset:s}=i;if(a!==null){let t=Eb(a),r=gb(a);if(t!==null&&Z(r)){if((t===Kp||t===Jp)&&n){let e=n.length;t=n,o=e,s=e}t!==null&&Ob(r,t,o,s,e)}}}function Ob(e,t,n,r,i){let a=e;if(a.isAttached()&&(i||!a.isDirty())){let o=a.isComposing();if(a.isToken()&&o)return;let s=t;if((o||i)&&(t.endsWith(Kp)&&(s=t.slice(0,-Kp.length)),i)){let e=Jp,t;for(;(t=s.indexOf(e))!==-1;)s=s.slice(0,t)+s.slice(t+e.length),n!==null&&n>t&&(n=Math.max(t,n-e.length)),r!==null&&r>t&&(r=Math.max(t,r-e.length))}let c=a.getTextContent();if(i||s!==c){let t=yv();if(s===``){if(ub(null),Np||jp||Ip)a.remove();else{let e=Yv();kb(a,``,t),setTimeout(()=>{e.update(()=>{a.isAttached()&&a.getTextContent()===``&&a.remove()})},20)}return}let i=a.getParent(),c=bv(),l=a.getTextContentSize(),u=db(),d=a.getKey();if(a.isToken()&&!o||u!==null&&d===u&&!o||Q(c)&&(i!==null&&!i.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===e.__key&&c.anchor.offset===0&&!a.canInsertTextBefore()&&!o||c.focus.key===e.__key&&c.focus.offset===l&&!a.canInsertTextAfter()&&!o))return void a.markDirty();if(!Q(t)||n===null||r===null)return void kb(a,s,t);if(t.setTextNodeRange(a,n,a,r),a.isSegmented()){let e=I_(a.getTextContent());a.replace(e),a=e}kb(a,s,t)}}}function kb(e,t,n){if(e.setTextContent(t),Q(n)){let t=e.getKey(),r=!1;for(let i of[`anchor`,`focus`]){let a=n[i];a.type===`text`&&a.key===t&&(a.offset=HS(e,a.offset,`clamp`),r=!0)}r&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function Ab(e,t,n){let r=t[n]||!1;return r===`any`||r===e[n]}function jb(e,t){return Ab(e,t,`altKey`)&&Ab(e,t,`ctrlKey`)&&Ab(e,t,`shiftKey`)&&Ab(e,t,`metaKey`)}function Mb(e,t,n){if(!jb(e,n))return!1;if(e.key.toLowerCase()===t.toLowerCase())return!0;if(t.length>1||e.key.length===1&&e.key.charCodeAt(0)<=127)return!1;if(e.code.startsWith(`Digit`)&&/^\d$/.test(t))return e.code===`Digit${t}`;let r=`Key`+t.toUpperCase();return e.code===r}var Nb={ctrlKey:!Op,metaKey:Op},Pb={altKey:Op,ctrlKey:!Op};function Fb(e){return e.key===`Backspace`}function Ib(e){let t=yb();if(Q(e)){let t=e.anchor,n=e.focus,r=t.getNode();if(_y(r))return t.set(r.getKey(),0,`element`),n.set(r.getKey(),r.getChildrenSize(),`element`),Bm(e),e;let i=r.getTopLevelElementOrThrow(),a=i.getParent();if(a===null)return $(i)&&(t.set(i.getKey(),0,`element`),n.set(i.getKey(),i.getChildrenSize(),`element`),Bm(e)),e;let o=a;return t.set(o.getKey(),0,`element`),n.set(o.getKey(),o.getChildrenSize(),`element`),Bm(e),e}{let e=t.select(0,t.getChildrenSize());return bb(Bm(e)),e}}function Lb(e,t){e.__lexicalClassNameCache===void 0&&(e.__lexicalClassNameCache={});let n=e.__lexicalClassNameCache,r=n[t];if(r!==void 0)return r;let i=e[t];if(typeof i==`string`){let e=TC(i);return n[t]=e,e}return i}function Rb(e,t,n,r,i){if(n.size===0)return;let a=r.__type,o=r.__key,s=t.get(a);s===void 0&&X(33,a);let c=s.klass,l=e.get(c);l===void 0&&(l=new Map,e.set(c,l));let u=l.get(o),d=u===`destroyed`&&i===`created`;(u===void 0||d)&&l.set(o,d?`updated`:i)}function zb(e,t,n){let r=e.getParent(),i=n,a=e;return r!==null&&(t&&n===0?(i=a.getIndexWithinParent(),a=r):t||n!==a.getChildrenSize()||(i=a.getIndexWithinParent()+1,a=r)),a.getChildAtIndex(t?i-1:i)}function Bb(e,t){let n=e.offset;if(e.type===`element`)return zb(e.getNode(),t,n);{let r=e.getNode();if(t&&n===0||!t&&n===r.getTextContentSize()){let e=t?r.getPreviousSibling():r.getNextSibling();return e===null?zb(r.getParentOrThrow(),t,r.getIndexWithinParent()+ +!t):e}}return null}function Vb(e){let t=Xb(e).event,n=t&&t.inputType;return n===`insertFromPaste`||n===`insertFromPasteAsQuotation`}function Hb(e,t,...n){return oy(e,t,n[0],e)}function Ub(e,t){let n=e._keyToDOMMap.get(t);return n===void 0&&X(75,t),n}function Wb(e){let t=e.assignedSlot||e.parentElement;if(t!==null)return t;let n=e.parentNode;return lx(n)?n.host:null}function Gb(e){return ib(e)?e:wx(e)?e.ownerDocument:null}function Kb(e){Gv(),Yv()._updateTags.add(e)}function qb(e){Gv(),Yv()._deferred.push(e)}function Jb(e,t){let n=e.getParent();for(;n!==null;){if(n.is(t))return!0;n=n.getParent()}return!1}function Yb(e){let t=Gb(e);return t?t.defaultView:null}function Xb(e){let t=e._window;return t===null&&X(78),t}function Zb(e){return $(e)&&e.isInline()||hy(e)&&e.isInline()}function Qb(e){let t=e.getLatest();for(;t!==null;){if(sS(t)!==null&&$(t))return t;let e=t.getParentOrThrow();if(ex(e))return e;t=e}return t}function $b(e){return $(e)&&e.isShadowRoot()}function ex(e){return _y(e)||$b(e)}function tx(e,t=!1){let n=e.constructor.clone(e,Gy);return sb(n,null),n.afterCloneFrom(e),t||n.resetOnCopyNodeFrom(e),n}function nx(e){let t=Yv(),n=e.getType(),r=Jy(t,n);r===void 0&&X(200,e.constructor.name,n);let{replace:i,replaceWithKlass:a}=r;if(i!==null){let t=i(e),r=t.constructor;return a===null?t instanceof e.constructor&&r!==e.constructor||X(202,r.name,r.getType(),e.constructor.name,n):t instanceof a||X(201,a.name,a.getType(),r.name,r.getType(),e.constructor.name,n),t.__key===e.__key&&X(203,e.constructor.name,n,r.name,r.getType()),t}return e}function rx(e,t){!_y(e.getParent())||$(t)||hy(t)||X(99)}function ix(e){let t=fb(e);return t===null&&X(63,e),t}function ax(e){if(!e||e.isInline())return!1;if(hy(e))return!0;if($(e)){if(e.isShadowRoot()){let t=e.getParent();return!($(t)&&t.isShadowRoot())}return!e.canBeEmpty()}return!1}function ox(e,t,n){n.style.removeProperty(`caret-color`),t._blockCursorElement=null;let r=e.parentElement;r!==null&&r.removeChild(e)}function sx(e){return Ep?(e||window).getSelection():null}function cx(e){let t=Yb(e);return t?t.getSelection():null}function lx(e){return Ex(e)&&`host`in e}var ux=[];function dx(e){let t=e.getRootNode();if(t===e||!lx(t))return ux;let n=[t],r=t.host;for(;;){let e=r.getRootNode();if(e===r||!lx(e))break;n.push(e),r=e.host}return n}function*fx(e){let t=[e],n;for(;n=t.pop();){yield*n.querySelectorAll(`[data-lexical-editor="true"]`);let e=(ib(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r;for(;r=e.nextNode();)r.shadowRoot&&t.push(r.shadowRoot)}}function px(e){return e===null?document:e.ownerDocument}function mx(){let e=Qv();return px(e===null?null:e._rootElement)}function hx(e,t){if(t===null||typeof e.getComposedRanges!=`function`)return null;let n=dx(t);if(n.length===0)return null;let r=e.getComposedRanges;try{let t=r.call(e,{shadowRoots:n})[0];if(t!==void 0)return t}catch{}try{let t=r.apply(e,n)[0];if(t!==void 0)return t}catch{}return null}function gx(e,t){let n=hx(e,t);if(n!==null){let e=vx(n);if(e!==null)return e}return e.rangeCount>0?e.getRangeAt(0):null}function _x(e,t){let n=hx(e,t);return n===null?e:yx(n,bx(e))}function vx(e){let t=e.startContainer.ownerDocument;if(t===null)return null;let n=t.createRange();try{return n.setStart(e.startContainer,e.startOffset),n.setEnd(e.endContainer,e.endOffset),n}catch{return null}}function yx(e,t){let{startContainer:n,startOffset:r,endContainer:i,endOffset:a}=e;return t===`backward`?{anchorNode:i,anchorOffset:a,direction:t,focusNode:n,focusOffset:r}:{anchorNode:n,anchorOffset:r,direction:t,focusNode:i,focusOffset:a}}function bx(e){return e.direction}function xx(e){let t=e.getRootNode();return ib(t)||lx(t)?t.activeElement:null}function Sx(e){let t=e.activeElement;for(;t!==null&&t.shadowRoot!==null;){let e=t.shadowRoot.activeElement;if(e===null)break;t=e}return t}function Cx(e){let t=e.target;if(t!==null&&wx(t)&&t.shadowRoot!==null&&typeof e.composedPath==`function`){let t=e.composedPath();if(t.length>0)return t[0]}return t}function wx(e){return Tx(e)&&e.nodeType===1}function Tx(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function Ex(e){return Tx(e)&&e.nodeType===11}var Dx=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/i;function Ox(e){return!(!wx(e)||!e.style.display.startsWith(`inline`))||Dx.test(e.nodeName)}var kx=/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/i;function Ax(e){return(!wx(e)||!e.style.display.startsWith(`inline`))&&kx.test(e.nodeName)}function jx(e){if(hy(e)&&!e.isInline())return!0;if(!$(e)||ex(e))return!1;let t=e.getFirstChild(),n=t===null||Dy(t)||Z(t)||t.isInline();return!e.isInline()&&!1!==e.canBeEmpty()&&n}function Mx(){return Yv()}function Nx(e=Mx()){return e._config.dom||Ry}function Px(e,t,n=Mx()){let r=Nx(n).$getDOMSlot(e,t,n);return $(e)&&(Fx(r)||X(344,e.getKey(),e.getType())),r}function Fx(e){return e instanceof om}function Ix(e,t,n=Mx()){return ab(Px(e,t,n).element)}var Lx=new WeakMap,Rx=new Map;function zx(e){if(!e._readOnly&&e.isEmpty())return Rx;e._readOnly||X(192);let t=Lx.get(e);return t||(t=function(e){let t=new Map;for(let[n,r]of e._nodeMap){let e=r.__type,i=t.get(e);i||(i=new Map,t.set(e,i)),i.set(n,r)}return t}(e),Lx.set(e,t)),t}function Bx(e){let t=e.constructor.clone(e,Gy);return t.afterCloneFrom(e),t}function Vx(e){return(t=Bx(e))[s_]=!0,t;var t}function Hx(e,t){let n=e.getAttribute(`data-lexical-indent`);if(n!==null){let e=parseInt(n,10);if(Number.isFinite(e)&&e>=0)return void t.setIndent(e)}let r=parseInt(e.style.paddingInlineStart,10)||0,i=Math.round(r/40);t.setIndent(i)}function Ux(e,t){let n=t.getAttribute(`dir`);return n===`ltr`||n===`rtl`?e.setDirection(n):e}function Wx(e,t){let n=t.style.textAlign;return n&&n in Zp?e.setFormat(n):e}function Gx(e,t){e.__lexicalUnmanaged=!0,t&&t.captureSelection!==void 0&&(e.__lexicalCapturedSelection=t.captureSelection)}function Kx(e){return!0===e.__lexicalUnmanaged}function qx(e,t=Mx()){let n=t.isEditable();e.contentEditable=n?`true`:`false`,n?e.__lexicalEditor=t:delete e.__lexicalEditor}function Jx(e,t){let n=e;for(;n!=null;){if(!0===n.__lexicalCapturedSelection)return!0;if(wx(n)&&n.hasAttribute(`data-lexical-slot`)||hb(n,t)!==void 0)return!1;n=Wb(n)}return!1}function Yx(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)&&e[t]!==u_[t]}var Xx=new WeakMap,Zx=Symbol(`lexical.synthesizedGetType`);function Qx(e){let t=Xx.get(e);if(t)return t;let n=e.prototype!=null&&tm in e.prototype?e.prototype[tm]():void 0,r=function(e){if(!(e===u_||e.prototype instanceof u_)){let t=`<unknown>`,n=`<unknown>`;try{t=e.getType()}catch{}try{Hy.version&&(n=JSON.parse(Hy.version))}catch{}X(290,e.name,t,n)}return e===my||e===fy||e===u_}(e),i=!r&&Yx(e,`getType`)?e.getType:void 0,a=i&&!(Zx in i)?i.call(e):void 0,o,s=a;if(n){if(a)o=n[a];else{for(let[e,t]of Object.entries(n))s=e,o=t;if(!o)for(let e of Object.getOwnPropertySymbols(n)){let t=n[e];if(t){o=t;break}}}}if(!r&&s){if(!Yx(e,`getType`)){let t=e,n=function(){return this===t?s:u_.getType.call(this)};n[Zx]=!0,e.getType=n}if(Yx(e,`clone`)||(e.clone=(t,n)=>{Wy(t);let r=new e;return n!==Gy&&r.afterCloneFrom(t),r}),Yx(e,`importJSON`)||(e.importJSON=o&&o.$importJSON||(t=>new e().updateFromJSON(t))),!Yx(e,`importDOM`)&&o){let{importDOM:t}=o;t&&(e.importDOM=()=>t)}}let c={klass:e,ownNodeConfig:o,ownNodeType:s};return Xx.set(e,c),c}function*$x(e){for(let t=e;t&&(t===u_||d_(t.prototype));){let e=Qx(t);yield e,t=e.ownNodeConfig&&e.ownNodeConfig.extends||rS(t)}}function eS(e){let t=Mx();return Gv(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e))).klass}var tS=(e,t)=>{let n=e;for(;n!=null&&!_y(n);){if(t(n))return n;n=n.getParent()}return null};function nS(e,t){let n=[],r=e.__first;for(;r!==null;){let e=t===null?fb(r):t.get(r);e??X(174),n.push(r),r=e.__next}return n}function rS(e){let t=Object.getPrototypeOf(e);if(typeof t==`function`&&t!==Function.prototype)return t;let n=e.prototype&&Object.getPrototypeOf(e.prototype);return n?n.constructor:null}var iS=new Map;function aS(e){return $(e)||hy(e)}function oS(e){return $(e)||hy(e)}function sS(e){let t=e.getLatest();return oS(t)?t.__slotHost:null}function cS(e){let t=sS(e);if(t===null)return null;let n=fb(t);return $(n)||hy(n)||X(370),n}function lS(e){let t=cS(e);if(t===null)return null;let n=e.getLatest().__key;for(let[e,r]of dS(t))if(r===n)return e;return null}function uS(e){let t=e.getLatest();for(;t!==null;){if(sS(t)!==null)return t;t=t.getParent()}return null}function dS(e){let t=e.getLatest();return aS(t)&&t.__slots!==null?t.__slots:iS}function fS(e){return Array.from(dS(e).keys())}function pS(e,t){let n=dS(e).get(t);return n===void 0?null:fb(n)}var mS=[`__proto__`,`constructor`,`prototype`],hS=Symbol(`slotMapOwner`);function gS(e){let t=e.__slots;return t!==null&&t[hS]===e||(t=new Map(t),t[hS]=e,e.__slots=t),t}var _S=new WeakMap,vS=[];function yS(e){for(let{ownNodeConfig:t}of $x(e)){let e=t&&t.slots;if(e)return e}return vS}function bS(e){let t=``;for(let n of fS(e)){let r=pS(e,n);r!==null&&(t+=r.getTextContent())}return t}function xS(e,t,n){let r=n.get(e),i=n.get(t);return r===void 0?i===void 0?e<t?-1:+(e>t):1:i===void 0?-1:r-i}function SS(e){let t=e.__slots;if(t===null||t.size<2)return;let n=function(e){let t=_S.get(e);if(t===void 0){let n=yS(e),r=new Map;for(let t of n)mS.includes(t)&&X(371,e.name,t),r.has(t)&&X(372,e.name,t),r.set(t,r.size);t=r,_S.set(e,t)}return t}(e.constructor),r=null,i=!0;for(let e of t.keys()){if(r!==null&&xS(r,e,n)>0){i=!1;break}r=e}if(i)return;let a=Array.from(t).sort(([e],[t])=>xS(e,t,n));t.clear();for(let[e,n]of a)t.set(e,n)}function CS(e,t,n){t!==`__proto__`&&t!==`constructor`&&t!==`prototype`||X(373,t);let r=e.getLatest();if(r.__slots!==null&&r.__slots.get(t)===n.getLatest().__key)return r;(!$(n)&&!hy(n)||n.isInline())&&X(374,n.__key);let i=e.getWritable(),a=gS(i),o=a.get(t);o!==void 0&&TS(o);let s=n.getWritable(),c=cS(s);if(c!==null){let e=lS(s);e!==null&&gS(c.getWritable()).delete(e),s.__slotHost=null}return cb(s),s.__slotHost=i.__key,a.set(t,s.__key),SS(i),function(){let e=Mx();e._slotsUsed=!0,e._pendingEditorState&&(e._pendingEditorState._slotsUsed=!0)}(),i}function wS(e,t){let n=e.getWritable();if(n.__slots===null)return n;let r=n.__slots.get(t);return r!==void 0&&(TS(r),gS(n).delete(t)),n}function TS(e){let t=fb(e);if(t===null)return;let n=t.getWritable();oS(n)||X(377,e),n.__slotHost=null,n.remove()}var ES={next:`previous`,previous:`next`},DS=class{origin;constructor(e){this.origin=e}[Symbol.iterator](){return QS({hasNext:FS,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return BS(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return BS(this.origin,this.direction)}remove(){let e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){let n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(n===null?this.insert(e):n.replace(e,t)),this}splice(e,t,n=`next`){let r=n===this.direction?t:Array.from(t).reverse(),i=this,a=this.getParentAtCaret(),o=new Map;for(let t=i.getAdjacentCaret();t!==null&&o.size<e;t=t.getAdjacentCaret()){let e=t.origin.getWritable();o.set(e.getKey(),e)}for(let e of r){if(o.size>0){let t=i.getNodeAtCaret();if(t){if(o.delete(t.getKey()),o.delete(e.getKey()),!(t.is(e)||i.origin.is(e))){let n=e.getParent();n&&n.is(a)&&e.remove(),t.replace(e)}}else t===null&&X(263,Array.from(o).join(` `))}else i.insert(e);i=BS(e,this.direction)}for(let e of o.values())e.remove();return this}},OS=class e extends DS{type=`child`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:WS(e,this.direction)}getParentCaret(e=`root`){return BS(jS(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=AS(this.direction);return BS(this.getNodeAtCaret(),e)||WS(this.origin,e)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(e){return this.isSameNodeCaret(e)}},kS={root:_y,shadowRoot:ex};function AS(e){return ES[e]}function jS(e,t=`root`){return e===null||kS[t](e)?null:sS(e)===null?e:null}var MS=class e extends DS{type=`sibling`;getLatest(){let e=this.origin.getLatest();return e===this.origin?this:BS(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return $(this.origin)?WS(this.origin,this.direction):null}getParentCaret(e=`root`){return BS(jS(this.getParentAtCaret(),e),this.direction)}getFlipped(){let e=AS(this.direction);return BS(this.getNodeAtCaret(),e)||WS(this.origin.getParentOrThrow(),e)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof e||t instanceof NS)&&this.direction===t.direction&&this.origin.is(t.origin)}},NS=class e extends DS{type=`text`;offset;constructor(e,t){super(e),this.offset=t}getLatest(){let e=this.origin.getLatest();return e===this.origin?this:VS(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e=`root`){return BS(jS(this.getParentAtCaret(),e),this.direction)}getFlipped(){return VS(this.origin,AS(this.direction),this.offset)}isSamePointCaret(t){return t instanceof e&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof MS||t instanceof e)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return BS(this.origin,this.direction)}};function PS(e){return e instanceof NS}function FS(e){return e instanceof MS}function IS(e){return e instanceof OS}var LS={next:class extends NS{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends NS{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},RS={next:class extends MS{direction=`next`;getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends MS{direction=`previous`;getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},zS={next:class extends OS{direction=`next`;getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends OS{direction=`previous`;getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function BS(e,t){return e?new RS[t](e):null}function VS(e,t,n){return e?new LS[t](e,HS(e,n)):null}function HS(e,t,n=`error`){let r=e.getTextContentSize(),i=t===`next`?r:t===`previous`?0:t;return(i<0||i>r)&&(n!==`clamp`&&Tp(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function US(e,t){return new JS(e,t)}function WS(e,t){return $(e)?new zS[t](e):null}function GS(e){return e&&e.getChildCaret()||e}function KS(e){return e&&GS(e.getAdjacentCaret())}var qS=class e{type=`node-caret-range`;direction;anchor;focus;constructor(e,t,n){this.anchor=e,this.focus=t,this.direction=n}getLatest(){let t=this.anchor.getLatest(),n=this.focus.getLatest();return t===this.anchor&&n===this.focus?this:new e(t,n,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){let e=e=>{let t=this[e].getLatest();return PS(t)?function(e,t){let{direction:n,origin:r}=e;return US(e,HS(r,t===`focus`?AS(n):n)-e.offset)}(t,e):null},t=e(`anchor`),n=e(`focus`);if(t&&n){let{caret:e}=t,{caret:r}=n;if(e.isSameNodeCaret(r))return[US(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e=`root`){let t=PS(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=PS(n),i=t=>t.isSameNodeCaret(n)?null:KS(t)||t.getParentCaret(e);return QS({hasNext:e=>e!==null&&!(r&&n.isSameNodeCaret(e)),initial:t.isSameNodeCaret(n)?null:i(t),map:e=>e,step:i})}[Symbol.iterator](){return this.iterNodeCarets(`root`)}},JS=class{type=`slice`;caret;distance;constructor(e,t){this.caret=e,this.distance=t}getSliceIndices(){let{distance:e,caret:{offset:t}}=this,n=t+e;return n<t?[n,t]:[t,n]}getTextContent(){let[e,t]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(e,t)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){let{caret:{origin:e,direction:t}}=this,[n,r]=this.getSliceIndices(),i=e.getTextContent();return VS(e.setTextContent(i.slice(0,n)+i.slice(r)),t,n)}};function YS(e){return ZS(e,BS(yb(),e.direction))}function XS(e){return ZS(e,e)}function ZS(e,t){return e.direction!==t.direction&&X(265),new qS(e,t,e.direction)}function QS(e){let{initial:t,hasNext:n,step:r,map:i}=e,a=t;return{[Symbol.iterator](){return this},next(){if(!n(a))return{done:!0,value:void 0};let e={done:!1,value:i(a)};return a=r(a),e}}}function $S(e,t){let n=rC(e.origin,t.origin);switch(n===null&&X(275,e.origin.getKey(),t.origin.getKey()),n.type){case`same`:{let n=e.type===`text`,r=t.type===`text`;return n&&r?function(e,t){return Math.sign(e-t)}(e.offset,t.offset):e.type===t.type?0:n?-1:r?1:e.type===`child`?-1:1}case`ancestor`:return e.type===`child`?-1:1;case`descendant`:return t.type===`child`?1:-1;case`branch`:return eC(n)}}function eC(e){let{a:t,b:n}=e,r=t.__key,i=n.__key,a=t,o=n;for(;a&&o;a=a.getNextSibling(),o=o.getNextSibling()){if(a.__key===i)return-1;if(o.__key===r)return 1}return a===null?1:-1}function tC(e,t){return t.is(e)}function nC(e){return $(e)?[e.getLatest(),null]:[e.getParent(),e.getLatest()]}function rC(e,t){if(e.is(t))return{commonAncestor:e,type:`same`};let n=new Map;for(let[t,r]=nC(e);t;r=t,t=t.getParent())n.set(t,r);for(let[r,i]=nC(t);r;i=r,r=r.getParent()){let a=n.get(r);if(a!==void 0)return a===null?(tC(e,r)||X(276),{commonAncestor:r,type:`ancestor`}):i===null?(tC(t,r)||X(277),{commonAncestor:r,type:`descendant`}):(($(a)||tC(e,a))&&($(i)||tC(t,i))&&r.is(a.getParent())&&r.is(i.getParent())||X(278),{a,b:i,commonAncestor:r,type:`branch`})}return null}function iC(e,t){let{type:n,key:r,offset:i}=e,a=ix(e.key);return n===`text`?(Z(a)||X(266,a.getType(),r),VS(a,t,i)):($(a)||X(267,a.getType(),r),_C(a,e.offset,t))}function aC(e,t){let{origin:n,direction:r}=t,i=r===`next`;PS(t)?e.set(n.getKey(),t.offset,`text`):FS(t)?Z(n)?e.set(n.getKey(),HS(n,r),`text`):e.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent()+ +!!i,`element`):(IS(t)&&$(n)||X(268),e.set(n.getKey(),i?0:n.getChildrenSize(),`element`))}function oC(e){let t=yv(),n=Q(t)?t:gv();return sC(n,e),bb(n),n}function sC(e,t){aC(e.anchor,t.anchor),aC(e.focus,t.focus)}function cC(e){let{anchor:t,focus:n}=e,r=iC(t,`next`),i=iC(n,`next`),a=$S(r,i)<=0?`next`:`previous`;return ZS(hC(r,a),hC(i,a))}function lC(e){let{direction:t,origin:n}=e,r=BS(n,AS(t)).getNodeAtCaret();return r?BS(r,t):WS(n.getParentOrThrow(),t)}function uC(e,t=`root`){let n=[e];for(let r=IS(e)?e.getParentCaret(t):e.getSiblingCaret();r!==null;r=r.getParentCaret(t))n.push(lC(r));return n}function dC(e){return!!e&&e.origin.isAttached()}function fC(e,t=`removeEmptySlices`){if(e.isCollapsed())return e;let n=`root`,r=`next`,i=t,a=gC(e,r),o=uC(a.anchor,n),s=uC(a.focus.getFlipped(),n),c=new Set,l=[];for(let e of a.iterNodeCarets(n))if(IS(e))c.add(e.origin.getKey());else if(FS(e)){let{origin:t}=e;$(t)&&!c.has(t.getKey())||l.push(t)}let u=new Set;for(let e of l){let t=e.getParent();t===null||c.has(t.getKey())||u.add(t),cb(e)}for(let e of u)!e.canBeEmpty()&&!ex(e)&&e.isEmpty()&&e.isAttached()&&e.remove();for(let e of a.getTextSlices()){if(!e)continue;let{origin:t}=e.caret,n=t.getTextContentSize(),a=lC(BS(t,r)),c=t.getMode();if(Math.abs(e.distance)===n&&i===`removeEmptySlices`||c===`token`&&e.distance!==0)a.remove();else if(e.distance!==0){i=`removeEmptySlices`;let t=e.removeTextSlice(),n=e.caret.origin;if(c===`segmented`){let e=t.origin,n=I_(e.getTextContent()).setStyle(e.getStyle()).setFormat(e.getFormat());a.replaceOrInsert(n),t=VS(n,r,t.offset)}n.is(o[0].origin)&&(o[0]=t),n.is(s[0].origin)&&(s[0]=t.getFlipped())}}let d,f;for(let e of o)if(dC(e)){d=pC(e);break}for(let e of s)if(dC(e)){f=pC(e);break}let p=function(e,t,n){if(!e||!t)return null;let r=e.getParentAtCaret(),i=t.getParentAtCaret();if(!r||!i)return null;let a=r.getParents().reverse();a.push(r);let o=i.getParents().reverse();o.push(i);let s=Math.min(a.length,o.length),c;for(c=0;c<s&&a[c]===o[c];c++);let l=(e,t)=>{let n;for(let r=c;r<e.length;r++){let i=e[r];if(ex(i))return;!n&&t(i)&&(n=i)}return n},u=l(a,jx),d=u&&l(o,e=>n.has(e.getKey())&&jx(e));return d&&fS(d).length>0?null:u&&d?[u,d]:null}(d,f,c);if(p){let[e,t]=p;WS(e,`previous`).splice(0,t.getChildren());let n=t.getParent();for(t.remove(!0);n&&n.isEmpty();){let e=n;n=n.getParent(),e.remove(!0)}}else if(f){let e=function(e){if(IS(e)){let t=e.origin;if(jx(t))return t}else{let t=e.getParentAtCaret();if(t&&jx(t))return t}return null}(f),t=e&&e.getParent(),n=e&&e.getParents().findLast($b);if(e&&t&&!_y(t)&&e.isEmpty()&&c.has(e.getKey())&&fS(e).length===0&&(!n||c.has(n.getKey()))){e.remove(!0);let n=t;for(;n&&!_y(n)&&n.isEmpty();){let e=n.getParent();if(e&&_y(e)&&e.getChildrenSize()<=1)break;let t=n;n=e,t.remove(!0)}}}let m=[d,f,...o,...s].find(dC);if(m)return XS(hC(pC(m),e.direction));X(269,JSON.stringify(o.map(e=>e.origin.__key)))}function pC(e){let t=function(e){let t=e;for(;IS(t);){let e=KS(t);if(!IS(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(Z(t.origin))return PS(t)?t:VS(t.origin,n,n);let r=t.getAdjacentCaret();return FS(r)&&Z(r.origin)?VS(r.origin,n,AS(n)):t}function mC(e){return PS(e)&&e.offset!==HS(e.origin,e.direction)}function hC(e,t){return e.direction===t?e:e.getFlipped()}function gC(e,t){return e.direction===t?e:ZS(hC(e.focus,t),hC(e.anchor,t))}function _C(e,t,n){let r=WS(e,`next`);for(let e=0;e<t;e++){let e=r.getAdjacentCaret();if(e===null)break;r=e}return hC(r,n)}function vC(e){let{origin:t,offset:n,direction:r}=e;if(n===HS(t,r))return e.getSiblingCaret();if(n===HS(t,AS(r)))return lC(e.getSiblingCaret());let[i]=t.splitText(n);return Z(i)||X(281),hC(BS(i,`next`),r)}function yC(e,t){return!0}function bC(e,{$copyElementNode:t=tx,$splitTextPointCaretNext:n=vC,rootMode:r=`shadowRoot`,$shouldSplit:i=yC,removeEmptyDestination:a=!1}={}){if(PS(e))return n(e);let o=e.getParentCaret(r);if(o){let{origin:n}=o;if(IS(e)){let e=lC(o);if(a&&n.isEmpty())return n.remove(),e;if(!n.canBeEmpty()||!i(n,`first`))return e}let r=function(e){let t=[];for(let n=e.getAdjacentCaret();n;n=n.getAdjacentCaret())t.push(n.origin);return t}(e);(r.length>0||!a&&n.canBeEmpty()&&i(n,`last`))&&o.insert(t(n).splice(0,0,r))}return o}function xC(e,t,n){let r=hC(t,`next`);PS(r)&&(r.offset===0?r=BS(r.origin,`previous`).getFlipped():r.offset===r.origin.getTextContentSize()&&(r=BS(r.origin,`next`))),r.origin.is(e)&&(FS(r)||X(342,e.getKey(),e.getType()),r=lC(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let e=r;e;e=bC(e,n))r=e;return PS(r)&&X(283),r.insert(e.isInline()?Ny().append(e):e),hC(BS(e.getLatest(),`next`),t.direction)}function SC(e){return e}function CC(e){return e}function wC(e,t){if(!t||e===t)return e;for(let n in t)if(e[n]!==t[n])return{...e,...t};return e}function TC(...e){let t=[];for(let n of e)if(n&&typeof n==`string`)for(let[e]of n.matchAll(/\S+/g))t.push(e);return t}function EC(e,...t){let n=TC(...t);n.length>0&&e.classList.add(...n)}function DC(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}var OC=Ep?q.useLayoutEffect:q.useEffect,kC={tag:p_};function AC({initialConfig:e,children:t}){let n=(0,q.useMemo)(()=>{let{theme:t,namespace:n,nodes:r,onError:i,onWarn:a,editorState:o,html:s}=e,c=Cp(null,t),l=zy({editable:e.editable,html:s,namespace:n,nodes:r,onError:e=>i(e,l),...a?{onWarn:e=>a(e,l)}:{},theme:t});return function(e,t){if(t!==null){if(t===void 0)e.update(()=>{let t=yb();if(t.isEmpty()){let n=Ny();t.append(n);let r=e.getRootElement(),i=Ep&&r!==null?xx(r):null;(yv()!==null||i!==null&&i===r)&&n.select()}},kC);else if(t!==null)switch(typeof t){case`string`:{let n=e.parseEditorState(t);e.setEditorState(n,kC);break}case`object`:e.setEditorState(t,kC);break;case`function`:e.update(()=>{yb().isEmpty()&&t(e)},kC)}}}(l,o),[l,c]},[]);return OC(()=>{let t=e.editable,[r]=n;r.setEditable(t===void 0||t)},[]),(0,Y.jsx)(Sp.Provider,{value:n,children:t})}function jC(){return yb().getTextContent()}function MC(e,t=!0){if(e)return!1;let n=jC();return t&&(n=n.trim()),n===``}function NC(e){if(!MC(e,!1))return!1;let t=yb().getChildren(),n=t.length;if(n>1)return!1;for(let e=0;e<n;e++){let n=t[e];if(hy(n))return!1;if($(n)){if(!Py(n)||n.__indent!==0)return!1;let t=n.getChildren(),r=t.length;for(let n=0;n<r;n++){let n=t[e];if(!Z(n))return!1}}}return!0}function PC(e){return()=>NC(e)}var FC=Ep?q.useLayoutEffect:q.useEffect;function IC({editor:e,ariaActiveDescendant:t,ariaAutoComplete:n,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:a,ariaExpanded:o,ariaInvalid:s,ariaLabel:c,ariaLabelledBy:l,ariaMultiline:u,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:m,id:h,role:g=`textbox`,spellCheck:_=!0,style:v,tabIndex:y,"data-testid":b,...x},S){let[C,w]=(0,q.useState)(e.isEditable()),T=(0,q.useCallback)(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null)},[e]),E=(0,q.useMemo)(()=>function(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}(S,T),[T,S]);return FC(()=>(w(e.isEditable()),e.registerEditableListener(e=>{w(e)})),[e]),(0,Y.jsx)(`div`,{"aria-activedescendant":C?t:void 0,"aria-autocomplete":C?n:`none`,"aria-controls":C?r:void 0,"aria-describedby":i,...a==null?{}:{"aria-errormessage":a},"aria-expanded":C&&g===`combobox`?!!o:void 0,...s==null?{}:{"aria-invalid":s},"aria-label":c,"aria-labelledby":l,"aria-multiline":u,"aria-owns":C?d:void 0,"aria-readonly":!C||void 0,"aria-required":f,autoCapitalize:p,className:m,contentEditable:C,"data-testid":b,id:h,ref:E,role:g,spellCheck:_,style:v,tabIndex:y??(C?void 0:-1),...x})}var LC=(0,q.forwardRef)(IC);function RC(e){return e.read(`latest`,PC(e.isComposing()))}var zC=(0,q.forwardRef)(BC);function BC(e,t){let{placeholder:n,...r}=e,[i]=wp();return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(LC,{editor:i,...r,ref:t}),n!=null&&(0,Y.jsx)(VC,{editor:i,content:n})]})}function VC({content:e,editor:t}){let n=function(e){let[t,n]=(0,q.useState)(()=>RC(e));return FC(()=>{function t(){let t=RC(e);n(t)}return t(),DC(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),[r,i]=(0,q.useState)(t.isEditable());if((0,q.useLayoutEffect)(()=>(i(t.isEditable()),t.registerEditableListener(e=>{i(e)})),[t]),!n)return null;let a=null;return typeof e==`function`?a=e(r):e!==null&&(a=e),a===null?null:(0,Y.jsx)(`div`,{"aria-hidden":!0,children:a})}var HC=class extends q.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){this.props.onError(e instanceof Error?e:Error(String(e),{cause:e}),t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function UC({children:e,fallback:t,onError:n}){return(0,Y.jsx)(HC,{fallback:t===void 0?(0,Y.jsx)(`div`,{style:{border:`1px solid #f00`,color:`#f00`,padding:`8px`},children:`An error was thrown.`}):t,onError:n,children:e})}function WC(e){let t=Mx().getElementByKey(e.getKey());if(t===null)return null;let n=t.ownerDocument.defaultView;return n===null?null:n.getComputedStyle(t)}function GC(e){return WC(_y(e)?e:e.getParentOrThrow())}function KC(e,t,n=`self`){let r=e.getStartEndPoints();if(t.isSelected(e)&&!nb(t)&&r!==null){let[i,a]=r,o=e.isBackward(),s=i.getNode(),c=a.getNode(),l=t.is(s),u=t.is(c);if(l||u){let[r,i]=ev(e),a=s.is(c),l=t.is(o?c:s),u=t.is(o?s:c),d,f=0;a?(f=r>i?i:r,d=r>i?r:i):l?(f=o?i:r,d=void 0):u&&(f=0,d=o?r:i);let p=t.__text.slice(f,d);p!==t.__text&&(n===`clone`&&(t=Vx(t)),t.__text=p)}}return t}function qC(e){let t=JC(e);return t!==null&&t.writingMode===`vertical-rl`}function JC(e){let t=e.anchor.getNode();return $(t)?WC(t):GC(t)}function YC(e,t){let n=qC(e)?!t:t;ZC(e)&&(n=!n);let r=iC(e.focus,n?`previous`:`next`);if(mC(r))return!1;if(PS(r)&&!B_(r.origin)&&r.origin.isUnmergeable()){let e=r.getNodeAtCaret();if(Z(e)&&!B_(e))return!0}for(let e of YS(r)){if(IS(e))return!e.origin.isInline();if(!$(e.origin)){if(hy(e.origin))return!0;break}}return!1}function XC(e,t,n,r){e.modify(t?`extend`:`move`,n,r)}function ZC(e){let t=JC(e);return t!==null&&t.direction===`rtl`}function QC(e,t,n){let r=ZC(e),i;i=qC(e)||r?!n:n,XC(e,t,i,`character`)}function $C(e,t){return e!==null&&Object.getPrototypeOf(e).constructor.name===t.name}var ew=Symbol.for(`preact-signals`);function tw(){if(ow>1)return void ow--;let e,t=!1;for(function(){let e=aw;for(aw=void 0;e!==void 0;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();rw!==void 0;){let n=rw;for(rw=void 0,sw++;n!==void 0;){let r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&pw(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(sw=0,ow--,t)throw e}var nw,rw;function iw(e){let t=nw;nw=void 0;try{return e()}finally{nw=t}}var aw,ow=0,sw=0,cw=0,lw=0;function uw(e){if(nw===void 0)return;let t=e.n;return t===void 0||t.t!==nw?(t={i:0,S:e,p:nw.s,n:void 0,t:nw,e:void 0,x:void 0,r:t},nw.s!==void 0&&(nw.s.n=t),nw.s=t,e.n=t,32&nw.f&&e.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=nw.s,t.n=void 0,nw.s.n=t,nw.s=t),t):void 0}function dw(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function fw(e,t){return new dw(e,t)}function pw(e){for(let t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function mw(e){for(let t=e.s;t!==void 0;t=t.n){let n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function hw(e){let t,n=e.s;for(;n!==void 0;){let e=n.p;n.i===-1?(n.S.U(n),e!==void 0&&(e.n=n.n),n.n!==void 0&&(n.n.p=e)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=e}e.s=t}function gw(e,t){dw.call(this,void 0),this.x=e,this.s=void 0,this.g=lw-1,this.f=4,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}function _w(e){let t=e.m;if(e.m=void 0,typeof t==`function`){ow++;let n=nw;nw=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,vw(e),t}finally{nw=n,tw()}}}function vw(e){for(let t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,_w(e)}function yw(e){if(nw!==this)throw Error(`Out-of-order effect`);hw(this),nw=e,this.f&=-2,8&this.f&&vw(this),tw()}function bw(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name}function xw(e,t){let n=new bw(e,t);try{n.c()}catch(e){throw n.d(),e}let r=n.d.bind(n);return r[Symbol.dispose]=r,r}dw.prototype.brand=ew,dw.prototype.h=function(){return!0},dw.prototype.S=function(e){let t=this.t;t!==e&&e.e===void 0&&(e.x=t,this.t=e,t===void 0?iw(()=>{var e;(e=this.W)==null||e.call(this)}):t.e=e)},dw.prototype.U=function(e){if(this.t!==void 0){let t=e.e,n=e.x;t!==void 0&&(t.x=n,e.e=void 0),n!==void 0&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n,n===void 0&&iw(()=>{var e;(e=this.Z)==null||e.call(this)}))}},dw.prototype.subscribe=function(e){return xw(()=>{let t=this.value,n=nw;nw=void 0;try{e(t)}finally{nw=n}},{name:`sub`})},dw.prototype.valueOf=function(){return this.value},dw.prototype.toString=function(){return this.value+``},dw.prototype.toJSON=function(){return this.value},dw.prototype.peek=function(){let e=nw;nw=void 0;try{return this.value}finally{nw=e}},Object.defineProperty(dw.prototype,"value",{get(){let e=uw(this);return e!==void 0&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(sw>100)throw Error(`Cycle detected`);(function(e){ow!==0&&sw===0&&e.l!==cw&&(e.l=cw,aw={S:e,v:e.v,i:e.i,o:aw})})(this),this.v=e,this.i++,lw++,ow++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{tw()}}}}),gw.prototype=new dw,gw.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===lw))return!0;if(this.g=lw,this.f|=1,this.i>0&&!pw(this))return this.f&=-2,!0;let e=nw;try{mw(this),nw=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return nw=e,hw(this),this.f&=-2,!0},gw.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}dw.prototype.S.call(this,e)},gw.prototype.U=function(e){if(this.t!==void 0&&(dw.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}},gw.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(gw.prototype,"value",{get(){if(1&this.f)throw Error(`Cycle detected`);let e=uw(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),bw.prototype.c=function(){let e=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e==`function`&&(this.m=e)}finally{e()}},bw.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,_w(this),mw(this),ow++;let e=nw;return nw=this,yw.bind(this,e)},bw.prototype.N=function(){2&this.f||(this.f|=2,this.u=rw,rw=this)},bw.prototype.d=function(){this.f|=8,1&this.f||vw(this)},bw.prototype.dispose=function(){this.d()};function Sw(e){return(typeof e.nodes==`function`?e.nodes():e.nodes)||[]}function Cw(e,t){let n;return fw(e(),{unwatched(){n&&=(n(),void 0)},watched(){this.value=e(),n=t(this)}})}function ww(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var Tw;try{Tw=`0.49.0+prod.esm`}catch{}var Ew=Tw??`"<unknown>+source"`,Dw=new Set([`__proto__`,`constructor`,`prototype`]);function Ow(e,t){if(e&&t&&!Array.isArray(t)&&typeof e==`object`&&typeof t==`object`){let n=e,r=t;for(let e in r)!Dw.has(e)&&Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=Ow(n[e],r[e]));return e}return t}var kw=0,Aw=1,jw=2,Mw=3,Nw=4,Pw=5,Fw=6,Iw=7;function Lw(e){return e.id===kw}function Rw(e){return e.id===jw}function zw(e){return function(e){return e.id===Aw}(e)||ww(305,String(e.id),String(Aw)),Object.assign(e,{id:jw})}var Bw=new Set,Vw=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=new Set,this.state={id:kw}}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):wC;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;Rw(t)||ww(306,String(t.id));let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=function(e,t,n){return Object.assign(e,{config:t,id:Mw,registerState:n})}(t,this.mergeConfigs(),n),a;this.state=i,this.extension.init&&(a=this.extension.init(e,i.config,n)),this.state=function(e,t,n){return Object.assign(e,{id:Nw,initResult:t,registerState:n})}(i,a,r)}build(e){let t=this.state,n;t.id!==Nw&&ww(307,String(t.id),String(Pw)),this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(e,t,n){return Object.assign(e,{id:Pw,output:t,registerState:n})}(t,n,r)}register(e,t){this._signal=t;let n=this.state;n.id!==Pw&&ww(308,String(n.id),String(Pw));let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=function(e){return Object.assign(e,{id:Fw})}(n),()=>{let e=this.state;e.id!==Iw&&ww(309,String(n.id),String(Iw)),this.state=function(e){return Object.assign(e,{id:Pw})}(e),r&&r()}}afterRegistration(e){let t=this.state,n;return t.id!==Fw&&ww(310,String(t.id),String(Fw)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=function(e){return Object.assign(e,{id:Iw})}(t),n}getSignal(){return this._signal===void 0&&ww(311),this._signal}getInitResult(){this.extension.init===void 0&&ww(312,this.extension.name);let e=this.state;return function(e){return e.id>=Nw}(e)||ww(313,String(e.id),String(Nw)),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return function(e){return e.id>=Mw}(e)||ww(314,String(e.id),String(Mw)),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&ww(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&ww(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return function(e){return e.id>=Iw}(e)||ww(316,String(e.id),String(Iw)),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Bw}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([e])=>e)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;(function(e){return e.id>=Pw})(e)||ww(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output}}return this._dependency}},Hw={tag:p_};function Uw(){let e=yb();e.isEmpty()&&e.append(Ny())}var Ww=SC({config:CC({setOptions:Hw,updateOptions:Hw}),init:({$initialEditorState:e=Uw})=>({$initialEditorState:e,initialized:!1}),afterRegistration(e,{updateOptions:t,setOptions:n},r){let i=r.getInitResult();if(!i.initialized){i.initialized=!0;let{$initialEditorState:r}=i;if(xy(r))e.setEditorState(r,n);else if(typeof r==`function`)e.update(()=>{r(e)},t);else if(r&&(typeof r==`string`||typeof r==`object`)){let t=e.parseEditorState(r);e.setEditorState(t,n)}}return()=>{}},name:`@lexical/extension/InitialState`,nodes:[gy,D_,wy,R_,jy]}),Gw=Symbol.for(`@lexical/extension/LexicalBuilder`);function Kw(){}function qw(e){throw e}function Jw(e){return Array.isArray(e)?e:[e]}var Yw=Ew,Xw=class e{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=Yw,this.roots=e;for(let t of e)this.addExtension(t)}static fromExtensions(t){let n=[Jw(Ww)];for(let e of t)n.push(Jw(e));return new e(n)}static maybeFromEditor(t){let n=t[Gw];return n&&(n.PACKAGE_VERSION!==Yw&&ww(292,n.PACKAGE_VERSION,Yw),n instanceof e||ww(293)),n}static fromEditor(t){let n=e.maybeFromEditor(t);return n===void 0&&ww(294),n}constructEditor(){let{$initialEditorState:e,onError:t,onWarn:n,...r}=this.buildCreateEditorArgs(),i=Object.assign(zy({...r,...t?{onError:e=>{t(e,i)}}:{},...n?{onWarn:e=>{n(e,i)}}:{}}),{[Gw]:this});for(let e of this.sortedExtensionReps())e.build(i);return i}buildEditor(){let e=Kw;function t(){try{e()}finally{e=Kw}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=DC(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&ww(295,e.name),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,new Set([e]))}addExtension(e){this._sortedExtensionReps!==void 0&&ww(296);let[t]=Jw(e);typeof t.name!=`string`&&ww(297,typeof t.name);let n=this.extensionNameMap.get(t.name);if(n!==void 0&&n.extension!==t&&ww(298,t.name),!n){n=new Vw(this,t),this.extensionNameMap.set(t.name,n);let e=this.conflicts.get(t.name);typeof e==`string`&&ww(299,t.name,e);for(let e of t.conflictsWith||[])this.extensionNameMap.has(e)&&ww(299,t.name,e),this.conflicts.set(e,t.name);for(let e of t.dependencies||[]){let n=Jw(e);this.addEdge(t.name,n[0].name,n.slice(1)),this.addExtension(n)}for(let[e,n]of t.peerDependencies||[])this.addEdge(t.name,e,n?[n]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(Rw(i))return;let a=n.extension.name;var o;Lw(i)||ww(300,a,r||`[unknown]`),Lw(o=i)||ww(304,String(o.id),String(kw)),i=Object.assign(o,{id:Aw}),n.state=i;let s=this.outgoingConfigEdges.get(a);if(s)for(let e of s.keys()){let n=this.extensionNameMap.get(e);n&&t(n,a)}i=zw(i),n.state=i,e.push(n)};for(let e of this.extensionNameMap.values())Lw(e.state)&&t(e);for(let t of e)for(let[e,n]of this.outgoingConfigEdges.get(t.extension.name)||[])if(n.length>0){let t=this.extensionNameMap.get(e);if(t)for(let e of n)t.configs.add(e)}for(let[e,...t]of this.roots)if(t.length>0){let n=this.extensionNameMap.get(e.name);n===void 0&&ww(301,e.name);for(let e of t)n.configs.add(e)}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let n of t){let t=n.register(e,i);t&&r.push(t)}for(let n of t){let t=n.afterRegistration(e);t&&r.push(t)}return DC(...r)}buildCreateEditorArgs(){let e={},t=new Set,n=new Map,r=new Map,i={},a={},o=this.sortedExtensionReps();for(let s of o){let{extension:o}=s;if(o.onError!==void 0&&(e.onError=o.onError),o.onWarn!==void 0&&(e.onWarn=o.onWarn),o.disableEvents!==void 0&&(e.disableEvents=o.disableEvents),o.parentEditor!==void 0&&(e.parentEditor=o.parentEditor),o.editable!==void 0&&(e.editable=o.editable),o.namespace!==void 0&&(e.namespace=o.namespace),o.$initialEditorState!==void 0&&(e.$initialEditorState=o.$initialEditorState),o.nodes)for(let e of Sw(o)){if(typeof e!=`function`){let t=n.get(e.replace);t&&ww(302,o.name,e.replace.name,t.extension.name),n.set(e.replace,s)}t.add(e)}if(o.html){if(o.html.export)for(let[e,t]of o.html.export.entries())r.set(e,t);o.html.import&&Object.assign(i,o.html.import)}o.theme&&Ow(a,o.theme)}Object.keys(a).length>0&&(e.theme=a),t.size&&(e.nodes=[...t]);let s=Object.keys(i).length>0,c=r.size>0;(s||c)&&(e.html={},s&&(e.html.import=i),c&&(e.html.export=r));for(let t of o)t.init(e);return e.onError||=qw,e}};function Zw(e,t){let n=Xw.maybeFromEditor(e);if(!n)return;let r=n.extensionNameMap.get(t);return r?r.getExtensionDependency():void 0}var Qw=class extends my{$config(){return this.config(`horizontalrule`,{importDOM:{hr:()=>({conversion:$w,priority:0})}})}exportDOM(){return{element:mx().createElement(`hr`)}}createDOM(e){let t=mx().createElement(`hr`);return EC(t,e.theme.hr),t}getTextContent(){return`
|
|
19
|
-
`}isInline(){return!1}updateDOM(){return!1}};function $w(){return{node:eT()}}function eT(){return eS(Qw)}Date.now;function tT(e,t,n,r,i){if(e===null||n.size===0&&r.size===0&&!i)return 0;let a=t._selection,o=e._selection;if(i)return 1;if(!(Q(a)&&Q(o)&&o.isCollapsed()&&a.isCollapsed()))return 0;let s=function(e,t,n){let r=e._nodeMap,i=[];for(let e of t){let t=r.get(e);t!==void 0&&i.push(t)}for(let[e,t]of n){if(!t)continue;let n=r.get(e);n===void 0||_y(n)||i.push(n)}return i}(t,n,r);if(s.length===0)return 0;if(s.length>1){let n=t._nodeMap,r=n.get(a.anchor.key),i=n.get(o.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&Z(r)&&r.__text.length===1&&a.anchor.offset===1?2:0}let c=s[0],l=e._nodeMap.get(c.__key);if(!Z(l)||!Z(c)||l.__mode!==c.__mode)return 0;let u=l.__text,d=c.__text;if(u===d)return 0;let f=a.anchor,p=o.anchor;if(f.key!==p.key||f.type!==`text`)return 0;let m=f.offset,h=p.offset,g=d.length-u.length;return g===1&&h===m-1?2:g===-1&&h===m+1?3:g===-1&&h===m?4:0}function nT(e,t,n){let r=n(),i=0,a=r,o=0,s=null;return(c,l,u,d,f,p)=>{let m=n();if(p.has(`composition-start`)&&(a=r,o=i,s=c),p.has(`historic`))return i=0,r=m,2;p.has(`composition-end`)&&s&&(r=a,i=o,c=s);let h=p.has(`paste`)||p.has(`cut`)?0:tT(c,l,d,f,e.isComposing()),g=(()=>{let n=u===null||u.editor===e,a=p.has(f_);if(!a&&n&&p.has(`history-merge`))return 0;if(h===1)return 2;if(c===null)return 1;let o=l._selection;if(!(d.size>0||f.size>0))return o===null?2:0;let s=typeof t==`number`?t:t.peek();return!1===a&&h!==0&&h===i&&m<r+s&&n||d.size===1&&function(e,t,n){let r=t._nodeMap.get(e),i=n._nodeMap.get(e),a=t._selection,o=n._selection;return!(Q(a)&&Q(o)&&a.anchor.type===`element`&&a.focus.type===`element`&&o.anchor.type===`text`&&o.focus.type===`text`||!Z(r)||!Z(i)||r.__parent!==i.__parent)&&JSON.stringify(t.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>i.exportJSON()))}(Array.from(d)[0],c,l)?0:1})();return r=m,i=h,g}}function rT(e,t){e.undoStack=[],e.redoStack=[],e.current=null,t&&t(e)}function iT(e,t,n,r=Date.now,i,a=null){let o=nT(e,n,r),s=()=>{i&&i(t)};return s(),DC(e.registerCommand(tg,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(i.length!==0){let a=t.current,o=i.pop();a!==null&&(r.push(a),e.dispatchCommand(Tg,!0)),i.length===0&&e.dispatchCommand(Eg,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(ng,()=>(function(e,t,n){let r=t.redoStack,i=t.undoStack;if(r.length!==0){let a=t.current;a!==null&&(i.push(a),e.dispatchCommand(Eg,!0));let o=r.pop();r.length===0&&e.dispatchCommand(Tg,!1),t.current=o||null,n&&n(t),o&&o.editor.setEditorState(o.editorState,{tag:`historic`})}}(e,t,i),!0),0),e.registerCommand(Cg,()=>(rT(t,i),!1),0),e.registerCommand(wg,()=>(rT(t,i),e.dispatchCommand(Tg,!1),e.dispatchCommand(Eg,!1),!0),0),e.registerUpdateListener(({editorState:n,prevEditorState:r,dirtyLeaves:i,dirtyElements:c,tags:l})=>{let u=t.current,d=t.redoStack,f=t.undoStack,p=u===null?null:u.editorState;if(u!==null&&n===p)return;let m=o(r,n,u,i,c,l);if(m===1){if(d.length!==0&&(t.redoStack=[],e.dispatchCommand(Tg,!1)),u!==null){f.push({...u});let t=typeof a==`number`||a===null?a:a.peek();t!==null&&f.length>t&&f.splice(0,f.length-t),e.dispatchCommand(Eg,!0)}}else if(m===2)return;t.current={editor:e,editorState:n},s()}))}function aT(){return{current:null,redoStack:[],undoStack:[]}}Date.now;function oT({delay:e,externalHistoryState:t}){let[n]=wp();return function(e,t,n=1e3){let r=(0,q.useMemo)(()=>t||aT(),[t]);(0,q.useEffect)(()=>iT(e,r,n),[n,e,r])}(n,t,e),null}var sT=Ep?q.useLayoutEffect:q.useEffect;function cT({ignoreHistoryMergeTagChange:e=!0,ignoreSelectionChange:t=!1,onChange:n}){let[r]=wp();return sT(()=>{if(n)return r.registerUpdateListener(({editorState:i,dirtyElements:a,dirtyLeaves:o,prevEditorState:s,tags:c})=>{t&&a.size===0&&o.size===0||e&&c.has(`history-merge`)||s.isEmpty()||n(i,r,c)})},[r,e,t,n]),null}var lT=Ep?q.useLayoutEffect:q.useEffect;function uT(e){return{initialValueFn:()=>e.isEditable(),subscribe:t=>e.registerEditableListener(t)}}function dT(){return function(e){let[t]=wp(),n=(0,q.useMemo)(()=>e(t),[t,e]),[r,i]=(0,q.useState)(()=>n.initialValueFn()),a=(0,q.useRef)(r);return lT(()=>{let{initialValueFn:e,subscribe:t}=n,r=e();return a.current!==r&&(a.current=r,i(r)),t(e=>{a.current=e,i(e)})},[n,e]),r}(uT)}var fT=SC({name:`@lexical/react/ReactProvider`}),pT=e(Ro(),1),mT={bold:`bold`,italic:`italic`,strikeThrough:`strikethrough`,subscript:`subscript`,superscript:`superscript`,underline:`underline`},hT=Symbol.for(`@lexical/dragon/WindowState`);function gT(e,t,n){let r=function(e){let t=e[hT];return t===void 0&&(t={dispose:()=>{},editors:new Map,installs:new Set},e[hT]=t),t}(e);if(r.installs.size===0){let t=bT.bind(e);e.addEventListener(`message`,t,!0),r.dispose=()=>{e.removeEventListener(`message`,t,!0)}}if(r.installs.add(t),n){let e=r.editors.get(n)||new Set;e.add(t),r.editors.set(n,e)}return _T.bind(null,e,r,t,n)}function _T(e,t,n,r){if(r){let e=t.editors.get(r);e&&e.delete(n)&&e.size===0&&t.editors.delete(r)}t.installs.delete(n)&&t.installs.size===0&&(t.dispose(),delete e[hT])}function vT(e){return e&&e.ownerDocument.defaultView}function yT(e){let t=Cw(()=>vT(e.getRootElement()),t=>e.registerRootListener(e=>{t.value=vT(e)}));return xw(()=>{let n=t.value;if(n)return gT(n,Symbol(`@lexical/dragon/editorInstall`),e)})}function bT(e){if(e.origin!==this.location.origin)return;let t=function(e){let t=e[hT];if(t===void 0)return null;let n=eb(Sx(e.document));return Qy(n)&&t.editors.has(n)?n:null}(this);if(t===null)return;let n=e.data;if(typeof n==`string`){let r;try{r=JSON.parse(n)}catch{return}if(r&&r.protocol===`nuanria_messaging`&&r.type===`request`){let n=r.payload;if(n&&n.functionId===`makeChanges`){let r=n.args;if(Array.isArray(r)){let[n,i,a,o,s,c]=r;if(![n,i,o,s].every(Number.isFinite)||typeof a!=`string`&&a!==-1)return;t.update(()=>{let t=yv();if(Q(t)){let r=t.anchor,l=r.getNode(),u=0,d=0;if(Z(l)&&n>=0&&i>=0&&(u=n,d=n+i,t.setTextNodeRange(l,u,l,d)),typeof a!=`string`||u===d&&a===``||(t.insertRawText(a),l=r.getNode()),Z(l)){let e=l.getTextContentSize();u=Math.min(Math.max(o,0),e),d=o<0||s<0?u:Math.min(o+s,e),t.setTextNodeRange(l,u,l,d)}if(typeof c==`string`&&s>0&&!t.isCollapsed()){let e=mT[c];e!==void 0&&t.formatText(e)}e.stopImmediatePropagation()}})}}}}}function xT(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var ST;function CT(e,t){let{key:n}=t;return e&&n in e?e[n]:t.defaultValue}function wT(e){return ST&&ST.editor===e?ST:void 0}function TT(e,t){if(`cfg`in t){let{cfg:n,updater:r}=t;return[n,r(CT(e,n))]}return t}function ET(e,t){let n=t;for(let r of e){let[e,i]=TT(n,r),a=e.key;if(n===t&&CT(n,e)===i)continue;let o=n===t||n===void 0?DT(t):n;o[a]=i,n=o}return n}function DT(e){return Object.create(e||null)}function OT(e,t){return[e,t]}function kT(e,t,n,r=Mx()){let i=ST,a=wT(r);try{return ST={...a,editor:r,[e]:t},n()}finally{ST=i}}function AT(e,t=()=>{}){return(n,r=Mx())=>i=>{let a=wT(r),o=a&&a[e],s=ET(n,o||t(r));return s&&s!==o?kT(e,s,i,r):i()}}function jT(e,t,n,r){return Object.assign(Em(Symbol(t),{isEqual:r,parse:n}),{[e]:!0})}var MT=`@lexical/html/DOM`,NT=Symbol.for(`@lexical/html/DOMExportContext`);function PT(e,t,n){return jT(NT,e,t,n)}var FT=PT(`isExport`,Boolean);function IT(e){let t=Zw(e,MT);return t?t.output.defaults:void 0}function LT(e){let t=Zw(e,MT);return t?t.output.runtime:void 0}function RT(e=Mx()){let t=LT(e);return t?t.getSessionConfig():Nx(e)}var zT=AT(NT,IT),BT=Symbol.for(`@lexical/html/SelectorImpl`);function VT(e,t){let n={kind:`element`,predicate:(r=t,r.length===0?wx:r.length===1?r[0]:(e,t)=>{for(let n of r)if(!n(e,t))return!1;return!0}),tags:e};var r;let i=n=>VT(e,[...t,n]);return{[BT]:n,attr:(e,t,n)=>i(WT(e,t,n)),classAll:(...e)=>i(UT(e)),classAny:(...e)=>i(function(e){let t=HT(e);return t.length===0?()=>!1:e=>{if(!wx(e))return!1;let n=e.classList;for(let e of t)if(n.contains(e))return!0;return!1}}(e)),styleAny:(e,t,n)=>i(function(e,t,n){if(typeof t==`string`)return n=>wx(n)&&n.style.getPropertyValue(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!wx(t))return!1;let a=t.style.getPropertyValue(e);if(!a)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}xT(362,JSON.stringify(e))}(e,t,n))}}function HT(e){let t=[];for(let n of e)n&&t.push(n);return t}function UT(e){let t=HT(e);return t.length===0?()=>!0:e=>{if(!wx(e))return!1;let n=e.classList;for(let e of t)if(!n.contains(e))return!1;return!0}}function WT(e,t,n){if(!0===t)return t=>wx(t)&&t.hasAttribute(e);if(typeof t==`string`)return n=>wx(n)&&n.getAttribute(e)===t;if(t instanceof RegExp){let r=n&&n.capture,i=t;return(t,n)=>{if(!wx(t))return!1;let a=t.getAttribute(e);if(a==null)return!1;let o=a.match(i);return o!==null&&(r!==void 0&&(n[r]=o),!0)}}xT(361,JSON.stringify(e))}var GT={kind:`text`,predicate:rb,tags:new Set},KT={[BT]:GT},qT={kind:`comment`,predicate:e=>e.nodeType===8,tags:new Set},JT={[BT]:qT},YT={any:()=>VT(new Set,[]),comment:()=>JT,tag(...e){e.length>0||xT(363);let t=new Set;for(let n of e)t.add(n.toUpperCase());return VT(t,[])},text:()=>KT},XT=YT;XT.tag(`b`,`strong`,`em`,`i`,`code`,`mark`,`s`,`sub`,`sup`,`u`,`span`),XT.text(),XT.tag(`script`,`style`),XT.tag(`br`),XT.tag(`p`),XT.tag(`hr`),XT.any(),Object.freeze([]),Object.freeze({}),YT.any(),YT.any,YT.comment,YT.tag,YT.text;function ZT(e,t=null,n=Mx()){return zT([OT(FT,!0)],n)(()=>{let r=yb(),i=RT(n),a=Q(t)?uS(t.anchor.getNode()):null,o=e.append.bind(e);for(let e of($(a)?a:r).getChildren())$T(n,e,o,t,i);return e})}function QT(e,t=null){return(typeof document>`u`||typeof window>`u`&&global.window===void 0)&&xT(338),Jv(e),ZT(mx().createElement(`div`),t,e).innerHTML}function $T(e,t,n,r=null,i=Nx(e)){let a=i.$shouldInclude(t,r,e),o=i.$shouldExclude(t,r,e),s=t;r!==null&&Z(t)&&(s=KC(r,t,`clone`));let{element:c,after:l,append:u,$getChildNodes:d}=i.$exportDOM(s,e);if(!c)return!1;let f=mx().createDocumentFragment(),p=d?d():$(s)?s.getChildren():[],m=a&&X_(r)&&$(t)?null:r,h=f.append.bind(f);for(let n of p){let o=$T(e,n,h,m,i);!a&&o&&i.$extractWithChild(t,n,r,`html`,e)&&(a=!0)}if(a&&!o){if((wx(c)||Ex(c))&&(u?u(f):c.append(f)),n(c),l){let e=l.call(s,c);e&&(Ex(c)?c.replaceChildren(e):c.replaceWith(e))}}else n(f);return a}function eE(e,t,n=null){let r=px(n),i=n?dx(n):[],a=n!==null&&i.length>0;if(a&&typeof r.caretPositionFromPoint==`function`){let a=r.caretPositionFromPoint(e,t,{shadowRoots:i});if(a!==null&&function(e,t){for(let n=e;n!==null;){if(n===t)return!0;n=Wb(n)}return!1}(a.offsetNode,n))return{node:a.offsetNode,offset:a.offset}}if(a){let i=n.getRootNode();if(lx(i)){let a=i.elementFromPoint(e,t);if(a!==null&&n.contains(a)){let n=function(e,t,n,r){let i=r.createRange(),a=e=>t<e.top?e.top-t:t>e.bottom?t-e.bottom:0,o=t=>e<t.left?t.left-e:e>t.right?e-t.right:0,s=r.createTreeWalker(n,NodeFilter.SHOW_TEXT),c=null,l=1/0,u=1/0;for(let e=s.nextNode();e;e=s.nextNode()){i.selectNodeContents(e);for(let t of i.getClientRects()){let n=a(t),r=o(t);(n<l||n===l&&r<u)&&(l=n,u=r,c=e)}}if(c===null)return null;let d=0,f=1/0,p=1/0;for(let t=0;t<=c.length;t++){i.setStart(c,t),i.collapse(!0);let n=i.getBoundingClientRect(),r=a(n),o=Math.abs(e-n.left);(r<f||r===f&&o<p)&&(f=r,p=o,d=t)}return{node:c,offset:d}}(e,t,a,r);if(n!==null)return n}}}if(typeof r.caretRangeFromPoint==`function`){let n=r.caretRangeFromPoint(e,t);return n===null?null:{node:n.startContainer,offset:n.startOffset}}if(typeof r.caretPositionFromPoint==`function`){let n=r.caretPositionFromPoint(e,t);return n===null?null:{node:n.offsetNode,offset:n.offset}}return null}function tE(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function nE(e,t=yv()){return t??tE(166),Q(t)&&t.isCollapsed()||t.getNodes().length===0?``:QT(e,t)}function rE(e,t){let n=e.getData(`text/plain`)||e.getData(`text/uri-list`);n!=null&&t.insertRawText(n)}var iE=`application/x-lexical-drag`;function aE(e,t){let n={editorKey:t.getKey()};e.setData(iE,JSON.stringify(n))}function oE(e,t,n){let r=e.dataTransfer;if(r===null)return!1;let i=function(e){let t=e.getData(iE);if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}return(r=n)!==null&&typeof r==`object`&&`editorKey`in r&&typeof r.editorKey==`string`?n:null;var r}(r);if(i===null)return!1;let a=function(e,t){let n=eE(e.clientX,e.clientY,t.getRootElement());if(n===null)return null;let r=gb(n.node);if(r===null)return null;if(Z(r))return VS(r,`next`,n.offset);if($(r))return _C(r,n.offset,`next`);let i=r.getParent();return i===null?null:_C(i,r.getIndexWithinParent()+1,`next`)}(e,t);if(a===null)return!1;let o=bC(a);if(o===null)return!1;let s=i.editorKey===t.getKey(),c=yv();if(s){if(!Q(c)||c.isCollapsed())return!1;if(function(e,t){let{anchor:n,focus:r}=gC(cC(t),`next`);return $S(n,e)<0&&$S(e,r)<0}(a,c))return e.preventDefault(),!0;c.removeText()}if(!o.origin.isAttached())return e.preventDefault(),!0;if(n(r,oC(XS(o)),t),!s){let e=t.getRootElement(),n=e?e.ownerDocument:null,r=n?function(e,t){for(let n of fx(t)){let t=eb(n);if(Qy(t)&&t.getKey()===e&&wx(n))return n}return null}(i.editorKey,n):null;r!==null&&r.dispatchEvent(new InputEvent(`beforeinput`,{bubbles:!0,cancelable:!0,inputType:`deleteByDrag`}))}return e.preventDefault(),!0}function sE(e,t){return oE(e,t,(e,t)=>rE(e,t))}function cE(e,t){t.update(()=>{if(e!==null){let n=$C(e,KeyboardEvent)?null:e.clipboardData,r=yv();if(r!==null&&!r.isCollapsed()&&n!=null){e.preventDefault();let i=nE(t);i!==null&&n.setData(`text/html`,i),n.setData(`text/plain`,r.getTextContent())}}})}function lE(e){return DC(e.registerCommand(Kh,e=>{let t=yv();return!!Q(t)&&(t.deleteCharacter(e),!0)},0),e.registerCommand(Qh,e=>{let t=yv();return!!Q(t)&&(t.deleteWord(e),!0)},0),e.registerCommand($h,e=>{let t=yv();return!!Q(t)&&(t.deleteLine(e),!0)},0),e.registerCommand(Yh,e=>{let t=yv();if(!Q(t))return!1;if(typeof e==`string`)t.insertText(e);else{let n=e.dataTransfer;if(n!=null)rE(n,t);else{let n=e.data;n&&t.insertText(n)}}return!0},0),e.registerCommand(Zh,()=>{let e=yv();return!!Q(e)&&(e.removeText(),!0)},0),e.registerCommand(qh,e=>{let t=yv();return!!Q(t)&&(t.insertLineBreak(e),!0)},0),e.registerCommand(Jh,()=>{let e=yv();return!!Q(e)&&(e.insertLineBreak(),!0)},0),e.registerCommand(og,e=>{let t=yv();if(!Q(t))return!1;let n=e,r=n.shiftKey;return!!YC(t,!0)&&(n.preventDefault(),QC(t,r,!0),!0)},0),e.registerCommand(ig,e=>{let t=yv();if(!Q(t))return!1;let n=e,r=n.shiftKey;return!!YC(t,!1)&&(n.preventDefault(),QC(t,r,!1),!0)},0),e.registerCommand(fg,t=>!!Q(yv())&&(!jp||!Ap)&&(t.preventDefault(),e.dispatchCommand(Kh,!0)),0),e.registerCommand(mg,t=>!!Q(yv())&&(t.preventDefault(),e.dispatchCommand(Kh,!1)),0),e.registerCommand(ug,t=>{if(!Q(yv()))return!1;if(t!==null){if((jp||Np||Ip)&&Ap)return!1;t.preventDefault()}return e.dispatchCommand(qh,!1)},0),e.registerCommand(Sg,()=>{let e=yv();return Ib(Q(e)&&uS(e.anchor.getNode())!==null?e:null),!0},0),e.registerCommand(bg,t=>!!Q(yv())&&(cE(t,e),!0),0),e.registerCommand(xg,t=>!!Q(yv())&&(function(e,t){cE(e,t),t.update(()=>{let e=yv();Q(e)&&e.removeText()},{tag:`cut`})}(t,e),!0),0),e.registerCommand(Xh,t=>!!Q(yv())&&(function(e,t){e.preventDefault(),t.update(()=>{let t=yv(),n=$C(e,ClipboardEvent)?e.clipboardData:null;n!=null&&Q(t)&&rE(n,t)},{tag:`paste`})}(t,e),!0),0),e.registerCommand(gg,t=>sE(t,e),0),e.registerCommand(_g,t=>{let n=yv();return!!Q(n)&&(n.isCollapsed()||t.dataTransfer===null||aE(t.dataTransfer,e),!0)},0))}function uE(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}var dE=Ep?q.useLayoutEffect:q.useEffect;function fE({editor:e,ErrorBoundary:t}){return function(e,t){let[n,r]=(0,q.useState)(()=>e.getDecorators());return dE(()=>e.registerDecoratorListener(e=>{(0,pT.flushSync)(()=>{r(e)})}),[e]),(0,q.useEffect)(()=>{r(e.getDecorators())},[e]),(0,q.useMemo)(()=>{let r=[],i=Object.keys(n);for(let a=0;a<i.length;a++){let o=i[a],s=(0,Y.jsx)(t,{onError:t=>e._onError(t),children:(0,Y.jsx)(q.Suspense,{fallback:null,children:n[o]})}),c=e.getElementByKey(o);c!==null&&r.push((0,pT.createPortal)(s,c,o))}return r},[t,n,e])}(e,t)}function pE({editor:e,ErrorBoundary:t}){return function(e){let t=Xw.maybeFromEditor(e);if(t&&t.hasExtensionByName(fT.name)){for(let e of[`@lexical/plain-text`,`@lexical/rich-text`])t.hasExtensionByName(e)&&uE(320,e);return!0}return!1}(e)?null:(0,Y.jsx)(fE,{editor:e,ErrorBoundary:t})}function mE(e){return e.read(`latest`,PC(e.isComposing()))}function hE({contentEditable:e,placeholder:t=null,ErrorBoundary:n}){let[r]=wp();return function(e){dE(()=>DC(lE(e),yT(e)),[e])}(r),(0,Y.jsxs)(Y.Fragment,{children:[e,(0,Y.jsx)(gE,{content:t}),(0,Y.jsx)(pE,{editor:r,ErrorBoundary:n})]})}function gE({content:e}){let[t]=wp(),n=function(e){let[t,n]=(0,q.useState)(()=>mE(e));return dE(()=>{function t(){let t=mE(e);n(t)}return t(),DC(e.registerUpdateListener(()=>{t()}),e.registerEditableListener(()=>{t()}))},[e]),t}(t),r=dT();return n?typeof e==`function`?e(r):e:null}function _E(e){let t=(0,J.c)(18),{label:n,tooltipText:r,expired:i}=e,a=i!==void 0&&i,o=a&&`border-destructive/35 bg-destructive/8 text-destructive`,s;t[0]===o?s=t[1]:(s=G(Ea,o),t[0]=o,t[1]=s);let c=a?`true`:void 0,l=a&&`opacity-100`,u;t[2]===l?u=t[3]:(u=G($i,`size-3.5`,l),t[2]=l,t[3]=u);let d;t[4]===u?d=t[5]:(d=(0,Y.jsx)(Ja,{className:u}),t[4]=u,t[5]=d);let f;t[6]===n?f=t[7]:(f=(0,Y.jsx)(`span`,{className:Ta,children:n}),t[6]=n,t[7]=f);let p;t[8]!==s||t[9]!==c||t[10]!==d||t[11]!==f?(p=(0,Y.jsx)(Fo,{render:(0,Y.jsxs)(`span`,{className:s,"data-terminal-context-expired":c,children:[d,f]})}),t[8]=s,t[9]=c,t[10]=d,t[11]=f,t[12]=p):p=t[12];let m;t[13]===r?m=t[14]:(m=(0,Y.jsx)(Io,{side:`top`,className:`max-w-80 whitespace-pre-wrap leading-tight`,children:r}),t[13]=r,t[14]=m);let h;return t[15]!==p||t[16]!==m?(h=(0,Y.jsxs)(Lo,{children:[p,m]}),t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function vE(e){let t=(0,J.c)(8),{context:n}=e,r;t[0]===n?r=t[1]:(r=zt(n),t[0]=n,t[1]=r);let i=r,a;t[2]===n?a=t[3]:(a=fn(n),t[2]=n,t[3]=a);let o=a,s=o?`Terminal context expired. Remove and re-add ${i} to include it in your message.`:n.text,c;return t[4]!==o||t[5]!==i||t[6]!==s?(c=(0,Y.jsx)(_E,{label:i,tooltipText:s,expired:o}),t[4]=o,t[5]=i,t[6]=s,t[7]=c):c=t[7],c}var yE=`composer-editor-${Math.random().toString(36).slice(2)}`,bE=new Map([[`(`,`)`],[`[`,`]`],[`{`,`}`],[`'`,`'`],[`"`,`"`],[`“`,`”`],["`","`"],[`<`,`>`],[`«`,`»`],[`*`,`*`],[`_`,`_`]]),xE=bE.get("`")??null,SE=(0,q.createContext)({onRemoveTerminalContext:()=>{}});function CE(e){let t=(0,J.c)(20),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=FE(),t[0]=n):n=t[0];let r=n,i;t[1]===e.path?i=t[2]:(i=Jc(e.path),t[1]=e.path,t[2]=i);let a;t[3]!==e.path||t[4]!==i?(a=(0,Y.jsx)(ha,{className:$i,kind:i,pathValue:e.path,theme:r}),t[3]=e.path,t[4]=i,t[5]=a):a=t[5];let o;t[6]===e.path?o=t[7]:(o=Yc(e.path),t[6]=e.path,t[7]=o);let s;t[8]===o?s=t[9]:(s=(0,Y.jsx)(`span`,{className:Ta,children:o}),t[8]=o,t[9]=s);let c;t[10]!==a||t[11]!==s?(c=(0,Y.jsxs)(`span`,{className:Ea,contentEditable:!1,spellCheck:!1,"data-composer-mention-chip":`true`,children:[a,s]}),t[10]=a,t[11]=s,t[12]=c):c=t[12];let l=c,u;t[13]===l?u=t[14]:(u=(0,Y.jsx)(Fo,{render:l}),t[13]=l,t[14]=u);let d;t[15]===e.path?d=t[16]:(d=(0,Y.jsx)(Io,{side:`top`,className:`max-w-120 whitespace-normal leading-tight wrap-anywhere`,children:e.path}),t[15]=e.path,t[16]=d);let f;return t[17]!==u||t[18]!==d?(f=(0,Y.jsxs)(Lo,{children:[u,d]}),t[17]=u,t[18]=d,t[19]=f):f=t[19],f}var wE=class e extends my{__path;static getType(){return`composer-mention`}static clone(t){return new e(t.__path,t.__key)}static importJSON(e){return TE(e.path).updateFromJSON(e)}constructor(e,t){super(t);let n=e.startsWith(`@`)?e.slice(1):e;this.__path=n}exportJSON(){return{...super.exportJSON(),path:this.__path,type:`composer-mention`,version:1}}createDOM(){let e=document.createElement(`span`);return e.className=`inline-flex align-middle leading-none`,e}updateDOM(){return!1}getTextContent(){return`@${Xt(this.__path)}`}isInline(){return!0}decorate(){return(0,Y.jsx)(CE,{path:this.__path})}};function TE(e){return nx(new wE(e))}function EE(e){return e.shortDescription?.trim()||e.description?.trim()||null}function DE(e){return new Map(e.map(e=>[e.name,{label:ea(e),description:EE(e)}]))}function OE(e){let t=(0,J.c)(10),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:$i,dangerouslySetInnerHTML:{__html:ta}}),t[0]=n):n=t[0];let r;t[1]===e.skillLabel?r=t[2]:(r=(0,Y.jsxs)(`span`,{className:aa,contentEditable:!1,spellCheck:!1,"data-composer-skill-chip":`true`,children:[n,(0,Y.jsx)(`span`,{className:Ta,children:e.skillLabel})]}),t[1]=e.skillLabel,t[2]=r);let i=r;if(!e.skillDescription)return i;let a;t[3]===i?a=t[4]:(a=(0,Y.jsx)(Fo,{render:i}),t[3]=i,t[4]=a);let o;t[5]===e.skillDescription?o=t[6]:(o=(0,Y.jsx)(Io,{side:`top`,className:`max-w-120 whitespace-normal leading-tight`,children:e.skillDescription}),t[5]=e.skillDescription,t[6]=o);let s;return t[7]!==a||t[8]!==o?(s=(0,Y.jsxs)(Lo,{children:[a,o]}),t[7]=a,t[8]=o,t[9]=s):s=t[9],s}var kE=class e extends my{__skillName;__skillLabel;__skillDescription;static getType(){return`composer-skill`}static clone(t){return new e(t.__skillName,t.__skillLabel,t.__skillDescription,t.__key)}static importJSON(e){return AE(e.skillName,e.skillLabel??e.skillName,e.skillDescription??null).updateFromJSON(e)}constructor(e,t,n,r){super(r);let i=e.startsWith(`$`)?e.slice(1):e;this.__skillName=i,this.__skillLabel=t,this.__skillDescription=n}exportJSON(){return{...super.exportJSON(),skillName:this.__skillName,skillLabel:this.__skillLabel,...this.__skillDescription?{skillDescription:this.__skillDescription}:{},type:`composer-skill`,version:1}}createDOM(){let e=document.createElement(`span`);return e.className=`inline-flex align-middle leading-none`,e}updateDOM(){return!1}getTextContent(){return`$${this.__skillName}`}isInline(){return!0}decorate(){return(0,Y.jsx)(OE,{skillLabel:this.__skillLabel,skillDescription:this.__skillDescription})}};function AE(e,t,n){return nx(new kE(e,t,n))}function jE(e){let t=(0,J.c)(2),n;return t[0]===e.context?n=t[1]:(n=(0,Y.jsx)(vE,{context:e.context}),t[0]=e.context,t[1]=n),n}var ME=class e extends my{__context;static getType(){return`composer-terminal-context`}static clone(t){return new e(t.__context,t.__key)}static importJSON(e){return NE(e.context)}constructor(e,t){super(t),this.__context=e}exportJSON(){return{...super.exportJSON(),context:this.__context,type:`composer-terminal-context`,version:1}}createDOM(){let e=document.createElement(`span`);return e.className=`inline-flex align-middle leading-none`,e}updateDOM(){return!1}getTextContent(){return``}isInline(){return!0}decorate(){return(0,Y.jsx)(jE,{context:this.__context})}};function NE(e){return nx(new ME(e))}function PE(e){return e instanceof wE||e instanceof kE||e instanceof ME}function FE(){return document.documentElement.classList.contains(`dark`)?`dark`:`light`}function IE(e){return e.map(e=>[e.id,e.threadId,e.terminalId,e.terminalLabel,e.lineStart,e.lineEnd,e.createdAt,e.text].join(``)).join(``)}function LE(e){return e.map(e=>[e.name,e.displayName??``,e.shortDescription??``,e.description??``,e.path,e.scope??``,e.enabled?`1`:`0`].join(``)).join(``)}function RE(e,t){return Number.isFinite(t)?Math.max(0,Math.min(e.length,Math.floor(t))):e.length}function zE(e){return 1}function BE(e){return e.getTextContentSize()}function VE(e,t,n){return t+(n>0?zE(e):0)}function HE(e,t,n){return t+(n>0?BE(e):0)}function UE(e,t){let n=e.getParent();if(!n||!$(n))return null;let r=e.getIndexWithinParent();return t.value===0?{key:n.getKey(),offset:r,type:`element`}:t.value===zE(e)?{key:n.getKey(),offset:r+1,type:`element`}:(t.value-=zE(e),null)}function WE(e){return PE(e)?zE(e):Z(e)?e.getTextContentSize():Dy(e)?1:$(e)?e.getChildren().reduce((e,t)=>e+WE(t),0):0}function GE(e){return PE(e)?BE(e):Z(e)?e.getTextContentSize():Dy(e)?1:$(e)?e.getChildren().reduce((e,t)=>e+GE(t),0):0}function KE(e,t){let n=0,r=e;for(;r;){let e=r.getParent();if(!e||!$(e))break;let t=e.getChildren(),i=r.getIndexWithinParent();for(let e=0;e<i;e+=1){let r=t[e];r&&(n+=WE(r))}r=e}if(Z(e))return n+Math.min(t,e.getTextContentSize());if(PE(e))return VE(e,n,t);if(Dy(e))return n+Math.min(t,1);if($(e)){let r=e.getChildren(),i=Math.max(0,Math.min(t,r.length));for(let e=0;e<i;e+=1){let t=r[e];t&&(n+=WE(t))}return n}return n}function qE(e,t){let n=0,r=e;for(;r;){let e=r.getParent();if(!e||!$(e))break;let t=e.getChildren(),i=r.getIndexWithinParent();for(let e=0;e<i;e+=1){let r=t[e];r&&(n+=GE(r))}r=e}if(Z(e))return n+Math.min(t,e.getTextContentSize());if(PE(e))return HE(e,n,t);if(Dy(e))return n+Math.min(t,1);if($(e)){let r=e.getChildren(),i=Math.max(0,Math.min(t,r.length));for(let e=0;e<i;e+=1){let t=r[e];t&&(n+=GE(t))}return n}return n}function JE(e,t){if(PE(e))return UE(e,t);if(Z(e)){let n=e.getTextContentSize();return t.value<=n?{key:e.getKey(),offset:t.value,type:`text`}:(t.value-=n,null)}if(Dy(e)){let n=e.getParent();if(!n)return null;let r=e.getIndexWithinParent();return t.value===0?{key:n.getKey(),offset:r,type:`element`}:t.value===1?{key:n.getKey(),offset:r+1,type:`element`}:(--t.value,null)}if($(e)){let n=e.getChildren();for(let e of n){let n=JE(e,t);if(n)return n}if(t.value===0)return{key:e.getKey(),offset:n.length,type:`element`}}return null}function YE(){return yb().getChildren().reduce((e,t)=>e+WE(t),0)}function XE(e){let t=yb(),n=YE(),r=JE(t,{value:Math.max(0,Math.min(e,n))})??{key:t.getKey(),offset:t.getChildren().length,type:`element`},i=gv();i.anchor.set(r.key,r.offset,r.type),i.focus.set(r.key,r.offset,r.type),bb(i)}function ZE(e,t){let n=yb(),r=YE(),i=Math.max(0,Math.min(e,r)),a=Math.max(0,Math.min(t,r)),o={value:i},s={value:a},c=JE(n,o)??{key:n.getKey(),offset:n.getChildren().length,type:`element`},l=JE(n,s)??{key:n.getKey(),offset:n.getChildren().length,type:`element`},u=gv();u.anchor.set(c.key,c.offset,c.type),u.focus.set(l.key,l.offset,l.type),bb(u)}function QE(e){if(!Q(e))return null;let t=e.anchor.getNode(),n=e.focus.getNode(),r=qE(t,e.anchor.offset),i=qE(n,e.focus.offset);return{start:Math.min(r,i),end:Math.max(r,i)}}function $E(e){return Q(e)?e.getNodes().some(e=>PE(e)):!1}function eD(e){let t=yv();if(!Q(t)||!t.isCollapsed())return e;let n=KE(t.anchor.getNode(),t.anchor.offset),r=YE();return Math.max(0,Math.min(n,r))}function tD(e){let t=yv();if(!Q(t)||!t.isCollapsed())return e;let n=qE(t.anchor.getNode(),t.anchor.offset),r=yb().getTextContent().length;return Math.max(0,Math.min(n,r))}function nD(e,t){let n=t.split(`
|
|
20
|
-
`);for(let t=0;t<n.length;t+=1){let r=n[t]??``;r.length>0&&e.append(I_(r)),t<n.length-1&&e.append(Ey())}}function rD(e,t,n){let r=yb();r.clear();let i=Ny();r.append(i);let a=xt(e,t);for(let e of a){if(e.type===`mention`){i.append(TE(e.path));continue}if(e.type===`skill`){let t=n.get(e.name);i.append(AE(e.name,t?.label??ea({name:e.name}),t?.description??null));continue}if(e.type===`terminal-context`){e.context&&i.append(NE(e.context));continue}nD(i,e.text)}}function iD(e){return e instanceof ME?[e.__context.id]:$(e)?e.getChildren().flatMap(e=>iD(e)):[]}function aD(e){let t=(0,J.c)(4),[n]=wp(),r,i;return t[0]!==n||t[1]!==e?(r=()=>{let t=(t,n)=>{if(!e.onCommandKeyDown||!n)return!1;let r=e.onCommandKeyDown(t,n);return r&&(n.preventDefault(),n.stopPropagation()),r},r=n.registerCommand(lg,e=>t(`ArrowDown`,e),3),i=n.registerCommand(cg,e=>t(`ArrowUp`,e),3),a=n.registerCommand(ug,e=>t(`Enter`,e),3),o=n.registerCommand(hg,e=>t(`Tab`,e),3);return()=>{r(),i(),a(),o()}},i=[n,e],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),(0,q.useEffect)(r,i),null}function oD(){let e=(0,J.c)(3),[t]=wp(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=t.registerCommand(og,e=>{let n=null;if(t.getEditorState().read(()=>{let e=yv();if(!Q(e)||!e.isCollapsed())return;let t=eD(0);if(t<=0)return;let r=yb().getTextContent();pt(r,t,`left`)&&(n=t-1)}),n===null)return!1;let r=n;return e?.preventDefault(),e?.stopPropagation(),t.update(()=>{XE(r)}),!0},3),n=t.registerCommand(ig,e=>{let n=null;if(t.getEditorState().read(()=>{let e=yv();if(!Q(e)||!e.isCollapsed())return;let t=eD(0);if(t>=YE())return;let r=yb().getTextContent();pt(r,t,`right`)&&(n=t+1)}),n===null)return!1;let r=n;return e?.preventDefault(),e?.stopPropagation(),t.update(()=>{XE(r)}),!0},3);return()=>{e(),n()}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,q.useEffect)(n,r),null}function sD(){let e=(0,J.c)(3),[t]=wp(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>t.registerUpdateListener(e=>{let{editorState:n}=e,r=null;n.read(()=>{let e=yv();if(!Q(e)||!e.isCollapsed())return;let t=e.anchor.getNode();PE(t)&&e.anchor.offset!==0&&(r=KE(t,0)+1)}),r!==null&&queueMicrotask(()=>{t.update(()=>{XE(r)})})}),r=[t],e[0]=t,e[1]=n,e[2]=r),(0,q.useEffect)(n,r),null}function cD(){let e=(0,J.c)(4),[t]=wp(),{onRemoveTerminalContext:n}=(0,q.useContext)(SE),r,i;return e[0]!==t||e[1]!==n?(r=()=>t.registerCommand(fg,e=>{let t=yv();if(!Q(t)||!t.isCollapsed())return!1;let r=t.anchor.getNode(),i=eD(0),a=t=>{if(!PE(t))return!1;let r=KE(t,0);return t.remove(),t instanceof ME?(n(t.__context.id),XE(i)):XE(r),e?.preventDefault(),!0};if(a(r))return!0;if(Z(r)){if(t.anchor.offset>0)return!1;if(a(r.getPreviousSibling()))return!0;let e=r.getParent();if($(e)){let t=r.getIndexWithinParent();if(t>0&&a(e.getChildAtIndex(t-1)))return!0}return!1}if($(r)){let e=t.anchor.offset-1;if(e>=0&&a(r.getChildAtIndex(e)))return!0}return!1},3),i=[t,n],e[0]=t,e[1]=n,e[2]=r,e[3]=i):(r=e[2],i=e[3]),(0,q.useEffect)(r,i),null}function lD(e){let t=(0,J.c)(14),[n]=wp(),r=(0,q.useRef)(e.terminalContexts),i;t[0]===e.skills?i=t[1]:(i=DE(e.skills),t[0]=e.skills,t[1]=i);let a=(0,q.useRef)(i),o=(0,q.useRef)(null),s=(0,q.useRef)(null),c,l;t[2]===e.terminalContexts?(c=t[3],l=t[4]):(c=()=>{r.current=e.terminalContexts},l=[e.terminalContexts],t[2]=e.terminalContexts,t[3]=c,t[4]=l),(0,q.useEffect)(c,l);let u,d;t[5]===e.skills?(u=t[6],d=t[7]):(u=()=>{a.current=DE(e.skills)},d=[e.skills],t[5]=e.skills,t[6]=u,t[7]=d),(0,q.useEffect)(u,d);let f;t[8]===n?f=t[9]:(f=e=>{let t=bE.get(e),i=o.current;if(!t)return o.current=null,!1;let s=!1;return n.update(()=>{let n=i??uD();if(!n||!t)return;let c=n.value.slice(n.expandedStart,n.expandedEnd),l=`${n.value.slice(0,n.expandedStart)}${e}${c}${t}${n.value.slice(n.expandedEnd)}`;rD(l,r.current,a.current);let u=Ot(l,n.expandedStart);ZE(u+e.length,u+e.length+c.length),s=!0,o.current=null}),s},t[8]=n,t[9]=f);let p=f,m,h;return t[10]!==p||t[11]!==n?(m=()=>{let e=e=>{if(s.current){if(e.key===`Dead`||e.key===` `||e.code===`Space`)return;s.current=null}if(e.defaultPrevented||e.isComposing||e.metaKey||e.ctrlKey){o.current=null,s.current=null;return}n.getEditorState().read(()=>{let e=yv();if(!Q(e)||e.isCollapsed()){o.current=null,s.current=null;return}if($E(e)){o.current=null,s.current=null;return}let t=QE(e);if(!t||t.start===t.end){o.current=null,s.current=null;return}let n=yb().getTextContent();if(bt(n,t.start,t.end)){o.current=null,s.current=null;return}let r={value:n,expandedStart:t.start,expandedEnd:t.end};o.current=r,s.current=null})},t=e=>{if(e.inputType===`insertCompositionText`&&e.data==="`"&&xE!==null&&o.current){s.current=o.current;return}if(s.current||e.inputType===`insertCompositionText`)return;if(typeof e.data!=`string`){o.current=null;return}let t=e.inputType===`insertText`?e.data:null;if(!t||t.length!==1){o.current=null;return}p(t)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())},r=e=>{queueMicrotask(()=>{n.update(()=>{let t=s.current;if(!t)return;let n=yb().getTextContent();if(xE===null){s.current=null;return}if(n!==`${t.value.slice(0,t.expandedStart)}\`${t.value.slice(t.expandedEnd)}`){e?.finalAttempt&&(o.current=null,s.current=null);return}let r=t.value.slice(t.expandedStart,t.expandedEnd),i=Ot(n,t.expandedStart);ZE(i,i+1);let a=yv();if(!Q(a)){o.current=null,s.current=null;return}a.insertText(`\`${r}${xE}`),ZE(i+1,i+1+r.length),o.current=null,s.current=null},{tag:p_})})},i=e=>{let t=e;(t.inputType===`insertText`||t.inputType===`insertCompositionText`)&&r()},a=()=>{r({finalAttempt:!0})},c=null,l=n.registerRootListener((n,r)=>{r?.removeEventListener(`keydown`,e),r?.removeEventListener(`beforeinput`,t,!0),r?.removeEventListener(`input`,i),r?.removeEventListener(`compositionend`,a),n?.addEventListener(`keydown`,e),n?.addEventListener(`beforeinput`,t,!0),n?.addEventListener(`input`,i),n?.addEventListener(`compositionend`,a),c=n});return()=>{c&&(c.removeEventListener(`keydown`,e),c.removeEventListener(`beforeinput`,t,!0),c.removeEventListener(`input`,i),c.removeEventListener(`compositionend`,a)),l()}},h=[p,n],t[10]=p,t[11]=n,t[12]=m,t[13]=h):(m=t[12],h=t[13]),(0,q.useEffect)(m,h),null}function uD(){let e=yv();if(!Q(e)||e.isCollapsed()||$E(e))return null;let t=QE(e);if(!t||t.start===t.end)return null;let n=yb().getTextContent();return bt(n,t.start,t.end)?null:{value:n,expandedStart:t.start,expandedEnd:t.end}}function dD(e){let t=(0,J.c)(78),{value:n,cursor:r,terminalContexts:i,skills:a,disabled:o,placeholder:s,collapsed:c,className:l,onRemoveTerminalContext:u,onChange:d,onCommandKeyDown:f,onPaste:p,editorRef:m}=e,[h]=wp(),g=(0,q.useRef)(d),_=gn(n,r),v;t[0]===i?v=t[1]:(v=IE(i),t[0]=i,t[1]=v);let y=v,b=(0,q.useRef)(y),x;t[2]===a?x=t[3]:(x=LE(a),t[2]=a,t[3]=x);let S=x,C=(0,q.useRef)(S),w;t[4]===a?w=t[5]:(w=DE(a),t[4]=a,t[5]=w);let T=(0,q.useRef)(w),E=mn(n,_),D;t[6]===i?D=t[7]:(D=i.map(pD),t[6]=i,t[7]=D);let O;t[8]!==_||t[9]!==E||t[10]!==D||t[11]!==n?(O={value:n,cursor:_,expandedCursor:E,terminalContextIds:D},t[8]=_,t[9]=E,t[10]=D,t[11]=n,t[12]=O):O=t[12];let k=(0,q.useRef)(O),A=(0,q.useRef)(!1),j;t[13]===u?j=t[14]:(j={onRemoveTerminalContext:u},t[13]=u,t[14]=j);let M=j,N,P;t[15]===d?(N=t[16],P=t[17]):(N=()=>{g.current=d},P=[d],t[15]=d,t[16]=N,t[17]=P),(0,q.useEffect)(N,P);let F,I;t[18]===a?(F=t[19],I=t[20]):(F=()=>{T.current=DE(a)},I=[a],t[18]=a,t[19]=F,t[20]=I),(0,q.useLayoutEffect)(F,I);let ee,L;t[21]!==o||t[22]!==h?(ee=()=>{h.setEditable(!o)},L=[o,h],t[21]=o,t[22]=h,t[23]=ee,t[24]=L):(ee=t[23],L=t[24]),(0,q.useEffect)(ee,L);let R,te;t[25]!==r||t[26]!==h||t[27]!==S||t[28]!==i||t[29]!==y||t[30]!==n?(R=()=>{let e=gn(n,r),t=k.current,a=b.current!==y,o=C.current!==S;if(t.value===n&&t.cursor===e&&!a&&!o)return;k.current={value:n,cursor:e,expandedCursor:mn(n,e),terminalContextIds:i.map(fD)},b.current=y,C.current=S;let s=h.getRootElement(),c=!!(s&&document.activeElement===s);t.value===n&&!a&&!o&&!c||(A.current=!0,h.update(()=>{let r=t.value!==n||a||o;r&&rD(n,i,T.current),(r||c)&&XE(e)}),queueMicrotask(()=>{A.current=!1}))},te=[r,h,S,i,y,n],t[25]=r,t[26]=h,t[27]=S,t[28]=i,t[29]=y,t[30]=n,t[31]=R,t[32]=te):(R=t[31],te=t[32]),(0,q.useLayoutEffect)(R,te);let z;t[33]===h?z=t[34]:(z=e=>{let t=h.getRootElement();if(!t)return;let n=gn(k.current.value,e);t.focus({preventScroll:!0}),h.update(()=>{XE(n)}),k.current={value:k.current.value,cursor:n,expandedCursor:mn(k.current.value,n),terminalContextIds:k.current.terminalContextIds},g.current(k.current.value,n,k.current.expandedCursor,!1,k.current.terminalContextIds)},t[33]=h,t[34]=z);let ne=z,B;t[35]===h?B=t[36]:(B=()=>{let e=k.current;return h.getEditorState().read(()=>{let t=yb().getTextContent(),n=gn(t,k.current.cursor);e={value:t,cursor:gn(t,eD(n)),expandedCursor:RE(t,tD(RE(t,k.current.expandedCursor))),terminalContextIds:iD(yb())}}),k.current=e,e},t[35]=h,t[36]=B);let re=B,V;t[37]===h?V=t[38]:(V=e=>{h.getRootElement()?.focus(),h.update(()=>{let t=yv();Q(t)||(XE(k.current.cursor),t=yv()),Q(t)&&t.insertText(e)},{tag:p_})},t[37]=h,t[38]=V);let H=V,ie,ae;t[39]!==ne||t[40]!==H||t[41]!==re?(ie=()=>({focus:()=>{ne(k.current.cursor)},focusAt:ne,focusAtEnd:()=>{ne(Ot(k.current.value,k.current.value.length))},insertTextAndFocus:H,readSnapshot:re}),ae=[ne,H,re],t[39]=ne,t[40]=H,t[41]=re,t[42]=ie,t[43]=ae):(ie=t[42],ae=t[43]),(0,q.useImperativeHandle)(m,ie,ae);let U;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>{e.read(()=>{let e=yb().getTextContent(),t=gn(e,k.current.cursor),n=gn(e,eD(t)),r=RE(e,tD(RE(e,k.current.expandedCursor))),i=iD(yb()),a=k.current;if(a.value===e&&a.cursor===n&&a.expandedCursor===r&&a.terminalContextIds.length===i.length&&a.terminalContextIds.every((e,t)=>e===i[t])||A.current)return;k.current={value:e,cursor:n,expandedCursor:r,terminalContextIds:i};let o=pt(e,n,`left`)||pt(e,n,`right`);g.current(e,n,r,o,i)})},t[44]=U):U=t[44];let oe=U,se=c?`max-h-6.5 min-h-6.5 overflow-hidden text-ellipsis whitespace-nowrap`:`max-h-[200px] min-h-17.5 overflow-y-auto`,ce;t[45]!==l||t[46]!==se?(ce=G(`block w-full whitespace-pre-wrap wrap-break-word bg-transparent text-[16px] leading-relaxed text-foreground focus:outline-none not-phone:text-[14px]`,se,l),t[45]=l,t[46]=se,t[47]=ce):ce=t[47];let le=c?s:void 0,ue;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Y.jsx)(`span`,{}),t[48]=ue):ue=t[48];let de;t[49]!==p||t[50]!==s||t[51]!==ce||t[52]!==le?(de=(0,Y.jsx)(zC,{className:ce,"data-testid":`composer-editor`,"aria-label":le,"aria-placeholder":s,placeholder:ue,onPaste:p}),t[49]=p,t[50]=s,t[51]=ce,t[52]=le,t[53]=de):de=t[53];let fe;t[54]!==c||t[55]!==s||t[56]!==i.length?(fe=i.length>0?null:(0,Y.jsx)(`div`,{className:G(`pointer-events-none absolute inset-0 text-[16px] leading-relaxed text-muted-foreground/35 not-phone:text-[14px]`,c&&`overflow-hidden text-ellipsis whitespace-nowrap`),children:s}),t[54]=c,t[55]=s,t[56]=i.length,t[57]=fe):fe=t[57];let pe;t[58]!==de||t[59]!==fe?(pe=(0,Y.jsx)(hE,{contentEditable:de,placeholder:fe,ErrorBoundary:UC}),t[58]=de,t[59]=fe,t[60]=pe):pe=t[60];let me;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Y.jsx)(cT,{onChange:oe}),t[61]=me):me=t[61];let he;t[62]===f?he=t[63]:(he=(0,Y.jsx)(aD,{...f?{onCommandKeyDown:f}:{}}),t[62]=f,t[63]=he);let ge;t[64]!==a||t[65]!==i?(ge=(0,Y.jsx)(lD,{terminalContexts:i,skills:a}),t[64]=a,t[65]=i,t[66]=ge):ge=t[66];let _e,ve,ye,be;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Y.jsx)(oD,{}),ve=(0,Y.jsx)(sD,{}),ye=(0,Y.jsx)(cD,{}),be=(0,Y.jsx)(oT,{}),t[67]=_e,t[68]=ve,t[69]=ye,t[70]=be):(_e=t[67],ve=t[68],ye=t[69],be=t[70]);let xe;t[71]!==pe||t[72]!==he||t[73]!==ge?(xe=(0,Y.jsxs)(`div`,{className:`relative`,children:[pe,me,he,ge,_e,ve,ye,be]}),t[71]=pe,t[72]=he,t[73]=ge,t[74]=xe):xe=t[74];let Se;return t[75]!==xe||t[76]!==M?(Se=(0,Y.jsx)(SE.Provider,{value:M,children:xe}),t[75]=xe,t[76]=M,t[77]=Se):Se=t[77],Se}function fD(e){return e.id}function pD(e){return e.id}var mD=(0,q.forwardRef)(function(e,t){let n=(0,J.c)(21),{value:r,cursor:i,terminalContexts:a,skills:o,disabled:s,placeholder:c,collapsed:l,className:u,onRemoveTerminalContext:d,onChange:f,onCommandKeyDown:p,onPaste:m}=e,h=(0,q.useRef)(r),g=(0,q.useRef)(a),_;n[0]===o?_=n[1]:(_=DE(o),n[0]=o,n[1]=_);let v=(0,q.useRef)(_),y;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(y={namespace:`rycotools-composer-editor`,editable:!0,nodes:[wE,kE,ME],editorState:()=>{rD(h.current,g.current,v.current)},onError:hD},n[2]=y):y=n[2];let b=y,x;n[3]===p?x=n[4]:(x=p?{onCommandKeyDown:p}:{},n[3]=p,n[4]=x);let S;n[5]===u?S=n[6]:(S=u?{className:u}:{},n[5]=u,n[6]=S);let C;return n[7]!==l||n[8]!==i||n[9]!==s||n[10]!==f||n[11]!==m||n[12]!==d||n[13]!==c||n[14]!==t||n[15]!==o||n[16]!==x||n[17]!==S||n[18]!==a||n[19]!==r?(C=(0,Y.jsx)(AC,{initialConfig:b,children:(0,Y.jsx)(dD,{value:r,cursor:i,terminalContexts:a,skills:o,disabled:s,placeholder:c,collapsed:l,onRemoveTerminalContext:d,onChange:f,onPaste:m,editorRef:t,...x,...S})},yE),n[7]=l,n[8]=i,n[9]=s,n[10]=f,n[11]=m,n[12]=d,n[13]=c,n[14]=t,n[15]=o,n[16]=x,n[17]=S,n[18]=a,n[19]=r,n[20]=C):C=n[20],C});function hD(e){throw e}function gD(e,t){let n=e.flatMap(e=>e.previewUrl?[{id:e.id,src:e.previewUrl,name:e.name}]:[]);if(n.length===0)return null;let r=n.findIndex(e=>e.id===t);return r<0?null:{images:n.map(e=>({src:e.src,name:e.name})),index:r}}function _D(e){let t=e.indexOf(`#`);return t<0||e.slice(0,t).includes(`/`)?e:e.slice(t)}function vD(e){let t=(0,J.c)(36),{context:n,onRemove:r}=e,i;t[0]===n.reference?i=t[1]:(i=_D(n.reference),t[0]=n.reference,t[1]=i);let a=i,o=n.detail.title,s=n.detail.truncated,c;t[2]!==n.detail||t[3]!==n.kind?(c=n.kind===`change-request`&&`baseRefName`in n.detail?gi(n.detail):null,t[2]=n.detail,t[3]=n.kind,t[4]=c):c=t[4];let l=c,u=n.kind===`change-request`?Xi:yr,d=`body`in n.detail&&typeof n.detail.body==`string`?n.detail.body:null,f=n.id,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=G($i,`size-3.5`),t[5]=p):p=t[5];let m;t[6]===u?m=t[7]:(m=(0,Y.jsx)(u,{className:p,"aria-hidden":`true`}),t[6]=u,t[7]=m);let h;t[8]===a?h=t[9]:(h=(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:a}),t[8]=a,t[9]=h);let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=G(Ta,`max-w-32`),t[10]=g):g=t[10];let _;t[11]===o?_=t[12]:(_=(0,Y.jsx)(`span`,{className:g,children:o}),t[11]=o,t[12]=_);let v;t[13]===s?v=t[14]:(v=s?(0,Y.jsx)(`span`,{"aria-label":`Context truncated`,className:`ml-0.5 shrink-0 rounded-sm bg-warning/20 px-0.5 text-[9px] font-semibold uppercase leading-tight text-warning-foreground`,children:`truncated`}):null,t[13]=s,t[14]=v);let y;t[15]===l?y=t[16]:(y=l?(0,Y.jsx)(oi,{view:l,mode:`compact`}):null,t[15]=l,t[16]=y);let b;t[17]!==n.id||t[18]!==r?(b=()=>r(n.id),t[17]=n.id,t[18]=r,t[19]=b):b=t[19];let x;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Y.jsx)($a,{className:`size-3`,"aria-hidden":`true`}),t[20]=x):x=t[20];let S;t[21]===b?S=t[22]:(S=(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Remove context`,className:ia,onClick:b,children:x}),t[21]=b,t[22]=S);let C;t[23]!==n.id||t[24]!==S||t[25]!==m||t[26]!==h||t[27]!==_||t[28]!==v||t[29]!==y?(C=(0,Y.jsx)(Fo,{render:(0,Y.jsxs)(`span`,{className:Ea,"data-context-id":f,children:[m,h,_,v,y,S]})}),t[23]=n.id,t[24]=S,t[25]=m,t[26]=h,t[27]=_,t[28]=v,t[29]=y,t[30]=C):C=t[30];let w;t[31]===d?w=t[32]:(w=d?(0,Y.jsx)(Io,{side:`top`,className:`max-w-80 whitespace-pre-wrap leading-tight`,children:d}):null,t[31]=d,t[32]=w);let T;return t[33]!==C||t[34]!==w?(T=(0,Y.jsxs)(Lo,{children:[C,w]}),t[33]=C,t[34]=w,t[35]=T):T=t[35],T}var yD=(0,q.memo)(function(e){let t=(0,J.c)(76),{editorRef:n,isComposerCollapsedMobile:r,hasComposerHeader:i,isComposerApprovalState:a,resolvedTheme:o,composerMenuOpen:s,composerMenuItems:c,isComposerMenuLoading:l,composerTriggerKind:u,composerTrigger:d,composerMenuEmptyState:f,activeComposerMenuItemId:p,onComposerMenuItemHighlighted:m,onSelectComposerItem:h,composerSourceControlContexts:g,onRemoveSourceControlContext:_,composerImages:v,nonPersistedComposerImageIdSet:y,onExpandImage:b,onRemoveImage:x,pendingUserInputCount:S,prompt:C,composerCursor:w,composerTerminalContexts:T,skills:E,showMobilePendingAnswerActions:D,onRemoveTerminalContext:O,onPromptChange:k,onComposerCommandKey:A,onComposerPaste:j,activePendingProgress:M,showPlanFollowUpPrompt:N,activeProposedPlan:P,environmentUnavailable:F,phase:I,isConnecting:ee,isEditorDisabled:L,showCollapsedSendAction:R,collapsedSendActionLabel:te,collapsedSendActionDisabled:z,onCollapsedSend:ne,isSendBusy:B,pendingPrimaryAction:re,onPreviousPendingQuestion:V,onInterrupt:H,onImplementPlanInNewThread:ie}=e,ae=i?`pt-2.5 sm:pt-3`:`pt-3.5 sm:pt-4`,U;t[0]===ae?U=t[1]:(U=G(`relative px-3 pb-2 sm:px-4`,ae),t[0]=ae,t[1]=U);let oe=s&&!a,se;t[2]===d?se=t[3]:(se=d?.kind===`slash-command`&&d.query.trim().length===0,t[2]=d,t[3]=se);let ce;t[4]!==p||t[5]!==f||t[6]!==c||t[7]!==u||t[8]!==l||t[9]!==m||t[10]!==h||t[11]!==o||t[12]!==oe||t[13]!==se?(ce=(0,Y.jsx)(Bf,{open:oe,items:c,resolvedTheme:o,isLoading:l,triggerKind:u,groupSlashCommandSections:se,emptyStateText:f,activeItemId:p,onHighlightedItemChange:m,onSelect:h}),t[4]=p,t[5]=f,t[6]=c,t[7]=u,t[8]=l,t[9]=m,t[10]=h,t[11]=o,t[12]=oe,t[13]=se,t[14]=ce):ce=t[14];let le;t[15]!==g||t[16]!==a||t[17]!==r||t[18]!==_||t[19]!==S?(le=!r&&!a&&S===0&&g.length>0&&(0,Y.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:g.map(e=>(0,Y.jsx)(vD,{context:e,onRemove:_},e.id))}),t[15]=g,t[16]=a,t[17]=r,t[18]=_,t[19]=S,t[20]=le):le=t[20];let ue;t[21]!==v||t[22]!==a||t[23]!==r||t[24]!==y||t[25]!==b||t[26]!==x||t[27]!==S?(ue=!r&&!a&&S===0&&v.length>0&&(0,Y.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:v.map(e=>(0,Y.jsxs)(`div`,{className:`relative h-16 w-16 overflow-hidden rounded-lg border border-border/80 bg-background`,children:[e.previewUrl?(0,Y.jsx)(`button`,{type:`button`,className:`h-full w-full cursor-zoom-in`,"aria-label":`Preview ${e.name}`,onClick:()=>{let t=gD(v,e.id);t&&b(t)},children:(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`h-full w-full object-cover`})}):(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center px-1 text-center text-[10px] text-muted-foreground/70`,children:e.name}),y.has(e.id)&&(0,Y.jsxs)(Lo,{children:[(0,Y.jsx)(Fo,{render:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Draft attachment may not persist`,className:`absolute left-1 top-1 inline-flex items-center justify-center rounded bg-background/85 p-0.5 text-amber-600`,children:(0,Y.jsx)(Oi,{className:`size-3`})})}),(0,Y.jsx)(Io,{side:`top`,className:`max-w-64 whitespace-normal leading-tight`,children:`Draft attachment could not be saved locally and may be lost on navigation.`})]}),(0,Y.jsx)(K,{variant:`ghost`,size:`icon-xs`,className:`absolute right-1 top-1 bg-background/80 hover:bg-background/90`,onClick:()=>x(e.id),"aria-label":`Remove ${e.name}`,children:(0,Y.jsx)($a,{})})]},e.id))}),t[21]=v,t[22]=a,t[23]=r,t[24]=y,t[25]=b,t[26]=x,t[27]=S,t[28]=ue):ue=t[28];let de=R&&`flex items-center gap-2`,fe;t[29]===de?fe=t[30]:(fe=G(`relative`,de),t[29]=de,t[30]=fe);let pe=a?``:M?M.customAnswer:C,me;t[31]!==T||t[32]!==a||t[33]!==S?(me=!a&&S===0?T:[],t[31]=T,t[32]=a,t[33]=S,t[34]=me):me=t[34];let he;t[35]===D?he=t[36]:(he=D?{className:`phone:pb-11`}:{},t[35]=D,t[36]=he);let ge=a?`Resolve this approval request to continue`:M?r?`Write custom answer`:`Type your own answer, or leave this blank to use the selected option`:N&&P?r?`Add plan feedback`:`Add feedback to refine the plan, or leave this blank to implement it`:F?`${F.label} is ${F.connectionState===`connecting`?`connecting`:`disconnected`}`:I===`disconnected`?`Ask for follow-up changes or attach images`:r?`Ask anything...`:`Ask anything, @tag files/folders, or use / to show available commands`,_e;t[37]!==w||t[38]!==n||t[39]!==r||t[40]!==L||t[41]!==A||t[42]!==j||t[43]!==k||t[44]!==O||t[45]!==E||t[46]!==me||t[47]!==he||t[48]!==ge||t[49]!==pe?(_e=(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(mD,{ref:n,collapsed:r,value:pe,cursor:w,terminalContexts:me,skills:E,...he,onRemoveTerminalContext:O,onChange:k,onCommandKeyDown:A,onPaste:j,placeholder:ge,disabled:L})}),t[37]=w,t[38]=n,t[39]=r,t[40]=L,t[41]=A,t[42]=j,t[43]=k,t[44]=O,t[45]=E,t[46]=me,t[47]=he,t[48]=ge,t[49]=pe,t[50]=_e):_e=t[50];let ve;t[51]!==z||t[52]!==te||t[53]!==ne||t[54]!==R?(ve=R?(0,Y.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/90 text-primary-foreground disabled:opacity-30`,disabled:z,"aria-label":te,onPointerDown:bD,onClick:e=>{e.stopPropagation(),ne()},children:(0,Y.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:(0,Y.jsx)(`path`,{d:`M8 3L8 13M8 3L4 7M8 3L12 7`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}):null,t[51]=z,t[52]=te,t[53]=ne,t[54]=R,t[55]=ve):ve=t[55];let ye;t[56]!==F||t[57]!==ee||t[58]!==B||t[59]!==ie||t[60]!==H||t[61]!==V||t[62]!==re||t[63]!==D?(ye=D?(0,Y.jsx)(`div`,{"data-chat-composer-mobile-pending-actions":`true`,className:`absolute bottom-0 right-0 flex justify-end`,children:(0,Y.jsx)(zd,{compact:!0,pendingAction:re,isRunning:!1,showPlanFollowUpPrompt:!1,promptHasText:!1,isSendBusy:B,isConnecting:ee,isEnvironmentUnavailable:F!==null,isPreparingWorktree:!1,hasSendableContent:!1,preserveComposerFocusOnPointerDown:!0,onPreviousPendingQuestion:V,onInterrupt:H,onImplementPlanInNewThread:ie})}):null,t[56]=F,t[57]=ee,t[58]=B,t[59]=ie,t[60]=H,t[61]=V,t[62]=re,t[63]=D,t[64]=ye):ye=t[64];let be;t[65]!==_e||t[66]!==ve||t[67]!==ye||t[68]!==fe?(be=(0,Y.jsxs)(`div`,{className:fe,children:[_e,ve,ye]}),t[65]=_e,t[66]=ve,t[67]=ye,t[68]=fe,t[69]=be):be=t[69];let xe;return t[70]!==U||t[71]!==be||t[72]!==ce||t[73]!==le||t[74]!==ue?(xe=(0,Y.jsxs)(`div`,{className:U,children:[ce,le,ue,be]}),t[70]=U,t[71]=be,t[72]=ce,t[73]=le,t[74]=ue,t[75]=xe):xe=t[75],xe});function bD(e){return e.preventDefault()}function xD(e){let t=(0,J.c)(11),{label:n,items:r,className:i}=e;if(r.length===0)return null;let a;t[0]===i?a=t[1]:(a=G(`relative min-w-0`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=r.map(SD),t[2]=r,t[3]=o);let s;t[4]!==n||t[5]!==o?(s=(0,Y.jsx)(`div`,{role:`group`,"aria-label":n,className:`flex min-w-0 items-center gap-1.5 overflow-x-auto overscroll-x-contain pe-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,"data-slot":`mobile-context-strip-rail`,children:o}),t[4]=n,t[5]=o,t[6]=s):s=t[6];let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 end-0 w-4 bg-gradient-to-l from-background/80 to-transparent`,"data-slot":`mobile-context-strip-edge`}),t[7]=c):c=t[7];let l;return t[8]!==a||t[9]!==s?(l=(0,Y.jsxs)(`div`,{className:a,"data-slot":`mobile-context-strip`,children:[s,c]}),t[8]=a,t[9]=s,t[10]=l):l=t[10],l}function SD(e){return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":e.selected,disabled:e.disabled??!1,className:G(Hc(`chip`),`flex min-h-[var(--app-dock-control-size)] min-w-[var(--app-dock-control-size)] shrink-0 items-center gap-1.5 rounded-full border border-border/60 px-3 text-xs`,`transition-colors duration-[var(--app-motion-duration-chip)] ease-[var(--app-motion-ease)] motion-reduce:transition-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,`disabled:pointer-events-none disabled:text-muted-foreground/60`,e.selected===!0&&`ring-1 ring-ring/50`),"data-slot":`mobile-context-strip-pill`,onClick:e.onSelect,children:[e.icon,(0,Y.jsx)(`span`,{className:`max-w-40 truncate font-medium`,children:e.label}),e.value===void 0?null:(0,Y.jsx)(`span`,{className:`max-w-40 truncate text-muted-foreground`,children:e.value})]},e.id)}var CD=new Map;function wD(e){let[t,n]=(0,q.useState)(!1),[r,a]=(0,q.useState)(!1),o=f(i(e.environmentId,e.threadId)),s=oe(eo(le)),c=(0,q.useMemo)(()=>s.find(t=>t.id===e.threadId&&t.environmentId===e.environmentId)??null,[e.environmentId,e.threadId,s]),l=(0,q.useMemo)(()=>e.draft?{id:e.threadId,environmentId:e.environmentId,projectId:e.draft.projectId,title:e.title,interactionMode:rn,session:null,createdAt:e.draft.createdAt,archivedAt:null,settledOverride:null,settledAt:null,latestTurn:null,branch:null,worktreePath:null,latestUserMessageAt:null,hasPendingApprovals:!1,hasPendingUserInput:!1,hasActionableProposedPlan:!1,draftId:e.draft.draftId}:null,[e.draft,e.environmentId,e.threadId,e.title]),u=c??l,d=(0,q.useRef)(new Map);d.current=(0,q.useMemo)(()=>new Map(u?[[o,u]]:[]),[u,o]);let p=Qc({sidebarThreadByKeyRef:d,memberProjectByScopedKey:CD,projectCwd:e.projectCwd}),m=u?p.listThreadMenuActions(o):[],h=e.sessionTabs.length>0&&e.onSelectSessionTab!==null,g=[{id:`find`,label:`Find in thread`,icon:(0,Y.jsx)(La,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),onSelect:e.onOpenFindInThread},...e.onOpenSourceControl?[{id:`source-control`,label:`Source control`,...e.branch===null?{}:{value:e.branch},icon:(0,Y.jsx)(Xi,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),onSelect:e.onOpenSourceControl}]:[],...h?[{id:`sessions`,label:`Sessions`,value:String(e.sessionTabs.length),icon:(0,Y.jsx)(Ki,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),onSelect:()=>a(!0)}]:[]];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex min-w-0 items-center gap-1.5`,"data-slot":`phone-thread-dock`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Toggle workspace panel`,"aria-pressed":e.workspacePanelOpen,className:`flex min-h-[var(--app-dock-control-size)] min-w-[var(--app-dock-control-size)] shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring aria-pressed:bg-accent aria-pressed:text-foreground`,onClick:e.onToggleWorkspacePanel,children:(0,Y.jsx)(kl,{"aria-hidden":!0,className:`size-4`})}),(0,Y.jsx)(xD,{label:`Thread context`,items:g,className:`w-0 grow`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Thread actions`,className:`flex min-h-[var(--app-dock-control-size)] min-w-[var(--app-dock-control-size)] shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(!0),children:(0,Y.jsx)(Vi,{"aria-hidden":!0,className:`size-4`})})]}),(0,Y.jsx)(Xc,{open:t,onOpenChange:n,title:e.title,items:m,onAction:t=>{p.performThreadMenuAction(i(e.environmentId,e.threadId),t)},leadingSections:c?(0,Y.jsx)(gr,{thread:c}):void 0}),(0,Y.jsxs)(Vc,{open:r,onOpenChange:a,label:`Sessions in this worktree`,detent:`medium`,children:[(0,Y.jsx)(Ic,{children:(0,Y.jsx)(Rc,{children:`Sessions`})}),(0,Y.jsx)(Pc,{children:(0,Y.jsx)(`div`,{role:`group`,"aria-label":`Sessions in this worktree`,className:`space-y-0.5`,children:e.sessionTabs.map(t=>(0,Y.jsx)(Bc,{label:t.title,selected:t.key===e.activeSessionTabKey,trailing:t.key===e.activeSessionTabKey?(0,Y.jsx)(Yr,{"aria-hidden":!0,className:`size-4 shrink-0`}):void 0,onClick:()=>{a(!1),e.onSelectSessionTab?.(t.key)}},t.key))})})]}),(0,Y.jsx)(Zc,{renamingThreadKey:p.renamingThreadKey,originalTitle:c?.title??e.title,renamingTitle:p.renamingTitle,setRenamingTitle:p.setRenamingTitle,commitRename:p.commitRename,cancelRename:p.cancelRename})]})}function TD(e){return e===`copilot`||e===`opencode`}var ED=`${Math.round(F/1048576)}MB`,DD=`${Math.round(_/1048576)}MB`,OD=`${Math.round(T/1048576)}MB`,kD=` `;async function AD(e){let t=new Uint8Array(await e.arrayBuffer()),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}function jD(e){let{composerDraftTarget:t,environmentId:n,activeThreadId:r,draftId:i,routeThreadRef:a,runtimeMode:o,selectedProvider:s,gitCwd:c,pendingUserInputCount:l,composerImagesRef:u,editorRef:d,setThreadError:f,focusComposer:p}=e,m=Jt(e=>e.addImage),h=Jt(e=>e.addImages),g=Jt(e=>e.removeImage),[v,y]=(0,q.useState)(!1),b=(0,q.useRef)(0);(0,q.useEffect)(()=>{b.current=0,y(!1)},[i,r]);let x=(0,q.useCallback)(e=>{m(t,e)},[t,m]),S=(0,q.useCallback)(e=>{h(t,e)},[t,h]),C=(0,q.useCallback)(e=>{g(t,e)},[t,g]),w=(0,q.useCallback)(e=>{if(!r||e.length===0)return;if(l>0){Ai.add({type:`error`,title:`Attach files after answering plan questions.`});return}let t=[],n=u.current.length,i=u.current.reduce((e,t)=>e+t.sizeBytes,0),a=null;for(let r of e){let e=r.type.startsWith(`image/`),o=r.name||(e?`image`:`file`);if(!/^[^/\\\p{Cc}]+$/u.test(o)){a=`'${o}' has an unsafe filename. Rename it without path separators or control characters.`;continue}let s=e?F:_,c=e?ED:DD;if(r.size<=0||r.size>s){a=`'${o}' must be non-empty and no larger than the ${c} attachment limit.`;continue}if(n>=8){a=`You can attach up to 8 files per message.`;break}if(i+r.size>52428800){a=`Attachments can total at most ${DD} per message.`;continue}let l=e?URL.createObjectURL(r):``;t.push({type:e?`image`:`file`,id:io(),name:o,mimeType:r.type||`application/octet-stream`,sizeBytes:r.size,previewUrl:l,file:r}),n+=1,i+=r.size}t.length===1&&t[0]?x(t[0]):t.length>1&&S(t),f(r,a)},[r,x,S,u,l,f]),T=(0,q.useCallback)(e=>{if(e.length===0)return;let t=d.current;if(!t)return;let n=t.readSnapshot(),r=e.join(kD),i=n.value[n.cursor-1]??``,a=n.value[n.cursor]??``,o=i.length>0&&!/\s/.test(i),s=a.length>0&&!/\s/.test(a);t.insertTextAndFocus(`${o?kD:``}${r}${s?kD:``}`)},[d]),E=(0,q.useCallback)(()=>{let e=rt();return window.desktopBridge!==void 0&&e?.source===`desktop-managed`&&e.environmentId===n},[n]),D=(0,q.useCallback)(async e=>{if(!c)return Ai.add({type:`error`,title:`Couldn't stage '${e.name||`file`}'.`,description:`No active workspace is available for this composer.`}),null;if(e.size>10485760)return Ai.add({type:`error`,title:`'${e.name||`file`}' exceeds the ${OD} file staging limit.`}),null;let t=Be(n);if(!t)return Ai.add({type:`error`,title:`Couldn't stage '${e.name||`file`}'.`,description:`The active environment is not connected.`}),null;try{return(await t.projects.stageFileReference({cwd:c,scopeId:String(r??i??a.threadId),name:e.name||`file`,...e.type?{mimeType:e.type}:{},sizeBytes:e.size,dataBase64:await AD(e)})).relativePath}catch(t){return Ai.add({type:`error`,title:`Couldn't stage '${e.name||`file`}'.`,description:t instanceof Error?t.message:`File staging failed.`}),null}},[r,i,n,c,a.threadId]),O=(0,q.useCallback)(async e=>{let t=null;try{t=await he()?.shell.getPathForFile?.(e)??null}catch{t=null}return ot({resolvedPath:t,cwd:c,runtimeMode:o,isLocalDesktopEnvironment:E()})?t:D(e)},[c,E,o,D]),k=(0,q.useCallback)(async e=>{if(e.length===0)return;let t=TD(s),n=t?e:e.filter(e=>e.type.startsWith(`image/`)),r=t?[]:e.filter(e=>!e.type.startsWith(`image/`));if(n.length>0&&w(n),r.length===0)return;let i=(await Promise.all(r.map(async e=>{let t=await O(e);return t?At(t):null}))).filter(e=>e!==null);T(i)},[w,T,O,s]);return{isDragOverComposer:v,addComposerAttachments:k,removeComposerImage:(0,q.useCallback)(e=>{C(e)},[C]),onComposerPaste:(0,q.useCallback)(e=>{let t=Array.from(e.clipboardData.files);t.length!==0&&(e.preventDefault(),k(t))},[k]),onComposerDragEnter:(0,q.useCallback)(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),b.current+=1,y(!0))},[]),onComposerDragOver:(0,q.useCallback)(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,y(!0))},[]),onComposerDragLeave:(0,q.useCallback)(e=>{if(!e.dataTransfer.types.includes(`Files`))return;e.preventDefault();let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||(b.current=Math.max(0,b.current-1),b.current===0&&y(!1))},[]),onComposerDrop:(0,q.useCallback)(e=>{if(!e.dataTransfer.types.includes(`Files`))return;e.preventDefault(),b.current=0,y(!1);let t=Array.from(e.dataTransfer.files),n=!TD(s)&&t.some(e=>!e.type.startsWith(`image/`));k(t),n||p()},[k,p,s])}}function MD(){let e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}function ND(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function PD(e){let t=e.memoryStorage??MD(),n=e.hosted??!1,r,i=()=>{if(n)return null;if(r!==void 0)return r;try{r=(e.getDurableStorage??ND)()}catch{r=null}return r||(n=!0),r},a=()=>{try{return t.getItem(Ut)}catch{return null}};return{read:()=>{let e=i();if(e)try{return e.getItem(Ut)}catch{n=!0}return a()},write:e=>{let r=JSON.stringify({entries:e}),a=i();if(a)try{return a.setItem(Ut,r),{written:!0,durable:!0}}catch{n=!0}try{return t.setItem(Ut,r),{written:!0,durable:!1}}catch{return{written:!1,durable:!1}}},remove:()=>{let e=i();if(e)try{return e.removeItem(Ut),{durable:!0}}catch{n=!0}try{t.removeItem(Ut)}catch{}return{durable:!1}}}}function FD(e={}){let t=PD(e),n=c()((e,n)=>({entries:[],hydrate:()=>{let n=t.read();if(typeof n!=`string`||n.length===0){e({entries:[]});return}try{let t=JSON.parse(n);e({entries:nn(t).entries})}catch{t.remove(),e({entries:[]})}},getEntries:()=>n().entries,getCount:()=>n().entries.length,stashEntry:r=>{if(!y(on)(r))return{evicted:null,written:!1,durable:!1};let i=n().entries,a=Gt([r,...i]),o=a.kept.slice(1),s=a.evicted[0]??null,c=Kt(r.attachments,Pt(o)),l=[{...r,attachments:c.kept,droppedImageNames:[...r.droppedImageNames,...c.droppedNames]},...o],u=t.write(l);return u.written?(e({entries:l}),{evicted:s,...u}):{evicted:null,...u}},takeEntry:r=>{let i=n().entries,a=i.find(e=>e.id===r)??null;if(!a)return{entry:null,durable:!0};let o=i.filter(e=>e.id!==r),s=t.write(o);return e({entries:o}),{entry:a,durable:s.durable}},finalizeEntryImages:(r,i)=>{let a=n().entries,o=a.findIndex(e=>e.id===r),s=o<0?void 0:a[o];if(!s)return{attached:!1,written:!0,durable:!0};let c=Kt(i.attachments,Pt(a,r)),l=[...a];l[o]={...s,attachments:c.kept,droppedImageNames:[...i.droppedImageNames,...c.droppedNames],unreadableImageNames:[...i.unreadableImageNames],pendingImageCount:0};let u=t.write(l);return u.written?(e({entries:l}),{attached:!0,...u}):{attached:!1,...u}}}));return n.getState().hydrate(),n}var ID=FD({hosted:l()}),LD=-64;function RD({hostRef:e}){let t=(0,q.useId)().replace(/[^a-zA-Z0-9_-]/g,``),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{$c()&&(r(!0),a(nl()))},[]),(0,q.useEffect)(()=>{let r=e.current;if(!r||!n||!i)return;let a=il(t);a.setScale(LD),el().appendChild(a.filter);let o=0,c=0,l=null,u=!1,d=()=>{o=0;let e=r.offsetWidth,t=r.offsetHeight;if(e<24||t<24)return;let n=++c;rl({width:e,height:t,radius:22,edgeBandPx:36}).then(r=>{if(!r)return;if(u||n!==c){r.release();return}let i=Cr();a.setMap(r.url,e,t),l?.release(),l=r,s(!0),Sr(`web.liquid-glass.apply`,{durationMs:Math.max(0,Cr()-i)})})},f=new ResizeObserver(()=>{o||=window.requestAnimationFrame(d)});return f.observe(r),d(),()=>{u=!0,c+=1,f.disconnect(),o&&window.cancelAnimationFrame(o),l?.release(),a.filter.remove(),s(!1)}},[n,i,t,e]),(0,q.useEffect)(()=>{let r=e.current;if(!r||!n)return;r.setAttribute(`data-liquid-glass`,`true`);let a=i&&o?`url(#${t}) blur(10px) saturate(185%)`:`blur(24px) saturate(185%)`;return r.style.setProperty(`--composer-liquid-backdrop`,a),()=>{r.removeAttribute(`data-liquid-glass`),r.style.removeProperty(`--composer-liquid-backdrop`)}},[n,i,o,t,e]),(0,q.useEffect)(()=>{let t=e.current;if(!(!t||!n))return tl(t)},[n,e]),n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`liquid-glass-sheen`}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`liquid-glass-ring`}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`liquid-glass-ring liquid-glass-ring--overlay`})]}):null}var zD=(0,q.memo)(function(e){let t=(0,J.c)(11);if(e.count===0)return null;let n=`Stashed prompts: ${e.count}. Open stash.`,r=e.open,i=e.open?`border-border text-foreground opacity-100`:`border-border/70 text-muted-foreground opacity-75 hover:text-foreground hover:opacity-100`,a;t[0]===i?a=t[1]:(a=G(`absolute -top-3 right-4 z-20 inline-flex cursor-pointer items-center gap-1.5 rounded-full border bg-popover px-2.5 py-0.5 text-xs shadow-sm`,`transition-[color,border-color,opacity] duration-200 motion-reduce:transition-none`,i),t[0]=i,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Y.jsx)(pl,{className:`size-3`,"aria-hidden":`true`}),t[2]=o):o=t[2];let s;t[3]===e.count?s=t[4]:(s=(0,Y.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] font-medium tabular-nums text-muted-foreground`,children:e.count}),t[3]=e.count,t[4]=s);let c;return t[5]!==e.onToggle||t[6]!==e.open||t[7]!==n||t[8]!==a||t[9]!==s?(c=(0,Y.jsxs)(`button`,{type:`button`,"data-prompt-stash-badge":`true`,"aria-label":n,"aria-expanded":r,className:a,onPointerDown:BD,onClick:e.onToggle,children:[o,`Stash`,s]}),t[5]=e.onToggle,t[6]=e.open,t[7]=n,t[8]=a,t[9]=s,t[10]=c):c=t[10],c});function BD(e){return e.preventDefault()}var VD=100;function HD(e){let t=e.prompt.trim().replace(/\s+/g,` `);if(t.length>0)return t.length>VD?`${t.slice(0,VD)}…`:t;let n=e.attachments.length+e.pendingImageCount+e.droppedImageNames.length+e.unreadableImageNames.length;return n===1?`(1 image)`:`(${n} images)`}function UD(e){return e.droppedImageNames.length+e.unreadableImageNames.length}function WD(e){return e instanceof Element&&e.closest(`button, a, input, select, textarea, [contenteditable], [role=button]`)!==null}var GD=(0,q.memo)(function(e){let t=(0,J.c)(28),{entries:n,onRestore:r,onDelete:i,onClose:a}=e,[o,s]=(0,q.useState)(n[0]?.id??null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u;t[0]!==n||t[1]!==o?(u=n.find(e=>e.id===o)??n[0]??null,t[0]=n,t[1]=o,t[2]=u):u=t[2];let d=u,f,p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{c.current?.focus()},p=[],t[3]=f,t[4]=p):(f=t[3],p=t[4]),(0,q.useEffect)(f,p);let m,h;t[5]!==d||t[6]!==o?(m=()=>{if(!d){s(null);return}d.id!==o&&s(d.id)},h=[d,o],t[5]=d,t[6]=o,t[7]=m,t[8]=h):(m=t[7],h=t[8]),(0,q.useEffect)(m,h);let g,_;t[9]===o?(g=t[10],_=t[11]):(g=()=>{!o||!l.current||l.current.querySelector(`[data-prompt-stash-row="${CSS.escape(o)}"]`)?.scrollIntoView({block:`nearest`})},_=[o],t[9]=o,t[10]=g,t[11]=_),(0,q.useEffect)(g,_);let v,y;t[12]!==n||t[13]!==a||t[14]!==i||t[15]!==r||t[16]!==d||t[17]!==o?(v=()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),a();return}if(c.current?.contains(document.activeElement)){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(n.length===0)return;e.preventDefault(),e.stopPropagation();let t=n.findIndex(e=>e.id===o),r=e.key===`ArrowDown`?1:-1,i=((t>=0?t:r>0?-1:0)+r+n.length)%n.length;s(n[i]?.id??null);return}if(e.key===`Enter`){if(WD(e.target)||!d)return;e.preventDefault(),e.stopPropagation(),r(d.id);return}e.key===`Backspace`&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&d&&(e.preventDefault(),e.stopPropagation(),i(d.id))}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},y=[n,a,i,r,d,o],t[12]=n,t[13]=a,t[14]=i,t[15]=r,t[16]=d,t[17]=o,t[18]=v,t[19]=y):(v=t[18],y=t[19]),(0,q.useEffect)(v,y);let b;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Y.jsxs)(Ko,{className:`flex items-center gap-1.5 px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground/55`,children:[(0,Y.jsx)(pl,{className:`size-3`,"aria-hidden":`true`}),`Stashed prompts`]}),t[20]=b):b=t[20];let x;t[21]!==n||t[22]!==i||t[23]!==r||t[24]!==o?(x=n.length===0?(0,Y.jsx)(`p`,{className:`px-3 pt-1 pb-3 text-xs text-muted-foreground/70`,children:`Nothing stashed yet. Use the stash shortcut with a prompt or image to save it.`}):n.map(e=>{let t=UD(e);return(0,Y.jsxs)(Zo,{value:e.id,"data-prompt-stash-row":e.id,className:G(`group/stash cursor-pointer select-none gap-2 hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit`,o===e.id&&`bg-accent! text-accent-foreground!`),onMouseMove:()=>s(e.id),onMouseDown:KD,onClick:t=>{WD(t.target)||r(e.id)},children:[e.attachments.length>0?(0,Y.jsx)(`span`,{className:`-space-x-1.5 flex shrink-0 items-center`,children:e.attachments.slice(0,3).map(qD)}):(0,Y.jsx)(pl,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:HD(e)}),e.pendingImageCount>0?(0,Y.jsxs)(`span`,{"data-prompt-stash-pending":`true`,className:`shrink-0 text-[10px] text-muted-foreground/65`,children:[`saving `,e.pendingImageCount,` image`,e.pendingImageCount===1?``:`s`,`…`]}):t>0?(0,Y.jsxs)(`span`,{className:`shrink-0 text-[10px] text-amber-600`,children:[t,` image`,t===1?``:`s`,` not saved`]}):e.attachments.length>0?(0,Y.jsxs)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/65`,children:[e.attachments.length,` image`,e.attachments.length===1?``:`s`]}):null,(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground/60`,children:xo(e.createdAt)}),(0,Y.jsx)(K,{variant:`ghost`,size:`icon-xs`,"data-prompt-stash-delete":e.id,className:`shrink-0 opacity-55 transition-opacity motion-reduce:transition-none group-hover/stash:opacity-100 focus:opacity-100`,"aria-label":`Delete stashed prompt: ${HD(e)}`,onClick:t=>{t.stopPropagation(),i(e.id)},children:(0,Y.jsx)(Ya,{})})]},e.id)}),t[21]=n,t[22]=i,t[23]=r,t[24]=o,t[25]=x):x=t[25];let S;return t[26]===x?S=t[27]:(S=(0,Y.jsx)(`div`,{ref:c,role:`region`,"aria-label":`Stashed prompts`,tabIndex:-1,"data-prompt-stash-picker":`true`,className:`absolute right-0 bottom-[calc(100%+0.75rem)] z-30 w-[min(28rem,calc(100vw-2rem))]`,children:(0,Y.jsx)(Xo,{autoHighlight:!1,mode:`none`,children:(0,Y.jsx)(`div`,{className:`app-surface relative overflow-hidden rounded-xl border border-border/80 bg-popover/96 shadow-lg/8 backdrop-blur-xs`,children:(0,Y.jsx)(qo,{ref:l,className:`max-h-72`,children:(0,Y.jsxs)(Yo,{children:[b,x]})})})})}),t[26]=x,t[27]=S),S});function KD(e){WD(e.target)||e.preventDefault()}function qD(e){return(0,Y.jsx)(`img`,{src:e.dataUrl,alt:``,"aria-hidden":`true`,className:`size-6 rounded border border-border/70 object-cover`},e.id)}var JD={codex:`Codex`,claudeAgent:`Claude`,copilot:`GitHub Copilot`,opencode:`OpenCode`,cursor:`Cursor`,grok:`Grok`};function YD(e){return e.providerDisplayName??JD[e.driverKind]??e.providerInstanceId}function XD(e){return e.modelDisplayName??e.modelSlug}function ZD(e){return`${YD(e)} ${XD(e)}`}var QD=(0,q.memo)(function(e){let t=(0,J.c)(26),n=e.endpoint.providerDisplayName,r=JD[e.endpoint.driverKind],i;t[0]===e.endpoint?i=t[1]:(i=YD(e.endpoint),t[0]=e.endpoint,t[1]=i);let a=i,o;t[2]===e.endpoint?o=t[3]:(o=ZD(e.endpoint),t[2]=e.endpoint,t[3]=o);let s=o,c;t[4]===e.className?c=t[5]:(c=G(`inline-flex min-w-0 items-center gap-1`,e.className),t[4]=e.className,t[5]=c);let l=e.endpoint.driverKind,u=e.endpoint.providerAccentColor,d=n!==void 0&&n!==r,f;t[6]===e.iconClassName?f=t[7]:(f=G(`size-3.5`,e.iconClassName),t[6]=e.iconClassName,t[7]=f);let p;t[8]!==a||t[9]!==e.endpoint.driverKind||t[10]!==e.endpoint.providerAccentColor||t[11]!==d||t[12]!==f?(p=(0,Y.jsx)(Ua,{driverKind:l,displayName:a,accentColor:u,showBadge:d,className:`size-4`,iconClassName:f,badgeClassName:`h-2.5 min-w-2.5 text-[6px]`}),t[8]=a,t[9]=e.endpoint.driverKind,t[10]=e.endpoint.providerAccentColor,t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;t[14]===e.modelClassName?m=t[15]:(m=G(`truncate`,e.modelClassName),t[14]=e.modelClassName,t[15]=m);let h;t[16]===e.endpoint?h=t[17]:(h=XD(e.endpoint),t[16]=e.endpoint,t[17]=h);let g;t[18]!==m||t[19]!==h?(g=(0,Y.jsx)(`span`,{className:m,children:h}),t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;return t[21]!==s||t[22]!==g||t[23]!==c||t[24]!==p?(_=(0,Y.jsxs)(`span`,{className:c,title:s,children:[p,g]}),t[21]=s,t[22]=g,t[23]=c,t[24]=p,t[25]=_):_=t[25],_}),$D=(0,q.memo)(function(e){let t=(0,J.c)(18),n;t[0]===e.source?n=t[1]:(n=ZD(e.source),t[0]=e.source,t[1]=n);let r;t[2]===e.target?r=t[3]:(r=ZD(e.target),t[2]=e.target,t[3]=r);let i=`Next message will hand off context from ${n} to ${r}`,a,o,s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Y.jsx)(dl,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),o=(0,Y.jsx)(`span`,{className:`shrink-0 font-medium`,children:`Next message hands off context`}),s=(0,Y.jsx)(`span`,{className:`text-muted-foreground/45`,"aria-hidden":!0,children:`·`}),t[4]=a,t[5]=o,t[6]=s):(a=t[4],o=t[5],s=t[6]);let c;t[7]===e.source?c=t[8]:(c=(0,Y.jsx)(QD,{endpoint:e.source,className:`max-w-32 sm:max-w-44`}),t[7]=e.source,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Y.jsx)(fl,{className:`size-3.5 shrink-0 text-muted-foreground/55`,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]===e.target?u=t[11]:(u=(0,Y.jsx)(QD,{endpoint:e.target,className:`max-w-32 font-medium text-foreground/85 sm:max-w-44`}),t[10]=e.target,t[11]=u);let d;return t[12]!==i||t[13]!==e.source.providerInstanceId||t[14]!==e.target.providerInstanceId||t[15]!==c||t[16]!==u?(d=(0,Y.jsxs)(`div`,{role:`status`,"aria-label":i,title:i,"data-pending-context-handoff":`true`,"data-pending-context-handoff-source":e.source.providerInstanceId,"data-pending-context-handoff-target":e.target.providerInstanceId,className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-[11px] leading-4 text-muted-foreground shadow-sm backdrop-blur-xs`,children:[a,o,s,c,l,u]}),t[12]=i,t[13]=e.source.providerInstanceId,t[14]=e.target.providerInstanceId,t[15]=c,t[16]=u,t[17]=d):d=t[17],d}),eO={active:`Pursuing goal`,paused:`Goal paused`,blocked:`Goal blocked`,usageLimited:`Usage limit reached`,budgetLimited:`Goal budget reached`,complete:`Goal achieved`};function tO(e,t){let n=e.status===`active`?Math.max(0,Math.floor((t-Date.parse(e.updatedAt))/1e3)):0;return e.timeUsedSeconds+n}function nO(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`:`${n}:${String(r).padStart(2,`0`)}`}var rO=new Intl.NumberFormat(void 0,{notation:`compact`});function iO(e){let t=(0,J.c)(7),n=e.label,r=e.label,i=e.onClick,a=e.destructive&&`hover:text-destructive`,o;t[0]===a?o=t[1]:(o=G(`inline-flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-background/75 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,a),t[0]=a,t[1]=o);let s;return t[2]!==e.children||t[3]!==e.label||t[4]!==e.onClick||t[5]!==o?(s=(0,Y.jsx)(`button`,{type:`button`,"aria-label":n,title:r,onClick:i,className:o,children:e.children}),t[2]=e.children,t[3]=e.label,t[4]=e.onClick,t[5]=o,t[6]=s):s=t[6],s}var aO=(0,q.memo)(function(e){let t=(0,J.c)(57),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(oO),o;t[0]===e.goal.status?o=t[1]:(o=()=>{if(e.goal.status!==`active`)return;a(Date.now());let t=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(t)},t[0]=e.goal.status,t[1]=o);let s;t[2]!==e.goal.status||t[3]!==e.goal.updatedAt?(s=[e.goal.status,e.goal.updatedAt],t[2]=e.goal.status,t[3]=e.goal.updatedAt,t[4]=s):s=t[4],(0,q.useEffect)(o,s);let c=e.goal.status===`paused`||e.goal.status===`blocked`||e.goal.status===`usageLimited`,l=e.goal.status===`complete`,u=e.goal.status===`active`&&`border-primary/30 text-primary`,d=l&&`border-emerald-500/30 text-emerald-600 dark:text-emerald-400`,f;t[5]!==u||t[6]!==d?(f=G(`mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-full border border-border/60 bg-background/55 text-muted-foreground`,u,d),t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;t[8]===l?p=t[9]:(p=l?(0,Y.jsx)(ji,{className:`size-3.5`}):(0,Y.jsx)(jl,{className:`size-3.5`}),t[8]=l,t[9]=p);let m;t[10]!==f||t[11]!==p?(m=(0,Y.jsx)(`div`,{className:f,children:p}),t[10]=f,t[11]=p,t[12]=m):m=t[12];let h;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>r(sO),t[13]=h):h=t[13];let g=eO[e.goal.status],_;t[14]!==i||t[15]!==e.goal?(_=nO(tO(e.goal,i)),t[14]=i,t[15]=e.goal,t[16]=_):_=t[16];let v;t[17]===_?v=t[18]:(v=(0,Y.jsx)(`span`,{className:`font-mono font-normal tracking-normal normal-case`,children:_}),t[17]=_,t[18]=v);let y;t[19]!==e.goal.tokenBudget||t[20]!==e.goal.tokensUsed?(y=e.goal.tokenBudget===null?null:(0,Y.jsxs)(`span`,{className:`font-normal tracking-normal normal-case`,children:[rO.format(e.goal.tokensUsed),` /`,` `,rO.format(e.goal.tokenBudget),` tokens`]}),t[19]=e.goal.tokenBudget,t[20]=e.goal.tokensUsed,t[21]=y):y=t[21];let b;t[22]!==v||t[23]!==y||t[24]!==g?(b=(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 text-[11px] font-medium tracking-wide text-muted-foreground uppercase`,children:[g,v,y]}),t[22]=v,t[23]=y,t[24]=g,t[25]=b):b=t[25];let x=!n&&`line-clamp-2`,S;t[26]===x?S=t[27]:(S=G(`mt-0.5 block text-sm leading-5 text-foreground/90`,x),t[26]=x,t[27]=S);let C;t[28]!==e.goal.objective||t[29]!==S?(C=(0,Y.jsx)(`span`,{className:S,children:e.goal.objective}),t[28]=e.goal.objective,t[29]=S,t[30]=C):C=t[30];let w;t[31]!==n||t[32]!==b||t[33]!==C?(w=(0,Y.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left focus-visible:outline-none`,onClick:h,"aria-expanded":n,children:[b,C]}),t[31]=n,t[32]=b,t[33]=C,t[34]=w):w=t[34];let T;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Y.jsx)(Pa,{className:`size-3.5`}),t[35]=T):T=t[35];let E;t[36]===e.onEdit?E=t[37]:(E=(0,Y.jsx)(iO,{label:`Edit goal`,onClick:e.onEdit,children:T}),t[36]=e.onEdit,t[37]=E);let D;t[38]!==c||t[39]!==e?(D=e.goal.status===`active`?(0,Y.jsx)(iO,{label:`Pause goal`,onClick:()=>e.onStatusChange(`paused`),children:(0,Y.jsx)(Ma,{className:`size-3.5`})}):c?(0,Y.jsx)(iO,{label:`Resume goal`,onClick:()=>e.onStatusChange(`active`),children:(0,Y.jsx)(Na,{className:`size-3.5`})}):null,t[38]=c,t[39]=e,t[40]=D):D=t[40];let O;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Y.jsx)(Ya,{className:`size-3.5`}),t[41]=O):O=t[41];let k;t[42]===e.onClear?k=t[43]:(k=(0,Y.jsx)(iO,{label:`Clear goal`,destructive:!0,onClick:e.onClear,children:O}),t[42]=e.onClear,t[43]=k);let A=n&&`rotate-180`,j;t[44]===A?j=t[45]:(j=G(`mt-1 size-3.5 text-muted-foreground/60 transition-transform`,A),t[44]=A,t[45]=j);let M;t[46]===j?M=t[47]:(M=(0,Y.jsx)(Zr,{"aria-hidden":!0,className:j}),t[46]=j,t[47]=M);let N;t[48]!==E||t[49]!==D||t[50]!==k||t[51]!==M?(N=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[E,D,k,M]}),t[48]=E,t[49]=D,t[50]=k,t[51]=M,t[52]=N):N=t[52];let P;return t[53]!==w||t[54]!==N||t[55]!==m?(P=(0,Y.jsx)(`div`,{className:`rounded-t-[max(0px,calc(var(--radius-3xl)-3px))] border-b border-border/65 bg-muted/25 px-3.5 py-2.5`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[m,w,N]})}),t[53]=w,t[54]=N,t[55]=m,t[56]=P):P=t[56],P});function oO(){return Date.now()}function sO(e){return!e}function cO(e){let t=e.providerInstanceEntries.find(t=>t.instanceId===e.selection.instanceId);if(!t)return null;let n=e.modelOptionsByInstance.get(e.selection.instanceId)?.find(t=>t.slug===e.selection.model)??t.models.find(t=>t.slug===e.selection.model);return{providerInstanceId:t.instanceId,driverKind:t.driverKind,providerDisplayName:t.displayName,...t.accentColor?{providerAccentColor:t.accentColor}:{},modelSlug:e.selection.model,...n?{modelDisplayName:hn(n,{preferShortName:!0})}:{}}}function lO(e){if(!e.threadStarted||e.isPhoneTier||!e.canonicalSelection||!st({canonicalSelection:e.canonicalSelection,targetSelection:e.targetSelection}))return null;let t=cO({selection:e.canonicalSelection,providerInstanceEntries:e.providerInstanceEntries,modelOptionsByInstance:e.modelOptionsByInstance}),n=cO({selection:e.targetSelection,providerInstanceEntries:e.providerInstanceEntries,modelOptionsByInstance:e.modelOptionsByInstance});return t&&n?{source:t,target:n}:null}var uO=[`[data-slot="popover-popup"]`,`[data-slot="menu-popup"]`,`[data-slot="select-popup"]`,`[data-slot="combobox-popup"]`,`[data-slot="autocomplete-popup"]`].join(`,`),dO=(e,t,n)=>n.endsWith(` `)&&e[t]===` `?t+1:t,fO=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=n.get(e);return t?[t]:[]})},pO=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]);function mO(e){return e.closest(uO)!==null}function hO(e,t){return t.trim().length===0?e:e.length===0?t:`${e}\n\n${t}`}function gO(e){let t=e.slice(0,3),n=e.length>t.length?` and ${e.length-t.length} more`:``;return`${t.join(`, `)}${n}`}function _O(e,t,n){return`${typeof e==`string`?e:`${e.environmentId}:${e.threadId}`}\u0000${t}\u0000${n.map(e=>e.id).join(``)}`}function vO(e){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`)return;let t=new Set(Object.values(Jt.getState().draftsByThreadKey).flatMap(e=>e.images.map(e=>e.previewUrl)));for(let n of e)n.previewUrl.startsWith(`blob:`)&&!t.has(n.previewUrl)&&URL.revokeObjectURL(n.previewUrl)}var yO=(0,q.memo)((0,q.forwardRef)(function(e,t){let{composerDraftTarget:n,environmentId:r,routeKind:i,routeThreadRef:a,draftId:o,activeThreadId:s,activeThreadEnvironmentId:c,activeThreadSessionProviderInstanceId:l,activeThreadStarted:u,isServerThread:d,isLocalDraftThread:f,activeThreadGoal:p,phase:m,isConnecting:h,isSendBusy:g,isPreparingWorktree:_,environmentUnavailable:v,activePendingApproval:y,pendingApprovals:b,pendingUserInputs:S,activePendingProgress:C,activePendingResolvedAnswers:w,activePendingIsResponding:T,activePendingDraftAnswers:E,activePendingQuestionIndex:D,respondingRequestIds:O,showPlanFollowUpPrompt:k,activeProposedPlan:A,planSidebarLabel:j,planSidebarOpen:N,runtimeMode:P,interactionMode:F,tokenMode:ee,lockedProvider:L,providerStatuses:R,activeProjectDefaultModelSelection:te,activeThreadModelSelection:z,activeThreadActivities:ne,phoneThreadDock:B,resolvedTheme:re,settings:V,keybindings:H,terminalOpen:ie,gitCwd:ae,promptRef:U,composerImagesRef:oe,composerTerminalContextsRef:se,shouldAutoScrollRef:ce,scheduleStickToBottom:le,onSend:ue,onInterrupt:fe,onImplementPlanInNewThread:pe,onRespondToApproval:me,onSelectActivePendingUserInputOption:he,onAdvanceActivePendingUserInput:ge,onPreviousActivePendingUserInputQuestion:_e,onChangeActivePendingUserInputCustomAnswer:ve,onProviderModelSelect:ye,toggleInteractionMode:be,handleRuntimeModeChange:xe,handleInteractionModeChange:Se,handleTokenModeChange:Ce,togglePlanSidebar:we,focusComposer:Te,scheduleComposerFocus:Ee,setThreadError:De,onExpandImage:Oe,onEditGoal:ke,onGoalStatusChange:Ae,onClearGoal:je}=e,Me=Vl(n),Ne=Me.prompt,Pe=Me.images,Fe=Me.terminalContexts,Ie=Me.sourceControlContexts,Le=Me.nonPersistedImageIds,Re=de(),ze=(0,q.useMemo)(()=>(Re.data?.sourceControlProviders??[]).some(e=>e.status===`available`&&(e.auth.status===`authenticated`||e.auth.status===`unknown`)),[Re.data]),Be=Jt(e=>e.setPrompt),Ve=Jt(e=>e.insertTerminalContext),He=Jt(e=>e.removeTerminalContext),Ue=Jt(e=>e.setTerminalContexts),We=Jt(e=>e.clearPersistedAttachments),Ge=Jt(e=>e.syncPersistedAttachments),Ke=Jt(e=>e.clearPromptAndImages),qe=Jt(e=>e.addImages),Je=Jt(e=>e.getComposerDraft),Ye=Jt(e=>e.addSourceControlContext),Xe=Jt(e=>e.removeSourceControlContext),Ze=ID(e=>e.entries),Qe=ID(e=>e.stashEntry),$e=ID(e=>e.takeEntry),et=ID(e=>e.finalizeEntryImages),tt=(0,q.useMemo)(()=>jt(sn(R)),[R]),nt=Me.activeProvider??null,rt=l??z?.instanceId??te?.instanceId??null,it=nt??rt,at=Mt(tt,R,it)??M.make(`codex`),ot=L??at,st=(0,q.useMemo)(()=>{if(!L)return null;let e=l??z?.instanceId;return e?tt.find(t=>t.instanceId===e)?.continuationGroupKey??null:null},[z?.instanceId,l,L,tt]),dt=(0,q.useMemo)(()=>{let e=L?[z?.instanceId,l,te?.instanceId]:[Me.activeProvider,l,z?.instanceId,te?.instanceId];for(let t of e){if(!t)continue;let e=tt.find(e=>e.instanceId===t&&e.enabled);if(e){if(L&&e.driverKind!==L||st&&e.continuationGroupKey!==st)continue;return e.instanceId}}if(it)return I.make(it);let t=tt.find(e=>e.enabled&&e.driverKind===ot&&(!st||e.continuationGroupKey===st));return t?t.instanceId:tt.find(e=>e.enabled)?.instanceId??tt[0]?.instanceId??z?.instanceId??te?.instanceId??I.make(`codex`)},[te?.instanceId,l,z?.instanceId,Me.activeProvider,it,st,L,tt,ot]),ft=Ul({threadRef:n,providers:R,selectedProvider:ot,selectedInstanceId:dt,threadModelSelection:z,projectModelSelection:te,settings:V}),pt=ft.modelOptions,mt=L&&z?.instanceId===dt?z.model:ft.selectedModel,ht=(0,q.useMemo)(()=>tt.find(e=>e.instanceId===dt),[tt,dt]),gt=(0,q.useMemo)(()=>ht?.snapshot??null,[ht]),_t=(0,q.useMemo)(()=>ht?.models??[],[ht]),vt=(0,q.useMemo)(()=>yp({provider:ot,model:mt,models:_t,prompt:Ne,modelOptions:pt?.[dt]}),[pt,Ne,dt,mt,ot,_t]),bt=vt.promptEffort,xt=vt.modelOptionsForDispatch,St=Tr(e=>e.alwaysUseBuildMode),Ct=Rs(),wt=St&&Ct!==`phone`,Tt=(0,q.useMemo)(()=>({showInteractionModeToggle:!wt&&Et(R,ot),askModeSupported:Ht(R,ot)}),[wt,R,ot]),Dt=(0,q.useMemo)(()=>ut(dt,mt,xt),[dt,mt,xt]),kt=mt,At=(0,q.useMemo)(()=>{let e=new Map;for(let t of tt)e.set(t.instanceId,ct(V,t,t.instanceId===dt?mt:void 0));return e},[tt,dt,mt,V]),Nt=(0,q.useMemo)(()=>(At.get(dt)??[]).some(e=>e.slug===kt)?kt:Zt(kt,ot)??kt,[At,dt,kt,ot]),Pt=vt.modelOptionsForDispatch?.find(e=>e.id===`contextWindow`)?.value??null,It=(0,q.useMemo)(()=>$d(ne??[],typeof Pt==`string`?Pt:null),[ne,Pt]),Lt=gt?.rateLimits,[Rt,zt]=(0,q.useState)(()=>Ot(Ne,Ne.length)),[Bt,Ut]=(0,q.useState)(()=>lt(Ne,Ne.length)),[Gt,Kt]=(0,q.useState)(null),[qt,Yt]=(0,q.useState)(null),[$t,en]=(0,q.useState)(!1),[nn,rn]=(0,q.useState)(!1),[an,on]=(0,q.useState)(!1),[cn,ln]=(0,q.useState)(!1),[un,fn]=(0,q.useState)(!1),pn=Ct===`phone`,hn=pn&&!cn,_n=(0,q.useMemo)(()=>lO({threadStarted:u,isPhoneTier:pn,canonicalSelection:z,targetSelection:Dt,providerInstanceEntries:tt,modelOptionsByInstance:At}),[z,u,pn,At,tt,Dt]),vn=(0,q.useRef)(null),yn=(0,q.useRef)(null),bn=(0,q.useRef)(null),xn=(0,q.useRef)(0),Sn=(0,q.useRef)(!1),Cn=(0,q.useRef)(!1),wn=(0,q.useRef)([]),Tn=(0,q.useRef)(null),En=(0,q.useRef)(null),Dn=(0,q.useRef)(new Set),On=(0,q.useRef)(new Map),kn=(0,q.useRef)(()=>{}),An=(0,q.useCallback)(e=>{let t=On.current.get(e);t&&(On.current.delete(e),Dn.current.delete(t.key),vO(t.images))},[]);(0,q.useEffect)(()=>()=>{let e=[...On.current.values()];On.current.clear(),Dn.current.clear();for(let t of e)vO(t.images)},[]);let jn=(0,q.useMemo)(()=>wd({prompt:Ne,imageCount:Pe.length,terminalContexts:Fe,sourceControlContexts:Ie}),[Pe.length,Ie,Fe,Ne]),Mn=Bt?.kind??null,{composerMenuItems:Nn,composerMenuOpen:Pn,composerMenuSearchKey:Fn,activeComposerMenuItem:In,isComposerMenuLoading:Ln,composerMenuEmptyState:Rn}=If({composerTrigger:Bt,environmentId:r,gitCwd:ae,selectedProvider:ot,selectedProviderStatus:gt,composerHighlightedItemId:Gt,composerHighlightedSearchKey:qt});Cn.current=Pn,wn.current=Nn,Tn.current=In;let zn=(0,q.useMemo)(()=>new Set(Le),[Le]),Bn=y!==null,Vn=S[0]??null,Hn=!pn&&p!=null&&!Bn&&S.length===0&&!(k&&A!==null),Un=Bn||S.length>0||k&&A!==null||Hn,Wn=hn&&!Bn&&S.length===0,Gn=h||Bn||v!==null&&C===null,Kn=k||C!==null,qn=(0,q.useMemo)(()=>Fd({pendingProgress:C,pendingIsResponding:T,phase:m,showPlanFollowUpPrompt:k,promptHasText:Ne.trim().length>0,hasSendableContent:jn.hasSendableContent,isSendBusy:g,isConnecting:h,isPreparingWorktree:_}),[T,C,jn.hasSendableContent,h,_,g,m,Ne,k]),Jn=(0,q.useCallback)(e=>{if(e===U.current){Ee();return}U.current=e,Be(n,e);let t=Ot(e,e.length);zt(t),Ut(lt(e,e.length)),Ee()},[n,U,Ee,Be]),Yn=Ms(x.dispatchCommand),Xn=!Yn.allowed,Zn=Yn.reason,Qn=bp({provider:ot,instanceId:dt,...i===`server`?{threadRef:a}:{},...i===`draft`&&o?{draftId:o}:{},model:mt,models:_t,modelOptions:pt?.[dt],prompt:Ne,onPromptChange:Jn,disabled:Xn,disabledReason:Zn}),$n=xp({provider:ot,instanceId:dt,...i===`server`?{threadRef:a}:{},...i===`draft`&&o?{draftId:o}:{},model:mt,models:_t,modelOptions:pt?.[dt],prompt:Ne,onPromptChange:Jn,disabled:Xn,disabledReason:Zn}),er=(0,q.useMemo)(()=>C?{questionIndex:C.questionIndex,isLastQuestion:C.isLastQuestion,canAdvance:C.canAdvance,isResponding:T,isComplete:!!w}:null,[T,C,w]),tr=Nd({phase:m,isSendBusy:g,isConnecting:h,hasSendableContent:jn.hasSendableContent}),nr=pn&&!hn&&er!==null,rr=(0,q.useCallback)(e=>{Be(n,e)},[n,Be]),ir=(0,q.useCallback)(e=>{let t=Fe.findIndex(t=>t.id===e);if(t<0)return;let r=Vt(U.current,t);U.current=r.prompt,rr(r.prompt),He(n,e);let i=Ot(r.prompt,r.cursor);zt(i),Ut(lt(r.prompt,r.cursor))},[n,Fe,U,He,rr]);(0,q.useEffect)(()=>{U.current=Ne,zt(e=>gn(Ne,e))},[Ne,U]),(0,q.useEffect)(()=>{oe.current=Pe},[Pe,oe]),(0,q.useEffect)(()=>{se.current=Fe},[Fe,se]),(0,q.useEffect)(()=>{if(!Pn){Kt(null),Yt(null);return}let e=wf({items:Nn,highlightedItemId:Gt,currentSearchKey:Fn,highlightedSearchKey:qt});Kt(t=>t===e?t:e),Yt(e=>e===Fn?e:Fn)},[Gt,qt,Nn,Pn,Fn]);let ar=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=C?.customAnswer;if(typeof e!=`string`){ar.current=null;return}let t=Vn?.requestId??null,n=C?.activeQuestion?.id??null,r=ar.current?.requestId!==t||ar.current?.questionId!==n,i=U.current!==e;if(ar.current={requestId:t,questionId:n},!r&&!i)return;U.current=e;let a=Ot(e,e.length);zt(a),Ut(lt(e,mn(e,a))),Kt(null)},[C?.customAnswer,C?.activeQuestion?.id,Vn?.requestId,U]),(0,q.useEffect)(()=>{Kt(null),zt(Ot(U.current,U.current.length)),Ut(lt(U.current,U.current.length))},[o,s,U]),(0,q.useLayoutEffect)(()=>{let e=yn.current;if(!e)return;let t=()=>e.clientWidth,n=()=>{let e=t(),n=Vf(e,{hasWideActions:Kn});return{primaryActionsCompact:n&&Hf(e,{hasWideActions:Kn}),footerCompact:n}};xn.current=e.getBoundingClientRect().height;let r=n();if(rn(r.primaryActionsCompact),en(r.footerCompact),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(e=>{let[t]=e;if(!t)return;let r=n();rn(e=>e===r.primaryActionsCompact?e:r.primaryActionsCompact),en(e=>e===r.footerCompact?e:r.footerCompact);let i=t.contentRect.height,a=xn.current;xn.current=i,!(a>0&&Math.abs(i-a)<.5)&&ce.current&&le()});return i.observe(e),()=>{i.disconnect()}},[s,qn,Kn,le,ce]),(0,q.useEffect)(()=>{let e=!1;return(async()=>{if(Pe.length===0){We(n);return}let t=()=>Je(n)?.persistedAttachments??[];try{let r=t(),i=new Map(r.map(e=>[e.id,e])),a=new Map;await Promise.all(Pe.map(async e=>{try{let t=dn(await ul.encode(e));a.set(e.id,{type:e.type,id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,dataUrl:t})}catch{let t=i.get(e.id);t&&a.set(e.id,t)}}));let o=Array.from(a.values());if(e)return;Ge(n,o)}catch{let r=new Set(Pe.map(e=>e.id)),i=t(),a=i.map(e=>e.id).filter(e=>r.has(e)),o=new Set(a),s=i.filter(e=>o.has(e.id));if(e)return;Ge(n,s)}})(),()=>{e=!0}},[n,We,Pe,Je,Ge]);let W=(0,q.useCallback)((e,t,r,i,a)=>{if(C?.activeQuestion&&S.length>0){zt(t),Ut(i?null:lt(e,r)),ve(C.activeQuestion.id,e,t,r,i);return}U.current=e,rr(e),pO(Fe,a)||Ue(n,fO(Fe,a)),zt(t),Ut(i?null:lt(e,r))},[C?.activeQuestion,S.length,ve,U,rr,n,Fe,Ue]),or=(0,q.useCallback)((e,t,n,r)=>{let i=U.current,a=Math.max(0,Math.min(i.length,e)),o=Math.max(a,Math.min(i.length,t));if(r?.expectedText!==void 0&&i.slice(a,o)!==r.expectedText)return!1;let s=Qt(U.current,e,t,n),c=Ot(s.text,s.cursor),l=mn(s.text,c);U.current=s.text;let u=C?.activeQuestion;return u&&Vn?ve(u.id,s.text,c,l,!1):rr(s.text),zt(c),Ut(lt(s.text,l)),r?.focusEditorAfterReplace!==!1&&window.requestAnimationFrame(()=>{vn.current?.focusAt(c)}),!0},[C?.activeQuestion,Vn,ve,U,rr]),sr=(0,q.useCallback)(()=>vn.current?.readSnapshot()||{value:U.current,cursor:Rt,expandedCursor:mn(U.current,Rt),terminalContextIds:Fe.map(e=>e.id)},[Rt,Fe,U]),cr=(0,q.useCallback)(()=>{let e=sr();return{snapshot:e,trigger:lt(e.value,e.expandedCursor)}},[sr]),{handleSelectIssue:lr,handleSelectChangeRequest:ur}=zf({environmentId:r,gitCwd:ae,composerDraftTarget:n,addSourceControlContext:Ye}),dr=(0,q.useCallback)(e=>{if(Sn.current)return;Sn.current=!0,window.requestAnimationFrame(()=>{Sn.current=!1});let{snapshot:t,trigger:n}=cr();if(n){if(e.type===`path`){let r=`@${Xt(e.path)} `,i=dO(t.value,n.rangeEnd,r);or(n.rangeStart,i,r,{expectedText:t.value.slice(n.rangeStart,i)})&&Kt(null);return}if(e.type===`slash-command`){if(e.command===`model`){or(n.rangeStart,n.rangeEnd,``,{expectedText:t.value.slice(n.rangeStart,n.rangeEnd),focusEditorAfterReplace:!1})&&(Kt(null),on(!0));return}if(e.command===`goal`){let e=`/goal `,r=dO(t.value,n.rangeEnd,e);or(n.rangeStart,r,e,{expectedText:t.value.slice(n.rangeStart,r)})&&Kt(null);return}Se(e.command===`plan`?`plan`:`default`),or(n.rangeStart,n.rangeEnd,``,{expectedText:t.value.slice(n.rangeStart,n.rangeEnd)})&&Kt(null);return}if(e.type===`provider-slash-command`){let r=`/${e.command.name} `,i=dO(t.value,n.rangeEnd,r);or(n.rangeStart,i,r,{expectedText:t.value.slice(n.rangeStart,i)})&&Kt(null);return}if(e.type===`skill`){let r=`$${e.skill.name} `,i=dO(t.value,n.rangeEnd,r);or(n.rangeStart,i,r,{expectedText:t.value.slice(n.rangeStart,i)})&&Kt(null);return}if(e.type===`source-control-issue`){or(n.rangeStart,n.rangeEnd,``,{expectedText:t.value.slice(n.rangeStart,n.rangeEnd)})&&Kt(null),lr(e.summary);return}if(e.type===`source-control-pr`){or(n.rangeStart,n.rangeEnd,``,{expectedText:t.value.slice(n.rangeStart,n.rangeEnd)})&&Kt(null),ur(e.summary);return}}},[or,Se,lr,ur,cr]),fr=(0,q.useCallback)(e=>{Kt(e),Yt(Fn)},[Fn]),pr=(0,q.useCallback)(e=>{if(Nn.length===0)return;let t=Nn.findIndex(e=>e.id===Gt),n=((t>=0?t:e===`ArrowDown`?-1:0)+(e===`ArrowDown`?1:-1)+Nn.length)%Nn.length,r=Nn[n];Kt(r?.id??null)},[Gt,Nn]),mr=(0,q.useCallback)(()=>{if(!pn)return;En.current!==null&&(window.cancelAnimationFrame(En.current),En.current=null);let e=document.activeElement;e instanceof HTMLElement&&e.blur(),ln(!1)},[pn]),hr=(0,q.useCallback)(()=>Pd({isMobileViewport:pn,isSendBusy:g,isConnecting:h,phase:m,pendingProgress:C,hasResolvedAnswers:!!w,showPlanFollowUpPrompt:k,hasSendableContent:jn.hasSendableContent}),[C,w,jn.hasSendableContent,h,pn,g,m,k]),gr=(0,q.useCallback)(e=>{ue(e),hr()&&mr()},[mr,ue,hr]),_r=(e,t)=>{if(e===`Tab`&&t.shiftKey)return be(),!0;let{trigger:n}=cr();if(Cn.current||n!==null){let t=wn.current,n=Tn.current??t[0];if(e===`ArrowDown`&&t.length>0)return pr(`ArrowDown`),!0;if(e===`ArrowUp`&&t.length>0)return pr(`ArrowUp`),!0;if((e===`Enter`||e===`Tab`)&&n)return dr(n),!0}return e===`Enter`&&!t.shiftKey&&(gr(),!0)},{isDragOverComposer:vr,addComposerAttachments:yr,removeComposerImage:br,onComposerPaste:xr,onComposerDragEnter:Sr,onComposerDragOver:Cr,onComposerDragLeave:wr,onComposerDrop:Er}=jD({composerDraftTarget:n,environmentId:r,activeThreadId:s,draftId:o,routeThreadRef:a,runtimeMode:P,selectedProvider:ot,gitCwd:ae,pendingUserInputCount:S.length,composerImagesRef:oe,editorRef:vn,setThreadError:De,focusComposer:Te}),Dr=(0,q.useCallback)(e=>{Xe(n,e)},[n,Xe]),Or=(0,q.useCallback)((e,t)=>{let{entry:r,durable:i}=$e(e);if(!r)return;let a=On.current.get(e),o=a!==void 0&&(t?.preferMemorySnapshot===!0||r.pendingImageCount>0),s,c=[];if(o&&a)s=a.images;else{let e=Ft(r.attachments);s=e.images,c=e.unreadableImageNames}let l=[...oe.current],u=new Set(l.map(e=>e.id)),d=new Set(l.map(e=>yt(e))),f=[],p=[],m=[];for(let e of s){let t=yt(e);if(u.has(e.id)||d.has(t)){p.push(e.name);continue}if(l.length+f.length>=8){m.push(e.name);continue}f.push(e),u.add(e.id),d.add(t)}let h=U.current,g=hO(h,r.prompt);if(g!==h){U.current=g,rr(g);let e=Ot(g,g.length);zt(e),Ut(lt(g,g.length))}f.length>0&&(qe(n,f),oe.current=[...l,...f]),fn(!1),An(e),Ee(),i||Ai.add({type:`warning`,title:`Restored stash may reappear after reload`,description:`The prompt was restored, but browser storage could not save its removal.`,data:{hideCopyButton:!0}});let _=[];!o&&r.unreadableImageNames.length>0&&_.push(`Unreadable while saving: ${gO(r.unreadableImageNames)}.`),!o&&c.length>0&&_.push(`Unreadable while restoring: ${gO(c)}.`),!o&&r.droppedImageNames.length>0&&_.push(`Not saved because the stash image budget was full: ${gO(r.droppedImageNames)}.`),!o&&r.pendingImageCount>0&&_.push(`${r.pendingImageCount} image${r.pendingImageCount===1?` was`:`s were`} still saving and could not be restored.`),p.length>0&&_.push(`Already attached and skipped: ${gO(p)}.`),m.length>0&&_.push(`Not restored because this composer can hold 8 images: ${gO(m)}.`),_.length>0&&Ai.add({type:`warning`,title:`Some stashed images could not be restored`,description:_.join(` `),data:{hideCopyButton:!0}})},[qe,n,oe,U,An,Ee,rr,$e]),kr=(0,q.useCallback)(e=>{let{entry:t,durable:n}=$e(e);t&&(An(e),n||Ai.add({type:`warning`,title:`Deleted stash may reappear after reload`,description:`Browser storage could not save the deletion.`,data:{hideCopyButton:!0}}))},[An,$e]);kn.current=(0,q.useCallback)(()=>{if(pn||Bn||S.length>0)return;let e=Wt(U.current),t=[...oe.current],r=e.trim().length>0?e:``;if(r.length===0&&t.length===0){fn(e=>!e);return}let i=_O(n,r,t);if(Dn.current.has(i))return;Dn.current.add(i);let a=io(),o={id:a,createdAt:new Date().toISOString(),prompt:r,attachments:[],droppedImageNames:[],unreadableImageNames:[],pendingImageCount:t.length},s=Qe(o);if(!s.written){Dn.current.delete(i),Ai.add(As({type:`error`,title:`Could not stash this prompt`,description:`Browser storage rejected the stash. The composer was left unchanged.`,data:{hideCopyButton:!0}}));return}On.current.set(a,{key:i,images:t}),s.evicted&&An(s.evicted.id),Ke(n);let c=Je(n)?.prompt??``;U.current=c,oe.current=[];let l=Ot(c,c.length);zt(l),Ut(null),Kt(null),fn(!1),Ai.add({type:`success`,title:`Prompt stashed`,description:t.length>0?`Saving ${t.length} image${t.length===1?``:`s`} in the background.`:void 0,actionProps:{children:`Undo`,onClick:()=>Or(a,{preferMemorySnapshot:!0})},data:{hideCopyButton:!0}}),s.durable||Ai.add({type:`warning`,title:`Stashed prompt will not survive a reload`,description:`Browser storage is unavailable, so this stash is kept in memory for this page session only.`,data:{hideCopyButton:!0}}),s.evicted&&Ai.add({type:`warning`,title:`Oldest stashed prompt discarded`,description:`The stash holds 20 prompts; the oldest was removed.`,data:{hideCopyButton:!0}}),(async()=>{let e=await Promise.all(t.map(async e=>{try{return{attachment:{type:e.type,id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,dataUrl:dn(await ul.encode(e))},unreadableName:null}}catch{return{attachment:null,unreadableName:e.name}}})),n=e.flatMap(e=>e.attachment?[e.attachment]:[]),r=e.flatMap(e=>e.unreadableName?[e.unreadableName]:[]),i=et(a,{attachments:n,droppedImageNames:[],unreadableImageNames:r});if(!i.attached){s.durable&&!i.written&&t.length>0&&Ai.add({type:`warning`,title:`Stashed images were not saved`,description:`The prompt is still stashed, but browser storage rejected its image data.`,data:{hideCopyButton:!0}});return}let o=ID.getState().entries.find(e=>e.id===a),c=[];o?.unreadableImageNames.length&&c.push(`Could not read: ${gO(o.unreadableImageNames)}.`),o?.droppedImageNames.length&&c.push(`Over the stash image budget: ${gO(o.droppedImageNames)}.`),c.length>0?Ai.add({type:`warning`,title:`Some images were not added to the stash`,description:c.join(` `),data:{hideCopyButton:!0}}):s.durable&&!i.durable&&t.length>0&&Ai.add({type:`warning`,title:`Stashed images will not survive a reload`,description:`The prompt was saved, but browser storage rejected the later image update.`,data:{hideCopyButton:!0}})})().finally(()=>{An(a)})},[Ke,n,oe,et,Je,Bn,pn,S.length,U,An,Or,Qe]),(0,q.useLayoutEffect)(()=>{let e=e=>{if(e.defaultPrevented||e.isComposing)return;let t=yn.current!==null&&e.composedPath().includes(yn.current),n=e.target===window||e.target===document||e.target===document.body;!t&&!n&&Mo(e)||To(e,H,{context:{terminalFocus:Ns(),terminalOpen:ie,modelPickerOpen:an,composerFocus:cn}})===`composer.stash`&&(e.preventDefault(),e.stopPropagation(),kn.current())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[cn,an,H,ie]),(0,q.useEffect)(()=>{fn(!1)},[n,pn]);let Ar=(0,q.useCallback)(()=>{fe()},[fe]),jr=(0,q.useCallback)(()=>{pe()},[pe]),Mr=(0,q.useCallback)(()=>{pn&&(En.current!==null&&window.cancelAnimationFrame(En.current),En.current=window.requestAnimationFrame(()=>{En.current=null;let e=bn.current,t=document.activeElement;t instanceof Element&&mO(t)||e&&t instanceof Element&&e.contains(t)&&t.closest(`[data-chat-composer-collapsed-controls="true"]`)===null||ln(!1)}))},[pn]);return(0,q.useEffect)(()=>()=>{En.current!==null&&window.cancelAnimationFrame(En.current)},[]),(0,q.useImperativeHandle)(t,()=>({focusAtEnd:()=>{vn.current?.focusAtEnd()},focusAt:e=>{vn.current?.focusAt(e)},openModelPicker:()=>{on(!0)},toggleModelPicker:()=>{on(e=>!e)},isModelPickerOpen:()=>an,readSnapshot:()=>sr(),resetCursorState:e=>{let t=e?.prompt??U.current,n=gn(t,e?.cursor??0);Kt(null),zt(n),Ut(e?.detectTrigger?lt(t,mn(t,n)):null)},addTerminalContext:e=>{if(!s)return;let t=vn.current?.readSnapshot()??{value:U.current,cursor:Rt,expandedCursor:mn(U.current,Rt),terminalContextIds:Fe.map(e=>e.id)},r=tn(t.value,t.expandedCursor),i=Ot(r.prompt,r.cursor);Ve(n,r.prompt,{id:io(),threadId:s,createdAt:new Date().toISOString(),...e},r.contextIndex)&&(U.current=r.prompt,zt(i),Ut(lt(r.prompt,r.cursor)),window.requestAnimationFrame(()=>{vn.current?.focusAt(i)}))},insertTriggerAtCursor:e=>{pn&&ln(!0);let t=vn.current?.readSnapshot()??{value:U.current,cursor:Rt,expandedCursor:mn(U.current,Rt),terminalContextIds:Fe.map(e=>e.id)},{text:r,cursor:i}=Qt(t.value,t.expandedCursor,t.expandedCursor,e),a=Ot(r,i);U.current=r,Be(n,r),zt(a),Ut(lt(r,i)),window.requestAnimationFrame(()=>{vn.current?.focusAt(a)})},getSendContext:()=>({prompt:U.current,images:oe.current,terminalContexts:se.current,sourceControlContexts:Ie,selectedPromptEffort:bt,selectedModelOptionsForDispatch:xt,selectedModelSelection:Dt,selectedProvider:ot,selectedModel:mt,selectedProviderModels:_t})}),[s,n,Rt,Ie,Fe,Ve,pn,U,oe,se,an,sr,mt,xt,Dt,bt,ot,_t,Be]),(0,Y.jsxs)(`form`,{ref:yn,onSubmit:gr,className:`relative mx-auto w-full min-w-0 max-w-208`,"data-chat-composer-form":`true`,children:[_n?(0,Y.jsx)(`div`,{className:G(`mb-2 flex min-w-0 items-center px-4`,Ze.length>0&&`pr-24`),children:(0,Y.jsx)($D,{source:_n.source,target:_n.target})}):null,pn?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(zD,{count:Ze.length,open:un,onToggle:()=>fn(e=>!e)}),un?(0,Y.jsx)(GD,{entries:Ze,onRestore:e=>Or(e),onDelete:kr,onClose:()=>fn(!1)}):null]}),(0,Y.jsx)(`div`,{className:G(`group rounded-3xl p-px transition-colors duration-200`,vt.composerFrameClassName),onDragEnter:Sr,onDragOver:Cr,onDragLeave:wr,onDrop:Er,children:(0,Y.jsxs)(`div`,{ref:bn,"data-chat-composer-mobile-collapsed":hn?`true`:`false`,className:G(`rounded-[max(0px,calc(var(--radius-3xl)-2px))] border-0 bg-[color-mix(in_srgb,var(--card)_var(--app-composer-alpha),transparent)] dark:bg-[color-mix(in_srgb,var(--card)_var(--app-composer-dark-alpha),transparent)] [-webkit-backdrop-filter:var(--app-composer-filter)] [backdrop-filter:var(--app-composer-filter)] shadow-[0_6px_18px_rgba(0,0,0,0.06),0_1px_3px_rgba(0,0,0,0.05)] outline-none transition-[background-color,box-shadow] duration-200 has-focus-visible:shadow-[0_8px_24px_rgba(0,0,0,0.09),0_1px_4px_rgba(0,0,0,0.07)] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.06),0_10px_28px_rgba(0,0,0,0.4),0_1px_3px_rgba(0,0,0,0.35)] dark:has-focus-visible:shadow-[inset_0_1px_0_rgba(255,255,255,0.08),0_12px_32px_rgba(0,0,0,0.5),0_1px_4px_rgba(0,0,0,0.4)]`,vr?`bg-accent/30 shadow-lg/12 ring-1 ring-inset ring-primary/45 [--lg-plate-alpha:72%] [--lg-plate-color:color-mix(in_srgb,var(--accent)_38%,var(--card))]`:null,v?`opacity-75`:null,vt.composerSurfaceClassName),onFocusCapture:e=>{let t=e.target;t instanceof HTMLElement&&t.closest(`[data-chat-composer-collapsed-controls="true"]`)||(En.current!==null&&(window.cancelAnimationFrame(En.current),En.current=null),ln(!0))},onBlurCapture:()=>{Mr()},onClick:e=>{if(!hn||!Gn)return;let t=e.target;t instanceof HTMLElement&&t.closest(`[data-chat-composer-collapsed-controls="true"]`)||ln(!0)},children:[(0,Y.jsx)(RD,{hostRef:bn}),!hn&&(y?(0,Y.jsx)(`div`,{className:`rounded-t-[max(0px,calc(var(--radius-3xl)-3px))] border-b border-border/65 bg-muted/20`,children:(0,Y.jsx)(Kf,{approval:y,pendingCount:b.length,isResponding:O.includes(y.requestId),onRespondToApproval:me})}):S.length>0?(0,Y.jsx)(`div`,{className:`rounded-t-[max(0px,calc(var(--radius-3xl)-3px))] border-b border-border/65 bg-muted/20`,children:(0,Y.jsx)(tp,{pendingUserInputs:S,respondingRequestIds:O,answers:E,questionIndex:D,onToggleOption:he,onAdvance:ge})}):k&&A?(0,Y.jsx)(`div`,{className:`rounded-t-[max(0px,calc(var(--radius-3xl)-3px))] border-b border-border/65 bg-muted/20`,children:(0,Y.jsx)(rp,{planTitle:pu(A.planMarkdown)??null},A.id)}):Hn&&p?(0,Y.jsx)(aO,{goal:p,onEdit:ke,onStatusChange:Ae,onClear:je}):null),hn&&y?(0,Y.jsx)(`div`,{className:`rounded-t-[max(0px,calc(var(--radius-3xl)-3px))] border-b border-border/65 bg-muted/20`,"data-chat-composer-collapsed-controls":`true`,children:(0,Y.jsx)(Kf,{approval:y,pendingCount:b.length,isResponding:O.includes(y.requestId),onRespondToApproval:me})}):hn&&S.length>0?(0,Y.jsxs)(`div`,{className:`rounded-t-[max(0px,calc(var(--radius-3xl)-3px))] border-b border-border/65 bg-muted/20`,"data-chat-composer-collapsed-controls":`true`,children:[(0,Y.jsx)(tp,{pendingUserInputs:S,respondingRequestIds:O,answers:E,questionIndex:D,onToggleOption:he,onAdvance:ge}),C?.activeQuestion?.multiSelect?(0,Y.jsx)(`div`,{className:`px-3 pb-3 sm:px-4`,children:(0,Y.jsx)(`div`,{"data-chat-composer-mobile-pending-compact":`true`,className:`flex min-w-0 items-center justify-end gap-2 rounded-lg border border-border/55 bg-background/55 p-1.5`,children:(0,Y.jsx)(zd,{compact:!0,pendingAction:er,isRunning:!1,showPlanFollowUpPrompt:!1,promptHasText:!1,isSendBusy:g,isConnecting:h,isEnvironmentUnavailable:v!==null,isPreparingWorktree:!1,hasSendableContent:!1,preserveComposerFocusOnPointerDown:!0,onPreviousPendingQuestion:_e,onInterrupt:Ar,onImplementPlanInNewThread:jr})})}):null]}):null,B?(0,Y.jsx)(`div`,{className:`px-3 pt-2 sm:px-4`,"data-chat-composer-collapsed-controls":`true`,children:(0,Y.jsx)(wD,{...B})}):null,(0,Y.jsx)(yD,{editorRef:vn,isComposerCollapsedMobile:hn,hasComposerHeader:Un,isComposerApprovalState:Bn,resolvedTheme:re,composerMenuOpen:Pn,composerMenuItems:Nn,isComposerMenuLoading:Ln,composerTriggerKind:Mn,composerTrigger:Bt,composerMenuEmptyState:Rn,activeComposerMenuItemId:In?.id??null,onComposerMenuItemHighlighted:fr,onSelectComposerItem:dr,composerSourceControlContexts:Ie,onRemoveSourceControlContext:Dr,composerImages:Pe,nonPersistedComposerImageIdSet:zn,onExpandImage:Oe,onRemoveImage:br,pendingUserInputCount:S.length,prompt:Ne,composerCursor:Rt,composerTerminalContexts:Fe,skills:gt?.skills??[],showMobilePendingAnswerActions:nr,onRemoveTerminalContext:ir,onPromptChange:W,onComposerCommandKey:_r,onComposerPaste:xr,activePendingProgress:C,showPlanFollowUpPrompt:k,activeProposedPlan:A,environmentUnavailable:v,phase:m,isConnecting:h,isEditorDisabled:Gn,showCollapsedSendAction:Wn,collapsedSendActionLabel:`Send message`,collapsedSendActionDisabled:tr,onCollapsedSend:gr,isSendBusy:g,pendingPrimaryAction:er,onPreviousPendingQuestion:_e,onInterrupt:Ar,onImplementPlanInNewThread:jr}),hn||y?null:(0,Y.jsx)(vf,{isFooterCompact:$t,isPrimaryActionsCompact:nn,isMobileViewport:pn,hideOnMobilePendingAnswers:nr,environmentId:r,gitCwd:ae,hasSourceControlRemote:ze,onSelectIssue:lr,onSelectChangeRequest:ur,onAttachFile:e=>{yr([e])},executionTargets:e.executionTargets,selectedExecutionEnvironmentId:r,executionTargetLocked:e.executionTargetLocked,onExecutionTargetChange:e.onExecutionTargetChange,selectedInstanceId:dt,selectedModel:Nt,lockedProvider:L,lockedContinuationGroupKey:st,providerInstanceEntries:tt,keybindings:H,modelOptionsByInstance:At,terminalOpen:ie,isModelPickerOpen:an,...vt.modelPickerIconClassName?{modelPickerIconClassName:vt.modelPickerIconClassName}:{},onModelPickerOpenChange:on,onProviderModelSelect:ye,showInteractionModeToggle:Tt.showInteractionModeToggle,askModeSupported:Tt.askModeSupported,showPlanSidebarToggle:!1,interactionMode:F,runtimeMode:P,tokenMode:ee,planSidebarLabel:j,planSidebarOpen:N,providerTraitsMenuContent:Qn,providerTraitsChips:$n,onInteractionModeChange:Se,onTogglePlanSidebar:we,onRuntimeModeChange:xe,onTokenModeChange:Ce,contextWindowUsage:It,contextWindowRateLimits:Lt,pendingAction:er,isRunning:m===`running`,showPlanFollowUpPrompt:S.length===0&&k,promptHasText:Ne.trim().length>0,isSendBusy:g,isConnecting:h,isEnvironmentUnavailable:v!==null,isPreparingWorktree:_,hasSendableContent:jn.hasSendableContent,onPreviousPendingQuestion:_e,onInterrupt:Ar,onImplementPlanInNewThread:jr})]})})]})})),bO=(0,q.lazy)(()=>n(()=>import(`./ThreadTerminalDrawer-DRelLlEP.js`).then(e=>e.n),__vite__mapDeps([0]))),xO=(0,q.memo)(function(e){let t=(0,J.c)(78),{threadRef:n,threadId:r,visible:i,launchContext:a,focusRequestId:s,splitShortcutLabel:c,newShortcutLabel:l,closeShortcutLabel:u,keybindings:d,onAddTerminalContext:f}=e,p;t[0]===n?p=t[1]:(p=ue(n),t[0]=n,t[1]=p);let m=oe(p),h;t[2]===n?h=t[3]:(h=e=>e.getDraftThreadByRef(n),t[2]=n,t[3]=h);let g=Jt(h),_;t[4]!==g||t[5]!==m?(_=m?o(m.environmentId,m.projectId):g?o(g.environmentId,g.projectId):null,t[4]=g,t[5]=m,t[6]=_):_=t[6];let v=_,y;t[7]===v?y=t[8]:(y=ne(v),t[7]=v,t[8]=y);let b=oe(y),x;t[9]===n?x=t[10]:(x=e=>Qe(e.terminalStateByThreadKey,n),t[9]=n,t[10]=x);let S=ge(x),C=ge(SO),w=ge(CO),T=ge(wO),E=ge(TO),D=ge(EO),[O,k]=(0,q.useState)(0),A=m?.worktreePath??g?.worktreePath??null,j;bb0:{if(a!==null){j=a.worktreePath;break bb0}j=A}let M=j,N;t[11]!==M||t[12]!==a?.cwd||t[13]!==b?(N=()=>a?.cwd??(b?Ca({project:{cwd:b.cwd},worktreePath:M}):null),t[11]=M,t[12]=a?.cwd,t[13]=b,t[14]=N):N=t[14],a?.cwd;let P;t[15]===N?P=t[16]:(P=N(),t[15]=N,t[16]=P);let F=P,I;t[17]!==M||t[18]!==b?(I=b?va({project:{cwd:b.cwd},worktreePath:M}):{},t[17]=M,t[18]=b,t[19]=I):I=t[19];let ee=I,L;t[20]===i?L=t[21]:(L=()=>{i&&k(DO)},t[20]=i,t[21]=L);let R=L,te;t[22]!==C||t[23]!==n?(te=e=>{C(n,e)},t[22]=C,t[23]=n,t[24]=te):te=t[24];let z=te,B;t[25]!==R||t[26]!==w||t[27]!==n?(B=()=>{w(n,`terminal-${io()}`),R()},t[25]=R,t[26]=w,t[27]=n,t[28]=B):B=t[28];let re=B,V;t[29]!==R||t[30]!==T||t[31]!==n?(V=()=>{T(n,`terminal-${io()}`),R()},t[29]=R,t[30]=T,t[31]=n,t[32]=V):V=t[32];let H=V,ie;t[33]!==R||t[34]!==E||t[35]!==n?(ie=e=>{E(n,e),R()},t[33]=R,t[34]=E,t[35]=n,t[36]=ie):ie=t[36];let ae=ie,U;t[37]!==R||t[38]!==D||t[39]!==S.terminalIds.length||t[40]!==r||t[41]!==n?(U=e=>{let t=Be(n.environmentId);if(!t)return;let i=S.terminalIds.length<=1,a=()=>t.terminal.write({threadId:r,terminalId:e,data:`exit
|
|
21
|
-
`}).catch(OO);`close`in t.terminal&&typeof t.terminal.close==`function`?(async()=>{i&&await t.terminal.clear({threadId:r,terminalId:e}).catch(kO),await t.terminal.close({threadId:r,terminalId:e,deleteHistory:!0})})().catch(()=>a()):a(),D(n,e),R()},t[37]=R,t[38]=D,t[39]=S.terminalIds.length,t[40]=r,t[41]=n,t[42]=U):U=t[42];let se=U,ce;t[43]!==f||t[44]!==i?(ce=e=>{i&&f(e)},t[43]=f,t[44]=i,t[45]=ce):ce=t[45];let le=ce;if(!b||!S.terminalOpen||!F)return null;let de=i?void 0:`hidden`,fe;t[46]===S.terminalHeight?fe=t[47]:(fe=(0,Y.jsx)(`div`,{className:`thread-terminal-drawer relative flex min-w-0 shrink-0 items-center border-border/80 border-t bg-background px-4 text-muted-foreground text-sm`,style:{height:S.terminalHeight},children:`Loading terminal...`}),t[46]=S.terminalHeight,t[47]=fe);let pe=s+O+ +!!i,me=i?c:void 0,he=i?l:void 0,_e=i?u:void 0,ve;t[48]!==ae||t[49]!==se||t[50]!==H||t[51]!==F||t[52]!==M||t[53]!==le||t[54]!==d||t[55]!==ee||t[56]!==z||t[57]!==re||t[58]!==pe||t[59]!==me||t[60]!==he||t[61]!==_e||t[62]!==S.activeTerminalGroupId||t[63]!==S.activeTerminalId||t[64]!==S.runningTerminalIds||t[65]!==S.terminalGroups||t[66]!==S.terminalHeight||t[67]!==S.terminalIds||t[68]!==r||t[69]!==n||t[70]!==i?(ve=(0,Y.jsx)(bO,{threadRef:n,threadId:r,cwd:F,worktreePath:M,runtimeEnv:ee,visible:i,height:S.terminalHeight,terminalIds:S.terminalIds,runningTerminalIds:S.runningTerminalIds,activeTerminalId:S.activeTerminalId,terminalGroups:S.terminalGroups,activeTerminalGroupId:S.activeTerminalGroupId,focusRequestId:pe,onSplitTerminal:re,onNewTerminal:H,splitShortcutLabel:me,newShortcutLabel:he,closeShortcutLabel:_e,keybindings:d,onActiveTerminalChange:ae,onCloseTerminal:se,onHeightChange:z,onAddTerminalContext:le}),t[48]=ae,t[49]=se,t[50]=H,t[51]=F,t[52]=M,t[53]=le,t[54]=d,t[55]=ee,t[56]=z,t[57]=re,t[58]=pe,t[59]=me,t[60]=he,t[61]=_e,t[62]=S.activeTerminalGroupId,t[63]=S.activeTerminalId,t[64]=S.runningTerminalIds,t[65]=S.terminalGroups,t[66]=S.terminalHeight,t[67]=S.terminalIds,t[68]=r,t[69]=n,t[70]=i,t[71]=ve):ve=t[71];let ye;t[72]!==fe||t[73]!==ve?(ye=(0,Y.jsx)(q.Suspense,{fallback:fe,children:ve}),t[72]=fe,t[73]=ve,t[74]=ye):ye=t[74];let be;return t[75]!==de||t[76]!==ye?(be=(0,Y.jsx)(`div`,{className:de,children:ye}),t[75]=de,t[76]=ye,t[77]=be):be=t[77],be});function SO(e){return e.setTerminalHeight}function CO(e){return e.splitTerminal}function wO(e){return e.newTerminal}function TO(e){return e.setActiveTerminal}function EO(e){return e.closeTerminal}function DO(e){return e+1}function OO(){}function kO(){}var AO=(0,q.memo)(function(e){let t=(0,J.c)(32),{preview:n,onClose:r}=e,[i,a]=(0,q.useState)(n),o,s;t[0]===n?(o=t[1],s=t[2]):(o=()=>{a(n)},s=[n],t[0]=n,t[1]=o,t[2]=s),(0,q.useEffect)(o,s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{a(t=>{if(t.images.length<=1)return t;let n=(t.index+e+t.images.length)%t.images.length;return n===t.index?t:{...t,index:n}})},t[3]=c):c=t[3];let l=c,u,d;t[4]!==r||t[5]!==i.images.length?(u=()=>{let e=e=>{if(jo(e)){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),r();return}if(!(i.images.length<=1)){if(e.key===`ArrowLeft`){e.preventDefault(),e.stopPropagation(),l(-1);return}e.key===`ArrowRight`&&(e.preventDefault(),e.stopPropagation(),l(1))}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},d=[l,r,i.images.length],t[4]=r,t[5]=i.images.length,t[6]=u,t[7]=d):(u=t[6],d=t[7]),(0,q.useEffect)(u,d);let f=i.images[i.index];if(!f)return null;let p;t[8]===r?p=t[9]:(p=(0,Y.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-0 cursor-zoom-out`,"aria-label":`Close image preview`,onClick:r}),t[8]=r,t[9]=p);let m;t[10]===i.images.length?m=t[11]:(m=i.images.length>1&&(0,Y.jsx)(K,{type:`button`,size:`icon`,variant:`ghost`,className:`absolute left-2 top-1/2 z-20 -translate-y-1/2 text-white/90 hover:bg-white/10 hover:text-white sm:left-6`,"aria-label":`Previous image`,onClick:()=>l(-1),children:(0,Y.jsx)($r,{className:`size-5`})}),t[10]=i.images.length,t[11]=m);let h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Y.jsx)($a,{}),t[12]=h):h=t[12];let g;t[13]===r?g=t[14]:(g=(0,Y.jsx)(K,{type:`button`,size:`icon-xs`,variant:`ghost`,className:`absolute right-2 top-2 z-20`,onClick:r,"aria-label":`Close image preview`,children:h}),t[13]=r,t[14]=g);let _;t[15]!==f.name||t[16]!==f.src?(_=(0,Y.jsx)(`img`,{src:f.src,alt:f.name,className:`max-h-[86vh] max-w-[92vw] select-none rounded-lg border border-border/70 bg-background object-contain shadow-2xl`,draggable:!1}),t[15]=f.name,t[16]=f.src,t[17]=_):_=t[17];let v=i.images.length>1?` (${i.index+1}/${i.images.length})`:``,y;t[18]!==f.name||t[19]!==v?(y=(0,Y.jsxs)(`p`,{className:`mt-2 max-w-[92vw] truncate text-center text-xs text-muted-foreground/80`,children:[f.name,v]}),t[18]=f.name,t[19]=v,t[20]=y):y=t[20];let b;t[21]!==_||t[22]!==y||t[23]!==g?(b=(0,Y.jsxs)(`div`,{className:`relative isolate z-10 max-h-[92vh] max-w-[92vw]`,children:[g,_,y]}),t[21]=_,t[22]=y,t[23]=g,t[24]=b):b=t[24];let x;t[25]===i.images.length?x=t[26]:(x=i.images.length>1&&(0,Y.jsx)(K,{type:`button`,size:`icon`,variant:`ghost`,className:`absolute right-2 top-1/2 z-20 -translate-y-1/2 text-white/90 hover:bg-white/10 hover:text-white sm:right-6`,"aria-label":`Next image`,onClick:()=>l(1),children:(0,Y.jsx)(ii,{className:`size-5`})}),t[25]=i.images.length,t[26]=x);let S;return t[27]!==b||t[28]!==x||t[29]!==p||t[30]!==m?(S=(0,Y.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/75 px-4 py-6 [-webkit-app-region:no-drag]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Expanded image preview`,children:[p,m,b,x]}),t[27]=b,t[28]=x,t[29]=p,t[30]=m,t[31]=S):S=t[31],S}),jO=class extends Error{constructor(e){super(e),this.name=`ContextHandoffChunkError`}};async function MO(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e));return Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,`0`)).join(``)}async function NO(e){let t=[],n=0,r=null,i=null;for(;;){if(e.signal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let a=await e.read(n);if(a.offset!==n)throw new jO(`The server returned a gap or overlapping chunk.`);if(r!==null&&a.digest!==r)throw new jO(`The artifact digest changed during transfer.`);if(i!==null&&a.totalBytes!==i)throw new jO(`The artifact size changed during transfer.`);r=a.digest,i=a.totalBytes;let o=new TextEncoder().encode(a.chunk).byteLength,s=n+o;if(t.push(a.chunk),e.onProgress?.(s,a.totalBytes),a.nextOffset===null){if(s!==a.totalBytes)throw new jO(`The final chunk does not match the artifact size.`);break}if(a.nextOffset!==s||a.nextOffset<=n)throw new jO(`The server returned a non-sequential chunk offset.`);n=a.nextOffset}let a=t.join(``);if(await MO(a)!==r)throw new jO(`The downloaded artifact failed integrity verification.`);return{text:a,digest:r,totalBytes:i}}async function PO(e){let t=null,n=await NO({read:async n=>{let r=await e.read(n);if(t!==null&&r.filename!==t)throw new jO(`The export filename changed during transfer.`);return t=r.filename,r},...e.signal?{signal:e.signal}:{},...e.onProgress?{onProgress:e.onProgress}:{}}),r=t??``,i=`.${e.expectedExtension}`;if(!/^ryco-context-handoff-[a-zA-Z0-9_-]+-(sent|complete)\.(md|json)$/.test(r)||!r.endsWith(i))throw new jO(`The server returned an unsafe export filename.`);return{blob:new Blob([n.text],{type:e.expectedExtension===`md`?`text/markdown;charset=utf-8`:`application/json`}),filename:r}}function FO(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),queueMicrotask(()=>URL.revokeObjectURL(n))}var IO={messages:`Messages`,plans:`Plans`,tools:`Tools and terminal results`,checkpoints:`Checkpoints and changed files`,notices:`Notices and pending questions`,subagents:`Subagents`,priorHandoffs:`Prior handoffs`,triggeringMessage:`Triggering user message`},LO={sent:`Sent to model`,"prepared-not-sent":`Prepared, not sent`,"prepared-not-accepted":`Prepared payload, not accepted`,"delivery-uncertain":`Attempted payload; delivery uncertain`};function RO(e){return e instanceof Error?e.message:`The context artifact could not be loaded.`}function zO(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function BO(e,t){if(!t||typeof t!=`object`)return(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-xs`,children:String(t)});let n=t,r=typeof n.text==`string`?n.text:null,i=typeof n.summary==`string`?n.summary:null,a=typeof n.command==`string`?n.command:null,o=typeof n.output==`string`?n.output:null;return e===`messages`||e===`triggeringMessage`?(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:typeof n.role==`string`?n.role:`Message`}),(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-6`,children:r})]}):e===`tools`?(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[i?(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:i}):null,a?(0,Y.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-muted/55 p-2 text-xs`,children:a}):null,o?(0,Y.jsx)(`pre`,{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-muted/35 p-2 text-xs`,children:o}):null]}):(0,Y.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted/35 p-2 text-xs leading-5`,children:JSON.stringify(t,null,2)})}function VO(e){let t=(0,q.useMemo)(()=>We(e.environmentId).contextHandoff,[e.environmentId]),n=(0,q.useRef)(0),r=(0,q.useRef)(null),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(`sent`),[u,d]=(0,q.useState)(`readable`),[f,p]=(0,q.useState)({}),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(`idle`),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(0),[w,T]=(0,q.useState)(null),E=(0,q.useCallback)(async()=>{let r=++n.current;s(null),a(null);try{let i=await t.getInspectionSummary({threadId:e.threadId,handoffId:e.marker.handoffId});if(n.current!==r)return;a(i),l(i.status===`consumed`&&i.sent.available?`sent`:`complete`)}catch(e){n.current===r&&s(RO(e))}},[t,e.marker.handoffId,e.threadId]);(0,q.useEffect)(()=>(E(),r.current?.focus(),()=>{n.current+=1}),[E]),(0,q.useEffect)(()=>{p({}),h(null),_(`idle`),y(null),T(null)},[c]);let D=(0,q.useCallback)(async(r,a=null)=>{let o=`${c}:${r}`,s=n.current;p(e=>({...e,[o]:{entries:a?e[o]?.entries??[]:[],nextCursor:a,loading:!0,error:null}}));try{let l=await t.listInspectionEntries({threadId:e.threadId,handoffId:e.marker.handoffId,scope:c,section:r,...a?{cursor:a}:{}});if(n.current!==s||l.artifactDigest!==i?.[c].digest)return;p(e=>({...e,[o]:{entries:a?[...e[o]?.entries??[],...l.entries]:l.entries,nextCursor:l.nextCursor,loading:!1,error:null}}))}catch(e){if(n.current!==s)return;p(t=>({...t,[o]:{entries:t[o]?.entries??[],nextCursor:a,loading:!1,error:RO(e)}}))}},[t,e.marker.handoffId,e.threadId,c,i]),O=(0,q.useCallback)(async()=>{let r=n.current;_(`loading`),y(null);try{let i=await NO({read:n=>t.readRawPayloadChunk({threadId:e.threadId,handoffId:e.marker.handoffId,scope:c,offset:n})});if(n.current!==r)return;h({text:i.text,digest:i.digest}),_(`idle`)}catch(e){if(n.current!==r)return;_(`error`),y(RO(e))}},[t,e.marker.handoffId,e.threadId,c]);(0,q.useEffect)(()=>{u===`raw`&&i?.[c].available===!0&&m===null&&g===`idle`&&O()},[O,m,g,c,i,u]);let k=(0,q.useCallback)(async n=>{x(n),C(0),T(null);try{let r=await PO({read:r=>t.readExportChunk({threadId:e.threadId,handoffId:e.marker.handoffId,scope:c,format:n,offset:r}),expectedExtension:n===`markdown`?`md`:`json`,onProgress:(e,t)=>C(t===0?1:Math.min(1,e/t))});FO(r.blob,r.filename)}catch(e){T(RO(e))}finally{x(null)}},[t,e.marker.handoffId,e.threadId,c]),A=i?.[c]??null,j=i?.sources??e.marker.sources,M=i?.target??e.marker.target;return(0,Y.jsxs)(`section`,{"aria-label":`Context handoff inspector`,className:`flex min-h-0 w-full flex-1 flex-col bg-background`,onKeyDown:t=>{t.key===`Escape`&&e.onClose()},children:[(0,Y.jsxs)(`header`,{className:`shrink-0 border-b border-border px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Context handoff`}),(0,Y.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-1.5 text-sm font-medium`,children:[j.map(e=>(0,Y.jsx)(QD,{endpoint:e,className:`max-w-44`},`${e.providerInstanceId}:${e.modelSlug}`)),(0,Y.jsx)(fl,{className:`size-3.5 text-muted-foreground`}),(0,Y.jsx)(QD,{endpoint:M,className:`max-w-44`})]})]}),(0,Y.jsx)(K,{ref:r,type:`button`,size:`icon`,variant:`ghost`,"aria-label":`Close context handoff inspector`,onClick:e.onClose,children:(0,Y.jsx)($a,{})})]}),i?(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-foreground`,children:[(0,Y.jsx)(ji,{className:`size-3.5`}),LO[i.deliveryLabel]]}),(0,Y.jsx)(`span`,{children:new Date(i.updatedAt).toLocaleString()})]}):null]}),o?(0,Y.jsxs)(`div`,{className:`m-4 rounded-lg border border-destructive/25 bg-destructive/5 p-3 text-sm`,children:[(0,Y.jsx)(`p`,{children:o}),(0,Y.jsxs)(K,{className:`mt-3`,size:`sm`,variant:`outline`,onClick:()=>void E(),children:[(0,Y.jsx)(Ia,{}),` Retry`]})]}):i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`shrink-0 space-y-3 border-b border-border px-4 py-3`,children:[(0,Y.jsx)(`div`,{className:`grid grid-cols-2 rounded-lg bg-muted/55 p-1`,children:[`sent`,`complete`].map(e=>{let t=i[e].available;return(0,Y.jsx)(`button`,{type:`button`,disabled:!t,onClick:()=>l(e),className:G(`rounded-md px-2 py-1.5 text-xs font-medium transition-colors`,c===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`,!t&&`cursor-not-allowed opacity-45`),children:e===`sent`?`Sent to model`:`Complete artifact`},e)})}),A?.available?(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[A.entryCount,` context entries`]}),(0,Y.jsx)(`span`,{children:zO(A.byteCount)}),A.truncated?(0,Y.jsx)(`span`,{children:`Trimmed to the target input budget`}):null]}):(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Exact sent payload unavailable for this handoff. The complete artifact remains available when it was prepared.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex rounded-md border border-border p-0.5`,children:[`readable`,`raw`].map(e=>(0,Y.jsx)(`button`,{type:`button`,disabled:!A?.available,onClick:()=>d(e),className:G(`rounded px-2 py-1 text-xs`,u===e?`bg-muted font-medium`:`text-muted-foreground`),children:e===`readable`?`Readable`:`Raw payload`},e))}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsxs)(K,{size:`sm`,variant:`outline`,disabled:!A?.available||b!==null,onClick:()=>void k(`markdown`),children:[b===`markdown`?(0,Y.jsx)(Xr,{className:`animate-spin`}):(0,Y.jsx)(qi,{}),`Markdown`]}),(0,Y.jsxs)(K,{size:`sm`,variant:`outline`,disabled:!A?.available||b!==null,onClick:()=>void k(`json`),children:[b===`json`?(0,Y.jsx)(Xr,{className:`animate-spin`}):(0,Y.jsx)(bl,{}),`JSON`]})]})]}),(0,Y.jsxs)(`p`,{className:`flex items-start gap-1.5 text-[11px] leading-4 text-muted-foreground`,children:[(0,Y.jsx)(Ra,{className:`mt-0.5 size-3 shrink-0`}),`Exports may contain conversation text, commands, tool output, and repository paths.`]}),b?(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Verifying export… `,Math.round(S*100),`%`]}):null,w?(0,Y.jsx)(`p`,{className:`text-xs text-destructive`,children:w}):null]}),(0,Y.jsx)(bs,{children:(0,Y.jsx)(`div`,{className:`space-y-2 p-4`,children:u===`raw`?g===`loading`?(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Y.jsx)(Xr,{className:`size-4 animate-spin`}),` Loading and verifying raw payload…`]}):g===`error`?(0,Y.jsxs)(`div`,{className:`text-sm text-destructive`,children:[(0,Y.jsx)(`p`,{children:v}),(0,Y.jsx)(K,{className:`mt-2`,size:`sm`,variant:`outline`,onClick:()=>void O(),children:`Retry`})]}):m?(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Verified SHA-256 ·`,` `,(0,Y.jsxs)(`span`,{className:`font-mono`,children:[m.digest.slice(0,16),`…`]})]}),(0,Y.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted/40 p-3 text-xs leading-5`,children:m.text})]}):null:A?.available?A.sections.map(e=>{let t=`${c}:${e.section}`,n=f[t];return(0,Y.jsxs)(`details`,{className:`group rounded-lg border border-border bg-card/35`,onToggle:t=>{t.currentTarget.open&&!n&&D(e.section)},children:[(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2.5 text-sm font-medium`,children:[(0,Y.jsx)(`span`,{children:IO[e.section]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.entryCount,(0,Y.jsx)(Zr,{className:`size-3.5 transition-transform group-open:rotate-180`})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3 border-t border-border px-3 py-3`,children:[n?.entries.map(t=>(0,Y.jsx)(`article`,{className:`rounded-md bg-muted/25 p-2.5`,children:BO(e.section,t.value)},t.id)),n?.loading?(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(Xr,{className:`size-3.5 animate-spin`}),` Loading…`]}):null,n?.error?(0,Y.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}):null,n?.nextCursor&&!n.loading?(0,Y.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>void D(e.section,n.nextCursor),children:`Load more`}):null]})]},t)}):null})})]}):(0,Y.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,Y.jsx)(Xr,{className:`size-4 animate-spin`}),` Loading context artifact…`]})]})}function HO({open:e,environmentId:t,projectId:n,threadId:r,cwd:i,initialReference:a,onOpenChange:o,onPrepared:s}){let c=(0,q.useRef)(null),[l,u]=(0,q.useState)(a??``),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(null),[h,g]=it(l,{wait:450},e=>({isPending:e.isPending})),{data:_=null}=ie({environmentId:t,cwd:i}),v=(0,q.useMemo)(()=>vr(_?.sourceControlProvider),[_?.sourceControlProvider]),y=v.terminology,b=v.Icon;(0,q.useEffect)(()=>{e&&(u(a??``),f(!1),m(null))},[a,e]),(0,q.useEffect)(()=>{if(!e)return;let t=window.requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()});return()=>{window.cancelAnimationFrame(t)}},[e]);let x=zu(l),S=zu(h),C=Tu({environmentId:t,cwd:i,reference:e?S:null}),w=Eu({environmentId:t,cwd:i,reference:x})?.pullRequest??null,T=Du({mutationFn:e=>{if(!i||!t)throw Error(`Pull request thread preparation is unavailable.`);return We(t).git.preparePullRequestThread({cwd:i,reference:e.reference,mode:e.mode,...n?{projectId:n}:{},...e.threadId?{threadId:e.threadId}:{}})},invalidates:i?[we(i)]:[]}),E=(x!==null&&x===S?C.data?.pullRequest??null:null)??w,D=e&&x!==null&&E===null&&(g.state.isPending||x!==S||C.isPending||C.isFetching),O=(0,q.useMemo)(()=>{switch(E?.state){case`merged`:return`text-violet-600 dark:text-violet-300/90`;case`closed`:return`text-zinc-500 dark:text-zinc-400/80`;case`open`:return`text-emerald-600 dark:text-emerald-300/90`;default:return`text-muted-foreground`}},[E?.state]),k=(0,q.useCallback)(async e=>{if(!x){f(!0);return}if(!(!x||!E||!i)){m(e);try{let t=await T.mutateAsync({reference:x,mode:e,...e===`worktree`?{threadId:r}:{}});await s({branch:t.branch,worktreePath:t.worktreePath}),o(!1)}finally{m(null)}}},[i,o,s,x,T,E,r]),A=(d?l.trim().length===0?`Paste a ${y.singular} URL, checkout command, or enter 123 / #123.`:x===null?`Use a ${y.singular} URL, checkout command, 123, or #123.`:null:null)??(E===null&&C.isError?C.error instanceof Error?C.error.message:`Failed to resolve ${y.singular}.`:T.error instanceof Error?T.error.message:T.error?`Failed to prepare ${y.singular} thread.`:null);return(0,Y.jsx)(Qs,{open:e,onOpenChange:e=>{T.isPending||o(e)},children:(0,Y.jsxs)(Zs,{className:`project-glass-surface max-w-xl`,surface:`glass`,children:[(0,Y.jsxs)(Ks,{children:[(0,Y.jsxs)(qs,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`size-4`}),`Checkout `,y.singular]}),(0,Y.jsxs)(Xs,{children:[`Resolve a `,v.providerName,` `,y.singular,`, then create the draft thread in the main repo or in a dedicated worktree.`]})]}),(0,Y.jsxs)(Ys,{className:`space-y-4`,children:[(0,Y.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground capitalize`,children:y.singular}),(0,Y.jsx)(ys,{ref:c,placeholder:`${y.shortLabel} URL, checkout command, or #42`,value:l,onChange:e=>{f(!0),u(e.target.value)},onKeyDown:e=>{e.key!==`Enter`||!jo(e)||(e.preventDefault(),!D&&!T.isPending&&k(`local`))}})]}),E?(0,Y.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-muted/24 p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`truncate font-medium text-sm`,children:E.title}),(0,Y.jsxs)(`p`,{className:`truncate text-muted-foreground text-xs`,children:[`#`,E.number,` · `,E.headBranch,` to`,` `,E.baseBranch]})]}),(0,Y.jsx)(`span`,{className:G(`shrink-0 text-xs capitalize`,O),children:E.state})]})}):null,D?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground text-xs`,children:[(0,Y.jsx)(lc,{className:`size-3.5`}),`Resolving `,y.singular,`...`]}):null,A?(0,Y.jsx)(`p`,{className:`text-destructive text-xs`,children:A}):null]}),(0,Y.jsxs)(Js,{children:[(0,Y.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!1),disabled:T.isPending,children:`Cancel`}),(0,Y.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>{k(`local`)},disabled:!i||!E||D||T.isPending,children:p===`local`?`Preparing local...`:`Local`}),(0,Y.jsx)(K,{type:`button`,size:`sm`,onClick:()=>{k(`worktree`)},disabled:!i||!E||D||T.isPending,children:p===`worktree`?`Preparing worktree...`:`Worktree`})]})]})})}var UO=(0,q.memo)(function(e){let t=(0,J.c)(108),{planMarkdown:n,environmentId:r,cwd:i,workspaceRoot:a}=e,[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={onError:WO},t[0]=m):m=t[0];let{copyToClipboard:h,isCopied:g}=ks(m),_=(0,q.useId)(),v;t[1]===n?v=t[2]:(v=pu(n)??`Proposed plan`,t[1]=n,t[2]=v);let y=v,b;t[3]===n?b=t[4]:(b=n.split(`
|
|
22
|
-
`),t[3]=n,t[4]=b);let x=b.length,S=n.length>900||x>20,C;t[5]===n?C=t[6]:(C=mu(n),t[5]=n,t[6]=C);let w=C,T;t[7]!==S||t[8]!==n?(T=S?hu(n,{maxLines:10}):null,t[7]=S,t[8]=n,t[9]=T):T=t[9];let E=T,D;t[10]===n?D=t[11]:(D=bu(n),t[10]=n,t[11]=D);let O=D,k;t[12]===n?k=t[13]:(k=xu(n),t[12]=n,t[13]=k);let A=k,j;t[14]!==O||t[15]!==A?(j=()=>{Su(O,A)},t[14]=O,t[15]=A,t[16]=j):j=t[16];let M=j,N;t[17]!==h||t[18]!==A?(N=()=>{h(A)},t[17]=h,t[18]=A,t[19]=N):N=t[19];let P=N,F;t[20]!==O||t[21]!==a?(F=()=>{if(!a){Ai.add(As({type:`error`,title:`Workspace path is unavailable`,description:`This thread does not have a workspace path to save into.`}));return}d(e=>e.length>0?e:O),l(!0)},t[20]=O,t[21]=a,t[22]=F):F=t[22];let I=F,ee;t[23]!==r||t[24]!==A||t[25]!==u||t[26]!==a?(ee=()=>{let e=Be(r),t=u.trim();if(!(!e||!a)){if(!t){Ai.add({type:`warning`,title:`Enter a workspace path`});return}p(!0),e.projects.writeFile({cwd:a,relativePath:t,contents:A}).then(e=>{l(!1),Ai.add({type:`success`,title:`Plan saved to workspace`,description:e.relativePath})}).catch(GO).then(()=>{p(!1)},()=>{p(!1)})}},t[23]=r,t[24]=A,t[25]=u,t[26]=a,t[27]=ee):ee=t[27];let L=ee,R;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Y.jsx)(jc,{variant:`secondary`,children:`Plan`}),t[28]=R):R=t[28];let te;t[29]===y?te=t[30]:(te=(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[R,(0,Y.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground`,children:y})]}),t[29]=y,t[30]=te);let z;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Y.jsx)(oc,{render:(0,Y.jsx)(K,{"aria-label":`Plan actions`,size:`icon-xs`,variant:`outline`}),children:(0,Y.jsx)(Vi,{"aria-hidden":`true`,className:`size-4`})}),t[31]=z):z=t[31];let ne=g?`Copied!`:`Copy to clipboard`,B;t[32]!==P||t[33]!==ne?(B=(0,Y.jsx)(sc,{onClick:P,children:ne}),t[32]=P,t[33]=ne,t[34]=B):B=t[34];let re;t[35]===M?re=t[36]:(re=(0,Y.jsx)(sc,{onClick:M,children:`Download as markdown`}),t[35]=M,t[36]=re);let V=!a||f,H;t[37]!==I||t[38]!==V?(H=(0,Y.jsx)(sc,{onClick:I,disabled:V,children:`Save to workspace`}),t[37]=I,t[38]=V,t[39]=H):H=t[39];let ie;t[40]!==B||t[41]!==re||t[42]!==H?(ie=(0,Y.jsxs)(rc,{children:[z,(0,Y.jsxs)(ec,{align:`end`,children:[B,re,H]})]}),t[40]=B,t[41]=re,t[42]=H,t[43]=ie):ie=t[43];let ae;t[44]!==te||t[45]!==ie?(ae=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[te,ie]}),t[44]=te,t[45]=ie,t[46]=ae):ae=t[46];let U=S&&!o&&`max-h-104 overflow-hidden`,oe;t[47]===U?oe=t[48]:(oe=G(`relative`,U),t[47]=U,t[48]=oe);let se;t[49]!==S||t[50]!==E||t[51]!==i||t[52]!==w||t[53]!==r||t[54]!==o?(se=S&&!o?(0,Y.jsx)(ua,{text:E??``,cwd:i,environmentId:r,isStreaming:!1}):(0,Y.jsx)(ua,{text:w,cwd:i,environmentId:r,isStreaming:!1}),t[49]=S,t[50]=E,t[51]=i,t[52]=w,t[53]=r,t[54]=o,t[55]=se):se=t[55];let ce;t[56]!==S||t[57]!==o?(ce=S&&!o?(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-24 bg-linear-to-t from-card/95 via-card/80 to-transparent`}):null,t[56]=S,t[57]=o,t[58]=ce):ce=t[58];let le;t[59]!==oe||t[60]!==se||t[61]!==ce?(le=(0,Y.jsxs)(`div`,{className:oe,children:[se,ce]}),t[59]=oe,t[60]=se,t[61]=ce,t[62]=le):le=t[62];let ue;t[63]!==S||t[64]!==o?(ue=S?(0,Y.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Y.jsx)(K,{size:`sm`,variant:`outline`,"data-scroll-anchor-ignore":!0,onClick:()=>s(KO),children:o?`Collapse plan`:`Expand plan`})}):null,t[63]=S,t[64]=o,t[65]=ue):ue=t[65];let de;t[66]!==le||t[67]!==ue?(de=(0,Y.jsxs)(`div`,{className:`mt-4`,children:[le,ue]}),t[66]=le,t[67]=ue,t[68]=de):de=t[68];let fe;t[69]===f?fe=t[70]:(fe=e=>{f||l(e)},t[69]=f,t[70]=fe);let pe;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Y.jsx)(qs,{children:`Save plan to workspace`}),t[71]=pe):pe=t[71];let me=a??`the workspace`,he;t[72]===me?he=t[73]:(he=(0,Y.jsxs)(Ks,{children:[pe,(0,Y.jsxs)(Xs,{children:[`Enter a path relative to `,(0,Y.jsx)(`code`,{children:me}),`.`]})]}),t[72]=me,t[73]=he);let ge;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Workspace path`}),t[74]=ge):ge=t[74];let _e;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>d(e.target.value),t[75]=_e):_e=t[75];let ve;t[76]!==O||t[77]!==f||t[78]!==u||t[79]!==_?(ve=(0,Y.jsx)(ys,{id:_,value:u,onChange:_e,placeholder:O,spellCheck:!1,disabled:f}),t[76]=O,t[77]=f,t[78]=u,t[79]=_,t[80]=ve):ve=t[80];let ye;t[81]!==_||t[82]!==ve?(ye=(0,Y.jsx)(Ys,{className:`space-y-3`,children:(0,Y.jsxs)(`label`,{htmlFor:_,className:`grid gap-1.5`,children:[ge,ve]})}),t[81]=_,t[82]=ve,t[83]=ye):ye=t[83];let be;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>l(!1),t[84]=be):be=t[84];let xe;t[85]===f?xe=t[86]:(xe=(0,Y.jsx)(K,{variant:`outline`,size:`sm`,onClick:be,disabled:f,children:`Cancel`}),t[85]=f,t[86]=xe);let Se;t[87]===L?Se=t[88]:(Se=()=>void L(),t[87]=L,t[88]=Se);let Ce=f?`Saving...`:`Save`,we;t[89]!==f||t[90]!==Se||t[91]!==Ce?(we=(0,Y.jsx)(K,{size:`sm`,onClick:Se,disabled:f,children:Ce}),t[89]=f,t[90]=Se,t[91]=Ce,t[92]=we):we=t[92];let Te;t[93]!==xe||t[94]!==we?(Te=(0,Y.jsxs)(Js,{children:[xe,we]}),t[93]=xe,t[94]=we,t[95]=Te):Te=t[95];let Ee;t[96]!==he||t[97]!==ye||t[98]!==Te?(Ee=(0,Y.jsxs)(Zs,{className:`max-w-xl`,children:[he,ye,Te]}),t[96]=he,t[97]=ye,t[98]=Te,t[99]=Ee):Ee=t[99];let De;t[100]!==c||t[101]!==fe||t[102]!==Ee?(De=(0,Y.jsx)(Qs,{open:c,onOpenChange:fe,children:Ee}),t[100]=c,t[101]=fe,t[102]=Ee,t[103]=De):De=t[103];let Oe;return t[104]!==ae||t[105]!==de||t[106]!==De?(Oe=(0,Y.jsxs)(`div`,{className:`rounded-3xl border border-border/80 bg-card/70 p-4 sm:p-5`,children:[ae,de,De]}),t[104]=ae,t[105]=de,t[106]=De,t[107]=Oe):Oe=t[107],Oe});function WO(e){Ai.add(As({type:`error`,title:`Could not copy plan`,description:e instanceof Error?e.message:`An error occurred while copying.`}))}function GO(e){Ai.add(As({type:`error`,title:`Could not save plan`,description:e instanceof Error?e.message:`An error occurred while saving.`}))}function KO(e){return!e}var qO=1e3,JO=e=>{e.current&&Mi.add({data:{tooltipStyle:!0},positionerProps:{anchor:e.current},timeout:qO,title:`Copied!`})},YO=(e,t)=>{e.current&&Mi.add({data:{tooltipStyle:!0},positionerProps:{anchor:e.current},timeout:qO,title:`Failed to copy`,description:t.message})},XO=(0,q.memo)(function(e){let t=(0,J.c)(21),{text:n,size:r,variant:i,className:a,ariaLabel:o}=e,s=r===void 0?`xs`:r,c=i===void 0?`outline`:i,l=o===void 0?`Copy link`:o,u=(0,q.useRef)(null),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={onCopy:()=>JO(u),onError:e=>YO(u,e),timeout:qO},t[0]=d):d=t[0];let{copyToClipboard:f,isCopied:p}=ks(d),m;t[1]!==f||t[2]!==n?(m=()=>f(n),t[1]=f,t[2]=n,t[3]=m):m=t[3];let h;t[4]===a?h=t[5]:(h=G(a),t[4]=a,t[5]=h);let g;t[6]!==l||t[7]!==p||t[8]!==s||t[9]!==m||t[10]!==h||t[11]!==c?(g=(0,Y.jsx)(K,{"aria-label":l,disabled:p,onClick:m,ref:u,type:`button`,size:s,variant:c,className:h}),t[6]=l,t[7]=p,t[8]=s,t[9]=m,t[10]=h,t[11]=c,t[12]=g):g=t[12];let _;t[13]===p?_=t[14]:(_=p?(0,Y.jsx)(Yr,{className:`size-3 text-success`}):(0,Y.jsx)(Li,{className:`size-3`}),t[13]=p,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,Y.jsx)(Fo,{render:g,children:_}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Y.jsx)(Io,{children:(0,Y.jsx)(`p`,{children:`Copy to clipboard`})}),t[18]=y):y=t[18];let b;return t[19]===v?b=t[20]:(b=(0,Y.jsxs)(Lo,{children:[v,y]}),t[19]=v,t[20]=b),b});function ZO(e){let t=e.replaceAll(`\\`,`/`).split(`/`);for(let e=t.length-1;e>=0;--e){let n=t[e];if(n)return n}return e}function QO(e){return(e??``).replace(/\s+(?:complete|completed|done|finished|success|succeeded|started|running)\s*$/i,``).toLowerCase().replace(/\s+/g,` `).trim()}var $O=new Set([`cat`,`nl`,`head`,`tail`,`sed`,`less`,`more`]),ek=new Set([`rg`,`grep`,`ag`,`ack`]),tk=new Set([`find`,`fd`]),nk=new Set([`ls`]);function rk(e){return $O.has(e)||ek.has(e)||tk.has(e)||nk.has(e)}function ik(e,t=!1){let n=Ok(wk(e)),[r,i]=Ck(pk(n));if($O.has(r))return{verb:t?`Reading`:`Read`,target:lk(i,`file`),fullCommand:e};if(ek.has(r))return{verb:t?`Searching`:`Searched`,target:_k(i),fullCommand:e};if(nk.has(r))return{verb:t?`Listing`:`Listed`,target:lk(i,`directory`),fullCommand:e};if(tk.has(r))return{verb:t?`Finding`:`Found`,target:uk(i,`files`),fullCommand:e};switch(r){case`mkdir`:return{verb:t?`Creating`:`Created`,target:lk(i,`directory`),fullCommand:e};case`rm`:return{verb:t?`Removing`:`Removed`,target:lk(i,`file`),fullCommand:e};case`cp`:case`mv`:return{verb:t?r===`cp`?`Copying`:`Moving`:r===`cp`?`Copied`:`Moved`,target:lk(i,`file`),fullCommand:e};case`git`:return ok(i,e,t);case`node`:case`bun`:case`deno`:case`python`:case`python3`:case`ruby`:case`perl`:return{verb:t?`Running`:`Ran`,target:mk(r,n,i)??fk(n),fullCommand:e};case`osascript`:return{verb:t?`Running`:`Ran`,target:`AppleScript`,fullCommand:e};default:return{verb:t?`Running`:`Ran`,target:fk(n),fullCommand:e}}}function ak(e){let[t]=Ck(pk(Ok(wk(e))));return rk(t)?`inspect`:t===`git`?`git`:t===`gh`||t===`hub`?`github`:`terminal`}function ok(e,t,n){let r=sk(e);switch(r.split(/\s+/,1)[0]?.toLowerCase()??``){case`status`:return{verb:n?`Checking`:`Checked`,target:`git status`,fullCommand:t};case`diff`:return{verb:n?`Comparing`:`Compared`,target:`changes`,fullCommand:t};case`show`:return{verb:n?`Inspecting`:`Inspected`,target:`commit`,fullCommand:t};case`log`:return{verb:n?`Reviewing`:`Reviewed`,target:`git history`,fullCommand:t};case`add`:return{verb:n?`Staging`:`Staged`,target:`changes`,fullCommand:t};case`commit`:return{verb:n?`Committing`:`Committed`,target:`changes`,fullCommand:t};case`push`:return{verb:n?`Pushing`:`Pushed`,target:`to remote`,fullCommand:t};case`pull`:return{verb:n?`Pulling`:`Pulled`,target:`from remote`,fullCommand:t};case`checkout`:case`switch`:return{verb:n?`Switching to`:`Switched to`,target:ck(e),fullCommand:t};default:return{verb:n?`Running`:`Ran`,target:fk(`git ${r}`.trim()),fullCommand:t}}}function sk(e){let t=Sk(e),n=0;for(;n<t.length;){let e=t[n];if(e===`-C`||e===`-c`||e===`--git-dir`||e===`--work-tree`){n+=2;continue}if(e.startsWith(`-C`)||e.startsWith(`-c`)||e.startsWith(`--git-dir=`)||e.startsWith(`--work-tree=`)){n+=1;continue}if(e.startsWith(`--`)){n+=1;continue}break}return t.slice(n).join(` `)}function ck(e){return Sk(e).at(-1)?.trim()||`branch`}function lk(e,t){let n=Sk(e);for(let e=n.length-1;e>=0;--e){let t=n[e].replace(/^['"]|['"]$/g,``);if(!(!t||t.startsWith(`-`)))return dk(t)}return t}function uk(e,t){let n=Sk(e),r=!1;for(let e of n){if(r){r=!1;continue}if(e.startsWith(`-`)){(e===`-maxdepth`||e===`-mindepth`||e===`-name`||e===`-type`||e===`-path`)&&(r=!0);continue}return dk(e)}return t}function dk(e){if(e===`.`)return`current directory`;if(e===`..`)return`parent directory`;let t=e.split(/[\\/]/).filter(Boolean);return t.length<=2?e:t.slice(-2).join(`/`)}function fk(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=140?t:`${t.slice(0,137).trimEnd()}...`}function pk(e){let t=Dk(e);return t?e.slice(0,t.operatorStart).trim():e}function mk(e,t,n){let r=e===`python3`?`python`:e;return hk(t)||gk(n)?`${r} script`:null}function hk(e){return/(^|\s)<<-?\s*['"]?[A-Za-z0-9_]+/.test(e)}function gk(e){return Sk(e).some(e=>e===`-e`||e===`-c`||e.startsWith(`-e=`))}function _k(e){let{pattern:t,path:n}=vk(e);return t&&n?`for ${t} in ${n}`:t?`for ${t}`:n?`in ${n}`:`files`}function vk(e){let t=Sk(e),n=null,r=null,i=!1;for(let e of t){if(i){i=!1;continue}if(e.startsWith(`-`)){(e===`-t`||e===`-g`||e===`--type`||e===`--glob`||e===`--max-count`)&&(i=!0);continue}if(!n){let t=yk(e);if(!t){let t=bk(e);t&&(!r||r===`current directory`)&&(r=t);continue}n=t;continue}(!r||r===`current directory`)&&(r=bk(e)??r)}return n&&r===`current directory`&&xk(n)&&(r=bk(n),n=null),{pattern:n,path:r}}function yk(e){let t=e.trim();return!t||t===`.`||t===`..`||!/[a-z0-9]/i.test(t)?null:t.length>30?`${t.slice(0,27)}...`:t}function bk(e){let t=e.trim();return t?dk(t):null}function xk(e){return e.includes(`/`)||e.startsWith(`.`)||e.includes(`\\`)}function Sk(e){let t=[],n=0;for(;n<e.length;){for(;e[n]===` `;)n+=1;if(n>=e.length)break;let r=e[n];if(r===`"`||r===`'`){n+=1;let i=``;for(;n<e.length&&e[n]!==r;){if(e[n]===`\\`&&n+1<e.length){i+=e[n+1],n+=2;continue}i+=e[n],n+=1}e[n]===r&&(n+=1),t.push(i);continue}let i=``;for(;n<e.length&&e[n]!==` `;)i+=e[n],n+=1;i&&t.push(i)}return t}function Ck(e){let t=e.trim().replace(/\s+/g,` `);if(!t)return[``,``];let n=t.indexOf(` `);return n===-1?[ZO(t).toLowerCase(),``]:[ZO(t.slice(0,n)).toLowerCase(),t.slice(n+1).trim()]}function wk(e){let t=e.trim();if(!t)return t;let n=[`/usr/bin/bash -lc `,`/usr/bin/bash -c `,`/bin/bash -lc `,`/bin/bash -c `,`/usr/bin/zsh -lc `,`/usr/bin/zsh -c `,`/bin/zsh -lc `,`/bin/zsh -c `,`/bin/sh -lc `,`/bin/sh -c `,`bash -lc `,`bash -c `,`zsh -lc `,`zsh -c `,`sh -lc `,`sh -c `],r=t.toLowerCase();for(let e of n)if(r.startsWith(e)){t=t.slice(e.length).trim(),t.length>=2&&(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).trim()),t=Tk(t);break}let i=t.search(/\s*\|\s*/);return i>0&&(t=t.slice(0,i).trim()),t}function Tk(e){let t=e.trim();for(let e=0;e<4;e+=1){let e=Dk(t);if(!e||!Ek(t.slice(0,e.operatorStart).trim()))return t;t=t.slice(e.commandStart).trim()}return t}function Ek(e){let t=e.replace(/\s+/g,` `).trim();return t?/^(?:builtin\s+)?cd\s+/.test(t)||/^(?:source|\.)\s+/.test(t)||/^set\s+[-+][A-Za-z]/.test(t)?!0:/^(?:export\s+)?[A-Za-z_][A-Za-z0-9_]*=\S+(?:\s+[A-Za-z_][A-Za-z0-9_]*=\S+)*$/.test(t):!1}function Dk(e){let t=null;for(let n=0;n<e.length-1;n+=1){let r=e[n];if(r===`\\`&&n+1<e.length){n+=1;continue}if(t){r===t&&(t=null);continue}if(r===`"`||r===`'`){t=r;continue}let i=e[n+1];if(r===`&`&&i===`&`)return{operatorStart:n,commandStart:n+2};if(r===`;`)return{operatorStart:n,commandStart:n+1}}return null}function Ok(e){let t=e.replace(/\s+/g,` `).trim();for(let e=0;e<4;e+=1){let[e,n]=Ck(t),r=e===`env`?kk(n):e===`timeout`||e===`gtimeout`?Ak(n):e===`nice`?jk(n):e===`arch`?Mk(n):e===`command`?n:null;if(!r||r===t)return t;t=r.trim()}return t}function kk(e){let t=Sk(e),n=0;for(;n<t.length;){let e=t[n];if(e===`--`){n+=1;break}if(e===`-u`||e===`--unset`||e===`-C`||e===`--chdir`){n+=2;continue}if(e.startsWith(`--unset=`)||e.startsWith(`--chdir=`)){n+=1;continue}if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e)){n+=1;continue}if(e.startsWith(`-`)){n+=1;continue}break}return n<t.length?t.slice(n).join(` `):null}function Ak(e){let t=Sk(e),n=0;for(;n<t.length&&t[n]?.startsWith(`-`);)n+=t[n]===`-s`||t[n]===`-k`?2:1;return n<t.length&&/^\d+(?:\.\d+)?[smhd]?$/.test(t[n])&&(n+=1),n<t.length?t.slice(n).join(` `):null}function jk(e){let t=Sk(e),n=0;if(t[n]===`-n`)n+=2;else for(;t[n]?.startsWith(`-`);)n+=1;return n<t.length?t.slice(n).join(` `):null}function Mk(e){let t=Sk(e),n=0;for(;t[n]?.startsWith(`-`);)n+=1;return n<t.length?t.slice(n).join(` `):null}function Nk(e){return e.tone===`error`||e.exitCode!==void 0&&e.exitCode!==0?`failed`:e.completed?`completed`:`running`}function Pk(e){switch(e){case`running`:return`Running`;case`completed`:return`Completed`;case`failed`:return`Failed`}}function Fk(e,t){if(!e.startedAt)return null;let n=Date.parse(e.startedAt);if(Number.isNaN(n))return null;let r=e.lastActivityAt??e.createdAt,i=t??Date.parse(r);return Number.isNaN(i)||i<n?null:mo(i-n)}function Ik(e){let t=[Pk(Nk(e))],n=Fk(e);return n&&t.push(`${n} elapsed`),t.join(` · `)}function Lk(e,t){return e===1?t:`${t}s`}function Rk(e){return e.tone===`tool`}var zk=new Set([`Read`,`Reading`]),Bk=new Set([`Searched`,`Searching`,`Found`,`Finding`]);function Vk(e){return zk.has(e)?`read`:Bk.has(e)?`search`:`command`}function Hk(e){if(e.requestKind===`file-change`||e.itemType===`file_change`||(e.changedFiles?.length??0)>0)return`edit`;if(e.requestKind===`file-read`)return`read`;if(e.itemType===`web_search`)return`search`;let t=e.command??e.rawCommand;return e.itemType===`command_execution`||e.requestKind===`command`||t?Vk(t?ik(t).verb:e.toolTitle?.trim().split(/\s+/,1)[0]??``):e.itemType===`collab_agent_tool_call`?`agent`:e.itemType===`mcp_tool_call`||e.itemType===`dynamic_tool_call`?`tool`:`other`}function Uk(e){if(e.changedFiles&&e.changedFiles.length>0)return e.changedFiles;let t=e.command??e.rawCommand;if(t){let e=ik(t).target.trim();if(e.length>0)return[e]}let n=e.detail?.trim();return n?[n]:[]}var Wk=[`command`,`edit`,`read`,`search`,`agent`,`tool`,`other`];function Gk(e,t,n){switch(e){case`command`:return`Ran ${t} ${Lk(t,`command`)}`;case`edit`:return`Edited ${t} ${Lk(t,`file`)}`;case`read`:return`Read ${t} ${Lk(t,`file`)}`;case`search`:return`Searched ${t} ${Lk(t,`file`)}`;case`agent`:return`Ran ${t} agent ${Lk(t,`task`)}`;case`tool`:return`Used ${t} ${Lk(t,`tool`)}`;case`other`:return n?`Ran ${t} tool ${Lk(t,`call`)}`:`${t} other tool ${Lk(t,`call`)}`}}function Kk(e){let t=e.filter(Rk);if(t.length<2||t.length!==e.length)return null;let n=new Map,r=new Map,i=!1;for(let e of t){Nk(e)===`running`&&(i=!0);let t=Hk(e);if(t===`edit`||t===`read`){let i=Uk(e);if(i.length===0){n.set(t,(n.get(t)??0)+1);continue}let a=r.get(t);a||(a=new Set,r.set(t,a));for(let e of i)a.add(e);continue}n.set(t,(n.get(t)??0)+1)}for(let[e,t]of r)n.set(e,(n.get(e)??0)+t.size);let a=Wk.filter(e=>(n.get(e)??0)>0),o=a.map(e=>{let t=n.get(e);return{category:e,count:t,label:Gk(e,t,a.length===1)}});return{label:o.map(e=>e.label).join(`, `),parts:o,entryCount:t.length,hasRunningEntry:i,iconEntry:t[0]}}var qk=`calc(100vh - 18rem)`,Jk=`22rem`,Yk=240;function Xk(e){return`min(${Math.max(1,(e-1)*8)}px, ${qk})`}function Zk(e,t){return t<=1?0:Math.max(0,Math.min(e,t-1))/(t-1)*100}function Qk(e){if(e.itemCount<=0||e.railHeight<=0)return null;if(e.itemCount===1)return 0;let t=Math.max(0,Math.min(1,(e.pointerY-e.railTop)/e.railHeight));return Math.max(0,Math.min(e.itemCount-1,Math.round(t*(e.itemCount-1))))}function $k(e){return!Number.isFinite(e)||e<=0?!1:Math.max(0,(e-Math.min(e,768))/2)>=48}function eA(e){if(!Number.isFinite(e)||e<=0)return 0;let t=Math.max(0,(e-Math.min(e,768))/2);return Math.max(0,Math.min(40,Math.floor(t)-12))}var tA=.1,nA=1;function rA(e){let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||r<=0||n-r<=nA||n-t-r<r*tA}function iA(e,t){return t?Jk:e}function aA(e){return{activeTurnInProgress:e.activeTurnInProgress,activeTurnId:e.activeTurnId,isWorking:e.isWorking,isRevertingCheckpoint:e.isRevertingCheckpoint,openDiffTurnId:e.openDiffTurnId,agentPanelModel:e.agentPanelModel}}function oA(e){return{timestampFormat:e.timestampFormat,routeThreadKey:e.routeThreadKey,markdownCwd:e.markdownCwd,resolvedTheme:e.resolvedTheme,workspaceRoot:e.workspaceRoot,skills:e.skills,activeThreadEnvironmentId:e.activeThreadEnvironmentId,highlightedMessageId:e.highlightedMessageId,threadMessageSearchQuery:e.threadMessageSearchQuery,threadMessageSearchOccurrencesByMessageId:e.threadMessageSearchOccurrencesByMessageId,activeThreadMessageSearchOccurrence:e.activeThreadMessageSearchOccurrence,onRevertUserMessage:e.onRevertUserMessage,onUndoTurn:e.onUndoTurn,onImageExpand:e.onImageExpand,onOpenTurnDiff:e.onOpenTurnDiff,onCloseDiff:e.onCloseDiff,onOpenAgents:e.onOpenAgents,onOpenMessageActions:e.onOpenMessageActions,...e.onInspectContextHandoff?{onInspectContextHandoff:e.onInspectContextHandoff}:{}}}function sA(e){return e.tone===`error`||e.exitCode!==void 0&&e.exitCode!==0}function cA(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];r?.kind===`message`&&r.message.role===`user`&&t.push({id:r.id,rowIndex:n,userText:uA(It(r.message.text).visibleText),assistantText:uA(lA(e,n))})}return t}function lA(e,t){let n=null;for(let r=t+1;r<e.length;r+=1){let t=e[r];if(t?.kind===`message`){if(t.message.role===`user`)break;t.message.role===`assistant`&&(n=t.message.text)}}return n}function uA(e){let t=e?.replace(/\s+/g,` `).trim()??``;return t.length===0?null:t.length<=Yk?t:`${t.slice(0,239)}…`}function dA(e){let t=new Map,n=null;for(let r of e)r.role===`user`&&(n=r.createdAt),t.set(r.id,n??r.createdAt),r.role===`assistant`&&r.completedAt&&(n=r.completedAt);return t}function fA(e){return e.replace(/\s+(?:complete|completed)\s*$/i,``).trim()}function pA({text:e,showCopyButton:t,streaming:n}){let r=e!==null&&e.trim().length>0;return{text:r?e:null,visible:t&&r&&!n}}function mA(e){let t=new Map,n=0;for(let r of e){if(r.kind!==`message`)continue;let{message:e}=r;if(e.role===`user`){n+=1;continue}if(e.role!==`assistant`)continue;let i=e.turnId?`turn:${e.turnId}`:`unkeyed:${n}`;t.set(i,e.id)}return new Set(t.values())}function hA(e,t){let n=Date.parse(e),r=Date.parse(t);return!Number.isFinite(n)||!Number.isFinite(r)?null:Math.max(0,r-n)}function gA(e,t){if(e===null)return t;if(t===null)return e;let n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)?Number.isFinite(r)&&r>n?t:e:t}function _A(e,t){return t===null?e?e.completedAt!==null&&e.state!==`running`?null:e.turnId:null:t}function vA(e){return e.kind===`message`&&e.message.role===`assistant`?e.message.turnId??null:e.kind===`work`?e.entry.turnId??null:null}function yA(e){return e.kind===`message`?e.message.completedAt??e.message.createdAt:e.createdAt}function bA(e){let t=new Map,n=null;for(let r of e.timelineEntries){if(r.kind===`message`&&r.message.role===`user`){n=r.message.createdAt;continue}let i=vA(r);if(!i)continue;let a=t.get(i);a||(a={entries:[],terminalEntry:null,hasStreamingMessage:!1,startBoundary:n},n=null,t.set(i,a)),a.entries.push(r),r.kind===`message`&&(e.terminalAssistantMessageIds.has(r.message.id)&&(a.terminalEntry=r),a.hasStreamingMessage||=r.message.streaming)}let r=new Map;for(let[n,i]of t){let t=n===e.unsettledTurnId;if(!t&&i.hasStreamingMessage)continue;let a=new Set;for(let e of i.entries)(e.kind!==`work`||e.entry.agentSpawn===void 0)&&(t||e.id!==i.terminalEntry?.id)&&a.add(e.id);if(a.size===0)continue;let o=i.entries[0],s=i.entries.at(-1);if(!o||!s)continue;let c=t?`running`:`settled`,l=`turn-fold:${c}:${n}`,u=(e.latestTurn?.turnId===n?e.latestTurn.startedAt:null)??(t?e.activeTurnStartedAt:null)??i.startBoundary??o.createdAt,d=null;if(!t){let t=e.latestTurn?.turnId===n?e.latestTurn.completedAt:null,r=gA(i.terminalEntry?yA(i.terminalEntry):null,yA(s))??yA(s),a=hA(u,t??r),o=a===null?null:mo(a);d=e.latestTurn?.turnId===n&&e.latestTurn.state===`interrupted`?o?`You stopped after ${o}`:`You stopped this response`:o?`Worked for ${o}`:`Worked`}r.set(o.id,{turnId:n,foldId:l,createdAt:o.createdAt,status:c,durationStart:u,label:d,hiddenEntryIds:a,expanded:e.turnFoldExpandedById[l]??t})}return r}function xA(e){let t=new Map,n=null;for(let r of e.timelineEntries){if(r.kind!==`message`)continue;if(r.message.role===`user`){n=r.message.id;continue}if(!n)continue;let i=e.turnDiffSummaryByAssistantMessageId.get(r.message.id);if(!i)continue;let a=i.checkpointTurnCount??e.inferredCheckpointTurnCountByTurnId[i.turnId];typeof a==`number`&&t.set(n,Math.max(0,a-1)),n=null}return t}function SA(e){let t=new Map;for(let n of e.turnDiffSummaries){if(n.status===`missing`||n.status===`error`||n.checkpointRef===void 0||n.checkpointRef.startsWith(`provider-diff:`)||n.files.length===0)continue;let r=n.checkpointTurnCount??e.inferredCheckpointTurnCountByTurnId[n.turnId];typeof r==`number`&&t.set(n.turnId,Math.max(0,r-1))}return t}function CA(e){let t=[],n=dA(e.timelineEntries.flatMap(e=>e.kind===`message`?[e.message]:[])),r=mA(e.timelineEntries),i=_A(e.latestTurn??null,e.runningTurnId??null),a=bA({timelineEntries:e.timelineEntries,terminalAssistantMessageIds:r,latestTurn:e.latestTurn??null,unsettledTurnId:i,activeTurnStartedAt:e.activeTurnStartedAt,turnFoldExpandedById:e.turnFoldExpandedById??{}}),o=new Set;for(let e of a.values())if(!e.expanded)for(let t of e.hiddenEntryIds)o.add(t);let s=!1;for(let i=0;i<e.timelineEntries.length;i+=1){let c=e.timelineEntries[i];if(!c)continue;let l=a.get(c.id);if(l&&(s||=l.status===`running`,t.push({kind:`turn-fold`,id:l.foldId,createdAt:l.createdAt,turnId:l.turnId,foldId:l.foldId,status:l.status,durationStart:l.durationStart,label:l.label,expanded:l.expanded})),o.has(c.id))continue;if(c.kind===`work`){let n=[c.entry],r=i+1;for(;r<e.timelineEntries.length;){let t=e.timelineEntries[r];if(!t||t.kind!==`work`||o.has(t.id)||a.has(t.id))break;n.push(t.entry),r+=1}if(n.length<=1)t.push({kind:`work`,id:c.id,createdAt:c.createdAt,groupedEntries:n});else{let a=`work-group:${c.id}`,o=e.workGroupExpandedById?.[a]??!1,s=n.filter(e=>e.agentSpawn===void 0).slice(0,-1);if(s.length===0){t.push({kind:`work`,id:c.id,createdAt:c.createdAt,groupedEntries:n}),i=r-1;continue}let l=new Set(s.map(e=>e.id)),u=n.filter(e=>e.agentSpawn!==void 0||!l.has(e.id)),d=o?n:u;t.push({kind:`work-toggle`,id:`work-toggle:${c.id}`,createdAt:c.createdAt,groupId:a,hiddenCount:s.length,expanded:o,onlyToolEntries:s.every(e=>e.tone===`tool`),summary:Kk(s)});for(let e of d)t.push({kind:`work`,id:e.id,createdAt:e.createdAt,groupedEntries:[e]})}i=r-1;continue}if(c.kind===`proposed-plan`){t.push({kind:`proposed-plan`,id:c.id,createdAt:c.createdAt,proposedPlan:c.proposedPlan});continue}if(c.kind===`context-compaction`){t.push({kind:`context-compaction`,id:c.id,createdAt:c.createdAt,marker:c.marker});continue}if(c.kind===`context-handoff`){t.push({kind:`context-handoff`,id:c.id,createdAt:c.createdAt,marker:c.marker});continue}let u=c.message.role===`assistant`?e.turnDiffSummaryByAssistantMessageId.get(c.message.id):void 0;t.push({kind:`message`,id:c.id,createdAt:c.createdAt,message:c.message,durationStart:n.get(c.message.id)??c.message.createdAt,showAssistantCopyButton:c.message.role===`assistant`&&r.has(c.message.id),assistantTurnDiffSummary:u,revertTurnCount:c.message.role===`user`?e.revertTurnCountByUserMessageId.get(c.message.id):void 0,assistantUndoTurnCount:u?e.undoTurnCountByTurnId?.get(u.turnId):void 0})}return e.isWorking&&!s&&t.push({kind:`working`,id:`working-indicator-row`,createdAt:e.activeTurnStartedAt}),t}function wA(e,t){let n=new Map,r=e.length!==t.byId.size,i=e.map((e,i)=>{let a=t.byId.get(e.id),o=a&&TA(a,e)?a:e;return n.set(e.id,o),!r&&t.result[i]!==o&&(r=!0),o});return r?{byId:n,result:i}:t}function TA(e,t){if(e.kind!==t.kind||e.id!==t.id)return!1;switch(e.kind){case`working`:return e.createdAt===t.createdAt;case`turn-fold`:{let n=t;return e.createdAt===n.createdAt&&e.foldId===n.foldId&&e.status===n.status&&e.durationStart===n.durationStart&&e.label===n.label&&e.expanded===n.expanded}case`work-toggle`:{let n=t;return e.createdAt===n.createdAt&&e.groupId===n.groupId&&e.hiddenCount===n.hiddenCount&&e.expanded===n.expanded&&e.onlyToolEntries===n.onlyToolEntries&&e.summary?.label===n.summary?.label}case`proposed-plan`:return e.proposedPlan===t.proposedPlan;case`work`:return EA(e,t);case`context-compaction`:return e.marker===t.marker;case`context-handoff`:return e.marker===t.marker;case`message`:{let n=t;return DA(e.message,n.message)&&e.durationStart===n.durationStart&&e.showAssistantCopyButton===n.showAssistantCopyButton&&e.assistantTurnDiffSummary===n.assistantTurnDiffSummary&&e.revertTurnCount===n.revertTurnCount&&e.assistantUndoTurnCount===n.assistantUndoTurnCount}}}function EA(e,t){if(e.createdAt!==t.createdAt||e.groupedEntries.length!==t.groupedEntries.length)return!1;for(let n=0;n<e.groupedEntries.length;n+=1){let r=e.groupedEntries[n],i=t.groupedEntries[n];if(!r||!i||!OA(r,i))return!1}return!0}function DA(e,t){return e===t||e.id===t.id&&e.role===t.role&&e.text===t.text&&jA(e.attachments,t.attachments)&&e.turnId===t.turnId&&e.createdAt===t.createdAt&&e.completedAt===t.completedAt&&e.streaming===t.streaming}function OA(e,t){return e===t||e.id===t.id&&e.createdAt===t.createdAt&&e.label===t.label&&e.detail===t.detail&&e.command===t.command&&e.rawCommand===t.rawCommand&&AA(e.changedFiles,t.changedFiles)&&kA(e.changedFileStats,t.changedFileStats)&&e.completed===t.completed&&e.tone===t.tone&&e.toolTitle===t.toolTitle&&e.itemType===t.itemType&&e.requestKind===t.requestKind&&e.turnId===t.turnId&&e.output===t.output&&e.exitCode===t.exitCode&&e.startedAt===t.startedAt&&e.lastActivityAt===t.lastActivityAt}function kA(e,t){if(e===t)return!0;let n=e?.length??0;if(n!==(t?.length??0))return!1;for(let r=0;r<n;r+=1){let n=e?.[r],i=t?.[r];if(!n||!i||n.path!==i.path||n.kind!==i.kind||n.additions!==i.additions||n.deletions!==i.deletions)return!1}return!0}function AA(e,t){if(e===t)return!0;let n=e?.length??0;if(n!==(t?.length??0))return!1;for(let r=0;r<n;r+=1)if(e?.[r]!==t?.[r])return!1;return!0}function jA(e,t){if(e===t)return!0;let n=e?.length??0;if(n!==(t?.length??0))return!1;for(let r=0;r<n;r+=1){let n=e?.[r],i=t?.[r];if(!n||!i||!MA(n,i))return!1}return!0}function MA(e,t){return e===t?!0:e.type!==t.type||e.id!==t.id||e.name!==t.name||e.mimeType!==t.mimeType||e.sizeBytes!==t.sizeBytes?!1:e.type!==`image`||t.type!==`image`||e.previewUrl===t.previewUrl}function NA(e){let t=(0,J.c)(18),{target:n,onOpenChange:r,revertDisabled:i,onRevert:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={onCopy:FA,onError:PA},t[0]=o):o=t[0];let{copyToClipboard:s}=ks(o),c=n!==null,l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Y.jsxs)(Ic,{children:[(0,Y.jsx)(Rc,{children:`Message actions`}),(0,Y.jsx)(Lc,{className:`sr-only`,children:`Actions for the selected message`})]}),t[1]=l):l=t[1];let u;t[2]!==s||t[3]!==r||t[4]!==n?(u=n?.copyText?(0,Y.jsx)(Bc,{label:n.role===`assistant`?`Copy response`:`Copy message`,icon:(0,Y.jsx)(Li,{"aria-hidden":!0,className:`size-4 shrink-0`}),onClick:()=>{r(!1),s(n.copyText??``)}}):null,t[2]=s,t[3]=r,t[4]=n,t[5]=u):u=t[5];let d;t[6]!==r||t[7]!==a||t[8]!==i||t[9]!==n?(d=n?.role===`user`&&n.canRevert?(0,Y.jsx)(Bc,{label:`Revert to this message`,icon:(0,Y.jsx)(Za,{"aria-hidden":!0,className:`size-4 shrink-0`}),disabled:i,disabledReason:`Reverting is unavailable while the session is busy.`,onClick:()=>{r(!1),a()}}):null,t[6]=r,t[7]=a,t[8]=i,t[9]=n,t[10]=d):d=t[10];let f;t[11]!==u||t[12]!==d?(f=(0,Y.jsx)(Pc,{children:(0,Y.jsxs)(`div`,{role:`group`,"aria-label":`Message actions`,className:`space-y-0.5`,children:[u,d]})}),t[11]=u,t[12]=d,t[13]=f):f=t[13];let p;return t[14]!==r||t[15]!==c||t[16]!==f?(p=(0,Y.jsxs)(Vc,{open:c,onOpenChange:r,label:`Message actions`,children:[l,f]}),t[14]=r,t[15]=c,t[16]=f,t[17]=p):p=t[17],p}function PA(e){Ai.add(As({type:`error`,title:`Failed to copy`,description:e.message}))}function FA(){Ai.add({type:`success`,title:`Copied to clipboard`})}function IA(e){let t=`Context handoff from ${e.sources.map(ZD).join(`, `)} to ${ZD(e.target)}`;return e.status===`failed`?`${t}. Failed${e.error?`: ${e.error}`:``}`:e.status===`delivery-uncertain`?`${t}. Delivery uncertain${e.error?`: ${e.error}`:``}`:`${t}. Completed`}function LA(e){let t=(0,J.c)(36),{marker:n,failed:r,uncertain:i}=e,a=r?`bg-destructive/35`:i?`bg-warning/40`:`bg-border/60`,o;t[0]===a?o=t[1]:(o=G(`h-px min-w-2 flex-1`,a),t[0]=a,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,Y.jsx)(`span`,{className:o,"aria-hidden":!0}),t[2]=o,t[3]=s);let c=r?`text-destructive`:i?`text-warning-foreground`:`text-muted-foreground/75`,l;t[4]===c?l=t[5]:(l=G(`flex min-w-0 max-w-[calc(100%_-_2.5rem)] flex-wrap items-center justify-center gap-x-1.5 gap-y-1 text-[11px] leading-4`,c),t[4]=c,t[5]=l);let u,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Y.jsx)(dl,{className:`size-3.5 shrink-0`}),d=(0,Y.jsx)(`span`,{className:`shrink-0 font-medium`,children:`Context handoff`}),t[6]=u,t[7]=d):(u=t[6],d=t[7]);let f;t[8]===n.sources?f=t[9]:(f=n.sources.map(RA),t[8]=n.sources,t[9]=f);let p;t[10]===f?p=t[11]:(p=(0,Y.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full flex-wrap items-center justify-center gap-x-1.5 gap-y-1`,children:f}),t[10]=f,t[11]=p);let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Y.jsx)(fl,{className:`size-3.5 shrink-0 text-muted-foreground/55`}),t[12]=m):m=t[12];let h=!r&&!i&&`text-foreground/85`,g;t[13]===h?g=t[14]:(g=G(`font-medium`,h),t[13]=h,t[14]=g);let _;t[15]===n.target?_=t[16]:(_=(0,Y.jsx)(QD,{endpoint:n.target,className:`max-w-40 sm:max-w-56`}),t[15]=n.target,t[16]=_);let v;t[17]!==g||t[18]!==_?(v=(0,Y.jsx)(`span`,{className:g,children:_}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==r||t[21]!==i?(y=r?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium`,children:[(0,Y.jsx)(Oi,{className:`size-3`}),`Failed`]}):i?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-warning/15 px-1.5 py-0.5 text-[10px] font-medium`,children:[(0,Y.jsx)(ui,{className:`size-3`}),`Delivery uncertain`]}):null,t[20]=r,t[21]=i,t[22]=y):y=t[22];let b;t[23]!==v||t[24]!==y||t[25]!==l||t[26]!==p?(b=(0,Y.jsxs)(`span`,{className:l,"aria-hidden":!0,children:[u,d,p,m,v,y]}),t[23]=v,t[24]=y,t[25]=l,t[26]=p,t[27]=b):b=t[27];let x=r?`bg-destructive/35`:i?`bg-warning/40`:`bg-border/60`,S;t[28]===x?S=t[29]:(S=G(`h-px min-w-2 flex-1`,x),t[28]=x,t[29]=S);let C;t[30]===S?C=t[31]:(C=(0,Y.jsx)(`span`,{className:S,"aria-hidden":!0}),t[30]=S,t[31]=C);let w;return t[32]!==b||t[33]!==C||t[34]!==s?(w=(0,Y.jsxs)(Y.Fragment,{children:[s,b,C]}),t[32]=b,t[33]=C,t[34]=s,t[35]=w):w=t[35],w}function RA(e,t){return(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[t>0?(0,Y.jsx)(`span`,{className:`text-muted-foreground/45`,children:`,`}):null,(0,Y.jsx)(QD,{endpoint:e,className:`max-w-40 sm:max-w-56`})]},`${e.providerInstanceId}:${e.modelSlug}`)}var zA=(0,q.memo)(function(e){let t=(0,J.c)(43),{marker:n,onInspect:r}=e,i;t[0]===n?i=t[1]:(i=IA(n),t[0]=n,t[1]=i);let a=i,o=n.status===`failed`,s=n.status===`delivery-uncertain`;if(!r){let e;t[2]!==o||t[3]!==n||t[4]!==s?(e=(0,Y.jsx)(LA,{marker:n,failed:o,uncertain:s}),t[2]=o,t[3]=n,t[4]=s,t[5]=e):e=t[5];let r;return t[6]!==a||t[7]!==n.handoffId||t[8]!==n.sources.length||t[9]!==n.status||t[10]!==e?(r=(0,Y.jsx)(`div`,{role:`status`,"aria-label":a,title:a,className:`flex w-full min-w-0 max-w-full items-center gap-2 overflow-hidden py-2 sm:gap-3`,"data-context-handoff-id":n.handoffId,"data-context-handoff-status":n.status,"data-context-handoff-source-count":n.sources.length,children:e}),t[6]=a,t[7]=n.handoffId,t[8]=n.sources.length,t[9]=n.status,t[10]=e,t[11]=r):r=t[11],r}let c;t[12]!==n||t[13]!==r?(c=e=>r(n,e.currentTarget),t[12]=n,t[13]=r,t[14]=c):c=t[14];let l;t[15]!==o||t[16]!==n||t[17]!==s?(l=(0,Y.jsx)(LA,{marker:n,failed:o,uncertain:s}),t[15]=o,t[16]=n,t[17]=s,t[18]=l):l=t[18];let u;t[19]!==a||t[20]!==n.handoffId||t[21]!==n.sources.length||t[22]!==n.status||t[23]!==c||t[24]!==l?(u=(0,Y.jsx)(`button`,{type:`button`,"aria-label":a,onClick:c,className:`group flex w-full min-w-0 max-w-full cursor-pointer items-center gap-2 overflow-hidden rounded-md py-2 outline-none transition-colors hover:bg-foreground/3 focus-visible:ring-1 focus-visible:ring-ring/60 sm:gap-3`,"data-context-handoff-id":n.handoffId,"data-context-handoff-status":n.status,"data-context-handoff-source-count":n.sources.length,children:l}),t[19]=a,t[20]=n.handoffId,t[21]=n.sources.length,t[22]=n.status,t[23]=c,t[24]=l,t[25]=u):u=t[25];let d=u,f;t[26]===d?f=t[27]:(f=(0,Y.jsx)(Fo,{render:d}),t[26]=d,t[27]=f);let p=n.status===`consumed`?`Sent to model`:n.status===`failed`?`Context handoff failed`:`Delivery uncertain`,m;t[28]===p?m=t[29]:(m=(0,Y.jsx)(`p`,{className:`font-medium text-foreground`,children:p}),t[28]=p,t[29]=m);let h;t[30]===n.createdAt?h=t[31]:(h=new Date(n.createdAt).toLocaleString(),t[30]=n.createdAt,t[31]=h);let g;t[32]===h?g=t[33]:(g=(0,Y.jsx)(`p`,{children:h}),t[32]=h,t[33]=g);let _;t[34]===n.inspection?_=t[35]:(_=n.inspection?(0,Y.jsxs)(`p`,{children:[n.inspection.includedEntryCount??n.inspection.completeEntryCount,` of`,` `,n.inspection.completeEntryCount,` context entries`,n.inspection.truncated?` · trimmed to fit`:``]}):(0,Y.jsx)(`p`,{children:`Open to inspect the available context artifact.`}),t[34]=n.inspection,t[35]=_);let v;t[36]!==_||t[37]!==m||t[38]!==g?(v=(0,Y.jsx)(Io,{className:`max-w-80 px-2 py-1.5`,side:`top`,children:(0,Y.jsxs)(`div`,{className:`space-y-1 text-left`,children:[m,g,_]})}),t[36]=_,t[37]=m,t[38]=g,t[39]=v):v=t[39];let y;return t[40]!==v||t[41]!==f?(y=(0,Y.jsxs)(Lo,{children:[f,v]}),t[40]=v,t[41]=f,t[42]=y):y=t[42],y});function BA(){return typeof window>`u`?null:window}function VA(){return typeof document>`u`?null:document}function HA({intervalMs:e,windowTarget:t=BA(),documentTarget:n=VA(),now:r=Date.now}){let i=new Set,a=null,o=!1,s=()=>n?.visibilityState!==`hidden`,c=()=>{let e=r();for(let t of i)t(e)},l=()=>{a===null||!t||(t.clearInterval(a),a=null)},u=()=>{a!==null||!t||i.size===0||!s()||(a=t.setInterval(c,e))},d=()=>{if(!s()){l();return}c(),u()},f=()=>{o||!n||(n.addEventListener(`visibilitychange`,d),o=!0)},p=()=>{!o||!n||(n.removeEventListener(`visibilitychange`,d),o=!1)};return{subscribe(e){i.add(e),f(),e(r()),u();let t=!1;return()=>{t||(t=!0,i.delete(e),i.size===0&&(l(),p()))}}}}var UA=HA({intervalMs:1e3}),WA=/^(.*?)\s+line(?:s)?\s+(\d+)(?:-(\d+))?$/i;function GA(e){return e.map(e=>e.header.trim()).filter(e=>e.length>0).map(KA).join(` `)}function KA(e){let t=e.trim(),n=WA.exec(t);if(!n)return`@${t.toLowerCase().replace(/\s+/g,`-`)}`;let r=Number.parseInt(n[2]??``,10),i=Number.parseInt(n[3]??n[2]??``,10);return!Number.isFinite(r)||!Number.isFinite(i)?`@${t.toLowerCase().replace(/\s+/g,`-`)}`:ln({terminalLabel:n[1]?.trim()||`terminal`,lineStart:r,lineEnd:i})}function qA(e,t){let n=0;for(let r of t){let t=KA(r.header),i=e.indexOf(t,n);if(i===-1)return!1;n=i+t.length}return!0}var JA=`grid transition-[grid-template-rows,opacity] duration-[220ms] ease-out motion-reduce:transition-none`,YA=`grid-rows-[1fr] opacity-100`,XA=`grid-rows-[0fr] opacity-0`,ZA=`min-h-0 overflow-hidden`,QA=`transition-[opacity,transform] duration-[220ms] ease-out motion-reduce:transition-none`,$A=`translate-y-0 opacity-100`,ej=`-translate-y-1 opacity-0 pointer-events-none`,tj=`size-3.5 shrink-0 transition-transform duration-[220ms] ease-out motion-reduce:transition-none`;function nj(e,t){return G(JA,e?YA:XA,t)}function rj(e,t){return G(QA,e?$A:ej,t)}function ij(e,t){return G(tj,e&&`rotate-90`,t)}function aj(e){let t=(0,J.c)(5),{open:n,className:r}=e,i;t[0]!==r||t[1]!==n?(i=ij(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,Y.jsx)(ii,{"aria-hidden":`true`,className:i}),t[3]=i,t[4]=a),a}function oj(e){let t=(0,J.c)(14),{open:n,children:r,className:i,contentClassName:a}=e,o;t[0]!==i||t[1]!==n?(o=nj(n,i),t[0]=i,t[1]=n,t[2]=o):o=t[2];let s=!n||void 0,c=!n,l;t[3]!==a||t[4]!==n?(l=rj(n,a),t[3]=a,t[4]=n,t[5]=l):l=t[5];let u;t[6]!==r||t[7]!==l?(u=(0,Y.jsx)(`div`,{className:ZA,children:(0,Y.jsx)(`div`,{className:l,children:r})}),t[6]=r,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==s||t[11]!==c||t[12]!==u?(d=(0,Y.jsx)(`div`,{className:o,"aria-hidden":s,inert:c,children:u}),t[9]=o,t[10]=s,t[11]=c,t[12]=u,t[13]=d):d=t[13],d}var sj=(0,q.createContext)(null),cj=(0,q.createContext)(null),lj=()=>{},uj=(0,Y.jsx)(`div`,{className:`h-[var(--chat-header-clearance,0.75rem)] sm:h-[var(--chat-header-clearance,1rem)]`}),dj=(0,Y.jsx)(`div`,{className:`h-[var(--chat-composer-clearance,0.75rem)] sm:h-[var(--chat-composer-clearance,1rem)]`}),fj=[],pj=fo(),mj=()=>{},hj=new Map,gj={},_j=1800,vj=`size-6 min-w-6 rounded-md border-0 bg-transparent px-0 text-muted-foreground/45 shadow-none transition-[background-color,color,box-shadow] before:hidden hover:bg-foreground/8 hover:text-foreground/75 hover:shadow-sm/5 focus-visible:ring-1 focus-visible:ring-ring/60 disabled:hover:bg-transparent disabled:hover:text-muted-foreground/35`,yj=(0,q.memo)(function({agentPanelModel:e=pj,onOpenAgents:t=mj,isWorking:n,activeTurnInProgress:r,activeTurnId:i,latestTurn:a=null,activeTurnStartedAt:o,listRef:s,targetMessageId:c=null,targetMessageRequestId:l=0,targetMessageRowHighlight:u=!0,threadMessageSearchQuery:d=``,threadMessageSearchOccurrencesByMessageId:f=hj,activeThreadMessageSearchOccurrence:p=null,timelineEntries:m,turnDiffSummaryByAssistantMessageId:h,openDiffTurnId:g=null,routeThreadKey:_,onOpenTurnDiff:v,onCloseDiff:y,revertTurnCountByUserMessageId:b,undoTurnCountByTurnId:x,onRevertUserMessage:S,onUndoTurn:C,isRevertingCheckpoint:w,onImageExpand:T,activeThreadEnvironmentId:E,markdownCwd:D,resolvedTheme:O,timestampFormat:k,workspaceRoot:A,skills:j=fj,liveFollowEnabled:M=!0,onIsAtEndChange:N,onManualNavigation:P,onUserReachedEnd:F,canLoadOlder:I=!1,isLoadingOlder:ee=!1,loadOlderError:L=null,onLoadOlder:R,onInspectContextHandoff:te}){ti(`MessagesTimeline`);let z=Tr(e=>e.threadTurnFoldExpandedById[_]??gj),ne=Tr(e=>e.threadWorkGroupExpandedById[_]??gj),B=(0,q.useRef)(b);B.current=b;let re=(0,q.useRef)(x);re.current=x;let V=Yj((0,q.useMemo)(()=>CA({timelineEntries:m,latestTurn:a,runningTurnId:n||r?i??null:null,turnFoldExpandedById:z,workGroupExpandedById:ne,isWorking:n,activeTurnStartedAt:o,turnDiffSummaryByAssistantMessageId:h,revertTurnCountByUserMessageId:B.current,undoTurnCountByTurnId:re.current}),[m,a,r,i,z,ne,n,o,h])),H=(0,q.useMemo)(()=>cA(V),[V]),[ie]=(0,q.useState)(()=>new Map),[ae,U]=(0,q.useState)(null),[oe,se]=(0,q.useState)(!1),[ce,le]=(0,q.useState)(0),[ue,de]=(0,q.useState)(null),[fe,pe]=(0,q.useState)(null),me=(0,q.useRef)(!1),he=(0,q.useRef)(null),ge=(0,q.useCallback)(()=>{me.current=!0,he.current!==null&&window.clearTimeout(he.current),he.current=window.setTimeout(()=>{me.current=!1,he.current=null},800)},[]),_e=(0,q.useCallback)(e=>{pe(e)},[]),ve=(0,q.useCallback)(()=>{let e=s.current?.getScrollableNode?.();if(!(e instanceof HTMLElement))return null;let t=rA(e);return N(t),t},[s,N]),ye=(0,q.useCallback)(()=>{let e=ve(),t=s.current?.getScrollableNode?.();t instanceof HTMLElement&&t.scrollTop<=320&&I&&!ee&&R?.(),e===!0&&me.current&&(me.current=!1,he.current!==null&&(window.clearTimeout(he.current),he.current=null),F?.());let n=s.current?.getState?.();if(!n||H.length===0)return;let r=n.scroll??0,i=r+(n.scrollLength??0);for(let e of H){let t=ie.get(e.id);if(!t)continue;let a=xj(n,e.rowIndex),o=Sj(n,e.rowIndex),s=a!==null&&a<i&&a+Math.max(1,o??1)>r;t.dataset.inView=s?`true`:`false`}},[I,ve,ee,s,H,ie,R,F]),be=(0,q.useMemo)(()=>(0,Y.jsxs)(Y.Fragment,{children:[uj,I||ee||L?(0,Y.jsx)(`div`,{className:`mx-auto flex min-h-9 w-full max-w-3xl items-center justify-center px-3 pb-2 text-xs text-muted-foreground`,children:ee?(0,Y.jsx)(`span`,{role:`status`,children:`Loading earlier history…`}):(0,Y.jsx)(K,{size:`sm`,variant:`ghost`,onClick:R,children:L?`Retry earlier history`:`Load earlier history`})}):null]}),[I,ee,L,R]);(0,q.useEffect)(()=>{let e=null,t=null,n=r=>{t=window.requestAnimationFrame(()=>{t=null;let i=s.current?.getScrollableNode?.();if(!(i instanceof HTMLElement)){r>0&&n(r-1);return}let a=()=>i.scrollHeight-i.clientHeight>1,o=()=>!rA(i),c=()=>{ge(),P?.()},l=e=>{if(a()){if(e.deltaY<0){P?.();return}e.deltaY>0&&ge()}},u=()=>{ge(),o()&&P?.()},d=e=>{ge(),(e.target===i?a():o())&&P?.()},f=e=>{switch(e.key){case`PageUp`:case`Home`:case`ArrowUp`:a()&&c();break;case`PageDown`:case`End`:case`ArrowDown`:ge()}};i.addEventListener(`wheel`,l,{passive:!0}),i.addEventListener(`touchmove`,u,{passive:!0}),i.addEventListener(`pointerdown`,d,{passive:!0}),i.addEventListener(`keydown`,f),e=()=>{i.removeEventListener(`wheel`,l),i.removeEventListener(`touchmove`,u),i.removeEventListener(`pointerdown`,d),i.removeEventListener(`keydown`,f)}})};return n(12),()=>{t!==null&&window.cancelAnimationFrame(t),e?.()}},[s,ge,P]),(0,q.useEffect)(()=>()=>{he.current!==null&&window.clearTimeout(he.current)},[]),(0,q.useEffect)(()=>{let e=requestAnimationFrame(ye);return()=>cancelAnimationFrame(e)},[ye,V.length]),(0,q.useEffect)(()=>{if(!ae)return;let e=s.current?.getState?.();if(!e?.listen)return;let t=[e.listen(`totalSize`,ve),e.listen(`headerSize`,ve),e.listen(`footerSize`,ve)];return()=>{for(let e of t)e()}},[ve,s,ae]),(0,q.useEffect)(()=>{if(!ae)return;let e=()=>{let e=ae.getBoundingClientRect().width,t=$k(e);se(e=>e===t?e:t),le(eA(e)),ve()},t=requestAnimationFrame(e),n=new ResizeObserver(e);return n.observe(ae),()=>{cancelAnimationFrame(t),n.disconnect()}},[ve,ae]);let xe=(0,q.useRef)(V.length);(0,q.useEffect)(()=>{let e=xe.current;if(xe.current=V.length,e>0||V.length===0)return;N(!0);let t=window.requestAnimationFrame(()=>{s.current?.scrollToEnd?.({animated:!1})});return()=>{window.cancelAnimationFrame(t)}},[s,N,V.length]),(0,q.useEffect)(()=>{if(c===null){de(null);return}let e=V.findIndex(e=>e.kind===`message`&&e.message.id===c);if(e<0){de(null);return}de(u?c:null),P?.(),s.current?.scrollToIndex?.({animated:!0,index:e,viewPosition:.45});let t=window.requestAnimationFrame(()=>{if(!u){let e=document.querySelector(`[data-thread-message-search-active="true"]`);if(e){e.scrollIntoView({behavior:`smooth`,block:`center`});return}}for(let e of document.querySelectorAll(`[data-message-id]`))if(e.dataset.messageId===c){e.scrollIntoView({behavior:`smooth`,block:`center`});break}}),n=window.setTimeout(()=>{de(e=>e===c?null:e)},_j);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(n)}},[s,P,V,c,l,u]);let Se=(0,q.useMemo)(()=>aA({activeTurnInProgress:r,activeTurnId:i??null,isWorking:n,isRevertingCheckpoint:w,openDiffTurnId:g,agentPanelModel:e}),[r,i,e,n,w,g]),Ce=(0,q.useMemo)(()=>oA({timestampFormat:k,routeThreadKey:_,markdownCwd:D,resolvedTheme:O,workspaceRoot:A,skills:j,activeThreadEnvironmentId:E,highlightedMessageId:ue,threadMessageSearchQuery:d,threadMessageSearchOccurrencesByMessageId:f,activeThreadMessageSearchOccurrence:p,onRevertUserMessage:S,onUndoTurn:C,onImageExpand:T,onOpenTurnDiff:v,onCloseDiff:y??lj,onOpenAgents:t,onOpenMessageActions:_e,...te?{onInspectContextHandoff:te}:{}}),[k,_,D,O,A,j,E,ue,d,f,p,S,C,T,v,y,t,_e,te]),we=(0,q.useCallback)(({item:e})=>(0,Y.jsx)(`div`,{className:`mx-auto w-full min-w-0 max-w-3xl overflow-x-hidden`,"data-timeline-root":`true`,children:(0,Y.jsx)(Oj,{row:e})}),[]);return V.length===0&&!n?(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`h-full`}):(0,Y.jsx)(cj.Provider,{value:Ce,children:(0,Y.jsxs)(sj.Provider,{value:Se,children:[(0,Y.jsxs)(`div`,{ref:U,className:`relative h-full min-h-0`,children:[(0,Y.jsx)(Bi,{ref:s,data:V,keyExtractor:bj,renderItem:we,estimatedItemSize:56,recycleItems:!1,initialScrollAtEnd:!0,maintainScrollAtEnd:M,maintainScrollAtEndThreshold:.1,maintainVisibleContentPosition:!0,onScroll:ye,className:`h-full overflow-x-hidden overscroll-y-contain px-3 [scrollbar-width:none] sm:px-5 [&::-webkit-scrollbar]:hidden`,ListHeaderComponent:be,ListFooterComponent:dj}),(0,Y.jsx)(wj,{hasPersistentGutter:oe,hitStripWidth:ce,items:H,stripMap:ie,onSelect:e=>{ge(),P?.(),s.current?.scrollToIndex({index:e.rowIndex,animated:!0,viewOffset:24})}})]}),(0,Y.jsx)(NA,{target:fe,onOpenChange:e=>{e||pe(null)},revertDisabled:w||n,onRevert:()=>{fe&&S(fe.messageId)}})]})})});function bj(e){return e.id}function xj(e,t){let n=e.positionAtIndex?.(t);return typeof n==`number`&&Number.isFinite(n)?n:null}function Sj(e,t){let n=e.sizeAtIndex?.(t);return typeof n==`number`&&Number.isFinite(n)?n:null}function Cj(e){return e instanceof Element&&e.closest(`[data-minimap-preview]`)!==null}function wj(e){let t=(0,J.c)(56),{hasPersistentGutter:n,hitStripWidth:r,items:i,stripMap:a,onSelect:o}=e,[s,c]=(0,q.useState)(null),l=s!==null&&s<i.length?s:null,u=l===null?null:i[l]??null,d;t[0]!==i.length||t[1]!==l?(d=l===null?0:Zk(l,i.length),t[0]=i.length,t[1]=l,t[2]=d):d=t[2];let f=d,p=l===null?`-50%`:l===0?`0%`:l===i.length-1?`-100%`:`-50%`,m;t[3]===i.length?m=t[4]:(m=e=>{let t=e.currentTarget.getBoundingClientRect();return Qk({itemCount:i.length,railTop:t.top,railHeight:t.height,pointerY:e.clientY})},t[3]=i.length,t[4]=m);let h=m,g;t[5]===h?g=t[6]:(g=e=>{c(h(e))},t[5]=h,t[6]=g);let _=g,v;t[7]===i.length?v=t[8]:(v=e=>{c(t=>{let n=t??0;return Math.max(0,Math.min(i.length-1,n+e))})},t[7]=i.length,t[8]=v);let y=v;if(i.length<2)return null;let b=n?`true`:`false`,x=`Jump to message: ${u?.userText??`User message`}`,S=r>0?`pointer-events-auto`:`pointer-events-none`,C;t[9]===S?C=t[10]:(C=G(`absolute top-1/2 left-3 -translate-y-1/2 cursor-pointer bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70`,S),t[9]=S,t[10]=C);let w;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>c(null),t[11]=w):w=t[11];let T;t[12]!==i||t[13]!==o||t[14]!==h?(T=e=>{if(Cj(e.target))return;let t=h(e),n=t===null?null:i[t]??null;n&&o(n),e.currentTarget.blur()},t[12]=i,t[13]=o,t[14]=h,t[15]=T):T=t[15];let E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>c(Dj),t[16]=E):E=t[16];let D;t[17]!==u||t[18]!==i.length||t[19]!==y||t[20]!==o?(D=e=>{e.key===`ArrowDown`?(e.preventDefault(),y(1)):e.key===`ArrowUp`?(e.preventDefault(),y(-1)):e.key===`Home`?(e.preventDefault(),c(0)):e.key===`End`?(e.preventDefault(),c(i.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u&&o(u))},t[17]=u,t[18]=i.length,t[19]=y,t[20]=o,t[21]=D):D=t[21];let O;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>c(null),t[22]=O):O=t[22];let k;t[23]===i.length?k=t[24]:(k=Xk(i.length),t[23]=i.length,t[24]=k);let A=u!==null,j;t[25]!==r||t[26]!==A?(j=iA(r,A),t[25]=r,t[26]=A,t[27]=j):j=t[27];let M;t[28]!==k||t[29]!==j?(M={height:k,width:j},t[28]=k,t[29]=j,t[30]=M):M=t[30];let N;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-0 left-3 h-full w-px bg-border/15`}),t[31]=N):N=t[31];let P;if(t[32]!==i||t[33]!==l||t[34]!==a){let e;t[36]!==i.length||t[37]!==l||t[38]!==a?(e=(e,t)=>{let n=l===null?null:Math.abs(t-l);return(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:G(`pointer-events-none absolute left-0 h-0.5 -translate-y-1/2 rounded-full bg-muted-foreground/35 transition-[background-color,width] duration-150 data-[in-view=true]:bg-foreground/90`,n===0?`w-6 bg-muted-foreground/75`:n===1?`w-4`:n===2?`w-2.5`:`w-2`),"data-in-view":`false`,"data-minimap-message-id":e.id,"data-minimap-strip":!0,ref:t=>{t?a.set(e.id,t):a.delete(e.id)},style:{top:`${Zk(t,i.length)}%`}},e.id)},t[36]=i.length,t[37]=l,t[38]=a,t[39]=e):e=t[39],P=i.map(e),t[32]=i,t[33]=l,t[34]=a,t[35]=P}else P=t[35];let F;t[40]!==u||t[41]!==p||t[42]!==f?(F=u?(0,Y.jsx)(`span`,{className:`pointer-events-auto absolute left-8 w-80 cursor-text select-text`,"data-minimap-preview":!0,onMouseMove:Tj,style:{top:`${f}%`,transform:`translateY(${p})`},children:(0,Y.jsxs)(`span`,{className:`selection-glass-surface block rounded-xl border p-3 text-left text-popover-foreground`,children:[(0,Y.jsx)(`span`,{className:`block max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium leading-5`,children:u.userText??`User message`}),u.assistantText?(0,Y.jsx)(`span`,{className:`mt-1 max-h-[3.75rem] overflow-hidden text-muted-foreground text-sm leading-5`,style:{display:`-webkit-box`,WebkitBoxOrient:`vertical`,WebkitLineClamp:3},children:u.assistantText}):null]})}):null,t[40]=u,t[41]=p,t[42]=f,t[43]=F):F=t[43];let I;t[44]!==T||t[45]!==D||t[46]!==M||t[47]!==P||t[48]!==F||t[49]!==x||t[50]!==C||t[51]!==_?(I=(0,Y.jsx)(`div`,{className:`relative h-full w-full select-none`,children:(0,Y.jsxs)(`button`,{"aria-label":x,className:C,"data-testid":`timeline-minimap-hit-strip`,onBlur:w,onClick:T,onFocus:E,onKeyDown:D,onMouseDown:Ej,onMouseLeave:O,onMouseMove:_,style:M,type:`button`,children:[N,P,F]})}),t[44]=T,t[45]=D,t[46]=M,t[47]=P,t[48]=F,t[49]=x,t[50]=C,t[51]=_,t[52]=I):I=t[52];let ee;return t[53]!==I||t[54]!==b?(ee=(0,Y.jsx)(`div`,{className:`group/minimap pointer-events-none absolute inset-y-0 left-0 z-40 hidden w-18 opacity-100 [@media(pointer:fine)]:block`,"data-persistent-gutter":b,"data-testid":`timeline-minimap`,children:I}),t[53]=I,t[54]=b,t[55]=ee):ee=t[55],ee}function Tj(e){return e.stopPropagation()}function Ej(e){Cj(e.target)||e.preventDefault()}function Dj(e){return e??0}function Oj(e){let t=(0,J.c)(71),{row:n}=e,r=(0,q.use)(cj),i=(0,q.use)(sj),a;t[0]!==r||t[1]!==i?(a={...r,...i},t[0]=r,t[1]=i,t[2]=a):a=t[2];let o=a,s=Rs()===`phone`,c;t[3]!==o||t[4]!==n?(c=()=>{if(n.kind!==`message`)return;if(n.message.role===`user`){let e=It(n.message.text).copyText??null,t=typeof n.revertTurnCount==`number`;if(e===null&&!t)return;o.onOpenMessageActions({messageId:n.message.id,role:`user`,copyText:e,canRevert:t});return}if(n.message.role!==`assistant`)return;let e=Zj(n,o),t=e.visible?e.text??null:null;t!==null&&o.onOpenMessageActions({messageId:n.message.id,role:`assistant`,copyText:t,canRevert:!1})},t[3]=o,t[4]=n,t[5]=c):c=t[5];let l=!s||n.kind!==`message`,u;t[6]===l?u=t[7]:(u={disabled:l},t[6]=l,t[7]=u);let d=Uc(c,u),f=n.kind===`message`&&o.highlightedMessageId===n.message.id,p;t[8]!==o||t[9]!==n.kind||t[10]!==n.message?(p=n.kind===`message`?o.threadMessageSearchOccurrencesByMessageId.get(n.message.id):void 0,t[8]=o,t[9]=n.kind,t[10]=n.message,t[11]=p):p=t[11];let m=p,h;t[12]!==o||t[13]!==m||t[14]!==n.kind||t[15]!==n.message?(h=n.kind===`message`&&m!==void 0&&m.length>0&&o.threadMessageSearchQuery.trim().length>0?{query:o.threadMessageSearchQuery,activeOccurrenceIndex:o.activeThreadMessageSearchOccurrence?.messageId===n.message.id?o.activeThreadMessageSearchOccurrence.messageOccurrenceIndex:null}:void 0,t[12]=o,t[13]=m,t[14]=n.kind,t[15]=n.message,t[16]=h):h=t[16];let g=h,_=n.kind===`work`?`pb-0.5`:n.kind===`work-toggle`||n.kind===`message`&&n.message.role===`assistant`&&!n.showAssistantCopyButton?`pb-2`:`pb-4`,v=n.kind===`message`?`scroll-mt-12 rounded-xl transition-[background-color,box-shadow] duration-500`:null,y=f?`bg-primary/10 ring-1 ring-primary/30`:null,b=n.kind===`message`&&n.message.role===`assistant`?`group/assistant`:null,x;t[17]!==v||t[18]!==y||t[19]!==b||t[20]!==_?(x=G(_,v,y,b),t[17]=v,t[18]=y,t[19]=b,t[20]=_,t[21]=x):x=t[21];let S=n.kind===`message`?n.message.id:void 0,C=f?`true`:void 0,w=n.kind===`message`?n.message.role:void 0,T;t[22]!==n.groupedEntries||t[23]!==n.kind?(T=n.kind===`work`&&(0,Y.jsx)(Lj,{groupedEntries:n.groupedEntries}),t[22]=n.groupedEntries,t[23]=n.kind,t[24]=T):T=t[24];let E;t[25]===n?E=t[26]:(E=n.kind===`work-toggle`&&(0,Y.jsx)(zj,{row:n}),t[25]=n,t[26]=E);let D;t[27]===n?D=t[28]:(D=n.kind===`turn-fold`&&(0,Y.jsx)(Aj,{row:n}),t[27]=n,t[28]=D);let O;t[29]!==n.createdAt||t[30]!==n.kind||t[31]!==n.marker?(O=n.kind===`context-compaction`&&(0,Y.jsx)(Vj,{createdAt:n.createdAt,label:n.marker.label}),t[29]=n.createdAt,t[30]=n.kind,t[31]=n.marker,t[32]=O):O=t[32];let k;t[33]!==o||t[34]!==n.kind||t[35]!==n.marker?(k=n.kind===`context-handoff`&&(0,Y.jsx)(zA,{marker:n.marker,...o.onInspectContextHandoff?{onInspect:o.onInspectContextHandoff}:{}}),t[33]=o,t[34]=n.kind,t[35]=n.marker,t[36]=k):k=t[36];let A;t[37]!==o||t[38]!==d||t[39]!==g||t[40]!==n.kind||t[41]!==n.message||t[42]!==n.revertTurnCount?(A=n.kind===`message`&&n.message.role===`user`&&(()=>{let e=n.message.attachments??[],t=It(n.message.text),r=t.contexts,i=typeof n.revertTurnCount==`number`;return(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsxs)(`div`,{className:`group flex max-w-[80%] flex-col items-end`,children:[(0,Y.jsxs)(`div`,{className:`relative rounded-2xl rounded-br-sm bg-foreground/8 px-3 py-2 shadow-md/5 transition-[background-color,box-shadow] duration-200 group-hover:bg-foreground/10 group-hover:shadow-lg/8`,...d,children:[e.length>0&&(0,Y.jsx)(`div`,{className:`mb-2 grid max-w-[420px] grid-cols-2 gap-2`,children:e.map(t=>(0,Y.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/80 bg-background/70`,children:t.type===`image`&&t.previewUrl?(0,Y.jsx)(`button`,{type:`button`,className:`h-full w-full cursor-zoom-in`,"aria-label":`Preview ${t.name}`,onClick:()=>{let n=gD(e,t.id);n&&o.onImageExpand(n)},children:(0,Y.jsx)(`img`,{src:t.previewUrl,alt:t.name,className:`block h-auto max-h-[220px] w-full object-cover`})}):t.type===`file`?(0,Y.jsxs)(`div`,{className:`flex min-h-[72px] items-center gap-2 px-3 py-3 text-left text-xs text-foreground/80`,children:[(0,Y.jsx)(Ji,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium`,children:t.name}),(0,Y.jsxs)(`span`,{className:`block text-[10px] text-muted-foreground`,children:[t.mimeType,` · `,Math.ceil(t.sizeBytes/1024),` KB`]})]})]}):(0,Y.jsx)(`div`,{className:`flex min-h-[72px] items-center justify-center px-2 py-3 text-center text-[11px] text-muted-foreground/70`,children:(0,Y.jsxs)(`span`,{children:[t.name,(0,Y.jsx)(`span`,{className:`mt-1 block`,children:`Preview unavailable on this connection.`})]})})},t.id))}),(t.visibleText.trim().length>0||r.length>0)&&(0,Y.jsx)(Jj,{text:t.visibleText,terminalContexts:r,skills:o.skills,searchHighlight:g})]}),(0,Y.jsxs)(`div`,{className:`mt-1 flex items-center justify-end gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 opacity-0 transition-opacity duration-200 focus-within:opacity-100 group-hover:opacity-100 phone:opacity-100`,children:[t.copyText&&(0,Y.jsx)(XO,{text:t.copyText,size:`icon-xs`,variant:`ghost`,className:vj,ariaLabel:`Copy message`}),i&&(0,Y.jsx)(K,{type:`button`,size:`icon-xs`,variant:`ghost`,className:vj,disabled:o.isRevertingCheckpoint||o.isWorking,onClick:()=>o.onRevertUserMessage(n.message.id),title:`Revert to this message`,children:(0,Y.jsx)(Za,{className:`size-3`})})]}),(0,Y.jsxs)(`p`,{className:`text-right text-[11px] text-muted-foreground/50`,children:[n.message.dispatchMode===`steer`?`Steered · `:``,Co(n.message.createdAt,o.timestampFormat)]})]})]})})})(),t[37]=o,t[38]=d,t[39]=g,t[40]=n.kind,t[41]=n.message,t[42]=n.revertTurnCount,t[43]=A):A=t[43];let j;t[44]!==o||t[45]!==d||t[46]!==g||t[47]!==n?(j=n.kind===`message`&&n.message.role===`assistant`&&(()=>{let e=n.message.text||(n.message.streaming?``:`(empty response)`),t=Xj(n,o),r=Zj(n,o);return(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(`div`,{className:`min-w-0 px-1 py-0.5`,...d,children:[(0,Y.jsx)(ua,{text:e,cwd:o.markdownCwd,environmentId:o.activeThreadEnvironmentId,isStreaming:t,skills:o.skills,searchHighlight:g}),!t&&(0,Y.jsx)(Hj,{turnSummary:n.assistantTurnDiffSummary,undoTurnCount:n.assistantUndoTurnCount,routeThreadKey:o.routeThreadKey,resolvedTheme:o.resolvedTheme,openDiffTurnId:o.openDiffTurnId,onOpenTurnDiff:o.onOpenTurnDiff,onCloseDiff:o.onCloseDiff}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30`,children:n.message.streaming?(0,Y.jsx)(Pj,{createdAt:n.message.createdAt,durationStart:n.durationStart,timestampFormat:o.timestampFormat}):tM(n.message.createdAt,bo(n.durationStart,n.message.completedAt),o.timestampFormat)}),r.visible?(0,Y.jsx)(`div`,{className:`flex items-center opacity-0 transition-opacity duration-200 group-hover/assistant:opacity-100 phone:opacity-100`,children:(0,Y.jsx)(XO,{text:r.text??``,size:`icon-xs`,variant:`ghost`,className:vj,ariaLabel:`Copy response`})}):null]})]})})})(),t[44]=o,t[45]=d,t[46]=g,t[47]=n,t[48]=j):j=t[48];let M;t[49]!==o||t[50]!==n.kind||t[51]!==n.proposedPlan?(M=n.kind===`proposed-plan`&&(0,Y.jsx)(`div`,{className:`min-w-0 px-1 py-0.5`,children:(0,Y.jsx)(UO,{planMarkdown:n.proposedPlan.planMarkdown,environmentId:o.activeThreadEnvironmentId,cwd:o.markdownCwd,workspaceRoot:o.workspaceRoot})}),t[49]=o,t[50]=n.kind,t[51]=n.proposedPlan,t[52]=M):M=t[52];let N;t[53]===n?N=t[54]:(N=n.kind===`working`&&(0,Y.jsx)(Mj,{row:n}),t[53]=n,t[54]=N);let P;return t[55]!==n.id||t[56]!==n.kind||t[57]!==x||t[58]!==S||t[59]!==C||t[60]!==w||t[61]!==T||t[62]!==E||t[63]!==D||t[64]!==O||t[65]!==k||t[66]!==A||t[67]!==j||t[68]!==M||t[69]!==N?(P=(0,Y.jsxs)(`div`,{className:x,"data-timeline-row-id":n.id,"data-timeline-row-kind":n.kind,"data-message-id":S,"data-message-highlighted":C,"data-message-role":w,children:[T,E,D,O,k,A,j,M,N]}),t[55]=n.id,t[56]=n.kind,t[57]=x,t[58]=S,t[59]=C,t[60]=w,t[61]=T,t[62]=E,t[63]=D,t[64]=O,t[65]=k,t[66]=A,t[67]=j,t[68]=M,t[69]=N,t[70]=P):P=t[70],P}var kj=`text-[13px] text-muted-foreground/70 tabular-nums`;function Aj(e){let t=(0,J.c)(23),{row:n}=e,{routeThreadKey:r}=(0,q.use)(cj),i=Tr(jj),a=n.status,o=n.expanded,s;t[0]!==r||t[1]!==n.expanded||t[2]!==n.foldId||t[3]!==i?(s=()=>i(r,n.foldId,!n.expanded),t[0]=r,t[1]=n.expanded,t[2]=n.foldId,t[3]=i,t[4]=s):s=t[4];let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=G(kj,`flex cursor-pointer select-none items-center gap-1 pb-2 transition-colors duration-200 hover:text-muted-foreground/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70`),t[5]=c):c=t[5];let l;t[6]!==n.durationStart||t[7]!==n.label||t[8]!==n.status?(l=n.status===`running`?n.durationStart?(0,Y.jsxs)(Y.Fragment,{children:[`Working for `,(0,Y.jsx)(Nj,{createdAt:n.durationStart})]}):`Working…`:n.label??`Worked`,t[6]=n.durationStart,t[7]=n.label,t[8]=n.status,t[9]=l):l=t[9];let u;t[10]===l?u=t[11]:(u=(0,Y.jsx)(`span`,{children:l}),t[10]=l,t[11]=u);let d;t[12]===n.expanded?d=t[13]:(d=(0,Y.jsx)(aj,{open:n.expanded,className:`text-muted-foreground/55`}),t[12]=n.expanded,t[13]=d);let f;t[14]!==n.expanded||t[15]!==s||t[16]!==u||t[17]!==d?(f=(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":o,onClick:s,className:c,children:[u,d]}),t[14]=n.expanded,t[15]=s,t[16]=u,t[17]=d,t[18]=f):f=t[18];let p;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Y.jsx)(`div`,{className:`h-px w-full bg-border`}),t[19]=p):p=t[19];let m;return t[20]!==n.status||t[21]!==f?(m=(0,Y.jsxs)(`div`,{className:`pt-1 pb-2`,"data-turn-fold-status":a,children:[f,p]}),t[20]=n.status,t[21]=f,t[22]=m):m=t[22],m}function jj(e){return e.setThreadTurnFoldExpanded}function Mj(e){let t=(0,J.c)(5),{row:n}=e,r;t[0]===n.createdAt?r=t[1]:(r=n.createdAt?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:G(kj,`flex items-center pb-2`),children:[`Working for `,(0,Y.jsx)(Nj,{createdAt:n.createdAt})]}),(0,Y.jsx)(`div`,{className:`h-px w-full bg-border`})]}):null,t[0]=n.createdAt,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Y.jsx)(`div`,{className:`pt-1.5 text-[13px] text-muted-foreground/70`,children:(0,Y.jsx)(`span`,{className:`shimmer thinking-status-shimmer`,children:`Thinking`})}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Y.jsxs)(`div`,{className:`pt-1 pb-2`,children:[r,i]}),t[3]=r,t[4]=a),a}function Nj(e){let t=(0,J.c)(7),{createdAt:n}=e,r=(0,q.useRef)(null),i;t[0]===n?i=t[1]:(i=$j(n),t[0]=n,t[1]=i);let a=i,o,s;t[2]===n?(o=t[3],s=t[4]):(o=()=>UA.subscribe(e=>{r.current&&(r.current.textContent=$j(n,e))}),s=[n],t[2]=n,t[3]=o,t[4]=s),(0,q.useEffect)(o,s);let c;return t[5]===a?c=t[6]:(c=(0,Y.jsx)(`span`,{ref:r,children:a}),t[5]=a,t[6]=c),c}function Pj(e){let t=(0,J.c)(11),{createdAt:n,durationStart:r,timestampFormat:i}=e,a=(0,q.useRef)(null),o;t[0]!==n||t[1]!==r||t[2]!==i?(o=eM(n,r,i),t[0]=n,t[1]=r,t[2]=i,t[3]=o):o=t[3];let s=o,c,l;t[4]!==n||t[5]!==r||t[6]!==i?(c=()=>{let e=e=>{a.current&&(a.current.textContent=eM(n,r,i,e))};if(!r){e(Date.now());return}return UA.subscribe(e)},l=[n,r,i],t[4]=n,t[5]=r,t[6]=i,t[7]=c,t[8]=l):(c=t[7],l=t[8]),(0,q.useEffect)(c,l);let u;return t[9]===s?u=t[10]:(u=(0,Y.jsx)(`span`,{ref:a,children:s}),t[9]=s,t[10]=u),u}var Fj=`group/tool-row grid min-h-[30px] w-full grid-cols-[1.25rem_minmax(0,1fr)_auto] items-center gap-x-2 rounded-md px-2 text-left`,Ij=`text-muted-foreground/70 transition-colors duration-200 group-hover/tool-row:text-foreground group-focus-visible/tool-row:text-foreground`,Lj=(0,q.memo)(function(e){let t=(0,J.c)(22),{groupedEntries:n}=e,{activeTurnId:r,isWorking:i}=(0,q.use)(sj),{workspaceRoot:a}=(0,q.use)(cj),o=Rs()===`phone`,s;t[0]===n?s=t[1]:(s=n.every(DM),t[0]=n,t[1]=s);let c=s,l=c?`Tool calls`:`Work log`,u;t[2]!==l||t[3]!==n.length||t[4]!==c?(u=!c&&(0,Y.jsx)(`div`,{className:`flex items-center gap-2 px-2`,children:(0,Y.jsxs)(`p`,{className:`text-[9px] uppercase tracking-[0.16em] text-muted-foreground/55`,children:[l,` (`,n.length,`)`]})}),t[2]=l,t[3]=n.length,t[4]=c,t[5]=u):u=t[5];let d;if(t[6]!==r||t[7]!==n||t[8]!==o||t[9]!==i||t[10]!==a){let e;t[12]!==r||t[13]!==o||t[14]!==i||t[15]!==a?(e=e=>{let t=i&&r!=null&&e.turnId===r;return e.agentSpawn&&!o?(0,Y.jsx)(Rj,{workEntry:e},`work-row:${e.id}`):fM(e)&&(e.changedFiles?.length??0)>0?(0,Y.jsx)(yM,{isEditing:t&&!e.completed&&!sA(e),workEntry:e,workspaceRoot:a},`work-row:${e.id}`):(0,Y.jsx)(SM,{workEntry:e,workspaceRoot:a},`work-row:${e.id}`)},t[12]=r,t[13]=o,t[14]=i,t[15]=a,t[16]=e):e=t[16],d=n.map(e),t[6]=r,t[7]=n,t[8]=o,t[9]=i,t[10]=a,t[11]=d}else d=t[11];let f;t[17]===d?f=t[18]:(f=(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:d}),t[17]=d,t[18]=f);let p;return t[19]!==u||t[20]!==f?(p=(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[u,f]}),t[19]=u,t[20]=f,t[21]=p):p=t[21],p}),Rj=(0,q.memo)(function(e){let t=(0,J.c)(44),{workEntry:n}=e,{agentPanelModel:r}=(0,q.use)(sj),{onOpenAgents:i}=(0,q.use)(cj),a=n.agentSpawn;if(!a)return null;let o;t[0]===a.agentTaskIds?o=t[1]:(o=new Set(a.agentTaskIds),t[0]=a.agentTaskIds,t[1]=o);let s=o,c,l,u,d,f,p,m,h,g;if(t[2]!==r||t[3]!==s||t[4]!==i||t[5]!==a.workflowId){let e=a.workflowId?r.workflows.find(e=>e.workflow.id===a.workflowId):void 0,n=e?[...e.phases.flatMap(OM),...e.unphasedMembers]:r.directAgents.filter(e=>s.has(e.id)),o=Math.max(n.length,Math.max(s.size-+!!a.workflowId,0)),_=n.filter(kM).length,v=n.filter(AM).length,y=n.filter(jM).length,b=e?.workflow.status,x=e===void 0?_+v>0:b!==`completed`&&b!==`failed`&&b!==`cancelled`&&b!==`interrupted`,S=n.reduce(MM,a.workflowId&&n.length===0?e?.workflow.usage?.totalTokens??0:0),C=e?.phases.find(NM),w=e?.workflow.workflowName??e?.workflow.title??null,T=_+v,E=x?`bg-info`:y>0?`bg-destructive`:`bg-success`,D=x?`Kicked off ${o} subagent${o===1?``:`s`}`:`Ran ${o} subagent${o===1?``:`s`}`,O=x?C?`${C.title} · ${C.activeCount} working`:T>0?`${T} working`:`Working`:y>0?`${y} failed`:`Completed`;d=`button`,f=i,p=x?`Open the Agents panel`:`View agents`,t[15]===Symbol.for(`react.memo_cache_sentinel`)?(m=G(Hc(`chip`),`group/agent-cta grid min-h-[36px] w-full grid-cols-[1.25rem_minmax(0,1fr)_auto_1.25rem] items-center gap-x-2 rounded-lg border border-border/50 px-2 text-left transition-colors hover:border-border/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70`),t[15]=m):m=t[15],t[16]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Y.jsx)(`span`,{className:`flex size-5 items-center justify-center`,children:(0,Y.jsx)(Jr,{"aria-hidden":!0,className:`size-3.5 text-muted-foreground/70 transition-colors group-hover/agent-cta:text-foreground`})}),t[16]=h):h=t[16];let k;t[17]===E?k=t[18]:(k=G(`size-1.5 shrink-0 rounded-full`,E),t[17]=E,t[18]=k);let A;t[19]===k?A=t[20]:(A=(0,Y.jsx)(`span`,{"aria-hidden":!0,className:k}),t[19]=k,t[20]=A);let j;t[21]===D?j=t[22]:(j=(0,Y.jsx)(`span`,{className:`font-medium text-foreground/90`,children:D}),t[21]=D,t[22]=j);let M=w?(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,w]}):null,N;t[23]!==j||t[24]!==M?(N=(0,Y.jsxs)(`span`,{className:`truncate text-[12px] leading-5`,children:[j,M]}),t[23]=j,t[24]=M,t[25]=N):N=t[25],t[26]!==A||t[27]!==N?(g=(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[A,N]}),t[26]=A,t[27]=N,t[28]=g):g=t[28],c=`flex shrink-0 items-center gap-2 text-[11px] leading-5 text-muted-foreground`,t[29]===O?l=t[30]:(l=(0,Y.jsx)(`span`,{children:O}),t[29]=O,t[30]=l),u=S>0?(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[so(S),` tok`]}):null,t[2]=r,t[3]=s,t[4]=i,t[5]=a.workflowId,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14];let _;t[31]!==c||t[32]!==l||t[33]!==u?(_=(0,Y.jsxs)(`span`,{className:c,children:[l,u]}),t[31]=c,t[32]=l,t[33]=u,t[34]=_):_=t[34];let v;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Y.jsx)(`span`,{className:`flex size-5 items-center justify-center`,children:(0,Y.jsx)(ii,{"aria-hidden":!0,className:`size-3.5 text-muted-foreground/60 transition-[color,translate] group-hover/agent-cta:translate-x-0.5 group-hover/agent-cta:text-foreground`})}),t[35]=v):v=t[35];let y;return t[36]!==_||t[37]!==d||t[38]!==f||t[39]!==p||t[40]!==m||t[41]!==h||t[42]!==g?(y=(0,Y.jsxs)(`button`,{type:d,onClick:f,"aria-label":p,className:m,children:[h,g,_,v]}),t[36]=_,t[37]=d,t[38]=f,t[39]=p,t[40]=m,t[41]=h,t[42]=g,t[43]=y):y=t[43],y});function zj(e){let t=(0,J.c)(23),{row:n}=e,{routeThreadKey:r}=(0,q.use)(cj),i=Tr(Bj),a=n.onlyToolEntries?n.hiddenCount===1?`tool call`:`tool calls`:n.hiddenCount===1?`log entry`:`log entries`,o=n.summary&&!n.summary.hasRunningEntry?n.summary.label:`+${n.hiddenCount} previous ${a}`,s;t[0]===n.summary?s=t[1]:(s=n.summary?cM(n.summary.iconEntry):Zr,t[0]=n.summary,t[1]=s);let c=s,l=n.expanded,u;t[2]!==r||t[3]!==n.expanded||t[4]!==n.groupId||t[5]!==i?(u=()=>i(r,n.groupId,!n.expanded),t[2]=r,t[3]=n.expanded,t[4]=n.groupId,t[5]=i,t[6]=u):u=t[6];let d,f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=G(Fj,`cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70`),f=G(`flex size-5 items-center justify-center`,Ij),t[7]=d,t[8]=f):(d=t[7],f=t[8]);let p;t[9]===c?p=t[10]:(p=(0,Y.jsx)(`span`,{className:f,children:(0,Y.jsx)(c,{className:`size-3.5`,"aria-hidden":!0})}),t[9]=c,t[10]=p);let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=G(`truncate text-[12px] leading-5`,Ij),t[11]=m):m=t[11];let h;t[12]===o?h=t[13]:(h=(0,Y.jsx)(`span`,{className:m,children:o}),t[12]=o,t[13]=h);let g=n.expanded,_;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(_=G(`size-3`,Ij),t[14]=_):_=t[14];let v;t[15]===n.expanded?v=t[16]:(v=(0,Y.jsx)(`span`,{className:`flex size-5 items-center justify-center`,children:(0,Y.jsx)(aj,{open:g,className:_})}),t[15]=n.expanded,t[16]=v);let y;return t[17]!==n.expanded||t[18]!==v||t[19]!==u||t[20]!==p||t[21]!==h?(y=(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":l,onClick:u,"data-work-group-toggle":`true`,className:d,children:[p,h,v]}),t[17]=n.expanded,t[18]=v,t[19]=u,t[20]=p,t[21]=h,t[22]=y):y=t[22],y}function Bj(e){return e.setThreadWorkGroupExpanded}var Vj=(0,q.memo)(function(e){let t=(0,J.c)(16),{createdAt:n,label:r}=e,{timestampFormat:i}=(0,q.use)(cj),a;t[0]!==n||t[1]!==i?(a=Co(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s=`${r} at ${o}`,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Y.jsx)(`span`,{className:`h-px flex-1 bg-border/55`}),t[3]=c):c=t[3];let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Y.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-muted-foreground/35`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,Y.jsx)(`span`,{className:`truncate`,children:r}),t[5]=r,t[6]=u);let d;t[7]===o?d=t[8]:(d=(0,Y.jsx)(`span`,{className:`shrink-0 font-normal normal-case tracking-normal text-muted-foreground/45`,children:o}),t[7]=o,t[8]=d);let f;t[9]!==u||t[10]!==d?(f=(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-2 rounded-full border border-border/60 bg-muted/35 px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground/75`,children:[l,u,d]}),t[9]=u,t[10]=d,t[11]=f):f=t[11];let p;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Y.jsx)(`span`,{className:`h-px flex-1 bg-border/55`}),t[12]=p):p=t[12];let m;return t[13]!==s||t[14]!==f?(m=(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-1.5`,"aria-label":s,children:[c,f,p]}),t[13]=s,t[14]=f,t[15]=m):m=t[15],m}),Hj=(0,q.memo)(function(e){let t=(0,J.c)(9),{turnSummary:n,undoTurnCount:r,routeThreadKey:i,resolvedTheme:a,openDiffTurnId:o,onOpenTurnDiff:s,onCloseDiff:c}=e;if(!n)return null;let l=n.files;if(l.length===0)return null;let u;return t[0]!==l||t[1]!==c||t[2]!==s||t[3]!==o||t[4]!==a||t[5]!==i||t[6]!==n||t[7]!==r?(u=(0,Y.jsx)(Wj,{turnSummary:n,checkpointFiles:l,undoTurnCount:r,routeThreadKey:i,resolvedTheme:a,openDiffTurnId:o,onOpenTurnDiff:s,onCloseDiff:c}),t[0]=l,t[1]=c,t[2]=s,t[3]=o,t[4]=a,t[5]=i,t[6]=n,t[7]=r,t[8]=u):u=t[8],u}),Uj=6;function Wj(e){let t=(0,J.c)(90),{turnSummary:n,checkpointFiles:r,undoTurnCount:i,routeThreadKey:a,resolvedTheme:o,openDiffTurnId:s,onOpenTurnDiff:c,onCloseDiff:l}=e,{onUndoTurn:u}=(0,q.use)(cj),{isRevertingCheckpoint:d}=(0,q.use)(sj),f;t[0]!==a||t[1]!==n.turnId?(f=e=>e.threadChangedFilesExpandedById[a]?.[n.turnId]??!0,t[0]=a,t[1]=n.turnId,t[2]=f):f=t[2];let p=Tr(f),m=Tr(Gj),[h,g]=(0,q.useState)(!1),_,v,y,b,x,S,C,w,T,E,D;if(t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==s||t[7]!==n.turnId||t[8]!==i){let e=pa(r);v=s===n.turnId;let a=`Edited ${r.length} ${r.length===1?`file`:`files`}`,o;t[20]!==r||t[21]!==h?(o=h?r:r.slice(0,Uj),t[20]=r,t[21]=h,t[22]=o):o=t[22],D=o,y=r.length-D.length,_=i!==void 0,E=`chat-final-diff-section mt-2 mb-1 overflow-hidden rounded-[0.65rem] border border-border/70`;let c=p&&`border-b border-border/70`;t[23]===c?T=t[24]:(T=G(`flex items-center justify-between gap-3 bg-muted/40 px-3 py-1.5`,c),t[23]=c,t[24]=T),C=`flex min-w-0 items-center gap-2.5`,t[25]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Y.jsx)(Gi,{className:`size-3.5 shrink-0 text-muted-foreground/70`,"aria-hidden":!0}),t[25]=w):w=t[25],b=`min-w-0`,t[26]===a?x=t[27]:(x=(0,Y.jsx)(`div`,{className:`truncate text-[12px] text-foreground/92`,children:a}),t[26]=a,t[27]=x),S=_a(e)&&(0,Y.jsx)(`div`,{className:`text-[12px] tabular-nums`,children:(0,Y.jsx)(Sa,{additions:e.additions,deletions:e.deletions})}),t[3]=r,t[4]=p,t[5]=h,t[6]=s,t[7]=n.turnId,t[8]=i,t[9]=_,t[10]=v,t[11]=y,t[12]=b,t[13]=x,t[14]=S,t[15]=C,t[16]=w,t[17]=T,t[18]=E,t[19]=D}else _=t[9],v=t[10],y=t[11],b=t[12],x=t[13],S=t[14],C=t[15],w=t[16],T=t[17],E=t[18],D=t[19];let O;t[28]!==b||t[29]!==x||t[30]!==S?(O=(0,Y.jsxs)(`div`,{className:b,children:[x,S]}),t[28]=b,t[29]=x,t[30]=S,t[31]=O):O=t[31];let k;t[32]!==C||t[33]!==w||t[34]!==O?(k=(0,Y.jsxs)(`div`,{className:C,children:[w,O]}),t[32]=C,t[33]=w,t[34]=O,t[35]=k):k=t[35];let A;t[36]!==_||t[37]!==d||t[38]!==u||t[39]!==i?(A=_&&(0,Y.jsxs)(`button`,{type:`button`,"data-changed-files-undo":`true`,disabled:d,className:`flex items-center gap-1 text-[12px] text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>u(i),children:[`Undo`,(0,Y.jsx)(Za,{className:`size-3`,"aria-hidden":!0})]}),t[36]=_,t[37]=d,t[38]=u,t[39]=i,t[40]=A):A=t[40];let j;t[41]!==r[0]?.path||t[42]!==v||t[43]!==l||t[44]!==c||t[45]!==n.turnId?(j=()=>{if(v){l();return}c(n.turnId,r[0]?.path)},t[41]=r[0]?.path,t[42]=v,t[43]=l,t[44]=c,t[45]=n.turnId,t[46]=j):j=t[46];let M=v?`Close diff`:`Review changes`,N;t[47]!==j||t[48]!==M?(N=(0,Y.jsx)(`button`,{type:`button`,className:`text-[12px] text-muted-foreground transition-colors hover:text-foreground`,onClick:j,children:M}),t[47]=j,t[48]=M,t[49]=N):N=t[49];let P=p?`Collapse changed files list`:`Expand changed files list`,F;t[50]!==p||t[51]!==a||t[52]!==m||t[53]!==n.turnId?(F=()=>m(a,n.turnId,!p),t[50]=p,t[51]=a,t[52]=m,t[53]=n.turnId,t[54]=F):F=t[54];let I;t[55]===p?I=t[56]:(I=(0,Y.jsx)(aj,{open:p,className:`size-3.5`}),t[55]=p,t[56]=I);let ee;t[57]!==p||t[58]!==P||t[59]!==F||t[60]!==I?(ee=(0,Y.jsx)(`button`,{type:`button`,"data-scroll-anchor-ignore":!0,"aria-expanded":p,"aria-label":P,className:`inline-flex items-center justify-center rounded-md p-1 text-muted-foreground/70 transition-colors hover:bg-foreground/5 hover:text-foreground/80`,onClick:F,children:I}),t[57]=p,t[58]=P,t[59]=F,t[60]=I,t[61]=ee):ee=t[61];let L;t[62]!==A||t[63]!==N||t[64]!==ee?(L=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[A,N,ee]}),t[62]=A,t[63]=N,t[64]=ee,t[65]=L):L=t[65];let R;t[66]!==k||t[67]!==L||t[68]!==T?(R=(0,Y.jsxs)(`div`,{className:T,children:[k,L]}),t[66]=k,t[67]=L,t[68]=T,t[69]=R):R=t[69];let te;if(t[70]!==c||t[71]!==o||t[72]!==n.turnId||t[73]!==D){let e;t[75]!==c||t[76]!==o||t[77]!==n.turnId?(e=e=>(0,Y.jsx)(Kj,{file:e,resolvedTheme:o,onOpen:()=>c(n.turnId,e.path)},e.path),t[75]=c,t[76]=o,t[77]=n.turnId,t[78]=e):e=t[78],te=D.map(e),t[70]=c,t[71]=o,t[72]=n.turnId,t[73]=D,t[74]=te}else te=t[74];let z;t[79]!==h||t[80]!==y?(z=y>0||h?(0,Y.jsxs)(`button`,{type:`button`,"data-scroll-anchor-ignore":!0,"aria-expanded":h,className:`flex w-full items-center gap-1.5 border-t border-border/70 px-3 py-2 text-[12px] text-muted-foreground transition-colors hover:bg-foreground/5 hover:text-foreground`,onClick:()=>g(!h),children:[(0,Y.jsx)(aj,{open:h,className:`size-3.5`}),(0,Y.jsx)(`span`,{children:h?`Show less`:`Show ${y} more ${y===1?`file`:`files`}`})]}):null,t[79]=h,t[80]=y,t[81]=z):z=t[81];let ne;t[82]!==p||t[83]!==te||t[84]!==z?(ne=(0,Y.jsxs)(oj,{open:p,children:[te,z]}),t[82]=p,t[83]=te,t[84]=z,t[85]=ne):ne=t[85];let B;return t[86]!==R||t[87]!==ne||t[88]!==E?(B=(0,Y.jsxs)(`div`,{className:E,children:[R,ne]}),t[86]=R,t[87]=ne,t[88]=E,t[89]=B):B=t[89],B}function Gj(e){return e.setThreadChangedFilesExpanded}function Kj(e){let t=(0,J.c)(15),{file:n,resolvedTheme:r,onOpen:i}=e,a=n.additions??0,o=n.deletions??0,s=a+o>0,c;t[0]!==n.path||t[1]!==r?(c=(0,Y.jsx)(ha,{pathValue:n.path,kind:`file`,theme:r,className:`size-4 shrink-0 opacity-80`}),t[0]=n.path,t[1]=r,t[2]=c):c=t[2];let l;t[3]===n.path?l=t[4]:(l=(0,Y.jsx)(`span`,{className:`truncate text-[12px] text-foreground/88 underline-offset-2 group-hover/file-row:underline`,children:n.path}),t[3]=n.path,t[4]=l);let u;t[5]!==a||t[6]!==o||t[7]!==s?(u=s&&(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-[12px] tabular-nums`,children:(0,Y.jsx)(Sa,{additions:a,deletions:o})}),t[5]=a,t[6]=o,t[7]=s,t[8]=u):u=t[8];let d;return t[9]!==n.path||t[10]!==i||t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,Y.jsxs)(`button`,{type:`button`,"data-changed-file-row":`true`,title:n.path,className:`group/file-row flex w-full items-center gap-2 border-t border-border/70 px-3 py-2 text-left transition-colors first:border-t-0 hover:bg-foreground/5`,onClick:i,children:[c,l,u]}),t[9]=n.path,t[10]=i,t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}var qj=(0,q.memo)(function(e){let t=(0,J.c)(3),n=e.context.body.length>0?`${e.context.header}\n${e.context.body}`:e.context.header,r;return t[0]!==e.context.header||t[1]!==n?(r=(0,Y.jsx)(_E,{label:e.context.header,tooltipText:n}),t[0]=e.context.header,t[1]=n,t[2]=r):r=t[2],r}),Jj=(0,q.memo)(function(e){let t=(0,q.useRef)({occurrenceIndex:0});t.current.occurrenceIndex=0;let n=e.searchHighlight?{...e.searchHighlight,cursor:t.current,keyPrefix:`user-message`}:void 0;if(e.terminalContexts.length>0){let t=qA(e.text,e.terminalContexts),r=GA(e.terminalContexts),i=[];if(t){let t=0;for(let r of e.terminalContexts){let a=KA(r.header),o=e.text.indexOf(a,t);if(o===-1){i.length=0;break}o>t&&i.push((0,Y.jsx)(`span`,{children:(0,Y.jsx)(oa,{text:e.text.slice(t,o),skills:e.skills,searchHighlight:n})},`user-terminal-context-inline-before:${r.header}:${t}`)),i.push((0,Y.jsx)(qj,{context:r},`user-terminal-context-inline:${r.header}`)),t=o+a.length}if(i.length>0)return t<e.text.length&&i.push((0,Y.jsx)(`span`,{children:(0,Y.jsx)(oa,{text:e.text.slice(t),skills:e.skills,searchHighlight:n})},`user-message-terminal-context-inline-rest:${t}`)),(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-foreground`,children:i})}for(let t of e.terminalContexts)i.push((0,Y.jsx)(qj,{context:t},`user-terminal-context-inline:${t.header}`)),i.push((0,Y.jsx)(`span`,{"aria-hidden":`true`,children:` `},`user-terminal-context-inline-space:${t.header}`));if(e.text.length>0)i.push((0,Y.jsx)(`span`,{children:(0,Y.jsx)(oa,{text:e.text,skills:e.skills,searchHighlight:n})},`user-message-terminal-context-inline-text`));else if(r.length===0)return null;return(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-foreground`,children:i})}return e.text.length===0?null:(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-foreground`,children:(0,Y.jsx)(oa,{text:e.text,skills:e.skills,searchHighlight:n})})});function Yj(e){let t=(0,q.useRef)({byId:new Map,result:[]});return(0,q.useMemo)(()=>{let n=wA(e,t.current);return t.current=n,n.result},[e])}function Xj(e,t){let n=t.activeTurnInProgress&&t.activeTurnId!==null&&t.activeTurnId!==void 0&&e.message.turnId===t.activeTurnId,r=t.activeTurnInProgress&&t.activeTurnId!==null&&t.activeTurnId!==void 0&&e.assistantTurnDiffSummary?.turnId===t.activeTurnId;return!!(e.message.streaming||n||r)}function Zj(e,t){return pA({text:e.message.text??null,showCopyButton:e.showAssistantCopyButton,streaming:Xj(e,t)})}function Qj(e,t){let n=Date.parse(e),r=Date.parse(t);if(!Number.isFinite(n)||!Number.isFinite(r))return null;let i=Math.max(0,Math.floor((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/3600),o=Math.floor(i%3600/60),s=i%60;return a>0?o>0?`${a}h ${o}m`:`${a}h`:s>0?`${o}m ${s}s`:`${o}m`}function $j(e,t=Date.now()){return Qj(e,new Date(t).toISOString())??`0s`}function eM(e,t,n,r=Date.now()){return tM(e,t?bo(t,new Date(r).toISOString()):null,n)}function tM(e,t,n){return t?`${Co(e,n)} • ${t}`:Co(e,n)}function nM(e){return e===`error`?Oi:e===`thinking`?Jr:e===`info`?Yr:Ml}function rM(e,t){let n=e.command??e.rawCommand;if(n)return ik(n).target;if((e.changedFiles?.length??0)>0){let n=e.changedFiles,[r]=n;if(r)return n.length===1?ZO(fa(r,t)):`${n.length} files`}let r=e.detail?.trim();if(!r)return null;let i=iM(r);return i?ZO(i):e.requestKind===`file-read`||e.requestKind===`file-change`||e.itemType===`file_change`||r.startsWith(`{`)||r.startsWith(`[`)?null:r}function iM(e){let t=/^(.+?\.[A-Za-z0-9][A-Za-z0-9._-]*)(?::\d+)?(?::\d+)?$/u.exec(e.trim());return t?.[1]?.includes(`/`)?t[1].trim():/"(?:file_path|filePath|path|filename)"\s*:\s*"([^"]+)"/u.exec(e)?.[1]?.trim()??null}function aM(e){return e.rawCommand?.trim()||e.command?.trim()||null}function oM(e){let t=e.command??e.rawCommand;switch(t?ak(t):`terminal`){case`inspect`:return La;case`git`:case`github`:return Xi;case`terminal`:return Ja}}function sM(e){let t=(e.toolTitle??``).toLowerCase().replace(/[^a-z]/g,``);return t===`read`||t===`readfile`||t===`viewfile`}function cM(e){if(sA(e))return Oi;if(e.requestKind===`command`)return oM(e);if(e.requestKind===`file-read`)return La;if(e.requestKind===`file-change`)return Pa;if(e.itemType===`command_execution`||e.command)return oM(e);if(e.itemType===`file_change`||(e.changedFiles?.length??0)>0)return Pa;if(e.itemType===`web_search`)return ma;if(e.itemType===`image_view`)return Wi;if(sM(e))return La;switch(e.itemType){case`mcp_tool_call`:return Qa;case`dynamic_tool_call`:return wl;case`collab_agent_tool_call`:return Jr}return e.taskId?Jr:nM(e.tone)}function lM(e){let t=e.trim();return t.length===0?e:`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function uM(e){return e.toolTitle?lM(fA(e.toolTitle)):lM(fA(e.label))}function dM(e,t){return t?QO(e)===QO(t)?e:`${e} · ${t}`:e}function fM(e){return e.requestKind===`file-change`||e.itemType===`file_change`||(e.changedFiles?.length??0)>0}function pM(e){return typeof e.additions==`number`||typeof e.deletions==`number`}function mM(e){return e?.some(pM)?e.reduce((e,t)=>({additions:e.additions+(t.additions??0),deletions:e.deletions+(t.deletions??0)}),{additions:0,deletions:0}):null}function hM(e){let t=e.replaceAll(`\\`,`/`).split(`/`);for(let e=t.length-1;e>=0;--e){let n=t[e];if(n)return n}return e}function gM(e){let t=(0,J.c)(7),n;t[0]===e.additions?n=t[1]:(n=(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),t[0]=e.additions,t[1]=n);let r;t[2]===e.deletions?r=t[3]:(r=(0,Y.jsxs)(`span`,{className:`ml-1 text-destructive`,children:[`-`,e.deletions]}),t[2]=e.deletions,t[3]=r);let i;return t[4]!==n||t[5]!==r?(i=(0,Y.jsxs)(Y.Fragment,{children:[n,r]}),t[4]=n,t[5]=r,t[6]=i):i=t[6],i}var _M=(0,q.memo)(function(e){let t=(0,J.c)(37),{workEntry:n,workspaceRoot:r}=e,i,a,o,s,c,l;if(t[0]!==n||t[1]!==r){let e=sA(n),u;t[8]===n?u=t[9]:(u=cM(n),t[8]=n,t[9]=u),i=u;let d=uM(n),f=rM(n,r);c=aM(n),a=dM(d,f??(c?ik(c).target:null));let p;t[10]===n?p=t[11]:(p=Ik(n),t[10]=n,t[11]=p),s=p,o=s?`${a} · ${s}`:a,l=G(`flex size-5 items-center justify-center`,Ij,e&&`text-destructive-foreground group-hover/tool-row:text-destructive-foreground group-focus-visible/tool-row:text-destructive-foreground`),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7];let u;t[12]===i?u=t[13]:(u=(0,Y.jsx)(i,{className:`size-3.5`}),t[12]=i,t[13]=u);let d;t[14]!==l||t[15]!==u?(d=(0,Y.jsx)(`span`,{className:l,"data-work-entry-icon":`true`,children:u}),t[14]=l,t[15]=u,t[16]=d):d=t[16];let f;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(f=G(`truncate text-[12px] leading-5`,Ij),t[17]=f):f=t[17];let p;t[18]===a?p=t[19]:(p=(0,Y.jsx)(`span`,{children:a}),t[18]=a,t[19]=p);let m;t[20]===s?m=t[21]:(m=s?(0,Y.jsxs)(`span`,{"data-work-entry-meta":`true`,children:[` · `,s]}):null,t[20]=s,t[21]=m);let h;t[22]!==p||t[23]!==m?(h=(0,Y.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,Y.jsxs)(`p`,{className:f,"data-work-entry-display-text":`true`,children:[p,m]})}),t[22]=p,t[23]=m,t[24]=h):h=t[24];let g;t[25]!==o||t[26]!==h?(g=(0,Y.jsx)(Fo,{className:`block min-w-0 w-full text-left`,"aria-label":o,render:h}),t[25]=o,t[26]=h,t[27]=g):g=t[27];let _;t[28]!==o||t[29]!==c?(_=(0,Y.jsx)(Io,{side:`top`,align:`start`,className:`max-w-[min(56rem,calc(100vw-2rem))]`,children:(0,Y.jsx)(vM,{displayText:o,rawCommand:c})}),t[28]=o,t[29]=c,t[30]=_):_=t[30];let v;t[31]!==g||t[32]!==_?(v=(0,Y.jsxs)(Lo,{children:[g,_]}),t[31]=g,t[32]=_,t[33]=v):v=t[33];let y;return t[34]!==d||t[35]!==v?(y=(0,Y.jsxs)(Y.Fragment,{children:[d,v]}),t[34]=d,t[35]=v,t[36]=y):y=t[36],y});function vM(e){let t=(0,J.c)(11);if(!e.rawCommand){let n;return t[0]===e.displayText?n=t[1]:(n=(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap wrap-break-word text-xs leading-5`,children:e.displayText}),t[0]=e.displayText,t[1]=n),n}let n;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Y.jsx)(`div`,{className:`text-muted-foreground/70`,children:`Summary`}),t[2]=n):n=t[2];let r;t[3]===e.displayText?r=t[4]:(r=(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[n,(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap wrap-break-word`,children:e.displayText})]}),t[3]=e.displayText,t[4]=r);let i;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Y.jsx)(`div`,{className:`text-muted-foreground/70`,children:`Raw call`}),t[5]=i):i=t[5];let a;t[6]===e.rawCommand?a=t[7]:(a=(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[i,(0,Y.jsx)(`code`,{className:`block whitespace-pre-wrap wrap-break-word font-mono text-[11px] text-foreground/92`,children:e.rawCommand})]}),t[6]=e.rawCommand,t[7]=a);let o;return t[8]!==r||t[9]!==a?(o=(0,Y.jsxs)(`div`,{className:`space-y-2 text-xs leading-5`,children:[r,a]}),t[8]=r,t[9]=a,t[10]=o):o=t[10],o}var yM=(0,q.memo)(function(e){let t=(0,J.c)(45),{isEditing:n,workEntry:r,workspaceRoot:i}=e,a,o,s,c,l,u,d,f,p,m,h;if(t[0]!==n||t[1]!==r.changedFileStats||t[2]!==r.changedFiles||t[3]!==r.completed||t[4]!==r.id||t[5]!==i){a=r.changedFiles??[];let e=new Map((r.changedFileStats??[]).map(PM)),g=a.slice(0,3),_=Math.max(0,a.length-g.length),v=a[0],y=v?fa(v,i):null,b=a.length===1&&y?`${r.completed?`Edited`:`Editing`} ${y}`:`${r.completed?`Edited`:`Editing`} ${a.length} files`,x=v?e.get(v):void 0;o=r.completed?a.length===1&&v?mM(x?[x]:void 0):mM(r.changedFileStats):null;let S=a.length>1&&`items-start py-1.5`;t[17]===S?u=t[18]:(u=G(Fj,`chat-file-edit-row`,S),t[17]=S,t[18]=u),d=`true`,f=`file-edit`,p=`true`,m=r.completed?`completed`:`editing`;let C=a.length>1&&`mt-0.5`,w;t[19]===C?w=t[20]:(w=G(`flex size-5 items-center justify-center`,Ij,C),t[19]=C,t[20]=w);let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Y.jsx)(Pa,{className:`size-3.5`}),t[21]=T):T=t[21],t[22]===w?h=t[23]:(h=(0,Y.jsx)(`span`,{className:w,"data-work-entry-icon":`true`,children:T}),t[22]=w,t[23]=h),s=`min-w-0`;let E=n&&`chat-file-edit-text--active`,D;t[24]===E?D=t[25]:(D=G(`chat-file-edit-text truncate text-[12px] leading-5`,Ij,E),t[24]=E,t[25]=D),t[26]!==b||t[27]!==D?(c=(0,Y.jsx)(`p`,{className:D,title:b,children:b}),t[26]=b,t[27]=D,t[28]=c):c=t[28],l=a.length>1&&(0,Y.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 flex-nowrap gap-1 overflow-hidden`,children:[g.map(t=>{let n=fa(t,i),a=e.get(t),o=mM(a?[a]:void 0);return(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-[15rem] items-center gap-1 rounded border border-border/45 px-1.5 py-0.5 font-mono text-[9px] leading-3 text-muted-foreground/70`,title:n,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:hM(n)}),o&&(0,Y.jsx)(`span`,{className:`shrink-0`,children:(0,Y.jsx)(gM,{additions:o.additions,deletions:o.deletions})})]},`${r.id}:edit-chip:${t}`)}),_>0&&(0,Y.jsxs)(`span`,{className:`shrink-0 px-1 text-[10px] leading-4 text-muted-foreground/55`,children:[`+`,_]})]}),t[0]=n,t[1]=r.changedFileStats,t[2]=r.changedFiles,t[3]=r.completed,t[4]=r.id,t[5]=i,t[6]=a,t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h}else a=t[6],o=t[7],s=t[8],c=t[9],l=t[10],u=t[11],d=t[12],f=t[13],p=t[14],m=t[15],h=t[16];let g;t[29]!==s||t[30]!==c||t[31]!==l?(g=(0,Y.jsxs)(`div`,{className:s,children:[c,l]}),t[29]=s,t[30]=c,t[31]=l,t[32]=g):g=t[32];let _;t[33]!==a||t[34]!==o?(_=o?(0,Y.jsx)(`span`,{className:G(`shrink-0 font-mono text-[10px]`,a.length>1&&`mt-1`),children:(0,Y.jsx)(gM,{additions:o.additions,deletions:o.deletions})}):(0,Y.jsx)(`span`,{className:`size-5`,"aria-hidden":!0}),t[33]=a,t[34]=o,t[35]=_):_=t[35];let v;return t[36]!==_||t[37]!==u||t[38]!==d||t[39]!==f||t[40]!==p||t[41]!==m||t[42]!==h||t[43]!==g?(v=(0,Y.jsxs)(`div`,{className:u,"data-tool-entry-row":d,"data-tool-entry-kind":f,"data-file-edit-work-row":p,"data-file-edit-work-state":m,children:[h,g,_]}),t[36]=_,t[37]=u,t[38]=d,t[39]=f,t[40]=p,t[41]=m,t[42]=h,t[43]=g,t[44]=v):v=t[44],v}),bM=new RegExp(String.raw`\u001b\[[0-9;]*m`,`g`);function xM(e){return`work-entry-panel:${e}`}var SM=(0,q.memo)(function(e){let t=(0,J.c)(43),{workEntry:n,workspaceRoot:r}=e,{routeThreadKey:i}=(0,q.use)(cj),a;t[0]!==i||t[1]!==n.id?(a=e=>e.threadWorkEntryExpandedById[i]?.[n.id],t[0]=i,t[1]=n.id,t[2]=a):a=t[2];let o=Tr(a),s=Tr(FM),c=o??!1,l;t[3]===n.id?l=t[4]:(l=xM(n.id),t[3]=n.id,t[4]=l);let u=l,d;t[5]===n?d=t[6]:(d=uM(n),t[5]=n,t[6]=d);let f=d,[p,m]=(0,q.useState)(c),h,g;t[7]!==c||t[8]!==p?(h=()=>{if(c){m(!0);return}if(!p)return;let e=window.setTimeout(()=>m(!1),260);return()=>window.clearTimeout(e)},g=[c,p],t[7]=c,t[8]=p,t[9]=h,t[10]=g):(h=t[9],g=t[10]),(0,q.useEffect)(h,g);let _;t[11]!==c||t[12]!==i||t[13]!==s||t[14]!==n.id?(_=()=>{s(i,n.id,!c)},t[11]=c,t[12]=i,t[13]=s,t[14]=n.id,t[15]=_):_=t[15];let v=_,y;t[16]===v?y=t[17]:(y=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),v())},t[16]=v,t[17]=y);let b;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=G(Fj,`cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70`),t[18]=b):b=t[18];let x;t[19]!==n||t[20]!==r?(x=(0,Y.jsx)(_M,{workEntry:n,workspaceRoot:r}),t[19]=n,t[20]=r,t[21]=x):x=t[21];let S;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(S=G(`size-3`,Ij),t[22]=S):S=t[22];let C;t[23]===c?C=t[24]:(C=(0,Y.jsx)(`span`,{className:`flex size-5 items-center justify-center`,children:(0,Y.jsx)(aj,{open:c,className:S})}),t[23]=c,t[24]=C);let w;t[25]!==c||t[26]!==u||t[27]!==C||t[28]!==y||t[29]!==x||t[30]!==v?(w=(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":c,"aria-controls":u,onClick:v,onKeyDown:y,"data-tool-entry-row":`true`,"data-tool-entry-kind":`expandable`,className:b,children:[x,C]}),t[25]=c,t[26]=u,t[27]=C,t[28]=y,t[29]=x,t[30]=v,t[31]=w):w=t[31];let T;t[32]!==f||t[33]!==p||t[34]!==u||t[35]!==n?(T=p?(0,Y.jsx)(CM,{workEntry:n,panelId:u,headingLabel:f}):null,t[32]=f,t[33]=p,t[34]=u,t[35]=n,t[36]=T):T=t[36];let E;t[37]!==c||t[38]!==T?(E=(0,Y.jsx)(oj,{open:c,contentClassName:`min-w-0 pl-9`,children:T}),t[37]=c,t[38]=T,t[39]=E):E=t[39];let D;return t[40]!==w||t[41]!==E?(D=(0,Y.jsxs)(`div`,{children:[w,E]}),t[40]=w,t[41]=E,t[42]=D):D=t[42],D}),CM=(0,q.memo)(function(e){let t=(0,J.c)(13),{workEntry:n,panelId:r,headingLabel:i}=e,{activeThreadEnvironmentId:a,markdownCwd:o,timestampFormat:s}=(0,q.use)(cj),c;if(t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==r||t[4]!==s||t[5]!==n){let e=aM(n),l=n.output?n.output.replace(bM,``):``,u=l.length>0,d;t[7]===n.detail?d=t[8]:(d=n.detail?.trim()||null,t[7]=n.detail,t[8]=d);let f=d,p=f===e?null:f,m;t[9]!==p||t[10]!==s||t[11]!==n?(m=(0,Y.jsx)(wM,{workEntry:n,detailText:p,timestampFormat:s}),t[9]=p,t[10]=s,t[11]=n,t[12]=m):m=t[12],c=(0,Y.jsxs)(`div`,{id:r,role:`region`,"aria-label":`${i} details`,className:`space-y-3 pt-2 pb-1`,children:[m,e||u?(0,Y.jsx)(ua,{text:TM(e,l,n.exitCode),cwd:o,environmentId:a,isStreaming:!1}):(0,Y.jsx)(`p`,{className:`text-[11px] italic text-muted-foreground/45`,children:`No output was captured.`})]}),t[0]=a,t[1]=i,t[2]=o,t[3]=r,t[4]=s,t[5]=n,t[6]=c}else c=t[6];return c});function wM(e){let t=(0,J.c)(28),{workEntry:n,detailText:r,timestampFormat:i}=e,a;t[0]===n?a=t[1]:(a=Pk(Nk(n)),t[0]=n,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=Fk(n),t[2]=n,t[3]=s);let c=s,l=n.lastActivityAt??n.createdAt,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Y.jsx)(`h3`,{className:`text-[11px] font-medium text-muted-foreground/56`,children:`Activity`}),t[4]=u):u=t[4];let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Y.jsx)(`dt`,{className:`text-muted-foreground/56`,children:`Status`}),t[5]=d):d=t[5];let f;t[6]===o?f=t[7]:(f=(0,Y.jsx)(`dd`,{className:`text-foreground/84`,children:o}),t[6]=o,t[7]=f);let p;t[8]!==i||t[9]!==n.startedAt?(p=n.startedAt?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground/56`,children:`Started`}),(0,Y.jsx)(`dd`,{className:`text-foreground/84`,children:(0,Y.jsx)(`time`,{dateTime:n.startedAt,title:n.startedAt,children:Co(n.startedAt,i)})})]}):null,t[8]=i,t[9]=n.startedAt,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Y.jsx)(`dt`,{className:`text-muted-foreground/56`,children:`Last activity`}),t[11]=m):m=t[11];let h;t[12]!==l||t[13]!==i?(h=Co(l,i),t[12]=l,t[13]=i,t[14]=h):h=t[14];let g;t[15]!==l||t[16]!==h?(g=(0,Y.jsx)(`dd`,{className:`text-foreground/84`,children:(0,Y.jsx)(`time`,{dateTime:l,title:l,children:h})}),t[15]=l,t[16]=h,t[17]=g):g=t[17];let _;t[18]===c?_=t[19]:(_=c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground/56`,children:`Elapsed`}),(0,Y.jsx)(`dd`,{className:`tabular-nums text-foreground/84`,children:c})]}):null,t[18]=c,t[19]=_);let v;t[20]===r?v=t[21]:(v=r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-muted-foreground/56`,children:`Detail`}),(0,Y.jsx)(`dd`,{"data-work-entry-detail":`true`,className:`wrap-break-word text-foreground/84`,children:r})]}):null,t[20]=r,t[21]=v);let y;return t[22]!==v||t[23]!==f||t[24]!==p||t[25]!==g||t[26]!==_?(y=(0,Y.jsxs)(`section`,{className:`space-y-2`,children:[u,(0,Y.jsxs)(`dl`,{className:`grid grid-cols-[max-content_minmax(0,1fr)] gap-x-3 gap-y-1.5 rounded-lg border border-border/45 bg-background/60 px-3 py-2.5 text-[11px]`,children:[d,f,p,m,g,_,v]})]}),t[22]=v,t[23]=f,t[24]=p,t[25]=g,t[26]=_,t[27]=y):y=t[27],y}function TM(e,t,n){let r=[];if(e){let[t,...n]=e.split(`
|
|
23
|
-
`);r.push(`$ ${t??``}`,...n)}t&&(r.length>0&&r.push(``),r.push(t.replace(/\s+$/,``))),n!==void 0&&n!==0&&(r.length>0&&r.push(``),r.push(`Exit code ${n}`));let i="`".repeat(Math.max(3,EM(r.join(`
|
|
24
|
-
`))+1));return`${i}bash\n${r.join(`
|
|
25
|
-
`)}\n${i}`}function EM(e){let t=0,n=0;for(let r of e){if(r==="`"){n+=1,t=Math.max(t,n);continue}n=0}return t}function DM(e){return e.tone===`tool`}function OM(e){return e.members}function kM(e){return e.status===`running`||e.status===`pending`}function AM(e){return e.status===`waiting`}function jM(e){return e.status===`failed`}function MM(e,t){return e+(t.usage?.totalTokens??0)}function NM(e){return e.state===`running`}function PM(e){return[e.path,e]}function FM(e){return e.setThreadWorkEntryExpanded}function IM(e){let t=e.trim();return t.length<=42?t:`${t.slice(0,41).trimEnd()}…`}function LM(e){let t=e.projectName?.trim();if(!t)return{prefix:`What should we do?`,projectName:null,suffix:``,text:`What should we do?`};let n=IM(t);return{prefix:`What should we do in `,projectName:n,suffix:`?`,text:`What should we do in ${n}?`}}function RM(e){return e.routeKind===`draft`&&!e.envLocked&&e.projectCount>1}function zM(e){let t=(0,J.c)(25),{projectName:n,activeProjectId:r,activeProjectEnvironmentId:i,routeKind:a,envLocked:o,draftId:s,workLocation:c}=e,l;t[0]===n?l=t[1]:(l=LM({projectName:n}),t[0]=n,t[1]=l);let u=l,d=oe(eo(BM)),f;t[2]!==i||t[3]!==r||t[4]!==s||t[5]!==o||t[6]!==u.projectName||t[7]!==d||t[8]!==a?(f=u.projectName!==null&&r!==null&&i!==null&&s!==void 0&&RM({routeKind:a,envLocked:o,projectCount:d}),t[2]=i,t[3]=r,t[4]=s,t[5]=o,t[6]=u.projectName,t[7]=d,t[8]=a,t[9]=f):f=t[9];let p=f,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Y.jsx)(Nc,{className:`h-10 text-foreground sm:h-12`}),t[10]=m):m=t[10];let h;t[11]!==i||t[12]!==r||t[13]!==p||t[14]!==s||t[15]!==u.prefix||t[16]!==u.projectName||t[17]!==u.suffix||t[18]!==u.text?(h=u.projectName===null?u.text:(0,Y.jsxs)(Y.Fragment,{children:[u.prefix,p&&r&&i&&s?(0,Y.jsx)(Xu,{activeProjectId:r,activeProjectEnvironmentId:i,appearance:`headline`,draftId:s,label:u.projectName}):(0,Y.jsx)(`span`,{className:`text-foreground`,children:u.projectName}),u.suffix]}),t[11]=i,t[12]=r,t[13]=p,t[14]=s,t[15]=u.prefix,t[16]=u.projectName,t[17]=u.suffix,t[18]=u.text,t[19]=h):h=t[19];let g;t[20]===h?g=t[21]:(g=(0,Y.jsx)(`h1`,{className:`max-w-208 text-balance text-center font-medium text-2xl text-foreground tracking-tight sm:text-3xl`,children:h}),t[20]=h,t[21]=g);let _;return t[22]!==g||t[23]!==c?(_=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-4 px-6 pb-6 sm:gap-5 sm:pb-8`,"data-testid":`new-thread-hero`,children:[m,g,c]}),t[22]=g,t[23]=c,t[24]=_):_=t[24],_}function BM(e){return re(e).length}var VM=60;function HM(e){let t=(0,J.c)(36),{label:n,sourceKind:r,environmentId:i,projectId:a,cwd:o,onSelect:s}=e,[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(`branches`),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(`open`),[S,C]=(0,q.useState)(`open`),[w,T]=(0,q.useState)(`open`),E=(0,q.useRef)(null),D=(0,q.useRef)(null),O=(0,q.useRef)(null),k=(0,q.useRef)(null),A;t[0]===s?A=t[1]:(A=e=>{l(!1),s(e)},t[0]=s,t[1]=A);let j=A,M=`Change what this worktree branches from (currently ${n})`,N;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Y.jsx)(`button`,{type:`button`}),t[2]=N):N=t[2];let P;t[3]===r?P=t[4]:(P=(0,Y.jsx)(UM,{kind:r}),t[3]=r,t[4]=P);let F;t[5]===n?F=t[6]:(F=(0,Y.jsx)(`span`,{className:`min-w-0 max-w-[18rem] truncate`,children:n}),t[5]=n,t[6]=F);let I;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Y.jsx)(Zr,{className:`size-3 shrink-0 text-muted-foreground`}),t[7]=I):I=t[7];let ee;t[8]!==M||t[9]!==P||t[10]!==F?(ee=(0,Y.jsxs)(Ec,{"aria-label":M,className:`inline-flex cursor-pointer items-center gap-1 rounded-md px-1 py-0.5 font-medium text-foreground/85 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60`,render:N,children:[P,F,I]}),t[8]=M,t[9]=P,t[10]=F,t[11]=ee):ee=t[11];let L;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(L=[{id:`branches`,label:`Branch`},{id:`prs`,label:`Pull requests`},{id:`issues`,label:`Issues`},{id:`jira`,label:`Jira`}],t[12]=L):L=t[12];let R;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>d(e),t[13]=R):R=t[13];let te;t[14]===u?te=t[15]:(te=(0,Y.jsx)(vi,{tabs:L,activeId:u,density:`compact`,onSelect:R}),t[14]=u,t[15]=te);let z;t[16]!==f||t[17]!==j||t[18]!==o||t[19]!==i||t[20]!==g||t[21]!==S||t[22]!==m||t[23]!==b||t[24]!==a||t[25]!==u||t[26]!==v||t[27]!==w?(z=(0,Y.jsx)(`div`,{className:`h-72 min-h-0`,children:u===`branches`?(0,Y.jsx)(WM,{environmentId:i,cwd:o,query:f,searchInputRef:E,onQueryChange:p,onSelect:e=>j({kind:`branch`,branchName:e})}):u===`prs`?(0,Y.jsx)(bi,{environmentId:i,cwd:o,searchInputRef:D,query:m,onQueryChange:h,density:`compact`,stateFilter:b,onStateFilterChange:x,onSelect:e=>j({kind:`pr`,changeRequest:e})}):u===`issues`?(0,Y.jsx)(_i,{environmentId:i,cwd:o,searchInputRef:O,query:g,onQueryChange:_,density:`compact`,stateFilter:S,onStateFilterChange:C,onSelect:e=>j({kind:`issue`,issue:e})}):(0,Y.jsx)(Ei,{environmentId:i,cwd:o,projectId:a,searchInputRef:k,query:v,onQueryChange:y,stateFilter:w,onStateFilterChange:T,onSelect:e=>j({kind:`workItem`,workItem:e})})}),t[16]=f,t[17]=j,t[18]=o,t[19]=i,t[20]=g,t[21]=S,t[22]=m,t[23]=b,t[24]=a,t[25]=u,t[26]=v,t[27]=w,t[28]=z):z=t[28];let ne;t[29]!==te||t[30]!==z?(ne=(0,Y.jsxs)(Tc,{align:`start`,side:`bottom`,className:`w-[30rem] overflow-hidden p-0`,viewportClassName:`p-0 [--viewport-inline-padding:0px]`,children:[te,z]}),t[29]=te,t[30]=z,t[31]=ne):ne=t[31];let B;return t[32]!==c||t[33]!==ne||t[34]!==ee?(B=(0,Y.jsxs)(Dc,{open:c,onOpenChange:l,children:[ee,ne]}),t[32]=c,t[33]=ne,t[34]=ee,t[35]=B):B=t[35],B}function UM(e){let t=(0,J.c)(4),{kind:n}=e;switch(n){case`pr`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(Zi,{"aria-label":`Pull request`,className:G(`size-3.5 shrink-0`,`text-emerald-500 dark:text-emerald-400`)}),t[0]=e):e=t[0],e}case`issue`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(yr,{"aria-label":`Issue`,className:G(`size-3.5 shrink-0`,`text-sky-500 dark:text-sky-400`)}),t[1]=e):e=t[1],e}case`workItem`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(Es,{"aria-label":`Jira work item`,className:G(`size-3.5 shrink-0`,`text-violet-500 dark:text-violet-400`)}),t[2]=e):e=t[2],e}case`branch`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(Xi,{"aria-hidden":!0,className:G(`size-3.5 shrink-0`,`text-muted-foreground`)}),t[3]=e):e=t[3],e}default:return null}}function WM({environmentId:e,cwd:t,query:n,searchInputRef:r,onQueryChange:i,onSelect:a}){let{refs:o,isPending:s}=wu({environmentId:e,cwd:t,query:n.trim()}),c=o.slice(0,VM);return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Y.jsx)(`div`,{className:`border-border/40 border-b px-2 py-1.5`,children:(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(Xi,{className:`-translate-y-1/2 absolute top-1/2 left-2 size-3.5 text-muted-foreground`}),(0,Y.jsx)(ys,{ref:r,value:n,onChange:e=>i(e.target.value),placeholder:`Search branches...`,className:`h-8 pl-7 text-sm`})]})}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:s&&c.length===0?(0,Y.jsx)(`p`,{className:`px-2.5 py-4 text-sm text-muted-foreground`,children:`Loading branches...`}):c.length===0?(0,Y.jsx)(`p`,{className:`px-2.5 py-4 text-sm text-muted-foreground`,children:`No branches match this search.`}):c.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e.name),className:`flex w-full cursor-pointer items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-accent/60`,children:[(0,Y.jsx)(Xi,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e.name}),e.isRemote?(0,Y.jsx)(`span`,{className:G(`shrink-0 text-[10px] text-muted-foreground/55`),children:e.remoteName??`remote`}):e.current?(0,Y.jsx)(`span`,{className:G(`shrink-0 text-[10px] text-muted-foreground/55`),children:`current`}):e.isDefault?(0,Y.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/55`,children:`default`}):null]},e.name))})]})}function GM(e){let{draft:t,worktrees:n}=e;return t.worktreePath?{kind:`existingWorktree`,worktree:n.find(e=>e.worktreePath===t.worktreePath)??{worktreeId:t.worktreePath,worktreePath:t.worktreePath,branch:``,title:null}}:t.envMode===`worktree`?{kind:`newWorktree`,worktree:null}:{kind:`projectRoot`,worktree:null}}function KM(e){switch(e.kind){case`existingWorktree`:return{envMode:`local`,worktreePath:e.worktree?.worktreePath??null,branch:e.worktree?.branch||null,worktreeSource:null};case`newWorktree`:return{envMode:`worktree`,worktreePath:null};case`projectRoot`:return{envMode:`local`,worktreePath:null,branch:null,worktreeSource:null}}}function qM(e){let t=e.title?.trim();if(t)return t;let n=e.branch.trim();if(n)return n;let r=e.worktreePath.split(`/`).filter(Boolean);return r[r.length-1]??e.worktreePath}function JM(e){switch(e.kind){case`existingWorktree`:return e.worktree?qM(e.worktree):`a worktree`;case`newWorktree`:return`a new worktree`;case`projectRoot`:return`the project root`}}function YM(e){return e.kind!==`existingWorktree`}function XM(e){return e.kind===`newWorktree`?`from`:`on`}var ZM=`__project_root__`,QM=`__new_worktree__`;function $M(e){let t=(0,J.c)(87),{draftId:n,environmentId:r,threadId:i,projectId:a,projectEnvironmentId:s,projectName:c,envLocked:l,availableEnvironments:u,onEnvironmentChange:d,onComposerFocusRequest:f,onCheckoutPullRequestRequest:p,cwd:m}=e,h=Jt(tN),g;t[0]===n?g=t[1]:(g=e=>n?e.getDraftSession(n):null,t[0]=n,t[1]=g);let _=Jt(g),v;t[2]!==s||t[3]!==a?(v=s&&a?o(s,a):null,t[2]=s,t[3]=a,t[4]=v):v=t[4];let y=v,b;t[5]===y?b=t[6]:(b=e=>Se(e,y),t[5]=y,t[6]=b);let x=oe(eo(b)),S;t[7]===x?S=t[8]:(S=x.flatMap(eN),t[7]=x,t[8]=S);let C=S,w,T,E,D,O,k,A,j,M,N,P,F,I;if(t[9]!==u.length||t[10]!==n||t[11]!==_?.branch||t[12]!==_?.envMode||t[13]!==_?.worktreePath||t[14]!==_?.worktreeSource||t[15]!==l||t[16]!==f||t[17]!==d||t[18]!==s||t[19]!==a||t[20]!==c||t[21]!==h||t[22]!==C){j=Symbol.for(`react.early_return_sentinel`);bb0:{E=GM({draft:{envMode:_?.envMode??`local`,worktreePath:_?.worktreePath??null},worktrees:C});let e;t[36]!==n||t[37]!==f||t[38]!==h?(e=e=>{n&&(h(n,KM(e)),f?.())},t[36]=n,t[37]=f,t[38]=h,t[39]=e):e=t[39];let r=e;D=u.length>1&&d!==void 0,w=n!==void 0&&!l;let i=_?.worktreeSource??null,o;t[40]!==_?.branch||t[41]!==i?.label?(o=i?.label??_?.branch?.trim()??`Select a source`,t[40]=_?.branch,t[41]=i?.label,t[42]=o):o=t[42],k=o;let p;t[43]!==_?.branch||t[44]!==i?(p=i?i.kind:_?.branch?.trim()?`branch`:null,t[43]=_?.branch,t[44]=i,t[45]=p):p=t[45],O=p;let m;if(t[46]!==n||t[47]!==f||t[48]!==h?(m=e=>{n&&(h(n,e.kind===`branch`?{branch:e.branchName,worktreeSource:null,worktreePath:null}:{branch:null,worktreePath:null,worktreeSource:nN(e)}),f?.())},t[46]=n,t[47]=f,t[48]=h,t[49]=m):m=t[49],T=m,!a||!s||!c){j=null;break bb0}M=`flex max-w-208 flex-wrap items-center justify-center gap-x-0.5 gap-y-1 text-[13px] text-muted-foreground/70`,N=`new-thread-work-location`,t[50]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Y.jsx)(`span`,{className:`px-1`,children:`Work in`}),t[50]=P):P=t[50],t[51]!==w||t[52]!==n||t[53]!==s||t[54]!==a||t[55]!==c?(F=w&&n?(0,Y.jsx)(Xu,{activeProjectId:a,activeProjectEnvironmentId:s,appearance:`sentence`,draftId:n,label:c}):(0,Y.jsx)(rN,{children:c}),t[51]=w,t[52]=n,t[53]=s,t[54]=a,t[55]=c,t[56]=F):F=t[56],t[57]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`px-1 text-muted-foreground/35`,children:`›`}),t[57]=I):I=t[57],A=w?(0,Y.jsx)(iN,{location:E,worktrees:C,onSelect:r}):(0,Y.jsx)(rN,{children:JM(E)})}t[9]=u.length,t[10]=n,t[11]=_?.branch,t[12]=_?.envMode,t[13]=_?.worktreePath,t[14]=_?.worktreeSource,t[15]=l,t[16]=f,t[17]=d,t[18]=s,t[19]=a,t[20]=c,t[21]=h,t[22]=C,t[23]=w,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j,t[31]=M,t[32]=N,t[33]=P,t[34]=F,t[35]=I}else w=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29],j=t[30],M=t[31],N=t[32],P=t[33],F=t[34],I=t[35];if(j!==Symbol.for(`react.early_return_sentinel`))return j;let ee;t[58]!==w||t[59]!==m||t[60]!==n||t[61]!==l||t[62]!==r||t[63]!==T||t[64]!==E||t[65]!==p||t[66]!==f||t[67]!==a||t[68]!==O||t[69]!==k||t[70]!==i?(ee=YM(E)?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`px-1`,children:XM(E)}),E.kind===`newWorktree`&&w&&a?(0,Y.jsx)(HM,{label:k,sourceKind:O,environmentId:r,projectId:a,cwd:m,onSelect:T}):(0,Y.jsx)(Hu,{className:`text-[13px] text-foreground/85 hover:text-foreground`,environmentId:r,threadId:i,...n?{draftId:n}:{},envLocked:l,omitBasePrefix:!0,...p?{onCheckoutPullRequestRequest:p}:{},...f?{onComposerFocusRequest:f}:{}})]}):null,t[58]=w,t[59]=m,t[60]=n,t[61]=l,t[62]=r,t[63]=T,t[64]=E,t[65]=p,t[66]=f,t[67]=a,t[68]=O,t[69]=k,t[70]=i,t[71]=ee):ee=t[71];let L;t[72]!==u||t[73]!==l||t[74]!==r||t[75]!==d||t[76]!==D?(L=D&&d?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`px-1`,children:`on`}),(0,Y.jsx)(Uu,{envLocked:l,environmentId:r,availableEnvironments:u,onEnvironmentChange:d})]}):null,t[72]=u,t[73]=l,t[74]=r,t[75]=d,t[76]=D,t[77]=L):L=t[77];let R;return t[78]!==A||t[79]!==ee||t[80]!==L||t[81]!==M||t[82]!==N||t[83]!==P||t[84]!==F||t[85]!==I?(R=(0,Y.jsxs)(`p`,{className:M,"data-testid":N,children:[P,F,I,A,ee,L]}),t[78]=A,t[79]=ee,t[80]=L,t[81]=M,t[82]=N,t[83]=P,t[84]=F,t[85]=I,t[86]=R):R=t[86],R}function eN(e){return e.worktreePath&&e.archivedAt===null?[{worktreeId:e.id,worktreePath:e.worktreePath,branch:e.branch,title:e.title??null}]:[]}function tN(e){return e.setDraftThreadContext}function nN(e){return e.kind===`pr`?{kind:`pr`,number:e.changeRequest.number,label:`#${e.changeRequest.number} ${e.changeRequest.title}`}:e.kind===`issue`?{kind:`issue`,number:e.issue.number,title:e.issue.title,label:`#${e.issue.number} ${e.issue.title}`}:{kind:`workItem`,provider:e.workItem.provider,key:e.workItem.key,title:e.workItem.title,...e.workItem.state?{state:e.workItem.state}:{},...e.workItem.stateName?{stateName:e.workItem.stateName}:{},...e.workItem.url?{url:e.workItem.url}:{},label:`${e.workItem.key} ${e.workItem.title}`}}function rN(e){let t=(0,J.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Y.jsx)(`span`,{className:`px-1 font-medium text-foreground/85`,children:n}),t[0]=n,t[1]=r),r}function iN(e){let t=(0,J.c)(32),{location:n,worktrees:r,onSelect:i}=e,[a,o]=(0,q.useState)(!1),s=(0,q.useRef)(null),c;t[0]===r?c=t[1]:(c=[ZM,...r.map(oN),QM],t[0]=r,t[1]=c);let l=c,u;t[2]===r?u=t[3]:(u=new Map(r.map(aN)),t[2]=r,t[3]=u);let d=u,f=n.kind===`projectRoot`?ZM:n.kind===`newWorktree`?QM:n.worktree?.worktreeId??ZM,p;t[4]!==i||t[5]!==d?(p=e=>{if(o(!1),e===ZM){i({kind:`projectRoot`,worktree:null});return}if(e===QM){i({kind:`newWorktree`,worktree:null});return}let t=d.get(e);t&&i({kind:`existingWorktree`,worktree:t})},t[4]=i,t[5]=d,t[6]=p):p=t[6];let m=p,h;t[7]===n?h=t[8]:(h=JM(n),t[7]=n,t[8]=h);let g=`Change where this thread runs (currently ${h})`,_;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Y.jsx)(`button`,{type:`button`}),t[9]=_):_=t[9];let v;t[10]===n.kind?v=t[11]:(v=(0,Y.jsx)(sN,{kind:n.kind}),t[10]=n.kind,t[11]=v);let y;t[12]===n?y=t[13]:(y=JM(n),t[12]=n,t[13]=y);let b;t[14]===y?b=t[15]:(b=(0,Y.jsx)(`span`,{className:`min-w-0 max-w-[16rem] truncate`,children:y}),t[14]=y,t[15]=b);let x;t[16]!==g||t[17]!==v||t[18]!==b?(x=(0,Y.jsxs)(is,{ref:s,"aria-label":g,className:`inline-flex cursor-pointer items-center gap-1 rounded-md px-1 py-0.5 font-medium text-foreground/85 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,render:_,children:[v,b]}),t[16]=g,t[17]=v,t[18]=b,t[19]=x):x=t[19];let S;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Y.jsx)(rs,{children:`Nowhere to run this thread.`}),t[20]=S):S=t[20];let C;t[21]!==f||t[22]!==l||t[23]!==m||t[24]!==d?(C=(0,Y.jsxs)(es,{anchor:s,align:`start`,side:`bottom`,className:`w-80`,children:[S,(0,Y.jsx)(ns,{className:`max-h-72`,children:l.map((e,t)=>{let n=d.get(e),r=e===ZM?`The project root`:e===QM?`A new worktree`:n?qM(n):e,i=e===ZM?`Work directly in the checked-out project directory`:e===QM?`Branch off and create the worktree when you send`:n?.worktreePath??``;return(0,Y.jsx)($o,{hideIndicator:!0,index:t,value:e,onClick:()=>m(e),children:(0,Y.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 py-0.5 text-left`,children:[(0,Y.jsx)(sN,{kind:e===ZM?`projectRoot`:e===QM?`newWorktree`:`existingWorktree`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:G(`truncate text-sm`,e===f&&`font-medium text-foreground`),children:r}),i?(0,Y.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:i}):null]})]})},e)})})]}),t[21]=f,t[22]=l,t[23]=m,t[24]=d,t[25]=C):C=t[25];let w;return t[26]!==f||t[27]!==l||t[28]!==a||t[29]!==x||t[30]!==C?(w=(0,Y.jsxs)(Qo,{items:l,filteredItems:l,autoHighlight:!0,open:a,value:f,onOpenChange:o,children:[x,C]}),t[26]=f,t[27]=l,t[28]=a,t[29]=x,t[30]=C,t[31]=w):w=t[31],w}function aN(e){return[e.worktreeId,e]}function oN(e){return e.worktreeId}function sN(e){let t=(0,J.c)(3),{kind:n}=e;if(n===`newWorktree`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(Cl,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[0]=e):e=t[0],e}if(n===`existingWorktree`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(Sl,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[1]=e):e=t[1],e}let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Y.jsx)(Yi,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[2]=r):r=t[2],r}function cN(e){let t=(0,J.c)(45),{query:n,focusRequestId:r,matchCount:i,selectedIndex:a,onQueryChange:o,onNext:s,onPrevious:c,onClose:l}=e,u=(0,q.useRef)(null),d=n.trim().length===0?`Thread`:i>0?`${a+1} / ${i}`:`No results`,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=window.requestAnimationFrame(()=>{u.current?.focus(),u.current?.select()});return()=>{window.cancelAnimationFrame(e)}},t[0]=f):f=t[0];let p;t[1]===r?p=t[2]:(p=[r],t[1]=r,t[2]=p),(0,q.useEffect)(f,p);let m;t[3]===s?m=t[4]:(m=e=>{e.preventDefault(),s()},t[3]=s,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Y.jsx)(La,{className:`ml-1 size-4 shrink-0 text-muted-foreground/70`,"aria-hidden":!0}),t[5]=h):h=t[5];let g;t[6]===o?g=t[7]:(g=e=>o(e.target.value),t[6]=o,t[7]=g);let _;t[8]!==l||t[9]!==s||t[10]!==c?(_=e=>{if(e.key===`Escape`){e.preventDefault(),l();return}e.key===`Enter`&&(e.preventDefault(),e.shiftKey?c():s())},t[8]=l,t[9]=s,t[10]=c,t[11]=_):_=t[11];let v;t[12]!==n||t[13]!==g||t[14]!==_?(v=(0,Y.jsx)(ys,{ref:u,type:`search`,size:`sm`,unstyled:!0,value:n,placeholder:`Find in thread`,"aria-label":`Find in thread`,className:`min-w-0 flex-1`,onChange:g,onKeyDown:_}),t[12]=n,t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]===d?y=t[17]:(y=(0,Y.jsx)(`span`,{className:`min-w-14 shrink-0 text-right text-xs text-muted-foreground/75`,children:d}),t[16]=d,t[17]=y);let b=i===0,x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Y.jsx)(ai,{className:`size-3.5`}),t[18]=x):x=t[18];let S;t[19]!==c||t[20]!==b?(S=(0,Y.jsx)(Fo,{render:(0,Y.jsx)(K,{"aria-label":`Previous match`,disabled:b,size:`icon-xs`,type:`button`,variant:`ghost`,onClick:c,children:x})}),t[19]=c,t[20]=b,t[21]=S):S=t[21];let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Y.jsx)(Io,{children:`Previous match`}),t[22]=C):C=t[22];let w;t[23]===S?w=t[24]:(w=(0,Y.jsxs)(Lo,{children:[S,C]}),t[23]=S,t[24]=w);let T=i===0,E;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Y.jsx)(Zr,{className:`size-3.5`}),t[25]=E):E=t[25];let D;t[26]!==s||t[27]!==T?(D=(0,Y.jsx)(Fo,{render:(0,Y.jsx)(K,{"aria-label":`Next match`,disabled:T,size:`icon-xs`,type:`button`,variant:`ghost`,onClick:s,children:E})}),t[26]=s,t[27]=T,t[28]=D):D=t[28];let O;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Y.jsx)(Io,{children:`Next match`}),t[29]=O):O=t[29];let k;t[30]===D?k=t[31]:(k=(0,Y.jsxs)(Lo,{children:[D,O]}),t[30]=D,t[31]=k);let A;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Y.jsx)($a,{className:`size-3.5`}),t[32]=A):A=t[32];let j;t[33]===l?j=t[34]:(j=(0,Y.jsx)(Fo,{render:(0,Y.jsx)(K,{"aria-label":`Close find`,size:`icon-xs`,type:`button`,variant:`ghost`,onClick:l,children:A})}),t[33]=l,t[34]=j);let M;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Y.jsx)(Io,{children:`Close find`}),t[35]=M):M=t[35];let N;t[36]===j?N=t[37]:(N=(0,Y.jsxs)(Lo,{children:[j,M]}),t[36]=j,t[37]=N);let P;return t[38]!==w||t[39]!==k||t[40]!==N||t[41]!==m||t[42]!==v||t[43]!==y?(P=(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-[calc(var(--chat-header-clearance,0px)+0.75rem)] z-30 flex justify-center px-3`,children:(0,Y.jsxs)(`form`,{className:`pointer-events-auto flex h-9 w-full max-w-md items-center gap-1 rounded-lg border border-border/80 bg-popover/96 px-1.5 shadow-lg/12 backdrop-blur`,"data-thread-message-search":`true`,onSubmit:m,children:[h,v,y,w,k,N]})}),t[38]=w,t[39]=k,t[40]=N,t[41]=m,t[42]=v,t[43]=y,t[44]=P):P=t[44],P}var lN=`Invalid keybinding.`;function uN(e){let t=e?.trim()??``;return t.length>0?t:null}function dN(e){let t=uN(e.keybinding);if(!t)return null;let n=p(k)({key:t,command:e.command});if(n._tag===`None`)throw Error(lN);return n.value}function fN(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(!r||r.command!==t)continue;let i=[];r.shortcut.modKey&&i.push(`mod`),r.shortcut.ctrlKey&&i.push(`ctrl`),r.shortcut.metaKey&&i.push(`meta`),r.shortcut.altKey&&i.push(`alt`),r.shortcut.shiftKey&&i.push(`shift`);let a=r.shortcut.key===` `?`space`:r.shortcut.key===`escape`?`esc`:r.shortcut.key;return i.push(a),i.join(`+`)}return null}function pN(e){let t=e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t.length===0?`script`:t.length<=24?t:t.slice(0,24).replace(/-+$/g,``)||`script`}var mN=e=>O.make(`script.${e}.run`);function hN(e){let t=e.trim();if(!y(O)(t))return null;let[n,,r]=O.parts;return t.slice(n.literal.length,-r.literal.length)}function gN(e,t){let n=new Set(Array.from(t)),r=pN(e);if(!n.has(r))return r;let i=2;for(;i<1e4;){let e=`${r}-${i}`,t=e.length<=24?e:`${r.slice(0,Math.max(1,24-String(i).length-1))}-${i}`;if(!n.has(t))return t;i+=1}return`${r}-${Date.now()}`.slice(0,24)}function _N(e){return e.find(e=>!e.runOnWorktreeCreate)??e[0]??null}var vN=`flex w-fit items-center gap-1`,yN=`h-8 min-w-8 shrink-0 rounded-md border-0 bg-transparent px-2 text-muted-foreground/72 shadow-none transition-[background-color,color] before:hidden hover:bg-foreground/8 hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring/70 data-pressed:bg-foreground/10 data-pressed:text-foreground sm:h-7 sm:min-w-7`,bN=`size-8 min-w-8 shrink-0 rounded-md border-0 bg-transparent px-0 text-muted-foreground/72 shadow-none transition-[background-color,color] before:hidden hover:bg-foreground/8 hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring/70 data-pressed:bg-foreground/10 data-pressed:text-foreground sm:size-7 sm:min-w-7`,xN=[{id:`play`,label:`Play`},{id:`test`,label:`Test`},{id:`lint`,label:`Lint`},{id:`configure`,label:`Configure`},{id:`build`,label:`Build`},{id:`debug`,label:`Debug`}];function SN(e){let t=(0,J.c)(12),{icon:n,className:r}=e,i=r===void 0?`size-3.5`:r;if(n===`test`){let e;return t[0]===i?e=t[1]:(e=(0,Y.jsx)(xl,{className:i}),t[0]=i,t[1]=e),e}if(n===`lint`){let e;return t[2]===i?e=t[3]:(e=(0,Y.jsx)(fi,{className:i}),t[2]=i,t[3]=e),e}if(n===`configure`){let e;return t[4]===i?e=t[5]:(e=(0,Y.jsx)(Qa,{className:i}),t[4]=i,t[5]=e),e}if(n===`build`){let e;return t[6]===i?e=t[7]:(e=(0,Y.jsx)(wl,{className:i}),t[6]=i,t[7]=e),e}if(n===`debug`){let e;return t[8]===i?e=t[9]:(e=(0,Y.jsx)(hl,{className:i}),t[8]=i,t[9]=e),e}let a;return t[10]===i?a=t[11]:(a=(0,Y.jsx)(Na,{className:i}),t[10]=i,t[11]=a),a}function CN(e){let t=e.toLowerCase();return t===`meta`||t===`control`||t===`ctrl`||t===`shift`||t===`alt`||t===`option`?null:t===` `?`space`:t===`escape`?`esc`:t===`arrowup`?`arrowup`:t===`arrowdown`?`arrowdown`:t===`arrowleft`?`arrowleft`:t===`arrowright`?`arrowright`:t.length===1||t.startsWith(`f`)&&t.length<=3||t===`enter`||t===`tab`||t===`backspace`||t===`delete`||t===`home`||t===`end`||t===`pageup`||t===`pagedown`?t:null}function wN(e){let t=CN(e.key);if(!t)return null;let n=[];return ao(navigator.platform)?(e.metaKey&&n.push(`mod`),e.ctrlKey&&n.push(`ctrl`)):(e.ctrlKey&&n.push(`mod`),e.metaKey&&n.push(`meta`)),e.altKey&&n.push(`alt`),e.shiftKey&&n.push(`shift`),n.length===0?null:(n.push(t),n.join(`+`))}function TN({scripts:e,keybindings:t,preferredScriptId:n=null,onRunScript:r,onAddScript:i,onUpdateScript:a,onDeleteScript:o}){let s=q.useId(),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(`play`),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(!1),[S,C]=(0,q.useState)(``),[w,T]=(0,q.useState)(null),[E,D]=(0,q.useState)(!1),O=(0,q.useMemo)(()=>{if(n){let t=e.find(e=>e.id===n);if(t)return t}return _N(e)},[n,e]),k=c!==null,A=`data-highlighted:bg-transparent data-highlighted:text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground data-highlighted:hover:bg-accent data-highlighted:hover:text-accent-foreground data-highlighted:focus-visible:bg-accent data-highlighted:focus-visible:text-accent-foreground`,j=e=>{if(e.key===`Tab`)return;if(e.preventDefault(),e.key===`Backspace`||e.key===`Delete`){C(``);return}let t=wN(e);t&&C(t)},M=async t=>{t.preventDefault();let n=f.trim(),r=m.trim();if(n.length===0){T(`Name is required.`);return}if(r.length===0){T(`Command is required.`);return}T(null);try{let t=c??gN(n,e.map(e=>e.id)),o=dN({keybinding:S,command:mN(t)}),s={name:n,command:r,icon:g,runOnWorktreeCreate:b,keybinding:o?.key??null};c?await a(c,s):await i(s),d(!1),y(!1)}catch(e){T(e instanceof Error?e.message:`Failed to save action.`)}},N=()=>{l(null),p(``),h(``),_(`play`),y(!1),x(!1),C(``),T(null),d(!0)},P=e=>{l(e.id),p(e.name),h(e.command),_(e.icon),y(!1),x(e.runOnWorktreeCreate),C(fN(t,mN(e.id))??``),T(null),d(!0)},F=(0,q.useCallback)(()=>{c&&(D(!1),d(!1),o(c))},[c,o]);return(0,Y.jsxs)(Y.Fragment,{children:[O?(0,Y.jsxs)(`div`,{"aria-label":`Project scripts`,className:vN,role:`group`,children:[(0,Y.jsxs)(K,{size:`xs`,variant:`ghost`,className:yN,onClick:()=>r(O),title:`Run ${O.name}`,children:[(0,Y.jsx)(SN,{icon:O.icon}),(0,Y.jsx)(`span`,{className:`sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5`,children:O.name})]}),(0,Y.jsxs)(rc,{highlightItemOnHover:!1,children:[(0,Y.jsx)(oc,{render:(0,Y.jsx)(K,{size:`icon-xs`,variant:`ghost`,className:bN,"aria-label":`Script actions`}),children:(0,Y.jsx)(Zr,{className:`size-4`})}),(0,Y.jsxs)(ec,{align:`end`,children:[e.map(e=>{let n=wo(t,mN(e.id));return(0,Y.jsxs)(sc,{className:`group ${A}`,onClick:()=>r(e),children:[(0,Y.jsx)(SN,{icon:e.icon,className:`size-4`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.runOnWorktreeCreate?`${e.name} (setup)`:e.name}),(0,Y.jsxs)(`span`,{className:`relative ms-auto flex h-6 min-w-6 items-center justify-end`,children:[n&&(0,Y.jsx)(nc,{className:`ms-0 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0`,children:n}),(0,Y.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-0 pointer-events-none transition-opacity group-hover:opacity-100 group-hover:pointer-events-auto group-focus-visible:opacity-100 group-focus-visible:pointer-events-auto`,"aria-label":`Edit ${e.name}`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>{t.preventDefault(),t.stopPropagation(),P(e)},children:(0,Y.jsx)(mr,{className:`size-3.5`})})]})]},e.id)}),(0,Y.jsxs)(sc,{className:A,onClick:N,children:[(0,Y.jsx)(Fa,{className:`size-4`}),`Add action`]})]})]})]}):(0,Y.jsxs)(K,{size:`xs`,variant:`ghost`,className:yN,onClick:N,title:`Add action`,children:[(0,Y.jsx)(Fa,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5`,children:`Add action`})]}),(0,Y.jsx)(Qs,{onOpenChange:e=>{d(e),e||y(!1)},onOpenChangeComplete:e=>{e||(l(null),p(``),h(``),_(`play`),x(!1),C(``),T(null))},open:u,children:(0,Y.jsxs)(Zs,{className:`project-glass-surface`,surface:`glass`,children:[(0,Y.jsxs)(Ks,{children:[(0,Y.jsx)(qs,{children:k?`Edit Action`:`Add Action`}),(0,Y.jsx)(Xs,{children:`Actions are project-scoped commands you can run from the top bar or keybindings.`})]}),(0,Y.jsx)(Ys,{children:(0,Y.jsxs)(`form`,{id:s,className:`space-y-4`,onSubmit:M,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(Mc,{htmlFor:`script-name`,children:`Name`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(Dc,{onOpenChange:y,open:v,children:[(0,Y.jsx)(Ec,{render:(0,Y.jsx)(K,{type:`button`,variant:`outline`,className:`size-9 shrink-0 hover:bg-popover active:bg-popover data-pressed:bg-popover data-pressed:shadow-xs/5 data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] dark:data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)]`,"aria-label":`Choose icon`}),children:(0,Y.jsx)(SN,{icon:g,className:`size-4.5`})}),(0,Y.jsx)(Tc,{align:`start`,children:(0,Y.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:xN.map(e=>{let t=e.id===g;return(0,Y.jsxs)(`button`,{type:`button`,className:`relative flex flex-col items-center gap-2 rounded-md border px-2 py-2 text-xs ${t?`border-primary/70 bg-primary/10`:`border-border/70 hover:bg-accent/60`}`,onClick:()=>{_(e.id),y(!1)},children:[(0,Y.jsx)(SN,{icon:e.id,className:`size-4`}),(0,Y.jsx)(`span`,{children:e.label})]},e.id)})})})]}),(0,Y.jsx)(ys,{id:`script-name`,autoFocus:!0,placeholder:`Test`,value:f,onChange:e=>p(e.target.value)})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(Mc,{htmlFor:`script-keybinding`,children:`Keybinding`}),(0,Y.jsx)(ys,{id:`script-keybinding`,placeholder:`Press shortcut`,value:S,readOnly:!0,onKeyDown:j}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Press a shortcut. Use `,(0,Y.jsx)(`code`,{children:`Backspace`}),` to clear.`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(Mc,{htmlFor:`script-command`,children:`Command`}),(0,Y.jsx)(uc,{id:`script-command`,placeholder:`bun test`,value:m,onChange:e=>h(e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm`,children:[(0,Y.jsx)(`span`,{children:`Run automatically on worktree creation`}),(0,Y.jsx)(vs,{checked:b,onCheckedChange:e=>x(!!e)})]}),w&&(0,Y.jsx)(`p`,{className:`text-sm text-destructive`,children:w})]})}),(0,Y.jsxs)(Js,{children:[k&&(0,Y.jsx)(K,{type:`button`,variant:`destructive-outline`,className:`mr-auto`,onClick:()=>D(!0),children:`Delete`}),(0,Y.jsx)(K,{type:`button`,variant:`outline`,onClick:()=>{d(!1)},children:`Cancel`}),(0,Y.jsx)(K,{form:s,type:`submit`,children:k?`Save changes`:`Save action`})]})]})}),(0,Y.jsx)(_c,{open:E,onOpenChange:D,children:(0,Y.jsxs)(mc,{children:[(0,Y.jsxs)(dc,{children:[(0,Y.jsxs)(gc,{children:[`Delete action "`,f,`"?`]}),(0,Y.jsx)(hc,{children:`This action cannot be undone.`})]}),(0,Y.jsxs)(fc,{children:[(0,Y.jsx)(pc,{render:(0,Y.jsx)(K,{variant:`outline`}),children:`Cancel`}),(0,Y.jsx)(K,{variant:`destructive`,onClick:F,children:`Delete action`})]})]})})]})}var EN=(0,q.memo)(function(e){let t=(0,J.c)(44),{keybindings:n,availableEditors:r,openInCwd:i}=e,[a,o]=Oc(r),s;t[0]===r?s=t[1]:(s=al(navigator.platform,r),t[0]=r,t[1]=s);let c=s,l;t[2]!==c||t[3]!==a?(l=c.find(e=>{let{value:t}=e;return t===a})??null,t[2]=c,t[3]=a,t[4]=l):l=t[4];let u=l,d;t[5]!==i||t[6]!==a||t[7]!==o?(d=e=>{let t=he();if(!t||!i)return;let n=e??a;n&&t.shell.openInEditor(i,n).then(()=>{Ac(n)&&o(n)}).catch(e=>{console.error(`Failed to open ${n}.`,e)})},t[5]=i,t[6]=a,t[7]=o,t[8]=d):d=t[8];let f=d,p;t[9]===n?p=t[10]:(p=wo(n,`editor.openFavorite`),t[9]=n,t[10]=p);let m=p,h,g;t[11]!==n||t[12]!==i||t[13]!==a?(h=()=>{let e=e=>{let t=he();Mo(e)||Ao(e,n)&&(!t||!i||a&&(e.preventDefault(),t.shell.openInEditor(i,a)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},g=[a,n,i],t[11]=n,t[12]=i,t[13]=a,t[14]=h,t[15]=g):(h=t[14],g=t[15]),(0,q.useEffect)(h,g);let _=!a||!i,v;t[16]!==f||t[17]!==a?(v=()=>f(a),t[16]=f,t[17]=a,t[18]=v):v=t[18];let y;t[19]===u?y=t[20]:(y=u?.Icon&&(0,Y.jsx)(u.Icon,{"aria-hidden":`true`,className:`size-3.5`}),t[19]=u,t[20]=y);let b;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Y.jsx)(`span`,{className:`sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5`,children:`Open`}),t[21]=b):b=t[21];let x;t[22]!==_||t[23]!==v||t[24]!==y?(x=(0,Y.jsxs)(K,{size:`xs`,variant:`ghost`,className:yN,disabled:_,onClick:v,children:[y,b]}),t[22]=_,t[23]=v,t[24]=y,t[25]=x):x=t[25];let S;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Y.jsx)(oc,{render:(0,Y.jsx)(K,{"aria-label":`Copy options`,className:bN,size:`icon-xs`,variant:`ghost`}),children:(0,Y.jsx)(Zr,{"aria-hidden":`true`,className:`size-4`})}),t[26]=S):S=t[26];let C;t[27]===c.length?C=t[28]:(C=c.length===0&&(0,Y.jsx)(sc,{disabled:!0,children:`No installed editors found`}),t[27]=c.length,t[28]=C);let w;if(t[29]!==m||t[30]!==f||t[31]!==c||t[32]!==a){let e;t[34]!==m||t[35]!==f||t[36]!==a?(e=e=>{let{label:t,Icon:n,value:r}=e;return(0,Y.jsxs)(sc,{onClick:()=>f(r),children:[(0,Y.jsx)(n,{"aria-hidden":`true`,className:`text-muted-foreground`}),t,r===a&&m&&(0,Y.jsx)(nc,{children:m})]},r)},t[34]=m,t[35]=f,t[36]=a,t[37]=e):e=t[37],w=c.map(e),t[29]=m,t[30]=f,t[31]=c,t[32]=a,t[33]=w}else w=t[33];let T;t[38]!==C||t[39]!==w?(T=(0,Y.jsxs)(rc,{children:[S,(0,Y.jsxs)(ec,{align:`end`,children:[C,w]})]}),t[38]=C,t[39]=w,t[40]=T):T=t[40];let E;return t[41]!==x||t[42]!==T?(E=(0,Y.jsxs)(`div`,{"aria-label":`Subscription actions`,className:vN,role:`group`,children:[x,T]}),t[41]=x,t[42]=T,t[43]=E):E=t[43],E}),DN=new Set([`main`,`master`]);function ON(e){if(e.origin===`main`)return!1;if(e.origin&&e.origin!==null)return!0;let t=e.branch?.trim()??``;return!(t.length===0||DN.has(t))}var kN=(0,q.memo)(function(e){let t=(0,J.c)(20),n;t[0]!==e.worktreeBranch||t[1]!==e.worktreeOrigin?(n=ON({origin:e.worktreeOrigin,branch:e.worktreeBranch}),t[0]=e.worktreeBranch,t[1]=e.worktreeOrigin,t[2]=n):n=t[2];let r=n,i;t[3]!==e.worktreeBranch||t[4]!==e.worktreeTitle?(i=(e.worktreeTitle?.trim()||e.worktreeBranch?.trim())??null,t[3]=e.worktreeBranch,t[4]=e.worktreeTitle,t[5]=i):i=t[5];let a=i,o;t[6]!==e.onSelectProject||t[7]!==e.projectName?(o=e.projectName?(0,Y.jsx)(AN,{label:e.projectName,onSelect:e.onSelectProject,prominent:!0}):null,t[6]=e.onSelectProject,t[7]=e.projectName,t[8]=o):o=t[8];let s;t[9]!==e.onSelectWorktree||t[10]!==r||t[11]!==a?(s=r&&a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ii,{className:`size-3 shrink-0 text-muted-foreground/60`,"aria-hidden":!0}),(0,Y.jsx)(AN,{label:a,onSelect:e.onSelectWorktree,mono:!0})]}):null,t[9]=e.onSelectWorktree,t[10]=r,t[11]=a,t[12]=s):s=t[12];let c;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Y.jsx)(ii,{className:`size-3 shrink-0 text-muted-foreground/60`,"aria-hidden":!0}),t[13]=c):c=t[13];let l;t[14]===e.sessionTitle?l=t[15]:(l=(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-foreground/85`,title:e.sessionTitle,children:e.sessionTitle}),t[14]=e.sessionTitle,t[15]=l);let u;return t[16]!==o||t[17]!==s||t[18]!==l?(u=(0,Y.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm font-medium`,children:[o,s,c,l]}),t[16]=o,t[17]=s,t[18]=l,t[19]=u):u=t[19],u});function AN(e){let t=(0,J.c)(16),n=e.mono?`font-mono text-xs`:``,r;t[0]===n?r=t[1]:(r=G(`min-w-0 truncate`,n),t[0]=n,t[1]=r);let i;t[2]!==e.label||t[3]!==r?(i=(0,Y.jsx)(`span`,{className:r,title:e.label,children:e.label}),t[2]=e.label,t[3]=r,t[4]=i):i=t[4];let a=i;if(e.onSelect){let n=e.onSelect,r=e.prominent?`text-foreground`:``,i;t[5]===r?i=t[6]:(i=G(`inline-flex min-w-0 items-center rounded-md px-1 py-0.5 -mx-1 text-foreground/80 hover:bg-accent/50 hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring`,r),t[5]=r,t[6]=i);let o;return t[7]!==e.onSelect||t[8]!==i||t[9]!==a?(o=(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:i,children:a}),t[7]=e.onSelect,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let o=e.prominent?`text-foreground`:`text-foreground/80`,s;t[11]===o?s=t[12]:(s=G(`min-w-0`,o),t[11]=o,t[12]=s);let c;return t[13]!==s||t[14]!==a?(c=(0,Y.jsx)(`span`,{className:s,children:a}),t[13]=s,t[14]=a,t[15]=c):c=t[15],c}var jN=(0,q.memo)(function(e){let t=(0,J.c)(35),n;t[0]===e.onSelectProject?n=t[1]:(n=e.onSelectProject?{onSelectProject:e.onSelectProject}:{},t[0]=e.onSelectProject,t[1]=n);let r;t[2]===e.onSelectWorktree?r=t[3]:(r=e.onSelectWorktree?{onSelectWorktree:e.onSelectWorktree}:{},t[2]=e.onSelectWorktree,t[3]=r);let i;t[4]!==e.projectName||t[5]!==e.sessionTitle||t[6]!==e.worktreeBranch||t[7]!==e.worktreeOrigin||t[8]!==e.worktreeTitle||t[9]!==n||t[10]!==r?(i=(0,Y.jsx)(kN,{projectName:e.projectName,worktreeBranch:e.worktreeBranch,worktreeTitle:e.worktreeTitle,worktreeOrigin:e.worktreeOrigin,sessionTitle:e.sessionTitle,...n,...r}),t[4]=e.projectName,t[5]=e.sessionTitle,t[6]=e.worktreeBranch,t[7]=e.worktreeOrigin,t[8]=e.worktreeTitle,t[9]=n,t[10]=r,t[11]=i):i=t[11];let a;t[12]!==e.onOpenLinkedWorktreeItem||t[13]!==e.worktreeIssueNumber||t[14]!==e.worktreeIssueState||t[15]!==e.worktreePrIsDraft||t[16]!==e.worktreePrNumber||t[17]!==e.worktreePrState||t[18]!==e.worktreeWorkItemKey||t[19]!==e.worktreeWorkItemProvider||t[20]!==e.worktreeWorkItemState||t[21]!==e.worktreeWorkItemStateName?(a=(0,Y.jsx)(Hi,{issueNumber:e.worktreeIssueNumber,issueState:e.worktreeIssueState,prNumber:e.worktreePrNumber,prState:e.worktreePrState,prIsDraft:e.worktreePrIsDraft,workItemProvider:e.worktreeWorkItemProvider,workItemKey:e.worktreeWorkItemKey,workItemState:e.worktreeWorkItemState,workItemStateName:e.worktreeWorkItemStateName,density:`header`,labelStyle:`kind`,onOpenLinkedItem:e.onOpenLinkedWorktreeItem}),t[12]=e.onOpenLinkedWorktreeItem,t[13]=e.worktreeIssueNumber,t[14]=e.worktreeIssueState,t[15]=e.worktreePrIsDraft,t[16]=e.worktreePrNumber,t[17]=e.worktreePrState,t[18]=e.worktreeWorkItemKey,t[19]=e.worktreeWorkItemProvider,t[20]=e.worktreeWorkItemState,t[21]=e.worktreeWorkItemStateName,t[22]=a):a=t[22];let o;t[23]!==e.isGitRepo||t[24]!==e.projectName?(o=e.projectName&&!e.isGitRepo?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-full border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[10px] text-amber-600 dark:text-amber-400`,children:`No Git`}):null,t[23]=e.isGitRepo,t[24]=e.projectName,t[25]=o):o=t[25];let s;t[26]!==i||t[27]!==a||t[28]!==o?(s=(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 overflow-hidden`,children:[i,a,o]}),t[26]=i,t[27]=a,t[28]=o,t[29]=s):s=t[29];let c;t[30]===e.inlineActions?c=t[31]:(c=e.inlineActions?(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 @3xl/header-actions:gap-3`,children:e.inlineActions}):null,t[30]=e.inlineActions,t[31]=c);let l;return t[32]!==s||t[33]!==c?(l=(0,Y.jsxs)(`div`,{className:`@container/header-actions flex min-w-0 flex-1 items-center gap-3`,children:[s,c]}),t[32]=s,t[33]=c,t[34]=l):l=t[34],l});function MN(e){return!!e.activeProjectName&&e.primaryEnvironmentId!==null&&e.activeThreadEnvironmentId===e.primaryEnvironmentId}var NN=(0,q.memo)(function(e){let t=(0,J.c)(73);ti(`ChatHeader`),Qr(e,`ChatHeader`);let n=nt(),r;t[0]!==n||t[1]!==e.activeProjectName||t[2]!==e.activeThreadEnvironmentId?(r=MN({activeProjectName:e.activeProjectName,activeThreadEnvironmentId:e.activeThreadEnvironmentId,primaryEnvironmentId:n}),t[0]=n,t[1]=e.activeProjectName,t[2]=e.activeThreadEnvironmentId,t[3]=r):r=t[3];let i=r,a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Y.jsx)(ka,{}),t[4]=a):a=t[4];let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Y.jsx)(fi,{className:`size-4`}),t[5]=o):o=t[5];let s;t[6]!==e.onToggleOverviewSidebar||t[7]!==e.overviewSidebarOpen?(s=(0,Y.jsx)(Fo,{render:(0,Y.jsx)(Gc,{pressed:e.overviewSidebarOpen,onPressedChange:e.onToggleOverviewSidebar,"aria-label":`Toggle overview panel`,className:bN,size:`sm`,children:o})}),t[6]=e.onToggleOverviewSidebar,t[7]=e.overviewSidebarOpen,t[8]=s):s=t[8];let c;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Y.jsx)(Io,{side:`bottom`,children:`Toggle overview panel`}),t[9]=c):c=t[9];let l;t[10]===s?l=t[11]:(l=(0,Y.jsxs)(Lo,{children:[s,c]}),t[10]=s,t[11]=l);let u;t[12]===e.liveAgentCount?u=t[13]:(u=e.liveAgentCount>0?`Toggle workspace panel, ${Qi(e.liveAgentCount)}`:`Toggle workspace panel`,t[12]=e.liveAgentCount,t[13]=u);let d;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Y.jsx)(kl,{className:`size-4`}),t[14]=d):d=t[14];let f;t[15]===e.liveAgentCount?f=t[16]:(f=(0,Y.jsxs)(`span`,{className:`relative inline-flex`,children:[d,(0,Y.jsx)(ra,{count:e.liveAgentCount,className:`-top-2 -right-2.5 h-3.5 min-w-3.5 px-0.5 text-[8px]`})]}),t[15]=e.liveAgentCount,t[16]=f);let p;t[17]!==e.onToggleWorkspacePanel||t[18]!==e.workspacePanelOpen||t[19]!==u||t[20]!==f?(p=(0,Y.jsx)(Fo,{render:(0,Y.jsx)(Gc,{pressed:e.workspacePanelOpen,onPressedChange:e.onToggleWorkspacePanel,"aria-label":u,className:bN,size:`sm`,children:f})}),t[17]=e.onToggleWorkspacePanel,t[18]=e.workspacePanelOpen,t[19]=u,t[20]=f,t[21]=p):p=t[21];let m;t[22]===e.liveAgentCount?m=t[23]:(m=e.liveAgentCount>0?`Workspace · ${Qi(e.liveAgentCount)}`:`Toggle workspace panel`,t[22]=e.liveAgentCount,t[23]=m);let h;t[24]===m?h=t[25]:(h=(0,Y.jsx)(Io,{side:`bottom`,children:m}),t[24]=m,t[25]=h);let g;t[26]!==h||t[27]!==p?(g=(0,Y.jsxs)(Lo,{children:[p,h]}),t[26]=h,t[27]=p,t[28]=g):g=t[28];let _;t[29]!==e.activeProjectScripts||t[30]!==e.keybindings||t[31]!==e.onAddProjectScript||t[32]!==e.onDeleteProjectScript||t[33]!==e.onRunProjectScript||t[34]!==e.onUpdateProjectScript||t[35]!==e.preferredScriptId?(_=e.activeProjectScripts?(0,Y.jsx)(TN,{scripts:e.activeProjectScripts,keybindings:e.keybindings,preferredScriptId:e.preferredScriptId,onRunScript:e.onRunProjectScript,onAddScript:e.onAddProjectScript,onUpdateScript:e.onUpdateProjectScript,onDeleteScript:e.onDeleteProjectScript}):null,t[29]=e.activeProjectScripts,t[30]=e.keybindings,t[31]=e.onAddProjectScript,t[32]=e.onDeleteProjectScript,t[33]=e.onRunProjectScript,t[34]=e.onUpdateProjectScript,t[35]=e.preferredScriptId,t[36]=_):_=t[36];let v;t[37]!==e.availableEditors||t[38]!==e.keybindings||t[39]!==e.openInCwd||t[40]!==i?(v=i?(0,Y.jsx)(EN,{keybindings:e.keybindings,availableEditors:e.availableEditors,openInCwd:e.openInCwd}):null,t[37]=e.availableEditors,t[38]=e.keybindings,t[39]=e.openInCwd,t[40]=i,t[41]=v):v=t[41];let y;t[42]!==g||t[43]!==_||t[44]!==v||t[45]!==l?(y=(0,Y.jsxs)(Y.Fragment,{children:[a,l,g,_,v]}),t[42]=g,t[43]=_,t[44]=v,t[45]=l,t[46]=y):y=t[46];let b=y,x;t[47]===e.onSelectProject?x=t[48]:(x=e.onSelectProject?{onSelectProject:e.onSelectProject}:{},t[47]=e.onSelectProject,t[48]=x);let S;t[49]===e.onSelectWorktree?S=t[50]:(S=e.onSelectWorktree?{onSelectWorktree:e.onSelectWorktree}:{},t[49]=e.onSelectWorktree,t[50]=S);let C;t[51]===e.onOpenLinkedWorktreeItem?C=t[52]:(C=e.onOpenLinkedWorktreeItem?{onOpenLinkedWorktreeItem:e.onOpenLinkedWorktreeItem}:{},t[51]=e.onOpenLinkedWorktreeItem,t[52]=C);let w;return t[53]!==b||t[54]!==e.activeProjectName||t[55]!==e.activeThreadTitle||t[56]!==e.isGitRepo||t[57]!==e.worktreeBranch||t[58]!==e.worktreeIssueNumber||t[59]!==e.worktreeIssueState||t[60]!==e.worktreeOrigin||t[61]!==e.worktreePrIsDraft||t[62]!==e.worktreePrNumber||t[63]!==e.worktreePrState||t[64]!==e.worktreeTitle||t[65]!==e.worktreeWorkItemKey||t[66]!==e.worktreeWorkItemProvider||t[67]!==e.worktreeWorkItemState||t[68]!==e.worktreeWorkItemStateName||t[69]!==x||t[70]!==S||t[71]!==C?(w=(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 py-3`,children:(0,Y.jsx)(jN,{projectName:e.activeProjectName,isGitRepo:e.isGitRepo,worktreeBranch:e.worktreeBranch,worktreeTitle:e.worktreeTitle,worktreeOrigin:e.worktreeOrigin,worktreeIssueNumber:e.worktreeIssueNumber,worktreeIssueState:e.worktreeIssueState,worktreePrNumber:e.worktreePrNumber,worktreePrState:e.worktreePrState,worktreePrIsDraft:e.worktreePrIsDraft,worktreeWorkItemProvider:e.worktreeWorkItemProvider,worktreeWorkItemKey:e.worktreeWorkItemKey,worktreeWorkItemState:e.worktreeWorkItemState,worktreeWorkItemStateName:e.worktreeWorkItemStateName,sessionTitle:e.activeThreadTitle,...x,...S,...C,inlineActions:b})}),t[53]=b,t[54]=e.activeProjectName,t[55]=e.activeThreadTitle,t[56]=e.isGitRepo,t[57]=e.worktreeBranch,t[58]=e.worktreeIssueNumber,t[59]=e.worktreeIssueState,t[60]=e.worktreeOrigin,t[61]=e.worktreePrIsDraft,t[62]=e.worktreePrNumber,t[63]=e.worktreePrState,t[64]=e.worktreeTitle,t[65]=e.worktreeWorkItemKey,t[66]=e.worktreeWorkItemProvider,t[67]=e.worktreeWorkItemState,t[68]=e.worktreeWorkItemStateName,t[69]=x,t[70]=S,t[71]=C,t[72]=w):w=t[72],w});function PN(e){let t=(0,J.c)(20),n=Qn(),r=oe(eo(le)),i;t[0]!==e.environmentId||t[1]!==e.threadId||t[2]!==r?(i=r.find(t=>t.id===e.threadId&&t.environmentId===e.environmentId)??null,t[0]=e.environmentId,t[1]=e.threadId,t[2]=r,t[3]=i):i=t[3];let a=i,o;t[4]===n?o=t[5]:(o=()=>void n({to:`/`}),t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Y.jsx)(qr,{}),t[6]=s):s=t[6];let c;t[7]===o?c=t[8]:(c=(0,Y.jsx)(K,{size:`icon`,variant:`ghost`,"aria-label":`Back to threads`,className:`shrink-0`,onClick:o,children:s}),t[7]=o,t[8]=c);let l;t[9]===e.title?l=t[10]:(l=(0,Y.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.title}),t[9]=e.title,t[10]=l);let u;t[11]===a?u=t[12]:(u=a?(0,Y.jsx)(`span`,{className:`flex items-center gap-1.5`,children:(0,Y.jsx)(_r,{thread:a,alwaysShowStatusLabel:!0})}):null,t[11]=a,t[12]=u);let d;t[13]!==l||t[14]!==u?(d=(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[l,u]}),t[13]=l,t[14]=u,t[15]=d):d=t[15];let f;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Y.jsx)(Oa,{}),t[16]=f):f=t[16];let p;return t[17]!==c||t[18]!==d?(p=(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 py-2`,children:[c,d,f]}),t[17]=c,t[18]=d,t[19]=p):p=t[19],p}var FN=`w-full min-w-0 max-w-none border-s-0 p-0 pt-[env(safe-area-inset-top)] pl-safe pr-safe pb-[max(env(safe-area-inset-bottom),var(--app-keyboard-inset,0px))] wco:mt-[env(titlebar-area-height)] wco:h-[calc(100%-env(titlebar-area-height))] wco:max-h-[calc(100%-env(titlebar-area-height))]`;function IN(e){let t=(0,J.c)(14),n;t[0]===e.open?n=t[1]:(n=Ps({active:e.open,containIntrinsicSize:`100vw 100vh`}),t[0]=e.open,t[1]=n);let r=n,i;t[2]===e?i=t[3]:(i=t=>{t||e.onClose()},t[2]=e,t[3]=i);let a;t[4]!==r||t[5]!==e.children?(a=(0,Y.jsx)(`div`,{className:`flex min-h-0 w-full flex-1`,style:r,children:e.children}),t[4]=r,t[5]=e.children,t[6]=a):a=t[6];let o;t[7]!==e.label||t[8]!==a?(o=(0,Y.jsx)(Is,{side:`right`,showCloseButton:!1,keepMounted:!0,"aria-label":e.label,className:FN,children:a}),t[7]=e.label,t[8]=a,t[9]=o):o=t[9];let s;return t[10]!==e.open||t[11]!==i||t[12]!==o?(s=(0,Y.jsx)(Ls,{open:e.open,onOpenChange:i,children:o}),t[10]=e.open,t[11]=i,t[12]=o,t[13]=s):s=t[13],s}function LN(e){let t=(0,J.c)(14),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Y.jsx)(qr,{}),t[0]=n):n=t[0];let r;t[1]!==e.backLabel||t[2]!==e.onBack?(r=(0,Y.jsx)(K,{size:`icon`,variant:`ghost`,"aria-label":e.backLabel,className:`shrink-0`,onClick:e.onBack,children:n}),t[1]=e.backLabel,t[2]=e.onBack,t[3]=r):r=t[3];let i;t[4]===e.title?i=t[5]:(i=(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:e.title}),t[4]=e.title,t[5]=i);let a;t[6]!==r||t[7]!==i?(a=(0,Y.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-1.5 border-b border-border bg-card/40 px-2`,children:[r,i]}),t[6]=r,t[7]=i,t[8]=a):a=t[8];let o;t[9]===e.children?o=t[10]:(o=(0,Y.jsx)(`div`,{className:`flex min-h-0 w-full min-w-0 flex-1`,children:e.children}),t[9]=e.children,t[10]=o);let s;return t[11]!==a||t[12]!==o?(s=(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 w-full min-w-0 flex-col bg-background`,children:[a,o]}),t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function RN(e,t,n=6){if(n<=0||e.length===0)return[];let r=Math.floor(n),i=t===null?-1:e.findIndex(e=>e.key===t);if(i<0)return e.map(e=>e.key).filter(e=>e!==t).slice(0,r);let a=[];for(let t=1;a.length<r;t+=1){let n=e[i-t],o=e[i+t];if(!n&&!o||n&&(a.push(n.key),a.length>=r))break;o&&a.push(o.key)}return a}function zN(e){let t=(0,J.c)(7),{activeWorktreeSessionTabs:n,activeSessionTabKey:r}=e,i,a;t[0]!==r||t[1]!==n?(i=()=>{if(n.length===0)return;let e=[];for(let t of RN(n,r)){let n=s(t);n&&e.push(Ie(n.environmentId,n.threadId))}return()=>{for(let t of e)t()}},a=[n,r],t[0]=r,t[1]=n,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,q.useEffect)(i,a);let o,c;t[4]===r?(o=t[5],c=t[6]):(o=()=>{if(!r)return;let e=r;queueMicrotask(()=>ei(e))},c=[r],t[4]=r,t[5]=o,t[6]=c),(0,q.useEffect)(o,c)}function BN(e){return{id:e.threadId,environmentId:e.environmentId,projectId:e.projectId,title:`Empty Session`,interactionMode:e.interactionMode,tokenMode:e.tokenMode??`balanced`,session:null,createdAt:e.createdAt,archivedAt:null,settledOverride:null,settledAt:null,updatedAt:e.createdAt,latestTurn:null,branch:e.branch,worktreePath:e.worktreePath,manualStatusBucket:null,latestUserMessageAt:null,hasPendingApprovals:!1,hasPendingUserInput:!1,hasActionableProposedPlan:!1}}function VN(e,t){return e.worktreeId!==void 0&&e.worktreeId!==null&&t.worktreeId&&e.worktreeId===t.worktreeId||t.worktreePath&&e.worktreePath===t.worktreePath?!0:!t.worktreeId&&!t.worktreePath&&e.worktreePath===null}function HN(){let e=new Map,t=null;return(n,r)=>{let a=[];for(let e of n)e.archivedAt===null&&VN(e,r)&&a.push(e);a.sort((e,t)=>(Date.parse(t.updatedAt??t.createdAt??``)||0)-(Date.parse(e.updatedAt??e.createdAt??``)||0));let o=new Set,s=[],c=t!==null&&t.length===a.length;for(let n=0;n<a.length;n+=1){let r=a[n],l=f(i(r.environmentId,r.id));o.add(l);let u=Nn({manualBucket:r.manualStatusBucket??null,statusPill:Pn({thread:r})}),d=e.get(l),p;d&&d.inputs.title===r.title&&d.inputs.bucket===u?p=d.item:(p={key:l,title:r.title,bucket:u},e.set(l,{item:p,inputs:{title:r.title,bucket:u}})),s.push(p),c&&t[n]!==p&&(c=!1)}for(let t of e.keys())o.has(t)||e.delete(t);return c&&t?t:(t=s,s)}}var UN=(0,q.memo)(function(e){let t=(0,J.c)(13),{status:n}=e;if(!n||n.status===`ready`||n.status===`disabled`)return null;let r;t[0]!==n.displayName||t[1]!==n.driver?(r=n.displayName?.trim()||Nt(n.driver),t[0]=n.displayName,t[1]=n.driver,t[2]=r):r=t[2];let i=r,a=n.status===`error`?`${i} provider is unavailable.`:`${i} provider has limited availability.`,o=`${i} provider status`,s=n.status===`error`?`error`:`warning`,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Y.jsx)(Oi,{}),t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,Y.jsx)(Hs,{children:o}),t[4]=o,t[5]=l);let u=n.message??a,d=n.message??a,f;t[6]!==u||t[7]!==d?(f=(0,Y.jsx)(Ws,{className:`line-clamp-3`,title:u,children:d}),t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;return t[9]!==s||t[10]!==l||t[11]!==f?(p=(0,Y.jsx)(`div`,{className:`pt-3 mx-auto max-w-3xl`,children:(0,Y.jsxs)(Gs,{variant:s,children:[c,l,f]})}),t[9]=s,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}),WN=(0,q.memo)(function(e){let t=(0,J.c)(8),{error:n,threadRef:r,onDismiss:i}=e,a=r?.environmentId??null,o=r?.threadId??null,s=(0,q.useRef)(i),c,l;t[0]===i?(c=t[1],l=t[2]):(c=()=>{s.current=i},l=[i],t[0]=i,t[1]=c,t[2]=l),(0,q.useEffect)(c,l);let u,d;return t[3]!==a||t[4]!==n||t[5]!==o?(u=()=>{if(!n)return;let e=!0,t=Ai.add({type:`error`,title:`Thread error`,description:n,priority:`high`,timeout:0,onClose:()=>{e&&s.current?.()},data:{threadRef:a!==null&&o!==null?{environmentId:a,threadId:o}:null}});return()=>{e=!1,Ai.close(t)}},d=[a,n,o],t[3]=a,t[4]=n,t[5]=o,t[6]=u,t[7]=d):(u=t[6],d=t[7]),(0,q.useEffect)(u,d),null}),GN={hydrated:!1,revision:0,proposalsById:{}},KN=20,qN=new Set(D);function JN(e){return qN.has(e)}var YN={"pending-user-approval":0,approved:1,executing:2,rejected:3,expired:3,completed:3,failed:3,cancelled:3};function XN(e){let t=Object.values(e).filter(e=>JN(e.status));if(t.length<=KN)return e;let n=t.toSorted((e,t)=>t.updatedAt.localeCompare(e.updatedAt)).slice(KN),r={...e};for(let e of n)delete r[e.proposalId];return r}function ZN(e,t){if(t.type===`snapshot`){let e={};for(let n of[...t.queue.active,...t.queue.recent])e[n.proposalId]=n;return{hydrated:!0,revision:t.queue.revision,proposalsById:e}}if(!e.hydrated)return e;let n=t.proposal,r=e.proposalsById[n.proposalId];if(r!==void 0){let t=YN[r.status],i=YN[n.status];if(i<t||i===t)return e}return{hydrated:!0,revision:Math.max(e.revision,t.revision),proposalsById:XN({...e.proposalsById,[n.proposalId]:n})}}function QN(e){return Object.values(e.proposalsById).filter(e=>!JN(e.status)).toSorted((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.proposalId.localeCompare(t.proposalId))}function $N(e){return Object.values(e.proposalsById).filter(e=>JN(e.status)).toSorted((e,t)=>t.updatedAt.localeCompare(e.updatedAt)||t.proposalId.localeCompare(e.proposalId))}var eP={"pending-user-approval":{label:`Awaiting approval`,tone:`pending`},approved:{label:`Approved · awaiting executor`,tone:`info`},executing:{label:`Executing`,tone:`info`},completed:{label:`Completed`,tone:`success`},failed:{label:`Failed`,tone:`danger`},rejected:{label:`Rejected`,tone:`muted`},expired:{label:`Expired`,tone:`muted`},cancelled:{label:`Cancelled`,tone:`muted`}},tP=e=>e.length>10?`${e.slice(0,8)}…`:e,nP=e=>e.replaceAll(`-`,` `);function rP(e){let t=e.principal;return t.kind===`provider-session`?{label:`Agent in thread ${tP(t.threadId)} (${t.providerInstanceId})`,threadId:t.threadId}:{label:`External integration ${t.label??tP(t.integrationId)}`,threadId:null}}function iP(e){let t=e=>e.kind===`once`?[`Schedule: one-shot`,`Next run: ${e.runAt}`]:[`Schedule: every ${e.intervalMs}ms`,`Next run: ${e.startsAt}`,`Ends: ${e.endsAt}`,`Missed intervals coalesce into at most one pending run.`],n=[`Limits: 25 active schedules per project; minimum interval ${L}ms.`,`Horizon: ${A}ms; retained run history: 50.`],r=e=>[`Project: ${e.projectId}`,`Provider: ${e.modelSelection.instanceId} · ${e.modelSelection.model}`,`Runtime: ${e.runtimeMode} · ${e.envMode}`,...e.baseRef===void 0?[]:[`Base ref: ${e.baseRef}`],`Intended work: ${e.title}`,`Prompt: ${e.prompt}`],i=e.plan,a=(e,t)=>[{heading:`Exact governed Simulator action`,lines:[`Device UDID: ${e.udid}`,`Thread: ${e.threadId}`,`Project: ${e.projectId}`,`Expected project revision: ${e.expectedProjectUpdatedAt}`,`Provider instance: ${e.providerInstanceId}`,`Expected attachment version: ${e.expectedThreadDeviceVersion}`,`Expected attached device: ${e.expectedAttachedDeviceUdid??`none`}`,`Expected lifecycle: ${e.expectedDeviceState}`,`Expected boot owner: ${e.expectedDeviceBootSource}`,`Expected recording: ${e.expectedRecording?`yes`:`no`}`,...t,`Execution stops if the device, attachment, thread, project, provider, or owner authority changes.`]}];switch(i.kind){case`createThreads`:{let e=i.entries.length,t=[...new Set(i.entries.map(e=>String(e.projectId)))],n=[...new Set(i.entries.map(e=>`${e.runtimeMode} · ${e.envMode}`))];return{actionLabel:e===1?`Create 1 thread`:`Create ${e} threads`,targetLabel:t.length===1?`project ${tP(t[0])}`:`${t.length} projects`,runtimeLabel:n.length===1?n[0]:`mixed runtime modes`,detailSections:i.entries.map((e,t)=>({heading:`Thread ${t+1}: ${e.title}`,lines:[`Project: ${e.projectId}`,`Model: ${e.modelSelection.instanceId} · ${e.modelSelection.model}`,`Runtime: ${e.runtimeMode} · ${e.envMode}`,...e.baseRef===void 0?[]:[`Base ref: ${e.baseRef}`],`Prompt: ${e.prompt}`]}))}}case`sendMessage`:return{actionLabel:i.delivery===`steer`?`Steer thread`:`Queue message`,targetLabel:`thread ${tP(i.threadId)}`,runtimeLabel:null,detailSections:[{heading:`Message`,lines:[`Thread: ${i.threadId}`,i.text]}]};case`interruptThread`:return{actionLabel:`Interrupt thread`,targetLabel:`thread ${tP(i.threadId)}`,runtimeLabel:null,detailSections:[{heading:`Interrupt`,lines:[`Thread: ${i.threadId}`,...i.turnId===void 0?[]:[`Only turn: ${i.turnId}`]]}]};case`updateThread`:{let e=[];return i.title!==void 0&&e.push(`Title: ${i.title}`),i.archived!==void 0&&e.push(i.archived?`Archive thread`:`Unarchive thread`),i.persistentGoal!==void 0&&e.push(i.persistentGoal===null?`Clear persistent goal`:`Goal: ${i.persistentGoal}`),{actionLabel:`Update thread`,targetLabel:`thread ${tP(i.threadId)}`,runtimeLabel:null,detailSections:[{heading:`Changes`,lines:[`Thread: ${i.threadId}`,...e]}]}}case`createProject`:return{actionLabel:`Create project`,targetLabel:`project ${tP(i.projectId)}`,runtimeLabel:null,detailSections:[{heading:`Before`,lines:[`No Ryco project record with this ID.`]},{heading:`After`,lines:[`Project ID: ${i.projectId}`,`Display name: ${i.title}`,`Workspace path: ${i.workspaceRoot}`,`Metadata directory: ${i.projectMetadataDir}`,`Repository identity: ${i.repositoryIdentityKey??`none`}`,`Workspace must already exist; no directory is created by this action.`]}]};case`updateProject`:return{actionLabel:`Update project metadata`,targetLabel:`project ${tP(i.projectId)}`,runtimeLabel:null,detailSections:[{heading:`Before`,lines:[`Display name: ${i.before.title}`,`Workspace path: ${i.before.workspaceRoot}`,`Repository identity: ${i.before.repositoryIdentityKey??`none`}`,`Expected revision: ${i.before.updatedAt}`]},{heading:`After`,lines:[`Display name: ${i.after.title}`,`Workspace path: ${i.after.workspaceRoot}`,`Repository identity: ${i.after.repositoryIdentityKey??`none`}`]}]};case`removeProject`:return{actionLabel:`Unlink project`,targetLabel:`project ${tP(i.projectId)}`,runtimeLabel:null,detailSections:[{heading:`Before · destructive Ryco record removal`,lines:[`Project ID: ${i.projectId}`,`Display name: ${i.expected.title}`,`Workspace path: ${i.expected.workspaceRoot}`,`Expected revision: ${i.expected.updatedAt}`,`Force removal: ${i.force?`yes`:`no`}`,...i.expectedThreadIds.length===0?[`Ryco thread records removed: none`]:i.expectedThreadIds.map(e=>`Ryco thread record removed: ${e}`),`Workspace files and repository contents will be retained.`]},{heading:`After`,lines:[`The Ryco project record and the exact listed Ryco thread records are unlinked.`,`The workspace directory and repository are unchanged.`]}]};case`changeSettings`:return{actionLabel:`Change setting`,targetLabel:i.change.kind,runtimeLabel:null,detailSections:[{heading:`Exact setting change`,lines:[`Setting: ${i.change.kind}`,`Before: ${String(i.change.before)}`,`After: ${String(i.change.after)}`,`Fresh owner reauthentication is required at approval and execution.`]}]};case`createAutomation`:return{actionLabel:`Create schedule definition`,targetLabel:`automation ${tP(i.automationId)}`,runtimeLabel:`${i.definition.execution.runtimeMode} · ${i.definition.execution.envMode}`,detailSections:[{heading:`Schedule definition approval`,lines:[...t(i.definition.schedule),...n,`Enabled: ${i.definition.enabled?`yes`:`no`}`,...r(i.definition.execution),`This approval authorizes only the schedule definition.`,`Every due run creates a fresh exact proposal and waits for user approval.`,`At most one pending or executing run is allowed for this automation.`]}]};case`updateAutomation`:return{actionLabel:`Update schedule definition`,targetLabel:`automation ${tP(i.automationId)}`,runtimeLabel:`${i.after.execution.runtimeMode} · ${i.after.execution.envMode}`,detailSections:[{heading:`Before · revision ${i.before.revision}`,lines:[...t(i.before.definition.schedule),`Enabled: ${i.before.definition.enabled?`yes`:`no`}`,`Last changed: ${i.before.updatedAt}`]},{heading:`After · schedule approval only`,lines:[...t(i.after.schedule),...n,`Enabled: ${i.after.enabled?`yes`:`no`}`,...r(i.after.execution),`Pending, unaccepted runs from the old definition are cancelled.`,`Already accepted or executing runs are not interrupted.`,`Future runs still require separate approval.`]}]};case`cancelAutomation`:return{actionLabel:`Cancel future scheduled runs`,targetLabel:`automation ${tP(i.automationId)}`,runtimeLabel:null,detailSections:[{heading:`Expected revision ${i.expected.revision}`,lines:[...t(i.expected.definition.schedule),`Project: ${i.expected.definition.execution.projectId}`,`Provider: ${i.expected.definition.execution.modelSelection.instanceId}`,`Cancellation prevents future run proposals and cancels a pending, unaccepted run.`,`It does not delete project/thread data or interrupt an accepted/executing run.`]}]};case`automationRun`:return{actionLabel:`Approve one scheduled run`,targetLabel:`run ${tP(i.runId)}`,runtimeLabel:`${i.execution.runtimeMode} · ${i.execution.envMode}`,detailSections:[{heading:`Fresh run approval`,lines:[`Automation: ${i.automationId} · revision ${i.automationRevision}`,`Scheduled for: ${i.scheduledFor}`,`Missed intervals coalesced: ${i.coalescedOccurrences}`,...r(i.execution),`Approving the schedule did not approve this run; this exact proposal does.`]}]};case`deviceBoot`:return{actionLabel:`Boot iOS Simulator`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`Action: boot this exact Simulator.`])};case`deviceAttach`:return{actionLabel:`Attach iOS Simulator`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`Action: attach this device to the exact thread.`])};case`deviceDetach`:return{actionLabel:`Detach iOS Simulator`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`Action: detach this device from the exact thread.`])};case`deviceInstall`:return{actionLabel:`Install Simulator application`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`Workspace-relative artifact: ${i.artifactPath}`,`The canonical artifact path is revalidated inside the project workspace at execution.`])};case`deviceLaunch`:return{actionLabel:`Launch Simulator application`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`Installed bundle ID: ${i.bundleId}`,`Launch arguments are not permitted through Agent Control.`])};case`deviceOpenUrl`:return{actionLabel:`Open URL on iOS Simulator`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`high risk · open world`,detailSections:a(i,[`Exact URL/deep link: ${i.url}`,`Credentials, file URLs, and unsafe schemes are rejected again at execution.`])};case`deviceTap`:return{actionLabel:`Tap iOS Simulator`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`Point: (${String(i.x)}, ${String(i.y)})`])};case`deviceSwipe`:return{actionLabel:`Swipe iOS Simulator`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`From: (${i.fromX}, ${i.fromY})`,`To: (${i.toX}, ${i.toY})`,`Duration: ${i.durationMs}ms`])};case`devicePressButton`:return{actionLabel:`Press Simulator hardware control`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`Button: ${i.button}`])};case`deviceStartRecording`:case`deviceStopRecording`:return{actionLabel:i.kind===`deviceStartRecording`?`Start Simulator recording`:`Stop Simulator recording`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`Action: ${i.kind===`deviceStartRecording`?`start`:`stop`} recording.`,`Recording paths and frame content are excluded from proposals and audit.`])};case`deviceShutdown`:return{actionLabel:`Shut down iOS Simulator`,targetLabel:`device ${tP(i.udid)}`,runtimeLabel:`explicit approval required`,detailSections:a(i,[`Action: shut down this exact Simulator.`])}}}function aP(e){let t=e.result;if(t===null)return null;if(t.outcome===`completed`){let e=t.createdThreadIds?.length??0,n=t.createdProjectIds?.length??0,r=t.detail===void 0?``:` · ${t.detail}`;return n>0?`Completed · created ${n} project${n===1?``:`s`}${r}`:e>0?`Completed · created ${e} thread${e===1?``:`s`}${r}`:`Completed${r}`}return`${t.error.code}: ${t.error.message}`}function oP(e){let t=e.result?.execution;if(t===void 0)return{label:null,affectedThreadIds:[],affectedProjectIds:[]};let n=[`Operation ${tP(t.operationId)}`,`${t.commands.length} command${t.commands.length===1?``:`s`}`];return t.worktreeIds.length>0&&n.push(`${t.worktreeIds.length} worktree${t.worktreeIds.length===1?``:`s`}`),t.delivery!==void 0&&n.push(`delivery: ${t.delivery}`),t.interrupt!==void 0&&n.push(`interrupt settled: ${t.interrupt.settledStatus}`),t.compensation!==void 0&&n.push(t.compensation.completed?`cleanup completed`:`cleanup needs attention`),{label:n.join(` · `),affectedThreadIds:t.affectedThreadIds,affectedProjectIds:t.affectedProjectIds??[]}}function sP(e){let t=eP[e.status],n=rP(e),r=iP(e),i=oP(e);return{proposalId:e.proposalId,status:e.status,statusLabel:t.label,statusTone:t.tone,originLabel:n.label,originThreadId:n.threadId,actionLabel:r.actionLabel,targetLabel:r.targetLabel,runtimeLabel:r.runtimeLabel,riskLabels:e.riskTags.map(e=>nP(String(e))),isDestructive:e.plan.kind===`removeProject`,warningLabel:e.plan.kind===`deviceOpenUrl`?`High risk · opens an external URL or deep link`:null,summary:e.promptSummary,expiresAt:e.expiresAt,isPending:e.status===`pending-user-approval`,outcomeLabel:aP(e),executionLabel:i.label,affectedThreadIds:i.affectedThreadIds,affectedProjectIds:i.affectedProjectIds,detailSections:r.detailSections}}var cP=c(e=>({queueByEnvironmentId:{},applyStreamEvent:(t,n)=>e(e=>{let r=e.queueByEnvironmentId[t]??GN,i=ZN(r,n);return i===r?e:{queueByEnvironmentId:{...e.queueByEnvironmentId,[t]:i}}}),clearEnvironment:t=>e(e=>{if(!(t in e.queueByEnvironmentId))return e;let n={...e.queueByEnvironmentId};return delete n[t],{queueByEnvironmentId:n}})}));function lP(e){let{environmentId:t,source:n,sink:r}=e,i=!1,a=n.subscribeProposals(e=>{i||r.applyStreamEvent(t,e)},{onError:()=>{i||(r.clearEnvironment(t),e.onError?.())}});return()=>{i||(i=!0,a())}}var uP={pending:`warning`,info:`info`,success:`success`,danger:`error`,muted:`secondary`},dP=(0,q.memo)(function(e){let t=(0,J.c)(67),{model:n,environmentId:r,isSubmitting:i,decisionError:a,disabledReason:o,onAccept:s,onReject:c}=e,[l,u]=(0,q.useState)(!1),d=i||o!==null,f=`mb-2 rounded-lg border bg-muted/20 ${n.isDestructive||n.warningLabel!==null?`border-destructive/70`:`border-border/60`}`,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Y.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-[0.2em] text-muted-foreground`,children:`Agent Control`}),t[0]=p):p=t[0];let m=uP[n.statusTone],h;t[1]!==n.statusLabel||t[2]!==m?(h=(0,Y.jsx)(jc,{size:`sm`,variant:m,children:n.statusLabel}),t[1]=n.statusLabel,t[2]=m,t[3]=h):h=t[3];let g;t[4]!==n.expiresAt||t[5]!==n.isPending?(g=n.isPending?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:So(n.expiresAt)}):null,t[4]=n.expiresAt,t[5]=n.isPending,t[6]=g):g=t[6];let _;t[7]===n.isDestructive?_=t[8]:(_=n.isDestructive?(0,Y.jsx)(jc,{size:`sm`,variant:`error`,children:`Destructive · Ryco records only`}):null,t[7]=n.isDestructive,t[8]=_);let v;t[9]===n.warningLabel?v=t[10]:(v=n.warningLabel===null?null:(0,Y.jsx)(jc,{size:`sm`,variant:`error`,children:n.warningLabel}),t[9]=n.warningLabel,t[10]=v);let y;t[11]!==h||t[12]!==g||t[13]!==_||t[14]!==v?(y=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p,h,g,_,v]}),t[11]=h,t[12]=g,t[13]=_,t[14]=v,t[15]=y):y=t[15];let b;t[16]!==n.actionLabel||t[17]!==n.targetLabel?(b=(0,Y.jsxs)(`p`,{className:`mt-1 text-sm font-medium text-foreground`,children:[n.actionLabel,` · `,n.targetLabel]}),t[16]=n.actionLabel,t[17]=n.targetLabel,t[18]=b):b=t[18];let x=n.runtimeLabel===null?null:` · ${n.runtimeLabel}`,S;t[19]!==n.originLabel||t[20]!==x?(S=(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[n.originLabel,x]}),t[19]=n.originLabel,t[20]=x,t[21]=S):S=t[21];let C;t[22]===n.summary?C=t[23]:(C=n.summary===null?null:(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:n.summary}),t[22]=n.summary,t[23]=C);let w;t[24]===n.riskLabels?w=t[25]:(w=n.riskLabels.length>0?(0,Y.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:n.riskLabels.map(fP)}):null,t[24]=n.riskLabels,t[25]=w);let T;t[26]===n.outcomeLabel?T=t[27]:(T=n.outcomeLabel===null?null:(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n.outcomeLabel}),t[26]=n.outcomeLabel,t[27]=T);let E;t[28]===n.executionLabel?E=t[29]:(E=n.executionLabel===null?null:(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n.executionLabel}),t[28]=n.executionLabel,t[29]=E);let D;t[30]!==r||t[31]!==n.affectedThreadIds?(D=n.affectedThreadIds.length>0?(0,Y.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-x-2 gap-y-1 text-xs`,children:n.affectedThreadIds.map(e=>(0,Y.jsxs)(`a`,{className:`text-primary underline-offset-2 hover:underline`,href:`/${encodeURIComponent(r)}/${encodeURIComponent(e)}`,children:[`Open thread `,e.length>10?`${e.slice(0,8)}…`:e]},e))}):null,t[30]=r,t[31]=n.affectedThreadIds,t[32]=D):D=t[32];let O;t[33]===n.affectedProjectIds?O=t[34]:(O=n.affectedProjectIds.length>0?(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Project`,n.affectedProjectIds.length===1?``:`s`,`:`,` `,n.affectedProjectIds.join(`, `)]}):null,t[33]=n.affectedProjectIds,t[34]=O);let k;t[35]===a?k=t[36]:(k=a===null?null:(0,Y.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs text-destructive`,children:a}),t[35]=a,t[36]=k);let A;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>u(pP),t[37]=A):A=t[37];let j=l?`Hide plan details`:`Show plan details`,M;t[38]!==l||t[39]!==j?(M=(0,Y.jsx)(K,{size:`xs`,variant:`ghost`,className:`mt-1 -ml-2 text-muted-foreground`,"aria-expanded":l,onClick:A,children:j}),t[38]=l,t[39]=j,t[40]=M):M=t[40];let N;t[41]!==l||t[42]!==n.detailSections?(N=l?(0,Y.jsx)(`div`,{"data-testid":`agent-control-proposal-detail`,className:`mt-1 max-h-[min(14rem,30dvh)] overflow-y-auto overscroll-contain rounded-md border border-border/50 bg-background/60 px-3 py-2`,children:n.detailSections.map(hP)}):null,t[41]=l,t[42]=n.detailSections,t[43]=N):N=t[43];let P;t[44]!==S||t[45]!==C||t[46]!==w||t[47]!==T||t[48]!==E||t[49]!==D||t[50]!==O||t[51]!==k||t[52]!==M||t[53]!==N||t[54]!==y||t[55]!==b?(P=(0,Y.jsxs)(`div`,{className:`px-3 pt-2.5 sm:px-4`,children:[y,b,S,C,w,T,E,D,O,k,M,N]}),t[44]=S,t[45]=C,t[46]=w,t[47]=T,t[48]=E,t[49]=D,t[50]=O,t[51]=k,t[52]=M,t[53]=N,t[54]=y,t[55]=b,t[56]=P):P=t[56];let F;t[57]!==d||t[58]!==o||t[59]!==n.isPending||t[60]!==s||t[61]!==c?(F=n.isPending?(0,Y.jsxs)(`div`,{"data-testid":`agent-control-proposal-actions`,className:`flex flex-wrap items-center justify-end gap-2 px-3 pt-2 pb-3 sm:px-4`,children:[(0,Y.jsx)(K,{size:`sm`,variant:`destructive-outline`,disabled:d,title:o??void 0,onClick:c,children:`Reject`}),(0,Y.jsx)(K,{size:`sm`,variant:`default`,disabled:d,title:o??void 0,onClick:s,children:`Approve`})]}):(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`pb-2.5`}),t[57]=d,t[58]=o,t[59]=n.isPending,t[60]=s,t[61]=c,t[62]=F):F=t[62];let I;return t[63]!==f||t[64]!==P||t[65]!==F?(I=(0,Y.jsxs)(`div`,{"data-testid":`agent-control-proposal-card`,className:f,children:[P,F]}),t[63]=f,t[64]=P,t[65]=F,t[66]=I):I=t[66],I});function fP(e){return(0,Y.jsx)(jc,{size:`sm`,variant:`outline`,children:e},e)}function pP(e){return!e}function mP(e,t){return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap wrap-break-word text-xs text-muted-foreground select-text`,children:e},t)}function hP(e){return(0,Y.jsxs)(`div`,{className:`mb-2 last:mb-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:e.heading}),e.lines.map(mP)]},e.heading)}function gP({environmentId:e,activeThreadId:t}){let n=Ms(N.acceptProposal),[r,i]=(0,q.useState)([]),[a,o]=(0,q.useState)({}),[s,c]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let t=null,n=null,r=()=>{let r=Fe(e)?.client??null;if(r===t)return;n?.(),n=null,t=r;let i=r?Le(e,r)?.agentControl:void 0;if(!i)return;let a=cP.getState();n=lP({environmentId:e,source:i,sink:{applyStreamEvent:a.applyStreamEvent,clearEnvironment:a.clearEnvironment}})},i=Ze(r);return r(),()=>{i(),n?.()}},[e]);let l=cP(t=>t.queueByEnvironmentId[e]??null),u=(0,q.useMemo)(()=>l===null?[]:QN(l),[l]),d=(0,q.useMemo)(()=>l===null?[]:$N(l),[l]),f=(0,q.useMemo)(()=>t===null?u:u.toSorted((e,n)=>{let r=e.principal.kind===`provider-session`&&e.principal.threadId===t,i=n.principal.kind===`provider-session`&&n.principal.threadId===t;return Number(i)-Number(r)}),[u,t]),p=(0,q.useCallback)(async(t,n)=>{let r=Be(e)?.agentControl;if(r){i(e=>e.includes(t)?e:[...e,t]),o(({[t]:e,...n})=>n);try{n===`accept`?await r.acceptProposal({proposalId:t}):await r.rejectProposal({proposalId:t})}catch(e){o(n=>({...n,[t]:e instanceof Error&&e.message.length>0?e.message:`Failed to submit the decision.`}))}finally{i(e=>e.filter(e=>e!==t))}}},[e]);return f.length===0&&d.length===0?null:(0,Y.jsxs)(`div`,{"data-testid":`agent-control-approvals`,children:[f.map(t=>(0,Y.jsx)(dP,{model:sP(t),environmentId:e,isSubmitting:r.includes(t.proposalId),decisionError:a[t.proposalId]??null,disabledReason:n.allowed?null:n.reason??null,onAccept:()=>void p(t.proposalId,`accept`),onReject:()=>void p(t.proposalId,`reject`)},t.proposalId)),d.length>0?(0,Y.jsxs)(`div`,{className:`mb-2`,children:[(0,Y.jsxs)(K,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[`Recent Agent Control decisions · `,d.length]}),s?(0,Y.jsx)(`ul`,{"data-testid":`agent-control-recent`,className:`mt-1 flex flex-col gap-0.5`,children:d.map(t=>{let n=sP(t);return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 px-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-medium text-foreground/80`,children:n.statusLabel}),(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[n.actionLabel,` · `,n.targetLabel,` · `,n.originLabel,n.executionLabel===null?null:` · ${n.executionLabel}`]}),n.affectedThreadIds.map(t=>(0,Y.jsxs)(`a`,{className:`shrink-0 text-primary underline-offset-2 hover:underline`,href:`/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,children:[`Open `,t.length>10?`${t.slice(0,8)}…`:t]},t)),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0`,children:xo(t.updatedAt)})]},t.proposalId)})}):null]}):null]})}var _P=220,vP={opacity:0,transform:`translate3d(0, 4rem, 0)`},yP={opacity:0,transform:`translate3d(0, 7rem, 0)`},bP={opacity:1,transform:`translate3d(0, 0, 0)`},xP={transition:`transform ${_P}ms ease-in, opacity ${_P}ms ease-in`,willChange:`transform, opacity`};function SP(e){let t=(0,J.c)(55),{className:n,items:r}=e,[i,a]=(0,q.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={pointer:`coarse`},t[0]=o):o=t[0];let s=ri(o),c=ri(Fs),[l,u]=(0,q.useState)(!1),d=(0,q.useRef)(null),f,p;t[1]!==i||t[2]!==r?(f=()=>{i&&!r.some(e=>e.id===i)&&a(null)},p=[i,r],t[1]=i,t[2]=r,t[3]=f,t[4]=p):(f=t[3],p=t[4]),(0,q.useEffect)(f,p);let m,h;t[5]!==s||t[6]!==r.length?(m=()=>{(r.length<=1||!s)&&u(!1)},h=[s,r.length],t[5]=s,t[6]=r.length,t[7]=m,t[8]=h):(m=t[7],h=t[8]),(0,q.useEffect)(m,h);let g,_;if(t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>{d.current&&clearTimeout(d.current)},_=[],t[9]=g,t[10]=_):(g=t[9],_=t[10]),(0,q.useEffect)(g,_),r.length===0)return null;let v=r[0];if(!v)return null;let y,b,x,S,C;if(t[11]!==n||t[12]!==i||t[13]!==v||t[14]!==s||t[15]!==l||t[16]!==r||t[17]!==c){let e=r.slice(1),o=e.length>0,f=o&&i!==v.id,p;t[23]!==i||t[24]!==c?(p=e=>{!e.onDismiss||i||(a(e.id),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,e.onDismiss?.()},c?0:_P))},t[23]=i,t[24]=c,t[25]=p):p=t[25];let m=p,h=c?void 0:xP;t[26]===n?x=t[27]:(x=G(`group/banner-stack mx-auto mb-2 max-w-208`,n),t[26]=n,t[27]=x);let g=o?`group-hover/banner-stack:z-50 group-focus-within/banner-stack:z-50`:null,_=o&&l?`z-50`:null;t[28]!==g||t[29]!==_?(S=G(`relative`,g,_),t[28]=g,t[29]=_,t[30]=S):S=t[30],C=f?s?(0,Y.jsx)(`button`,{type:`button`,"data-composer-banner-stack-cap":`true`,"aria-expanded":l,"aria-label":l?`Hide stacked notifications`:`Show ${e.length} more ${e.length===1?`notification`:`notifications`}`,className:G(`absolute inset-x-0 -top-3 z-0 mx-auto h-3 cursor-pointer rounded-t-xl`,`after:absolute after:inset-x-0 after:-top-7 after:-bottom-1.5`,`outline-none focus-visible:ring-2 focus-visible:ring-ring`,`border border-b-0 border-warning/24 bg-background/96 shadow-[0_6px_18px_rgba(0,0,0,0.06)]`),style:{width:`96%`},onClick:()=>u(CP)}):(0,Y.jsx)(`div`,{"data-composer-banner-stack-cap":`true`,className:G(`pointer-events-none absolute inset-x-0 -top-3 z-0 mx-auto h-3 rounded-t-xl`,`border border-b-0 border-warning/24 bg-background/96 shadow-[0_6px_18px_rgba(0,0,0,0.06)]`,`transition-opacity duration-150 ease-out motion-reduce:transition-none`,`group-hover/banner-stack:opacity-0 group-focus-within/banner-stack:opacity-0`),style:{width:`96%`},"aria-hidden":`true`}):null;let w=i===v.id?`pointer-events-none`:null,T;t[31]===w?T=t[32]:(T=G(`relative z-10`,w),t[31]=w,t[32]=T);let E=i===v.id?vP:bP,D;t[33]!==h||t[34]!==E?(D={...h,...E},t[33]=h,t[34]=E,t[35]=D):D=t[35];let O=i===v.id,k;t[36]!==v||t[37]!==m?(k=()=>m(v),t[36]=v,t[37]=m,t[38]=k):k=t[38];let A;t[39]!==v||t[40]!==O||t[41]!==k?(A=(0,Y.jsx)(wP,{item:v,exiting:O,onDismissRequest:k}),t[39]=v,t[40]=O,t[41]=k,t[42]=A):A=t[42],t[43]!==T||t[44]!==D||t[45]!==A?(y=(0,Y.jsx)(`div`,{className:T,style:D,children:A}),t[43]=T,t[44]=D,t[45]=A,t[46]=y):y=t[46],b=o?(0,Y.jsx)(`div`,{"data-composer-banner-stack-rest":`true`,className:G(`pointer-events-none absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-20 space-y-2 opacity-0`,`transition-[opacity,transform] duration-150 ease-out motion-reduce:transition-none motion-reduce:translate-y-0`,`translate-y-1`,`group-hover/banner-stack:pointer-events-auto group-hover/banner-stack:translate-y-0 group-hover/banner-stack:opacity-100`,`group-focus-within/banner-stack:pointer-events-auto group-focus-within/banner-stack:translate-y-0 group-focus-within/banner-stack:opacity-100`,l?`pointer-events-auto translate-y-0 opacity-100`:null),children:e.map(e=>(0,Y.jsx)(`div`,{className:G(i===e.id?`pointer-events-none`:null),style:{...h,...i===e.id?yP:bP},children:(0,Y.jsx)(wP,{item:e,exiting:i===e.id,onDismissRequest:()=>m(e)})},e.id))}):null,t[11]=n,t[12]=i,t[13]=v,t[14]=s,t[15]=l,t[16]=r,t[17]=c,t[18]=y,t[19]=b,t[20]=x,t[21]=S,t[22]=C}else y=t[18],b=t[19],x=t[20],S=t[21],C=t[22];let w;t[47]!==y||t[48]!==b||t[49]!==S||t[50]!==C?(w=(0,Y.jsxs)(`div`,{className:S,children:[C,y,b]}),t[47]=y,t[48]=b,t[49]=S,t[50]=C,t[51]=w):w=t[51];let T;return t[52]!==x||t[53]!==w?(T=(0,Y.jsx)(`div`,{className:x,children:w}),t[52]=x,t[53]=w,t[54]=T):T=t[54],T}function CP(e){return!e}function wP(e){let t=(0,J.c)(17),{item:n,exiting:r,onDismissRequest:i}=e,a=n.onDismiss&&!n.actions,o;t[0]===n.title?o=t[1]:(o=(0,Y.jsx)(Hs,{children:n.title}),t[0]=n.title,t[1]=o);let s;t[2]===n.description?s=t[3]:(s=n.description?(0,Y.jsx)(Ws,{children:n.description}):null,t[2]=n.description,t[3]=s);let c;t[4]!==a||t[5]!==r||t[6]!==n.actions||t[7]!==n.dismissLabel||t[8]!==n.onDismiss||t[9]!==i?(c=n.actions||n.onDismiss?(0,Y.jsxs)(Us,{className:a?`phone:col-start-3 phone:row-start-1 phone:mt-0 phone:self-start`:void 0,children:[n.actions,n.onDismiss?(0,Y.jsx)(K,{size:`icon-xs`,variant:`ghost`,"aria-label":n.dismissLabel??`Dismiss warning`,disabled:r,onClick:i,children:(0,Y.jsx)($a,{className:`size-3.5`})}):null]}):null,t[4]=a,t[5]=r,t[6]=n.actions,t[7]=n.dismissLabel,t[8]=n.onDismiss,t[9]=i,t[10]=c):c=t[10];let l;return t[11]!==n.icon||t[12]!==n.variant||t[13]!==o||t[14]!==s||t[15]!==c?(l=(0,Y.jsxs)(Gs,{variant:n.variant,children:[n.icon,o,s,c]}),t[11]=n.icon,t[12]=n.variant,t[13]=o,t[14]=s,t[15]=c,t[16]=l):l=t[16],l}function TP(e){let t=(0,J.c)(2),n;return t[0]===e?n=t[1]:(n={...e,state:`open`,limit:50},t[0]=e,t[1]=n),$n(n)}function EP(e){let t=(0,J.c)(2),n=pe(DP),r;return t[0]===n?r=t[1]:(r=e=>ar({mode:n,phase:e?.state===`open`?`active`:`settled`}),t[0]=n,t[1]=r),W(e,r)}function DP(e){return e.sourceControlRefreshMode}function OP(e){let t=(0,J.c)(7),n=e.pullRequestNumber===null?e.branch:null,r=e.enabled&&(e.pullRequestNumber!==null||e.branch!==null),i;return t[0]!==e.commitSha||t[1]!==e.cwd||t[2]!==e.environmentId||t[3]!==e.pullRequestNumber||t[4]!==n||t[5]!==r?(i={environmentId:e.environmentId,cwd:e.cwd,pullRequestNumber:e.pullRequestNumber,branch:n,commitSha:e.commitSha,limit:20,enabled:r},t[0]=e.commitSha,t[1]=e.cwd,t[2]=e.environmentId,t[3]=e.pullRequestNumber,t[4]=n,t[5]=r,t[6]=i):i=t[6],sr(i,e.resolveIntervalMs)}function kP(e){return er(e)}function AP(e){let t=0,n=0,r=0,i=!1;if(e.changes)t=e.changes.insertions,n=e.changes.deletions,r=e.changes.files.length,i=r>0||t>0||n>0;else for(let r of e.overviewItems??[])typeof r.additions==`number`&&(t+=r.additions,i=!0),typeof r.deletions==`number`&&(n+=r.deletions,i=!0);let a=e.pullRequest?.latestRuns??[],o=0,s=0,c=0;for(let e of a)e.tone===`success`?o+=1:e.tone===`failure`||e.tone===`error`?s+=1:e.tone===`running`&&(c+=1);let l=e.activePlan?.steps??[],u=e.subagents??[],d=l.filter(e=>e.status===`completed`||e.status===`inProgress`).length;return{additions:t,deletions:n,hasDiff:i,fileCount:r,checksTotal:a.length,checksPassed:o,checksFailed:s,checksRunning:c,planTotal:l.length,planDone:d,agentsTotal:u.length,agentsRunning:u.filter(e=>e.status===`running`).length,refName:e.changes?.refName??null,aheadCount:e.changes?.aheadCount??0,behindCount:e.changes?.behindCount??0}}function jP(e){return!e.activePlan&&!e.activeProposedPlan?.planMarkdown&&(e.subagents?.length??0)===0&&(e.overviewItems?.length??0)===0&&(e.changes?.files.length??0)===0&&!e.pullRequest&&!e.sourceControlActions&&!e.branchControl}function MP(e){return e?.find(e=>e.icon===`changes`)}function NP(e){return e?.find(e=>e.icon===`environment`)}function PP(e){return e.planTotal===0?0:Math.round(e.planDone/e.planTotal*100)}var FP={success:`bg-success/11 text-success-foreground`,warning:`bg-warning/12 text-warning-foreground`,error:`bg-destructive/11 text-destructive-foreground`,info:`bg-info/11 text-info-foreground`,neutral:`bg-secondary text-muted-foreground`,primary:`bg-primary/12 text-primary dark:text-info-foreground`};function IP(e){let t=(0,J.c)(5),{tone:n,children:r}=e,i=FP[n],a;t[0]===i?a=t[1]:(a=G(`inline-flex h-[19px] shrink-0 items-center gap-1 rounded-md px-1.5 text-[11.5px] leading-none font-medium [&_svg]:size-[11px]`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,Y.jsx)(`span`,{className:a,children:r}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function LP(e){let t=(0,J.c)(10),{additions:n,deletions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=G(`flex items-center gap-1.5 font-mono text-[12px] font-semibold tabular-nums`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,n]}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[`−`,r]}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,Y.jsxs)(`span`,{className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}var RP={success:`bg-success`,failure:`bg-destructive`,error:`bg-destructive`,running:`bg-sky-400 animate-status-pulse`,pending:`bg-warning/55`};function zP(e){let t=(0,J.c)(4),{runs:n}=e;if(n.length===0)return null;let r;t[0]===n?r=t[1]:(r=n.map(BP),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Y.jsx)(`span`,{className:`flex items-center gap-[3px]`,children:r}),t[2]=r,t[3]=i),i}function BP(e){return(0,Y.jsx)(`span`,{className:G(`size-[7px] rounded-full bg-[color:var(--border-strong)]`,RP[e.tone])},e.id)}function VP(e){let t=(0,J.c)(7),{value:n,className:r}=e,i;t[0]===r?i=t[1]:(i=G(`inline-block h-[5px] w-[54px] overflow-hidden rounded-[3px] bg-muted`,r),t[0]=r,t[1]=i);let a=`${Math.max(0,Math.min(100,n))}%`,o;t[2]===a?o=t[3]:(o=(0,Y.jsx)(`span`,{className:`block h-full rounded-[3px] bg-primary`,style:{width:a}}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,Y.jsx)(`span`,{className:i,children:o}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function HP(e){let t=(0,J.c)(4),{subagents:n}=e;if(n.length===0)return null;let r;t[0]===n?r=t[1]:(r=n.slice(0,3).map(UP),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Y.jsx)(`span`,{className:`flex items-center`,children:r}),t[2]=r,t[3]=i),i}function UP(e,t){return(0,Y.jsx)(`span`,{className:G(`grid size-5 place-items-center rounded-full border-2 border-card bg-secondary/60`,t>0&&`-ml-[7px]`),children:(0,Y.jsx)(da,{name:e.avatarKey??e.key,className:`size-3`})},e.key)}function WP(e){let t=(0,J.c)(5),{className:n,title:r}=e,i;t[0]===n?i=t[1]:(i=G(`size-2 shrink-0 rounded-full`,n),t[0]=n,t[1]=i);let a;return t[2]!==i||t[3]!==r?(a=(0,Y.jsx)(`span`,{className:i,title:r}),t[2]=i,t[3]=r,t[4]=a):a=t[4],a}function GP(e){let t=(0,J.c)(10),{label:n,value:r,monoValue:i}=e,a=i===void 0||i,o;t[0]===n?o=t[1]:(o=(0,Y.jsx)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground [&_svg]:size-3.5`,children:n}),t[0]=n,t[1]=o);let s=a&&`font-mono`,c;t[2]===s?c=t[3]:(c=G(`text-[12px] font-medium tabular-nums`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Y.jsx)(`span`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 text-[12.5px]`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function KP(e){let t=(0,J.c)(4),{detail:n}=e,r,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Y.jsx)(Xa,{className:`mt-px size-3.5 shrink-0`}),i=(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Merge conflict`}),t[0]=r,t[1]=i):(r=t[0],i=t[1]);let a=n?` · ${n}`:` — rebase onto the base branch to resolve before merge.`,o;return t[2]===a?o=t[3]:(o=(0,Y.jsxs)(`div`,{className:`flex gap-2 rounded-[10px] border border-destructive/24 bg-destructive/[0.09] px-[11px] py-[9px] text-[12.5px] text-destructive-foreground`,children:[r,(0,Y.jsxs)(`span`,{children:[i,a]})]}),t[2]=a,t[3]=o),o}function qP(e){let t=(0,J.c)(42),{icon:n,title:r,subtitle:i,summary:a,externalLink:o,defaultOpen:s,children:c}=e,l=s!==void 0&&s,u=c!=null&&c!==!1,[d,f]=(0,q.useState)(l),p=u&&d,m=u&&`transition-colors hover:bg-accent`,h=o?`pr-14`:u?`pr-8`:`pr-2.5`,g;t[0]!==m||t[1]!==h?(g=G(`relative grid min-h-10 w-full grid-cols-[20px_minmax(0,1fr)_auto] items-center gap-[7px] py-1 pl-2.5 text-left`,m,h),t[0]=m,t[1]=h,t[2]=g):g=t[2];let _=g,v=p&&`bg-primary/12 text-primary dark:text-info-foreground`,y;t[3]===v?y=t[4]:(y=G(`grid size-5 place-items-center rounded-md bg-secondary text-muted-foreground transition-colors [&_svg]:size-3`,v),t[3]=v,t[4]=y);let b;t[5]!==n||t[6]!==y?(b=(0,Y.jsx)(`span`,{className:y,children:n}),t[5]=n,t[6]=y,t[7]=b):b=t[7];let x;t[8]===r?x=t[9]:(x=(0,Y.jsx)(`span`,{className:`block truncate text-[11.5px] leading-[14px] font-semibold`,children:r}),t[8]=r,t[9]=x);let S;t[10]===i?S=t[11]:(S=i?(0,Y.jsx)(`span`,{className:`mt-px block truncate text-[10px] leading-3 text-muted-foreground`,children:i}):null,t[10]=i,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[x,S]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w;t[15]===a?w=t[16]:(w=a?(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center justify-self-end gap-1.5`,children:a}):null,t[15]=a,t[16]=w);let T;t[17]!==u||t[18]!==p?(T=u?(0,Y.jsx)(ii,{className:G(`absolute top-1/2 right-2.5 size-3 -translate-y-1/2 text-muted-foreground transition-transform`,p&&`rotate-90`)}):null,t[17]=u,t[18]=p,t[19]=T):T=t[19];let E;t[20]!==C||t[21]!==w||t[22]!==T||t[23]!==b?(E=(0,Y.jsxs)(Y.Fragment,{children:[b,C,w,T]}),t[20]=C,t[21]=w,t[22]=T,t[23]=b,t[24]=E):E=t[24];let D=E,O=u?`true`:`false`,k;t[25]!==u||t[26]!==_||t[27]!==D||t[28]!==p?(k=u?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(JP),"aria-expanded":p,className:_,children:D}):(0,Y.jsx)(`div`,{className:_,children:D}),t[25]=u,t[26]=_,t[27]=D,t[28]=p,t[29]=k):k=t[29];let A;t[30]===o?A=t[31]:(A=o?(0,Y.jsx)(`a`,{href:o.href,target:`_blank`,rel:`noreferrer`,"aria-label":o.ariaLabel,title:o.ariaLabel,className:`absolute top-1/2 right-7 z-10 grid size-7 -translate-y-1/2 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Y.jsx)(Ni,{className:`size-3`})}):null,t[30]=o,t[31]=A);let j;t[32]!==O||t[33]!==k||t[34]!==A?(j=(0,Y.jsxs)(`div`,{className:`relative min-h-10`,"data-slot":`overview-section-lane-header`,"data-expandable":O,children:[k,A]}),t[32]=O,t[33]=k,t[34]=A,t[35]=j):j=t[35];let M;t[36]!==c||t[37]!==p?(M=p?(0,Y.jsx)(`div`,{className:`pb-1.5`,children:c}):null,t[36]=c,t[37]=p,t[38]=M):M=t[38];let N;return t[39]!==j||t[40]!==M?(N=(0,Y.jsxs)(`div`,{className:`border-b border-border last:border-b-0`,children:[j,M]}),t[39]=j,t[40]=M,t[41]=N):N=t[41],N}function JP(e){return!e}function YP(e){let t=(0,J.c)(28),{label:n,detail:r,files:i,onOpen:a}=e,o;t[0]===i?o=t[1]:(o=i.reduce(ZP,0),t[0]=i,t[1]=o);let s=o,c;t[2]===i?c=t[3]:(c=i.reduce(XP,0),t[2]=i,t[3]=c);let l=c,u;t[4]===n?u=t[5]:(u=(0,Y.jsx)(`span`,{className:`font-medium text-foreground/90`,children:n}),t[4]=n,t[5]=u);let d;t[6]===r?d=t[7]:(d=r?(0,Y.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,children:r}):null,t[6]=r,t[7]=d);let f;t[8]!==u||t[9]!==d?(f=(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[u,d]}),t[8]=u,t[9]=d,t[10]=f):f=t[10];let p=i.length===1?`file`:`files`,m;t[11]!==i.length||t[12]!==p?(m=(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground tabular-nums`,children:[i.length,` `,p]}),t[11]=i.length,t[12]=p,t[13]=m):m=t[13];let h;t[14]!==l||t[15]!==s?(h=(0,Y.jsx)(LP,{additions:s,deletions:l,className:`text-[11px]`}),t[14]=l,t[15]=s,t[16]=h):h=t[16];let g;t[17]!==m||t[18]!==h?(g=(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2.5`,children:[m,h]}),t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==f||t[21]!==g?(_=(0,Y.jsxs)(Y.Fragment,{children:[f,g]}),t[20]=f,t[21]=g,t[22]=_):_=t[22];let v=_;if(a){let e;return t[23]!==v||t[24]!==a?(e=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:`flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-[12.5px] transition-colors hover:bg-accent`,children:v}),t[23]=v,t[24]=a,t[25]=e):e=t[25],e}let y;return t[26]===v?y=t[27]:(y=(0,Y.jsx)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 text-[12.5px]`,children:v}),t[26]=v,t[27]=y),y}function XP(e,t){return e+t.deletions}function ZP(e,t){return e+t.insertions}function QP(e){let t=(0,J.c)(32),{changes:n,overviewItems:r,onOpenReview:i,pullRequestNumber:a}=e,o;t[0]===r?o=t[1]:(o=MP(r),t[0]=r,t[1]=o);let s=o,c;t[2]===n?.files?c=t[3]:(c=n?.files??[],t[2]=n?.files,t[3]=c);let l=c;if(l.length>0){let e;t[4]===l?e=t[5]:(e=l.filter(eF),t[4]=l,t[5]=e);let n=e,r;t[6]===l?r=t[7]:(r=l.filter($P),t[6]=l,t[7]=r);let o=r,s;if(t[8]!==n||t[9]!==o||t[10]!==a){if(s=[],n.length>0){let e;t[12]===a?e=t[13]:(e=a?{detail:`· PR #${a}`}:{},t[12]=a,t[13]=e);let r;t[14]!==n||t[15]!==e?(r={key:`committed`,label:`Committed`,...e,files:n},t[14]=n,t[15]=e,t[16]=r):r=t[16],s.push(r)}if(o.length>0){let e;t[17]===o?e=t[18]:(e={key:`local`,label:`Uncommitted`,files:o},t[17]=o,t[18]=e),s.push(e)}t[8]=n,t[9]=o,t[10]=a,t[11]=s}else s=t[11];let c;return t[19]!==s||t[20]!==i?(c=(0,Y.jsx)(`div`,{children:s.map(e=>(0,Y.jsx)(YP,{label:e.label,detail:e.detail,files:e.files,onOpen:i},e.key))}),t[19]=s,t[20]=i,t[21]=c):c=t[21],c}if(s){let e=!i,n;t[22]===s.value?n=t[23]:(n=(0,Y.jsx)(`span`,{className:`truncate text-foreground/85`,children:s.value}),t[22]=s.value,t[23]=n);let r;t[24]===s.detail?r=t[25]:(r=s.detail?(0,Y.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,children:s.detail}):null,t[24]=s.detail,t[25]=r);let a;return t[26]!==i||t[27]!==e||t[28]!==n||t[29]!==r?(a=(0,Y.jsxs)(`button`,{type:`button`,onClick:i,disabled:e,className:`flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-[12.5px] transition-colors hover:bg-accent disabled:hover:bg-transparent`,children:[n,r]}),t[26]=i,t[27]=e,t[28]=n,t[29]=r,t[30]=a):a=t[30],a}let u;return t[31]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Y.jsx)(`p`,{className:`px-3 py-1.5 text-[12px] text-muted-foreground`,children:`No file changes.`}),t[31]=u):u=t[31],u}function $P(e){return e.category!==`committed`}function eF(e){return e.category===`committed`}function tF(e){let t=(0,J.c)(3),{status:n}=e;if(n===`completed`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(`span`,{className:`flex size-[17px] shrink-0 items-center justify-center rounded-full bg-success text-white`,children:(0,Y.jsx)(Yr,{className:`size-3`})}),t[0]=e):e=t[0],e}if(n===`inProgress`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(`span`,{className:`flex size-[17px] shrink-0 items-center justify-center rounded-full border-[1.5px] border-primary`,children:(0,Y.jsx)(`span`,{className:`size-[7px] animate-status-pulse rounded-full bg-primary`})}),t[1]=e):e=t[1],e}let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Y.jsx)(`span`,{className:`size-[17px] shrink-0 rounded-full border-[1.5px] border-[color:var(--border-strong)]`}),t[2]=r):r=t[2],r}function nF(e){let t=(0,J.c)(2),{activePlan:n}=e;if(!n?.explanation)return null;let r;return t[0]===n.explanation?r=t[1]:(r=(0,Y.jsx)(`p`,{className:`px-3 pt-1 pb-0.5 text-[12.5px] leading-relaxed text-muted-foreground`,children:n.explanation}),t[0]=n.explanation,t[1]=r),r}function rF(e){let t=(0,J.c)(4),{activePlan:n}=e;if(!n||n.steps.length===0)return null;let r;t[0]===n.steps?r=t[1]:(r=n.steps.map(iF),t[0]=n.steps,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,Y.jsx)(`div`,{children:r}),t[2]=r,t[3]=i),i}function iF(e){return(0,Y.jsxs)(`div`,{className:`flex items-start gap-2.5 px-3 py-[7px] text-[13px]`,children:[(0,Y.jsx)(`span`,{className:`mt-px`,children:(0,Y.jsx)(tF,{status:e.status})}),(0,Y.jsx)(`span`,{className:G(`leading-snug`,e.status===`inProgress`?`text-foreground`:`text-muted-foreground`),children:e.step})]},`${e.status}:${e.step}`)}function aF(e){let t=(0,J.c)(44),{activeProposedPlan:n,environmentId:r,markdownCwd:i,workspaceRoot:a}=e,[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),{copyToClipboard:u,isCopied:d}=ks(),f=n?.planMarkdown??null,p;t[0]===f?p=t[1]:(p=f?mu(f):null,t[0]=f,t[1]=p);let m=p,h;t[2]===f?h=t[3]:(h=f?pu(f):null,t[2]=f,t[3]=h);let g=h,_;t[4]!==u||t[5]!==f?(_=()=>{f&&u(f)},t[4]=u,t[5]=f,t[6]=_):_=t[6];let v=_,y;t[7]===f?y=t[8]:(y=()=>{f&&Su(bu(f),xu(f))},t[7]=f,t[8]=y);let b=y,x;t[9]!==r||t[10]!==f||t[11]!==a?(x=()=>{let e=Be(r);if(!e||!a||!f)return;let t=bu(f);l(!0),e.projects.writeFile({cwd:a,relativePath:t,contents:xu(f)}).then(cF).catch(sF).then(()=>l(!1),()=>l(!1))},t[9]=r,t[10]=f,t[11]=a,t[12]=x):x=t[12];let S=x;if(!f)return null;let C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>s(oF),t[13]=C):C=t[13];let w;t[14]===o?w=t[15]:(w=o?(0,Y.jsx)(Zr,{className:`size-3 shrink-0 text-muted-foreground`}):(0,Y.jsx)(ii,{className:`size-3 shrink-0 text-muted-foreground`}),t[14]=o,t[15]=w);let T=g??`Full plan`,E;t[16]===T?E=t[17]:(E=(0,Y.jsx)(`span`,{className:`truncate text-[10px] font-semibold tracking-widest text-muted-foreground uppercase group-hover:text-foreground/70`,children:T}),t[16]=T,t[17]=E);let D;t[18]!==w||t[19]!==E?(D=(0,Y.jsxs)(`button`,{type:`button`,className:`group flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:C,children:[w,E]}),t[18]=w,t[19]=E,t[20]=D):D=t[20];let O;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Y.jsx)(oc,{render:(0,Y.jsx)(K,{size:`icon-xs`,variant:`ghost`,className:`shrink-0 text-muted-foreground hover:text-foreground/70`,"aria-label":`Plan actions`}),children:(0,Y.jsx)(Vi,{className:`size-3.5`})}),t[21]=O):O=t[21];let k=d?`Copied!`:`Copy to clipboard`,A;t[22]!==v||t[23]!==k?(A=(0,Y.jsx)(sc,{onClick:v,children:k}),t[22]=v,t[23]=k,t[24]=A):A=t[24];let j;t[25]===b?j=t[26]:(j=(0,Y.jsx)(sc,{onClick:b,children:`Download as markdown`}),t[25]=b,t[26]=j);let M=!a||c,N;t[27]!==S||t[28]!==M?(N=(0,Y.jsx)(sc,{onClick:S,disabled:M,children:`Save to workspace`}),t[27]=S,t[28]=M,t[29]=N):N=t[29];let P;t[30]!==A||t[31]!==j||t[32]!==N?(P=(0,Y.jsxs)(rc,{children:[O,(0,Y.jsxs)(ec,{align:`end`,children:[A,j,N]})]}),t[30]=A,t[31]=j,t[32]=N,t[33]=P):P=t[33];let F;t[34]!==D||t[35]!==P?(F=(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[D,P]}),t[34]=D,t[35]=P,t[36]=F):F=t[36];let I;t[37]!==m||t[38]!==i||t[39]!==o?(I=o?(0,Y.jsx)(`div`,{className:`rounded-lg border border-border bg-background/50 p-3`,children:(0,Y.jsx)(ua,{text:m??``,cwd:i,isStreaming:!1})}):null,t[37]=m,t[38]=i,t[39]=o,t[40]=I):I=t[40];let ee;return t[41]!==F||t[42]!==I?(ee=(0,Y.jsxs)(`div`,{className:`space-y-2 px-3 pt-1 pb-1`,children:[F,I]}),t[41]=F,t[42]=I,t[43]=ee):ee=t[43],ee}function oF(e){return!e}function sF(e){Ai.add(As({type:`error`,title:`Could not save plan`,description:e instanceof Error?e.message:`An error occurred.`}))}function cF(e){Ai.add({type:`success`,title:`Plan saved`,description:e.relativePath})}function lF(e){return e===`running`?`Working`:e===`failed`?`Needs review`:e===`finished`?`Finished`:e===`interrupted`?`Stopped`:`Idle`}var uF={running:`bg-sky-400 animate-status-pulse shadow-[0_0_0_3px_color-mix(in_srgb,var(--sky)_22%,transparent)]`,finished:`bg-success`,failed:`bg-destructive`,interrupted:`bg-muted-foreground/60`,idle:`bg-muted-foreground/40`};function dF(e){let t=(0,J.c)(9),{subagents:n,onOpenSubagent:r}=e,i;t[0]===n?i=t[1]:(i=n===void 0?[]:n,t[0]=n,t[1]=i);let a=i;if(a.length===0)return null;let o;if(t[2]!==r||t[3]!==a){let e;t[5]===r?e=t[6]:(e=e=>{let t=e.model??e.tool??e.role??null,n=e.updatedAt||e.startedAt;return(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-center gap-2.5 px-3 py-2 text-left transition-colors hover:bg-accent`,onClick:()=>r?.(e),"aria-label":`${e.name} — ${lF(e.status)}`,title:e.detail??void 0,children:[(0,Y.jsx)(`span`,{className:`grid size-[26px] shrink-0 place-items-center rounded-lg border border-border bg-secondary/40`,children:(0,Y.jsx)(da,{name:e.avatarKey??e.key,className:`size-[18px]`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.name}),(0,Y.jsx)(WP,{className:uF[e.status],title:lF(e.status)})]}),t?(0,Y.jsx)(`span`,{className:`block truncate text-[11.5px] text-muted-foreground`,children:t}):null]}),n?(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground tabular-nums`,children:xo(n)}):null]},e.key)},t[5]=r,t[6]=e),o=a.map(e),t[2]=r,t[3]=a,t[4]=o}else o=t[4];let s;return t[7]===o?s=t[8]:(s=(0,Y.jsx)(`div`,{children:o}),t[7]=o,t[8]=s),s}function fF(e){return e===`success`?(0,Y.jsx)(Yr,{className:`size-3.5 text-success-foreground`}):e===`failure`||e===`error`?(0,Y.jsx)($a,{className:`size-3.5 text-destructive-foreground`}):e===`running`?(0,Y.jsx)(ja,{className:`size-3.5 animate-spin text-info-foreground`}):e===`pending`?(0,Y.jsx)(Ii,{className:`size-3.5 text-muted-foreground`}):(0,Y.jsx)(`span`,{className:`size-3 rounded-full border border-muted-foreground/35`})}function pF(e){let t=(0,J.c)(17),{run:n}=e,r;t[0]===n.tone?r=t[1]:(r=fF(n.tone),t[0]=n.tone,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,Y.jsx)(`span`,{className:`grid w-4 shrink-0 place-items-center`,children:r}),t[2]=r,t[3]=i);let a;t[4]===n.name?a=t[5]:(a=(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:n.name}),t[4]=n.name,t[5]=a);let o;t[6]===n.detail?o=t[7]:(o=n.detail?(0,Y.jsx)(`span`,{className:`shrink-0 text-[11.5px] text-muted-foreground`,children:n.detail}):null,t[6]=n.detail,t[7]=o);let s;t[8]!==i||t[9]!==a||t[10]!==o?(s=(0,Y.jsxs)(Y.Fragment,{children:[i,a,o]}),t[8]=i,t[9]=a,t[10]=o,t[11]=s):s=t[11];let c=s;if(n.url){let e;return t[12]!==c||t[13]!==n.url?(e=(0,Y.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`flex min-w-0 items-center gap-2.5 px-3 py-1.5 text-[12.5px] transition-colors hover:bg-accent`,children:c}),t[12]=c,t[13]=n.url,t[14]=e):e=t[14],e}let l;return t[15]===c?l=t[16]:(l=(0,Y.jsx)(`div`,{className:`flex min-w-0 items-center gap-2.5 px-3 py-1.5 text-[12.5px]`,children:c}),t[15]=c,t[16]=l),l}function mF(e){let t=(0,J.c)(11),{pullRequest:n}=e,r=n.checksError,i;t[0]===r?i=t[1]:(i=r?(0,Y.jsx)(`p`,{className:G(`px-3 py-1.5 text-[11.5px]`,r.kind===`terminal`?`text-destructive-foreground`:`text-muted-foreground`),children:r.message}):null,t[0]=r,t[1]=i);let a;t[2]===n.latestRuns?a=t[3]:(a=n.latestRuns.map(hF),t[2]=n.latestRuns,t[3]=a);let o;t[4]!==r||t[5]!==n.latestRuns.length?(o=n.latestRuns.length===0&&!r?(0,Y.jsx)(`p`,{className:`px-3 py-1.5 text-[12px] text-muted-foreground`,children:`No checks reported.`}):null,t[4]=r,t[5]=n.latestRuns.length,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==a||t[9]!==o?(s=(0,Y.jsxs)(`div`,{children:[i,a,o]}),t[7]=i,t[8]=a,t[9]=o,t[10]=s):s=t[10],s}function hF(e){return(0,Y.jsx)(pF,{run:e},e.id)}function gF(e,t){let n=[];return typeof e==`number`&&n.push(`${e} approved`),typeof t==`number`&&n.push(`${t} requested`),n.length>0?n.join(` · `):null}function _F(e){let t=(0,J.c)(6),{pullRequest:n}=e,r;t[0]!==n.reviewsApproved||t[1]!==n.reviewsRequested?(r=gF(n.reviewsApproved,n.reviewsRequested),t[0]=n.reviewsApproved,t[1]=n.reviewsRequested,t[2]=r):r=t[2];let i=r;if(!i)return null;let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(fr,{}),` Reviews`]}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,Y.jsx)(GP,{label:a,value:i,monoValue:!1}),t[4]=i,t[5]=o),o}function vF(e){let t=(0,J.c)(13),{pullRequest:n,showTitle:r,showChecks:i,showReviews:a}=e,o=r===void 0||r,s=i===void 0||i,c=a===void 0||a,l;t[0]!==n||t[1]!==o?(l=o||n.hasMergeConflicts?(0,Y.jsxs)(`div`,{className:`space-y-2 px-3 pt-0.5 pb-[9px]`,children:[o?(0,Y.jsx)(`p`,{className:`truncate text-[11.5px] text-muted-foreground`,children:n.title}):null,n.hasMergeConflicts?(0,Y.jsx)(KP,{}):null]}):null,t[0]=n,t[1]=o,t[2]=l):l=t[2];let u;t[3]!==n||t[4]!==s?(u=s?(0,Y.jsx)(mF,{pullRequest:n}):null,t[3]=n,t[4]=s,t[5]=u):u=t[5];let d;t[6]!==n||t[7]!==c?(d=c?(0,Y.jsx)(_F,{pullRequest:n}):null,t[6]=n,t[7]=c,t[8]=d):d=t[8];let f;return t[9]!==l||t[10]!==u||t[11]!==d?(f=(0,Y.jsxs)(`div`,{children:[l,u,d]}),t[9]=l,t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function yF(){let e=(0,J.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-3 py-12 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-[13px] text-muted-foreground/40`,children:`No active plan yet.`}),(0,Y.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground/30`,children:`Plans and subagents will appear here as the thread runs.`})]}),e[0]=t):t=e[0],t}var bF={changes:(0,Y.jsx)(mi,{}),plan:(0,Y.jsx)(Ba,{}),agents:(0,Y.jsx)(Jr,{}),pr:(0,Y.jsx)(Zi,{}),checks:(0,Y.jsx)(Zi,{}),env:(0,Y.jsx)(Ja,{})};function xF(e){return!!(e.activePlan&&(e.activePlan.steps.length>0||e.activePlan.explanation)||e.activeProposedPlan?.planMarkdown)}function SF(e,t){return`${e} ${t}${e===1?``:`s`}`}function CF(e){return e?(0,Y.jsx)(IP,{tone:`warning`,children:e}):(0,Y.jsxs)(IP,{tone:`success`,children:[(0,Y.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),` ready`]})}function wF(e,t){let n=t?.trim();if(n)return n.toLocaleLowerCase()===e.trim().toLocaleLowerCase()?void 0:n}function TF(e){let t=(0,J.c)(33),n,r,i,a,o,s;if(t[0]!==e){let c=AP(e),l;t[7]===e.overviewItems?l=t[8]:(l=MP(e.overviewItems),t[7]=e.overviewItems,t[8]=l);let u=l,d=NP(e.overviewItems),f,p,m;if(t[9]!==e.activePlan?.explanation||t[10]!==e.activePlan?.steps||t[11]!==e.subagents){p=e.subagents??[];let n;t[15]!==e.activePlan?.explanation||t[16]!==e.activePlan?.steps?(n=e.activePlan?.steps.find(DF)?.step??e.activePlan?.explanation??void 0,t[15]=e.activePlan?.explanation,t[16]=e.activePlan?.steps,t[17]=n):n=t[17],f=n,m=p.slice(0,2).map(EF).join(`, `),t[9]=e.activePlan?.explanation,t[10]=e.activePlan?.steps,t[11]=e.subagents,t[12]=f,t[13]=p,t[14]=m}else f=t[12],p=t[13],m=t[14];let h=m,g=c.fileCount>0?SF(c.fileCount,`file`):u?.value,_=d?wF(d.value,d.detail):void 0;n=c.fileCount>0||u?(0,Y.jsx)(qP,{icon:bF.changes,title:`Changes`,summary:(0,Y.jsxs)(Y.Fragment,{children:[g?(0,Y.jsx)(`span`,{className:G(`font-mono text-[10px] text-muted-foreground tabular-nums`,c.hasDiff&&`border-r border-border pr-1.5`),children:g}):null,c.hasDiff?(0,Y.jsx)(LP,{additions:c.additions,deletions:c.deletions,className:`text-[10px]`}):null]}),children:(0,Y.jsx)(QP,{changes:e.changes,overviewItems:e.overviewItems,onOpenReview:e.onOpenReview,pullRequestNumber:e.pullRequest?.number})}):null,r=e.pullRequest?(0,Y.jsx)(qP,{icon:bF.checks,title:`Checks`,subtitle:e.pullRequest.number==null?c.refName?`CI on ${c.refName}`:`CI`:`CI on PR #${e.pullRequest.number}`,summary:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(zP,{runs:e.pullRequest.latestRuns}),c.checksTotal>0?(0,Y.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:[c.checksPassed,`/`,c.checksTotal]}):null]}),children:(0,Y.jsx)(mF,{pullRequest:e.pullRequest})}):null,i=xF(e)?(0,Y.jsxs)(qP,{icon:bF.plan,title:`Plan`,subtitle:f,summary:c.planTotal>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(VP,{value:PP(c)}),(0,Y.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:[c.planDone,`/`,c.planTotal]})]}):void 0,children:[(0,Y.jsx)(nF,{activePlan:e.activePlan}),(0,Y.jsx)(rF,{activePlan:e.activePlan}),(0,Y.jsx)(aF,{activeProposedPlan:e.activeProposedPlan,environmentId:e.environmentId,markdownCwd:e.markdownCwd,workspaceRoot:e.workspaceRoot})]}):null,t[18]!==h||t[19]!==e.onOpenSubagent||t[20]!==e.subagents||t[21]!==p||t[22]!==c?(a=p.length>0?(0,Y.jsx)(qP,{icon:bF.agents,title:`Subagents`,subtitle:h?`${h}${p.length>2?`…`:``}`:void 0,summary:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(HP,{subagents:p}),(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:c.agentsRunning>0?`${c.agentsRunning} running`:`${c.agentsTotal} total`})]}),children:(0,Y.jsx)(dF,{subagents:e.subagents,onOpenSubagent:e.onOpenSubagent})}):null,t[18]=h,t[19]=e.onOpenSubagent,t[20]=e.subagents,t[21]=p,t[22]=c,t[23]=a):a=t[23],t[24]===e.pullRequest?o=t[25]:(o=e.pullRequest&&e.pullRequest.number!=null?(0,Y.jsx)(qP,{icon:bF.pr,title:`Pull Request #${e.pullRequest.number}`,subtitle:e.pullRequest.title,summary:(0,Y.jsxs)(Y.Fragment,{children:[e.pullRequest.state?(0,Y.jsx)(xi,{kind:ur(e.pullRequest.state,e.pullRequest.isDraft)}):null,e.pullRequest.hasMergeConflicts?(0,Y.jsx)(IP,{tone:`error`,children:`conflict`}):null]}),externalLink:e.pullRequest.url?{href:e.pullRequest.url,ariaLabel:`Open pull request #${e.pullRequest.number} in a new tab`}:void 0,children:(0,Y.jsx)(vF,{pullRequest:e.pullRequest,showTitle:!1,showChecks:!1,showReviews:!0})}):null,t[24]=e.pullRequest,t[25]=o),s=d?(0,Y.jsx)(qP,{icon:bF.env,title:`Environment`,subtitle:d.value,summary:CF(_)}):null,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s}else n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6];let c;return t[26]!==n||t[27]!==r||t[28]!==i||t[29]!==a||t[30]!==o||t[31]!==s?(c=(0,Y.jsxs)(`div`,{children:[n,r,i,a,o,s]}),t[26]=n,t[27]=r,t[28]=i,t[29]=a,t[30]=o,t[31]=s,t[32]=c):c=t[32],c}function EF(e){return e.name}function DF(e){return e.status===`inProgress`}function OF(e){let t=(0,J.c)(10),{layoutProps:n}=e,r=!!n.pullRequest?.hasMergeConflicts,i=!!n.onRefreshPullRequest;if(!r&&!i)return null;let a=!!n.pullRequest?.checksError,o;t[0]===r?o=t[1]:(o=r?(0,Y.jsxs)(IP,{tone:`error`,children:[(0,Y.jsx)(Xa,{}),` conflict`]}):null,t[0]=r,t[1]=o);let s;t[2]!==a||t[3]!==n.isRefreshingPullRequest||t[4]!==n.onRefreshPullRequest||t[5]!==i?(s=i?(0,Y.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,Y.jsx)(K,{type:`button`,size:`icon-xs`,variant:`ghost`,className:`text-muted-foreground hover:text-foreground`,onClick:n.onRefreshPullRequest,disabled:n.isRefreshingPullRequest,"aria-label":a?`Retry loading source control (last refresh failed)`:`Refresh source control`,children:(0,Y.jsx)(di,{className:G(`size-3.5`,n.isRefreshingPullRequest&&`animate-spin`)})}),a&&!n.isRefreshingPullRequest?(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute -top-0.5 -right-0.5 size-2 rounded-full bg-warning ring-2 ring-card`}):null]}):null,t[2]=a,t[3]=n.isRefreshingPullRequest,t[4]=n.onRefreshPullRequest,t[5]=i,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}var kF=(0,q.memo)(function(e){let t=(0,J.c)(32),n,r,i,a;if(t[0]!==e){let{mode:o,onClose:s,...c}=e;i=s,n=c,r=o===void 0?`sidebar`:o,a=jP(n),t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a}else n=t[1],r=t[2],i=t[3],a=t[4];let o=a,s;t[5]===i?s=t[6]:(s=i?(0,Y.jsx)(K,{type:`button`,size:`icon-xs`,variant:`ghost`,className:`shrink-0 text-muted-foreground hover:text-foreground`,onClick:i,"aria-label":`Close overview`,children:(0,Y.jsx)($a,{className:`size-3.5`})}):null,t[5]=i,t[6]=s);let c=s,l;t[7]!==o||t[8]!==n?(l=o?(0,Y.jsx)(yF,{}):(0,Y.jsx)(TF,{...n}),t[7]=o,t[8]=n,t[9]=l):l=t[9];let u=l,d=r===`sidebar`&&`my-3 mr-3 w-[340px] shrink-0 self-start overflow-hidden rounded-lg border border-border/70 bg-card/90 shadow-xl backdrop-blur supports-[backdrop-filter]:bg-card/75`,f=r===`sheet`&&`h-full w-full bg-card/90 backdrop-blur supports-[backdrop-filter]:bg-card/75`,p=r===`floating`&&`selection-glass-surface pointer-events-auto max-h-[min(72vh,42rem)] w-[min(360px,calc(100vw_-_1.5rem))] rounded-lg border`,m;t[10]!==d||t[11]!==f||t[12]!==p?(m=G(`flex min-h-0 flex-col`,d,f,p),t[10]=d,t[11]=f,t[12]=p,t[13]=m):m=t[13];let h;t[14]===r?h=t[15]:(h=r===`sidebar`?{maxHeight:`calc(100% - 1.5rem)`}:void 0,t[14]=r,t[15]=h);let g;t[16]!==c||t[17]!==o||t[18]!==n?(g=!o&&n.branchControl?(0,Y.jsxs)(`div`,{className:`flex min-h-9 min-w-0 shrink-0 items-center justify-between gap-1 border-b border-border/60 pr-2`,"data-slot":`overview-branch-header`,children:[(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,"data-slot":`overview-branch-control`,children:n.branchControl}),c?(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Y.jsx)(OF,{layoutProps:n}),c]}):(0,Y.jsx)(OF,{layoutProps:n})]}):c?(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-b border-border/60 px-2 py-1.5`,children:c}):null,t[16]=c,t[17]=o,t[18]=n,t[19]=g):g=t[19];let _;t[20]!==u||t[21]!==r?(_=r===`sidebar`?(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]`,"data-slot":`scroll-area-viewport`,children:u}):(0,Y.jsx)(bs,{className:`min-h-0 flex-1`,scrollbarGutter:!0,children:u}),t[20]=u,t[21]=r,t[22]=_):_=t[22];let v;t[23]!==o||t[24]!==n?(v=!o&&n.sourceControlActions?(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-border/60 bg-card/50 px-3 py-2.5`,children:(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1`,children:n.sourceControlActions})}):null,t[23]=o,t[24]=n,t[25]=v):v=t[25];let y;return t[26]!==_||t[27]!==v||t[28]!==m||t[29]!==h||t[30]!==g?(y=(0,Y.jsxs)(`div`,{className:m,style:h,children:[g,_,v]}),t[26]=_,t[27]=v,t[28]=m,t[29]=h,t[30]=g,t[31]=y):y=t[31],y}),AF={added:`A`,add:`A`,a:`A`,new:`A`,modified:`M`,modify:`M`,changed:`M`,m:`M`,deleted:`D`,delete:`D`,removed:`D`,d:`D`,renamed:`R`,rename:`R`,r:`R`,copied:`C`,c:`C`,typechange:`T`,type:`T`,t:`T`};function jF(e){if(e)return AF[e.toLowerCase()]}function MF(e,t,n=[]){let r=new Set(t.map(e=>e.path)),i=new Map;for(let t of e)for(let e of t.files){let t=i.get(e.path),n=jF(e.kind)??t?.status;i.set(e.path,{path:e.path,insertions:(t?.insertions??0)+(e.additions??0),deletions:(t?.deletions??0)+(e.deletions??0),category:r.has(e.path)?`local`:`committed`,...n?{status:n}:{}})}for(let e of t)i.has(e.path)||i.set(e.path,{path:e.path,insertions:e.insertions,deletions:e.deletions,category:`local`});for(let e of n)i.has(e.path)||i.set(e.path,{path:e.path,insertions:e.insertions,deletions:e.deletions,category:`committed`});return[...i.values()]}function NF(e){return`${e} ${e===1?`file`:`files`}`}function PF(e){let t=0,n=0;for(let r of e)t+=r.insertions,n+=r.deletions;return{fileCount:e.length,insertions:t,deletions:n}}function FF(e){return{committed:PF(e.filter(e=>e.category===`committed`)),local:PF(e.filter(e=>e.category!==`committed`))}}function IF(e){let{committed:t,local:n}=e,r=t.insertions+n.insertions,i=t.deletions+n.deletions,a=t.fileCount>0,o=n.fileCount>0;return!a&&!o?{label:`Changes`,value:`No changes`,additions:0,deletions:0}:a&&o?{label:`Changes`,value:`Committed + local`,additions:r,deletions:i,breakdown:[{label:`Committed`,value:NF(t.fileCount),...e.pullRequestNumber?{detail:`PR #${e.pullRequestNumber}`}:{},additions:t.insertions,deletions:t.deletions,muted:!1},{label:`Uncommitted`,value:NF(n.fileCount),detail:`local`,additions:n.insertions,deletions:n.deletions,muted:!1}]}:{label:`Changes`,value:NF(a?t.fileCount:n.fileCount),additions:r,deletions:i}}function LF(e){return e==null?``:typeof e==`string`?e:e instanceof Error||typeof e==`object`&&`message`in e&&typeof e.message==`string`?e.message:String(e)}var RF=[{kind:`terminal`,message:`Sign in to your source control provider to load this pull request.`,patterns:[`gh auth`,`not logged in`,`authentication`,`unauthorized`,`http 401`,`401`,`bad credentials`]},{kind:`terminal`,message:`This pull request could not be found.`,patterns:[`could not resolve to a`,`not found`,`404`,`no pull requests found`]},{kind:`transient`,message:`The source control provider is rate limiting requests. Try again shortly.`,patterns:[`rate limit`]},{kind:`transient`,message:`Loading pull request details timed out. Try refreshing.`,patterns:[`timed out`,`timeout`,`etimedout`,`vcsprocesstimeout`]},{kind:`transient`,message:`Couldn't reach the source control provider. Try refreshing.`,patterns:[`econnreset`,`enotfound`,`eai_again`,`socket hang up`,`network`,`fetch failed`,`econnrefused`,`connection refused`]}];function zF(e){let t=LF(e).trim();if(t.length===0)return null;let n=t.toLowerCase();for(let e of RF)if(e.patterns.some(e=>n.includes(e)))return{kind:e.kind,message:e.message,raw:t};return{kind:`transient`,message:`Couldn't load pull request details. Try refreshing.`,raw:t}}function BF(e,t){return!e||e.pr||!t?e:{...e,pr:{number:t.number,title:t.title,url:t.url,baseRef:t.baseRefName,headRef:t.headRefName,state:t.state}}}function VF(e){return e?.sourceControlProvider?lr(e.sourceControlProvider):hr}function HF(e){let t=e.terminology??hr,n=e.featureBranch?[`Preparing feature ref...`]:[],r=e.pushTarget?`Pushing to ${e.pushTarget}...`:`Pushing...`,i=[`Preparing ${t.shortLabel}...`,`Generating ${t.shortLabel} content...`,`Creating ${t.singular}...`];if(e.action===`push`)return[r];if(e.action===`create_pr`)return e.shouldPushBeforePr?[r,...i]:i;let a=e.action===`commit`||e.hasWorkingTreeChanges?e.hasCustomCommitMessage?[`Committing...`]:[`Generating commit message...`,`Committing...`]:[];return e.action===`commit`?[...n,...a]:e.action===`commit_push`?[...n,...a,r]:[...n,...a,r,...i]}function UF(e,t,n=!0){if(!e)return[];let r=VF(e),i=e.refName!==null,a=e.hasWorkingTreeChanges,o=e.pr?.state===`open`,s=e.behindCount>0,c=(e.aheadOfDefaultCount??e.aheadCount)>0,l=n&&!e.hasUpstream,u=!t&&a,d=!t&&i&&!s&&e.aheadCount>0&&(e.hasUpstream||l),f=!t&&i&&!a&&!o&&c&&!s&&(e.hasUpstream||l),p=!t&&o,m={id:`commit`,label:`Commit`,disabled:!u,icon:`commit`,kind:`open_dialog`,dialogAction:`commit`};return n?[m,{id:`push`,label:`Push`,disabled:!d,icon:`push`,kind:`open_dialog`,dialogAction:`push`},o?{id:`pr`,label:`View ${r.shortLabel}`,disabled:!p,icon:`pr`,kind:`open_pr`}:{id:`pr`,label:`Create ${r.shortLabel}`,disabled:!f,icon:`pr`,kind:`open_dialog`,dialogAction:`create_pr`}]:[m]}function WF(e,t,n=!1,r=!0){if(t)return{label:`Commit`,disabled:!0,kind:`show_hint`,hint:`Git action in progress.`};if(!e)return{label:`Commit`,disabled:!0,kind:`show_hint`,hint:`Git status is unavailable.`};let i=e.refName!==null,a=e.hasWorkingTreeChanges,o=e.pr?.state===`open`,s=e.aheadCount>0,c=(e.aheadOfDefaultCount??e.aheadCount)>0,l=e.behindCount>0,u=s&&l,d=VF(e);return i?a?!e.hasUpstream&&!r?{label:`Commit`,disabled:!1,kind:`run_action`,action:`commit`}:o||n?{label:`Commit & push`,disabled:!1,kind:`run_action`,action:`commit_push`}:{label:`Commit, push & ${d.shortLabel}`,disabled:!1,kind:`run_action`,action:`commit_push_pr`}:e.hasUpstream?u?{label:`Sync ref`,disabled:!0,kind:`show_hint`,hint:`Branch has diverged from upstream. Rebase/merge first.`}:l?{label:`Pull`,disabled:!1,kind:`run_pull`}:s?o||n?{label:`Push`,disabled:!1,kind:`run_action`,action:n?`commit_push`:`push`}:{label:`Push & create ${d.shortLabel}`,disabled:!1,kind:`run_action`,action:`create_pr`}:o&&e.hasUpstream?{label:`View ${d.shortLabel}`,disabled:!1,kind:`open_pr`}:c&&!n?{label:`Create ${d.shortLabel}`,disabled:!1,kind:`run_action`,action:`create_pr`}:{label:`Commit`,disabled:!0,kind:`show_hint`,hint:`Branch is up to date. No action needed.`}:r?s?o||n?{label:`Push`,disabled:!1,kind:`run_action`,action:n?`commit_push`:`push`}:{label:`Push & create ${d.shortLabel}`,disabled:!1,kind:`run_action`,action:`create_pr`}:o?{label:`View ${d.shortLabel}`,disabled:!1,kind:`open_pr`}:{label:`Push`,disabled:!0,kind:`show_hint`,hint:`No local commits to push.`}:o&&!s?{label:`View ${d.shortLabel}`,disabled:!1,kind:`open_pr`}:{label:`Publish repository`,disabled:!1,kind:`open_publish`}:{label:`Commit`,disabled:!0,kind:`show_hint`,hint:`Create and checkout a ref before pushing or opening a ${d.singular}.`}}function GF(e,t){return t?e===`push`||e===`create_pr`||e===`commit_push`||e===`commit_push_pr`:!1}function KF(e){let t=e.branchName,n=` on "${t}". You can continue on this ref or create a feature ref and run the same action there.`,r=e.terminology??hr;return e.action===`push`||e.action===`commit_push`?e.includesCommit?{title:`Commit & push to default ref?`,description:`This action will commit and push changes${n}`,continueLabel:`Commit & push to ${t}`}:{title:`Push to default ref?`,description:`This action will push local commits${n}`,continueLabel:`Push to ${t}`}:e.includesCommit?{title:`Commit, push & create ${r.shortLabel} from default ref?`,description:`This action will commit, push, and create a ${r.singular}${n}`,continueLabel:`Commit, push & create ${r.shortLabel}`}:{title:`Push & create ${r.shortLabel} from default ref?`,description:`This action will push local commits and create a ${r.singular}${n}`,continueLabel:`Push & create ${r.shortLabel}`}}function qF(e){return e.branch.status!==`created`||!e.branch.name?null:{branch:e.branch.name}}function JF(e){return!e.gitStatus||e.gitStatus.refName===null&&e.threadBranch!==null||e.threadBranch===e.gitStatus.refName||e.threadBranch!==null&&e.gitStatus.refName!==null&&!a(e.threadBranch)&&a(e.gitStatus.refName)?null:{branch:e.gitStatus.refName}}function YF(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}function XF(e){return{checked(t){return e.indeterminate?{}:t?{"data-checked":``}:{"data-unchecked":``}},...Go}}var ZF=q.createContext(void 0);function QF(){return q.useContext(ZF)}var $F=q.createContext(void 0);function eI(){let e=q.useContext($F);if(e===void 0)throw Error(Lr(14));return e}var tI=`data-parent`,nI=q.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:m=!1,render:h,required:g=!1,uncheckedValue:_,value:v,nativeButton:y=!1,style:b,...x}=e,{clearErrors:S}=Uo(),{disabled:C,name:w,setDirty:T,setFilled:E,setFocused:D,setTouched:O,state:k,validationMode:A,validityData:j,validation:M}=Wo(),N=ls(),{labelId:P,controlId:F,registerControlId:I,getDescriptionProps:ee}=Ho(),L=QF(),R=L?.allValues===void 0?void 0:L.parent,te=R!==void 0,z=C||N.disabled||L?.disabled||o,ne=w??d,B=v??ne,re=On(),V=On(),H=c||F;te&&(p?H=V:B===void 0?H||=V:H=`${R.id}-${B}`);let ie={};te&&(p?ie=R.getParentProps():B!==void 0&&(ie=R.getChildProps(B)));let{checked:ae=n,indeterminate:U=l,onCheckedChange:oe,...se}=ie,ce=L?.value,le=q.useRef(null),ue=Wr(()=>Symbol()),de=q.useRef(!1),{getButtonProps:fe,buttonRef:pe}=Po({disabled:z,native:y}),me=L?.validation??M,[he,ge]=Bo({controlled:B!==void 0&&ce!==void 0&&!p?ce.includes(B):ae,default:i,name:`Checkbox`,state:`checked`}),_e=te?!!ae:he,ve=te&&U||l;Sn(()=>{I!==Hr&&(de.current=!0,I(ue.current,H))},[H,I,ue]),q.useEffect(()=>{let e=ue.current;return()=>{!de.current||I===Hr||(de.current=!1,I(e,void 0))}},[I,ue]),Vo(le,re,he,void 0,!L&&!z,d);let ye=q.useRef(null),be=me.registerInput,xe=L?B:void 0,Se=q.useCallback(e=>be(e,{controlRef:le,value:xe}),[be,xe]),Ce=zr(u,ye,p?void 0:Se),we=_s(a,P,ye,!y,H??void 0);Sn(()=>{ye.current&&(ye.current.indeterminate=ve,he&&E(!0))},[he,ve,E]),zo(he,()=>{L||(S(ne),E(he),T(he!==j.initialValue),me.change(he))});let Te=Vr({checked:he,disabled:z,form:s,name:p?void 0:ne,id:y?void 0:H??void 0,required:g,ref:Ce,style:ne?xn:En,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(m){e.preventDefault();return}let t=e.currentTarget.checked,n=An(Tn,e.nativeEvent);if(f?.(t,n),!n.isCanceled&&(oe?.(t,n),!n.isCanceled&&(ge(t),B!==void 0&&L!==void 0&&!p&&!te))){let e=t?[...L.value,B]:L.value.filter(e=>e!==B);L.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){le.current?.focus()}},v===void 0?Br:{value:(L?he&&v:v)||``},ee,e=>me.getValidationProps(z,e));q.useEffect(()=>{if(!R||B===void 0)return;let e=R.disabledStatesRef.current;return e.set(B,z),()=>{e.delete(B)}},[R,z,B]);let Ee=q.useMemo(()=>({...k,checked:_e,disabled:z,readOnly:m,required:g,indeterminate:ve}),[k,_e,z,m,g,ve]),De=XF(Ee),Oe=Ur(`span`,e,{state:Ee,ref:[pe,le,t],props:[{id:y?H??void 0:re,role:`checkbox`,"aria-checked":ve?`mixed`:_e,"aria-readonly":m||void 0,"aria-required":g||void 0,"aria-labelledby":we,[tI]:p?``:void 0,onFocus(){z||D(!0)},onBlur(){let e=ye.current;e&&(O(!0),D(!1),A===`onBlur`&&me.commit(L?ce:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=ye.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),wn(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||YF(t)?.click()})},onClick(e){if(m||z)return;e.preventDefault();let t=ye.current;t&&No(t,e)}},x,se,fe,ee,e=>me.getValidationProps(z,e)],stateAttributesMapping:De});return(0,Y.jsxs)($F.Provider,{value:Ee,children:[Oe,!he&&!L&&ne&&!p&&_!==void 0&&(0,Y.jsx)(`input`,{type:`hidden`,form:s,name:ne,value:_,disabled:z}),(0,Y.jsx)(`input`,{...Te,suppressHydrationWarning:!0})]})}),rI=q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=eI(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=Cn(c),f=q.useRef(null),p={...s,transitionStatus:u};kn({open:c,ref:f,onComplete(){c||d(!1)}});let m={...XF(s),...Dn},h=a||l,g=Ur(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function iI(e){let t=(0,J.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-sm border border-input bg-background not-dark:bg-clip-padding shadow-xs/5 outline-none ring-ring transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[max(0px,calc(var(--radius-sm)-1px))] not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/48 data-disabled:opacity-64 sm:size-4 dark:not-data-checked:bg-input/32 dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)] [[data-disabled],[data-checked],[aria-invalid]]:shadow-none`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Y.jsx)(rI,{className:`-inset-px absolute flex items-center justify-center rounded-sm text-primary-foreground data-unchecked:hidden data-checked:bg-primary data-indeterminate:text-foreground`,"data-slot":`checkbox-indicator`,render:aI}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Y.jsx)(nI,{className:i,"data-slot":`checkbox`,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function aI(e,t){return(0,Y.jsx)(`span`,{...e,children:t.indeterminate?(0,Y.jsx)(`svg`,{className:`size-3.5 sm:size-3`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`3`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,Y.jsx)(`path`,{d:`M5.252 12h13.496`})}):(0,Y.jsx)(`svg`,{className:`size-3.5 sm:size-3`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`3`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,Y.jsx)(`path`,{d:`M5.252 12.7 10.2 18.63 18.748 5.37`})})})}var oI=250,sI=[{value:`github`,label:`GitHub`,description:`github.com`,host:`github.com`,pathPlaceholder:`owner/repo`,Icon:Ds},{value:`gitlab`,label:`GitLab`,description:`gitlab.com`,host:`gitlab.com`,pathPlaceholder:`group/project`,Icon:ws},{value:`forgejo`,label:`Forgejo`,description:`Forgejo instance`,host:`configured Forgejo host`,pathPlaceholder:`owner/repo`,Icon:Ss},{value:`bitbucket`,label:`Bitbucket`,description:`bitbucket.org`,host:`bitbucket.org`,pathPlaceholder:`workspace/repository`,Icon:xs},{value:`azure-devops`,label:`Azure DevOps`,description:`dev.azure.com`,host:`dev.azure.com`,pathPlaceholder:`project/repository`,Icon:Ts}];function cI(e){return sI.find(t=>t.value===e)??sI[0]}function lI(e){return sI.some(t=>t.value===e)}function uI(e){let t=e.sourceControlProviders.find(t=>t.kind===e.provider);return t?t.status===`available`?t.auth.status===`unauthenticated`?{ready:!1,hint:g(t.auth.detail)??`${t.label} is not authenticated. Open Settings -> Source Control for setup guidance.`}:{ready:!0,hint:null}:{ready:!1,hint:t.installHint}:{ready:!1,hint:`Provider status unavailable. Open Settings -> Source Control and rescan.`}}function dI(e){if(e===null)return;let t=Math.max(0,Math.floor((Date.now()-e)/1e3));return t<60?`Running for ${t}s`:`Running for ${Math.floor(t/60)}m ${t%60}s`}function fI(e){return e.lastOutputLine?e.lastOutputLine:dI(e.hookStartedAtMs??e.phaseStartedAtMs)}function pI({item:e,gitStatus:t,isBusy:n,hasPrimaryRemote:r}){if(!e.disabled)return null;if(n)return`Git action in progress.`;if(!t)return`Git status is unavailable.`;let i=t.refName!==null,a=t.hasWorkingTreeChanges,o=t.pr?.state===`open`,s=t.aheadCount>0,c=t.behindCount>0,l=vr(t.sourceControlProvider).terminology;return e.id===`commit`?a?`Commit is currently unavailable.`:`Worktree is clean. Make changes before committing.`:e.id===`push`?i?a?`Commit or stash local changes before pushing.`:c?`Branch is behind upstream. Pull/rebase before pushing.`:!t.hasUpstream&&!r?`Add an "origin" remote before pushing.`:s?`Push is currently unavailable.`:`No local commits to push.`:`Detached HEAD: checkout a refName before pushing.`:o?`View ${l.singular} is currently unavailable.`:i?a?`Commit local changes before creating a ${l.singular}.`:!t.hasUpstream&&!r?`Add an "origin" remote before creating a ${l.singular}.`:s?c?`Branch is behind upstream. Pull/rebase before creating a ${l.singular}.`:`Create ${l.singular} is currently unavailable.`:`No local commits to include in a ${l.singular}.`:`Detached HEAD: checkout a refName before creating a ${l.singular}.`}var mI=`Commit changes`,hI=`Review and confirm your commit. Leave the message blank to auto-generate one.`;function gI(e){let t=(0,J.c)(4),{icon:n,SourceControlIcon:r}=e;if(n===`commit`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(mi,{}),t[0]=e):e=t[0],e}if(n===`push`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(_l,{}),t[1]=e):e=t[1],e}let i;return t[2]===r?i=t[3]:(i=(0,Y.jsx)(r,{}),t[2]=r,t[3]=i),i}function _I(e){let t=(0,J.c)(10),{quickAction:n,SourceControlIcon:r}=e;if(n.kind===`open_pr`){let e;return t[0]===r?e=t[1]:(e=(0,Y.jsx)(r,{className:`size-3.5`}),t[0]=r,t[1]=e),e}if(n.kind===`open_publish`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(_l,{className:`size-3.5`}),t[2]=e):e=t[2],e}if(n.kind===`run_pull`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(ki,{className:`size-3.5`}),t[3]=e):e=t[3],e}if(n.kind===`run_action`){if(n.action===`commit`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(mi,{className:`size-3.5`}),t[4]=e):e=t[4],e}if(n.action===`push`||n.action===`commit_push`){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(_l,{className:`size-3.5`}),t[5]=e):e=t[5],e}let e;return t[6]===r?e=t[7]:(e=(0,Y.jsx)(r,{className:`size-3.5`}),t[6]=r,t[7]=e),e}if(n.label===`Commit`){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(mi,{className:`size-3.5`}),t[8]=e):e=t[8],e}let i;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Y.jsx)(ki,{className:`size-3.5`}),t[9]=i):i=t[9],i}function vI(e){let t=(0,J.c)(7),{quickAction:n}=e;if(n.kind===`open_pr`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(Wi,{className:`size-3.5`}),t[0]=e):e=t[0],e}if(n.kind===`open_publish`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(_l,{className:`size-3.5`}),t[1]=e):e=t[1],e}if(n.kind===`run_pull`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(Gr,{className:`size-3.5`}),t[2]=e):e=t[2],e}if(n.kind===`run_action`){if(n.action===`commit`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(mi,{className:`size-3.5`}),t[3]=e):e=t[3],e}if(n.action===`create_pr`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(Zi,{className:`size-3.5`}),t[4]=e):e=t[4],e}let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Y.jsx)(_l,{className:`size-3.5`}),t[5]=e):e=t[5],e}let r;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Y.jsx)(mi,{className:`size-3.5`}),t[6]=r):r=t[6],r}function yI(e){let t=(0,J.c)(168),n=de(),[r,i]=(0,q.useState)(`github`),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(`private`),[l,u]=(0,q.useState)(`origin`),[d,f]=(0,q.useState)(`ssh`),[p,m]=(0,q.useState)(0),[h,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(!1),w;t[0]!==e.environmentId||t[1]!==e.gitCwd?(w=t=>{if(!e.gitCwd||!e.environmentId)throw Error(`Repository publishing is unavailable.`);return We(e.environmentId).sourceControl.publishRepository({cwd:e.gitCwd,...t})},t[0]=e.environmentId,t[1]=e.gitCwd,t[2]=w):w=t[2];let T;t[3]===e.gitCwd?T=t[4]:(T=e.gitCwd?[we(e.gitCwd)]:[],t[3]=e.gitCwd,t[4]=T);let E;t[5]!==e.environmentId||t[6]!==e.gitCwd?(E=ku(`publish-repository`,e.environmentId,e.gitCwd),t[5]=e.environmentId,t[6]=e.gitCwd,t[7]=E):E=t[7];let D;t[8]!==w||t[9]!==T||t[10]!==E?(D={mutationFn:w,invalidates:T,trackingKey:E},t[8]=w,t[9]=T,t[10]=E,t[11]=D):D=t[11];let O=Du(D),k;if(t[12]!==n.data?.sourceControlProviders){k={github:null,gitlab:null,forgejo:null,bitbucket:null,"azure-devops":null};for(let e of n.data?.sourceControlProviders??[])lI(e.kind)&&(k[e.kind]=g(e.auth.account));t[12]=n.data?.sourceControlProviders,t[13]=k}else k=t[13];let A=k,j;t[14]===n.data?.sourceControlProviders?j=t[15]:(j=n.data?.sourceControlProviders??[],t[14]=n.data?.sourceControlProviders,t[15]=j);let M=j,N;t[16]===M?N=t[17]:(N=Object.fromEntries(sI.map(e=>[e.value,uI({provider:e.value,sourceControlProviders:M})])),t[16]=M,t[17]=N);let P=N,F;t[18]===P?F=t[19]:(F=sI.some(e=>P[e.value].ready),t[18]=P,t[19]=F);let I=F,ee;t[20]===P?ee=t[21]:(ee=sI.toSorted((e,t)=>{let n=P[e.value].ready;return n===P[t.value].ready?e.label.localeCompare(t.label):n?-1:1}),t[20]=P,t[21]=ee);let L=ee,R=P[r],te=A[r]?`${A[r]}/`:``,z;t[22]===r?z=t[23]:(z=cI(r),t[22]=r,t[23]=z);let ne=z,re=ne.host,V=ne.pathPlaceholder,H=ne.label,ie;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ie=[`Provider`,`Repository`,`Summary`],t[24]=ie):ie=t[24];let ae=ie,U=b?.repository.nameWithOwner??null,oe;t[25]!==H||t[26]!==U?(oe=[H,U,null],t[25]=H,t[26]=U,t[27]=oe):oe=t[27];let se=oe,ce,le;t[28]!==S||t[29]!==e.open||t[30]!==te?(ce=()=>{!e.open||S||o(te)},le=[S,e.open,te],t[28]=S,t[29]=e.open,t[30]=te,t[31]=ce,t[32]=le):(ce=t[31],le=t[32]),(0,q.useEffect)(ce,le);let ue;bb0:{if(!R.ready){ue=!1;break bb0}if(O.isPending){ue=!1;break bb0}let e,n;if(t[33]!==a){let r=a.trim().split(`/`);e=r[0]?.trim()??``,n=r.slice(1).join(`/`).trim(),t[33]=a,t[34]=e,t[35]=n}else e=t[34],n=t[35];let r=n;ue=e.length>0&&r.length>0}let fe=ue,pe,me;t[36]!==e.open||t[37]!==r||t[38]!==P?(pe=()=>{if(!e.open||P[r].ready)return;let t=sI.find(e=>P[e.value].ready);t&&i(t.value)},me=[e.open,r,P],t[36]=e.open,t[37]=r,t[38]=P,t[39]=pe,t[40]=me):(pe=t[39],me=t[40]),(0,q.useEffect)(pe,me);let ge;t[41]!==fe||t[42]!==e.environmentId||t[43]!==e.gitCwd||t[44]!==d||t[45]!==r||t[46]!==l||t[47]!==a||t[48]!==O||t[49]!==s?(ge=()=>{fe&&(y(null),O.mutateAsync({provider:r,repository:a.trim(),visibility:s,remoteName:l.trim()||`origin`,protocol:d}).then(t=>{(0,pT.flushSync)(()=>{x(t),m(2)}),B({environmentId:e.environmentId,cwd:e.gitCwd}).catch(wI)}).catch(e=>{y(e instanceof Error?e.message:`An error occurred.`)}))},t[41]=fe,t[42]=e.environmentId,t[43]=e.gitCwd,t[44]=d,t[45]=r,t[46]=l,t[47]=a,t[48]=O,t[49]=s,t[50]=ge):ge=t[50];let _e=ge,ve;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ve=()=>{u(`origin`),o(``),C(!1),m(0),_(!1),y(null),x(null)},t[51]=ve):ve=t[51];let ye=ve,be;t[52]===e?be=t[53]:(be=t=>{e.onOpenChange(t),t||ye()},t[52]=e,t[53]=be);let xe=be,Se=wr(CI),Ce;t[54]!==xe||t[55]!==Se?(Ce=()=>{xe(!1),Se(`source-control`)},t[54]=xe,t[55]=Se,t[56]=Ce):Ce=t[56];let Te=Ce,Ee=e.open,De,Oe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Y.jsx)(qs,{children:`Publish repository`}),Oe=(0,Y.jsx)(Xs,{children:`Pick where to host it, then point us at a repo to push to.`}),t[57]=De,t[58]=Oe):(De=t[57],Oe=t[58]);let ke;t[59]!==p||t[60]!==se?(ke=(0,Y.jsxs)(Ks,{className:`border-b border-border/70 bg-background`,children:[De,Oe,(0,Y.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:ae.map((e,t)=>{let n=t<p,r=p!==2&&t<ae.length-1&&t<=p;return(0,Y.jsxs)(`button`,{type:`button`,onClick:r?()=>m(t):void 0,disabled:!r,className:G(`grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] gap-x-2 rounded-lg border px-3 py-2 text-left`,t===p?`border-primary bg-primary/10 ring-1 ring-primary/25`:n?`border-border bg-background`:`border-border bg-muted/40`,!r&&`cursor-default`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:G(`row-span-2 mt-0.5 grid size-4 place-items-center rounded-full border`,n?`border-primary bg-primary text-primary-foreground`:t===p?`border-primary bg-background`:`border-muted-foreground/35 bg-background`),children:n?(0,Y.jsx)(Yr,{className:`size-3`}):null}),(0,Y.jsxs)(`span`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:[`Step `,t+1]}),(0,Y.jsxs)(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:[e,n&&se[t]?`: ${se[t]}`:``]})]},e)})})]}),t[59]=p,t[60]=se,t[61]=ke):ke=t[61];let Ae=p!==0&&`hidden`,je;t[62]===Ae?je=t[63]:(je=G(`space-y-2`,Ae),t[62]=Ae,t[63]=je);let Me;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(Me=(0,Y.jsx)(`span`,{id:`publish-provider-cards-label`,className:`text-xs font-medium text-foreground`,children:`Provider`}),t[64]=Me):Me=t[64];let Ne;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=e=>i(e),t[65]=Ne):Ne=t[65];let Pe;if(t[66]!==Te||t[67]!==r||t[68]!==P||t[69]!==L){let e;t[71]!==Te||t[72]!==r||t[73]!==P?(e=e=>{let t=P[e.value],n=r===e.value&&t.ready;return t.ready?(0,Y.jsxs)(ds,{value:e.value,className:G(`relative flex cursor-pointer items-center gap-3 rounded-lg border px-3 py-3 text-left outline-none transition-[background-color,border-color,box-shadow]`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background`,n?`border-primary bg-background shadow-sm ring-2 ring-primary/35`:`border-border bg-background hover:border-foreground/20 hover:bg-muted/50`),children:[(0,Y.jsx)(e.Icon,{className:`size-5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:e.label})]},e.value):(0,Y.jsxs)(`div`,{className:`relative flex cursor-not-allowed items-center gap-3 rounded-lg border border-border bg-background px-3 py-3 text-left opacity-55`,children:[(0,Y.jsx)(e.Icon,{className:`size-5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:e.label}),(0,Y.jsxs)(Lo,{children:[(0,Y.jsx)(Fo,{render:(0,Y.jsx)(K,{variant:`outline`,size:`xs`,className:`h-5 rounded-sm px-1.5 text-[10px] text-warning-foreground`,onClick:e=>{e.preventDefault(),e.stopPropagation(),Te()},children:`Setup Required`})}),(0,Y.jsx)(Io,{side:`top`,align:`end`,className:`max-w-72`,children:t.hint??`Open Settings -> Source Control to configure this provider.`})]})]},e.value)},t[71]=Te,t[72]=r,t[73]=P,t[74]=e):e=t[74],Pe=L.map(e),t[66]=Te,t[67]=r,t[68]=P,t[69]=L,t[70]=Pe}else Pe=t[70];let Fe;t[75]!==r||t[76]!==Pe?(Fe=(0,Y.jsx)(hs,{value:r,onValueChange:Ne,"aria-labelledby":`publish-provider-cards-label`,className:`grid grid-cols-2 gap-2.5`,children:Pe}),t[75]=r,t[76]=Pe,t[77]=Fe):Fe=t[77];let Ie;t[78]!==je||t[79]!==Fe?(Ie=(0,Y.jsxs)(`div`,{className:je,children:[Me,Fe]}),t[78]=je,t[79]=Fe,t[80]=Ie):Ie=t[80];let Le=p!==1&&`hidden`,Re;t[81]===Le?Re=t[82]:(Re=G(`space-y-5`,Le),t[81]=Le,t[82]=Re);let ze;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,Y.jsx)(`label`,{htmlFor:`publish-repository-path`,className:`text-xs font-medium text-foreground`,children:`Repository`}),t[83]=ze):ze=t[83];let Be;t[84]===ne.Icon?Be=t[85]:(Be=(0,Y.jsx)(ne.Icon,{className:`size-3.5`}),t[84]=ne.Icon,t[85]=Be);let Ve;t[86]!==re||t[87]!==Be?(Ve=(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 border-r border-input bg-muted/50 px-2.5 font-mono text-xs text-muted-foreground`,children:[Be,re,`/`]}),t[86]=re,t[87]=Be,t[88]=Ve):Ve=t[88];let He;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(He=e=>{o(e.target.value),C(!0)},t[89]=He):He=t[89];let Ue;t[90]===_e?Ue=t[91]:(Ue=e=>{e.key===`Enter`&&jo(e)&&(e.preventDefault(),_e())},t[90]=_e,t[91]=Ue);let Ge;t[92]!==V||t[93]!==a||t[94]!==O.isPending||t[95]!==Ue?(Ge=(0,Y.jsx)(`input`,{id:`publish-repository-path`,name:`publish-repository-path`,value:a,onChange:He,onKeyDown:Ue,placeholder:V,disabled:O.isPending,className:`w-full bg-transparent px-3 py-2 font-mono text-sm placeholder:text-muted-foreground/60 focus:outline-none`}),t[92]=V,t[93]=a,t[94]=O.isPending,t[95]=Ue,t[96]=Ge):Ge=t[96];let Ke;t[97]!==Ve||t[98]!==Ge?(Ke=(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[ze,(0,Y.jsxs)(`div`,{className:`flex items-stretch overflow-hidden rounded-md border border-input bg-background focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-ring`,children:[Ve,Ge]})]}),t[97]=Ve,t[98]=Ge,t[99]=Ke):Ke=t[99];let qe;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,Y.jsx)(`span`,{id:`publish-visibility-cards-label`,className:`text-xs font-medium text-foreground`,children:`Visibility`}),t[100]=qe):qe=t[100];let Je;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(Je=e=>c(e),t[101]=Je):Je=t[101];let Ye=O.isPending,Xe;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(Xe={value:`private`,label:`Private`,description:`Only invited people`,Icon:ba},t[102]=Xe):Xe=t[102];let Ze;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=[Xe,{value:`public`,label:`Public`,description:`Anyone on the web`,Icon:ma}],t[103]=Ze):Ze=t[103];let Qe;t[104]===s?Qe=t[105]:(Qe=Ze.map(e=>{let t=s===e.value;return(0,Y.jsxs)(ds,{value:e.value,className:G(`relative flex cursor-pointer items-center gap-3 rounded-lg border px-3 py-2.5 text-left outline-none transition-[background-color,border-color,box-shadow]`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background`,t?`border-primary bg-background shadow-sm ring-2 ring-primary/35`:`border-border bg-background hover:border-foreground/20 hover:bg-muted/50`),children:[(0,Y.jsx)(e.Icon,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:e.label}),(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]})]},e.value)}),t[104]=s,t[105]=Qe);let $e;t[106]!==O.isPending||t[107]!==s||t[108]!==Qe?($e=(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[qe,(0,Y.jsx)(hs,{value:s,onValueChange:Je,"aria-labelledby":`publish-visibility-cards-label`,disabled:Ye,className:`grid grid-cols-2 gap-2.5`,children:Qe})]}),t[106]=O.isPending,t[107]=s,t[108]=Qe,t[109]=$e):$e=t[109];let et;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(et=()=>_(SI),t[110]=et):et=t[110];let tt=h?``:`-rotate-90`,nt;t[111]===tt?nt=t[112]:(nt=G(`size-3.5 transition-transform`,tt),t[111]=tt,t[112]=nt);let rt;t[113]===nt?rt=t[114]:(rt=(0,Y.jsx)(Zr,{className:nt}),t[113]=nt,t[114]=rt);let it;t[115]!==h||t[116]!==rt?(it=(0,Y.jsxs)(`button`,{type:`button`,onClick:et,"aria-expanded":h,className:`flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:[rt,`Advanced`]}),t[115]=h,t[116]=rt,t[117]=it):it=t[117];let at;t[118]!==h||t[119]!==d||t[120]!==l||t[121]!==O.isPending?(at=h?(0,Y.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`label`,{className:`space-y-1.5`,htmlFor:`publish-remote-name`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Remote`}),(0,Y.jsx)(ys,{id:`publish-remote-name`,value:l,onChange:e=>u(e.target.value),placeholder:`origin`,disabled:O.isPending})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`span`,{id:`publish-protocol-label`,className:`text-xs font-medium text-foreground`,children:`Protocol`}),(0,Y.jsx)(hs,{value:d,onValueChange:e=>f(e),"aria-labelledby":`publish-protocol-label`,disabled:O.isPending,className:`grid grid-cols-2 gap-2`,children:[`ssh`,`https`].map(e=>{let t=d===e;return(0,Y.jsx)(ds,{value:e,className:G(`rounded-md border px-3 py-1.5 text-center text-sm font-medium outline-none transition`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background`,t?`border-primary bg-background ring-2 ring-primary/35 text-foreground`:`border-border bg-background text-muted-foreground hover:border-foreground/20 hover:text-foreground`),children:e===`ssh`?`SSH`:`HTTPS`},e)})})]})]}):null,t[118]=h,t[119]=d,t[120]=l,t[121]=O.isPending,t[122]=at):at=t[122];let ot;t[123]!==it||t[124]!==at?(ot=(0,Y.jsxs)(`div`,{children:[it,at]}),t[123]=it,t[124]=at,t[125]=ot):ot=t[125];let st;t[126]!==H||t[127]!==O.isPending?(st=O.isPending?(0,Y.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center gap-2 rounded-md border border-input bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(lc,{className:`size-3.5`,"aria-hidden":!0}),`Publishing repository to `,H,`...`]}):null,t[126]=H,t[127]=O.isPending,t[128]=st):st=t[128];let ct;t[129]!==v||t[130]!==O.isPending?(ct=v&&!O.isPending?(0,Y.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:`Publish failed`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-destructive/90`,children:v})]}):null,t[129]=v,t[130]=O.isPending,t[131]=ct):ct=t[131];let lt;t[132]!==Re||t[133]!==Ke||t[134]!==$e||t[135]!==ot||t[136]!==st||t[137]!==ct?(lt=(0,Y.jsxs)(`div`,{className:Re,children:[Ke,$e,ot,st,ct]}),t[132]=Re,t[133]=Ke,t[134]=$e,t[135]=ot,t[136]=st,t[137]=ct,t[138]=lt):lt=t[138];let ut=p!==2&&`hidden`,dt;t[139]===ut?dt=t[140]:(dt=G(`space-y-4`,ut),t[139]=ut,t[140]=dt);let ft;t[141]!==ne.Icon||t[142]!==H||t[143]!==b?(ft=b?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-1 text-center`,children:[(0,Y.jsx)(`span`,{className:`grid size-8 place-items-center rounded-full bg-success/15 text-success`,children:(0,Y.jsx)(Yr,{className:`size-4`,"aria-hidden":!0})}),(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:b.status===`pushed`?`Repository published`:`Repository created`}),(0,Y.jsx)(`p`,{className:`max-w-xs text-pretty text-xs text-muted-foreground`,children:b.status===`pushed`?`${b.branch} is now live on ${H}.`:`Remote "${b.remoteName}" is set up. Make a commit and push it to share your code.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-input bg-muted/40 px-3 py-2`,children:[(0,Y.jsx)(ne.Icon,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:b.repository.nameWithOwner})]}),(0,Y.jsxs)(K,{variant:`outline`,size:`sm`,className:`w-full`,onClick:()=>{let e=he();e&&e.shell.openExternal(b.repository.url)},children:[(0,Y.jsx)(Ni,{className:`size-3.5`,"aria-hidden":!0}),`Open on `,H]})]}):(0,Y.jsx)(`div`,{className:`rounded-md border border-input bg-background px-3 py-2 text-xs text-muted-foreground`,children:`Publish result unavailable.`}),t[141]=ne.Icon,t[142]=H,t[143]=b,t[144]=ft):ft=t[144];let pt;t[145]!==dt||t[146]!==ft?(pt=(0,Y.jsx)(`div`,{className:dt,children:ft}),t[145]=dt,t[146]=ft,t[147]=pt):pt=t[147];let mt;t[148]!==Ie||t[149]!==lt||t[150]!==pt?(mt=(0,Y.jsx)(Ys,{className:`space-y-5 border-b border-border/70 bg-muted/20 px-6 py-5`,children:(0,Y.jsxs)(ol,{children:[Ie,lt,pt]})}),t[148]=Ie,t[149]=lt,t[150]=pt,t[151]=mt):mt=t[151];let ht;t[152]!==fe||t[153]!==xe||t[154]!==I||t[155]!==O.isPending||t[156]!==p||t[157]!==R.ready||t[158]!==_e?(ht=(0,Y.jsx)(Js,{children:p===2?(0,Y.jsx)(K,{size:`sm`,onClick:()=>xe(!1),children:`Done`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{variant:`outline`,size:`sm`,disabled:O.isPending,onClick:()=>{if(p===0){xe(!1);return}m(xI)},children:p===0?`Cancel`:`Back`}),p<1?(0,Y.jsx)(K,{size:`sm`,disabled:!I||!R.ready,onClick:()=>m(bI),children:`Next`}):(0,Y.jsx)(K,{size:`sm`,disabled:!fe,onClick:_e,children:O.isPending?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(lc,{className:`size-3.5`,"aria-hidden":!0}),`Publishing...`]}):`Publish`})]})}),t[152]=fe,t[153]=xe,t[154]=I,t[155]=O.isPending,t[156]=p,t[157]=R.ready,t[158]=_e,t[159]=ht):ht=t[159];let gt;t[160]!==ke||t[161]!==mt||t[162]!==ht?(gt=(0,Y.jsx)(Zs,{className:`max-w-xl overflow-hidden`,children:(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden border-foreground/10 bg-background shadow-2xl`,children:[ke,mt,ht]})}),t[160]=ke,t[161]=mt,t[162]=ht,t[163]=gt):gt=t[163];let _t;return t[164]!==xe||t[165]!==e.open||t[166]!==gt?(_t=(0,Y.jsx)(Qs,{open:Ee,onOpenChange:xe,children:gt}),t[164]=xe,t[165]=e.open,t[166]=gt,t[167]=_t):_t=t[167],_t}function bI(e){return Math.min(1,e+1)}function xI(e){return Math.max(0,e-1)}function SI(e){return!e}function CI(e){return e.openSettings}function wI(){}function TI({gitCwd:e,activeThreadRef:t,draftId:n,showLabels:r=!1,block:i=!1,detectedChangeRequest:a=null,onPostPush:o}){let s=t?.environmentId??null,c=(0,q.useMemo)(()=>t?{threadRef:t}:void 0,[t]),l=(0,q.useMemo)(()=>ue(t),[t]),u=oe(l),d=Jt(e=>n?e.getDraftSession(n):t?e.getDraftThreadByRef(t):null),p=Jt(e=>e.setDraftThreadContext),m=oe(e=>e.setThreadBranch),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(new Set),[x,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(null),O=(0,q.useRef)(null),[k,A]=(0,q.useState)(0),j,M=(0,q.useCallback)(e=>{O.current=e,A(e=>e+1)},[]),N=(0,q.useCallback)(()=>{O.current&&(O.current=null,A(e=>e+1))},[]),P=(0,q.useCallback)(()=>{let e=O.current;e&&Ai.update(e.toastId,{type:`loading`,title:e.title,description:fI(e),timeout:0,data:e.toastData})},[]),F=(0,q.useCallback)(e=>{if(t){if(u){if(u.branch===e)return;let n=u.worktreePath,r=Be(t.environmentId);r&&r.orchestration.dispatchCommand({type:`thread.meta.update`,commandId:ro(),threadId:t.threadId,branch:e,worktreePath:n}).catch(()=>void 0),m(t,e,n);return}!d||d.branch===e||p(n??t,{branch:e,worktreePath:d.worktreePath})}},[d,u,t,n,p,m]),I=(0,q.useCallback)(e=>{let t=qF(e);t&&F(t.branch)},[F]),{data:ee=null,error:L}=ie({environmentId:s,cwd:e}),R=(0,q.useMemo)(()=>vr(ee?.sourceControlProvider),[ee?.sourceControlProvider]),te=R.terminology,z=R.Icon,ne=ee?.isRepo??!0,re=ee?.hasPrimaryRemote??!1,V=(0,q.useMemo)(()=>BF(ee,a),[a,ee]),H=V?.workingTree.files??[],ae=H.filter(e=>!y.has(e.path)),U=y.size===0,se=ae.length===0,ce=(0,q.useMemo)(()=>e?[we(e)]:[],[e]),le=ku(`run-stacked-action`,s,e),de=ku(`pull`,s,e),fe=ku(`publish-repository`,s,e),pe=Du({mutationFn:()=>{if(!e||!s)throw Error(`Git init is unavailable.`);return We(s).vcs.init({cwd:e})},invalidates:ce,invalidateOn:`settled`}),me=Du({mutationFn:({actionId:t,action:n,commitMessage:r,featureBranch:i,filePaths:a,worktreeId:o,onProgress:c})=>{if(!e||!s)throw Error(`Git action is unavailable.`);return ze(s).client.git.runStackedAction({action:n,actionId:t,cwd:e,...o?{worktreeId:o}:{},...r?{commitMessage:r}:{},...i?{featureBranch:!0}:{},...a&&a.length>0?{filePaths:a}:{}},...c?[{onProgress:c}]:[])},invalidates:ce,trackingKey:le}),ge=Du({mutationFn:()=>{if(!e||!s)throw Error(`Git pull is unavailable.`);return We(s).vcs.pull({cwd:e})},invalidates:ce,trackingKey:de}),_e=Ou(le),ve=Ou(de),ye=Ou(fe),be=_e||ve||ye,xe=!u&&d?.envMode===`worktree`&&d.worktreePath===null;(0,q.useEffect)(()=>{if(be||xe)return;let e=JF({threadBranch:u?.branch??d?.branch??null,gitStatus:V});e&&F(e.branch)},[u?.branch,d?.branch,V,be,xe,F]);let Se=(0,q.useMemo)(()=>V?.isDefaultRef??!1,[V?.isDefaultRef]),Ce=(0,q.useMemo)(()=>UF(V,be,re),[V,re,be]),Te=(0,q.useMemo)(()=>WF(V,be,Se,re),[V,re,Se,be]),Ee=Te.disabled?Te.hint??`This action is currently unavailable.`:null,De=E?KF({action:E.action,branchName:E.branchName,includesCommit:E.includesCommit,terminology:te}):null;(0,q.useEffect)(()=>{if(O.current)return xr({lifecycle:br,run:()=>(P(),Promise.resolve()),resolveDelayMs:()=>1e3,runImmediately:!1}).stop},[k,P]),(0,q.useEffect)(()=>{if(e===null)return;let t=null,n=()=>{t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null,B({environmentId:s,cwd:e}).catch(()=>void 0)},oI)},r=()=>{document.visibilityState===`visible`&&n()};return window.addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,r),()=>{t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,r)}},[s,e]);let Oe=(0,q.useCallback)(async()=>{let e=he();if(!e){Ai.add({type:`error`,title:`Link opening is unavailable.`,data:c});return}let t=V?.pr?.state===`open`?V.pr.url:null;if(!t){Ai.add({type:`error`,title:`No open pull request found.`,data:c});return}e.shell.openExternal(t).catch(e=>{Ai.add(As({type:`error`,title:`Unable to open pull request link`,description:e instanceof Error?e.message:`An error occurred.`,...c===void 0?{}:{data:c}}))})},[V,c]);j=(0,q.useEffectEvent)(async({action:n,commitMessage:r,onConfirmed:i,skipDefaultBranchPrompt:a=!1,statusOverride:l,featureBranch:d=!1,progressToastId:p,filePaths:m})=>{let h=l??V,g=h?.refName??null,_=!d&&Se,v=(n===`commit`||n===`commit_push`||n===`commit_push_pr`)&&(n===`commit`||!!h?.hasWorkingTreeChanges||d);if(!a&&GF(n,_)&&g){if(n!==`push`&&n!==`create_pr`&&n!==`commit_push`&&n!==`commit_push_pr`)return;D({action:n,branchName:g,includesCommit:v,...r?{commitMessage:r}:{},...i?{onConfirmed:i}:{},...m?{filePaths:m}:{}});return}i?.();let y=HF({action:n,hasCustomCommitMessage:!!r?.trim(),hasWorkingTreeChanges:!!h?.hasWorkingTreeChanges,featureBranch:d,terminology:te,shouldPushBeforePr:n===`create_pr`&&(!h?.hasUpstream||(h?.aheadCount??0)>0)}),b=c?{...c}:void 0,x=t?f(t):null,C=io(),w=p??Ai.add({type:`loading`,title:y[0]??`Running git action...`,description:`Waiting for Git...`,timeout:0,data:b});M({toastId:w,toastData:b,actionId:C,title:y[0]??`Running git action...`,phaseStartedAtMs:null,hookStartedAtMs:null,hookName:null,lastOutputLine:null,currentPhaseLabel:y[0]??`Running git action...`}),p&&Ai.update(p,{type:`loading`,title:y[0]??`Running git action...`,description:`Waiting for Git...`,timeout:0,data:b});let T=t=>{let n=O.current;if(!n||e&&t.cwd!==e||n.actionId!==t.actionId)return;let r=Date.now();switch(t.kind){case`action_started`:n.phaseStartedAtMs=r,n.hookStartedAtMs=null,n.hookName=null,n.lastOutputLine=null;break;case`phase_started`:n.title=t.label,n.currentPhaseLabel=t.label,n.phaseStartedAtMs=r,n.hookStartedAtMs=null,n.hookName=null,n.lastOutputLine=null;break;case`hook_started`:n.title=`Running ${t.hookName}...`,n.hookName=t.hookName,n.hookStartedAtMs=r,n.lastOutputLine=null;break;case`hook_output`:n.lastOutputLine=t.text;break;case`hook_finished`:n.title=n.currentPhaseLabel??`Committing...`,n.hookName=null,n.hookStartedAtMs=null,n.lastOutputLine=null;break;case`action_finished`:return;case`action_failed`:return}P()},E=me.mutateAsync({actionId:C,action:n,worktreeId:u?.worktreeId?S.make(u.worktreeId):null,...r?{commitMessage:r}:{},...d?{featureBranch:d}:{},...m?{filePaths:m}:{},onProgress:T});try{let t=await E;N(),I(t),t.push.status===`pushed`&&s&&e&&o?.({environmentId:s,threadKey:x,cwd:e,action:t.action,commitSha:t.commit.commitSha??null,pullRequestNumber:t.pr.number??null});let n=()=>{Ai.close(w)},r=t.toast.cta,i=null;r.kind===`run_action`?i={children:r.label,onClick:()=>{n(),j({action:r.action.kind})}}:r.kind===`open_pr`&&(i={children:r.label,onClick:()=>{let e=he();e&&(n(),e.shell.openExternal(r.url))}});let a={...b,dismissAfterVisibleMs:1e4};i?Ai.update(w,As({type:`success`,title:t.toast.title,description:t.toast.description,timeout:0,actionProps:i,actionVariant:`outline`,data:a})):Ai.update(w,{type:`success`,title:t.toast.title,description:t.toast.description,timeout:0,data:a})}catch(e){N(),Ai.update(w,As({type:`error`,title:`Action failed`,description:e instanceof Error?e.message:`An error occurred.`,...b===void 0?{}:{data:b}}))}});let ke=()=>{if(!E)return;let{action:e,commitMessage:t,onConfirmed:n,filePaths:r}=E;D(null),j({action:e,...t?{commitMessage:t}:{},...n?{onConfirmed:n}:{},...r?{filePaths:r}:{},skipDefaultBranchPrompt:!0})},Ae=()=>{if(!E)return;let{action:e,commitMessage:t,onConfirmed:n,filePaths:r}=E;D(null),j({action:e,...t?{commitMessage:t}:{},...n?{onConfirmed:n}:{},...r?{filePaths:r}:{},featureBranch:!0,skipDefaultBranchPrompt:!0})},je=()=>{if(!h)return;let e=_.trim();g(!1),v(``),b(new Set),C(!1),j({action:`commit`,...e?{commitMessage:e}:{},...U?{}:{filePaths:ae.map(e=>e.path)},featureBranch:!0,skipDefaultBranchPrompt:!0})},Me=()=>{let e=ge.mutateAsync();Ai.promise(e,{loading:{title:`Pulling...`,data:c},success:e=>({title:e.status===`pulled`?`Pulled`:`Already up to date`,description:e.status===`pulled`?`Updated ${e.refName} from ${e.upstreamRef??`upstream`}`:`${e.refName} is already synchronized.`,data:c}),error:e=>({title:`Pull failed`,description:e instanceof Error?e.message:`An error occurred.`,data:c})}),e.catch(()=>void 0)},Ne=()=>{if(Te.kind===`open_pr`){Oe();return}if(Te.kind===`open_publish`){T(!0);return}if(Te.kind===`run_pull`){Me();return}if(Te.kind===`show_hint`){Ai.add({type:`info`,title:Te.label,description:Te.hint,data:c});return}Te.action&&j({action:Te.action})},Pe=e=>{if(!e.disabled){if(e.kind===`open_pr`){Oe();return}if(e.dialogAction===`push`){j({action:`push`});return}if(e.dialogAction===`create_pr`){j({action:`create_pr`});return}b(new Set),C(!1),g(!0)}},Fe=()=>{if(!h)return;let e=_.trim();g(!1),v(``),b(new Set),C(!1),j({action:`commit`,...e?{commitMessage:e}:{},...U?{}:{filePaths:ae.map(e=>e.path)}})},Ie=(0,q.useCallback)(t=>{let n=he();if(!n||!e){Ai.add({type:`error`,title:`Editor opening is unavailable.`,data:c});return}let r=Ha(t,e);kc(n,r).catch(e=>{Ai.add(As({type:`error`,title:`Unable to open file`,description:e instanceof Error?e.message:`An error occurred.`,...c===void 0?{}:{data:c}}))})},[e,c]),Le=ne&&V!==null&&!re,Re=r?`truncate text-[11px] font-medium`:`sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:truncate @3xl/header-actions:text-[11px] @3xl/header-actions:font-medium`,Ve=G(`h-7 gap-1.5 border-border/50 bg-background/35 px-2 text-foreground/86 shadow-none before:shadow-none`,`dark:bg-background/20 dark:not-disabled:before:shadow-none`,`[:hover,[data-pressed]]:bg-muted/55 dark:[:hover,[data-pressed]]:bg-muted/35`,r?`min-w-0 max-w-45`:`max-w-7 @3xl/header-actions:max-w-45`),He=`flex size-4 shrink-0 items-center justify-center rounded-sm bg-muted/55 text-muted-foreground/75`,Ue=r?`block bg-border/50 dark:before:bg-border/45`:`hidden bg-border/50 dark:before:bg-border/45 @3xl/header-actions:block`,Ge=H.length,Ke=V?.refName??`branch`,qe=V?.behindCount??0,Je=V?.hasWorkingTreeChanges??!1,Ye=V?.pr?.state===`open`,Xe=V?.hasUpstream??!1,Ze=te.shortLabel,Qe=V?.refName!=null&&(Xe||re);return e?(0,Y.jsxs)(Y.Fragment,{children:[ne?(0,Y.jsxs)(cl,{"aria-label":`Git actions`,className:G(`shrink-0`,i&&`flex w-full`),children:[i?(0,Y.jsxs)(K,{variant:`default`,size:`sm`,className:`h-8 min-w-0 flex-1 justify-center gap-1.5 rounded-e-none px-3 text-[13px]`,disabled:be||Te.disabled,title:Ee??void 0,onClick:Ne,children:[(0,Y.jsx)(vI,{quickAction:Te}),(0,Y.jsx)(`span`,{className:`truncate`,children:Te.label})]}):Ee?(0,Y.jsxs)(Dc,{children:[(0,Y.jsxs)(Ec,{openOnHover:!0,render:(0,Y.jsx)(K,{"aria-disabled":`true`,className:G(Ve,`cursor-not-allowed rounded-e-none border-e-0 opacity-64 before:rounded-e-none`),size:`xs`,variant:`outline`}),children:[(0,Y.jsx)(`span`,{className:He,children:(0,Y.jsx)(_I,{quickAction:Te,SourceControlIcon:z})}),(0,Y.jsx)(`span`,{className:Re,children:Te.label})]}),(0,Y.jsx)(Tc,{tooltipStyle:!0,side:`bottom`,align:`start`,children:Ee})]}):(0,Y.jsxs)(K,{variant:`outline`,size:`xs`,className:Ve,disabled:be||Te.disabled,onClick:Ne,children:[(0,Y.jsx)(`span`,{className:He,children:(0,Y.jsx)(_I,{quickAction:Te,SourceControlIcon:z})}),(0,Y.jsx)(`span`,{className:Re,children:Te.label})]}),(0,Y.jsx)(sl,{className:i?`hidden`:Ue}),(0,Y.jsxs)(rc,{onOpenChange:t=>{t&&B({environmentId:s,cwd:e}).catch(()=>void 0)},children:[(0,Y.jsx)(oc,{render:(0,Y.jsx)(K,{"aria-label":`Git action options`,className:i?`h-8 w-9 rounded-s-none border-s-primary-foreground/25 px-0`:`h-7 w-7 border-border/50 bg-background/35 text-muted-foreground/65 shadow-none before:shadow-none dark:bg-background/20 dark:not-disabled:before:shadow-none [:hover,[data-pressed]]:bg-muted/55 dark:[:hover,[data-pressed]]:bg-muted/35`,size:i?`sm`:`icon-xs`,variant:i?`default`:`outline`}),disabled:be,children:(0,Y.jsx)(Zr,{"aria-hidden":`true`,className:`size-4`})}),(0,Y.jsx)(ec,{align:`end`,className:i?`min-w-[248px]`:`w-full`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)($s,{children:[(0,Y.jsx)(ac,{className:`text-[10.5px] tracking-wider uppercase`,children:`Commit actions`}),(0,Y.jsxs)(sc,{disabled:be||!Je,onClick:()=>void j({action:`commit`}),children:[(0,Y.jsx)(mi,{className:`text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Commit only`}),(0,Y.jsxs)(`span`,{className:`truncate text-[11.5px] font-normal text-muted-foreground`,children:[Ge,` `,Ge===1?`file`:`files`]})]})]}),(0,Y.jsxs)(sc,{disabled:be||!Je||!Qe,onClick:()=>void j({action:`commit_push`}),children:[(0,Y.jsx)(_l,{className:`text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Commit & Push`}),(0,Y.jsxs)(`span`,{className:`truncate text-[11.5px] font-normal text-muted-foreground`,children:[`to origin/`,Ke]})]})]}),(0,Y.jsxs)(sc,{disabled:be||!Je||Ye||!Qe,onClick:()=>void j({action:`commit_push_pr`}),children:[(0,Y.jsx)(z,{className:`text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsxs)(`span`,{className:`font-medium`,children:[`Commit, Push & open `,Ze]}),(0,Y.jsxs)(`span`,{className:`truncate text-[11.5px] font-normal text-muted-foreground`,children:[`from `,Ke]})]})]})]}),(0,Y.jsx)(tc,{}),(0,Y.jsxs)(sc,{disabled:be||!Xe||qe===0,onClick:Me,children:[(0,Y.jsx)(Gr,{className:`text-muted-foreground`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Pull`}),(0,Y.jsx)(`span`,{className:`truncate text-[11.5px] font-normal text-muted-foreground`,children:Xe?qe>0?`${qe} behind upstream`:`Up to date`:`No upstream`})]})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[Ce.map(e=>{let t=pI({item:e,gitStatus:V,isBusy:be,hasPrimaryRemote:re});return e.disabled&&t?(0,Y.jsxs)(Dc,{children:[(0,Y.jsx)(Ec,{openOnHover:!0,nativeButton:!1,render:(0,Y.jsx)(`span`,{className:`block w-max cursor-not-allowed`}),children:(0,Y.jsxs)(sc,{className:`w-full`,disabled:!0,children:[(0,Y.jsx)(gI,{icon:e.icon,SourceControlIcon:z}),e.label]})}),(0,Y.jsx)(Tc,{tooltipStyle:!0,side:`left`,align:`center`,children:t})]},`${e.id}-${e.label}`):(0,Y.jsxs)(sc,{disabled:e.disabled,onClick:()=>{Pe(e)},children:[(0,Y.jsx)(gI,{icon:e.icon,SourceControlIcon:z}),e.label]},`${e.id}-${e.label}`)}),Le?(0,Y.jsxs)(sc,{disabled:be,onClick:()=>{T(!0)},children:[(0,Y.jsx)(_l,{}),`Publish repository...`]}):null,V?.refName===null&&(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-warning`,children:`Detached HEAD: create and checkout a refName to enable push and pull request actions.`}),V&&V.refName!==null&&!V.hasWorkingTreeChanges&&V.behindCount>0&&V.aheadCount===0&&(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-warning`,children:`Behind upstream. Pull/rebase first.`}),L&&(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-destructive`,children:L.message})]})})]})]}):(0,Y.jsx)(K,{variant:`outline`,size:`xs`,disabled:pe.isPending,onClick:()=>pe.mutate(),children:pe.isPending?`Initializing...`:`Initialize Git`}),(0,Y.jsx)(Qs,{open:h,onOpenChange:e=>{e||(g(!1),v(``),b(new Set),C(!1))},children:(0,Y.jsxs)(Zs,{children:[(0,Y.jsxs)(Ks,{children:[(0,Y.jsx)(qs,{children:mI}),(0,Y.jsx)(Xs,{children:hI})]}),(0,Y.jsxs)(Ys,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-input bg-muted/40 p-3 text-xs`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Branch`}),(0,Y.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:V?.refName??`(detached HEAD)`}),Se&&(0,Y.jsx)(`span`,{className:`text-right text-warning text-xs`,children:`Warning: default refName`})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[x&&H.length>0&&(0,Y.jsx)(iI,{checked:U,indeterminate:!U&&!se,onCheckedChange:()=>{b(U?new Set(H.map(e=>e.path)):new Set)}}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Files`}),!U&&!x&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,ae.length,` of `,H.length,`)`]})]}),H.length>0&&(0,Y.jsx)(K,{variant:`ghost`,size:`xs`,onClick:()=>C(e=>!e),children:x?`Done`:`Edit`})]}),!V||H.length===0?(0,Y.jsx)(`p`,{className:`font-medium`,children:`none`}):(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(bs,{className:`h-44 rounded-md border border-input bg-background`,children:(0,Y.jsx)(`div`,{className:`space-y-1 p-1`,children:H.map(e=>{let t=y.has(e.path);return(0,Y.jsxs)(`div`,{className:`flex w-full items-center gap-2 rounded-md px-2 py-1 font-mono text-xs transition-colors hover:bg-accent/50`,children:[x&&(0,Y.jsx)(iI,{checked:!y.has(e.path),onCheckedChange:()=>{b(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})}}),(0,Y.jsxs)(`button`,{type:`button`,className:`flex flex-1 items-center justify-between gap-3 text-left truncate`,onClick:()=>Ie(e.path),children:[(0,Y.jsx)(`span`,{className:`truncate${t?` text-muted-foreground`:``}`,children:e.path}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:t?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Excluded`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,e.insertions]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[`-`,e.deletions]})]})})]})]},e.path)})})}),(0,Y.jsxs)(`div`,{className:`flex justify-end font-mono`,children:[(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,ae.reduce((e,t)=>e+t.insertions,0)]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[`-`,ae.reduce((e,t)=>e+t.deletions,0)]})]})]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium`,children:`Commit message (optional)`}),(0,Y.jsx)(uc,{value:_,onChange:e=>v(e.target.value),placeholder:`Leave empty to auto-generate`,size:`sm`})]})]}),(0,Y.jsxs)(Js,{children:[(0,Y.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>{g(!1),v(``),b(new Set),C(!1)},children:`Cancel`}),(0,Y.jsx)(K,{variant:`outline`,size:`sm`,disabled:se,onClick:je,children:`Commit on new refName`}),(0,Y.jsx)(K,{size:`sm`,disabled:se,onClick:Fe,children:`Commit`})]})]})}),(0,Y.jsx)(yI,{open:w,onOpenChange:T,environmentId:s,gitCwd:e}),(0,Y.jsx)(Qs,{open:E!==null,onOpenChange:e=>{e||D(null)},children:(0,Y.jsxs)(Zs,{className:`max-w-xl`,children:[(0,Y.jsxs)(Ks,{children:[(0,Y.jsx)(qs,{children:De?.title??`Run action on default refName?`}),(0,Y.jsx)(Xs,{children:De?.description})]}),(0,Y.jsxs)(Js,{className:`sm:flex-wrap sm:items-center`,children:[(0,Y.jsx)(K,{className:`w-full sm:mr-auto sm:w-auto`,variant:`outline`,size:`sm`,onClick:()=>D(null),children:`Abort`}),(0,Y.jsx)(K,{className:`min-h-8 w-full max-w-full whitespace-normal py-1.5 leading-snug sm:min-h-7 sm:w-auto`,variant:`outline`,size:`sm`,onClick:ke,children:De?.continueLabel??`Continue`}),(0,Y.jsx)(K,{className:`min-h-8 w-full max-w-full whitespace-normal py-1.5 leading-snug sm:min-h-7 sm:w-auto`,size:`sm`,onClick:Ae,children:`Checkout feature branch & continue`})]})]})})]}):null}var EI=nr;function DI(e){return{environmentId:e.environmentId,threadKey:e.threadKey??null,cwd:e.cwd,pullRequestNumber:e.pullRequestNumber??null,commitSha:e.commitSha?.trim()||null,expiresAtMs:e.nowMs+EI}}function OI(e){let{watch:t}=e;return!t||!e.environmentId||!e.cwd||e.nowMs>=t.expiresAtMs||t.environmentId!==e.environmentId||t.cwd!==e.cwd||t.threadKey!==null&&t.threadKey!==e.threadKey||t.pullRequestNumber!==null&&e.pullRequestNumber!==null&&t.pullRequestNumber!==e.pullRequestNumber?null:t}function kI(e){if(!e.watch||!e.runs||e.runs.length===0)return!1;let t=e.watch.commitSha;return t?e.runs.some(e=>{let n=e.commit.oid;return n===t||n.startsWith(t)||t.startsWith(n)}):!1}function AI(e){return e.activeWatch&&e.nowMs<e.activeWatch.expiresAtMs&&!e.discoveredPostPushRun?ar({mode:e.mode??`automatic`,phase:`discovery`,nowMs:e.nowMs,discoveryExpiresAtMs:e.activeWatch.expiresAtMs}):ar({mode:e.mode??`automatic`,phase:e.statusRefreshable?`active`:`settled`})}function jI(e){return e===`github`}function MI(e){return e.workflowRunsSupported?e.workflowError??e.detailError:e.detailError}function NI(e){let t=ci(e.status),n=ci(e.conclusion);return t===`skipped`||n===`skipped`?`Skipped`:e.statusKind===`passed`?`Succeeded`:e.statusKind===`failed`||e.statusKind===`api-error`?`Failed`:e.statusKind===`cancelled`?`Cancelled`:e.statusKind===`running`?`Running`:e.statusKind===`pending`||e.statusKind===`loading`?`Pending`:`Unknown`}function PI(e){return e===`loading`||e===`pending`||e===`running`}function FI(e){return PI(si(e).kind)}function II(e){return hi({name:e.name,status:e.status,conclusion:Si(e.conclusion),url:Si(e.url)})}function LI(e){return hi({name:e.name,status:e.status,conclusion:Si(e.conclusion)})}function RI(e,t){return e.find(({status:e})=>t.includes(e.kind))?.step??null}function zI(e){return ci(e.status)===`skipped`||ci(Si(e.conclusion))===`skipped`}function BI(e){let t=e.steps.map(e=>({step:e,status:LI(e)}));return RI(t,[`failed`,`api-error`])??RI(t,[`running`])??RI(t,[`pending`,`loading`])??RI(t,[`cancelled`])??t.find(({step:e})=>zI(e))?.step??null}function VI(e){let t=(e??[]).map(e=>({job:e,status:II(e)})),n=t.find(({status:e})=>e.kind===`running`)??t.find(({status:e})=>e.kind===`pending`||e.kind===`loading`)??null;if(!n)return;let r=BI(n.job);return r?`${n.job.name} / ${r.name}`:n.job.name}function HI(e){let t=si(e),n={id:`run:${e.runId}`,name:e.workflowName,statusLabel:NI({status:e.status,conclusion:Si(e.conclusion),statusKind:t.kind}),tone:t.tone,statusKind:t.kind,url:e.url};return e.displayTitle&&e.displayTitle!==e.workflowName&&(n.detail=e.displayTitle),n}function UI(e){let t=II(e.job),n=BI(e.job),r=Si(e.job.url),i=[e.run.workflowName===e.job.name?null:e.run.workflowName,n?.name??null].filter(e=>!!e),a={id:`run:${e.run.runId}:job:${e.job.jobId}`,name:e.job.name,statusLabel:NI({status:e.job.status,conclusion:Si(e.job.conclusion),statusKind:t.kind}),tone:t.tone,statusKind:t.kind,url:r??e.run.url};return i.length>0&&(a.detail=i.join(` / `)),a}function WI(e,t){let n=hi({name:e.name,workflowName:e.workflowName,status:Si(e.status),conclusion:Si(e.conclusion),url:Si(e.url)}),r=Si(e.url),i={id:`rollup:${t}:${e.kind}:${e.name}`,name:e.name,statusLabel:NI({status:Si(e.status),conclusion:Si(e.conclusion),statusKind:n.kind}),tone:n.tone,statusKind:n.kind};return e.workflowName&&e.workflowName!==e.name&&(i.detail=e.workflowName),r&&(i.url=r),i}function GI(e){let t=[],n=e.limit??40;for(let r of e.runs){let i=e.jobsByRunId.get(r.runId);if(i&&i.length>0){for(let e of i)if(t.push(UI({run:r,job:e})),t.length>=n)return t}else if(t.push(HI(r)),t.length>=n)return t}return t}function KI(e){let t=e.limit??40;return(e.rollup??[]).slice(0,t).map(WI)}function qI(e){let t=new Set,n=e?.trim()??``;if(n.length===0)return t;t.add(n);let r=n.indexOf(`/`);if(r>0&&r<n.length-1){let e=n.slice(0,r);(e===`origin`||e===`upstream`)&&t.add(n.slice(r+1))}return t}function JI(e,t){let n=qI(t);return n.size===0?null:e?.find(e=>n.has(e.headRefName))??null}function YI(e){return e.activeWorktreePrNumber??e.gitStatusPrNumber??e.overviewBranchPullRequestNumber??e.postPushWatchPullRequestNumber??null}function XI(e){if(!e.workflowRunsSupported||e.pullRequestNumber===null&&(e.branchName??null)===null)return[];let t=(e.runs??[]).slice(0,8).map(e=>e.runId);return e.activeWorkflowRunId&&!t.includes(e.activeWorkflowRunId)?[e.activeWorkflowRunId,...t].slice(0,8):t}function ZI(e){let t=[];if(e.gitStatusData||e.changedFiles.length>0){let{committed:n,local:r}=FF(e.changedFiles),i=IF({committed:n,local:r,pullRequestNumber:e.overviewPullRequestNumber});t.push({...i,action:`review`,icon:`changes`})}return t.push({label:`Environment`,value:e.activeEnvironmentUnavailableState?.label??`Local`,...e.activeEnvironmentUnavailableState?{detail:e.activeEnvironmentUnavailableState.connectionState}:{},icon:`environment`}),t}var QI=`calc(340px + 0.75rem)`;function $I(e){let t=(0,J.c)(17),[n,r]=(0,q.useState)(!e.animate&&e.open),i,a;t[0]!==e.animate||t[1]!==e.open?(i=()=>{if(!e.animate){r(e.open);return}if(!e.open){r(!1);return}let t=window.requestAnimationFrame(()=>r(!0));return()=>window.cancelAnimationFrame(t)},a=[e.animate,e.open],t[0]=e.animate,t[1]=e.open,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,q.useEffect)(i,a);let o=e.animate?e.open&&n:e.open,s=!e.open||void 0,c=!e.open||void 0,l=o?`w-(--overview-sidebar-frame-width) opacity-100`:`w-0 opacity-0`,u;t[4]===l?u=t[5]:(u=G(`h-full min-h-0 shrink-0 overflow-hidden pt-[var(--chat-header-clearance,0px)] transition-[width,opacity] duration-[320ms] ease-[cubic-bezier(0.16,1,0.3,1)] motion-reduce:transition-none`,l),t[4]=l,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={"--overview-sidebar-frame-width":QI},t[6]=d):d=t[6];let f=o?`translate-x-0 opacity-100`:`translate-x-5 opacity-0`,p;t[7]===f?p=t[8]:(p=G(`h-full min-h-0 w-(--overview-sidebar-frame-width) transition-[translate,opacity] duration-[320ms] ease-[cubic-bezier(0.16,1,0.3,1)] will-change-transform motion-reduce:transition-none`,f),t[7]=f,t[8]=p);let m;t[9]!==e.children||t[10]!==p?(m=(0,Y.jsx)(`div`,{className:p,children:e.children}),t[9]=e.children,t[10]=p,t[11]=m):m=t[11];let h;return t[12]!==s||t[13]!==c||t[14]!==u||t[15]!==m?(h=(0,Y.jsx)(`div`,{"aria-hidden":s,inert:c,className:u,style:d,children:m}),t[12]=s,t[13]=c,t[14]=u,t[15]=m,t[16]=h):h=t[16],h}function eL(e){let t=(0,J.c)(11),[n,r]=(0,q.useState)(!e.animate&&e.open),i,a;t[0]!==e.animate||t[1]!==e.open?(i=()=>{if(!e.animate){r(e.open);return}if(!e.open){r(!1);return}let t=window.requestAnimationFrame(()=>r(!0));return()=>window.cancelAnimationFrame(t)},a=[e.animate,e.open],t[0]=e.animate,t[1]=e.open,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,q.useEffect)(i,a);let o=e.animate?e.open&&n:e.open,s=!e.open||void 0,c=!e.open||void 0,l=o?`translate-x-0 opacity-100`:`translate-x-3 opacity-0`,u;t[4]===l?u=t[5]:(u=G(`origin-top-right transition-[translate,opacity] duration-[260ms] ease-[cubic-bezier(0.16,1,0.3,1)] will-change-transform motion-reduce:transition-none`,l),t[4]=l,t[5]=u);let d;return t[6]!==e.children||t[7]!==s||t[8]!==c||t[9]!==u?(d=(0,Y.jsx)(`div`,{className:`pointer-events-none absolute top-[calc(var(--chat-header-clearance,0px)+0.75rem)] right-3 z-40`,children:(0,Y.jsx)(`div`,{"aria-hidden":s,inert:c,className:u,children:e.children})}),t[6]=e.children,t[7]=s,t[8]=c,t[9]=u,t[10]=d):d=t[10],d}function tL(){let e=(0,J.c)(7),[t,n]=(0,q.useState)(null),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=e=>{n(DI({environmentId:e.environmentId,threadKey:e.threadKey,cwd:e.cwd,pullRequestNumber:e.pullRequestNumber,commitSha:e.commitSha,nowMs:Date.now()})),cr({environmentId:e.environmentId,cwd:e.cwd})},e[0]=r):r=e[0];let i=r,a,o;e[1]===t?(a=e[2],o=e[3]):(a=()=>{if(!t)return;let e=window.setTimeout(()=>n(e=>e===t?null:e),Math.max(0,t.expiresAtMs-Date.now()));return()=>window.clearTimeout(e)},o=[t],e[1]=t,e[2]=a,e[3]=o),(0,q.useEffect)(a,o);let s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{n(null)},e[4]=s):s=e[4];let c=s,l;return e[5]===t?l=e[6]:(l={postPushWorkflowWatch:t,handlePostPush:i,clearWatch:c},e[5]=t,e[6]=l),l}function nL(e){let t=(0,J.c)(21),{gitCwd:n,activeThreadRef:r,routeKind:i,draftId:a,onPostPush:o,branchControlThread:s,isGitRepo:c,canOverrideServerThreadBranch:l,activeThreadBranch:u,onActiveThreadBranchOverrideChange:d,envLocked:f,onComposerFocusRequest:p,canCheckoutPullRequestIntoThread:m,onCheckoutPullRequestRequest:h}=e,g;t[0]!==r||t[1]!==a||t[2]!==n||t[3]!==o||t[4]!==i?(g=e=>n&&r?(0,Y.jsx)(TI,{gitCwd:n,activeThreadRef:r,detectedChangeRequest:e,...i===`draft`&&a?{draftId:a}:{},onPostPush:o,showLabels:!0,block:!0}):null,t[0]=r,t[1]=a,t[2]=n,t[3]=o,t[4]=i,t[5]=g):g=t[5];let _=g,v;t[6]!==u||t[7]!==s||t[8]!==m||t[9]!==l||t[10]!==a||t[11]!==f||t[12]!==c||t[13]!==d||t[14]!==h||t[15]!==p||t[16]!==i?(v=s&&c?(0,Y.jsx)(Hu,{appearance:`panelRow`,className:`w-full`,environmentId:s.environmentId,threadId:s.id,...i===`draft`&&a?{draftId:a}:{},...l?{activeThreadBranchOverride:u,onActiveThreadBranchOverrideChange:d}:{},envLocked:f,onComposerFocusRequest:p,...m?{onCheckoutPullRequestRequest:h}:{}}):null,t[6]=u,t[7]=s,t[8]=m,t[9]=l,t[10]=a,t[11]=f,t[12]=c,t[13]=d,t[14]=h,t[15]=p,t[16]=i,t[17]=v):v=t[17];let y=v,b;return t[18]!==y||t[19]!==_?(b={sourceControlActions:_,branchControl:y},t[18]=y,t[19]=_,t[20]=b):b=t[20],b}function rL(e){let t=(0,J.c)(143),{environmentId:n,gitCwd:r,activeWorktreeBranch:i,activeThreadBranch:a,activeWorktreePrNumber:o,activeWorktreePrState:s,activeWorktreePrIsDraft:c,activeWorktreeTitle:l,postPushWorkflowWatch:u,activeThreadKey:d,activeEnvironmentUnavailableState:f,activePlan:p,sidebarProposedPlan:m,threadSubagents:h,changedFileSummaries:g,sourceControlActions:_,branchControl:v,markdownCwd:y,workspaceRoot:b,mode:x,onClose:S,onOpenFiles:C,onOpenReview:w,onOpenSubagent:T,onPostPushDiscoveryComplete:E}=e,D=pe(lL),O;t[0]!==n||t[1]!==r?(O={environmentId:n,cwd:r},t[0]=n,t[1]=r,t[2]=O):O=t[2];let k=ie(O),A=i??a??k.data?.refName??null,j=A!==null&&o==null&&k.data?.pr==null,M;t[3]!==n||t[4]!==r||t[5]!==j?(M={environmentId:n,cwd:r,enabled:j},t[3]=n,t[4]=r,t[5]=j,t[6]=M):M=t[6];let N=TP(M),P;t[7]!==A||t[8]!==N.data?(P=JI(N.data,A),t[7]=A,t[8]=N.data,t[9]=P):P=t[9];let F=P,I,ee;if(t[10]!==d||t[11]!==o||t[12]!==n||t[13]!==r||t[14]!==k.data?.pr?.number||t[15]!==F?.number||t[16]!==u){let e=OI({watch:u,environmentId:n,threadKey:d,cwd:r,pullRequestNumber:null,nowMs:Date.now()});I=YI({activeWorktreePrNumber:o,gitStatusPrNumber:k.data?.pr?.number??null,overviewBranchPullRequestNumber:F?.number??null,postPushWatchPullRequestNumber:e?.pullRequestNumber??null}),ee=OI({watch:e,environmentId:n,threadKey:d,cwd:r,pullRequestNumber:I,nowMs:Date.now()}),t[10]=d,t[11]=o,t[12]=n,t[13]=r,t[14]=k.data?.pr?.number,t[15]=F?.number,t[16]=u,t[17]=I,t[18]=ee}else I=t[17],ee=t[18];let L=ee,R=I===null?null:String(I),te=k.data?.sourceControlProvider?.kind??null,z=I!==null,ne;t[19]!==n||t[20]!==r||t[21]!==R||t[22]!==z?(ne={environmentId:n,cwd:r,reference:R,enabled:z},t[19]=n,t[20]=r,t[21]=R,t[22]=z,t[23]=ne):ne=t[23];let B=EP(ne),re=B.data?.provider??F?.provider??te,V;t[24]===re?V=t[25]:(V=jI(re),t[24]=re,t[25]=V);let H=V,ae=H&&I===null&&k.data?.isDefaultRef===!0&&k.data?.hasPrimaryRemote===!0,U=ae?k.data?.refName??null:null,oe=H&&(I!==null||U!==null),se;t[26]!==L||t[27]!==D?(se=e=>{let t=e?li({runs:e.runs,headSha:Si(e.headSha)}):null;return AI({mode:D,activeWatch:L,nowMs:Date.now(),discoveredPostPushRun:kI({watch:L,runs:e?.runs}),statusRefreshable:t?pi(t):!1})},t[26]=L,t[27]=D,t[28]=se):se=t[28];let ce=se,le=L?.commitSha??null,ue;t[29]!==n||t[30]!==r||t[31]!==U||t[32]!==I||t[33]!==oe||t[34]!==ce||t[35]!==le?(ue={environmentId:n,cwd:r,pullRequestNumber:I,branch:U,commitSha:le,enabled:oe,resolveIntervalMs:ce},t[29]=n,t[30]=r,t[31]=U,t[32]=I,t[33]=oe,t[34]=ce,t[35]=le,t[36]=ue):ue=t[36];let de=OP(ue),fe;t[37]!==L||t[38]!==E||t[39]!==de.data?.runs?(fe=()=>{L&&kI({watch:L,runs:de.data?.runs})&&E()},t[37]=L,t[38]=E,t[39]=de.data?.runs,t[40]=fe):fe=t[40];let me=de.data?.runs,he;t[41]!==L||t[42]!==E||t[43]!==me?(he=[L,me,E],t[41]=L,t[42]=E,t[43]=me,t[44]=he):he=t[44],(0,q.useEffect)(fe,he);let ge;t[45]===de.data?.runs?ge=t[46]:(ge=de.data?.runs??[],t[45]=de.data?.runs,t[46]=ge);let _e=ge,ve;t[47]===_e?ve=t[48]:(ve=_e.find(FI)?.runId??null,t[47]=_e,t[48]=ve);let ye=ve,be;t[49]!==ye||t[50]!==U||t[51]!==I||t[52]!==de.data?.runs||t[53]!==H?(be=()=>XI({workflowRunsSupported:H,pullRequestNumber:I,branchName:U,runs:de.data?.runs,activeWorkflowRunId:ye}),t[49]=ye,t[50]=U,t[51]=I,t[52]=de.data?.runs,t[53]=H,t[54]=be):be=t[54],de.data?.runs;let xe;t[55]===be?xe=t[56]:(xe=be(),t[55]=be,t[56]=xe);let Se=xe,Ce=H&&(I!==null||U!==null),we;t[57]!==n||t[58]!==r||t[59]!==ye||t[60]!==Se||t[61]!==Ce?(we={environmentId:n,cwd:r,runIds:Se,activeRunId:ye,enabled:Ce},t[57]=n,t[58]=r,t[59]=ye,t[60]=Se,t[61]=Ce,t[62]=we):we=t[62];let{jobsByRunId:Te,isLoading:Ee}=kP(we),De;t[63]!==B.error||t[64]!==de.error||t[65]!==H?(De=zF(MI({workflowRunsSupported:H,workflowError:de.error,detailError:B.error})),t[63]=B.error,t[64]=de.error,t[65]=H,t[66]=De):De=t[66];let Oe=De,ke;t[67]!==c||t[68]!==s||t[69]!==l||t[70]!==Oe||t[71]!==k.data?.pr||t[72]!==ye||t[73]!==F||t[74]!==ae||t[75]!==B.data||t[76]!==B.error||t[77]!==B.isLoading||t[78]!==I||t[79]!==Te||t[80]!==Ee||t[81]!==de.data||t[82]!==de.error||t[83]!==de.isLoading||t[84]!==H?(ke=()=>{let e=I!==null;if(!e&&!ae)return null;let t=e?k.data?.pr??null:null,n=e?F:null,r=e?B.data??null:null,i=H?de.data??null:null,a=MI({workflowRunsSupported:H,workflowError:de.error,detailError:B.error}),o=ye===null?void 0:VI(Te.get(ye)),u=i&&H?Di({isLoading:de.isLoading,error:de.error,status:li({runs:i.runs,headSha:Si(i.headSha)})}):r?gi(r):n?gi(n):Di({isLoading:H&&de.isLoading||B.isLoading,error:a,status:null}),d=i?GI({runs:i.runs,jobsByRunId:Te}):[],f=KI({rollup:r?.checkRollup??n?.checkRollup}),p=Array.from(Te.values()).some(cL)?d:f.length>0?f:d;if(o)for(let e of p)PI(e.statusKind)&&ye!==null&&e.id.startsWith(`run:${ye}`)&&(e.activeDetail=o);let m=p.filter(sL),h=Oe,g=H&&de.isLoading||e&&B.isLoading||Ee,_=m.length>0?m.length:u&&PI(u.kind)?1:0;if(I===null)return!g&&p.length===0&&!h?null:{checkStatus:u,checksLoading:g,...h?{checksError:h}:{},hasMergeConflicts:!1,activeCheckCount:_,runs:m,latestRuns:p};let v=r?.url??t?.url??n?.url??null,y=r?.state??s??t?.state??n?.state??null,b=r?.isDraft??c??n?.isDraft,x=r?.participants?r.participants.filter(oL).length:void 0,S=r?.reviewers?r.reviewers.length:void 0;return{number:I,title:r?.title??t?.title??n?.title??l??`Pull request #${I}`,...v?{url:v}:{},...y?{state:y}:{},...typeof b==`boolean`?{isDraft:b}:{},...typeof r?.commentsCount==`number`?{commentsCount:r.commentsCount}:r?{commentsCount:r.comments.length}:typeof n?.commentsCount==`number`?{commentsCount:n.commentsCount}:{},...typeof x==`number`?{reviewsApproved:x}:{},...typeof S==`number`?{reviewsRequested:S}:{},checkStatus:u,checksLoading:g,...h?{checksError:h}:{},...r?.mergeability?{mergeability:r.mergeability}:{},hasMergeConflicts:r?.mergeability===`conflicting`,activeCheckCount:_,runs:m,latestRuns:p}},t[67]=c,t[68]=s,t[69]=l,t[70]=Oe,t[71]=k.data?.pr,t[72]=ye,t[73]=F,t[74]=ae,t[75]=B.data,t[76]=B.error,t[77]=B.isLoading,t[78]=I,t[79]=Te,t[80]=Ee,t[81]=de.data,t[82]=de.error,t[83]=de.isLoading,t[84]=H,t[85]=ke):ke=t[85],k.data?.pr;let Ae;t[86]===ke?Ae=t[87]:(Ae=ke(),t[86]=ke,t[87]=Ae);let je=Ae,Me=(0,q.useRef)(null),Ne,Pe;t[88]!==Oe||t[89]!==I?(Ne=()=>{if(!Oe){Me.current=null;return}let e=`${I??`?`}|${Oe.kind}|${Oe.message}`;if(Me.current===e)return;Me.current=e,Oe.raw&&console.debug(`[overview] source control fetch failed:`,Oe.raw);let t=I===null;Ai.add(As({type:Oe.kind===`terminal`?`error`:`warning`,title:Oe.kind===`terminal`?t?`Checks unavailable`:`Pull request unavailable`:t?`Couldn't refresh checks`:`Couldn't refresh pull request`,description:Oe.message}))},Pe=[Oe,I],t[88]=Oe,t[89]=I,t[90]=Ne,t[91]=Pe):(Ne=t[90],Pe=t[91]),(0,q.useEffect)(Ne,Pe);let Fe;t[92]===g?Fe=t[93]:(Fe=g??[],t[92]=g,t[93]=Fe);let Ie;t[94]===k.data?.workingTree.files?Ie=t[95]:(Ie=k.data?.workingTree.files??[],t[94]=k.data?.workingTree.files,t[95]=Ie);let Le;t[96]===k.data?.committed?.files?Le=t[97]:(Le=k.data?.committed?.files??[],t[96]=k.data?.committed?.files,t[97]=Le);let Re;t[98]!==Fe||t[99]!==Ie||t[100]!==Le?(Re=MF(Fe,Ie,Le),t[98]=Fe,t[99]=Ie,t[100]=Le,t[101]=Re):Re=t[101];let ze=Re,Be;t[102]!==f||t[103]!==ze||t[104]!==k.data||t[105]!==I?(Be=ZI({gitStatusData:k.data,changedFiles:ze,overviewPullRequestNumber:I,activeEnvironmentUnavailableState:f}),t[102]=f,t[103]=ze,t[104]=k.data,t[105]=I,t[106]=Be):Be=t[106];let Ve=Be,He;bb0:{let e=k.data;if(!e&&ze.length===0){He=void 0;break bb0}let n;t[107]===ze?n=t[108]:(n=ze.reduce(aL,0),t[107]=ze,t[108]=n);let r=n,i;t[109]===ze?i=t[110]:(i=ze.reduce(iL,0),t[109]=ze,t[110]=i);let a=i,o=e?.refName??null,s=e?.aheadCount??0,c=e?.behindCount??0,l;t[111]!==ze||t[112]!==a||t[113]!==r||t[114]!==o||t[115]!==s||t[116]!==c?(l={files:ze,insertions:r,deletions:a,refName:o,aheadCount:s,behindCount:c},t[111]=ze,t[112]=a,t[113]=r,t[114]=o,t[115]=s,t[116]=c,t[117]=l):l=t[117],He=l}let Ue=He,We;t[118]!==n||t[119]!==r?(We=()=>{cr({environmentId:n,cwd:r})},t[118]=n,t[119]=r,t[120]=We):We=t[120];let Ge=We,Ke=B.isFetching||H&&de.isFetching,qe=B.data??F??null,Je;t[121]!==qe||t[122]!==_?(Je=_(qe),t[121]=qe,t[122]=_,t[123]=Je):Je=t[123];let Ye;return t[124]!==p||t[125]!==v||t[126]!==n||t[127]!==Ge||t[128]!==Ke||t[129]!==y||t[130]!==x||t[131]!==S||t[132]!==C||t[133]!==w||t[134]!==T||t[135]!==Ue||t[136]!==Ve||t[137]!==je||t[138]!==m||t[139]!==Je||t[140]!==h||t[141]!==b?(Ye=(0,Y.jsx)(kF,{activePlan:p,activeProposedPlan:m,changes:Ue,overviewItems:Ve,pullRequest:je,onRefreshPullRequest:Ge,isRefreshingPullRequest:Ke,subagents:h,sourceControlActions:Je,branchControl:v,environmentId:n,markdownCwd:y,workspaceRoot:b,mode:x,onClose:S,onOpenFiles:C,onOpenReview:w,onOpenSubagent:T}),t[124]=p,t[125]=v,t[126]=n,t[127]=Ge,t[128]=Ke,t[129]=y,t[130]=x,t[131]=S,t[132]=C,t[133]=w,t[134]=T,t[135]=Ue,t[136]=Ve,t[137]=je,t[138]=m,t[139]=Je,t[140]=h,t[141]=b,t[142]=Ye):Ye=t[142],Ye}function iL(e,t){return e+t.deletions}function aL(e,t){return e+t.insertions}function oL(e){return e.approved===!0}function sL(e){return PI(e.statusKind)}function cL(e){return e.length>0}function lL(e){return e.sourceControlRefreshMode}function uL(e){let t=(0,J.c)(19),{activeThreadId:n,keybindings:r,terminalOpen:i,activeTerminalId:a,readComposer:o,activeProject:s,toggleTerminalVisibility:c,splitTerminal:l,closeTerminal:u,createNewTerminal:d,setTerminalOpen:f,onToggleDiff:p,onOpenFilesPanel:m,onOpenReviewPanel:h,onOpenTerminalPanel:g,onOpenSimulatorPanel:_,runProjectScript:v}=e,y,b;t[0]!==s||t[1]!==a||t[2]!==n||t[3]!==u||t[4]!==d||t[5]!==r||t[6]!==m||t[7]!==h||t[8]!==_||t[9]!==g||t[10]!==p||t[11]!==o||t[12]!==v||t[13]!==f||t[14]!==l||t[15]!==i||t[16]!==c?(y=()=>{let e=e=>{if(!n||Ue.getState().open||e.defaultPrevented)return;let t=o()?.isModelPickerOpen()??!1,y={terminalFocus:Ns(),terminalOpen:!!i,modelPickerOpen:t},b=To(e,r,{context:y});if(Mo(e)&&(b!==`modelPicker.toggle`||!t)||!b)return;if(b===`terminal.toggle`){e.preventDefault(),e.stopPropagation(),c();return}if(b===`terminal.split`){e.preventDefault(),e.stopPropagation(),i||f(!0),l();return}if(b===`terminal.close`){if(e.preventDefault(),e.stopPropagation(),!i)return;u(a);return}if(b===`terminal.new`){e.preventDefault(),e.stopPropagation(),i||f(!0),d();return}if(b===`diff.toggle`){e.preventDefault(),e.stopPropagation(),p();return}if(b===`workspace.files`){e.preventDefault(),e.stopPropagation(),m();return}if(b===`workspace.review`){e.preventDefault(),e.stopPropagation(),h();return}if(b===`workspace.terminal`){e.preventDefault(),e.stopPropagation(),g();return}if(b===`workspace.simulator`){e.preventDefault(),e.stopPropagation(),_();return}if(b===`modelPicker.toggle`){e.preventDefault(),e.stopPropagation(),o()?.toggleModelPicker();return}let x=hN(b);if(!x||!s)return;let S=s.scripts.find(e=>e.id===x);S&&(e.preventDefault(),e.stopPropagation(),v(S))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},b=[s,i,a,n,u,d,f,v,l,r,p,m,h,g,_,o,c],t[0]=s,t[1]=a,t[2]=n,t[3]=u,t[4]=d,t[5]=r,t[6]=m,t[7]=h,t[8]=_,t[9]=g,t[10]=p,t[11]=o,t[12]=v,t[13]=f,t[14]=l,t[15]=i,t[16]=c,t[17]=y,t[18]=b):(y=t[17],b=t[18]),(0,q.useEffect)(y,b)}var dL={};function fL(e){let{pendingUserInputs:t,respondingUserInputRequestIds:n,readComposer:r,promptRef:i}=e,a=e.onRespondToUserInput,[o,s]=(0,q.useState)({}),[c,l]=(0,q.useState)({}),u=t[0]??null,d=(0,q.useMemo)(()=>u?o[u.requestId]??dL:dL,[u,o]),f=u?c[u.requestId]??0:0,p=(0,q.useMemo)(()=>u?ep(u.questions,d,f):null,[d,f,u]),m=(0,q.useMemo)(()=>u?Qf(u.questions,d):null,[d,u]),h=u?n.includes(u.requestId):!1,g=(0,q.useCallback)(e=>{u&&l(t=>({...t,[u.requestId]:e}))},[u]);return{activePendingUserInput:u,activePendingDraftAnswers:d,activePendingQuestionIndex:f,activePendingProgress:p,activePendingResolvedAnswers:m,activePendingIsResponding:h,onSelectActivePendingUserInputOption:(0,q.useCallback)((e,t)=>{u&&(s(n=>{let r=(p?.activeQuestion?.id===e?p.activeQuestion:void 0)??u.questions.find(t=>t.id===e);return r?{...n,[u.requestId]:{...n[u.requestId],[e]:Zf(r,n[u.requestId]?.[e],t)}}:n}),i.current=``,r()?.resetCursorState({cursor:0}))},[p?.activeQuestion,u,i,r]),onChangeActivePendingUserInputCustomAnswer:(0,q.useCallback)((e,t,n,a,o)=>{if(!u)return;i.current=t,s(n=>({...n,[u.requestId]:{...n[u.requestId],[e]:Xf(n[u.requestId]?.[e],t)}}));let c=r()?.readSnapshot();(c?.value!==t||c.cursor!==n||c.expandedCursor!==a)&&r()?.focusAt(n)},[u,i,r]),onAdvanceActivePendingUserInput:(0,q.useCallback)(()=>{if(!(!u||!p)){if(p.isLastQuestion){m&&a(u.requestId,m);return}g(p.questionIndex+1)}},[p,m,u,a,g]),onPreviousActivePendingUserInputQuestion:(0,q.useCallback)(()=>{p&&g(Math.max(p.questionIndex-1,0))},[p,g])}}function pL(e){let t=(0,J.c)(3),n=(0,q.useRef)(e),r;t[0]===e?r=t[1]:(r=()=>{n.current=e},t[0]=e,t[1]=r),(0,q.useLayoutEffect)(r);let i;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(...e)=>{let t=e;return n.current(...t)},t[2]=i):i=t[2],i}var mL=e=>({...Hn(e),diff:void 0,diffTurnId:void 0,diffFilePath:void 0,preview:void 0,workspaceOpen:void 0,workspaceTab:void 0,workspaceAgentKey:void 0});function hL(e){let t=(0,J.c)(85),{navigate:n,environmentId:r,threadId:i,routeKind:a,draftId:o,isServerThread:s,hasActiveProject:c,diffOpen:l,workspacePanelOpen:u,externalToggleWorkspacePanel:d,onDiffPanelOpen:f,onPreviewPanelOpen:p,onTerminalPanelOpen:m,onSimulatorPanelOpen:h,onAgentPanelOpen:g}=e,_=Rs()===`phone`,v;t[0]!==r||t[1]!==s||t[2]!==n||t[3]!==f||t[4]!==i?(v=()=>{s&&(f?.(),n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},replace:!0,search:xL}))},t[0]=r,t[1]=s,t[2]=n,t[3]=f,t[4]=i,t[5]=v):v=t[5];let y=pL(v),b;t[6]!==l||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==y||t[11]!==i?(b=()=>{if(s){if(!l){y();return}n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},replace:!0,search:e=>l?mL(e):Xn(e)})}},t[6]=l,t[7]=r,t[8]=s,t[9]=n,t[10]=y,t[11]=i,t[12]=b):b=t[12];let x=pL(b),S;t[13]!==o||t[14]!==r||t[15]!==c||t[16]!==n||t[17]!==p||t[18]!==a||t[19]!==i?(S=()=>{if(!c)return;p?.();let e=bL;if(a===`draft`&&o){n({to:`/draft/$draftId`,params:{draftId:o},replace:!0,search:e});return}n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},replace:!0,search:e})},t[13]=o,t[14]=r,t[15]=c,t[16]=n,t[17]=p,t[18]=a,t[19]=i,t[20]=S):S=t[20];let C=pL(S),w;t[21]!==o||t[22]!==r||t[23]!==s||t[24]!==n||t[25]!==m||t[26]!==a||t[27]!==i?(w=()=>{m?.();let e=yL;if(a===`draft`&&o){n({to:`/draft/$draftId`,params:{draftId:o},replace:!0,search:e});return}s&&n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},replace:!0,search:e})},t[21]=o,t[22]=r,t[23]=s,t[24]=n,t[25]=m,t[26]=a,t[27]=i,t[28]=w):w=t[28];let T=pL(w),E;t[29]!==o||t[30]!==r||t[31]!==_||t[32]!==s||t[33]!==n||t[34]!==h||t[35]!==a||t[36]!==i?(E=()=>{if(_)return;h?.();let e=vL;if(a===`draft`&&o){n({to:`/draft/$draftId`,params:{draftId:o},replace:!0,search:e});return}s&&n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},replace:!0,search:e})},t[29]=o,t[30]=r,t[31]=_,t[32]=s,t[33]=n,t[34]=h,t[35]=a,t[36]=i,t[37]=E):E=t[37];let D=pL(E),O;t[38]!==o||t[39]!==r||t[40]!==d||t[41]!==s||t[42]!==n||t[43]!==a||t[44]!==i||t[45]!==u?(O=()=>{if(d){d();return}let e=e=>u?mL(e):Zn(e);if(a===`draft`&&o){n({to:`/draft/$draftId`,params:{draftId:o},replace:!0,search:e});return}s&&n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},replace:!0,search:e})},t[38]=o,t[39]=r,t[40]=d,t[41]=s,t[42]=n,t[43]=a,t[44]=i,t[45]=u,t[46]=O):O=t[46];let k=pL(O),A;t[47]!==r||t[48]!==s||t[49]!==n||t[50]!==f||t[51]!==i?(A=(e,t)=>{s&&(f?.(),n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},search:n=>Xn(n,{diffTurnId:e,diffFilePath:t??void 0})}))},t[47]=r,t[48]=s,t[49]=n,t[50]=f,t[51]=i,t[52]=A):A=t[52];let j=A,M;t[53]!==r||t[54]!==s||t[55]!==n||t[56]!==i?(M=()=>{s&&n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},search:_L})},t[53]=r,t[54]=s,t[55]=n,t[56]=i,t[57]=M):M=t[57];let N=M,P;t[58]!==o||t[59]!==r||t[60]!==_||t[61]!==s||t[62]!==n||t[63]!==a||t[64]!==i?(P=()=>{if(_)return;let e=gL;if(a===`draft`&&o){n({to:`/draft/$draftId`,params:{draftId:o},replace:!0,search:e});return}s&&n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},replace:!0,search:e})},t[58]=o,t[59]=r,t[60]=_,t[61]=s,t[62]=n,t[63]=a,t[64]=i,t[65]=P):P=t[65];let F=pL(P),I;t[66]!==o||t[67]!==r||t[68]!==s||t[69]!==n||t[70]!==g||t[71]!==a||t[72]!==i?(I=e=>{g?.();let t=t=>Gn(t,e.key);if(a===`draft`&&o){n({to:`/draft/$draftId`,params:{draftId:o},search:t});return}s&&n({to:`/$environmentId/$threadId`,params:{environmentId:r,threadId:i},search:t})},t[66]=o,t[67]=r,t[68]=s,t[69]=n,t[70]=g,t[71]=a,t[72]=i,t[73]=I):I=t[73];let ee=I,L;return t[74]!==N||t[75]!==F||t[76]!==C||t[77]!==y||t[78]!==D||t[79]!==ee||t[80]!==T||t[81]!==j||t[82]!==x||t[83]!==k?(L={onOpenReviewPanel:y,onToggleDiff:x,onOpenFilesPanel:C,onOpenTerminalPanel:T,onOpenSimulatorPanel:D,onToggleWorkspacePanel:k,onOpenTurnDiff:j,onCloseDiff:N,onOpenAgentsPanel:F,onOpenSubagentPanel:ee},t[74]=N,t[75]=F,t[76]=C,t[77]=y,t[78]=D,t[79]=ee,t[80]=T,t[81]=j,t[82]=x,t[83]=k,t[84]=L):L=t[84],L}function gL(e){return Bn(e)}function _L(e){return mL(e)}function vL(e){return Vn(e)}function yL(e){return Kn(e)}function bL(e){return Jn(e)}function xL(e){return Xn(e)}var SL=[];function CL(e){return oe((0,q.useMemo)(()=>{let t=[],n=[],r=new Map;return i=>{let a=t.length===e.length&&t.every((t,n)=>t===e[n]),o=new Map,s=[],c=!a;for(let t of e){let e,n,a;for(let r of Object.values(i.environmentStateById)){let i=r.threadShellById[t];if(i){e=i,n=r.proposedPlanIdsByThreadId[t],a=r.proposedPlanByThreadId[t];break}}if(!e){let e=r.get(t);if(e&&e.shell===null&&e.proposedPlanIds===void 0&&e.proposedPlansById===void 0){o.set(t,e);continue}c=!0,o.set(t,{shell:null,proposedPlanIds:void 0,proposedPlansById:void 0,entry:{id:t,proposedPlans:SL}});continue}let l=r.get(t);if(l&&l.shell===e&&l.proposedPlanIds===n&&l.proposedPlansById===a){o.set(t,l),s.push(l.entry);continue}c=!0;let u={id:t,proposedPlans:n&&n.length>0&&a?n.flatMap(e=>{let t=a?.[e];return t?[t]:[]}):SL};o.set(t,{shell:e,proposedPlanIds:n,proposedPlansById:a,entry:u}),s.push(u)}return!c&&n.length===s.length?n:(t=e,r=o,n=s,s)}},[e]))}function wL(e){let t=(0,J.c)(19),[n,r]=(0,q.useState)(null),i;t[0]===e.activeThread?i=t[1]:(i=t=>{let n=!!t?.preparingWorktree;r(r=>r?r.preparingWorktree===n?r:{...r,preparingWorktree:n}:Ad(e.activeThread,t))},t[0]=e.activeThread,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{r(null)},t[2]=o):o=t[2];let s=o;e.activeThread?.session;let c=e.activeThread?.session??null,l=e.activePendingApproval!==null,u=e.activePendingUserInput!==null,d;t[3]!==e.activeLatestTurn||t[4]!==e.phase||t[5]!==e.threadError||t[6]!==n||t[7]!==c||t[8]!==l||t[9]!==u?(d=jd({localDispatch:n,phase:e.phase,latestTurn:e.activeLatestTurn,session:c,hasPendingApproval:l,hasPendingUserInput:u,threadError:e.threadError}),t[3]=e.activeLatestTurn,t[4]=e.phase,t[5]=e.threadError,t[6]=n,t[7]=c,t[8]=l,t[9]=u,t[10]=d):d=t[10];let f=d,p,m;t[11]===f?(p=t[12],m=t[13]):(p=()=>{f&&s()},m=[s,f],t[11]=f,t[12]=p,t[13]=m),(0,q.useEffect)(p,m);let h=n?.startedAt??null,g=n?.preparingWorktree??!1,_=n!==null&&!f,v;return t[14]!==a||t[15]!==_||t[16]!==h||t[17]!==g?(v={beginLocalDispatch:a,resetLocalDispatch:s,localDispatchStartedAt:h,isPreparingWorktree:g,isSendBusy:_},t[14]=a,t[15]=_,t[16]=h,t[17]=g,t[18]=v):v=t[18],v}var TL=120,EL=30;function DL(e){let{environmentId:t,activeThread:n,activeThreadId:r,activeThreadRef:i,activeProject:a,gitCwd:o,terminalState:s,setLastInvokedScriptByProjectId:c,setTerminalLaunchContext:l,setTerminalOpen:u,storeNewTerminal:f,storeSetActiveTerminal:p,setTerminalFocusRequestId:m,setThreadError:h}=e,g=pL(async(e,d)=>{let g=Be(t);if(!g||!r||!a||!n)return;d?.rememberAsLastInvoked!==!1&&c(t=>t[a.id]===e.id?t:{...t,[a.id]:e.id});let _=d?.cwd??o??a.cwd,v=s.activeTerminalId||s.terminalIds[0]||`default`,y=s.runningTerminalIds.includes(v),b=!!d?.preferNewTerminal||y,x=b?`terminal-${io()}`:v,S=d?.worktreePath??n.worktreePath??null;if(l({threadId:r,cwd:_,worktreePath:S}),u(!0),!i)return;b?f(i,x):p(i,x),m(e=>e+1);let C=va({project:{cwd:a.cwd},worktreePath:S,...d?.env?{extraEnv:d.env}:{}}),w=b?{threadId:r,terminalId:x,cwd:_,...S===null?{}:{worktreePath:S},env:C,cols:TL,rows:EL}:{threadId:r,terminalId:x,cwd:_,...S===null?{}:{worktreePath:S},env:C};try{await g.terminal.open(w),await g.terminal.write({threadId:r,terminalId:x,data:`${e.command}\r`})}catch(t){h(r,t instanceof Error?t.message:`Failed to run script "${e.name}".`)}}),_=(0,q.useCallback)(async e=>{let n=Be(t);if(!n)return;await n.orchestration.dispatchCommand({type:`project.meta.update`,commandId:ro(),projectId:e.projectId,scripts:e.nextScripts});let r=dN({keybinding:e.keybinding,command:e.keybindingCommand});if(d&&r){let e=he();if(!e)throw Error(`Local API unavailable.`);await e.server.upsertKeybinding(r)}},[t]);return{runProjectScript:g,saveProjectScript:(0,q.useCallback)(async e=>{if(!a)return;let t=gN(e.name,a.scripts.map(e=>e.id)),n={id:t,name:e.name,command:e.command,icon:e.icon,runOnWorktreeCreate:e.runOnWorktreeCreate},r=e.runOnWorktreeCreate?[...a.scripts.map(e=>e.runOnWorktreeCreate?{...e,runOnWorktreeCreate:!1}:e),n]:[...a.scripts,n];await _({projectId:a.id,projectCwd:a.cwd,previousScripts:a.scripts,nextScripts:r,keybinding:e.keybinding,keybindingCommand:mN(t)})},[a,_]),updateProjectScript:(0,q.useCallback)(async(e,t)=>{if(!a)return;let n=a.scripts.find(t=>t.id===e);if(!n)throw Error(`Script not found.`);let r={...n,name:t.name,command:t.command,icon:t.icon,runOnWorktreeCreate:t.runOnWorktreeCreate},i=a.scripts.map(n=>n.id===e?r:t.runOnWorktreeCreate?{...n,runOnWorktreeCreate:!1}:n);await _({projectId:a.id,projectCwd:a.cwd,previousScripts:a.scripts,nextScripts:i,keybinding:t.keybinding,keybindingCommand:mN(e)})},[a,_]),deleteProjectScript:(0,q.useCallback)(async e=>{if(!a)return;let t=a.scripts.filter(t=>t.id!==e),n=a.scripts.find(t=>t.id===e)?.name;try{await _({projectId:a.id,projectCwd:a.cwd,previousScripts:a.scripts,nextScripts:t,keybinding:null,keybindingCommand:mN(e)}),Ai.add({type:`success`,title:`Deleted action "${n??`Unknown`}"`})}catch(e){Ai.add(As({type:`error`,title:`Could not delete action`,description:e instanceof Error?e.message:`An unexpected error occurred.`}))}},[a,_])}}function OL(e){let{serverMessages:t,optimisticUserMessagesRef:n}=e,[r,i]=(0,q.useState)({}),a=(0,q.useRef)({}),o=(0,q.useRef)({});(0,q.useEffect)(()=>{a.current=r},[r]);let s=(0,q.useCallback)((e,t)=>{delete o.current[e];let n=t??a.current[e]??[];i(t=>{if(!(e in t))return t;let n={...t};return delete n[e],a.current=n,n});for(let e of n)_d(e)},[]),c=(0,q.useCallback)(()=>{o.current={};for(let e of Object.values(a.current))for(let t of e)_d(t);a.current={},i({})},[]);(0,q.useEffect)(()=>()=>{c();for(let e of n.current)vd(e)},[c,n]);let l=(0,q.useCallback)((e,t)=>{if(t.length===0)return;let n=a.current[e]??[];for(let e of n)t.includes(e)||_d(e);i(n=>{let r={...n,[e]:t};return a.current=r,r})},[]);return(0,q.useEffect)(()=>{if(typeof Image>`u`||!t||t.length===0)return;let e=[];for(let[n,i]of Object.entries(r)){if(o.current[n])continue;let r=t.find(e=>e.id===n&&e.role===`user`);if(!r?.attachments||r.attachments.length===0)continue;let a=r.attachments.flatMap(e=>e.type===`image`&&e.previewUrl?[e.previewUrl]:[]);if(a.length===0||a.length!==i.length||a.some(e=>e.startsWith(`blob:`)))continue;o.current[n]=!0;let c=!1,l=[];Promise.all(a.map(e=>new Promise((t,r)=>{let i=new Image;l.push(i),i.addEventListener(`load`,()=>t(),{once:!0}),i.addEventListener(`error`,()=>r(Error(`Failed to load server preview for ${n}.`)),{once:!0}),i.src=e}))).then(()=>{c||s(n,i)}).catch(()=>{c||delete o.current[n]}),e.push(()=>{c=!0,delete o.current[n];for(let e of l)e.src=``})}return()=>{for(let t of e)t()}},[r,s,t]),{attachmentPreviewHandoffByMessageId:r,handoffAttachmentPreviews:l}}async function kL(e,t){await e.orchestration.dispatchCommand({type:`thread.turn.interrupt`,commandId:ro(),threadId:t,createdAt:new Date().toISOString()})}async function AL(e){await e.api.orchestration.dispatchCommand({type:`thread.approval.respond`,commandId:ro(),threadId:e.threadId,requestId:e.requestId,decision:e.decision,createdAt:new Date().toISOString()})}async function jL(e){await e.api.orchestration.dispatchCommand({type:`thread.user-input.respond`,commandId:ro(),threadId:e.threadId,requestId:e.requestId,answers:e.answers,createdAt:new Date().toISOString()})}async function ML(e){await e.api.orchestration.dispatchCommand({type:`thread.checkpoint.revert`,commandId:ro(),threadId:e.threadId,turnCount:e.turnCount,createdAt:new Date().toISOString()})}async function NL(e){return!e.api||!e.localApi||!e.thread?{ok:!1,reason:{type:`missing-api`}}:e.environmentUnavailable?{ok:!1,reason:{type:`environment-unavailable`,label:e.environmentUnavailableLabel??`environment`}}:e.turnInProgress?{ok:!1,reason:{type:`turn-in-progress`}}:await e.localApi.dialogs.confirm(e.confirmMessage)?(await ML({api:e.api,threadId:e.thread.id,turnCount:e.turnCount}),{ok:!0}):{ok:!1,reason:{type:`user-cancelled`}}}function PL(e){switch(e.type){case`missing-api`:case`missing-thread`:case`user-cancelled`:return null;case`environment-unavailable`:return`Reconnect ${e.label} before reverting checkpoints.`;case`turn-in-progress`:return`Interrupt the current turn before reverting checkpoints.`}}function FL(e){let{environmentId:t,activeThreadId:n,setThreadError:r}=e,[i,a]=(0,q.useState)([]),[o,s]=(0,q.useState)([]),[c,l]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{l(!1)},[n]),{interruptTurn:(0,q.useCallback)(async()=>{let e=Be(t);!e||!n||await kL(e,n)},[n,t]),respondToApproval:(0,q.useCallback)(async(e,i)=>{let o=Be(t);if(!(!o||!n)){a(t=>t.includes(e)?t:[...t,e]);try{await AL({api:o,threadId:n,requestId:e,decision:i})}catch(e){r(n,e instanceof Error?e.message:`Failed to submit approval decision.`)}finally{a(t=>t.filter(t=>t!==e))}}},[n,t,r]),respondToUserInput:(0,q.useCallback)(async(e,i)=>{let a=Be(t);if(!(!a||!n)){s(t=>t.includes(e)?t:[...t,e]);try{await jL({api:a,threadId:n,requestId:e,answers:i})}catch(e){r(n,e instanceof Error?e.message:`Failed to submit user input.`)}finally{s(t=>t.filter(t=>t!==e))}}},[n,t,r]),revertToTurnCount:(0,q.useCallback)(async e=>{let n=Be(t),i=he();if(!c){l(!0),e.thread&&r(e.thread.id,null);try{let t=await NL({api:n??null,localApi:i??null,thread:e.thread,turnCount:e.turnCount,environmentUnavailable:e.environmentUnavailable,environmentUnavailableLabel:e.environmentUnavailableLabel,turnInProgress:e.turnInProgress,confirmMessage:[`Revert this thread to checkpoint ${e.turnCount}?`,`This will discard newer messages and turn diffs in this thread.`,`This action cannot be undone.`].join(`
|
|
26
|
-
`)});if(!t.ok){let n=PL(t.reason);n&&e.thread&&r(e.thread.id,n)}}catch(t){e.thread&&r(e.thread.id,t instanceof Error?t.message:`Failed to revert thread state.`)}finally{l(!1)}}},[t,c,r]),respondingRequestIds:i,respondingUserInputRequestIds:o,isRevertingCheckpoint:c}}function IL(e,t){e(e=>{let n=e.filter(e=>e.id===t);for(let e of n)vd(e);let r=e.filter(e=>e.id!==t);return r.length===e.length?e:r})}function LL(e){let{refs:t,composerHandle:n,dispatch:r,draft:i,messageId:a,promptSnapshot:o,imagesSnapshot:s,terminalContextsSnapshot:c}=e;if(t.promptRef.current.length!==0||t.composerImagesRef.current.length!==0||t.composerTerminalContextsRef.current.length!==0)return;IL(r.setOptimisticUserMessages,a),t.promptRef.current=o;let l=s.map(Cd);t.composerImagesRef.current=l,t.composerTerminalContextsRef.current=c,i.setComposerDraftPrompt(i.composerDraftTarget,o),i.addComposerDraftImages(i.composerDraftTarget,l),i.setComposerDraftTerminalContexts(i.composerDraftTarget,c),n.readComposer()?.resetCursorState({cursor:Ot(o,o.length),prompt:o,detectTrigger:!0})}function RL(e){let t=Yt(e.composer.prompt,e.composer.sendableTerminalContexts);return e.formatOutgoingPrompt({provider:e.composer.selectedProvider,model:e.composer.selectedModel,models:e.composer.selectedProviderModels,effort:e.composer.selectedPromptEffort,text:t||`[User attached one or more files without additional text. Respond using the conversation context and the attachment(s).]`})}async function zL(e){return Promise.all(e.map(async e=>Rt({attachment:await ul.encode({id:e.id,file:e.file}),name:e.name,type:e.type})))}async function BL(e){let{composer:t,thread:n,worktree:r,settings:a,project:o,scroll:s,draft:c,dispatch:l,refs:u,sourceControl:d,persistSettings:f,composerHandle:p,formatOutgoingPrompt:m}=e,{api:h,beginLocalDispatch:g,resetLocalDispatch:_,setOptimisticUserMessages:v,setThreadError:y}=l;u.sendInFlightRef.current=!0,g({preparingWorktree:!!r.baseBranchForWorktree});let b=[...t.images],x=[...t.sendableTerminalContexts],S=[...t.sourceControlContexts],C=e.messageId??oo(),w=new Date().toISOString(),T=RL({composer:t,formatOutgoingPrompt:m}),E=zL(b),D=b.map(e=>({type:e.type,id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,previewUrl:e.previewUrl}));if(await s.scrollToEndBeforeOptimistic(),v(e=>[...e,{id:C,role:`user`,text:T,...D.length>0?{attachments:D}:{},createdAt:w,streaming:!1}]),s.scrollToEndAfterOptimistic(),y(n.threadId,null),c.setComposerDraftTokenMode(i(c.environmentId,n.threadId),a.tokenMode),n.isLocalDraftThread&&c.setDraftThreadContext(c.composerDraftTarget,{tokenMode:a.tokenMode}),t.expiredTerminalContextCount>0){let e=Td(t.expiredTerminalContextCount,`omitted`);Ai.add(As({type:`warning`,title:e.title,description:e.description}))}u.promptRef.current=``,c.clearComposerDraftContent(c.composerDraftTarget),c.setComposerDraftTokenMode(c.composerDraftTarget,a.tokenMode),p.readComposer()?.resetCursorState();let O=!1;await(async()=>{let i=null;if(b.length>0){let e=b[0];e&&(i=e.name)}let s=cu(Sd({trimmedPrompt:t.trimmedPrompt,firstImageName:i,firstTerminalContextLabel:x.length>0?zt(x[0]):null})),c=o.defaultModelSelection?.model??null,l=Bt({selectedModelSelection:t.selectedModelSelection,selectedModel:t.selectedModel,defaultModel:c}),u=await E,p=await Ed(S,d),m=cn({isLocalDraftThread:n.isLocalDraftThread,baseBranchForWorktree:r.baseBranchForWorktree,shouldMaterializeLegacyBranchWorktree:r.shouldMaterializeLegacyBranchWorktree,projectId:o.projectId,projectCwd:o.projectCwd,title:s,threadCreateModelSelection:l,runtimeMode:a.runtimeMode,interactionMode:a.interactionMode,tokenMode:a.tokenMode,activeThreadBranch:n.activeThreadBranch,worktreePath:n.worktreePath,threadCreatedAt:n.createdAt}),_=e.prepareForDispatch?await e.prepareForDispatch():null;await en({api:h,threadId:_?.threadId??n.threadId,isFirstMessage:_?.isFirstMessage??n.isFirstMessage,isServerThread:_?.isServerThread??n.isServerThread,title:s,messageId:C,outgoingMessageText:T,turnAttachments:u,modelSelection:t.selectedModelSelection,runtimeMode:a.runtimeMode,interactionMode:a.interactionMode,tokenMode:a.tokenMode,bootstrap:_?void 0:m,sourceControlContexts:p,createdAt:w,newCommandId:ro,beginLocalDispatch:g,persistThreadSettingsForNextTurn:f.persistThreadSettingsForNextTurn}),O=!0})().catch(async e=>{LL({refs:u,composerHandle:p,dispatch:{setOptimisticUserMessages:v},draft:c,messageId:C,promptSnapshot:t.prompt,imagesSnapshot:b,terminalContextsSnapshot:x}),y(n.threadId,e instanceof Error?e.message:`Failed to send message.`)}),u.sendInFlightRef.current=!1,O||_()}function VL(e){return Me({trimmedPrompt:e.composer.trimmedPrompt,imageCount:e.composer.images.length,terminalContextCount:e.composer.sendableTerminalContexts.length})}var HL=G(`inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/80`,`transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),UL=(0,q.memo)(function(e){let t=(0,J.c)(23),{messages:n,onRemove:r,onMove:i,showSteerAction:a,steeringIds:o,getSteerUnavailableReason:s,onSteer:c}=e;if(n.length===0)return null;let l;t[0]===n.length?l=t[1]:(l=(0,Y.jsxs)(`div`,{className:`px-1.5 pb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[`Queued · `,n.length]}),t[0]=n.length,t[1]=l);let u;if(t[2]!==s||t[3]!==n||t[4]!==i||t[5]!==r||t[6]!==c||t[7]!==a||t[8]!==o){let e;t[10]!==s||t[11]!==n.length||t[12]!==i||t[13]!==r||t[14]!==c||t[15]!==a||t[16]!==o?(e=(e,t)=>{let l=VL(e),u=`queued message ${t+1} of ${n.length}: ${l}`,d=s(e),f=o.includes(e.id);return(0,Y.jsxs)(`li`,{className:`flex items-center gap-1 rounded-md px-1.5 py-1 hover:bg-muted/50`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,title:l,children:l}),a?(0,Y.jsxs)(`button`,{type:`button`,className:G(HL,`w-auto gap-1 px-1.5 text-[11px]`),disabled:d!==null||f,onClick:()=>c(e),"aria-label":`Steer ${u} into the active turn`,title:d??`Send this message into the active turn`,children:[f?(0,Y.jsx)(Xr,{className:`size-3 animate-spin`}):(0,Y.jsx)(vl,{className:`size-3`}),`Steer`]}):null,(0,Y.jsx)(`button`,{type:`button`,className:HL,disabled:t===0,onClick:()=>i(e.id,`up`),"aria-label":`Move ${u} up`,children:(0,Y.jsx)(ai,{className:`size-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,className:HL,disabled:t===n.length-1,onClick:()=>i(e.id,`down`),"aria-label":`Move ${u} down`,children:(0,Y.jsx)(Zr,{className:`size-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,className:HL,onClick:()=>r(e.id),"aria-label":`Remove ${u}`,children:(0,Y.jsx)($a,{className:`size-3.5`})})]},e.id)},t[10]=s,t[11]=n.length,t[12]=i,t[13]=r,t[14]=c,t[15]=a,t[16]=o,t[17]=e):e=t[17],u=n.map(e),t[2]=s,t[3]=n,t[4]=i,t[5]=r,t[6]=c,t[7]=a,t[8]=o,t[9]=u}else u=t[9];let d;t[18]===u?d=t[19]:(d=(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:u}),t[18]=u,t[19]=d);let f;return t[20]!==l||t[21]!==d?(f=(0,Y.jsxs)(`div`,{className:`mb-2 rounded-lg border border-border/60 bg-muted/30 p-1.5`,children:[l,d]}),t[20]=l,t[21]=d,t[22]=f):f=t[22],f});function WL(e){let t=(0,J.c)(11),n;t[0]===e.open?n=t[1]:(n=Ps({active:e.open,containIntrinsicSize:`28rem 100vh`}),t[0]=e.open,t[1]=n);let r=n,i;t[2]===e?i=t[3]:(i=t=>{t||e.onClose()},t[2]=e,t[3]=i);let a;t[4]!==r||t[5]!==e.children?(a=(0,Y.jsx)(Is,{side:`right`,showCloseButton:!1,keepMounted:!0,className:su,children:(0,Y.jsx)(`div`,{className:`flex min-h-0 w-full flex-1`,style:r,children:e.children})}),t[4]=r,t[5]=e.children,t[6]=a):a=t[6];let o;return t[7]!==e.open||t[8]!==i||t[9]!==a?(o=(0,Y.jsx)(Ls,{open:e.open,onOpenChange:i,children:a}),t[7]=e.open,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}var GL=[],KL=[],qL=[],JL=Object.freeze([]),YL=`\0`,XL=Object.freeze([]),ZL=Object.freeze([]);function QL(e){let t=[`${e.length}`];for(let n of e){t.push(n.instanceId,n.driver,n.displayName??``,n.accentColor??``,n.badgeLabel??``,n.continuation?.groupKey??``,n.showInteractionModeToggle?`1`:`0`,n.supportsAskMode?`1`:`0`,n.supportsTurnSteering?`1`:`0`,n.enabled?`1`:`0`,n.status,n.installed?`1`:`0`,n.availability??``,n.unavailableReason??``,n.auth.status,n.auth.type??``,n.auth.label??``,n.auth.email??``,n.message??``);for(let e of n.models)t.push(`model`,e.slug,e.name,e.shortName??``,e.subProvider??``,e.isCustom?`1`:`0`,JSON.stringify(e.capabilities)??``);for(let e of n.slashCommands)t.push(`command`,e.name,e.description??``,e.input?.hint??``);for(let e of n.skills)t.push(`skill`,e.name,e.path,e.enabled?`1`:`0`,e.scope??``,e.displayName??``,e.shortDescription??``,e.description??``)}return t.join(YL)}function $L(e,t){let n=QL(e);if(n===t.key)return t.snapshot;let r=e;return t.key=n,t.snapshot=r,r}function eR(e){let t=at(e.models,e.model,e.provider),n=St(t,e.effort);return _n(e.text,n)}function tR(e){return typeof Element>`u`?null:e instanceof Element?e:null}function nR(e){return tR(e)?.closest(`[data-chat-composer-form="true"], [data-thread-message-search="true"]`)!==null}function rR(e){return!!(e.type!==`keydown`||e.isComposing||Ns()||ko(e.target)||Eo()||Do(e.target)&&!nR(e.target))}function iR(e){ti(`ChatView`);let t=Ms(x.dispatchCommand),n=Ms(ee.terminalOpen),{environmentId:r,threadId:a,routeKind:c,onDiffPanelOpen:l,onPreviewPanelOpen:u,onTerminalPanelOpen:p,onSimulatorPanelOpen:m,onAgentPanelOpen:g,onToggleWorkspacePanel:_,reserveTitleBarControlInset:v=!0}=e,y=c===`draft`?e.draftId:null,b=(0,q.useMemo)(()=>i(r,a),[r,a]),S=(0,q.useMemo)(()=>f(b),[b]),w=c===`server`?b:e.draftId,T=oe((0,q.useMemo)(()=>ue(c===`server`?b:null),[c,b])),D=oe(e=>e.setThreadError),O=Tr(e=>e.markThreadVisited),k=Tr(e=>e.alwaysUseBuildMode),A=Tr(e=>c===`server`?e.threadLastVisitedAtById[S]:void 0),j=pe(),N=Or(),P=Ln(),F=Jt(e=>e.setStickyModelSelection),L=j.timestampFormat,te=j.autoOpenPlanSidebar,B=Qn(),V=wr(e=>e.openSettings),H=zn({strict:!1,select:e=>Yn(e)}),{resolvedTheme:U}=Wc(),se=Jt(e=>e.getComposerDraft(w)?.runtimeMode??null),le=Jt(e=>e.getComposerDraft(w)?.interactionMode??null),de=Jt(e=>e.getComposerDraft(w)?.tokenMode??null),fe=Jt(e=>e.getComposerDraft(w)?.activeProvider??null),he=Jt(e=>e.setPrompt),_e=Jt(e=>e.addImages),ye=Jt(e=>e.setTerminalContexts),be=Jt(e=>e.setModelSelection),Se=Jt(e=>e.setRuntimeMode),Ce=Jt(e=>e.setInteractionMode),we=Jt(e=>e.setTokenMode),Te=Jt(e=>e.clearComposerContent),Ee=Jt(e=>e.setDraftThreadContext),De=Jt(e=>e.clearDraftThread),Me=Jt(e=>e.getDraftSessionByLogicalProjectKey),Pe=Jt(e=>e.getDraftSession),Fe=Jt(e=>e.setLogicalProjectDraftThreadId),Le=Jt(e=>c===`server`?e.getDraftSessionByRef(b):y?e.getDraftSession(y):null),ze=(0,q.useRef)(``),Ue=(0,q.useRef)([]),We=(0,q.useRef)([]),qe=(0,q.useRef)(null),Ye=js()??qe,Ze=(0,q.useCallback)(()=>Ye.current,[Ye]),[rt,at]=(0,q.useState)(!1),[ot,st]=(0,q.useState)(null),[ct,lt]=(0,q.useState)([]),[ut,ft]=(0,q.useState)(!1),[pt,mt]=(0,q.useState)(``),[_t,vt]=(0,q.useState)(0),[yt,bt]=(0,q.useState)(0),[xt,St]=(0,q.useState)(null),[wt,Tt]=(0,q.useState)([]),[Et]=it(pt,{wait:180}),Dt=(0,q.useRef)(ct);Dt.current=ct;let[Ot,kt]=(0,q.useState)({}),[At,jt]=(0,q.useState)(!1),[Mt,Nt]=(0,q.useState)(!0),[Pt,Ft]=(0,q.useState)(!1),[It,Rt]=(0,q.useState)(!1),zt=ri(ou),Bt=ri(Fs),Vt=Rs(),Ut=Kc(),Wt=(0,q.useRef)(Vt);Wt.current=Vt;let Gt=(0,q.useRef)(zt);Gt.current=zt;let[Kt,Yt]=(0,q.useState)(null),Xt=(0,q.useCallback)((e,t)=>{Wt.current!==`phone`&&(Nt(!1),Yt({marker:e,trigger:t}))},[]),Zt=(0,q.useCallback)(()=>{Yt(e=>(e&&requestAnimationFrame(()=>e.trigger.focus({preventScroll:!0})),null))},[]),Qt=k&&Vt!==`phone`,$t=(0,q.useRef)(null),en=(0,q.useRef)(!1),[tn,nn]=(0,q.useState)(0),[an,on]=(0,q.useState)(null),[sn,cn]=(0,q.useState)(!1),ln=(0,q.useRef)(sn);ln.current=sn;let[dn,fn]=(0,q.useState)(`prs`),[mn,hn]=(0,q.useState)(null),[gn,_n]=(0,q.useState)(),[bn,xn]=yn(dd,{},fd),Sn=(0,q.useRef)(null),Cn=(0,q.useRef)(!0),[wn,Tn]=(0,q.useState)(!0),En=(0,q.useRef)(!1),Dn=(0,q.useRef)({}),On=ge(e=>Qe(e.terminalStateByThreadKey,b)),kn=ge(eo(e=>Object.entries(e.terminalStateByThreadKey).flatMap(([e,t])=>t.terminalOpen?[e]:[]))),An=ge(e=>e.setTerminalOpen),Nn=ge(e=>e.splitTerminal),Pn=ge(e=>e.newTerminal),Bn=ge(e=>e.setActiveTerminal),Vn=ge(e=>e.closeTerminal),Hn=oe(eo(e=>ce(e).map(e=>f(i(e.environmentId,e.id))))),Gn=ge(e=>e.terminalLaunchContextByThreadKey[f(b)]??null),Kn=ge(e=>e.clearTerminalLaunchContext),Jn=Jt(e=>e.draftThreadsByThreadKey),Xn=(0,q.useMemo)(()=>Object.values(Jn).map(e=>f(i(e.environmentId,e.threadId))),[Jn]),[Zn,$n]=(0,q.useState)([]),er=(0,q.useMemo)(()=>Zn.flatMap(e=>{let t=s(e);return t?[{key:e,threadRef:t}]:[]}),[Zn]),tr=Le?o(Le.environmentId,Le.projectId):null,nr=oe((0,q.useMemo)(()=>ne(tr),[tr])),rr=c===`server`&&T?null:(y?Ot[y]:null)??null,ir=(0,q.useMemo)(()=>Le?md(a,Le,nr?.defaultModelSelection??{instanceId:I.make(`codex`),model:`gpt-5.6-terra`},rr):void 0,[Le,nr?.defaultModelSelection,rr,a]),ar=c===`server`&&T!==void 0,W=ar?T:ir;(0,q.useEffect)(()=>{Yt(null)},[W?.id]);let or=W?.id??null,sr=(0,q.useDeferredValue)(or)===or,cr=se??W?.runtimeMode??`full-access`,lr=Qt?rn:le??W?.interactionMode??`default`,ur=de??W?.tokenMode??j.defaultAgentTokenMode??`balanced`,dr=!ar&&ir!==void 0,fr=dr,pr=H.diff===`1`,mr=e.workspacePanelOpen??qn(H),hr=W?.id??null,gr=(0,q.useCallback)((e,t)=>{if(!e)return;let n=tt(t);if(hd({serverThread:T,routeThreadRef:b,targetThreadId:e})){D(b,n);return}let r=y??e;kt(e=>(e[r]??null)===n?e:{...e,[r]:n})},[y,b,T,D]),{interruptTurn:_r,respondToApproval:vr,respondToUserInput:yr,revertToTurnCount:br,respondingRequestIds:xr,respondingUserInputRequestIds:Sr,isRevertingCheckpoint:Cr}=FL({environmentId:r,activeThreadId:hr,setThreadError:gr}),Ar=(0,q.useMemo)(()=>W?i(W.environmentId,W.id):null,[W]),jr=Ar?f(Ar):null,Mr=oe(e=>Ar?e.environmentStateById[Ar.environmentId]?.threadHistoryByThreadId?.[Ar.threadId]?.messages:void 0),Pr=oe(e=>Ar?e.environmentStateById[Ar.environmentId]?.threadHistoryLoadByThreadId?.[Ar.threadId]?.messages:void 0),Fr=(0,q.useCallback)(()=>{!Ar||!Mr||Xe({environmentId:Ar.environmentId,threadId:Ar.threadId,collection:`messages`,page:Mr,limit:150}).catch(()=>void 0)},[Mr,Ar]);(0,q.useEffect)(()=>{let e=H.messageId;!Ar||!e||!Mr||W?.messages.some(t=>t.id===e)||Ne({environmentId:Ar.environmentId,threadId:Ar.threadId,messageId:e,limit:101}).catch(()=>void 0)},[W?.messages,Mr,Ar,H.messageId]);let Ir=He(e=>e.enqueue),Lr=He(e=>e.remove),Rr=He(e=>e.move),zr=He(e=>e.dequeue),Br=He(e=>e.beginSteer),Vr=He(e=>e.endSteer),Hr=He(e=>jr?e.queuesByThreadKey[jr]??XL:XL),Ur=He(e=>jr?e.steeringIdsByThreadKey[jr]??ZL:ZL),Wr=(0,q.useCallback)(e=>{if(!jr)return;let t=He.getState().queuesByThreadKey[jr]?.find(t=>t.id===e);if(t)for(let e of t.composer.images)e.previewUrl.startsWith(`blob:`)&&URL.revokeObjectURL(e.previewUrl);Lr(jr,e)},[jr,Lr]),Gr=(0,q.useCallback)((e,t)=>{jr&&Rr(jr,e,t)},[jr,Rr]);(0,q.useEffect)(()=>{ft(!1),mt(``),bt(0),St(null)},[jr]);let Kr=(0,q.useMemo)(()=>{let e=new Set([...Hn,...Xn]);return kn.filter(t=>e.has(t))},[Xn,kn,Hn]),qr=W?.latestTurn??null,Jr=CL((0,q.useMemo)(()=>{let e=[];W?.id&&e.push(W.id);let t=qr?.sourceProposedPlan?.threadId;return t&&t!==W?.id&&e.push(t),e},[qr?.sourceProposedPlan?.threadId,W?.id]));(0,q.useEffect)(()=>{$n(e=>{let t=gd({currentThreadIds:e,openThreadIds:Kr,activeThreadId:jr,activeThreadTerminalOpen:!!(jr&&On.terminalOpen),maxHiddenThreadCount:10});return e.length===t.length&&e.every((e,n)=>e===t[n])?e:t})},[jr,Kr,On.terminalOpen]);let Yr=_o(qr,W?.session??null),Xr=W?o(W.environmentId,W.projectId):null,Qr=oe((0,q.useMemo)(()=>ne(Xr),[Xr])),$r=oe((0,q.useMemo)(()=>e=>{if(!W||!W.environmentId)return null;let t=W.worktreeId;if(!t)return null;let n=e.environmentStateById[W.environmentId];return n?.worktreeById?n.worktreeById[t]??null:null},[W?.environmentId,W?.worktreeId])),[ei,ii]=(0,q.useState)(null),ai=(0,q.useCallback)(e=>{ii(e)},[]),oi=(0,q.useCallback)(e=>{e||ii(null)},[]),si=(0,q.useMemo)(()=>HN(),[]),ci=W?.worktreeId,li=W?.worktreePath,ui=(0,q.useMemo)(()=>{if(!Xr)return[];let e=[];for(let t of Object.values(Jn))t.promotedTo==null&&t.environmentId===Xr.environmentId&&t.projectId===Xr.projectId&&e.push(BN(t));return e},[Jn,Xr]),di=oe(e=>{if(!Xr||!W)return JL;let t=me(e,Xr),n=ui.length>0?[...t,...ui]:t;return si(n,{worktreeId:ci??null,worktreePath:li??null})}),fi=W?f(i(W.environmentId,W.id)):null,pi=(0,q.useCallback)(e=>{let t=s(e);t&&(ni(e),setTimeout(()=>{B({to:`/$environmentId/$threadId`,params:{environmentId:t.environmentId,threadId:t.threadId}})},0))},[B]);zN({activeWorktreeSessionTabs:di,activeSessionTabKey:fi}),(0,q.useEffect)(()=>{let e=In(r,a);if(c!==`server`)return e;let t=Ie(r,a);return()=>{e(),t()}},[r,c,a]);let mi=oe(eo(re)),hi=nt(),gi=et(e=>e.byId),_i=je(e=>e.byId),vi=W&&W.environmentId!==hi?gi[W.environmentId]??null:null,bi=vi?_i[vi.environmentId]??null:null,xi=vi?bi?.connectionState??`disconnected`:`connected`,Si=vi!==null&&xi!==`connected`,Ci=vi?.environmentId??null,Ti=vi?Nr({isPrimary:!1,environmentId:vi.environmentId,runtimeLabel:bi?.descriptor?.label??null,savedLabel:vi.label}):null,Ei=(0,q.useMemo)(()=>!Si||!Ti||!Ci?null:{environmentId:Ci,label:Ti,connectionState:xi===`connecting`||xi===`error`?xi:`disconnected`},[Si,Ti,xi,Ci]),[Di,Oi]=(0,q.useState)(null),ki=(0,q.useCallback)(async(e,t)=>{Oi(e);try{await Ke(e),Ai.add({type:`success`,title:`Environment reconnected`,description:`${t} is ready.`})}catch(e){Ai.add(As({type:`error`,title:`Could not reconnect environment`,description:e instanceof Error?e.message:`Failed to reconnect.`}))}finally{Oi(null)}},[]),ji=pe(e=>({sidebarProjectGroupingMode:e.sidebarProjectGroupingMode,sidebarProjectGroupingOverrides:e.sidebarProjectGroupingOverrides})),Mi=(0,q.useMemo)(()=>{if(!Qr)return[];let e=Ae(Qr,ji),t=mi.filter(t=>Ae(t,ji)===e),n=new Set,r=[];for(let e of t){if(n.has(e.environmentId))continue;n.add(e.environmentId);let t=e.environmentId===hi,i=gi[e.environmentId],a=_i[e.environmentId],o=N.machines.find(t=>t.environmentId===e.environmentId),s=P.machines.find(t=>t.environmentId===e.environmentId),c=P.status===`signed-out`?o:s,l=c?.label??Nr({isPrimary:t,environmentId:e.environmentId,runtimeLabel:a?.descriptor?.label??null,savedLabel:i?.label??null});r.push({environmentId:e.environmentId,projectId:e.id,label:l,isPrimary:t,...N.status===`ready`||P.status===`ready`?{disabled:c?.canMutate!==!0}:{}})}return r.sort((e,t)=>e.isPrimary===t.isPrimary?e.label.localeCompare(t.label):e.isPrimary?-1:1),r},[Qr,mi,N,P,ji,hi,gi,_i]),Ni=Mi.length>1,Pi=(0,q.useCallback)(e=>{fr&&on({initialReference:e??null,key:Date.now()})},[fr]),Fi=(0,q.useCallback)(()=>{on(null)},[]),Ii=(0,q.useCallback)(async e=>{if(!Qr)throw Error(`No active project is available for this pull request.`);let t=o(Qr.environmentId,Qr.id),n=Ae(Qr,ji),r=Me(n);if(r)return Ee(r.draftId,e),Fe(n,t,r.draftId,{threadId:r.threadId,...e}),(c!==`draft`||y!==r.draftId)&&await B({to:`/draft/$draftId`,params:Mn(r.draftId)}),r.threadId;let i=c===`draft`&&y?Pe(y):null;if(!ar&&i?.logicalProjectKey===n&&y)return Ee(y,e),Fe(n,t,y,{threadId:i.threadId,createdAt:i.createdAt,runtimeMode:i.runtimeMode,interactionMode:i.interactionMode,tokenMode:i.tokenMode??`balanced`,...e}),i.threadId;let a=to(),s=no();return Fe(n,t,a,{threadId:s,createdAt:new Date().toISOString(),runtimeMode:qt,interactionMode:rn,tokenMode:j.defaultAgentTokenMode??`balanced`,...e}),await B({to:`/draft/$draftId`,params:Mn(a)}),s},[Qr,y,Pe,Me,ar,B,ji,c,Ee,Fe,j.defaultAgentTokenMode]),Li=(0,q.useCallback)(async e=>{await Ii({branch:e.branch,worktreePath:e.worktreePath,envMode:e.worktreePath?`worktree`:`local`})},[Ii]);(0,q.useEffect)(()=>{if(!T?.id||!Yr||!qr?.completedAt)return;let e=Date.parse(qr.completedAt);if(Number.isNaN(e))return;let t=A?Date.parse(A):NaN;!Number.isNaN(t)&&t>=e||O(f(i(T.environmentId,T.id)),qr.completedAt)},[qr?.completedAt,A,Yr,O,T?.environmentId,T?.id]);let Ri=fe??null,Bi=W?.modelSelection.instanceId??Qr?.defaultModelSelection?.instanceId??null,Vi=xe(),Hi=je(e=>W?.environmentId?e.byId[W.environmentId]:null),Wi=hi&&W?.environmentId===hi?Vi:Hi?.serverConfig??Vi,Gi=Oe(Wi),Ki=Gi&&W?Ge(W.environmentId,Gi):null,[qi,Ji]=(0,q.useState)(null),Yi=Ki===qi||Re(Ki),Xi=Gi!==null&&Ki!==null&&!Yi,Zi=Object.keys(gi).length>0,Qi=(0,q.useMemo)(()=>{if(!Zi||!W)return`server`;let e=W.environmentId===hi,t=gi[W.environmentId],n=_i[W.environmentId];return`${Nr({isPrimary:e,environmentId:W.environmentId,runtimeLabel:n?.descriptor?.label??Wi?.environment.label??null,savedLabel:t?.label??null})} server`},[W,Zi,hi,gi,_i,Wi?.environment.label]),$i=(0,q.useMemo)(()=>{let e=[];return t.hosted&&!t.allowed&&e.push({id:`hosted-dispatch-unavailable`,variant:`warning`,icon:(0,Y.jsx)(Xa,{}),title:`Read-only hosted session`,description:t.reason??`Commands are unavailable on this connection.`}),Ei&&e.push({id:`environment-unavailable:${Ei.environmentId}`,variant:Ei.connectionState===`error`?`error`:`warning`,icon:(0,Y.jsx)(Aa,{}),title:(0,Y.jsxs)(Y.Fragment,{children:[Ei.label,` is`,` `,Ei.connectionState===`connecting`?`connecting`:`disconnected`]}),description:`Reconnect this environment before sending messages or running actions.`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(K,{size:`xs`,disabled:Ei.connectionState===`connecting`||Di===Ei.environmentId,onClick:()=>void ki(Ei.environmentId,Ei.label),children:Ei.connectionState===`connecting`||Di===Ei.environmentId?`Reconnecting...`:`Reconnect`}),(0,Y.jsx)(K,{size:`xs`,variant:`outline`,onClick:()=>V(`connections`),children:`Connections`})]})}),Xi&&Gi&&Ki&&e.push({id:`version-mismatch:${Ki}`,variant:`warning`,icon:(0,Y.jsx)(Xa,{}),title:`Client and server versions differ`,description:(0,Y.jsxs)(Y.Fragment,{children:[`Client `,Gi.clientVersion,` is connected to `,Qi,` `,Gi.serverVersion,`. Sync them if RPC calls or reconnects fail.`]}),dismissLabel:`Dismiss version mismatch warning`,onDismiss:()=>{Ve(Ki),Ji(Ki)}}),e},[t.allowed,t.hosted,t.reason,Ei,ki,V,Di,Xi,Gi,Ki,Qi]),ea=W!==void 0&&W.messages.length===0&&ct.length===0,ta=Wi?.providers??KL,na=(0,q.useRef)({key:``,snapshot:KL}),ra=(0,q.useMemo)(()=>$L(ta,na.current),[ta]),ia=W?.session?.providerInstanceId??null,aa=co(W?.session??null),oa=j.notifyOnTurnCompleteWhenUnfocused,sa=(0,q.useRef)(new Set),la=(0,q.useRef)(new Set);(0,q.useEffect)(()=>{let e=qr?.turnId;if(!e)return;if(aa===`running`){sa.current.add(e);return}if(!T?.id||!Yr||!qr?.completedAt||!sa.current.has(e)||la.current.has(e)||(la.current.add(e),!oa)||typeof document<`u`&&document.hasFocus())return;let t=typeof window<`u`?window.desktopBridge:void 0;if(!t?.notifyTurnComplete)return;let n=W?.title?.trim()?W.title:`Ryco`;t.notifyTurnComplete({threadId:T.id,environmentId:T.environmentId,title:n,body:`The agent finished responding.`}).catch(()=>void 0)},[aa,Yr,qr?.turnId,qr?.completedAt,oa,T?.id,T?.environmentId,W?.title]);let ua=W?.activities??GL,{workLogEntries:da,contextCompactionEntries:fa,contextHandoffEntries:pa,pendingApprovals:ma,pendingUserInputs:ha,activePlan:_a}=(0,q.useMemo)(()=>go(ua,qr?.turnId),[qr?.turnId,ua]),va=aa!==`disconnected`&&W?.session?.orchestrationStatus!==`stopped`&&W?.session?.orchestrationStatus!==`interrupted`&&W?.session?.orchestrationStatus!==`error`,ya=(0,q.useMemo)(()=>yo(ua,{sessionLive:va,parentTurnState:qr?.state??null}),[qr?.state,va,ua]),ba=(0,q.useMemo)(()=>ho({activities:ua,transcriptSubagents:ya,sessionLive:va}),[va,ua,ya]),{activePendingUserInput:xa,activePendingDraftAnswers:Sa,activePendingQuestionIndex:Ta,activePendingProgress:Ea,activePendingResolvedAnswers:Oa,activePendingIsResponding:ka,onSelectActivePendingUserInputOption:ja,onChangeActivePendingUserInputCustomAnswer:Ma,onAdvanceActivePendingUserInput:Na,onPreviousActivePendingUserInputQuestion:Pa}=fL({pendingUserInputs:ha,respondingUserInputRequestIds:Sr,readComposer:Ze,promptRef:ze,onRespondToUserInput:yr}),Fa=(0,q.useMemo)(()=>Yr?vo(W?.proposedPlans??[],qr?.turnId??null):null,[qr?.turnId,W?.proposedPlans,Yr]),Ia=(0,q.useMemo)(()=>lo({threads:Jr,latestTurn:qr,latestTurnSettled:Yr,threadId:W?.id??null}),[qr,W?.id,Yr,Jr]),La=`Overview`,Ra=ha.length===0&&lr===`plan`&&Yr&&uo(Fa),za=ma[0]??null,{beginLocalDispatch:Ba,resetLocalDispatch:Va,localDispatchStartedAt:Ha,isPreparingWorktree:Ua,isSendBusy:Wa}=wL({activeThread:W,activeLatestTurn:qr,phase:aa,activePendingApproval:za?.requestId??null,activePendingUserInput:xa?.requestId??null,threadError:W?.error}),Ga=(0,q.useMemo)(()=>W?.session?.provider??ta.find(e=>e.instanceId===W?.modelSelection.instanceId)?.driver??null,[W?.modelSelection.instanceId,W?.session?.provider,ta]),Ka=Dd(W),qa=W?.session?.orchestrationStatus??null,Ja=(0,q.useMemo)(()=>pn({threadStarted:Ka,canonicalProvider:Ga,phase:aa,orchestrationStatus:qa,isConnecting:At,isSendBusy:Wa,isPreparingWorktree:Ua,hasPendingApproval:ma.length>0,hasPendingUserInput:ha.length>0,hasQueuedMessage:Hr.length>0,isRevertingCheckpoint:Cr,mutationAllowed:t.allowed,environmentAvailable:!Si,isPhoneTier:Vt===`phone`}),[Si,Ka,Ga,t.allowed,At,Ua,Cr,Wa,ma.length,ha.length,aa,Vt,Hr.length,qa]),Ya=Ja.lockedProvider,Za=ta.find(e=>e.instanceId===Ri)?.driver??un(ta,Ri??Bi??M.make(`codex`)),Qa=Ya??Za,$a=aa===`running`||Wa||At||Cr,ao=oe(e=>ae(e,Ar)),so=!$a&&W?ao?.backgroundLiveness??null:null,[fo,mo]=(0,q.useState)(!1);(0,q.useEffect)(()=>{so===null&&mo(!1)},[so]),(0,q.useEffect)(()=>{mo(!1)},[hr]);let bo=(0,q.useCallback)(()=>{mo(!0),(async()=>{try{await _r()}catch(e){mo(!1),hr&&gr(hr,e instanceof Error?e.message:`Failed to stop background work.`)}})()},[hr,_r,gr]),xo=po(qr,W?.session??null,Ha),So=W?.messages,{attachmentPreviewHandoffByMessageId:Co,handoffAttachmentPreviews:Eo}=OL({serverMessages:So,optimisticUserMessagesRef:Dt}),Do=(0,q.useMemo)(()=>{let e=So??[],t=Object.keys(Co).length===0?e:e.map(e=>{if(e.role!==`user`||!e.attachments||e.attachments.length===0)return e;let t=Co[e.id];if(!t||t.length===0)return e;let n=!1,r=0,i=e.attachments.map(e=>{if(e.type!==`image`)return e;let i=t[r];return r+=1,!i||e.previewUrl===i?e:(n=!0,{...e,previewUrl:i})});return n?{...e,attachments:i}:e});if(ct.length===0)return t;let n=new Set(t.map(e=>e.id)),r=ct.filter(e=>!n.has(e.id));return r.length===0?t:[...t,...r]},[So,Co,ct]),ko=(0,q.useRef)({threadId:null,index:Bl()}),Ao=(0,q.useMemo)(()=>(ko.current.threadId!==hr&&(ko.current={threadId:hr,index:Bl()}),ko.current.index.update({messages:Do,proposedPlans:W?.proposedPlans??[],workEntries:da,contextCompactionEntries:fa,contextHandoffEntries:pa})),[hr,W?.proposedPlans,fa,pa,Do,da]),jo=Md({hasThread:W!==void 0,messageCount:W?.messages.length??0,optimisticMessageCount:ct.length,timelineEntryCount:Ao.length,presentationTier:Vt}),No=(0,q.useMemo)(()=>wa({timelineEntries:Ao,query:pt}),[pt,Ao]);(0,q.useEffect)(()=>{let e=Et.trim();if(!ut||!Ar||e.length<2){Tt([]);return}let t=Be(Ar.environmentId);if(!t){Tt([]);return}let n=!1;return t.orchestration.searchThreadMessages({query:e,threadId:Ar.threadId,limit:50}).then(e=>{n||Tt(e)}).catch(()=>{n||Tt([])}),()=>{n=!0}},[Ar,Et,ut]);let Po=(0,q.useMemo)(()=>{let e=new Set(No.map(e=>e.messageId)),t=[];for(let n of wt)e.has(n.messageId)||t.push({id:`server:${n.messageId}`,messageId:n.messageId,occurrenceIndex:No.length+t.length,messageOccurrenceIndex:0,start:0,end:0,text:pt.trim()});return[...No,...t]},[No,wt,pt]),Fo=(0,q.useMemo)(()=>{if(!ut)return new Map;let e=new Map;for(let t of Po){let n=e.get(t.messageId);n?n.push(t):e.set(t.messageId,[t])}return e},[Po,ut]),Io=Po.length,Lo=Da(yt,Io),Ro=Po[Lo]??null,zo=Ro?.messageId??null,Bo=(0,q.useCallback)(e=>{St(t=>({messageId:e,requestId:(t?.requestId??0)+1}))},[]);(0,q.useEffect)(()=>{bt(0)},[jr,pt]),(0,q.useEffect)(()=>{bt(e=>Da(e,Io))},[Io]),(0,q.useEffect)(()=>{if(!ut||!zo){St(null);return}Bo(zo)},[Bo,zo,ut]),(0,q.useEffect)(()=>{!ut||!zo||!Ar||!Mr||W?.messages.some(e=>e.id===zo)||Ne({environmentId:Ar.environmentId,threadId:Ar.threadId,messageId:zo,limit:101}).catch(()=>void 0)},[W?.messages,Mr,Ar,zo,ut]);let{turnDiffSummaries:Vo,inferredCheckpointTurnCountByTurnId:Ho}=ga(W),Uo=(0,q.useMemo)(()=>{let e=new Map;for(let t of Vo)t.assistantMessageId&&e.set(t.assistantMessageId,t);return e},[Vo]),Wo=(0,q.useMemo)(()=>xA({timelineEntries:Ao,turnDiffSummaryByAssistantMessageId:Uo,inferredCheckpointTurnCountByTurnId:Ho}),[Ho,Ao,Uo]),Go=(0,q.useMemo)(()=>SA({turnDiffSummaries:Vo,inferredCheckpointTurnCountByTurnId:Ho}),[Ho,Vo]),Ko=Qr?Ca({project:{cwd:Qr.cwd},worktreePath:W?.worktreePath??null}):null,qo=ie({environmentId:r,cwd:Ko}),Jo=$e(),{postPushWorkflowWatch:Yo,handlePostPush:Xo,clearWatch:Zo}=tL(),Qo=ve(),$o=z(),es=W?.session?.providerInstanceId??W?.modelSelection.instanceId??Qr?.defaultModelSelection?.instanceId??null,ts=(0,q.useMemo)(()=>{if(es)return ta.find(e=>e.instanceId===es)??null;let e=E(Qa);return ta.find(t=>t.instanceId===e)??null},[es,ta,Qa]);(0,q.useEffect)(()=>{if(c!==`server`||!Ko)return;let e=Er(r,Ko),t=Rn(r,Ko);return()=>{t(),e()}},[r,Ko,c]),(0,q.useEffect)(()=>{if(c!==`server`)return;let e=Dr(r,ts?.instanceId),t=Fn(r,ts?.instanceId);return()=>{t(),e()}},[ts?.instanceId,r,c]);let ns=Qr?.cwd??null,rs=W?.worktreePath??null,is=rs??ns??void 0,as=mn?.threadId===hr?mn:Gn??null,os=qo.data?.isRepo??!0,ss=(0,q.useMemo)(()=>({context:{terminalFocus:!0,terminalOpen:!!On.terminalOpen}}),[On.terminalOpen]),cs=(0,q.useMemo)(()=>wo(Qo,`terminal.toggle`),[Qo]),ls=(0,q.useMemo)(()=>wo(Qo,`terminal.split`,ss),[Qo,ss]),us=(0,q.useMemo)(()=>wo(Qo,`terminal.new`,ss),[Qo,ss]),ds=(0,q.useMemo)(()=>wo(Qo,`terminal.close`,ss),[Qo,ss]),{onOpenReviewPanel:fs,onToggleDiff:ps,onOpenFilesPanel:ms,onOpenTerminalPanel:hs,onOpenSimulatorPanel:gs,onToggleWorkspacePanel:_s,onOpenTurnDiff:vs,onCloseDiff:ys,onOpenAgentsPanel:bs,onOpenSubagentPanel:xs}=hL({navigate:B,environmentId:r,threadId:a,routeKind:c,draftId:y,isServerThread:ar,hasActiveProject:!!Qr,diffOpen:pr,workspacePanelOpen:mr,externalToggleWorkspacePanel:_,onDiffPanelOpen:l,onPreviewPanelOpen:u,onTerminalPanelOpen:p,onSimulatorPanelOpen:m,onAgentPanelOpen:g}),Ss=!!(W&&(W.messages.length>0||W.session!==null&&W.session.status!==`closed`)),Cs=(0,q.useCallback)(e=>{if(Ss||!y)return;let t=Mi.find(t=>t.environmentId===e);!t||t.disabled||Ee(y,{projectRef:o(t.environmentId,t.projectId)})},[y,Ss,Mi,Ee]),ws=P.status===`signed-out`?N.machines.find(e=>e.environmentId===r):P.machines.find(e=>e.environmentId===r),Ts=c===`draft`&&(N.status===`ready`||P.status===`ready`)&&ws?.canMutate!==!0,Es=((On.terminalGroups.find(e=>e.id===On.activeTerminalGroupId)??On.terminalGroups.find(e=>e.terminalIds.includes(On.activeTerminalId))??null)?.terminalIds.length??0)>=4,Ds=(0,q.useCallback)(()=>{Wt.current!==`phone`&&Ze()?.focusAtEnd()},[Ze]),Os=(0,q.useCallback)(()=>{window.requestAnimationFrame(()=>{Ds()})},[Ds]),ks=(0,q.useCallback)(()=>{hr&&(ft(!0),vt(e=>e+1))},[hr]),Ps=(0,q.useCallback)(()=>{ft(!1),St(null),Os()},[Os]),Is=(0,q.useCallback)(e=>{if(Io===0)return;let t=ca({currentIndex:Lo,matchCount:Io,direction:e});bt(t);let n=Po[t];n&&Bo(n.messageId)},[Bo,Lo,Io,Po]),Ls=(0,q.useCallback)(e=>{Ze()?.addTerminalContext(e)},[Ze]),zs=(0,q.useCallback)(e=>{Ar&&An(Ar,e)},[Ar,An]),Bs=(0,q.useCallback)(()=>{!Ar||!n.allowed||zs(!On.terminalOpen)},[Ar,zs,n.allowed,On.terminalOpen]),Vs=(0,q.useCallback)(()=>{if(!Ar||Es||!n.allowed)return;let e=`terminal-${io()}`;Nn(Ar,e),nn(e=>e+1)},[Ar,Es,Nn,n.allowed]),Hs=(0,q.useCallback)(()=>{if(!Ar||!n.allowed)return;let e=`terminal-${io()}`;Pn(Ar,e),nn(e=>e+1)},[Ar,Pn,n.allowed]),Us=(0,q.useCallback)(e=>{let t=Be(r);if(!hr||!t||!n.allowed)return;let i=On.terminalIds.length<=1,a=()=>t.terminal.write({threadId:hr,terminalId:e,data:`exit
|
|
27
|
-
`}).catch(()=>void 0);`close`in t.terminal&&typeof t.terminal.close==`function`?(async()=>{i&&await t.terminal.clear({threadId:hr,terminalId:e}).catch(()=>void 0),await t.terminal.close({threadId:hr,terminalId:e,deleteHistory:!0})})().catch(()=>a()):a(),Ar&&Vn(Ar,e),nn(e=>e+1)},[hr,Ar,r,Vn,On.terminalIds.length,n.allowed]),{runProjectScript:Ws,saveProjectScript:Gs,updateProjectScript:Ks,deleteProjectScript:qs}=DL({environmentId:r,activeThread:W,activeThreadId:hr,activeThreadRef:Ar,activeProject:Qr,gitCwd:Ko,terminalState:On,setLastInvokedScriptByProjectId:xn,setTerminalLaunchContext:hn,setTerminalOpen:zs,storeNewTerminal:Pn,storeSetActiveTerminal:Bn,setTerminalFocusRequestId:nn,setThreadError:gr}),Js=(0,q.useCallback)(e=>{e!==cr&&(Se(w,e),dr&&Ee(w,{runtimeMode:e}),Os())},[dr,cr,Os,w,Se,Ee]),Ys=(0,q.useCallback)(e=>{e!==lr&&(Ce(w,e),dr&&Ee(w,{interactionMode:e}),Os())},[lr,dr,Os,w,Ce,Ee]),Xs=(0,q.useCallback)(e=>{e!==ur&&(we(w,e),dr&&Ee(w,{tokenMode:e}),Os())},[w,dr,Os,we,Ee,ur]),Zs=(0,q.useCallback)(()=>{if(Qt)return;let e=Ht(ta,Qa);Ys(lr==="default"?`plan`:lr===`plan`&&e?`ask`:`default`)},[Qt,Ys,lr,ta,Qa]),Qs=(0,q.useCallback)(e=>{Nt(e),$t.current=e?null:_a?.turnId??Ia?.turnId??`__dismissed__`},[_a?.turnId,Ia?.turnId]),$s=(0,q.useCallback)(()=>{Rt(!1),Qs(!1)},[Qs]),ec=(0,q.useCallback)(e=>{if(mr){let t=typeof e==`boolean`?e:!It;Rt(t),Qs(t),t&&Ft(!0);return}let t=typeof e==`boolean`?e:jo&&!Pt?!0:!Mt;Rt(!1),Qs(t),Ft(t)},[jo,It,Pt,Mt,Qs,mr]),tc=(0,q.useCallback)(async e=>{if(!T)return;let t=Be(r);t&&(e.runtimeMode!==T.runtimeMode&&await t.orchestration.dispatchCommand({type:`thread.runtime-mode.set`,commandId:ro(),threadId:e.threadId,runtimeMode:e.runtimeMode,createdAt:e.createdAt}),e.interactionMode!==T.interactionMode&&await t.orchestration.dispatchCommand({type:`thread.interaction-mode.set`,commandId:ro(),threadId:e.threadId,interactionMode:e.interactionMode,createdAt:e.createdAt}),e.tokenMode!==(T.tokenMode??`balanced`)&&await t.orchestration.dispatchCommand({type:`thread.token-mode.set`,commandId:ro(),threadId:e.threadId,tokenMode:e.tokenMode,createdAt:e.createdAt}))},[r,T]),nc=(0,q.useCallback)(async e=>{if(!T||!t.allowed)return!1;let n=Be(r);if(!n)return!1;try{return await n.orchestration.dispatchCommand({type:`thread.goal.set`,commandId:ro(),threadId:T.id,...e,createdAt:new Date().toISOString()}),!0}catch(e){return Ai.add(As({type:`error`,title:`Could not update goal`,description:e instanceof Error?e.message:`The goal update failed.`})),!1}},[t.allowed,r,T]),rc=(0,q.useCallback)(()=>{let e=T?.goal?.objective;if(!e)return;let t=`/goal ${e}`;ze.current=t,he(w,t),Ze()?.resetCursorState({prompt:t,cursor:t.length,detectTrigger:!1}),Os()},[w,Ze,Os,T?.goal?.objective,he]),ic=(0,q.useCallback)(e=>{nc({status:e})},[nc]),ac=(0,q.useCallback)(()=>{if(!T||!t.allowed)return;let e=Be(r);e&&e.orchestration.dispatchCommand({type:`thread.goal.clear`,commandId:ro(),threadId:T.id,createdAt:new Date().toISOString()}).catch(e=>{Ai.add(As({type:`error`,title:`Could not clear goal`,description:e instanceof Error?e.message:`The goal could not be cleared.`}))})},[t.allowed,r,T]),oc=(0,q.useCallback)((e=!1)=>{Tn(!0),Sn.current?.scrollToEnd?.({animated:e})},[]),sc=(0,q.useCallback)(()=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{Sn.current?.scrollToEnd?.({animated:!1})})})},[]),cc=(0,q.useCallback)(()=>{Tn(!1)},[]),lc=(0,q.useCallback)(()=>{Tn(!0)},[]),uc=(0,q.useRef)(new ht(()=>at(!0),{wait:150})),dc=(0,q.useCallback)(e=>{Cn.current!==e&&(Cn.current=e,e?(uc.current.cancel(),at(!1)):uc.current.maybeExecute())},[]);(0,q.useEffect)(()=>{on(null),Cn.current=!0,Tn(!0),uc.current.cancel(),at(!1);let e=en.current;en.current=!1,Nt(e||!Gt.current&&Wt.current!==`phone`),$t.current=null},[W?.id]),(0,q.useEffect)(()=>{if(!te||!_a||Mt)return;let e=qr?.turnId??null;if(e&&_a.turnId!==e)return;let t=_a.turnId??Ia?.turnId??`__dismissed__`;if($t.current!==t){if(Wt.current===`phone`){let e=document.activeElement;if(e instanceof HTMLElement&&e.closest(`[data-chat-composer-form="true"]`)!==null){$t.current=t;return}}Nt(!0)}},[_a,qr?.turnId,te,Mt,Ia?.turnId]),(0,q.useEffect)(()=>{if(!W?.id||On.terminalOpen)return;let e=window.requestAnimationFrame(()=>{Ds()});return()=>{window.cancelAnimationFrame(e)}},[W?.id,Ds,On.terminalOpen]),(0,q.useEffect)(()=>{if(!W?.id||W.messages.length===0)return;let e=new Set(W.messages.map(e=>e.id)),t=ct.filter(t=>e.has(t.id));if(t.length===0)return;let n=window.setTimeout(()=>{lt(t=>t.filter(t=>!e.has(t.id)))},0);for(let e of t){let t=yd(e);if(t.length>0){Eo(e.id,t);continue}vd(e)}return()=>{window.clearTimeout(n)}},[W?.id,W?.messages,Eo,ct]),(0,q.useEffect)(()=>{lt(e=>{for(let t of e)vd(t);return[]}),Va(),st(null)},[y,Va,a]);let fc=(0,q.useCallback)(()=>{st(null)},[]),pc=W?.worktreePath??null,mc=kr({activeWorktreePath:pc,hasServerThread:ar,draftThreadEnvMode:dr?Le?.envMode:void 0}),hc=!!(ar&&W&&W.messages.length===0&&W.worktreePath===null&&!Ss),gc=hc&&gn!==void 0?gn:W?.branch??null,{sourceControlActions:_c,branchControl:vc}=nL({gitCwd:Ko,activeThreadRef:Ar,routeKind:c,draftId:y,onPostPush:Xo,branchControlThread:W?{environmentId:W.environmentId,id:W.id}:null,isGitRepo:os,canOverrideServerThreadBranch:hc,activeThreadBranch:gc,onActiveThreadBranchOverrideChange:_n,envLocked:Ss,onComposerFocusRequest:Os,canCheckoutPullRequestIntoThread:fr,onCheckoutPullRequestRequest:Pi}),yc=bd({requestedEnvMode:mc,isGitRepo:os});(0,q.useEffect)(()=>{_n(void 0)},[W?.id]),(0,q.useEffect)(()=>{hc||_n(void 0)},[hc]),(0,q.useEffect)(()=>{if(!hr){hn(null),Kn(b);return}hn(e=>!e||e.threadId===hr?e:null)},[hr,b,Kn]),(0,q.useEffect)(()=>{!hr||!ns||hn(e=>!e||e.threadId!==hr?e:Ca({project:{cwd:ns},worktreePath:rs})===e.cwd&&(rs??null)===e.worktreePath?(Ar&&Kn(Ar),null):e)},[ns,hr,Ar,rs,Kn]),(0,q.useEffect)(()=>{!hr||!ns||!Gn||Ca({project:{cwd:ns},worktreePath:rs})===Gn.cwd&&(rs??null)===Gn.worktreePath&&Ar&&Kn(Ar)},[ns,hr,Ar,rs,Kn,Gn]),(0,q.useEffect)(()=>{On.terminalOpen||(Ar&&Kn(Ar),hn(e=>e?.threadId===hr?null:e))},[hr,Ar,Kn,On.terminalOpen]),(0,q.useEffect)(()=>{if(!jr)return;let e=Dn.current[jr]??!1,t=!!On.terminalOpen;if(!e&&t){Dn.current[jr]=t,nn(e=>e+1);return}if(e&&!t){Dn.current[jr]=t;let e=window.requestAnimationFrame(()=>{Ds()});return()=>{window.cancelAnimationFrame(e)}}Dn.current[jr]=t},[jr,Ds,On.terminalOpen]),(0,q.useEffect)(()=>{let e=e=>{!hr||e.defaultPrevented||To(e,Qo,{context:{terminalFocus:Ns(),terminalOpen:!!On.terminalOpen,modelPickerOpen:Ze()?.isModelPickerOpen()??!1}})===`thread.find`&&(rR(e)||(e.preventDefault(),e.stopPropagation(),ks()))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[hr,Qo,ks,Ze,On.terminalOpen]),(0,q.useEffect)(()=>{let e=e=>{e.defaultPrevented||Mo(e)&&!ln.current||Oo(e,`p`,{shiftKey:!0})&&(e.preventDefault(),e.stopPropagation(),fn(`prs`),cn(e=>!e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]);let bc=(0,q.useCallback)(()=>{fn(`prs`),cn(!0)},[]);uL({activeThreadId:hr,keybindings:Qo,terminalOpen:On.terminalOpen,activeTerminalId:On.activeTerminalId,readComposer:Ze,activeProject:Qr,toggleTerminalVisibility:Bs,splitTerminal:Vs,closeTerminal:Us,createNewTerminal:Hs,setTerminalOpen:zs,onToggleDiff:ps,onOpenFilesPanel:ms,onOpenReviewPanel:fs,onOpenTerminalPanel:hs,onOpenSimulatorPanel:gs,runProjectScript:Ws});let xc=(0,q.useCallback)(async e=>{await br({thread:W??null,turnCount:e,environmentUnavailable:Si,environmentUnavailableLabel:Ti,turnInProgress:aa===`running`||Wa||At})},[Si,Ti,W,At,Wa,aa,br]),Sc=(0,q.useCallback)(e=>W?Lt({threadStarted:Ka,policy:Ja,canonicalSelection:W.modelSelection,targetSelection:e}):!1,[W,Ka,Ja]),Cc=(0,q.useCallback)(()=>{Ai.add(As({type:`warning`,title:`Wait for the thread to become idle`,description:Ja.reason===`phone-tier`?`Provider switching stays on the current provider in the web phone view.`:`The staged provider or model was not sent. Try again when this thread is idle.`}))},[Ja.reason]),wc=(0,q.useCallback)(e=>{let n=W?.session?.providerInstanceId,r=n?ra.find(e=>e.instanceId===n):void 0,i=W?.tokenMode??`balanced`,a=W?.interactionMode??`default`;return Je({mutationReady:t.allowed&&!Si,turnRunning:aa===`running`,activeTurnId:W?.session?.activeTurnId,supportsTurnSteering:r?.supportsTurnSteering===!0,queuedModelSelection:e.composer.selectedModelSelection,activeModelSelection:W?.modelSelection,queuedRuntimeMode:e.settings.runtimeMode,activeRuntimeMode:W?.runtimeMode,queuedInteractionMode:e.settings.interactionMode,activeInteractionMode:a,queuedTokenMode:e.settings.tokenMode,activeTokenMode:i})},[Si,W,ra,t.allowed,aa]),Tc=(0,q.useCallback)(e=>{let t=wc(e);return t.allowed?null:t.reason},[wc]),Ec=(0,q.useCallback)(async e=>{if(!jr||!W)return;let t=wc(e);if(!t.allowed){Ai.add(As({type:`warning`,title:`Cannot steer this message`,description:t.reason}));return}let n=Be(r);if(n){Br(jr,e.id);try{let r=RL({composer:e.composer,formatOutgoingPrompt:eR}),i=fu(e.composer.sourceControlContexts),a=i?`${i}\n\n${r}`:r,o=await zL(e.composer.images),s=new Date().toISOString();await n.orchestration.dispatchCommand(ke({commandId:ro(),threadId:W.id,expectedTurnId:t.expectedTurnId,messageId:h.make(e.id),text:a,attachments:o,createdAt:e.createdAt??s,requestedAt:s}))}catch(t){Vr(jr,e.id),Ai.add(As({type:`error`,title:`Could not steer message`,description:t instanceof Error?t.message:`The steer request failed.`}))}}},[W,jr,Br,Vr,r,wc]);(0,q.useEffect)(()=>{if(!jr||Ur.length===0)return;let e=new Set(W?.messages.map(e=>String(e.id))??[]);for(let t of Ur)e.has(t)&&Wr(t)},[W?.messages,jr,Wr,Ur]),(0,q.useEffect)(()=>{if(!jr||Ur.length===0)return;let e=new Set(ua.flatMap(e=>{if(e.kind!==`provider.turn.steer.failed`||!e.payload)return[];let t=e.payload.messageId;return typeof t==`string`?[t]:[]}));for(let t of Ur)e.has(t)&&Vr(jr,t)},[jr,Vr,Ur,ua]);let Dc=async(e,n,a)=>{if(!t.allowed)return!1;let o=Be(r);if(!o||!W||!Qr)return!1;if(!Sc(e.selectedModelSelection))return Cc(),!1;let s=await ud({api:o,threadId:W.id,prompt:e.prompt}).catch(()=>({requested:!1,image:null}));if(s.image)e.images.length<8?e={...e,images:[...e.images,s.image]}:(URL.revokeObjectURL(s.image.previewUrl),Ai.add(As({type:`warning`,title:`The simulator screenshot was skipped`,description:`This message already has 8 attachments.`})));else if(s.requested){let e=s.reason===`no-attached-device`?`Open the Simulator workspace and choose a device first.`:s.reason===`device-not-booted`?`The selected simulator is still starting.`:`The current simulator screen could not be attached.`;Ai.add(As({type:`warning`,title:`Couldn’t attach the simulator screen`,description:e}))}let c=Qt?{...n,interactionMode:rn}:n,l=W.id,u=!ar||W.messages.length===0,{shouldMaterializeLegacyBranchWorktree:d,baseBranchForWorktree:f,shouldCreateWorktree:p}=xd({isServerThread:ar,isFirstMessage:u,threadWorktreePath:W.worktreePath,activeThreadBranch:gc,currentGitRefName:qo.data?.refName??null,sendEnvMode:yc}),m=u&&yc===`worktree`?Le?.worktreeSource??null:null;if(m&&!o.git.createWorktreeForProject)return gr(l,`Worktree creation is unavailable in this environment.`),!1;let h=null,g=async()=>{let e=o.git.createWorktreeForProject;if(!m||!e||!Qr)return null;let t=await e({projectId:Qr.id,intent:m.kind===`pr`?{kind:`pr`,number:m.number}:m.kind===`issue`?{kind:`issue`,number:m.number,title:m.title}:{kind:`workItem`,provider:m.provider,key:m.key,title:m.title,...m.state?{state:m.state}:{},...m.stateName?{stateName:m.stateName}:{},...m.url?{url:m.url}:{}}});return h=i(r,t.sessionId),{threadId:t.sessionId,isServerThread:!0,isFirstMessage:!0}};return p&&!gc&&!m?(gr(l,`Select a base branch before sending in New worktree mode.`),!1):(await BL({...a===void 0?{}:{messageId:a},composer:e,thread:{threadId:l,isFirstMessage:u,isServerThread:ar,isLocalDraftThread:dr&&!m,activeThreadBranch:gc,worktreePath:W.worktreePath,createdAt:W.createdAt,projectId:Qr.id},worktree:m?{shouldMaterializeLegacyBranchWorktree:!1,baseBranchForWorktree:null,shouldCreateWorktree:!1}:{shouldMaterializeLegacyBranchWorktree:d,baseBranchForWorktree:f,shouldCreateWorktree:p},settings:c,project:{projectId:Qr.id,projectCwd:Qr.cwd,defaultModelSelection:Qr.defaultModelSelection??null},...m?{prepareForDispatch:g}:{},scroll:{scrollToEndBeforeOptimistic:async()=>{Cn.current=!0,Tn(!0),uc.current.cancel(),at(!1),await Sn.current?.scrollToEnd?.({animated:!1})},scrollToEndAfterOptimistic:sc},draft:{composerDraftTarget:w,environmentId:r,clearComposerDraftContent:Te,setComposerDraftTokenMode:we,setComposerDraftPrompt:he,addComposerDraftImages:_e,setComposerDraftTerminalContexts:ye,setDraftThreadContext:Ee},dispatch:{api:o,beginLocalDispatch:Ba,resetLocalDispatch:Va,setOptimisticUserMessages:lt,setThreadError:gr},refs:{promptRef:ze,composerImagesRef:Ue,composerTerminalContextsRef:We,sendInFlightRef:En},sourceControl:{fetcher:async e=>{let t=Ko;if(!t)return e;let n=R(new Date),i=R(new Date(Date.now()+3e5));if(e.kind===`issue`){let a=await Jo.fetchQuery(wi({environmentId:r,cwd:t,reference:String(e.detail.number)}));return{...e,detail:a,fetchedAt:n,staleAfter:i}}let a=await Jo.fetchQuery(yi({environmentId:r,cwd:t,reference:String(e.detail.number)}));return{...e,detail:a,fetchedAt:n,staleAfter:i}}},persistSettings:{persistThreadSettingsForNextTurn:tc},composerHandle:{readComposer:Ze},formatOutgoingPrompt:eR}),h&&(y&&De(y),await B({to:`/$environmentId/$threadId`,params:jn(h),replace:!0})),!0)},Oc=(0,q.useRef)(Dc);Oc.current=Dc;let kc=async e=>{if(e?.preventDefault(),!t.allowed||!Be(r)||!W||Wa&&aa!==`running`||At||Si||En.current)return;if(Ea){Na();return}let n=Ze()?.getSendContext();if(!n)return;let{images:i,terminalContexts:a,sourceControlContexts:o,selectedProvider:s,selectedModel:c,selectedProviderModels:l,selectedPromptEffort:u,selectedModelSelection:d}=n,f=ze.current,{trimmedPrompt:p,sendableTerminalContexts:m,expiredTerminalContextCount:h,hasSendableContent:g}=wd({prompt:f,imageCount:i.length,terminalContexts:a}),_=i.length===0&&m.length===0?Ct(p):null;if(_!==null){if(!T){Ai.add({type:`warning`,title:`Start the thread first`,description:`A goal can be attached after the thread has been created.`});return}if(_.length===0){Ai.add({type:`warning`,title:`Describe the goal`,description:`Use /goal followed by the outcome you want this thread to pursue.`});return}if(_.length>4e3){Ai.add({type:`warning`,title:`Goal is too long`,description:`Keep the objective under ${C.toLocaleString()} characters.`});return}await nc({objective:_})&&(ze.current=``,Te(w),we(w,ur),Ze()?.resetCursorState());return}if(Ra&&Fa){let e=vu({draftText:p,planMarkdown:Fa.planMarkdown});ze.current=``,Te(w),we(w,ur),Ze()?.resetCursorState(),await Mc({text:e.text,interactionMode:e.interactionMode});return}let v=i.length===0&&m.length===0?dt(p):null;if(v){Ys(v),ze.current=``,Te(w),we(w,ur),Ze()?.resetCursorState();return}if(!g){if(h>0){let e=Td(h,`empty`);Ai.add(As({type:`warning`,title:e.title,description:e.description}))}return}let y={prompt:f,trimmedPrompt:p,images:i,sendableTerminalContexts:m,sourceControlContexts:o,selectedProvider:s,selectedModel:c,selectedProviderModels:l,selectedPromptEffort:u,selectedModelSelection:d,expiredTerminalContextCount:h},b={runtimeMode:cr,interactionMode:lr,tokenMode:ur};if(!Sc(y.selectedModelSelection)){Cc();return}if(aa===`running`&&jr){let e=oo();Ir(jr,{id:e,createdAt:new Date().toISOString(),composer:{...y,images:y.images.map(Cd)},settings:b}),ze.current=``,Te(w),we(w,ur),Ze()?.resetCursorState();return}await Oc.current(y,b)},Ac=(0,q.useRef)(kc);Ac.current=kc;let jc=(0,q.useCallback)(e=>{Ac.current(e)},[]);(0,q.useEffect)(()=>{if(!jr)return;let e=jr,n=Hr[0];n&&t.allowed&&($a||Si||Ea||za||En.current||Ur.includes(n.id)||Oc.current(n.composer,n.settings,h.make(n.id)).then(t=>{t&&zr(e)}))},[jr,Hr,$a,Si,Ea,za,t.allowed,zr,Ur]);let Mc=(0,q.useCallback)(async({text:e,interactionMode:t})=>{let n=Be(r);if(!n||!W||!ar||Wa||At||En.current)return;let a=e.trim();if(!a)return;let o=Ze()?.getSendContext();if(!o)return;let{selectedProvider:s,selectedModel:c,selectedProviderModels:l,selectedPromptEffort:u,selectedModelSelection:d}=o;if(!Sc(d)){Cc();return}let f=W.id,p=oo(),m=new Date().toISOString(),h=eR({provider:s,model:c,models:l,effort:u,text:a});En.current=!0,Ba({preparingWorktree:!1}),gr(f,null),Cn.current=!0,Tn(!0),uc.current.cancel(),at(!1),await Sn.current?.scrollToEnd?.({animated:!1}),lt(e=>[...e,{id:p,role:`user`,text:h,createdAt:m,streaming:!1}]),sc();try{await tc({threadId:f,createdAt:m,runtimeMode:cr,interactionMode:t,tokenMode:ur}),Ce(i(W.environmentId,f),t),we(i(W.environmentId,f),ur),await n.orchestration.dispatchCommand({type:`thread.turn.start`,commandId:ro(),threadId:f,message:{messageId:p,role:`user`,text:h,attachments:[]},modelSelection:d,titleSeed:W.title,runtimeMode:cr,interactionMode:t,tokenMode:ur,...t==="default"&&Fa?{sourceProposedPlan:{threadId:W.id,planId:Fa.id}}:{},createdAt:m}),t==="default"&&te&&($t.current=null,Nt(!0)),En.current=!1}catch(e){lt(e=>e.filter(e=>e.id!==p)),gr(f,e instanceof Error?e.message:`Failed to send plan follow-up.`),En.current=!1,Va()}},[W,Fa,Ba,Sc,At,Wa,ar,Cc,tc,Ze,Va,cr,sc,Ce,we,gr,te,r,ur]),Nc=(0,q.useCallback)(async()=>{let e=Be(r);if(!e||!W||!Qr||!Fa||!ar||Wa||At||Si||En.current)return;let t=Ze()?.getSendContext();if(!t)return;let{selectedProvider:n,selectedModel:a,selectedProviderModels:o,selectedPromptEffort:s,selectedModelSelection:c}=t,l=new Date().toISOString(),u=no(),d=Fa.planMarkdown,f=eR({provider:n,model:a,models:o,effort:s,text:_u(d)}),p=cu(yu(d)),m=c;En.current=!0,Ba({preparingWorktree:!1});let h=()=>{En.current=!1,Va()};await e.orchestration.dispatchCommand({type:`thread.create`,commandId:ro(),threadId:u,projectId:Qr.id,title:p,modelSelection:m,runtimeMode:cr,interactionMode:`default`,tokenMode:ur,branch:gc,worktreePath:W.worktreePath,createdAt:l}).then(()=>e.orchestration.dispatchCommand({type:`thread.turn.start`,commandId:ro(),threadId:u,message:{messageId:oo(),role:`user`,text:f,attachments:[]},modelSelection:c,titleSeed:p,runtimeMode:cr,interactionMode:`default`,tokenMode:ur,sourceProposedPlan:{threadId:W.id,planId:Fa.id},createdAt:l})).then(()=>kd(i(W.environmentId,u))).then(()=>(en.current=te,B({to:`/$environmentId/$threadId`,params:{environmentId:W.environmentId,threadId:u}}))).catch(async t=>{await e.orchestration.dispatchCommand({type:`thread.delete`,commandId:ro(),threadId:u}).catch(()=>void 0),Ai.add(As({type:`error`,title:`Could not start implementation thread`,description:t instanceof Error?t.message:`An error occurred while creating the new thread.`}))}).then(h,h)},[Qr,Fa,gc,W,Ba,Si,At,Wa,ar,B,Ze,Va,cr,ur,te,r]),Pc=(0,q.useCallback)((e,t)=>{if(!W)return;let n=ta.find(t=>t.instanceId===e);if(!n||!n.enabled||!n.installed||n.status!==`ready`||n.availability===`unavailable`){Os();return}let r=n?.driver??null;if(Ja.mode===`continuation-only`&&Ya===null){Os();return}if(Ya!==null&&r!==null&&r!==Ya){Os();return}if(Ya!==null&&W.session?.providerInstanceId){let e=ta.find(e=>e.instanceId===W.session?.providerInstanceId);if(e?.continuation?.groupKey&&n?.continuation?.groupKey&&e.continuation.groupKey!==n.continuation.groupKey){Os();return}}let a=gt(e,j,ta,t);if(!a){Os();return}let o={instanceId:e,model:a};if(!Lt({threadStarted:Ka,policy:Ja,canonicalSelection:W.modelSelection,targetSelection:o})){Os();return}be(i(W.environmentId,W.id),o),Dd(W)||F(o);let s=vn(lr,n.supportsAskMode??!1);s!==lr&&Ys(s),Os()},[W,Ka,Ys,lr,Ya,Ja,Os,be,F,ta,j]),Fc=(0,q.useCallback)(e=>{st(e)},[]),Ic=(0,q.useRef)(Wo);Ic.current=Wo;let Lc=(0,q.useRef)(xc);Lc.current=xc;let Rc=(0,q.useCallback)(e=>{let t=Ic.current.get(e);typeof t==`number`&&Lc.current(t)},[]),zc=(0,q.useCallback)(e=>{Lc.current(e)},[]);(0,q.useEffect)(()=>{mr||Rt(!1)},[mr]),(0,q.useEffect)(()=>{Rt(!1),Ft(!1)},[W?.id]);let Bc=Mt&&!mr&&!(jo&&!Pt),Vc=It&&mr,Hc=Bc||Vc,Uc=Vt===`phone`,Gc=Bc&&!zt&&!Uc,Jc=Bc&&(zt||Uc),Yc=Cu(Vc,Bt||!mr?0:260),Xc=Cu(Gc,Bt||zt||mr?0:320),Zc=(0,q.useMemo)(()=>!Uc||!W?null:{environmentId:W.environmentId,threadId:W.id,title:W.title,projectCwd:Ko,branch:$r?.branch??W.branch??null,draft:c===`draft`&&y?{draftId:y,projectId:W.projectId,createdAt:W.createdAt}:null,workspacePanelOpen:mr,onToggleWorkspacePanel:_s,onOpenFindInThread:ks,onOpenSourceControl:c===`draft`?null:()=>ec(!0),sessionTabs:di,activeSessionTabKey:fi,onSelectSessionTab:pi},[fi,W,di,$r?.branch,y,Ko,pi,Uc,_s,ks,c,ec,mr]),Qc=Vt!==`phone`&&!jo,$c=Vt!==`phone`,el=(0,q.useRef)(null),tl=(0,q.useRef)(null),nl=(0,q.useRef)(null),rl=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let e=el.current;if(!e)return;if(!Qc){e.style.removeProperty(`--chat-composer-clearance`);return}let t=tl.current;if(!t)return;let n=()=>e.style.setProperty(`--chat-composer-clearance`,`${t.offsetHeight+8}px`);n();let r=new ResizeObserver(n);return r.observe(t),()=>{r.disconnect(),e.style.removeProperty(`--chat-composer-clearance`)}},[Qc,hr]),(0,q.useEffect)(()=>{let e=nl.current;if(!e)return;if(!$c){e.style.removeProperty(`--chat-header-clearance`);return}let t=rl.current;if(!t)return;let n=()=>e.style.setProperty(`--chat-header-clearance`,`${t.offsetHeight+8}px`);n();let r=new ResizeObserver(n);return r.observe(t),()=>{r.disconnect(),e.style.removeProperty(`--chat-header-clearance`)}},[$c,hr]),W?(0,Y.jsxs)(`div`,{ref:nl,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background`,children:[(0,Y.jsx)(`header`,{ref:rl,className:G(`border-b phone:pt-safe`,$c?`app-chrome-glass border-sidebar-border`:`border-border bg-muted/24`,$c&&`absolute inset-x-0 top-0 z-20`,Wn,d?G(`drag-region flex min-h-[52px] items-stretch pr-3 sm:pr-5 wco:min-h-[env(titlebar-area-height)]`,Ut?Un:`pl-3 sm:pl-5`,v&&`wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]`):G(`pr-[calc(env(safe-area-inset-right)+0.75rem)] sm:pr-[calc(env(safe-area-inset-right)+1.25rem)]`,Ut?Un:`pl-[calc(env(safe-area-inset-left)+0.75rem)] sm:pl-[calc(env(safe-area-inset-left)+1.25rem)]`)),children:Vt===`phone`?(0,Y.jsx)(PN,{environmentId:W.environmentId,threadId:W.id,title:W.title}):(0,Y.jsx)(NN,{activeThreadEnvironmentId:W.environmentId,activeThreadTitle:W.title,activeProjectName:Qr?.name,isGitRepo:os,openInCwd:Ko,activeProjectScripts:Qr?.scripts,preferredScriptId:Qr?bn[Qr.id]??null:null,keybindings:Qo,availableEditors:$o,worktreeBranch:$r?.branch??W.branch??null,worktreeTitle:$r?.title??null,worktreeOrigin:$r?.origin??null,worktreeIssueNumber:$r?.issueNumber??null,worktreeIssueState:$r?.issueState??null,worktreePrNumber:$r?.prNumber??null,worktreePrState:$r?.prState??null,worktreePrIsDraft:$r?.prIsDraft??null,worktreeWorkItemProvider:$r?.workItemProvider??null,worktreeWorkItemKey:$r?.workItemKey??null,worktreeWorkItemState:$r?.workItemState??null,worktreeWorkItemStateName:$r?.workItemStateName??null,onOpenLinkedWorktreeItem:ai,workspacePanelOpen:mr,liveAgentCount:pd({liveCount:ba.liveCount,workspacePanelOpen:mr,workspaceTab:H.workspaceTab}),onToggleWorkspacePanel:_s,overviewSidebarOpen:Hc,onToggleOverviewSidebar:ec,onRunProjectScript:Ws,onAddProjectScript:Gs,onUpdateProjectScript:Ks,onDeleteProjectScript:qs})}),(0,Y.jsx)(zi,{open:ei!==null,item:ei,environmentId:Qr?.environmentId??W.environmentId,projectId:Qr?.id??W.projectId,cwd:Qr?.cwd??Ko,onOpenChange:oi}),(0,Y.jsx)(`div`,{className:G($c&&`absolute inset-x-0 top-(--chat-header-clearance,0px) z-20`),children:(0,Y.jsx)(UN,{status:ts})}),(0,Y.jsx)(WN,{error:W.error,threadRef:Ar,onDismiss:()=>gr(W.id,null)}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{ref:el,className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[jo?null:sr?(0,Y.jsx)(yj,{agentPanelModel:ba,onOpenAgents:bs,isWorking:$a,activeTurnInProgress:$a||!Yr,activeTurnId:qr?.turnId??null,latestTurn:qr,activeTurnStartedAt:xo,listRef:Sn,targetMessageId:xt?.messageId??H.messageId??null,targetMessageRequestId:xt?.requestId??0,targetMessageRowHighlight:xt===null,threadMessageSearchQuery:ut?pt:``,threadMessageSearchOccurrencesByMessageId:Fo,activeThreadMessageSearchOccurrence:ut?Ro:null,timelineEntries:Ao,turnDiffSummaryByAssistantMessageId:Uo,activeThreadEnvironmentId:W.environmentId,routeThreadKey:S,openDiffTurnId:pr?H.diffTurnId??null:null,onOpenTurnDiff:vs,onCloseDiff:ys,revertTurnCountByUserMessageId:Wo,undoTurnCountByTurnId:Go,onUndoTurn:zc,onRevertUserMessage:Rc,isRevertingCheckpoint:Cr,onImageExpand:Fc,markdownCwd:Ko??void 0,resolvedTheme:U,timestampFormat:L,workspaceRoot:is,skills:ts?.skills??qL,liveFollowEnabled:wn,onIsAtEndChange:dc,onManualNavigation:cc,onUserReachedEnd:lc,canLoadOlder:Mr?.hasMoreBefore??!1,isLoadingOlder:Pr?.status===`loading`,loadOlderError:Pr?.error??null,onLoadOlder:Fr,...Vt===`phone`?{}:{onInspectContextHandoff:Xt}},W.id):(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`flex min-h-0 flex-1`}),ut?(0,Y.jsx)(cN,{query:pt,focusRequestId:_t,matchCount:Io,selectedIndex:Lo,onQueryChange:mt,onNext:()=>Is(`next`),onPrevious:()=>Is(`previous`),onClose:Ps}):null,Yc?(0,Y.jsx)(eL,{animate:!Bt,open:Vc,children:(0,Y.jsx)(rL,{environmentId:r,gitCwd:Ko,activeWorktreeBranch:$r?.branch??null,activeThreadBranch:W?.branch??null,activeWorktreePrNumber:$r?.prNumber??null,activeWorktreePrState:$r?.prState,activeWorktreePrIsDraft:$r?.prIsDraft,activeWorktreeTitle:$r?.title,postPushWorkflowWatch:Yo,activeThreadKey:jr,activeEnvironmentUnavailableState:Ei,activePlan:_a,sidebarProposedPlan:Ia,threadSubagents:ya,changedFileSummaries:W?.turnDiffSummaries,sourceControlActions:_c,branchControl:vc,markdownCwd:Ko??void 0,workspaceRoot:is,mode:`floating`,onClose:$s,onOpenFiles:ms,onOpenReview:fs,onOpenSubagent:xs,onPostPushDiscoveryComplete:Zo})}):null,rt&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute bottom-[calc(var(--chat-composer-clearance,0px)+0.25rem)] left-1/2 z-30 flex -translate-x-1/2 justify-center py-1.5`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>oc(!0),className:`pointer-events-auto flex items-center gap-1.5 rounded-full border-0 bg-card/80 px-3 py-1 text-muted-foreground text-xs shadow-md/5 ring-1 ring-inset ring-foreground/6 backdrop-blur transition-[background-color,color,box-shadow] hover:bg-card hover:text-foreground hover:shadow-lg/8 hover:cursor-pointer`,children:[(0,Y.jsx)(Zr,{className:`size-3.5`}),`Scroll to bottom`]})})]}),jo?(0,Y.jsx)(`div`,{className:G(`shrink-0`,!Bt&&`animate-in fade-in slide-in-from-bottom-1`),children:(0,Y.jsx)(zM,{projectName:Qr?.name??null,activeProjectId:Qr?.id??null,activeProjectEnvironmentId:Qr?.environmentId??null,routeKind:c,envLocked:Ss,draftId:y??void 0,workLocation:os?(0,Y.jsx)($M,{draftId:y??void 0,environmentId:W.environmentId,threadId:W.id,projectId:Qr?.id??null,projectEnvironmentId:Qr?.environmentId??null,projectName:Qr?.name??null,envLocked:Ss,availableEnvironments:Mi,onEnvironmentChange:Ni?Cs:void 0,onComposerFocusRequest:Os,onCheckoutPullRequestRequest:fr?Pi:void 0,cwd:Qr?.cwd??Ko}):null})}):null,(0,Y.jsxs)(`div`,{ref:tl,className:G(`flex min-h-0 flex-col justify-end`,Qc&&`pointer-events-none absolute inset-x-0 bottom-0 z-20`,`pl-[calc(env(safe-area-inset-left)+0.75rem)] pr-[calc(env(safe-area-inset-right)+0.75rem)] pt-1.5 sm:pl-[calc(env(safe-area-inset-left)+1.25rem)] sm:pr-[calc(env(safe-area-inset-right)+1.25rem)] sm:pt-2`,os?`pb-[calc(max(env(safe-area-inset-bottom),var(--app-keyboard-inset,0px))+0.25rem)]`:`pb-[calc(max(env(safe-area-inset-bottom),var(--app-keyboard-inset,0px))+0.75rem)] sm:pb-[calc(max(env(safe-area-inset-bottom),var(--app-keyboard-inset,0px))+1rem)]`),children:[Qc?(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`-top-10 -z-10 pointer-events-none absolute inset-x-0 bottom-0 bg-linear-to-t from-background via-background/45 to-transparent`}):null,(0,Y.jsxs)(`div`,{className:G(`relative isolate`,Qc&&`pointer-events-auto`),children:[so!==null&&Vt!==`phone`?(0,Y.jsx)(`div`,{className:`mx-auto mb-2 flex w-full min-w-0 max-w-208 items-center px-4`,children:(0,Y.jsx)(id,{liveness:so,liveCount:ba.liveCount,stopping:fo,onStop:bo})}):null,(0,Y.jsx)(SP,{className:`relative z-0`,items:$i}),Vt===`phone`?null:(0,Y.jsx)(gP,{environmentId:r,activeThreadId:hr}),ea?(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`mb-2 h-5`}):null,(0,Y.jsx)(UL,{messages:Hr,onRemove:Wr,onMove:Gr,showSteerAction:Vt!==`phone`,steeringIds:Ur,getSteerUnavailableReason:Tc,onSteer:e=>void Ec(e)}),(0,Y.jsx)(`div`,{className:`relative z-10`,children:(0,Y.jsx)(yO,{ref:Ye,composerDraftTarget:w,environmentId:r,routeKind:c,routeThreadRef:b,draftId:y,activeThreadId:hr,activeThreadEnvironmentId:W?.environmentId,activeThreadSessionProviderInstanceId:ia,activeThreadStarted:Ka,isServerThread:ar,isLocalDraftThread:dr,activeThreadGoal:T?.goal??null,phase:aa,isConnecting:At,isSendBusy:Wa||!t.allowed||Ts,isPreparingWorktree:Ua,environmentUnavailable:Ei,activePendingApproval:za,pendingApprovals:ma,pendingUserInputs:ha,activePendingProgress:Ea,activePendingResolvedAnswers:Oa,activePendingIsResponding:ka,activePendingDraftAnswers:Sa,activePendingQuestionIndex:Ta,respondingRequestIds:xr,showPlanFollowUpPrompt:Ra,activeProposedPlan:Fa,activePlan:_a,sidebarProposedPlan:Ia,planSidebarLabel:La,planSidebarOpen:Hc,runtimeMode:cr,interactionMode:lr,tokenMode:ur,lockedProvider:Ya,providerStatuses:ra,activeProjectDefaultModelSelection:Qr?.defaultModelSelection,activeThreadModelSelection:W?.modelSelection,activeThreadActivities:ua,phoneThreadDock:Zc,resolvedTheme:U,settings:j,keybindings:Qo,terminalOpen:!!On.terminalOpen,gitCwd:Ko,executionTargets:Mi,executionTargetLocked:Ss||c===`server`,onExecutionTargetChange:Cs,promptRef:ze,composerImagesRef:Ue,composerTerminalContextsRef:We,shouldAutoScrollRef:Cn,scheduleStickToBottom:oc,onSend:jc,onInterrupt:_r,onImplementPlanInNewThread:Nc,onRespondToApproval:vr,onSelectActivePendingUserInputOption:ja,onAdvanceActivePendingUserInput:Na,onPreviousActivePendingUserInputQuestion:Pa,onChangeActivePendingUserInputCustomAnswer:Ma,onProviderModelSelect:Pc,toggleInteractionMode:Zs,handleRuntimeModeChange:Js,handleInteractionModeChange:Ys,handleTokenModeChange:Xs,togglePlanSidebar:ec,focusComposer:Ds,scheduleComposerFocus:Os,setThreadError:gr,onExpandImage:Fc,onEditGoal:rc,onGoalStatusChange:ic,onClearGoal:ac})})]}),os&&(0,Y.jsx)(`div`,{className:G(Qc&&`pointer-events-auto`),children:(0,Y.jsx)(nd,{environmentId:W.environmentId,threadId:W.id,...c===`draft`&&y?{draftId:y}:{},...hc?{activeThreadBranchOverride:gc,onActiveThreadBranchOverrideChange:_n}:{},envLocked:Ss,onComposerFocusRequest:Os,onOpenWorktreeSources:bc,contextControlsHoisted:jo,...fr?{onCheckoutPullRequestRequest:Pi}:{},...Ni?{onEnvironmentChange:Cs}:{},availableEnvironments:Mi,terminalAvailable:Qr!==void 0&&n.allowed,terminalOpen:On.terminalOpen,terminalToggleShortcutLabel:cs,onToggleTerminal:Bs,terminalCount:On.terminalIds.length})})]}),jo?(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`min-h-0 flex-1`}):null,an?(0,Y.jsx)(HO,{open:!0,environmentId:W.environmentId,projectId:Qr?.id??null,threadId:W.id,cwd:Qr?.cwd??null,initialReference:an.initialReference,onOpenChange:e=>{e||Fi()},onPrepared:Li},an.key):null,(0,Y.jsx)(Ui,{open:sn,environmentId:W.environmentId,projectId:Qr?.id??null,cwd:Qr?.cwd??null,initialTab:dn,onCreated:e=>{B({to:`/$environmentId/$threadId`,params:{environmentId:W.environmentId,threadId:e.sessionId}})},onOpenChange:cn})]}),Kt&&!zt&&!Uc?(0,Y.jsx)(`aside`,{className:`flex min-h-0 w-[25rem] shrink-0 border-l border-border pt-[var(--chat-header-clearance,0px)]`,children:(0,Y.jsx)(VO,{environmentId:W.environmentId,threadId:W.id,marker:Kt.marker,onClose:Zt})}):Xc?(0,Y.jsx)($I,{animate:!Bt,open:Gc,children:(0,Y.jsx)(rL,{environmentId:r,gitCwd:Ko,activeWorktreeBranch:$r?.branch??null,activeThreadBranch:W?.branch??null,activeWorktreePrNumber:$r?.prNumber??null,activeWorktreePrState:$r?.prState,activeWorktreePrIsDraft:$r?.prIsDraft,activeWorktreeTitle:$r?.title,postPushWorkflowWatch:Yo,activeThreadKey:jr,activeEnvironmentUnavailableState:Ei,activePlan:_a,sidebarProposedPlan:Ia,threadSubagents:ya,changedFileSummaries:W?.turnDiffSummaries,sourceControlActions:_c,branchControl:vc,markdownCwd:Ko??void 0,workspaceRoot:is,mode:`sidebar`,onOpenFiles:ms,onOpenReview:fs,onOpenSubagent:xs,onPostPushDiscoveryComplete:Zo})}):null]}),er.map(({key:e,threadRef:t})=>(0,Y.jsx)(xO,{threadRef:t,threadId:t.threadId,visible:e===jr&&On.terminalOpen&&n.allowed,launchContext:e===jr?as??null:null,focusRequestId:e===jr?tn:0,splitShortcutLabel:ls??void 0,newShortcutLabel:us??void 0,closeShortcutLabel:ds??void 0,keybindings:Qo,onAddTerminalContext:Ls},e)),!Uc&&zt&&Kt?(0,Y.jsx)(WL,{open:!0,onClose:Zt,children:(0,Y.jsx)(VO,{environmentId:W.environmentId,threadId:W.id,marker:Kt.marker,onClose:Zt})}):null,Uc?(0,Y.jsx)(IN,{label:La,open:Jc,onClose:$s,children:(0,Y.jsx)(LN,{title:La,backLabel:`Back to thread`,onBack:$s,children:(0,Y.jsx)(rL,{environmentId:r,gitCwd:Ko,activeWorktreeBranch:$r?.branch??null,activeThreadBranch:W?.branch??null,activeWorktreePrNumber:$r?.prNumber??null,activeWorktreePrState:$r?.prState,activeWorktreePrIsDraft:$r?.prIsDraft,activeWorktreeTitle:$r?.title,postPushWorkflowWatch:Yo,activeThreadKey:jr,activeEnvironmentUnavailableState:Ei,activePlan:_a,sidebarProposedPlan:Ia,threadSubagents:ya,changedFileSummaries:W?.turnDiffSummaries,sourceControlActions:_c,branchControl:vc,markdownCwd:Ko??void 0,workspaceRoot:is,mode:`sheet`,onOpenFiles:ms,onOpenReview:fs,onOpenSubagent:xs,onPostPushDiscoveryComplete:Zo})})}):zt?(0,Y.jsx)(WL,{open:Jc,onClose:$s,children:(0,Y.jsx)(rL,{environmentId:r,gitCwd:Ko,activeWorktreeBranch:$r?.branch??null,activeThreadBranch:W?.branch??null,activeWorktreePrNumber:$r?.prNumber??null,activeWorktreePrState:$r?.prState,activeWorktreePrIsDraft:$r?.prIsDraft,activeWorktreeTitle:$r?.title,postPushWorkflowWatch:Yo,activeThreadKey:jr,activeEnvironmentUnavailableState:Ei,activePlan:_a,sidebarProposedPlan:Ia,threadSubagents:ya,changedFileSummaries:W?.turnDiffSummaries,sourceControlActions:_c,branchControl:vc,markdownCwd:Ko??void 0,workspaceRoot:is,mode:`sheet`,onOpenFiles:ms,onOpenReview:fs,onOpenSubagent:xs,onPostPushDiscoveryComplete:Zo})}):null,ot&&(0,Y.jsx)(AO,{preview:ot,onClose:fc})]}):(0,Y.jsx)(qc,{})}var aR=(0,q.lazy)(()=>n(()=>import(`./ThreadWorkspacePanel-CktVSliZ.js`),__vite__mapDeps([0]))),oR=`chat_diff_sidebar_width`,sR=`clamp(24rem,34vw,36rem)`,cR=352,lR=896,uR=360,dR=`w-5 cursor-ew-resize after:w-px after:bg-border/50 hover:after:bg-border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-0`,fR=208;function pR(e){return{...Hn(e),diff:void 0,diffTurnId:void 0,diffFilePath:void 0,preview:void 0,workspaceOpen:void 0,workspaceTab:void 0,workspaceAgentKey:void 0}}var mR=e=>{let t=(0,J.c)(6),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Y.jsx)(ya,{}),t[0]=n):n=t[0];let r;t[1]===e.label?r=t[2]:(r=(0,Y.jsx)(xa,{label:e.label}),t[1]=e.label,t[2]=r);let i;return t[3]!==e.mode||t[4]!==r?(i=(0,Y.jsx)(la,{mode:e.mode,header:n,children:r}),t[3]=e.mode,t[4]=r,t[5]=i):i=t[5],i};function hR(e){let t=(0,J.c)(11),[n,r]=(0,q.useState)(!e.animate&&e.open),i,a;t[0]!==e.animate||t[1]!==e.open?(i=()=>{if(!e.animate){r(e.open);return}if(!e.open){r(!1);return}let t=window.requestAnimationFrame(()=>r(!0));return()=>window.cancelAnimationFrame(t)},a=[e.animate,e.open],t[0]=e.animate,t[1]=e.open,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,q.useEffect)(i,a);let o=e.animate?e.open&&n:e.open,s=!e.open||void 0,c=!e.open||void 0,l=o?`translate-x-0 opacity-100`:`translate-x-4 opacity-0`,u;t[4]===l?u=t[5]:(u=G(`flex min-h-0 w-full flex-1 transition-[translate,opacity] duration-[300ms] ease-[cubic-bezier(0.16,1,0.3,1)] will-change-transform motion-reduce:transition-none`,l),t[4]=l,t[5]=u);let d;return t[6]!==e.children||t[7]!==s||t[8]!==c||t[9]!==u?(d=(0,Y.jsx)(`div`,{"aria-hidden":s,inert:c,className:u,children:e.children}),t[6]=e.children,t[7]=s,t[8]=c,t[9]=u,t[10]=d):d=t[10],d}var gR=e=>{let t=(0,J.c)(15),n=e.panelMode===`review`?`Loading diff viewer...`:e.panelMode===`files`?`Loading file preview...`:e.panelMode===`terminal`?`Loading terminal...`:e.panelMode===`simulator`?`Loading simulator...`:e.panelMode===`agents`?`Loading agents...`:e.panelMode===`agent`?`Loading subagent thread...`:`Loading workspace...`,r;t[0]!==e.mode||t[1]!==n?(r=(0,Y.jsx)(mR,{mode:e.mode,label:n}),t[0]=e.mode,t[1]=n,t[2]=r):r=t[2];let i=e.maximized??!1,a=e.reserveChromeInset??!1,o;t[3]!==e.mode||t[4]!==e.onClosePanelTab||t[5]!==e.onToggleMaximized||t[6]!==e.openedAgentKeys||t[7]!==e.openedPanelModes||t[8]!==e.panelMode||t[9]!==i||t[10]!==a?(o=(0,Y.jsx)(aR,{mode:e.mode,panelMode:e.panelMode,openedPanelModes:e.openedPanelModes,openedAgentKeys:e.openedAgentKeys,onClosePanelTab:e.onClosePanelTab,maximized:i,onToggleMaximized:e.onToggleMaximized,reserveChromeInset:a}),t[3]=e.mode,t[4]=e.onClosePanelTab,t[5]=e.onToggleMaximized,t[6]=e.openedAgentKeys,t[7]=e.openedPanelModes,t[8]=e.panelMode,t[9]=i,t[10]=a,t[11]=o):o=t[11];let s;return t[12]!==r||t[13]!==o?(s=(0,Y.jsx)(sa,{children:(0,Y.jsx)(q.Suspense,{fallback:r,children:o})}),t[12]=r,t[13]=o,t[14]=s):s=t[14],s},_R=e=>{let t=(0,J.c)(41),{maximized:n,open:r,onClose:i,onOpen:a,panelMode:o,renderContent:s}=e,c=ri(Fs),l=Cu(r,c?0:uR),u;t[0]===l?u=t[1]:(u=Ps({active:l,containIntrinsicSize:`28rem 100vh`}),t[0]=l,t[1]=u);let d=u,f;t[2]!==i||t[3]!==a?(f=e=>{if(e){a();return}i()},t[2]=i,t[3]=a,t[4]=f):f=t[4];let p=f,m=vR,h;t[5]!==n||t[6]!==r?(h=G(`min-h-0 bg-transparent`,n?`min-w-0 flex-1`:G(`flex-none transition-[width] duration-[360ms] ease-[cubic-bezier(0.16,1,0.3,1)] motion-reduce:transition-none`,r?`w-(--sidebar-width)`:`w-0`)),t[5]=n,t[6]=r,t[7]=h):h=t[7];let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g={"--sidebar-width":sR},t[8]=g):g=t[8];let _;t[9]!==n||t[10]!==r?(_=G(`border-l border-border bg-card text-foreground`,n?`translate-x-0`:G(`transition-[translate,width] duration-[360ms] ease-[cubic-bezier(0.16,1,0.3,1)] motion-reduce:transition-none`,r?`translate-x-0`:`pointer-events-none translate-x-full`)),t[9]=n,t[10]=r,t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v={maxWidth:lR,minWidth:cR,shouldAcceptWidth:m,storageKey:oR},t[12]=v):v=t[12];let y=!c,b;t[13]!==n||t[14]!==o||t[15]!==e.onClosePanelTab||t[16]!==e.onToggleMaximized||t[17]!==e.openedAgentKeys||t[18]!==e.openedPanelModes||t[19]!==e.reserveChromeInset||t[20]!==s||t[21]!==l?(b=s&&l?(0,Y.jsx)(gR,{mode:`sidebar`,panelMode:o,openedPanelModes:e.openedPanelModes,openedAgentKeys:e.openedAgentKeys,onClosePanelTab:e.onClosePanelTab,maximized:n,onToggleMaximized:e.onToggleMaximized,reserveChromeInset:e.reserveChromeInset}):null,t[13]=n,t[14]=o,t[15]=e.onClosePanelTab,t[16]=e.onToggleMaximized,t[17]=e.openedAgentKeys,t[18]=e.openedPanelModes,t[19]=e.reserveChromeInset,t[20]=s,t[21]=l,t[22]=b):b=t[22];let x;t[23]!==d||t[24]!==b?(x=(0,Y.jsx)(`div`,{className:`flex min-h-0 w-full flex-1`,style:d,children:b}),t[23]=d,t[24]=b,t[25]=x):x=t[25];let S;t[26]!==r||t[27]!==y||t[28]!==x?(S=(0,Y.jsx)(hR,{animate:y,open:r,children:x}),t[26]=r,t[27]=y,t[28]=x,t[29]=S):S=t[29];let C;t[30]===n?C=t[31]:(C=n?null:(0,Y.jsx)(zs,{"aria-label":`Resize workspace panel`,className:dR,title:`Drag to resize workspace panel`}),t[30]=n,t[31]=C);let w;t[32]!==n||t[33]!==C||t[34]!==_||t[35]!==S?(w=(0,Y.jsxs)(Vs,{side:`right`,collapsible:`offcanvas`,maximized:n,className:_,resizable:v,children:[S,C]}),t[32]=n,t[33]=C,t[34]=_,t[35]=S,t[36]=w):w=t[36];let T;return t[37]!==p||t[38]!==w||t[39]!==h?(T=(0,Y.jsx)(Bs,{defaultOpen:!1,open:!0,onOpenChange:p,className:h,style:g,children:w}),t[37]=p,t[38]=w,t[39]=h,t[40]=T):T=t[40],T};function vR(e){let{nextWidth:t,wrapper:n}=e,r=document.querySelector(`[data-chat-composer-form='true']`);if(!r)return!0;let i=r.parentElement;if(!i)return!0;let a=n.style.getPropertyValue(`--sidebar-width`);n.style.setProperty(`--sidebar-width`,`${t}px`);let o=window.getComputedStyle(i),s=Number.parseFloat(o.paddingLeft)||0,c=Number.parseFloat(o.paddingRight)||0,l=Math.max(0,i.clientWidth-s-c),u=r.getBoundingClientRect(),d=r.querySelector(`[data-chat-composer-footer='true']`),f=r.querySelector(`[data-chat-composer-actions='right']`)?.getBoundingClientRect().width??0,p=d&&(Number.parseFloat(window.getComputedStyle(d).columnGap)||Number.parseFloat(window.getComputedStyle(d).gap))||0,m=fR+f+p,h=r.scrollWidth>r.clientWidth+.5,g=u.width>l+.5,_=r.clientWidth+.5<m;return a.length>0?n.style.setProperty(`--sidebar-width`,a):n.style.removeProperty(`--sidebar-width`),!h&&!g&&!_}export{WL as a,Od as c,ru as d,Zl as f,ql as g,Kl as h,iR as i,ou as l,Gl as m,_R as n,IN as o,Wl as p,pR as r,Dd as s,gR as t,au as u};
|