local-operator-ui 0.57.2 → 0.57.3
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/out/main/index.js +124 -7
- package/out/preload/index.js +25 -7
- package/out/renderer/assets/{_basePickBy-CkpAAO6S.js → _basePickBy-BeAzmqgq.js} +1 -1
- package/out/renderer/assets/{_baseUniq-u-agm62p.js → _baseUniq-Clx9gdFs.js} +1 -1
- package/out/renderer/assets/{agent-details-page-ldvl1N_6.js → agent-details-page-BMztNR89.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-CzX9q829.js → agent-hub-page-quUNNwcr.js} +1 -1
- package/out/renderer/assets/{agents-page-Car3j2Yp.js → agents-page-BTYHgMAf.js} +3 -3
- package/out/renderer/assets/{appearance-Cs1cmmXP.js → appearance-DCqlsN7S.js} +6 -6
- package/out/renderer/assets/{approvalsOverlay-X94PALoM.js → approvalsOverlay-BxwEca1y.js} +1 -1
- package/out/renderer/assets/{arc-BYiPoX8t.js → arc-BOZHzyJm.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DLjq8CZ0.js → architectureDiagram-IEHRJDOE-CpE8Siol.js} +1 -1
- package/out/renderer/assets/{avatar-cropper-8lHILQQo.js → avatar-cropper-BWJE7j7A.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-CCwA1fYB.js → blockDiagram-JOT3LUYC-D4LTtQ_H.js} +1 -1
- package/out/renderer/assets/{book-open-gN5NGmEk.js → book-open-fa_DaJBq.js} +1 -1
- package/out/renderer/assets/browser-page-AgwdXhLM.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-D0MMfl2O.js → browser-webauthn-prompt-VC7pNm9O.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-7uFTm2ZA.js → c4Diagram-VJAJSXHY-DRtUDXOF.js} +1 -1
- package/out/renderer/assets/channel-DMQl-cpj.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-Dto4mCOM.js → chunk-4BMEZGHF-Cw4VudrA.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-VPHjX20y.js → chunk-A2AXSNBT-0JOiKMb-.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-Cbz0GPQs.js → chunk-AEK57VVT-CAKCg9DA.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-XGhv_ezv.js → chunk-D6G4REZN-CFZ2DTGX.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-DSiUCa5w.js → chunk-RZ5BOZE2-CupwUHva.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-B0DxcSxw.js → chunk-XZIHB7SX-B1vcbFku.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DJsxDWD8.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DJsxDWD8.js +1 -0
- package/out/renderer/assets/clone-B9GxWhWi.js +1 -0
- package/out/renderer/assets/{console-mirror-Du9Cwm9t.js → console-mirror-IB35kNI8.js} +1 -1
- package/out/renderer/assets/{consoleCapture-BJORZIj0.js → consoleCapture-D4G96kDb.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-WpEjb9aG.js → conversation-input-sync-DlorrZ6B.js} +5 -5
- package/out/renderer/assets/{dagre-OKDRZEBW-sM3z9HUa.js → dagre-OKDRZEBW-CunvCCGM.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-CgOb7R2k.js → diagram-SSKATNLV-DlpXMePq.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DbVc8xXd.js → diagram-VNBRO52H-CtgMK6MT.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-TSxVIxOX.js → erDiagram-Q7BY3M3F-C-QNezLB.js} +1 -1
- package/out/renderer/assets/{error-boundary-CTG7hrrI.js → error-boundary-C1x5W-AX.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-Cqxg2ABh.js → flowDiagram-4HSFHLVR-DjwRYw0E.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-DCQUmhya.js → ganttDiagram-APWFNJXF-Tb5F1KXD.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BfuP7Xlp.js → gitGraphDiagram-7IBYFJ6S-BokP9Y1T.js} +1 -1
- package/out/renderer/assets/{graph-CWbHIULM.js → graph-DEHYXN6b.js} +1 -1
- package/out/renderer/assets/{heart-DO1T8X1C.js → heart-DqMMtrJ1.js} +1 -1
- package/out/renderer/assets/{index-dka8FW5R.js → index-BWQzFq0n.js} +1 -1
- package/out/renderer/assets/index-BnqyWEPM.css +1 -0
- package/out/renderer/assets/{index-BXnmoGxM.js → index-Buuz619t.js} +178 -178
- package/out/renderer/assets/{index-CyPPdUQq.js → index-CJ8BPUHQ.js} +1 -1
- package/out/renderer/assets/{index-qhYHvOTU.js → index-D7fnBkIK.js} +1 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-bdAhVGkO.js +2 -0
- package/out/renderer/assets/{inline-error-boundary-Dl-my4ee.js → inline-error-boundary-ChbTvdIh.js} +1 -1
- package/out/renderer/assets/{installer-CqRpemT_.js → installer-Bplg-bpo.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-CZSzzTfE.js → journeyDiagram-U35MCT3I-BfXoBW-2.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-JDn5Etaq.js → kanban-definition-NDS4AKOZ-BeT3LOJG.js} +1 -1
- package/out/renderer/assets/{layout-BVY06uZz.js → layout-B71SsWep.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-CK5i5r9m.js → legacy-agents-page-BaSX_kru.js} +1 -1
- package/out/renderer/assets/{library-page-D5mJW5w9.js → library-page-BwmVBhNJ.js} +3 -3
- package/out/renderer/assets/{log-in-BtrQ-uFl.js → log-in-C4tjIXzF.js} +1 -1
- package/out/renderer/assets/{mermaid.core-DyOJXgnf.js → mermaid.core-D7wfsRjY.js} +5 -5
- package/out/renderer/assets/{mesh-page-DKmN2cUs.js → mesh-page-DbC0RmVo.js} +1 -1
- package/out/renderer/assets/{messages-DEk5v9-I.js → messages-B7aIuFuF.js} +9 -9
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DMKmIV2d.js → mindmap-definition-ALO5MXBD-BPTOzHuL.js} +1 -1
- package/out/renderer/assets/{mini-BVOAEtrk.js → mini-DXMqE-0u.js} +1 -1
- package/out/renderer/assets/{notebook-pen-C2m21lW6.js → notebook-pen-CQdB2BC5.js} +1 -1
- package/out/renderer/assets/{notifications-page-DllLf-Mx.js → notifications-page-C9PU2typ.js} +1 -1
- package/out/renderer/assets/{org-access-C1LmC5QU.js → org-access-Fw38H9fZ.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-N1nQoy_C.js → org-surface-gate-CKBjFWJL.js} +1 -1
- package/out/renderer/assets/{page-header-BE4EUy8r.js → page-header-CAW9G_fb.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-DpswQBn6.js → pieDiagram-IB7DONF6-C0JN0KMq.js} +1 -1
- package/out/renderer/assets/{projects-page-DPltfj6k.js → projects-page-D9F4QotN.js} +1 -1
- package/out/renderer/assets/{publication-validation-CHMryQwz.js → publication-validation-DygSOQkj.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-C8q54QlE.js → quadrantDiagram-7GDLP6J5-BRgjFQlM.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-CgQaQ4QP.js → radar-MK3ICKWK-VE0niGVF.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-DoUZ5jOc.js → radient-auth-buttons-CXMLVkUO.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-Dyrv3VAu.js → requirementDiagram-KVF5MWMF-DkwJBmMi.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-CNEvckl5.js → sankeyDiagram-QLVOVGJD-DFv3zh8B.js} +1 -1
- package/out/renderer/assets/schedules-page-aTbxrD_M.js +115 -0
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DeOCt35P.js → sequenceDiagram-X6HHIX6F-BXcr3er8.js} +1 -1
- package/out/renderer/assets/{settings-page-Czps85Y1.js → settings-page-DWZ3Mguh.js} +1 -1
- package/out/renderer/assets/{smartart-8ZXfpZbU.js → smartart-CWBh1X_F.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-BnN0kFCN.js → stateDiagram-DGXRK772-Cw08neDd.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BtazAv7-.js +1 -0
- package/out/renderer/assets/{team-bridge-page-BVJP-Gyq.js → team-bridge-page-BHAdGSZS.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-CecYCV3I.js → timeline-definition-BDJGKUSR-B-ZFBehC.js} +1 -1
- package/out/renderer/assets/{use-default-on-banner-BQGiegDV.js → use-default-on-banner-C8DUslhy.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-_yRuWSqj.js → use-download-agent-mutation-DMGaSxDK.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-D_gZ9O7j.js → xychartDiagram-VJFVF3MP-BGB8PPzY.js} +1 -1
- package/out/renderer/browser-approvals-overlay.html +2 -2
- package/out/renderer/console-capture.html +6 -6
- package/out/renderer/index.html +8 -8
- package/out/renderer/installer.html +5 -5
- package/out/renderer/mini.html +7 -7
- package/package.json +1 -1
- package/out/renderer/assets/browser-page-BmtzPNyp.js +0 -1
- package/out/renderer/assets/channel-DDmXL0fB.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-CyDUcev3.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-CyDUcev3.js +0 -1
- package/out/renderer/assets/clone-S08t9Xt4.js +0 -1
- package/out/renderer/assets/index-C353PzEb.css +0 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-D0MyLVLo.js +0 -2
- package/out/renderer/assets/schedules-page-DhitlPyE.js +0 -115
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-0RUTziKL.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-
|
|
2
|
-
import{r as $,b as te,h as lEe,j as d,c as X,i as gA,g as Bn,J as due,l as fue,n as $A,u as cEe,K as iw,f as gn,t as hue}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CJ8BPUHQ.js","./index-BWQzFq0n.js","./messages-B7aIuFuF.js","./index-BnqyWEPM.css","./appearance-DCqlsN7S.js","./roles-D1pcbxAx.js","./error-boundary-C1x5W-AX.js","./index-D7fnBkIK.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-D7wfsRjY.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as $,b as te,h as lEe,j as d,c as X,i as gA,g as Bn,J as due,l as fue,n as $A,u as cEe,K as iw,f as gn,t as hue}from"./index-BWQzFq0n.js";import{bu as uEe,f6 as BG,f7 as OEe,f8 as dEe,br as fEe,f9 as hEe,fa as HG,fb as pEe,bs as pue,u as ga,bA as mEe,fc as gEe,fd as $Ee,O as zr,fe as mue,ff as Cv,fg as yEe,b3 as vEe,fh as bEe,fi as wEe,fj as xEe,f as yu,aa as gue,fk as SEe,fl as KG,fm as QEe,fn as _Ee,fo as kEe,Q as vn,fp as Sn,ay as Ba,fq as uf,cp as nk,fr as j3,as as oS,c1 as $ue,N as ju,fs as PEe,m as St,r as ei,y as TEe,w as Si,au as YO,ft as XEe,d as kn,A as fn,a as dr,h as ni,ax as REe,j as Te,bQ as yA,c5 as yue,k as To,fu as vue,ab as V$,fv as rk,c3 as EEe,c4 as bue,ew as qEe,ai as zv,l as Av,i as ur,I as It,a7 as jEe,o as CEe,fw as zEe,az as AEe,fx as UEe,fy as WEe,dS as NEe,dR as YEe,dW as m2,dT as GEe,b$ as wue,fz as IEe,fA as ZEe,fB as DEe,fC as VEe,fD as MEe,eW as LEe,dX as FEe,aw as vO,fE as ik,fF as Np,fG as vA,fH as BEe,fI as JG,J as Fn,fJ as eI,dM as wr,fK as xue,fL as Sue,aB as ka,bq as bA,fM as HEe,fN as KEe,fO as JEe,fP as eqe,fQ as tqe,fR as sS,fS as Que,fT as M$,fU as nqe,fV as tI,aR as Of,fW as rqe,fX as Uv,fY as iqe,fZ as aqe,f_ as oqe,f$ as sqe,g0 as _ue,g1 as kue,aP as jc,g2 as lqe,g3 as cqe,g4 as uqe,cx as Oqe,cv as dqe,g5 as fqe,g6 as hqe,g7 as pqe,dA as Vs,g8 as Ms,g9 as tu,ga as Kn,gb as mqe,gc as lS,gd as gqe,a_ as $qe,bl as g2,ge as yqe,gf as vqe,gg as bqe,gh as wqe,gi as xqe,gj as wA,gk as Sqe,M as Qqe,eb as xA,co as Pue,aV as Tue,aZ as _qe,aY as kqe,ar as SA,gl as Xue,gm as Pqe,gn as Tqe,go as Xqe,gp as Rqe,gq as Rue,gr as Eqe,gs as qqe,gt as jqe,gu as nI,gv as rI,gw as iI,gx as Cqe,gy as zqe,gz as Aqe,gA as Uqe,gB as Wqe,gC as Nqe,gD as Yqe,gE as Gqe,gF as aw,gG as Iqe,gH as C3,gI as Zqe,gJ as Dqe,gK as Vqe,gL as Mqe,gM as Lqe,gN as Fqe,gO as Bqe,gP as Hqe,gQ as Kqe,gR as Jqe,gS as Eue,gT as eje,gU as tje,gV as nje,gW as rje,gX as ije,gY as aje,gZ as _O,g_ as QA,g$ as que,h0 as Yp,h1 as oje,a1 as L$,h2 as sje,$ as jue,Y as Cue,h3 as ox,h4 as lje,h5 as cje,h6 as z3,h7 as uje,h8 as aI,h9 as Oje,ha as dje,hb as fje,hc as kO,hd as hje,he as pje,hf as _A,hg as mje,hh as gje,hi as $je,hj as yje,hk as vje,hl as bje,hm as wje,hn as xje,ho as Sje,hp as Qje,hq as _je,hr as kje,hs as Pje,ht as Tje,hu as Xje,n as ak,hv as Rje,hw as zue,hx as Eje,hy as qje,hz as Wv,hA as Aue,hB as Uue,hC as Wue,hD as kA,hE as jje,hF as Cje,hG as zje,aL as Aje,hH as Uje,f2 as ok,eH as Wje,c as PA,hI as Nje,hJ as Yje,D as Gje,bi as Ije,hK as Zje,z as Dje,hL as Vje,hM as Mje,hN as Lje,hO as Fje,hP as Bje,hQ as F$,hR as Hje,hS as oI,hT as Nue,hU as Kje,hV as sI,hW as Jje,hX as e3e,hY as t3e,hZ as Yue,h_ as n3e,h$ as r3e,i0 as ow,i1 as lI,i2 as i3e,i3 as cI,i4 as a3e,en as uI,i5 as OI,bo as dI,i6 as fI,i7 as o3e,i8 as s3e,i9 as hI,ia as A3,ib as l3e,at as pI,cC as c3e,ic as u3e,id as O3e,ie as d3e,ig as Gp,ih as f3e,dh as h3e,ii as p3e,bH as m3e,ij as g3e,de as $3e,dg as y3e,df as v3e,b4 as b3e,bg as w3e,cs as TA,cq as x3e,ik as S3e,dZ as Gue,dY as Iue,ao as B$,il as o$,aS as Zue,im as Q3e,aU as Due,io as _3e,ip as XA,iq as k3e,ir as P3e,cR as T3e,aM as X3e,is as R3e,aT as E3e,it as q3e,iu as j3e,iv as C3e,iw as mI,ix as z3e,iy as cS,iz as Vue,cA as A3e,iA as Mue,iB as U3e,iC as W3e,iD as N3e,iE as Y3e,g as G3e,iF as sk,iG as RA,iH as I3e,iI as Z3e,iJ as Lue,iK as H$,iL as Cc,iM as D3e,iN as V3e,iO as M3e,iP as L3e,e7 as F3e,iQ as uS,iR as B3e,iS as H3e,iT as K3e,iU as J3e,iV as gI,iW as e7e,iX as t7e,iY as n7e,iZ as r7e,i_ as i7e,i$ as a7e,S as o7e,aA as $I,j0 as U3,j1 as W3,j2 as s7e}from"./appearance-DCqlsN7S.js";import{aA as l7e,c as je,aJ as c7e,aK as Fue,aL as u7e,aM as O7e,aN as d7e,aO as f7e,aP as h7e,aQ as p7e,aR as Wg,aS as m7e,B as ve,m as EA,n as qA,y as g7e,o as jA,F as $7e,u as be,z as OS,S as ti,T as lk,w as $t,h as dS,J as Bue,r as df,b as Ai,e as Is,X as Zr,a as Hue,d as K$,f as y7e,A as is,D as ck,g as uk,i as Ok,I as Fo,l as oa,C as Kue,ak as J$,a4 as $2,ag as v7e,v as b7e,ad as Ip,p as ap,x as fS,au as CA,q as nu,R as yI,aT as w7e,a1 as x7e,ae as S7e,a3 as Q7e,ah as _7e,at as k7e,a6 as P7e,N as T7e,O as X7e,P as R7e,K as Ha,U as Jue,V as eOe,W as tOe,Y as nOe,Z as N3,a5 as E7e,L as rOe,aI as q7e,a7 as j7e,a8 as C7e,a9 as vI,aa as bI,ab as z7e,ac as wI,an as A7e,s as U7e,G as y2,H as xI,E as SI}from"./error-boundary-C1x5W-AX.js";import{b as iOe,c as zA,t as h,r as W7e,e as AA,L as Ad,f as N7e,i as Y7e,g as Y3}from"./messages-B7aIuFuF.js";import{P as UA}from"./roles-D1pcbxAx.js";var G7e=class extends uEe{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:BG()})}getOptimisticResult(e){return e.behavior=BG(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,l=n.fetchMeta?.fetchMore?.direction,c=o&&l==="forward",u=i&&l==="forward",O=o&&l==="backward",f=i&&l==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:dEe(t,n.data),hasPreviousPage:OEe(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:f,isRefetchError:s&&!c&&!O,isRefetching:a&&!u&&!f}}},I7e=class extends fEe{#n;#r=void 0;#e;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#n.defaultMutationOptions(t),hEe(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&HG(n.mutationKey)!==HG(this.options.mutationKey)?this.reset():this.#e?.state.status==="pending"&&this.#e.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#e?.removeObserver(this)}onMutationUpdate(t){this.#i(),this.#a(t)}getCurrentResult(){return this.#r}reset(){this.#e?.removeObserver(this),this.#e=void 0,this.#i(),this.#a()}mutate(t,n){return this.#t=n,this.#e?.removeObserver(this),this.#e=this.#n.getMutationCache().build(this.#n,this.options),this.#e.addObserver(this),this.#e.execute(t)}#i(){const t=this.#e?.state??pEe();this.#r={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){pue.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#r.variables,r=this.#r.context;t?.type==="success"?(this.#t.onSuccess?.(t.data,n,r),this.#t.onSettled?.(t.data,null,n,r)):t?.type==="error"&&(this.#t.onError?.(t.error,n,r),this.#t.onSettled?.(void 0,t.error,n,r))}this.listeners.forEach(n=>{n(this.#r)})})}};function hS(e,t){const n=ga(t),[r]=$.useState(()=>new I7e(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(pue.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(mEe)},[r]);if(i.error&&gEe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function aOe(e,t){return $Ee(e,G7e,t)}const Z7e=5e3;let oOe=0;function D7e(e=Z7e){oOe=Date.now()+e}function npn(e=Date.now()){return e<=oOe}function V7e(e){D7e(),e.invalidateQueries({queryKey:zr.capabilities})}const M7e=e=>e!==""&&iOe(zA())==="rtl"?`${e}`:e;function L7e(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!F7e(n)||!Array.isArray(r)||r.length===0||r.some(s=>!s||typeof s!="object"||typeof s.name!="string"))return null;const i=new Map,a=new Set(r.map(s=>s.name)),o=new Set;return r.map(s=>{const l=s,c=typeof l.name=="string"?l.name:"",u=(i.get(c)??0)+1;i.set(c,u);let O=u,f=u===1?c:`${c} (${O})`;for(;o.has(f)||f!==c&&a.has(f);)f=`${c} (${++O})`;o.add(f);const p=t.find(m=>m.kind==="audio"&&typeof l.digest=="string"&&m.attachment===l.digest)??null;return{id:JSON.stringify([l.request_id??null,c,u]),name:c,label:f,audio:p,costCaption:sOe(l,!0),status:l.status==="cancelled"?"cancelled":l.status==="failed"||l.error?"failed":l.status==="completed"?"completed":"unknown",error:typeof l.error=="string"?l.error:null}})}function sOe(e,t=!1){const n=e.cost&&typeof e.cost=="object"?e.cost:null;if(t&&(e.status==="failed"||e.error)&&e.cost_usd===0){if(n?.basis==="billed")return h("ui.chat.canonical.sound.cost.no_charge");if(n?.basis==="estimated")return h("ui.chat.canonical.sound.cost.estimated_zero")}return Cv({...e,billing_basis:n?.basis??e.billing_basis})}function v2(e){const t=e,n=sOe(t);if(!n)return h("ui.chat.canonical.sound.cost.batch_unknown");const r=t.cost_complete===!0;return`${r?"Total cost":"Known total cost"} ${n.slice(5)}${r?"":" Unknown or late charges are not included."}`}function F7e(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function B7e(e,t){const n=e,r=s=>{const l=n[s];return typeof l=="number"&&Number.isInteger(l)&&l>=0?l:t.filter(c=>c.status===s).length},i=r("cancelled"),a=t.filter(s=>s.status==="unknown").length,o=t.filter(s=>s.status!=="completed");return h("ui.chat.canonical.sound.batch.summary",{completed:r("completed"),failed:r("failed"),cancelled:i,unknown:a,has_attention:o.length?"yes":"no",labels:mue(o.map(s=>s.label))})}function H7e(e,t){const n=e;if(typeof n.error=="string"&&n.error)return n.error;const r=t?.split(`
|
|
3
3
|
`)[0];if(!r)return null;const i=r.indexOf("Batch ");return i>=0?r.slice(i):null}function K7e(e,t){const n=t&&typeof t=="object"?t:{},r=e&&typeof e=="object"?e.sounds:null,i=typeof n.total=="number"&&Number.isInteger(n.total)&&n.total>0?n.total:Array.isArray(r)&&r.length?r.length:null;if(i===null)return null;const a=n.item,o=typeof a=="number"&&Number.isInteger(a)&&a>=1&&a<=i&&typeof n.name=="string"?h("ui.chat.canonical.sound.batch.latest_update",{name:n.name,item:a,total:i}):null;return{total:i,note:o}}const WA="generate_video",NA="generate_voiceover",YA="generate_sound_effect",J7e=new Set(["generate_image",WA,NA,YA]);function lOe(e){return J7e.has(e)}function eCe(e){return e===WA}function tCe(e){return e===NA||e===YA}function nCe(e){return e===WA?"video":e===NA?"voiceover":e===YA?"sound-effect":"image"}function rCe(e){if(!e||typeof e!="object")return null;const t=e;if(t.stage!=="cancelled")return null;const n=t.error_type;if(typeof n=="string"&&n)return null;const r=t.settling;if(typeof r!="boolean"||!("vendor_stopped"in t))return null;const i=t.vendor_stopped;return i!==null&&typeof i!="boolean"?null:{vendorStopped:i,settling:r}}function iCe(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n.message;typeof r=="string"&&r&&t.push(r)}return t}function aCe(e){const t=e??{};return{stage:typeof t.stage=="string"?t.stage:null,fraction:typeof t.progress_fraction=="number"&&Number.isFinite(t.progress_fraction)?t.progress_fraction:null,logs:iCe(t.log_lines),queuePosition:typeof t.queue_position=="number"&&Number.isInteger(t.queue_position)?t.queue_position:null,error:typeof t.error=="string"&&t.error?t.error:null,errorType:typeof t.error_type=="string"&&t.error_type?t.error_type:null}}function QI(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?cOe:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const cOe=Object.freeze({fraction:null,logs:[],queuePosition:null});function oCe(e,{stopping:t=!1,settled:n=!1}={}){const r=aCe(e.details),i=nCe(e.toolName),a=i==="voiceover"||i==="sound-effect",o=a&&e.phase==="done"?L7e(e.details,e.images??[]):null,s=a?K7e(e.args,e.details):null,l=o?{batch:o,batchSummary:B7e(e.details,o),batchNote:H7e(e.details,e.output)}:{},c=a?cCe(e.details):null,u=c?.caption??null,O=c?.pending===!0,f=rCe(e.details);if(e.stopped===!0)return{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...o?{...l,material:i,costCaption:v2(e.details)}:{},...u?{settlementCaption:u}:{},...O?{settlementPending:O}:{},...f?{cancel:f}:{},...u||O||n?{settled:!0}:{}};if(e.notRunKind==="skipped"||e.notRunKind==="aborted")return{state:"cancelled",generating:!1,message:e.output};if(e.notRunReason)return{state:"failed",material:i,message:e.notRunReason,errorCode:b2(e.notRunKind,e.notRunReason)};if(e.neverSent===!0)return{state:"cancelled",generating:!1,message:e.output};if(o&&e.isError)return{state:"failed",material:i,message:r.error??e.output,errorCode:b2(r.errorType,r.error??e.output),...l,costCaption:v2(e.details)};if(e.isError===!0)return r.errorType==="media_already_completed"?{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"already-finished"}:r.stage==="cancelled"&&r.errorType===null?{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...f?{cancel:f}:{},...u?{settlementCaption:u}:{},...O?{settlementPending:O}:{},...u||O||n?{settled:!0}:{}}:{state:"failed",material:i,message:r.error??e.output??null,errorCode:b2(r.errorType,r.error??e.output)};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,material:i,startedAtMs:null,progress:cOe}:{state:"queued",material:i,composing:e.phase==="composing",argumentBytes:e.argumentBytes??0,queuePosition:r.queuePosition};case"running":{const p=e.startedAt??null;return t?{state:"cancelling",generating:!0,material:i,startedAtMs:p,progress:QI(r)}:{state:"running",material:i,startedAtMs:p,progress:QI(r),note:r.error,...s?{batchProgress:s}:{}}}case"done":{const p=a?Cv(e.details,e.output):null;return{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"generated",batch:o,...l,costCaption:o?v2(e.details):p}}}}const sCe=/\s*Checking for settlement\.?\s*$/;function lCe(e){return e.replace(sCe,"").trimEnd()}function cCe(e){if(!e||typeof e!="object")return null;const t=e,n=t.cost;return t.settled===!0?{caption:Cv(e),pending:!1}:t.settled===null&&t.cost_usd===null&&n?.basis==="quote"?{caption:null,pending:!0}:null}function b2(e,t){if(!e)return null;const n=e.replace(/_/g," ");return t?.toLowerCase().startsWith(n.toLowerCase())?null:e}function uCe(e,t){const n=[],r=e.state==="queued"||e.state==="running"||e.state==="cancelling";t?.onCancel&&r&&n.push({kind:"cancel",disabled:e.state==="cancelling"});const i=e.state==="failed"||e.state==="cancelled";return t?.onRestart&&i&&n.push({kind:"restart",disabled:!1}),t?.onEditRestart&&i&&n.push({kind:"editRestart",disabled:!1}),n}function OCe(e,t){if(!eCe(e))return t?{onCancel:t}:void 0}function dCe(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const fCe=e=>{switch(e){case"success":return mCe;case"info":return $Ce;case"warning":return gCe;case"error":return yCe;default:return null}},hCe=Array(12).fill(0),pCe=({visible:e,className:t})=>te.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},te.createElement("div",{className:"sonner-spinner"},hCe.map((n,r)=>te.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),mCe=te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},te.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),gCe=te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},te.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),$Ce=te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},te.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),yCe=te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},te.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),vCe=te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},te.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),te.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),bCe=()=>{const[e,t]=te.useState(document.hidden);return te.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let G3=1;class wCe{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...i}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:G3++,o=this.toasts.find(l=>l.id===a),s=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),o?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...t,id:a,title:r}),{...l,...t,id:a,dismissible:s,title:r}):l):this.addToast({title:r,...i,dismissible:s,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(t instanceof Function?t():t);let a=r!==void 0,o;const s=i.then(async c=>{if(o=["resolve",c],te.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(SCe(c)&&!c.ok){a=!1;const O=typeof n.error=="function"?await n.error(`HTTP error! status: ${c.status}`):n.error,f=typeof n.description=="function"?await n.description(`HTTP error! status: ${c.status}`):n.description,m=typeof O=="object"&&!te.isValidElement(O)?O:{message:O};this.create({id:r,type:"error",description:f,...m})}else if(c instanceof Error){a=!1;const O=typeof n.error=="function"?await n.error(c):n.error,f=typeof n.description=="function"?await n.description(c):n.description,m=typeof O=="object"&&!te.isValidElement(O)?O:{message:O};this.create({id:r,type:"error",description:f,...m})}else if(n.success!==void 0){a=!1;const O=typeof n.success=="function"?await n.success(c):n.success,f=typeof n.description=="function"?await n.description(c):n.description,m=typeof O=="object"&&!te.isValidElement(O)?O:{message:O};this.create({id:r,type:"success",description:f,...m})}}).catch(async c=>{if(o=["reject",c],n.error!==void 0){a=!1;const u=typeof n.error=="function"?await n.error(c):n.error,O=typeof n.description=="function"?await n.description(c):n.description,p=typeof u=="object"&&!te.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:O,...p})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((c,u)=>s.then(()=>o[0]==="reject"?u(o[1]):c(o[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(t,n)=>{const r=n?.id||G3++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Na=new wCe,xCe=(e,t)=>{const n=t?.id||G3++;return Na.addToast({title:e,...t,id:n}),n},SCe=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",QCe=xCe,_Ce=()=>Na.toasts,kCe=()=>Na.getActiveToasts(),Wf=Object.assign(QCe,{success:Na.success,info:Na.info,warning:Na.warning,error:Na.error,custom:Na.custom,message:Na.message,promise:Na.promise,dismiss:Na.dismiss,loading:Na.loading},{getHistory:_Ce,getToasts:kCe});dCe("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}[data-sonner-toaster][data-lifted=true]{transform:translateY(-8px)}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function sw(e){return e.label!==void 0}const PCe=3,TCe="24px",XCe="16px",_I=4e3,RCe=356,ECe=14,qCe=45,jCe=200;function ul(...e){return e.filter(Boolean).join(" ")}function CCe(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const zCe=e=>{var t,n,r,i,a,o,s,l,c;const{invert:u,toast:O,unstyled:f,interacting:p,setHeights:m,visibleToasts:g,heights:y,index:v,toasts:b,expanded:x,removeToast:Q,defaultRichColors:w,closeButton:S,style:_,cancelButtonStyle:k,actionButtonStyle:R,className:E="",descriptionClassName:T="",duration:q,position:A,gap:G,expandByDefault:I,classNames:C,icons:U,closeButtonAriaLabel:Y="Close toast"}=e,[V,z]=te.useState(null),[Z,K]=te.useState(null),[N,ce]=te.useState(!1),[ee,D]=te.useState(!1),[ne,J]=te.useState(!1),[L,B]=te.useState(!1),[ae,ie]=te.useState(!1),[ke,fe]=te.useState(0),[_e,qe]=te.useState(0),Ce=te.useRef(O.duration||q||_I),Oe=te.useRef(null),we=te.useRef(null),Je=v===0,ct=v+1<=g,nt=O.type,gt=O.dismissible!==!1,me=O.className||"",Ke=O.descriptionClassName||"",pe=te.useMemo(()=>y.findIndex(at=>at.toastId===O.id)||0,[y,O.id]),re=te.useMemo(()=>{var at;return(at=O.closeButton)!=null?at:S},[O.closeButton,S]),$e=te.useMemo(()=>O.duration||q||_I,[O.duration,q]),Qe=te.useRef(0),Se=te.useRef(0),ft=te.useRef(0),We=te.useRef(null),[rt,Wt]=A.split("-"),yt=te.useMemo(()=>y.reduce((at,At,on)=>on>=pe?at:at+At.height,0),[y,pe]),Ue=bCe(),_t=O.invert||u,Zt=nt==="loading";Se.current=te.useMemo(()=>pe*G+yt,[pe,yt]),te.useEffect(()=>{Ce.current=$e},[$e]),te.useEffect(()=>{ce(!0)},[]),te.useEffect(()=>{const at=we.current;if(at){const At=at.getBoundingClientRect().height;return qe(At),m(on=>[{toastId:O.id,height:At,position:O.position},...on]),()=>m(on=>on.filter(Cn=>Cn.toastId!==O.id))}},[m,O.id]),te.useLayoutEffect(()=>{if(!N)return;const at=we.current,At=at.style.height;at.style.height="auto";const on=at.getBoundingClientRect().height;at.style.height=At,qe(on),m(Cn=>Cn.find(Yt=>Yt.toastId===O.id)?Cn.map(Yt=>Yt.toastId===O.id?{...Yt,height:on}:Yt):[{toastId:O.id,height:on,position:O.position},...Cn])},[N,O.title,O.description,m,O.id]);const Ye=te.useCallback(()=>{D(!0),fe(Se.current),m(at=>at.filter(At=>At.toastId!==O.id)),setTimeout(()=>{Q(O)},jCe)},[O,Q,m,Se]);te.useEffect(()=>{if(O.promise&&nt==="loading"||O.duration===1/0||O.type==="loading")return;let at;return x||p||Ue?(()=>{if(ft.current<Qe.current){const Cn=new Date().getTime()-Qe.current;Ce.current=Ce.current-Cn}ft.current=new Date().getTime()})():(()=>{Ce.current!==1/0&&(Qe.current=new Date().getTime(),at=setTimeout(()=>{O.onAutoClose==null||O.onAutoClose.call(O,O),Ye()},Ce.current))})(),()=>clearTimeout(at)},[x,p,O,nt,Ue,Ye]),te.useEffect(()=>{O.delete&&Ye()},[Ye,O.delete]);function Nt(){var at;if(U?.loading){var At;return te.createElement("div",{className:ul(C?.loader,O==null||(At=O.classNames)==null?void 0:At.loader,"sonner-loader"),"data-visible":nt==="loading"},U.loading)}return te.createElement(pCe,{className:ul(C?.loader,O==null||(at=O.classNames)==null?void 0:at.loader),visible:nt==="loading"})}const Ae=O.icon||U?.[nt]||fCe(nt);var it,Ct;return te.createElement("li",{tabIndex:0,ref:we,className:ul(E,me,C?.toast,O==null||(t=O.classNames)==null?void 0:t.toast,C?.default,C?.[nt],O==null||(n=O.classNames)==null?void 0:n[nt]),"data-sonner-toast":"","data-rich-colors":(it=O.richColors)!=null?it:w,"data-styled":!(O.jsx||O.unstyled||f),"data-mounted":N,"data-promise":!!O.promise,"data-swiped":ae,"data-removed":ee,"data-visible":ct,"data-y-position":rt,"data-x-position":Wt,"data-index":v,"data-front":Je,"data-swiping":ne,"data-dismissible":gt,"data-type":nt,"data-invert":_t,"data-swipe-out":L,"data-swipe-direction":Z,"data-expanded":!!(x||I&&N),style:{"--index":v,"--toasts-before":v,"--z-index":b.length-v,"--offset":`${ee?ke:Se.current}px`,"--initial-height":I?"auto":`${_e}px`,..._,...O.style},onDragEnd:()=>{J(!1),z(null),We.current=null},onPointerDown:at=>{Zt||!gt||(Oe.current=new Date,fe(Se.current),at.target.setPointerCapture(at.pointerId),at.target.tagName!=="BUTTON"&&(J(!0),We.current={x:at.clientX,y:at.clientY}))},onPointerUp:()=>{var at,At,on;if(L||!gt)return;We.current=null;const Cn=Number(((at=we.current)==null?void 0:at.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),kr=Number(((At=we.current)==null?void 0:At.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Yt=new Date().getTime()-((on=Oe.current)==null?void 0:on.getTime()),or=V==="x"?Cn:kr,pi=Math.abs(or)/Yt;if(Math.abs(or)>=qCe||pi>.11){fe(Se.current),O.onDismiss==null||O.onDismiss.call(O,O),K(V==="x"?Cn>0?"right":"left":kr>0?"down":"up"),Ye(),B(!0);return}else{var Tt,zn;(Tt=we.current)==null||Tt.style.setProperty("--swipe-amount-x","0px"),(zn=we.current)==null||zn.style.setProperty("--swipe-amount-y","0px")}ie(!1),J(!1),z(null)},onPointerMove:at=>{var At,on,Cn;if(!We.current||!gt||((At=window.getSelection())==null?void 0:At.toString().length)>0)return;const Yt=at.clientY-We.current.y,or=at.clientX-We.current.x;var pi;const Tt=(pi=e.swipeDirections)!=null?pi:CCe(A);!V&&(Math.abs(or)>1||Math.abs(Yt)>1)&&z(Math.abs(or)>Math.abs(Yt)?"x":"y");let zn={x:0,y:0};const Bi=$n=>1/(1.5+Math.abs($n)/20);if(V==="y"){if(Tt.includes("top")||Tt.includes("bottom"))if(Tt.includes("top")&&Yt<0||Tt.includes("bottom")&&Yt>0)zn.y=Yt;else{const $n=Yt*Bi(Yt);zn.y=Math.abs($n)<Math.abs(Yt)?$n:Yt}}else if(V==="x"&&(Tt.includes("left")||Tt.includes("right")))if(Tt.includes("left")&&or<0||Tt.includes("right")&&or>0)zn.x=or;else{const $n=or*Bi(or);zn.x=Math.abs($n)<Math.abs(or)?$n:or}(Math.abs(zn.x)>0||Math.abs(zn.y)>0)&&ie(!0),(on=we.current)==null||on.style.setProperty("--swipe-amount-x",`${zn.x}px`),(Cn=we.current)==null||Cn.style.setProperty("--swipe-amount-y",`${zn.y}px`)}},re&&!O.jsx&&nt!=="loading"?te.createElement("button",{"aria-label":Y,"data-disabled":Zt,"data-close-button":!0,onClick:Zt||!gt?()=>{}:()=>{Ye(),O.onDismiss==null||O.onDismiss.call(O,O)},className:ul(C?.closeButton,O==null||(r=O.classNames)==null?void 0:r.closeButton)},(Ct=U?.close)!=null?Ct:vCe):null,(nt||O.icon||O.promise)&&O.icon!==null&&(U?.[nt]!==null||O.icon)?te.createElement("div",{"data-icon":"",className:ul(C?.icon,O==null||(i=O.classNames)==null?void 0:i.icon)},O.promise||O.type==="loading"&&!O.icon?O.icon||Nt():null,O.type!=="loading"?Ae:null):null,te.createElement("div",{"data-content":"",className:ul(C?.content,O==null||(a=O.classNames)==null?void 0:a.content)},te.createElement("div",{"data-title":"",className:ul(C?.title,O==null||(o=O.classNames)==null?void 0:o.title)},O.jsx?O.jsx:typeof O.title=="function"?O.title():O.title),O.description?te.createElement("div",{"data-description":"",className:ul(T,Ke,C?.description,O==null||(s=O.classNames)==null?void 0:s.description)},typeof O.description=="function"?O.description():O.description):null),te.isValidElement(O.cancel)?O.cancel:O.cancel&&sw(O.cancel)?te.createElement("button",{"data-button":!0,"data-cancel":!0,style:O.cancelButtonStyle||k,onClick:at=>{sw(O.cancel)&>&&(O.cancel.onClick==null||O.cancel.onClick.call(O.cancel,at),Ye())},className:ul(C?.cancelButton,O==null||(l=O.classNames)==null?void 0:l.cancelButton)},O.cancel.label):null,te.isValidElement(O.action)?O.action:O.action&&sw(O.action)?te.createElement("button",{"data-button":!0,"data-action":!0,style:O.actionButtonStyle||R,onClick:at=>{sw(O.action)&&(O.action.onClick==null||O.action.onClick.call(O.action,at),!at.defaultPrevented&&Ye())},className:ul(C?.actionButton,O==null||(c=O.classNames)==null?void 0:c.actionButton)},O.action.label):null)};function kI(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function ACe(e,t){const n={};return[e,t].forEach((r,i)=>{const a=i===1,o=a?"--mobile-offset":"--offset",s=a?XCe:TCe;function l(c){["top","right","bottom","left"].forEach(u=>{n[`${o}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${o}-${c}`]=s:n[`${o}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(s)}),n}const UCe=te.forwardRef(function(t,n){const{invert:r,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:s,className:l,offset:c,mobileOffset:u,theme:O="light",richColors:f,duration:p,style:m,visibleToasts:g=PCe,toastOptions:y,dir:v=kI(),gap:b=ECe,icons:x,containerAriaLabel:Q="Notifications"}=t,[w,S]=te.useState([]),_=te.useMemo(()=>Array.from(new Set([i].concat(w.filter(Z=>Z.position).map(Z=>Z.position)))),[w,i]),[k,R]=te.useState([]),[E,T]=te.useState(!1),[q,A]=te.useState(!1),[G,I]=te.useState(O!=="system"?O:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),C=te.useRef(null),U=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),Y=te.useRef(null),V=te.useRef(!1),z=te.useCallback(Z=>{S(K=>{var N;return(N=K.find(ce=>ce.id===Z.id))!=null&&N.delete||Na.dismiss(Z.id),K.filter(({id:ce})=>ce!==Z.id)})},[]);return te.useEffect(()=>Na.subscribe(Z=>{if(Z.dismiss){requestAnimationFrame(()=>{S(K=>K.map(N=>N.id===Z.id?{...N,delete:!0}:N))});return}setTimeout(()=>{l7e.flushSync(()=>{S(K=>{const N=K.findIndex(ce=>ce.id===Z.id);return N!==-1?[...K.slice(0,N),{...K[N],...Z},...K.slice(N+1)]:[Z,...K]})})})}),[w]),te.useEffect(()=>{if(O!=="system"){I(O);return}if(O==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?I("dark"):I("light")),typeof window>"u")return;const Z=window.matchMedia("(prefers-color-scheme: dark)");try{Z.addEventListener("change",({matches:K})=>{I(K?"dark":"light")})}catch{Z.addListener(({matches:N})=>{try{I(N?"dark":"light")}catch(ce){console.error(ce)}})}},[O]),te.useEffect(()=>{w.length<=1&&T(!1)},[w]),te.useEffect(()=>{const Z=K=>{var N;if(a.every(D=>K[D]||K.code===D)){var ee;T(!0),(ee=C.current)==null||ee.focus()}K.code==="Escape"&&(document.activeElement===C.current||(N=C.current)!=null&&N.contains(document.activeElement))&&T(!1)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[a]),te.useEffect(()=>{if(C.current)return()=>{Y.current&&(Y.current.focus({preventScroll:!0}),Y.current=null,V.current=!1)}},[C.current]),te.createElement("section",{ref:n,"aria-label":`${Q} ${U}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},_.map((Z,K)=>{var N;const[ce,ee]=Z.split("-");return w.length?te.createElement("ol",{key:Z,dir:v==="auto"?kI():v,tabIndex:-1,ref:C,className:l,"data-sonner-toaster":!0,"data-sonner-theme":G,"data-y-position":ce,"data-lifted":E&&w.length>1&&!o,"data-x-position":ee,style:{"--front-toast-height":`${((N=k[0])==null?void 0:N.height)||0}px`,"--width":`${RCe}px`,"--gap":`${b}px`,...m,...ACe(c,u)},onBlur:D=>{V.current&&!D.currentTarget.contains(D.relatedTarget)&&(V.current=!1,Y.current&&(Y.current.focus({preventScroll:!0}),Y.current=null))},onFocus:D=>{D.target instanceof HTMLElement&&D.target.dataset.dismissible==="false"||V.current||(V.current=!0,Y.current=D.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{q||T(!1)},onDragEnd:()=>T(!1),onPointerDown:D=>{D.target instanceof HTMLElement&&D.target.dataset.dismissible==="false"||A(!0)},onPointerUp:()=>A(!1)},w.filter(D=>!D.position&&K===0||D.position===Z).map((D,ne)=>{var J,L;return te.createElement(zCe,{key:D.id,icons:x,index:ne,toast:D,defaultRichColors:f,duration:(J=y?.duration)!=null?J:p,className:y?.className,descriptionClassName:y?.descriptionClassName,invert:r,visibleToasts:g,closeButton:(L=y?.closeButton)!=null?L:s,interacting:q,position:Z,style:y?.style,unstyled:y?.unstyled,classNames:y?.classNames,cancelButtonStyle:y?.cancelButtonStyle,actionButtonStyle:y?.actionButtonStyle,closeButtonAriaLabel:y?.closeButtonAriaLabel,removeToast:z,toasts:w.filter(B=>B.position==D.position),heights:k.filter(B=>B.position==D.position),setHeights:R,expandByDefault:o,gap:b,expanded:E,swipeDirections:t.swipeDirections})})):null}))}),WCe=["ERR_INTERNET_DISCONNECTED","ERR_NETWORK_CHANGED","ERR_NAME_NOT_RESOLVED","ERR_TIMED_OUT","ERR_CONNECTION_RESET","ERR_CONNECTION_REFUSED","ERR_CONNECTION_CLOSED","ERR_CONNECTION_FAILED","ERR_CONNECTION_TIMED_OUT","ERR_ADDRESS_UNREACHABLE","ERR_NETWORK_IO_SUSPENDED","ERR_PROXY_CONNECTION_FAILED"],NCe=["ENOTFOUND","EAI_AGAIN","ETIMEDOUT","ECONNRESET","ECONNREFUSED","EHOSTUNREACH","ENETUNREACH","ENETDOWN","ENETRESET","ECONNABORTED","EPIPE"],YCe=["Failed to fetch","Load failed","NetworkError when attempting to fetch resource."],GCe=new Set(WCe),ICe=/[:\-\u2014\n]$/,ZCe=/^[:\n]/,PI=/[:\uff1a\n\u2014]| - /g,DCe=/^(?:\s*Error:\s*)+/,VCe=/:\s+Error:\s+/g,MCe=/\b(?:net::)?(ERR_[A-Z0-9_]+)\b/g,LCe=NCe.map(e=>({code:e,pattern:new RegExp(`\\b${e}\\b`)}));function w2(e,t,n){const r=e.slice(0,t).trimEnd(),i=e.slice(t+n).trimStart(),a=r===""||ICe.test(r),o=i===""||ZCe.test(i);return a&&o}function uOe(e){const t=BCe(e);if(!t)return null;const n=OOe(t);for(const r of n.matchAll(MCe)){const i=r[1];if(!GCe.has(i))continue;const a=r.index??0,o=a+r[0].length;return{code:`net::${i}`,start:a,end:o,clauseText:x2(n,a,o),clause:w2(n,a,o-a)}}for(const{code:r,pattern:i}of LCe){const a=i.exec(n);if(a){const o=a.index,s=o+a[0].length;return{code:r,start:o,end:s,clauseText:x2(n,o,s),clause:w2(n,o,s-o)}}}for(const r of YCe){const i=n.indexOf(r);if(i!==-1&&w2(n,i,r.length))return{code:r,start:i,end:i+r.length,clauseText:x2(n,i,i+r.length),clause:!0}}return null}function FCe(e){return uOe(e)?.code??null}function rpn(e){return FCe(e)!==null}function BCe(e){if(typeof e=="string")return e;if(e instanceof Error)return e.message||e.name||"";if(e&&typeof e=="object"&&"message"in e){const t=e.message;return typeof t=="string"?t:""}return""}function x2(e,t,n){let r=0;for(const a of e.slice(0,t).matchAll(PI))r=(a.index??0)+a[0].length;let i=e.length;for(const a of e.slice(n).matchAll(PI)){i=n+(a.index??0);break}return e.slice(r,i).trim()}function OOe(e){return e.replace(DCe,"").replace(VCe,": ")}const Ng=new Map,S2=new Map,Q2=new Map,TI=5e3,HCe=1,KCe={CONNECTION:["Failed to fetch","Network error","ERR_CONNECTION_REFUSED","Server is offline","Connection failed"]},JCe={"Failed to fetch":!0,"TypeError: Failed to fetch":!0,"Load failed":!0,"NetworkError when attempting to fetch resource.":!0,ERR_CONNECTION_REFUSED:!0,"net::ERR_CONNECTION_REFUSED":!0},_2=()=>h("ui.common.connection.transport_failure"),dOe=e=>{const t=e.trim();if(Object.prototype.hasOwnProperty.call(JCe,t))return _2();const n=OOe(t),r=uOe(n);return r===null?e:r.clause?`${n.slice(0,r.start)}${_2()}${n.slice(r.end)}`:_2()},e6e=e=>{for(const[t,n]of Object.entries(KCe))if(n.some(r=>e.includes(r)))return t;return null},t6e=(e,t)=>Wf.loading(e,t),Jn=(e,t)=>{const n=Date.now(),i=e6e(e)||e,a=dOe(e),o=S2.get(i);if(o&&n-o<TI)return null;const s=Q2.get(i)||0;if(s>=HCe)return null;if(Ng.has(i))return S2.set(i,n),Ng.get(i);const l=Wf.error(a,{...t,onDismiss:c=>{Ng.delete(i),t?.onDismiss?.(c)},onAutoClose:c=>{Ng.delete(i),t?.onAutoClose?.(c)}});return Ng.set(i,l),S2.set(i,n),Q2.set(i,s+1),setTimeout(()=>{Q2.set(i,0)},TI),l},k2=(e,t)=>Wf.error(dOe(e),t),_o=(e,t)=>Wf.info(e,t),s$=e=>{Wf.dismiss(e)},Ls=(e,t)=>Wf.success(e,t),Kh=(e,t)=>Wf.warning(e,t),n6e={"under-window":{dark:{canvas:.53,surface:.59,elevated:.68},light:{canvas:.61,surface:.5,elevated:.45}},menu:{dark:{canvas:.67,surface:.72,elevated:.8},light:{canvas:.79,surface:.7,elevated:.65}},popover:{dark:{canvas:.75,surface:.78,elevated:.86},light:{canvas:.86,surface:.79,elevated:.75}}},r6e={dark:.09,light:.12},i6e={dark:{role:"sunken",scale:.68},light:{role:"surface",scale:.72}},a6e={"under-window":{dark:.15,light:.2},menu:{dark:.1,light:.2},popover:{dark:.1,light:.15}},o6e={dark:.88,light:.78},s6e={dark:.7,light:.5},l6e={dark:.65,light:.6},c6e={dark:.3,light:.4},u6e={hover:.05,selected:.08,field:.05,work:.08},O6e="Minimum ground alphas, the minimum ink and edge mixes the floating overlay carries, the state/field overlay alphas and the edge mix the window-glass feature paints, derived by scripts/derive-glass-floors.mjs (AA ink over the worst measured backdrop WITH the state overlay stacked; the 3:1 structural edge via a border->ink mix; the overlay floor against the least opaque column the app can present, plus the two mixes that carry the semantic inks and the panel's own boundary on it). Asserted by scripts/contrast-contract.mjs. Never hand-lower or hand-pick a value: re-derive.",GA={alphaFloor:n6e,blockVeil:r6e,laneWash:i6e,controlMix:a6e,bandFloor:o6e,overlayFloor:s6e,overlayInkMix:l6e,overlayEdgeMix:c6e,stateAlpha:u6e,_why:O6e},ipn=["sidebars","full"],fOe=(e,t)=>e!=="vibrancy"?"popover":t==="menu"?"menu":t==="popover"?"popover":"under-window",hOe=.96,IA=e=>Math.round(e*100)/100;function d6e(e,t,n,r=GA){const i=r.alphaFloor[fOe(e,t)][n];return{canvas:i.canvas,surface:i.surface,elevated:i.elevated}}function f6e(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=d6e(e.mechanism,e.material,e.scheme,e.floors),r=i=>{const a=Math.max(hOe,i);return IA(a-t*(a-i))};return{canvas:r(n.canvas),surface:r(n.surface),elevated:r(n.elevated)}}function h6e(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=GA.overlayFloor[e.scheme],r=Math.max(hOe,n);return IA(r-t*(r-n))}const p6e={sidebars:["sidebar"],full:["sidebar","canvas","pane"]};function m6e(e){const t=e.floors??GA,n=f6e(e),r=a=>n.canvas===1?0:IA(Math.min(1,Math.max(0,1-(1-a)/(1-n.canvas)))),i={"--lo-glass-a-canvas":String(n.canvas),"--lo-glass-a-surface":String(n.surface),"--lo-glass-a-elevated":String(n.elevated),"--lo-glass-a-row-hover":String(t.stateAlpha.hover),"--lo-glass-a-row-selected":String(t.stateAlpha.selected),"--lo-glass-a-row-work":String(t.stateAlpha.work),"--lo-glass-a-field":String(t.stateAlpha.field),"--lo-glass-a-block-veil":String(t.blockVeil[e.scheme]),"--lo-glass-a-band-floor":String(t.bandFloor[e.scheme]),"--lo-glass-a-overlay":String(h6e({intensity:e.intensity,scheme:e.scheme})),"--lo-glass-overlay-ink-mix":String(t.overlayInkMix[e.scheme]),"--lo-glass-overlay-edge-mix":String(t.overlayEdgeMix[e.scheme]),"--lo-glass-a-lane":String(Math.round(n.canvas*t.laneWash[e.scheme].scale*100)/100),"--lo-glass-lane-tone":t.laneWash[e.scheme].role==="sunken"?"var(--lo-sunken)":"var(--lo-surface)","--lo-glass-control-mix":String(t.controlMix[fOe(e.mechanism,e.material)][e.scheme]),"--lo-glass-in-surface":String(r(n.surface)),"--lo-glass-in-elevated":String(r(n.elevated))};return{kinds:p6e[e.coverage].join(" "),vars:i}}const pOe=()=>document.documentElement,g6e=["--lo-glass-a-canvas","--lo-glass-a-surface","--lo-glass-a-elevated","--lo-glass-a-row-hover","--lo-glass-a-row-selected","--lo-glass-a-row-work","--lo-glass-a-block-veil","--lo-glass-a-band-floor","--lo-glass-a-overlay","--lo-glass-overlay-ink-mix","--lo-glass-overlay-edge-mix","--lo-glass-a-lane","--lo-glass-lane-tone","--lo-glass-a-field","--lo-glass-control-mix","--lo-glass-in-surface","--lo-glass-in-elevated"];let sx=null;const pS=()=>pOe().classList.contains("dark")?"dark":"light";function mS(e){sx=e;const t=pOe();if(!e||!e.active){delete t.dataset.glass;for(const a of g6e)t.style.removeProperty(a);return}const n=yEe(document),{kinds:r,vars:i}=m6e({floors:n?vEe(n):void 0,coverage:e.settings.coverage,intensity:e.settings.intensity,mechanism:e.mechanism,material:e.settings.material,scheme:e.scheme});t.dataset.glass=r;for(const[a,o]of Object.entries(i))t.style.setProperty(a,o)}function apn(e){mS(e?{active:!0,scheme:e.scheme,mechanism:e.mechanism,settings:{coverage:e.coverage,intensity:e.intensity,material:e.material}}:null)}function I3(e){if(!e||!e.active||e.capability.mechanism==="none"){mS(null);return}e.restartRequired&&e.active||mS({active:!0,scheme:pS(),mechanism:e.capability.mechanism,settings:{coverage:e.settings.coverage,intensity:e.settings.intensity,material:e.settings.material}})}function opn(){!sx||!sx.active||(mS({...sx,scheme:pS()}),window.api?.windowGlass?.reportScheme?.(pS()))}function spn(){const e=window.api?.windowGlass;if(!e)return()=>{};const t=e.onState(r=>I3(r)),n=r=>{r&&I3(r)};return typeof CSS<"u"&&e.reportRenderer?.({backdropFilter:CSS.supports("backdrop-filter: blur(1px)")}).then(n,()=>{}),e.get?.().then(n,()=>{}),t}function lpn(){const[e,t]=$.useState(null);return $.useEffect(()=>{const r=window.api?.windowGlass;if(!r)return;let i=!1;r.get().then(o=>{i||t(o)});const a=r.onState(o=>t(o));return()=>{i=!0,a()}},[]),{state:e,set:async r=>{const i=await window.api?.windowGlass?.set(r);i&&(t(i),I3(i),window.api?.windowGlass?.reportScheme?.(pS()))}}}const $6e=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),y6e=function(e,t){return new URL(e,t).href},XI={},xe=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link"),s=document.querySelector("meta[property=csp-nonce]"),l=s?.nonce||s?.getAttribute("nonce");i=Promise.allSettled(n.map(c=>{if(c=y6e(c,r),c in XI)return;XI[c]=!0;const u=c.endsWith(".css"),O=u?'[rel="stylesheet"]':"";if(!!r)for(let m=o.length-1;m>=0;m--){const g=o[m];if(g.href===c&&(!u||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${O}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":$6e,u||(p.as="script"),p.crossOrigin="",p.href=c,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((m,g)=>{p.addEventListener("load",m),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(o){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=o,window.dispatchEvent(s),!s.defaultPrevented)throw o}return i.then(o=>{for(const s of o||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};/**
|
|
4
4
|
* React Router DOM v6.30.0
|
|
5
5
|
*
|
|
@@ -901,7 +901,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
901
901
|
`))};if(c.from==this.from&&a<this.from?c.from=a:c.to==this.to&&a>this.to&&(c.to=a),c.from==c.to&&!c.insert.length){let u=Le.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((dt.mac||dt.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:Vn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);JU(t,c,Le.single(this.toEditorPos(r.selectionStart,u),this.toEditorPos(r.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=r=>{let i=[],a=null;for(let o=this.toEditorPos(r.rangeStart),s=this.toEditorPos(r.rangeEnd);o<s;o++){let l=t.coordsForChar(o);a=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||a||new DOMRect,i.push(a)}n.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let a of r.getTextFormats()){let o=a.underlineStyle,s=a.underlineThickness;if(o!="None"&&s!="None"){let l=this.toEditorPos(a.rangeStart),c=this.toEditorPos(a.rangeEnd);if(l<c){let u=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${s=="Thin"?1:2}px`;i.push(On.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:V0e.of(On.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(t.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let i=wy(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let n=0,r=!1,i=this.pendingContextChange;return t.changes.iterChanges((a,o,s,l,c)=>{if(r)return;let u=c.length-(o-a);if(i&&o>=i.to)if(i.from==a&&i.to==o&&i.insert.eq(c)){i=this.pendingContextChange=null,n+=u,this.to+=u;return}else i=null,this.revertPending(t.state);if(a+=n,o+=n,o<=this.from)this.from+=u,this.to+=u;else if(a<this.to){if(a<this.from||o>this.to||this.to-this.from+c.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(o),c.toString()),this.to+=u}n+=u}),i&&!r&&this.revertPending(t.state),!r}update(t){let n=this.pendingContextChange,r=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(r.from,r.to)&&t.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||n)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:n}=t.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(t.doc.length,n+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),t.doc.sliceString(n.from,n.to))}setSelection(t){let{main:n}=t.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(t){let{head:n}=t.selection.main;return!(this.from>0&&n-this.from<500||this.to<t.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(t,n=this.to-this.from){t=Math.min(t,n);let r=this.composing;return r&&r.drifted?r.editorBase+(t-r.contextBase):t+this.from}toContextPos(t){let n=this.composing;return n&&n.drifted?n.contextBase+(t-n.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Pt{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:r}=t;this.dispatchTransactions=t.dispatchTransactions||r&&(i=>i.forEach(a=>r(a,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||tot(t.parent)||document,this.viewState=new cL(t.state||Wn.create(t)),t.scrollTo&&t.scrollTo.is(qw)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(lp).map(i=>new KT(i));for(let i of this.plugins)i.update(this);this.observer=new yst(this),this.inputState=new Got(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ZM(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let n=t.length==1&&t[0]instanceof Li?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,a=this.state;for(let f of t){if(f.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=f.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,l=null;t.some(f=>f.annotation(a$e))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=o$e(a,o),l||(s=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(Wn.phrases)!=this.state.facet(Wn.phrases))return this.setState(a);i=BS.create(this,a,t),i.flags|=s;let O=this.viewState.scrollTarget;try{this.updateState=2;for(let f of t){if(O&&(O=O.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection;O=new Qp(p.empty?p:Le.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of f.effects)p.is(qw)&&(O=p.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=KS.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(I0)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Ww)!=i.state.facet(Ww)&&(this.viewState.mustMeasureContent=!0),(n||r||O||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let f of this.state.facet(kC))try{f(i)}catch(p){Va(this.state,p,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!J0e(this,u)&&c.force&&Sp(this.contentDOM,c.key,c.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new cL(t),this.plugins=t.facet(lp).map(r=>new KT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new ZM(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(lp),r=t.state.facet(lp);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new KT(a));else{let s=this.plugins[o];s.mustUpdate=t,i.push(s)}}for(let a of this.plugins)a.mustUpdate!=t&&a.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=t;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let n=t.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){Va(this.state,r,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:a,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let s=0;;s++){if(o<0)if(v0e(r))a=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(i);a=p.from,o=p.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(s>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(p=>{try{return p.read(this)}catch(m){return Va(this.state,m),fL}}),O=BS.create(this,this.state,[]),f=!1;O.flags|=l,n?n.flags|=l:n=O,this.updateState=2,O.empty||(this.updatePlugins(O),this.inputState.update(O),this.updateAttrs(),f=this.docView.update(O),f&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(u[p]!=fL)try{let m=c[p];m.write&&m.write(u[p],this)}catch(m){Va(this.state,m)}if(f&&this.docView.updateSelection(!0),!O.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let m=(a<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(a).top)-o;if(m>1||m<-1){i=i+m,r.scrollTop=i/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let s of this.state.facet(kC))s(n)}get themeClasses(){return EC+" "+(this.state.facet(RC)?u$e:c$e)+" "+this.state.facet(Ww)}updateAttrs(){let t=hL(this,M0e,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ec)?"true":"false",class:"cm-content",style:`${dt.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),hL(this,BU,n);let r=this.observer.ignore(()=>{let i=wC(this.contentDOM,this.contentAttrs,n),a=wC(this.dom,this.editorAttrs,t);return i||a});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(Pt.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(I0);let t=this.state.facet(Pt.cspNonce);zO.mount(this.root,this.styleModules.concat(gst).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===t.key){this.measureRequests[n]=t;return}}this.measureRequests.push(t)}}plugin(t){let n=this.pluginMap.get(t);return(n===void 0||n&&n.plugin!=t)&&this.pluginMap.set(t,n=this.plugins.find(r=>r.plugin==t)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,n,r){return eX(this,t,FM(this,t,n,r))}moveByGroup(t,n){return eX(this,t,FM(this,t,n,r=>qot(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),a=r[n?r.length-1:0];return Le.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return Eot(this,t,n,r)}moveVertically(t,n,r){return eX(this,t,jot(this,t,n,r))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){return this.readMeasured(),K0e(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.docView.coordsAt(t,n);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(t),a=this.bidiSpans(i),o=a[dO.find(a,t-i.from,-1,n)];return ob(r,o.dir==xr.LTR==n>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(I0e)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>wst)return C0e(t.length);let n=this.textDirectionAt(t.from),r;for(let a of this.bidiCache)if(a.from==t.from&&a.dir==n&&(a.fresh||j0e(a.isolates,r=IM(this,t))))return a.order;r||(r=IM(this,t));let i=mot(t.text,n,r);return this.bidiCache.push(new KS(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||dt.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{$0e(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,n={}){return qw.of(new Qp(typeof t=="number"?Le.cursor(t):t,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return qw.of(new Qp(Le.cursor(r.from),"start","start",r.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return xi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return xi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=zO.newName(),i=[Ww.of(r),I0.of(qC(`.${r}`,t))];return n&&n.dark&&i.push(RC.of(!0)),i}static baseTheme(t){return FO.lowest(I0.of(qC("."+EC,t,O$e)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&nr.get(r)||nr.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}Pt.styleModule=I0;Pt.inputHandler=Y0e;Pt.clipboardInputFilter=LU;Pt.clipboardOutputFilter=FU;Pt.scrollHandler=D0e;Pt.focusChangeEffect=G0e;Pt.perLineTextDirection=I0e;Pt.exceptionSink=N0e;Pt.updateListener=kC;Pt.editable=Ec;Pt.mouseSelectionStyle=W0e;Pt.dragMovesSelection=U0e;Pt.clickAddsSelectionRange=A0e;Pt.decorations=xy;Pt.outerDecorations=L0e;Pt.atomicRanges=HU;Pt.bidiIsolatedRanges=F0e;Pt.scrollMargins=B0e;Pt.darkTheme=RC;Pt.cspNonce=mt.define({combine:e=>e.length?e[0]:""});Pt.contentAttributes=BU;Pt.editorAttributes=M0e;Pt.lineWrapping=Pt.contentAttributes.of({class:"cm-lineWrapping"});Pt.announce=_n.define();const wst=4096,fL={};class KS{constructor(t,n,r,i,a,o){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=a,this.order=o}static update(t,n){if(n.empty&&!t.some(a=>a.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:xr.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new KS(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function hL(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let a=r[i],o=typeof a=="function"?a(e):a;o&&bC(o,n)}return n}const xst=dt.mac?"mac":dt.windows?"win":dt.linux?"linux":"key";function Sst(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,a,o,s;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))a=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))t=="mac"?s=!0:a=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),a&&(r="Ctrl-"+r),s&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function Nw(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n!==!1&&t.shiftKey&&(e="Shift-"+e),e}const Qst=FO.default(Pt.domEventHandlers({keydown(e,t){return f$e(d$e(t.state),e,t,"editor")}})),Kk=mt.define({enables:Qst}),pL=new WeakMap;function d$e(e){let t=e.facet(Kk),n=pL.get(t);return n||pL.set(t,n=kst(t.reduce((r,i)=>r.concat(i),[]))),n}function w0n(e,t,n){return f$e(d$e(e.state),t,e,n)}let oO=null;const _st=4e3;function kst(e,t=xst){let n=Object.create(null),r=Object.create(null),i=(o,s)=>{let l=r[o];if(l==null)r[o]=s;else if(l!=s)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},a=(o,s,l,c,u)=>{var O,f;let p=n[o]||(n[o]=Object.create(null)),m=s.split(/ (?!$)/).map(v=>Sst(v,t));for(let v=1;v<m.length;v++){let b=m.slice(0,v).join(" ");i(b,!0),p[b]||(p[b]={preventDefault:!0,stopPropagation:!1,run:[x=>{let Q=oO={view:x,prefix:b,scope:o};return setTimeout(()=>{oO==Q&&(oO=null)},_st),!0}]})}let g=m.join(" ");i(g,!1);let y=p[g]||(p[g]={preventDefault:!1,stopPropagation:!1,run:((f=(O=p._any)===null||O===void 0?void 0:O.run)===null||f===void 0?void 0:f.slice())||[]});l&&y.run.push(l),c&&(y.preventDefault=!0),u&&(y.stopPropagation=!0)};for(let o of e){let s=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of s){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:O}=o;for(let f in u)u[f].run.push(p=>O(p,jC))}let l=o[t]||o.key;if(l)for(let c of s)a(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&a(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return n}let jC=null;function f$e(e,t,n,r){jC=t;let i=Bat(t),a=yo(i,0),o=Rc(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;oO&&oO.view==n&&oO.scope==r&&(s=oO.prefix+" ",t$e.indexOf(t.keyCode)<0&&(c=!0,oO=null));let O=new Set,f=y=>{if(y){for(let v of y.run)if(!O.has(v)&&(O.add(v),v(n)))return y.stopPropagation&&(u=!0),!0;y.preventDefault&&(y.stopPropagation&&(u=!0),c=!0)}return!1},p=e[r],m,g;return p&&(f(p[s+Nw(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(dt.windows&&t.ctrlKey&&t.altKey)&&(m=AO[t.keyCode])&&m!=i?(f(p[s+Nw(m,t,!0)])||t.shiftKey&&(g=by[t.keyCode])!=i&&g!=m&&f(p[s+Nw(g,t,!1)]))&&(l=!0):o&&t.shiftKey&&f(p[s+Nw(i,t,!0)])&&(l=!0),!l&&f(p._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),jC=null,l}class cb{constructor(t,n,r,i,a){this.className=t,this.left=n,this.top=r,this.width=i,this.height=a}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=h$e(t);return[new cb(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return Pst(t,n,r)}}function h$e(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==xr.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function mL(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),l=e.posAtCoords({x:a.right-1,y:o});return s==null||l==null?r:{from:Math.max(r.from,Math.min(s,l)),to:Math.min(r.to,Math.max(s,l))}}function Pst(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==xr.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=h$e(e),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),O=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=TC(e,r,1),m=TC(e,i,-1),g=p.type==Ea.Text?p:null,y=m.type==Ea.Text?m:null;if(g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=mL(e,r,1,g)),y&&(e.lineWrapping||m.widgetLineBreaks)&&(y=mL(e,i,-1,y)),g&&y&&g.from==y.from&&g.to==y.to)return b(x(n.from,n.to,g));{let w=g?x(n.from,null,g):Q(p,!1),S=y?x(null,n.to,y):Q(m,!0),_=[];return(g||p).to<(y||m).from-(g&&y?1:0)||p.widgetLineBreaks>1&&w.bottom+e.defaultLineHeight/2<S.top?_.push(v(O,w.bottom,f,S.top)):w.bottom<S.top&&e.elementAtHeight((w.bottom+S.top)/2).type==Ea.Text&&(w.bottom=S.top=(w.bottom+S.top)/2),b(w).concat(_).concat(b(S))}function v(w,S,_,k){return new cb(t,w-l.left,S-l.top,_-w,k-S)}function b({top:w,bottom:S,horizontal:_}){let k=[];for(let R=0;R<_.length;R+=2)k.push(v(_[R],w,_[R+1],S));return k}function x(w,S,_){let k=1e9,R=-1e9,E=[];function T(G,I,C,U,Y){let V=e.coordsAtPos(G,G==_.to?-2:2),z=e.coordsAtPos(C,C==_.from?2:-2);!V||!z||(k=Math.min(V.top,z.top,k),R=Math.max(V.bottom,z.bottom,R),Y==xr.LTR?E.push(a&&I?O:V.left,a&&U?f:z.right):E.push(!a&&U?O:z.left,!a&&I?f:V.right))}let q=w??_.from,A=S??_.to;for(let G of e.visibleRanges)if(G.to>q&&G.from<A)for(let I=Math.max(G.from,q),C=Math.min(G.to,A);;){let U=e.state.doc.lineAt(I);for(let Y of e.bidiSpans(U)){let V=Y.from+U.from,z=Y.to+U.from;if(V>=C)break;z>I&&T(Math.max(V,I),w==null&&V<=q,Math.min(z,C),S==null&&z>=A,Y.dir)}if(I=U.to+1,I>=C)break}return E.length==0&&T(q,w==null,A,S==null,e.textDirection),{top:k,bottom:R,horizontal:E}}function Q(w,S){let _=s.top+(S?w.top:w.bottom);return{top:_,bottom:_,horizontal:[]}}}function Tst(e,t){return e.constructor==t.constructor&&e.eq(t)}class Xst{constructor(t,n){this.view=t,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,t)}update(t){t.startState.facet(_x)!=t.state.facet(_x)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let n=0,r=t.facet(_x);for(;n<r.length&&r[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:n}=this.view;(t!=this.scaleX||n!=this.scaleY)&&(this.scaleX=t,this.scaleY=n,this.dom.style.transform=`scale(${1/t}, ${1/n})`)}draw(t){if(t.length!=this.drawn.length||t.some((n,r)=>!Tst(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let i of t)i.update&&n&&i.constructor&&this.drawn[r].constructor&&i.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(i.draw(),n);for(;n;){let i=n.nextSibling;n.remove(),n=i}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const _x=mt.define();function p$e(e){return[xi.define(t=>new Xst(t,e)),_x.of(e)]}const Sy=mt.define({combine(e){return ng(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function x0n(e={}){return[Sy.of(e),Rst,Est,qst,Z0e.of(!0)]}function m$e(e){return e.startState.facet(Sy)!=e.state.facet(Sy)}const Rst=p$e({above:!0,markers(e){let{state:t}=e,n=t.facet(Sy),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor){let o=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",s=i.empty?i:Le.cursor(i.head,i.head>i.anchor?-1:1);for(let l of cb.forRange(e,o,s))r.push(l)}}return r},update(e,t){e.transactions.some(r=>r.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=m$e(e);return n&&gL(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){gL(t.state,e)},class:"cm-cursorLayer"});function gL(e,t){t.style.animationDuration=e.facet(Sy).cursorBlinkRate+"ms"}const Est=p$e({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:cb.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||m$e(e)},class:"cm-selectionLayer"}),qst=FO.highest(Pt.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),g$e=_n.define({map(e,t){return e==null?null:t.mapPos(e)}}),V0=eo.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(g$e)?r.value:n,e)}}),jst=xi.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(V0);n==null?this.cursor!=null&&((t=this.cursor)===null||t===void 0||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(V0)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(V0),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(V0)!=e&&this.view.dispatch({effects:g$e.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function S0n(){return[V0,jst]}function $L(e,t,n,r,i){t.lastIndex=0;for(let a=e.iterRange(n,r),o=n,s;!a.next().done;o+=a.value.length)if(!a.lineBreak)for(;s=t.exec(a.value);)i(o+s.index,s)}function Cst(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:a}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),a=Math.min(e.state.doc.lineAt(a).to,a+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=a:r.push({from:i,to:a});return r}class zst{constructor(t){const{regexp:n,decoration:r,decorate:i,boundary:a,maxLength:o=1e3}=t;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,i)this.addMatch=(s,l,c,u)=>i(u,c,c+s[0].length,s,l);else if(typeof r=="function")this.addMatch=(s,l,c,u)=>{let O=r(s,l,c);O&&u(c,c+s[0].length,O)};else if(r)this.addMatch=(s,l,c,u)=>u(c,c+s[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=a,this.maxLength=o}createDeco(t){let n=new yf,r=n.add.bind(n);for(let{from:i,to:a}of Cst(t,this.maxLength))$L(t.state.doc,this.regexp,i,a,(o,s)=>this.addMatch(s,t,o,r));return n.finish()}updateDeco(t,n){let r=1e9,i=-1;return t.docChanged&&t.changes.iterChanges((a,o,s,l)=>{l>=t.view.viewport.from&&s<=t.view.viewport.to&&(r=Math.min(s,r),i=Math.max(l,i))}),t.viewportMoved||i-r>1e3?this.createDeco(t.view):i>-1?this.updateRange(t.view,n.map(t.changes),r,i):n}updateRange(t,n,r,i){for(let a of t.visibleRanges){let o=Math.max(a.from,r),s=Math.min(a.to,i);if(s>=o){let l=t.state.doc.lineAt(o),c=l.to<s?t.state.doc.lineAt(s):l,u=Math.max(a.from,l.from),O=Math.min(a.to,c.to);if(this.boundary){for(;o>l.from;o--)if(this.boundary.test(l.text[o-1-l.from])){u=o;break}for(;s<c.to;s++)if(this.boundary.test(c.text[s-c.from])){O=s;break}}let f=[],p,m=(g,y,v)=>f.push(v.range(g,y));if(l==c)for(this.regexp.lastIndex=u-l.from;(p=this.regexp.exec(l.text))&&p.index<O-l.from;)this.addMatch(p,t,p.index+l.from,m);else $L(t.state.doc,this.regexp,u,O,(g,y)=>this.addMatch(y,t,g,m));n=n.update({filterFrom:u,filterTo:O,filter:(g,y)=>g<u||y>O,add:f})}}return n}}const CC=/x/.unicode!=null?"gu":"g",Ast=new RegExp(`[\0-\b
|
|
902
902
|
--\u2028\u2029\uFEFF-]`,CC),Ust={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let rX=null;function Wst(){var e;if(rX==null&&typeof document<"u"&&document.body){let t=document.body.style;rX=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return rX||!1}const kx=mt.define({combine(e){let t=ng(e,{render:null,specialChars:Ast,addSpecialChars:null});return(t.replaceTabs=!Wst())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,CC)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,CC)),t}});function Q0n(e={}){return[kx.of(e),Nst()]}let yL=null;function Nst(){return yL||(yL=xi.fromClass(class{constructor(e){this.view=e,this.decorations=On.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(kx)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new zst({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=yo(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=CO(o.text,s,r-o.from);return On.replace({widget:new Zst((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=On.replace({widget:new Ist(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(kx);e.startState.facet(kx)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const Yst="•";function Gst(e){return e>=32?Yst:e==10?"":String.fromCharCode(9216+e)}class Ist extends xu{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=Gst(this.code),r=t.state.phrase("Control character")+" "+(Ust[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let a=document.createElement("span");return a.textContent=n,a.title=r,a.setAttribute("aria-label",r),a.className="cm-specialChar",a}ignoreEvent(){return!1}}class Zst extends xu{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function _0n(){return Vst}const Dst=On.line({class:"cm-activeLine"}),Vst=xi.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(Dst.range(i.from)),t=i.from)}return On.set(n)}},{decorations:e=>e.decorations});class Mst extends xu{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?nm(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=ob(n[0],r.direction!="rtl"),a=parseInt(r.lineHeight);return i.bottom-i.top>a*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+a}:i}ignoreEvent(){return!1}}function k0n(e){let t=xi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?On.set([On.widget({widget:new Mst(e),side:1}).range(0)]):On.none}get decorations(){return this.view.state.doc.length?On.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,Pt.contentAttributes.of({"aria-placeholder":e})]:t}const zC=2e3;function Lst(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>zC||n.off>zC||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let c=e.doc.line(l);c.length<=s&&a.push(Le.range(c.from+o,c.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let c=e.doc.line(l),u=hC(c.text,o,e.tabSize,!0);if(u<0)a.push(Le.cursor(c.to));else{let O=hC(c.text,s,e.tabSize);a.push(Le.range(c.from+u,c.from+O))}}}return a}function Fst(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function vL(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>zC?-1:i==r.length?Fst(e,t.clientX):CO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function Bst(e,t){let n=vL(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let a=i.changes.mapPos(i.startState.doc.line(n.line).from),o=i.state.doc.lineAt(a);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},r=r.map(i.changes)}},get(i,a,o){let s=vL(e,i);if(!s)return r;let l=Lst(e.state,n,s);return l.length?o?Le.create(l.concat(r.ranges)):Le.create(l):r}}:null}function P0n(e){let t=n=>n.altKey&&n.button==0;return Pt.mouseSelectionStyle.of((n,r)=>t(r)?Bst(n,r):null)}const Hst={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Kst={style:"cursor: crosshair"};function T0n(e={}){let[t,n]=Hst[e.key||"Alt"],r=xi.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,Pt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?Kst:null})]}const Jg="-10000px";class $$e{constructor(t,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=t.state.facet(n),this.tooltips=this.input.filter(o=>o);let a=null;this.tooltipViews=this.tooltips.map(o=>a=r(o,a))}update(t,n){var r;let i=t.state.facet(this.facet),a=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(t);return!1}let o=[],s=n?[]:null;for(let l=0;l<a.length;l++){let c=a[l],u=-1;if(c){for(let O=0;O<this.tooltips.length;O++){let f=this.tooltips[O];f&&f.create==c.create&&(u=O)}if(u<0)o[l]=this.createTooltipView(c,l?o[l-1]:null),s&&(s[l]=!!c.above);else{let O=o[l]=this.tooltipViews[u];s&&(s[l]=n[u]),O.update&&O.update(t)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(s.forEach((l,c)=>n[c]=l),n.length=s.length),this.input=i,this.tooltips=a,this.tooltipViews=o,!0}}function Jst(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const iX=mt.define({combine:e=>{var t,n,r;return{position:dt.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||Jst}}}),bL=new WeakMap,nW=xi.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(iX);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new $$e(e,rW,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(iX);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=Jg,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(dt.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==Jg&&a.style.left=="0px"){let o=a.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(n||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(e=a.width/this.parent.offsetWidth,t=a.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=KU(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,o)=>{let s=this.manager.tooltipViews[o];return s.getCoords?s.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(iX).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let s of this.manager.tooltipViews)s.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:a}=e,o=[];for(let s=0;s<this.manager.tooltips.length;s++){let l=this.manager.tooltips[s],c=this.manager.tooltipViews[s],{dom:u}=c,O=e.pos[s],f=e.size[s];if(!O||l.clip!==!1&&(O.bottom<=Math.max(n.top,r.top)||O.top>=Math.min(n.bottom,r.bottom)||O.right<Math.max(n.left,r.left)-.1||O.left>Math.min(n.right,r.right)+.1)){u.style.top=Jg;continue}let p=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,m=p?7:0,g=f.right-f.left,y=(t=bL.get(c))!==null&&t!==void 0?t:f.bottom-f.top,v=c.offset||tlt,b=this.view.textDirection==xr.LTR,x=f.width>r.right-r.left?b?r.left:r.right-f.width:b?Math.max(r.left,Math.min(O.left-(p?14:0)+v.x,r.right-g)):Math.min(Math.max(r.left,O.left-g+(p?14:0)-v.x),r.right-g),Q=this.above[s];!l.strictSide&&(Q?O.top-y-m-v.y<r.top:O.bottom+y+m+v.y>r.bottom)&&Q==r.bottom-O.bottom>O.top-r.top&&(Q=this.above[s]=!Q);let w=(Q?O.top-r.top:r.bottom-O.bottom)-m;if(w<y&&c.resize!==!1){if(w<this.view.defaultLineHeight){u.style.top=Jg;continue}bL.set(c,y),u.style.height=(y=w)/a+"px"}else u.style.height&&(u.style.height="");let S=Q?O.top-y-m-v.y:O.bottom+m+v.y,_=x+g;if(c.overlap!==!0)for(let k of o)k.left<_&&k.right>x&&k.top<S+y&&k.bottom>S&&(S=Q?k.top-y-2-m:k.bottom+m+2);if(this.position=="absolute"?(u.style.top=(S-e.parent.top)/a+"px",wL(u,(x-e.parent.left)/i)):(u.style.top=S/a+"px",wL(u,x/i)),p){let k=O.left+(b?v.x:-v.x)-(x+14-7);p.style.left=k/i+"px"}c.overlap!==!0&&o.push({left:x,top:S,right:_,bottom:S+y}),u.classList.toggle("cm-tooltip-above",Q),u.classList.toggle("cm-tooltip-below",!Q),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=Jg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function wL(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const elt=Pt.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),tlt={x:0,y:0},rW=mt.define({enables:[nW,elt]}),JS=mt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class Jk{static create(t){return new Jk(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new $$e(t,JS,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(t,n){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let r of this.manager.tooltipViews){let i=r[t];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const nlt=rW.compute([JS],e=>{let t=e.facet(JS);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Jk.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class rlt{constructor(t,n,r,i,a){this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:n}=this,r=t.docView.nearest(n.target);if(!r)return;let i,a=1;if(r instanceof OO)i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let s=t.coordsAtPos(i);if(!s||n.y<s.top||n.y>s.bottom||n.x<s.left-t.defaultCharacterWidth||n.x>s.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==xr.RTL?-1:1;a=n.x<s.left?-c:c}let o=this.source(t,i,a);if(o?.then){let s=this.pending={pos:i};o.then(l=>{this.pending==s&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Va(t.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let t=this.view.plugin(nW),n=t?t.manager.tooltips.findIndex(r=>r.create==Jk.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,r;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:a}=this;if(i.length&&a&&!ilt(a.dom,t)||this.pending){let{pos:o}=i[0]||this.pending,s=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==s?this.view.posAtCoords(this.lastMove)!=o:!alt(this.view,o,s,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:r}=this;r&&r.dom.contains(t.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=r=>{t.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Yw=4;function ilt(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(".cm-tooltip-arrow")){let s=o.getBoundingClientRect();i=Math.min(s.top,i),a=Math.max(s.bottom,a)}return t.clientX>=n-Yw&&t.clientX<=r+Yw&&t.clientY>=i-Yw&&t.clientY<=a+Yw}function alt(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let l=e.posAtCoords({x:r,y:i},!1);return l>=t&&l<=n}function X0n(e,t={}){let n=_n.define(),r=eo.define({create(){return[]},update(i,a){if(i.length&&(t.hideOnChange&&(a.docChanged||a.selection)?i=[]:t.hideOn&&(i=i.filter(o=>!t.hideOn(a,o))),a.docChanged)){let o=[];for(let s of i){let l=a.changes.mapPos(s.pos,-1,Mi.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),s);c.pos=l,c.end!=null&&(c.end=a.changes.mapPos(c.end)),o.push(c)}}i=o}for(let o of a.effects)o.is(n)&&(i=o.value),o.is(olt)&&(i=[]);return i},provide:i=>JS.from(i)});return{active:r,extension:[r,xi.define(i=>new rlt(i,e,r,n,t.hoverTime||300)),nlt]}}function y$e(e,t){let n=e.plugin(nW);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const olt=_n.define(),xL=mt.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function R0n(e,t){let n=e.plugin(v$e),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const v$e=xi.fromClass(class{constructor(e){this.input=e.state.facet(QL),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(xL);this.top=new Gw(e,!0,t.topContainer),this.bottom=new Gw(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(xL);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Gw(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Gw(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(QL);if(n!=this.input){let r=n.filter(l=>l),i=[],a=[],o=[],s=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(e.view),s.push(u)):(u=this.panels[c],u.update&&u.update(e)),i.push(u),(u.top?a:o).push(u)}this.specs=r,this.panels=i,this.top.sync(a),this.bottom.sync(o);for(let l of s)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Pt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Gw{constructor(t,n,r){this.view=t,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=SL(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=SL(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function SL(e){let t=e.nextSibling;return e.remove(),t}const QL=mt.define({enables:v$e});class su extends $f{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}su.prototype.elementClass="";su.prototype.toDOM=void 0;su.prototype.mapMode=Mi.TrackBefore;su.prototype.startSide=su.prototype.endSide=-1;su.prototype.point=!0;const Px=mt.define(),slt=mt.define(),llt={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Qn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},x$=mt.define();function clt(e){return[b$e(),x$.of({...llt,...e})]}const _L=mt.define({combine:e=>e.some(t=>t)});function b$e(e){return[ult]}const ult=xi.fromClass(class{constructor(e){this.view=e,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(x$).map(t=>new PL(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(_L),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(_L)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&this.dom.remove();let n=Qn.iter(this.view.state.facet(Px),this.view.viewport.from),r=[],i=this.gutters.map(a=>new Olt(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let o=!0;for(let s of a.type)if(s.type==Ea.Text&&o){AC(n,r,s.from);for(let l of i)l.line(this.view,s,r);o=!1}else if(s.widget)for(let l of i)l.widget(this.view,s)}else if(a.type==Ea.Text){AC(n,r,a.from);for(let o of i)o.line(this.view,a,r)}else if(a.widget)for(let o of i)o.widget(this.view,a);for(let a of i)a.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(x$),n=e.state.facet(x$),r=e.docChanged||e.heightChanged||e.viewportChanged||!Qn.eq(e.startState.facet(Px),e.state.facet(Px),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let a of n){let o=t.indexOf(a);o<0?i.push(new PL(this.view,a)):(this.gutters[o].update(e),i.push(this.gutters[o]))}for(let a of this.gutters)a.dom.remove(),i.indexOf(a)<0&&a.destroy();for(let a of i)this.dom.appendChild(a.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>Pt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==xr.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function kL(e){return Array.isArray(e)?e:[e]}function AC(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Olt{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=Qn.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,a=(n.top-this.height)/t.scaleY,o=n.height/t.scaleY;if(this.i==i.elements.length){let s=new w$e(t,o,a,r);i.elements.push(s),i.dom.appendChild(s.dom)}else i.elements[this.i].update(t,o,a,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];AC(this.cursor,i,n.from),r.length&&(i=i.concat(r));let a=this.gutter.config.lineMarker(t,n,i);a&&i.unshift(a);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(t,n,i)}widget(t,n){let r=this.gutter.config.widgetMarker(t,n.widget,n),i=r?[r]:null;for(let a of t.state.facet(slt)){let o=a(t,n.widget,n);o&&(i||(i=[])).push(o)}i&&this.addElement(t,n,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class PL{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let a=i.target,o;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let l=a.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=i.clientY;let s=t.lineBlockAtHeight(o-t.documentTop);n.domEventHandlers[r](t,s,i)&&i.preventDefault()});this.markers=kL(n.markers(t)),n.initialSpacer&&(this.spacer=new w$e(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=kL(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],t);i!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[i])}let r=t.view.viewport;return!Qn.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class w$e{constructor(t,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,r,i)}update(t,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),dlt(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let a=0,o=0;;){let s=o,l=a<n.length?n[a++]:null,c=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let O=o;O<this.markers.length;O++)if(this.markers[O].compare(l)){s=O,c=!0;break}}else s=this.markers.length;for(;o<s;){let u=this.markers[o++];if(u.toDOM){u.destroy(i);let O=i.nextSibling;i.remove(),i=O}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(t),i)),c&&o++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function dlt(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}const flt=mt.define(),hlt=mt.define(),cp=mt.define({combine(e){return ng(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let a=r[i],o=n[i];r[i]=a?(s,l,c)=>a(s,l,c)||o(s,l,c):o}return r}})}});class aX extends su{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function oX(e,t){return e.state.facet(cp).formatNumber(t,e.state)}const plt=x$.compute([cp],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(flt)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new aX(oX(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(hlt)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(cp)!=t.state.facet(cp),initialSpacer(t){return new aX(oX(t,TL(t.state.doc.lines)))},updateSpacer(t,n){let r=oX(n.view,TL(n.view.state.doc.lines));return r==t.number?t:new aX(r)},domEventHandlers:e.facet(cp).domEventHandlers}));function E0n(e={}){return[cp.of(e),b$e(),plt]}function TL(e){let t=9;for(;t<e;)t=t*10+9;return t}const mlt=new class extends su{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},glt=Px.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(mlt.range(i)))}return Qn.of(t)});function q0n(){return glt}let $lt=0;class ot{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=$lt++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof ot&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new ot(r,[],null,[]);if(i.set.push(i),n)for(let a of n.set)i.set.push(a);return i}static defineModifier(t){let n=new eQ(t);return r=>r.modified.indexOf(n)>-1?r:eQ.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let ylt=0;class eQ{constructor(t){this.name=t,this.instances=[],this.id=ylt++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&vlt(n,s.modified));if(r)return r;let i=[],a=new ot(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=blt(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(eQ.get(s,l));return a}}function vlt(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function blt(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((n,r)=>r.length-n.length)}function jn(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let a=[],o=2,s=i;for(let O=0;;){if(s=="..."&&O>0&&O+3==i.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!f)throw new RangeError("Invalid path: "+i);if(a.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),O+=f[0].length,O==i.length)break;let p=i[O++];if(O==i.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+i);s=i.slice(O)}let l=a.length-1,c=a[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new tQ(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return x$e.add(t)}const x$e=new Vt;let tQ=class{constructor(t,n,r,i){this.tags=t,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}};tQ.empty=new tQ([],2,null);function S$e(e,t){let n=Object.create(null);for(let a of e)if(!Array.isArray(a.tag))n[a.tag.id]=a.class;else for(let o of a.tag)n[o.id]=a.class;let{scope:r,all:i=null}=t||{};return{style:a=>{let o=i;for(let s of a)for(let l of s.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function wlt(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function xlt(e,t,n,r=0,i=e.length){let a=new Slt(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class Slt{constructor(t,n,r){this.at=t,this.highlighters=n,this.span=r,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,r,i,a){let{type:o,from:s,to:l}=t;if(s>=r||l<=n)return;o.isTop&&(a=this.highlighters.filter(p=>!p.scope||p.scope(o)));let c=i,u=Qlt(t)||tQ.empty,O=wlt(a,u.tags);if(O&&(c&&(c+=" "),c+=O,u.mode==1&&(i+=(i?" ":"")+O)),this.startSpan(Math.max(n,s),c),u.opaque)return;let f=t.tree&&t.tree.prop(Vt.mounted);if(f&&f.overlay){let p=t.node.enter(f.overlay[0].from+s,1),m=this.highlighters.filter(y=>!y.scope||y.scope(f.tree.type)),g=t.firstChild();for(let y=0,v=s;;y++){let b=y<f.overlay.length?f.overlay[y]:null,x=b?b.from+s:l,Q=Math.max(n,v),w=Math.min(r,x);if(Q<w&&g)for(;t.from<w&&(this.highlightRange(t,Q,w,i,a),this.startSpan(Math.min(w,t.to),c),!(t.to>=x||!t.nextSibling())););if(!b||x>r)break;v=b.to+s,v>n&&(this.highlightRange(p.cursor(),Math.max(n,b.from+s),Math.min(r,v),"",m),this.startSpan(Math.min(r,v),c))}g&&t.parent()}else if(t.firstChild()){f&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,a),this.startSpan(Math.min(r,t.to),c)}while(t.nextSibling());t.parent()}}}function Qlt(e){let t=e.type.prop(x$e);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const tt=ot.define,Iw=tt(),Ku=tt(),XL=tt(Ku),RL=tt(Ku),Ju=tt(),Zw=tt(Ju),sX=tt(Ju),gl=tt(),gd=tt(gl),dl=tt(),fl=tt(),UC=tt(),e0=tt(UC),Dw=tt(),P={comment:Iw,lineComment:tt(Iw),blockComment:tt(Iw),docComment:tt(Iw),name:Ku,variableName:tt(Ku),typeName:XL,tagName:tt(XL),propertyName:RL,attributeName:tt(RL),className:tt(Ku),labelName:tt(Ku),namespace:tt(Ku),macroName:tt(Ku),literal:Ju,string:Zw,docString:tt(Zw),character:tt(Zw),attributeValue:tt(Zw),number:sX,integer:tt(sX),float:tt(sX),bool:tt(Ju),regexp:tt(Ju),escape:tt(Ju),color:tt(Ju),url:tt(Ju),keyword:dl,self:tt(dl),null:tt(dl),atom:tt(dl),unit:tt(dl),modifier:tt(dl),operatorKeyword:tt(dl),controlKeyword:tt(dl),definitionKeyword:tt(dl),moduleKeyword:tt(dl),operator:fl,derefOperator:tt(fl),arithmeticOperator:tt(fl),logicOperator:tt(fl),bitwiseOperator:tt(fl),compareOperator:tt(fl),updateOperator:tt(fl),definitionOperator:tt(fl),typeOperator:tt(fl),controlOperator:tt(fl),punctuation:UC,separator:tt(UC),bracket:e0,angleBracket:tt(e0),squareBracket:tt(e0),paren:tt(e0),brace:tt(e0),content:gl,heading:gd,heading1:tt(gd),heading2:tt(gd),heading3:tt(gd),heading4:tt(gd),heading5:tt(gd),heading6:tt(gd),contentSeparator:tt(gl),list:tt(gl),quote:tt(gl),emphasis:tt(gl),strong:tt(gl),link:tt(gl),monospace:tt(gl),strikethrough:tt(gl),inserted:tt(),deleted:tt(),changed:tt(),invalid:tt(),meta:Dw,documentMeta:tt(Dw),annotation:tt(Dw),processingInstruction:tt(Dw),definition:ot.defineModifier("definition"),constant:ot.defineModifier("constant"),function:ot.defineModifier("function"),standard:ot.defineModifier("standard"),local:ot.defineModifier("local"),special:ot.defineModifier("special")};for(let e in P){let t=P[e];t instanceof ot&&(t.name=e)}S$e([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var lX;const fO=new Vt;function eP(e){return mt.define({combine:e?t=>t.concat(e):void 0})}const iW=new Vt;class So{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Wn.prototype.hasOwnProperty("tree")||Object.defineProperty(Wn.prototype,"tree",{get(){return Mn(this)}}),this.parser=n,this.extension=[WO.of(this),Wn.languageData.of((a,o,s)=>{let l=EL(a,o,s),c=l.type.prop(fO);if(!c)return[];let u=a.facet(c),O=l.type.prop(iW);if(O){let f=l.resolve(o-l.from,s);for(let p of O)if(p.test(f,a)){let m=a.facet(p.facet);return p.type=="replace"?m:m.concat(u)}}return u})].concat(r)}isActiveAt(t,n,r=-1){return EL(t,n,r).type.prop(fO)==this.data}findRegions(t){let n=t.facet(WO);if(n?.data==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(a,o)=>{if(a.prop(fO)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(Vt.mounted);if(s){if(s.tree.prop(fO)==this.data){if(s.overlay)for(let l of s.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+a.length});return}else if(s.overlay){let l=r.length;if(i(s.tree,s.overlay[0].from+o),r.length>l)return}}for(let l=0;l<a.children.length;l++){let c=a.children[l];c instanceof pn&&i(c,a.positions[l]+o)}};return i(Mn(t),0),r}get allowsNesting(){return!0}}So.setState=_n.define();function EL(e,t,n){let r=e.facet(WO),i=Mn(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,tr.ExcludeBuffers))a.type.isTop&&(i=a);return i}class Tn extends So{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=eP(t.languageData);return new Tn(n,t.parser.configure({props:[fO.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Tn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Mn(e){let t=e.field(So.state,!1);return t?t.tree:pn.empty}class _lt{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let r=this.cursorPos-this.string.length;return t<r||n>=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-r,n-r)}}let t0=null;class xf{constructor(t,n,r=[],i,a,o,s,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=a,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new xf(t,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new _lt(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(Lc.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,n;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(Lc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=t0;t0=this;try{return t()}finally{t0=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=qL(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((c,u,O,f)=>l.push({fromA:c,toA:u,fromB:O,toB:f})),r=Lc.applyChanges(r,l),i=pn.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let c of this.skipped){let u=t.mapPos(c.from,1),O=t.mapPos(c.to,-1);u<O&&s.push({from:u,to:O})}}}return new xf(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:a}=this.skipped[r];i<t.to&&a>t.from&&(this.fragments=qL(this.fragments,i,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends Lk{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=t0;if(l){for(let c of i)l.tempSkipped.push(c);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new pn(fi.none,[],[],o-a)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return t0}}function qL(e,t,n){return Lc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class om{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new om(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=xf.create(t.facet(WO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new om(r)}}So.state=eo.define({create:om.init,update(e,t){for(let n of t.effects)if(n.is(So.setState))return n.value;return t.startState.facet(WO)!=t.state.facet(WO)?om.init(t.state):e.apply(t)}});let Q$e=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Q$e=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const cX=typeof navigator<"u"&&(!((lX=navigator.scheduling)===null||lX===void 0)&&lX.isInputPending)?()=>navigator.scheduling.isInputPending():null,klt=xi.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(So.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(So.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Q$e(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,a=r.field(So.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!cX?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>cX&&cX()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:So.setState.of(new om(a.context))})),this.chunkBudget>0&&!(l&&!s)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Va(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),WO=mt.define({combine(e){return e.length?e[0]:null},enables:e=>[So.state,klt,Pt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class bn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class ye{constructor(t,n,r,i,a,o=void 0){this.name=t,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=a,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(r)}return new ye(t.name,(t.alias||[]).concat(t.name).map(i=>i.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(t,n){for(let i of t)if(i.filename&&i.filename.test(n))return i;let r=/\.([^.]+)$/.exec(n);if(r){for(let i of t)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(t,n,r=!0){n=n.toLowerCase();for(let i of t)if(i.alias.some(a=>a==n))return i;if(r)for(let i of t)for(let a of i.alias){let o=n.indexOf(a);if(o>-1&&(a.length>2||!/\w/.test(n[o-1])&&!/\w/.test(n[o+a.length])))return i}return null}}const Plt=mt.define(),tP=mt.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function nQ(e){let t=e.facet(tP);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Tlt(e,t){let n="",r=e.tabSize,i=e.facet(tP)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function Xlt(e,t){e instanceof Wn&&(e=new _$e(e));for(let r of e.state.facet(Plt)){let i=r(e,t);if(i!==void 0)return i}let n=Mn(e.state);return n.length>=t?Rlt(e,n,t):null}class _$e{constructor(t,n={}){this.state=t,this.options=n,this.unit=nQ(t)}lineAt(t,n=1){let r=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:a}=this.options;return i!=null&&i>=r.from&&i<=r.to?a&&i==t?{text:"",from:t}:(n<0?i<t:i<=t)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(t,n=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(t,n);return r.slice(t-i,Math.min(r.length,t+100-i))}column(t,n=1){let{text:r,from:i}=this.lineAt(t,n),a=this.countColumn(r,t-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(a+=o-this.countColumn(r,r.search(/\S|$/))),a}countColumn(t,n=t.length){return CO(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:r,from:i}=this.lineAt(t,n),a=this.options.overrideIndentation;if(a){let o=a(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ar=new Vt;function Rlt(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let a=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)a.push(o);for(let o=a.length-1;o>=0;o--)r={node:a[o],next:r}}return k$e(r,e,n)}function k$e(e,t,n){for(let r=e;r;r=r.next){let i=qlt(r.node);if(i)return i(aW.create(t,n,r))}return 0}function Elt(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function qlt(e){let t=e.type.prop(Ar);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Vt.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>P$e(o,!0,1,void 0,a&&!Elt(o)?i.from:void 0)}return e.parent==null?jlt:null}function jlt(){return 0}class aW extends _$e{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new aW(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(Clt(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return k$e(this.context.next,this.base,this.pos)}}function Clt(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function zlt(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let s=n.to;;){let l=t.childAfter(s);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+c}}s=l.to}}function os({closing:e,align:t=!0,units:n=1}){return r=>P$e(r,t,n,e)}function P$e(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,l=t?zlt(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const oW=e=>e.baseIndent;function Ir({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const Alt=200;function z0n(){return Wn.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+Alt)return e;let a=n.sliceString(i.from,r);if(!t.some(c=>c.test(a)))return e;let{state:o}=e,s=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==s)continue;s=u.from;let O=Xlt(o,u.from);if(O==null)continue;let f=/^\s*/.exec(u.text)[0],p=Tlt(o,O);f!=p&&l.push({from:u.from,to:u.from+f.length,insert:p})}return l.length?[e,{changes:l,sequential:!0}]:e})}const T$e=mt.define(),_r=new Vt;function ma(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function Ult(e,t,n){let r=Mn(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(a&&s.from<t)break;let l=s.type.prop(_r);if(l&&(s.to<r.length-50||r.length==e.doc.length||!Wlt(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function Wlt(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function rQ(e,t,n){for(let r of e.facet(T$e)){let i=r(e,t,n);if(i)return i}return Ult(e,t,n)}function X$e(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const nP=_n.define({map:X$e}),ub=_n.define({map:X$e});function R$e(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(r=>r.from<=n&&r.to>=n)||t.push(e.lineBlockAt(n));return t}const Sf=eo.define({create(){return On.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(nP)&&!Nlt(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(j$e),i=r?On.replace({widget:new Vlt(r(t.state,n.value))}):jL;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(ub)&&(e=e.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:r}=t.selection.main;e.between(r,r,(i,a)=>{i<r&&a>r&&(n=!0)}),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(i,a)=>a<=r||i>=r}))}return e},provide:e=>Pt.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");t.push(jL.range(r,i))}return On.set(t,!0)}});function iQ(e,t,n){var r;let i=null;return(r=e.field(Sf,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function Nlt(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function E$e(e,t){return e.field(Sf,!1)?t:t.concat(_n.appendConfig.of(C$e()))}const Ylt=e=>{for(let t of R$e(e)){let n=rQ(e.state,t.from,t.to);if(n)return e.dispatch({effects:E$e(e.state,[nP.of(n),q$e(e,n)])}),!0}return!1},Glt=e=>{if(!e.state.field(Sf,!1))return!1;let t=[];for(let n of R$e(e)){let r=iQ(e.state,n.from,n.to);r&&t.push(ub.of(r),q$e(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function q$e(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return Pt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const Ilt=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=rQ(t,i.from,i.to);a&&n.push(nP.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:E$e(e.state,n)}),!!n.length},Zlt=e=>{let t=e.state.field(Sf,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(ub.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},A0n=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Ylt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Glt},{key:"Ctrl-Alt-[",run:Ilt},{key:"Ctrl-Alt-]",run:Zlt}],Dlt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},j$e=mt.define({combine(e){return ng(e,Dlt)}});function C$e(e){return[Sf,Llt]}function z$e(e,t){let{state:n}=e,r=n.facet(j$e),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=iQ(e.state,s.from,s.to);l&&e.dispatch({effects:ub.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement("span");return a.textContent=r.placeholderText,a.setAttribute("aria-label",n.phrase("folded code")),a.title=n.phrase("unfold"),a.className="cm-foldPlaceholder",a.onclick=i,a}const jL=On.replace({widget:new class extends xu{toDOM(e){return z$e(e,null)}}});class Vlt extends xu{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return z$e(t,this.value)}}const Mlt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class uX extends su{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function U0n(e={}){let t={...Mlt,...e},n=new uX(t,!0),r=new uX(t,!1),i=xi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(WO)!=o.state.facet(WO)||o.startState.field(Sf,!1)!=o.state.field(Sf,!1)||Mn(o.startState)!=Mn(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new yf;for(let l of o.viewportLineBlocks){let c=iQ(o.state,l.from,l.to)?r:rQ(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,clt({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||Qn.empty},initialSpacer(){return new uX(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=iQ(o.state,s.from,s.to);if(c)return o.dispatch({effects:ub.of(c)}),!0;let u=rQ(o.state,s.from,s.to);return u?(o.dispatch({effects:nP.of(u)}),!0):!1}}}),C$e()]}const Llt=Pt.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class rP{constructor(t,n){this.specs=t;let r;function i(s){let l=zO.newName();return(r||(r=Object.create(null)))["."+l]=s,l}const a=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof So?s=>s.prop(fO)==o.data:o?s=>s==o:void 0,this.style=S$e(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new zO(r):null,this.themeType=n.themeType}static define(t,n){return new rP(t,n||{})}}const WC=mt.define(),A$e=mt.define({combine(e){return e.length?[e[0]]:null}});function OX(e){let t=e.facet(WC);return t.length?t:e.facet(A$e)}function W0n(e,t){let n=[Blt],r;return e instanceof rP&&(e.module&&n.push(Pt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(A$e.of(e)):r?n.push(WC.computeN([Pt.darkTheme],i=>i.facet(Pt.darkTheme)==(r=="dark")?[e]:[])):n.push(WC.of(e)),n}class Flt{constructor(t){this.markCache=Object.create(null),this.tree=Mn(t.state),this.decorations=this.buildDeco(t,OX(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Mn(t.state),r=OX(t.state),i=r!=OX(t.startState),{viewport:a}=t.view,o=t.changes.mapPos(this.decoratedTo,1);n.length<a.to&&!i&&n.type==this.tree.type&&o>=a.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(n!=this.tree||t.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=a.to)}buildDeco(t,n){if(!n||!this.tree.length)return On.none;let r=new yf;for(let{from:i,to:a}of t.visibleRanges)xlt(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=On.mark({class:l})))},i,a);return r.finish()}}const Blt=FO.high(xi.fromClass(Flt,{decorations:e=>e.decorations})),N0n=rP.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),Hlt=Pt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),U$e=1e4,W$e="()[]{}",N$e=mt.define({combine(e){return ng(e,{afterCursor:!0,brackets:W$e,maxScanDistance:U$e,renderMatch:ect})}}),Klt=On.mark({class:"cm-matchingBracket"}),Jlt=On.mark({class:"cm-nonmatchingBracket"});function ect(e){let t=[],n=e.matched?Klt:Jlt;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const tct=eo.define({create(){return On.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(N$e);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=Vw(t.state,i.head,-1,r)||i.head>0&&Vw(t.state,i.head-1,1,r)||r.afterCursor&&(Vw(t.state,i.head,1,r)||i.head<t.state.doc.length&&Vw(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return On.set(n,!0)},provide:e=>Pt.decorations.from(e)}),nct=[tct,Hlt];function Y0n(e={}){return[N$e.of(e),nct]}const sW=new Vt;function NC(e,t,n){let r=e.prop(t<0?Vt.openedBy:Vt.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function YC(e){let t=e.type.prop(sW);return t?t(e.node):e}function Vw(e,t,n,r={}){let i=r.maxScanDistance||U$e,a=r.brackets||W$e,o=Mn(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=NC(l.type,n,a);if(c&&l.from<l.to){let u=YC(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return rct(e,t,n,l,u,c,a)}}return ict(e,t,n,o,s.type,i,a)}function rct(e,t,n,r,i,a,o){let s=r.parent,l={from:i.from,to:i.to},c=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(c==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let O=YC(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(NC(u.type,n,o))c++;else if(NC(u.type,-n,o)){if(c==0){let O=YC(u);return{start:l,end:O&&O.from<O.to?{from:O.from,to:O.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function ict(e,t,n,r,i,a,o){let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=o.indexOf(s);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),O=0;for(let f=0;!u.next().done&&f<=a;){let p=u.value;n<0&&(f+=p.length);let m=t+f*n;for(let g=n>0?0:p.length-1,y=n>0?p.length:-1;g!=y;g+=n){let v=o.indexOf(p[g]);if(!(v<0||r.resolveInner(m+g,1).type!=i))if(v%2==0==n>0)O++;else{if(O==1)return{start:c,end:{from:m+g,to:m+g+1},matched:v>>1==l>>1};O--}}n>0&&(f+=p.length)}return u.done?{start:c,matched:!1}:null}function CL(e,t,n,r=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let o=r;o<t;o++)e.charCodeAt(o)==9?a+=n-a%n:a++;return a}class Y$e{constructor(t,n,r,i){this.string=t,this.tabSize=n,this.indentUnit=r,this.overrideIndent=i,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let n=this.string.charAt(this.pos),r;if(typeof t=="string"?r=n==t:r=n&&(t instanceof RegExp?t.test(n):t(n)),r)return++this.pos,n}eatWhile(t){let n=this.pos;for(;this.eat(t););return this.pos>n}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let n=this.string.indexOf(t,this.pos);if(n>-1)return this.pos=n,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=CL(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:CL(this.string,null,this.tabSize)}match(t,n,r){if(typeof t=="string"){let i=o=>r?o.toLowerCase():o,a=this.string.substr(this.pos,t.length);return i(a)==i(t)?(n!==!1&&(this.pos+=t.length),!0):null}else{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&n!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function act(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||oct,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||cW,mergeTokens:e.mergeTokens!==!1}}function oct(e){if(typeof e!="object")return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}const zL=new WeakMap;class Ge extends So{constructor(t){let n=eP(t.languageData),r=act(t),i,a=new class extends Lk{createParse(o,s,l){return new lct(i,o,s,l)}};super(n,a,[],t.name),this.topNode=Oct(n,this),i=this,this.streamParser=r,this.stateAfter=new Vt({perNode:!0}),this.tokenTable=t.tokenTable?new D$e(r.tokenTable):uct}static define(t){return new Ge(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=zL.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=lW(this,t.node.tree,t.node.from,t.node.from,n??t.pos),a,o;if(i?(o=i.state,a=i.pos+1):(o=this.streamParser.startState(t.unit),a=t.node.from),t.pos-a>1e4)return null;for(;a<t.pos;){let l=t.state.doc.lineAt(a),c=Math.min(t.pos,l.to);if(l.length){let u=r?r(l.from):-1,O=new Y$e(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)I$e(this.streamParser.token,O,o)}else this.streamParser.blankLine(o,t.unit);if(c==t.pos)break;a=l.to+1}let s=t.lineAt(t.pos);return r&&n==null&&zL.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function lW(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let o=t.children.length-1;o>=0;o--){let s=t.children[o],l=n+t.positions[o],c=s instanceof pn&&l<i&&lW(e,s,l,r,i);if(c)return c}return null}function G$e(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],l;if(o<r&&s instanceof pn){if(!(l=G$e(e,s,n-o,r-o,i)))break;return i?new pn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function sct(e,t,n,r,i){for(let a of t){let o=a.from+(a.openStart?25:0),s=a.to-(a.openEnd?25:0),l=o<=n&&s>n&&lW(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=G$e(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?nQ(i):4),tree:pn.empty}}let lct=class{constructor(t,n,r,i){this.lang=t,this.input=n,this.fragments=r,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let a=xf.get(),o=i[0].from,{state:s,tree:l}=sct(t,r,o,this.to,a?.state);this.state=s,this.parsedPos=this.chunkStart=o+l.length;for(let c=0;c<l.children.length;c++)this.chunks.push(l.children[c]),this.chunkPos.push(l.positions[c]);a&&this.parsedPos<a.viewport.from-1e5&&i.some(c=>c.from<=a.viewport.from&&c.to>=a.viewport.from)&&(this.state=this.lang.streamParser.startState(nQ(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=xf.get(),n=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(n,this.chunkStart+2048);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=n?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,n),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let n=this.input.chunk(t);if(this.input.lineChunks)n==`
|
|
903
903
|
`&&(n="");else{let r=n.indexOf(`
|
|
904
|
-
`);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let a=this.ranges[i].to;if(a>=r||(n=n.slice(0,a-(r-n.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,s=this.lineAfter(o);n+=s,r=o+s.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,a=t+n;if(r>0?i>a:i>=a)break;let o=this.ranges[++this.rangeIndex].from;n+=o-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let a=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let s=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-s}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==n?this.chunk[o+2]=r:this.chunk.push(t,n,r,a),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:a}=this.lang,o=new Y$e(n,t?t.state.tabSize:4,t?nQ(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=I$e(a.token,o,this.state);if(s&&(i=this.emitToken(this.lang.tokenTable.resolve(s),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=pn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:cct,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new pn(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new pn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function I$e(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const cW=Object.create(null),Qy=[fi.none],cct=new tg(Qy),AL=[],UL=Object.create(null),Z$e=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Z$e[e]=V$e(cW,t);class D$e{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Z$e)}resolve(t){return t?this.table[t]||(this.table[t]=V$e(this.extra,t)):0}}const uct=new D$e(cW);function dX(e,t){AL.indexOf(e)>-1||(AL.push(e),console.warn(t))}function V$e(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):dX(c,`Modifier ${c} used at start of tag`):l.length?dX(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:dX(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=UL[i];if(a)return a.id;let o=UL[i]=fi.define({id:Qy.length,name:r,props:[jn({[r]:n})]});return Qy.push(o),o.id}function Oct(e,t){let n=fi.define({id:Qy.length,name:"Document",props:[fO.add(()=>e),Ar.add(()=>r=>t.getIndent(r))],top:!0});return Qy.push(n),n}xr.RTL,xr.LTR;function ze(e){return new bn(Ge.define(e))}function Nu(e){return xe(()=>Promise.resolve().then(()=>C0t),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const dct=[ye.of({name:"C",extensions:["c","h","ino"],load(){return xe(()=>Promise.resolve().then(()=>TB),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return xe(()=>Promise.resolve().then(()=>TB),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Nu("Cassandra")}}),ye.of({name:"CSS",extensions:["css"],load(){return xe(()=>Promise.resolve().then(()=>BOt),void 0,import.meta.url).then(e=>e.css())}}),ye.of({name:"Go",extensions:["go"],load(){return xe(()=>import("./index-CyPPdUQq.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(e=>e.go())}}),ye.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return xe(()=>Promise.resolve().then(()=>Ydt),void 0,import.meta.url).then(e=>e.html())}}),ye.of({name:"Java",extensions:["java"],load(){return xe(()=>Promise.resolve().then(()=>W0t),void 0,import.meta.url).then(e=>e.java())}}),ye.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return xe(()=>Promise.resolve().then(()=>Bw),void 0,import.meta.url).then(e=>e.javascript())}}),ye.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return xe(()=>Promise.resolve().then(()=>Vft),void 0,import.meta.url).then(e=>e.json())}}),ye.of({name:"JSX",extensions:["jsx"],load(){return xe(()=>Promise.resolve().then(()=>Bw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ye.of({name:"LESS",extensions:["less"],load(){return xe(()=>Promise.resolve().then(()=>lft),void 0,import.meta.url).then(e=>e.less())}}),ye.of({name:"Liquid",extensions:["liquid"],load(){return xe(()=>Promise.resolve().then(()=>Svt),void 0,import.meta.url).then(e=>e.liquid())}}),ye.of({name:"MariaDB SQL",load(){return Nu("MariaSQL")}}),ye.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return xe(()=>Promise.resolve().then(()=>Hdt),void 0,import.meta.url).then(e=>e.markdown())}}),ye.of({name:"MS SQL",load(){return Nu("MSSQL")}}),ye.of({name:"MySQL",load(){return Nu("MySQL")}}),ye.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return xe(()=>Promise.resolve().then(()=>tvt),void 0,import.meta.url).then(e=>e.php())}}),ye.of({name:"PLSQL",extensions:["pls"],load(){return Nu("PLSQL")}}),ye.of({name:"PostgreSQL",load(){return Nu("PostgreSQL")}}),ye.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return xe(()=>Promise.resolve().then(()=>Sgt),void 0,import.meta.url).then(e=>e.python())}}),ye.of({name:"Rust",extensions:["rs"],load(){return xe(()=>Promise.resolve().then(()=>a$t),void 0,import.meta.url).then(e=>e.rust())}}),ye.of({name:"Sass",extensions:["sass"],load(){return xe(()=>Promise.resolve().then(()=>ZF),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ye.of({name:"SCSS",extensions:["scss"],load(){return xe(()=>Promise.resolve().then(()=>ZF),void 0,import.meta.url).then(e=>e.sass())}}),ye.of({name:"SQL",extensions:["sql"],load(){return Nu("StandardSQL")}}),ye.of({name:"SQLite",load(){return Nu("SQLite")}}),ye.of({name:"TSX",extensions:["tsx"],load(){return xe(()=>Promise.resolve().then(()=>Bw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ye.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return xe(()=>Promise.resolve().then(()=>Bw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ye.of({name:"WebAssembly",extensions:["wat","wast"],load(){return xe(()=>Promise.resolve().then(()=>kvt),void 0,import.meta.url).then(e=>e.wast())}}),ye.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return xe(()=>Promise.resolve().then(()=>Vgt),void 0,import.meta.url).then(e=>e.xml())}}),ye.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return xe(()=>import("./index-qhYHvOTU.js"),__vite__mapDeps([7,1,2,3,4,5,6]),import.meta.url).then(e=>e.yaml())}}),ye.of({name:"APL",extensions:["dyalog","apl"],load(){return xe(()=>Promise.resolve().then(()=>n1t),void 0,import.meta.url).then(e=>ze(e.apl))}}),ye.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return xe(()=>Promise.resolve().then(()=>r1t),void 0,import.meta.url).then(e=>ze(e.asciiArmor))}}),ye.of({name:"ASN.1",extensions:["asn","asn1"],load(){return xe(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>ze(e.asn1({})))}}),ye.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return xe(()=>Promise.resolve().then(()=>l1t),void 0,import.meta.url).then(e=>ze(e.asterisk))}}),ye.of({name:"Brainfuck",extensions:["b","bf"],load(){return xe(()=>Promise.resolve().then(()=>u1t),void 0,import.meta.url).then(e=>ze(e.brainfuck))}}),ye.of({name:"Cobol",extensions:["cob","cpy"],load(){return xe(()=>Promise.resolve().then(()=>U1t),void 0,import.meta.url).then(e=>ze(e.cobol))}}),ye.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.csharp))}}),ye.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"ClojureScript",extensions:["cljs"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return xe(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>ze(e.gss))}}),ye.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return xe(()=>Promise.resolve().then(()=>T1t),void 0,import.meta.url).then(e=>ze(e.cmake))}}),ye.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return xe(()=>Promise.resolve().then(()=>H1t),void 0,import.meta.url).then(e=>ze(e.coffeeScript))}}),ye.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return xe(()=>Promise.resolve().then(()=>rxt),void 0,import.meta.url).then(e=>ze(e.commonLisp))}}),ye.of({name:"Cypher",extensions:["cyp","cypher"],load(){return xe(()=>Promise.resolve().then(()=>bxt),void 0,import.meta.url).then(e=>ze(e.cypher))}}),ye.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return xe(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>ze(e.cython))}}),ye.of({name:"Crystal",extensions:["cr"],load(){return xe(()=>Promise.resolve().then(()=>pxt),void 0,import.meta.url).then(e=>ze(e.crystal))}}),ye.of({name:"D",extensions:["d"],load(){return xe(()=>Promise.resolve().then(()=>Pxt),void 0,import.meta.url).then(e=>ze(e.d))}}),ye.of({name:"Dart",extensions:["dart"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.dart))}}),ye.of({name:"diff",extensions:["diff","patch"],load(){return xe(()=>Promise.resolve().then(()=>Txt),void 0,import.meta.url).then(e=>ze(e.diff))}}),ye.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return xe(()=>Promise.resolve().then(()=>Gxt),void 0,import.meta.url).then(e=>ze(e.dockerFile))}}),ye.of({name:"DTD",extensions:["dtd"],load(){return xe(()=>Promise.resolve().then(()=>Dxt),void 0,import.meta.url).then(e=>ze(e.dtd))}}),ye.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return xe(()=>Promise.resolve().then(()=>Bxt),void 0,import.meta.url).then(e=>ze(e.dylan))}}),ye.of({name:"EBNF",load(){return xe(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>ze(e.ebnf))}}),ye.of({name:"ECL",extensions:["ecl"],load(){return xe(()=>Promise.resolve().then(()=>aSt),void 0,import.meta.url).then(e=>ze(e.ecl))}}),ye.of({name:"edn",extensions:["edn"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"Eiffel",extensions:["e"],load(){return xe(()=>Promise.resolve().then(()=>OSt),void 0,import.meta.url).then(e=>ze(e.eiffel))}}),ye.of({name:"Elm",extensions:["elm"],load(){return xe(()=>Promise.resolve().then(()=>wSt),void 0,import.meta.url).then(e=>ze(e.elm))}}),ye.of({name:"Erlang",extensions:["erl"],load(){return xe(()=>Promise.resolve().then(()=>VSt),void 0,import.meta.url).then(e=>ze(e.erlang))}}),ye.of({name:"Esper",load(){return xe(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>ze(e.esper))}}),ye.of({name:"Factor",extensions:["factor"],load(){return xe(()=>Promise.resolve().then(()=>MSt),void 0,import.meta.url).then(e=>ze(e.factor))}}),ye.of({name:"FCL",load(){return xe(()=>Promise.resolve().then(()=>KSt),void 0,import.meta.url).then(e=>ze(e.fcl))}}),ye.of({name:"Forth",extensions:["forth","fth","4th"],load(){return xe(()=>Promise.resolve().then(()=>tQt),void 0,import.meta.url).then(e=>ze(e.forth))}}),ye.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return xe(()=>Promise.resolve().then(()=>lQt),void 0,import.meta.url).then(e=>ze(e.fortran))}}),ye.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.fSharp))}}),ye.of({name:"Gas",extensions:["s"],load(){return xe(()=>Promise.resolve().then(()=>uQt),void 0,import.meta.url).then(e=>ze(e.gas))}}),ye.of({name:"Gherkin",extensions:["feature"],load(){return xe(()=>Promise.resolve().then(()=>OQt),void 0,import.meta.url).then(e=>ze(e.gherkin))}}),ye.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return xe(()=>Promise.resolve().then(()=>wQt),void 0,import.meta.url).then(e=>ze(e.groovy))}}),ye.of({name:"Haskell",extensions:["hs"],load(){return xe(()=>Promise.resolve().then(()=>TQt),void 0,import.meta.url).then(e=>ze(e.haskell))}}),ye.of({name:"Haxe",extensions:["hx"],load(){return xe(()=>Promise.resolve().then(()=>KH),void 0,import.meta.url).then(e=>ze(e.haxe))}}),ye.of({name:"HXML",extensions:["hxml"],load(){return xe(()=>Promise.resolve().then(()=>KH),void 0,import.meta.url).then(e=>ze(e.hxml))}}),ye.of({name:"HTTP",load(){return xe(()=>Promise.resolve().then(()=>KQt),void 0,import.meta.url).then(e=>ze(e.http))}}),ye.of({name:"IDL",extensions:["pro"],load(){return xe(()=>Promise.resolve().then(()=>a_t),void 0,import.meta.url).then(e=>ze(e.idl))}}),ye.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return xe(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>ze(e.jsonld))}}),ye.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return xe(()=>Promise.resolve().then(()=>c_t),void 0,import.meta.url).then(e=>ze(e.jinja2))}}),ye.of({name:"Julia",extensions:["jl"],load(){return xe(()=>Promise.resolve().then(()=>j_t),void 0,import.meta.url).then(e=>ze(e.julia))}}),ye.of({name:"Kotlin",extensions:["kt","kts"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.kotlin))}}),ye.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return xe(()=>Promise.resolve().then(()=>U_t),void 0,import.meta.url).then(e=>ze(e.liveScript))}}),ye.of({name:"Lua",extensions:["lua"],load(){return xe(()=>Promise.resolve().then(()=>V_t),void 0,import.meta.url).then(e=>ze(e.lua))}}),ye.of({name:"mIRC",extensions:["mrc"],load(){return xe(()=>Promise.resolve().then(()=>pkt),void 0,import.meta.url).then(e=>ze(e.mirc))}}),ye.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return xe(()=>Promise.resolve().then(()=>ekt),void 0,import.meta.url).then(e=>ze(e.mathematica))}}),ye.of({name:"Modelica",extensions:["mo"],load(){return xe(()=>Promise.resolve().then(()=>Qkt),void 0,import.meta.url).then(e=>ze(e.modelica))}}),ye.of({name:"MUMPS",extensions:["mps"],load(){return xe(()=>Promise.resolve().then(()=>Ykt),void 0,import.meta.url).then(e=>ze(e.mumps))}}),ye.of({name:"Mbox",extensions:["mbox"],load(){return xe(()=>Promise.resolve().then(()=>dkt),void 0,import.meta.url).then(e=>ze(e.mbox))}}),ye.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return xe(()=>Promise.resolve().then(()=>Vkt),void 0,import.meta.url).then(e=>ze(e.nginx))}}),ye.of({name:"NSIS",extensions:["nsh","nsi"],load(){return xe(()=>Promise.resolve().then(()=>Mkt),void 0,import.meta.url).then(e=>ze(e.nsis))}}),ye.of({name:"NTriples",extensions:["nt","nq"],load(){return xe(()=>Promise.resolve().then(()=>Lkt),void 0,import.meta.url).then(e=>ze(e.ntriples))}}),ye.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.objectiveC))}}),ye.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.objectiveCpp))}}),ye.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.oCaml))}}),ye.of({name:"Octave",extensions:["m"],load(){return xe(()=>Promise.resolve().then(()=>aPt),void 0,import.meta.url).then(e=>ze(e.octave))}}),ye.of({name:"Oz",extensions:["oz"],load(){return xe(()=>Promise.resolve().then(()=>gPt),void 0,import.meta.url).then(e=>ze(e.oz))}}),ye.of({name:"Pascal",extensions:["p","pas"],load(){return xe(()=>Promise.resolve().then(()=>xPt),void 0,import.meta.url).then(e=>ze(e.pascal))}}),ye.of({name:"Perl",extensions:["pl","pm"],load(){return xe(()=>Promise.resolve().then(()=>SPt),void 0,import.meta.url).then(e=>ze(e.perl))}}),ye.of({name:"Pig",extensions:["pig"],load(){return xe(()=>Promise.resolve().then(()=>kPt),void 0,import.meta.url).then(e=>ze(e.pig))}}),ye.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return xe(()=>Promise.resolve().then(()=>IPt),void 0,import.meta.url).then(e=>ze(e.powerShell))}}),ye.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return xe(()=>Promise.resolve().then(()=>ZPt),void 0,import.meta.url).then(e=>ze(e.properties))}}),ye.of({name:"ProtoBuf",extensions:["proto"],load(){return xe(()=>Promise.resolve().then(()=>FPt),void 0,import.meta.url).then(e=>ze(e.protobuf))}}),ye.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return xe(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([8,9]),import.meta.url).then(e=>ze(e.pug))}}),ye.of({name:"Puppet",extensions:["pp"],load(){return xe(()=>Promise.resolve().then(()=>KPt),void 0,import.meta.url).then(e=>ze(e.puppet))}}),ye.of({name:"Q",extensions:["q"],load(){return xe(()=>Promise.resolve().then(()=>o5t),void 0,import.meta.url).then(e=>ze(e.q))}}),ye.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return xe(()=>Promise.resolve().then(()=>f5t),void 0,import.meta.url).then(e=>ze(e.r))}}),ye.of({name:"RPM Changes",load(){return xe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ze(e.rpmChanges))}}),ye.of({name:"RPM Spec",extensions:["spec"],load(){return xe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ze(e.rpmSpec))}}),ye.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return xe(()=>Promise.resolve().then(()=>w5t),void 0,import.meta.url).then(e=>ze(e.ruby))}}),ye.of({name:"SAS",extensions:["sas"],load(){return xe(()=>Promise.resolve().then(()=>_5t),void 0,import.meta.url).then(e=>ze(e.sas))}}),ye.of({name:"Scala",extensions:["scala"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.scala))}}),ye.of({name:"Scheme",extensions:["scm","ss"],load(){return xe(()=>Promise.resolve().then(()=>W5t),void 0,import.meta.url).then(e=>ze(e.scheme))}}),ye.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return xe(()=>Promise.resolve().then(()=>I5t),void 0,import.meta.url).then(e=>ze(e.shell))}}),ye.of({name:"Sieve",extensions:["siv","sieve"],load(){return xe(()=>Promise.resolve().then(()=>L5t),void 0,import.meta.url).then(e=>ze(e.sieve))}}),ye.of({name:"Smalltalk",extensions:["st"],load(){return xe(()=>Promise.resolve().then(()=>H5t),void 0,import.meta.url).then(e=>ze(e.smalltalk))}}),ye.of({name:"Solr",load(){return xe(()=>Promise.resolve().then(()=>i2t),void 0,import.meta.url).then(e=>ze(e.solr))}}),ye.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.sml))}}),ye.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return xe(()=>Promise.resolve().then(()=>O2t),void 0,import.meta.url).then(e=>ze(e.sparql))}}),ye.of({name:"Spreadsheet",alias:["excel","formula"],load(){return xe(()=>Promise.resolve().then(()=>d2t),void 0,import.meta.url).then(e=>ze(e.spreadsheet))}}),ye.of({name:"Squirrel",extensions:["nut"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.squirrel))}}),ye.of({name:"Stylus",extensions:["styl"],load(){return xe(()=>Promise.resolve().then(()=>j2t),void 0,import.meta.url).then(e=>ze(e.stylus))}}),ye.of({name:"Swift",extensions:["swift"],load(){return xe(()=>Promise.resolve().then(()=>eTt),void 0,import.meta.url).then(e=>ze(e.swift))}}),ye.of({name:"sTeX",load(){return xe(()=>Promise.resolve().then(()=>IK),void 0,import.meta.url).then(e=>ze(e.stex))}}),ye.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return xe(()=>Promise.resolve().then(()=>IK),void 0,import.meta.url).then(e=>ze(e.stex))}}),ye.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return xe(()=>Promise.resolve().then(()=>cJ),void 0,import.meta.url).then(e=>ze(e.verilog))}}),ye.of({name:"Tcl",extensions:["tcl"],load(){return xe(()=>Promise.resolve().then(()=>iTt),void 0,import.meta.url).then(e=>ze(e.tcl))}}),ye.of({name:"Textile",extensions:["textile"],load(){return xe(()=>Promise.resolve().then(()=>lTt),void 0,import.meta.url).then(e=>ze(e.textile))}}),ye.of({name:"TiddlyWiki",load(){return xe(()=>Promise.resolve().then(()=>TTt),void 0,import.meta.url).then(e=>ze(e.tiddlyWiki))}}),ye.of({name:"Tiki wiki",load(){return xe(()=>Promise.resolve().then(()=>zTt),void 0,import.meta.url).then(e=>ze(e.tiki))}}),ye.of({name:"TOML",extensions:["toml"],load(){return xe(()=>Promise.resolve().then(()=>ATt),void 0,import.meta.url).then(e=>ze(e.toml))}}),ye.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return xe(()=>Promise.resolve().then(()=>NTt),void 0,import.meta.url).then(e=>ze(e.troff))}}),ye.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return xe(()=>Promise.resolve().then(()=>iXt),void 0,import.meta.url).then(e=>ze(e.ttcn))}}),ye.of({name:"TTCN_CFG",extensions:["cfg"],load(){return xe(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>ze(e.ttcnCfg))}}),ye.of({name:"Turtle",extensions:["ttl"],load(){return xe(()=>Promise.resolve().then(()=>sXt),void 0,import.meta.url).then(e=>ze(e.turtle))}}),ye.of({name:"Web IDL",extensions:["webidl"],load(){return xe(()=>Promise.resolve().then(()=>eRt),void 0,import.meta.url).then(e=>ze(e.webIDL))}}),ye.of({name:"VB.NET",extensions:["vb"],load(){return xe(()=>Promise.resolve().then(()=>wXt),void 0,import.meta.url).then(e=>ze(e.vb))}}),ye.of({name:"VBScript",extensions:["vbs"],load(){return xe(()=>Promise.resolve().then(()=>SXt),void 0,import.meta.url).then(e=>ze(e.vbScript))}}),ye.of({name:"Velocity",extensions:["vtl"],load(){return xe(()=>Promise.resolve().then(()=>kXt),void 0,import.meta.url).then(e=>ze(e.velocity))}}),ye.of({name:"Verilog",extensions:["v"],load(){return xe(()=>Promise.resolve().then(()=>cJ),void 0,import.meta.url).then(e=>ze(e.verilog))}}),ye.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return xe(()=>Promise.resolve().then(()=>zXt),void 0,import.meta.url).then(e=>ze(e.vhdl))}}),ye.of({name:"XQuery",extensions:["xy","xquery"],load(){return xe(()=>Promise.resolve().then(()=>uRt),void 0,import.meta.url).then(e=>ze(e.xQuery))}}),ye.of({name:"Yacas",extensions:["ys"],load(){return xe(()=>Promise.resolve().then(()=>vRt),void 0,import.meta.url).then(e=>ze(e.yacas))}}),ye.of({name:"Z80",extensions:["z80"],load(){return xe(()=>Promise.resolve().then(()=>QRt),void 0,import.meta.url).then(e=>ze(e.z80))}}),ye.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return xe(()=>Promise.resolve().then(()=>$R),void 0,import.meta.url).then(e=>ze(e.mscgen))}}),ye.of({name:"Xù",extensions:["xu"],load(){return xe(()=>Promise.resolve().then(()=>$R),void 0,import.meta.url).then(e=>ze(e.xu))}}),ye.of({name:"MsGenny",extensions:["msgenny"],load(){return xe(()=>Promise.resolve().then(()=>$R),void 0,import.meta.url).then(e=>ze(e.msgenny))}}),ye.of({name:"Vue",extensions:["vue"],load(){return xe(()=>Promise.resolve().then(()=>Cvt),void 0,import.meta.url).then(e=>e.vue())}}),ye.of({name:"Angular Template",load(){return xe(()=>Promise.resolve().then(()=>ebt),void 0,import.meta.url).then(e=>e.angular())}})];class uW{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=Mn(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),a=i.search(M$e(t,!1));return a<0?null:{from:r+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function WL(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function fct(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let a=1;a<i.length;a++)n[i[a]]=!0}let r=WL(t)+WL(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Ob(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:fct(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function iP(e,t){return n=>{for(let r=Mn(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class NL{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function nf(e){return e.selection.main.from}function M$e(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",a=r[r.length-1]!="$";return!i&&!a?e:new RegExp(`${i?"^":""}(?:${r})${a?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const OW=Zf.define();function hct(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Le.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const YL=new WeakMap;function pct(e){if(!Array.isArray(e))return e;let t=YL.get(e);return t||YL.set(e,t=Ob(e)),t}const aQ=_n.define(),_y=_n.define();class mct{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=yo(t,n),i=Rc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(yo(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let b=yo(t,0),x=Rc(b),Q=x==t.length?0:-100;if(b!=n[0])if(b==r[0])Q+=-200;else return null;return this.ret(Q,[0,x])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let b=0,x=Math.min(t.length,200);b<x&&c<l;){let Q=yo(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=Rc(Q)}if(c<l)return null}let u=0,O=0,f=!1,p=0,m=-1,g=-1,y=/[a-z]/.test(t),v=!0;for(let b=0,x=Math.min(t.length,200),Q=0;b<x&&O<l;){let w=yo(t,b);s<0&&(u<l&&w==n[u]&&(a[u++]=b),p<l&&(w==n[p]||w==r[p]?(p==0&&(m=b),g=b+1,p++):p=0));let S,_=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=i0e(w))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||_==1&&y||Q==0&&_!=0)&&(n[O]==w||r[O]==w&&(f=!0)?o[O++]=b:o.length&&(v=!1)),Q=_,b+=Rc(w)}return O==l&&o[0]==0&&v?this.result(-100+(f?-200:0),o,t):p==l&&m==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):p==l?this.ret(-900-t.length,[m,g]):O==l?this.result(-100+(f?-200:0)+-700+(v?0:-1100),o,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],a=0;for(let o of n){let s=o+(this.astral?Rc(yo(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class gct{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const Ci=mt.define({combine(e){return ng(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:$ct,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>GL(t(r),n(r)),optionClass:(t,n)=>r=>GL(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function GL(e,t){return e?t?e+" "+t:e:t}function $ct(e,t,n,r,i,a){let o=e.textDirection==xr.RTL,s=o,l=!1,c="top",u,O,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,g=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,O=Math.min(400,s?f:p);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let b=i.bottom-t.bottom;b>=g||b>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let y=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${O/v}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function yct(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,a){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&o.appendChild(document.createTextNode(s.slice(l,u)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(s.slice(u,O))),f.className="cm-completionMatchedText",l=O}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function fX(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class vct{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:a,selected:o}=i.open,s=t.state.facet(Ci);this.optionContent=yct(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=fX(a.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,O;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(O=/-(\d+)$/.exec(u.id))&&+O[1]<c.length){this.applyCompletion(t,c[+O[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Ci).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:_y.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:a,selected:o,disabled:s}=r.open;(!i.open||i.open.options!=a)&&(this.range=fX(a.length,o,t.state.facet(Ci).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),s!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=fX(n.options.length,n.selected,this.view.state.facet(Ci).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let a=typeof i=="string"?document.createTextNode(i):i(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Va(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&wct(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.space;if(!a){let o=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(a.bottom,n.bottom)-10||i.bottom<Math.max(a.top,n.top)+10?null:this.view.state.facet(Ci).positionInfo(this.view,n,i,r,a,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let a=null;for(let o=r.from;o<r.to;o++){let{completion:s,match:l}=t[o],{section:c}=s;if(c){let f=typeof c=="string"?c:c.name;if(f!=a&&(o>r.from||r.from==0))if(a=f,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let p=i.appendChild(document.createElement("completion-section"));p.textContent=f}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let O=this.optionClass(s);O&&(u.className=O);for(let f of this.optionContent){let p=f(s,this.view.state,this.view,l);p&&u.appendChild(p)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function bct(e,t){return n=>new vct(n,e,t)}function wct(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function IL(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function xct(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let O=typeof u=="string"?u:u.name;r.some(f=>f.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Ci);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let O of c.result.options)i(new NL(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),f,p=a.filterStrict?new gct(O):new mct(O);for(let m of c.result.options)if(f=p.match(m.label)){let g=m.displayLabel?u?u(m,f.matched):[]:f.matched;i(new NL(m,c.source,g,f.score+(m.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(f,p)=>{var m,g;return((m=f.rank)!==null&&m!==void 0?m:1e9)-((g=p.rank)!==null&&g!==void 0?g:1e9)||(f.name<p.name?-1:1)};for(let f of r.sort(O))u-=1e5,c[f.name]=u;for(let f of n){let{section:p}=f.completion;p&&(f.score+=c[typeof p=="string"?p:p.name])}}let o=[],s=null,l=a.compareCompletions;for(let c of n.sort((u,O)=>O.score-u.score||l(u.completion,O.completion))){let u=c.completion;!s||s.label!=u.label||s.detail!=u.detail||s.type!=null&&u.type!=null&&s.type!=u.type||s.apply!=u.apply||s.boost!=u.boost?o.push(c):IL(c.completion)>IL(s)&&(o[o.length-1]=c),s=c.completion}return o}class up{constructor(t,n,r,i,a,o){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=o}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new up(this.options,ZL(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(c=>c.isPending))return i.setDisabled();let s=xct(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ci).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<s.length;u++)if(s[u].completion==c){l=u;break}}return new up(s,ZL(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Tct,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new up(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new up(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class oQ{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new oQ(kct,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ci),a=(r.override||n.languageDataAt("autocomplete",nf(n)).map(pct)).map(l=>(this.active.find(u=>u.source==l)||new ts(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(dW));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Sct(a,this.active)||s?o=up.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new ts(l.source,0):l));for(let l of t.effects)l.is(F$e)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new oQ(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Qct:_ct}}function Sct(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}const Qct={"aria-autocomplete":"list"},_ct={};function ZL(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const kct=[];function L$e(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(OW);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class ts{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=L$e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ts(i.source,0)),r&4&&i.state==0&&(i=new ts(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(aQ))i=new ts(i.source,1,a.value);else if(a.is(_y))i=new ts(i.source,0);else if(a.is(dW))for(let o of a.value)o.source==i.source&&(i=o);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(nf(t.state))}}class _p extends ts{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=nf(t.state);if(s>o||!i||n&2&&(nf(t.startState)==this.from||s<this.limit))return new ts(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Pct(i.validFor,t.state,a,o)?new _p(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new uW(t.state,s,!1)))?new _p(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:nf(t.state)):new ts(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new _p(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ts(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Pct(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):M$e(e,!0).test(i)}const dW=_n.define({map(e,t){return e.map(n=>n.map(t))}}),F$e=_n.define(),Ia=eo.define({create(){return oQ.start()},update(e,t){return e.update(t)},provide:e=>[rW.from(e,t=>t.tooltip),Pt.contentAttributes.from(e,t=>t.attrs)]});function fW(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ia).active.find(i=>i.source==t.source);return r instanceof _p?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},hct(e.state,n,r.from,r.to)),{annotations:OW.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Tct=bct(Ia,fW);function Mw(e,t="option"){return n=>{let r=n.state.field(Ia,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ci).interactionDelay)return!1;let i=1,a;t=="page"&&(a=y$e(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t=="page"?0:o-1:s>=o&&(s=t=="page"?o-1:0),n.dispatch({effects:F$e.of(s)}),!0}}const Xct=e=>{let t=e.state.field(Ia,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ci).interactionDelay?!1:fW(e,t.open.options[t.open.selected])},DL=e=>e.state.field(Ia,!1)?(e.dispatch({effects:aQ.of(!0)}),!0):!1,Rct=e=>{let t=e.state.field(Ia,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:_y.of(null)}),!0)};class Ect{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const qct=50,jct=1e3,Cct=xi.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Ia).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ia),n=e.state.facet(Ci);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ia)==t)return;let r=e.transactions.some(a=>{let o=L$e(a,n);return o&8||(a.selection||a.docChanged)&&!(o&3)});for(let a=0;a<this.running.length;a++){let o=this.running[a];if(r||o.context.abortOnDocChange&&e.docChanged||o.updates.length+e.transactions.length>qct&&Date.now()-o.time>jct){for(let s of o.context.abortListeners)try{s()}catch(l){Va(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(aQ)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(o=>o.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of e.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Ia);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ci).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=nf(t),r=new uW(t,n,e.explicit,this.view),i=new Ect(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:_y.of(null)}),Va(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ci).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ci),r=this.view.state.field(Ia);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=nf(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new _p(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new ts(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:dW.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ia,!1);if(t&&t.tooltip&&this.view.state.facet(Ci).closeOnBlur){let n=t.open&&y$e(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:_y.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:aQ.of(!1)}),20),this.composing=0}}}),zct=typeof navigator=="object"&&/Win/.test(navigator.platform),Act=FO.highest(Pt.domEventHandlers({keydown(e,t){let n=t.state.field(Ia,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(zct&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&fW(t,r),!1}})),B$e=Pt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Uct{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class hW{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Mi.TrackDel),r=t.mapPos(this.to,1,Mi.TrackDel);return n==null||r==null?null:new hW(this.field,n,r)}}class pW{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),o=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(tP);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let s=this.fieldPositions.map(l=>new hW(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:s}}static parse(t){let n=[],r=[],i=[],a;for(let o of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let s=a[1]?+a[1]:null,l=a[2]||a[3]||"",c=-1,u=l.replace(/\\[{}]/g,O=>O[1]);for(let O=0;O<n.length;O++)(s!=null?n[O].seq==s:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(s==null||n[O].seq!=null&&n[O].seq<s);)O++;n.splice(O,0,{seq:s,name:u}),c=O;for(let f of i)f.field>=c&&f.field++}i.push(new Uct(c,r.length,a.index,a.index+u.length)),o=o.slice(0,a.index)+l+o.slice(a.index+a[0].length)}o=o.replace(/\\([{}])/g,(s,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(o)}return new pW(r,i)}}let Wct=On.widget({widget:new class extends xu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Nct=On.mark({class:"cm-snippetField"});class rg{constructor(t,n){this.ranges=t,this.active=n,this.deco=On.set(t.map(r=>(r.from==r.to?Wct:Nct).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new rg(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const db=_n.define({map(e,t){return e&&e.map(t)}}),Yct=_n.define(),ky=eo.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(db))return n.value;if(n.is(Yct)&&e)return new rg(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Pt.decorations.from(e,t=>t?t.deco:On.none)});function mW(e,t){return Le.create(e.filter(n=>n.field==t).map(n=>Le.range(n.from,n.to)))}function Gct(e){let t=pW.parse(e);return(n,r,i,a)=>{let{text:o,ranges:s}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:Vn.of(o)},scrollIntoView:!0,annotations:r?[OW.of(r),Li.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=mW(s,0)),s.some(u=>u.field>0)){let u=new rg(s,0),O=c.effects=[db.of(u)];n.state.field(ky,!1)===void 0&&O.push(_n.appendConfig.of([ky,Mct,Lct,B$e]))}n.dispatch(n.state.update(c))}}function H$e(e){return({state:t,dispatch:n})=>{let r=t.field(ky,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(o=>o.field==i+e);return n(t.update({selection:mW(r.ranges,i),effects:db.of(a?null:new rg(r.ranges,i)),scrollIntoView:!0})),!0}}const Ict=({state:e,dispatch:t})=>e.field(ky,!1)?(t(e.update({effects:db.of(null)})),!0):!1,Zct=H$e(1),Dct=H$e(-1),Vct=[{key:"Tab",run:Zct,shift:Dct},{key:"Escape",run:Ict}],VL=mt.define({combine(e){return e.length?e[0]:Vct}}),Mct=FO.highest(Kk.compute([VL],e=>e.facet(VL)));function gr(e,t){return Object.assign(Object.assign({},t),{apply:Gct(e)})}const Lct=Pt.domEventHandlers({mousedown(e,t){let n=t.state.field(ky,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(a=>a.from<=r&&a.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:mW(n.ranges,i.field),effects:db.of(n.ranges.some(a=>a.field>i.field)?new rg(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Py={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Gd=_n.define({map(e,t){let n=t.mapPos(e,-1,Mi.TrackAfter);return n??void 0}}),gW=new class extends $f{};gW.startSide=1;gW.endSide=-1;const K$e=eo.define({create(){return Qn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(Gd)&&(e=e.update({add:[gW.range(n.value,n.value+1)]}));return e}});function I0n(){return[Bct,K$e]}const hX="()[]{}<>«»»«[]{}";function J$e(e){for(let t=0;t<hX.length;t+=2)if(hX.charCodeAt(t)==e)return hX.charAt(t+1);return i0e(e<128?e:e+1)}function eye(e,t){return e.languageDataAt("closeBrackets",t)[0]||Py}const Fct=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Bct=Pt.inputHandler.of((e,t,n,r)=>{if((Fct?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Rc(yo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Kct(e.state,r);return a?(e.dispatch(a),!0):!1}),Hct=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=eye(e,e.selection.main.head).brackets||Py.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=Jct(e.doc,o.head);for(let l of r)if(l==s&&aP(e.doc,o.head)==J$e(yo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Le.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Z0n=[{key:"Backspace",run:Hct}];function Kct(e,t){let n=eye(e,e.selection.main.head),r=n.brackets||Py.brackets;for(let i of r){let a=J$e(yo(i,0));if(t==i)return a==i?nut(e,i,r.indexOf(i+i+i)>-1,n):eut(e,i,a,n.before||Py.before);if(t==a&&tye(e,e.selection.main.from))return tut(e,i,a)}return null}function tye(e,t){let n=!1;return e.field(K$e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function aP(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Rc(yo(n,0)))}function Jct(e,t){let n=e.sliceString(t-2,t);return Rc(yo(n,0))==n.length?n:n.slice(1)}function eut(e,t,n,r){let i=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:Gd.of(o.to+t.length),range:Le.range(o.anchor+t.length,o.head+t.length)};let s=aP(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Gd.of(o.head+t.length),range:Le.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function tut(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&aP(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Le.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function nut(e,t,n,r){let i=r.stringPrefixes||Py.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Gd.of(s.to+t.length),range:Le.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=aP(e.doc,l),u;if(c==t){if(ML(e,l))return{changes:{insert:t+t,from:l},effects:Gd.of(l+t.length),range:Le.cursor(l+t.length)};if(tye(e,l)){let f=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+f.length,insert:f},range:Le.cursor(l+f.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=LL(e,l-2*t.length,i))>-1&&ML(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Gd.of(l+t.length),range:Le.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=es.Word&&LL(e,l,i)>-1&&!rut(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Gd.of(l+t.length),range:Le.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ML(e,t){let n=Mn(e).resolveInner(t+1);return n.parent&&n.from==t}function rut(e,t,n,r){let i=Mn(e).resolveInner(t,-1),a=r.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function LL(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=es.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=es.Word)return a}return-1}function D0n(e={}){return[Act,Ia,Ci.of(e),Cct,aut,B$e]}const iut=[{key:"Ctrl-Space",run:DL},{mac:"Alt-`",run:DL},{key:"Escape",run:Rct},{key:"ArrowDown",run:Mw(!0)},{key:"ArrowUp",run:Mw(!1)},{key:"PageDown",run:Mw(!0,"page")},{key:"PageUp",run:Mw(!1,"page")},{key:"Enter",run:Xct}],aut=FO.highest(Kk.computeN([Ci],e=>e.facet(Ci).defaultKeymap?[iut]:[]));class sQ{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new sQ(t,n,r,o,a,[],[])}constructor(t,n,r,i,a,o,s){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=o,this.positions=s,this.hashProp=[[Vt.contextHash,i]]}addChild(t,n){t.prop(Vt.contextHash)!=this.hash&&(t=new pn(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new pn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new pn(fi.none,i,a,o,this.hashProp)})}}var Fe;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(Fe||(Fe={}));class out{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let sut=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return S$(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}};function FL(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==Fe.OrderedList?vW:yW)(n,t,!1);return r>0&&(e.type!=Fe.BulletList||$W(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const nye={[Fe.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(yn(Fe.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(ms(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Fe.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Fe.OrderedList]:FL,[Fe.BulletList]:FL,[Fe.Document](){return!0}};function ms(e){return e==32||e==9||e==10||e==13}function S$(e,t=0){for(;t<e.length&&ms(e.charCodeAt(t));)t++;return t}function BL(e,t,n){for(;t>n&&ms(e.charCodeAt(t-1));)t--;return t}function rye(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function iye(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function $W(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!ms(a))return-1}return n&&e.next==45&&sye(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Oye.SetextHeading)>-1||r<3?-1:1}function aye(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function yW(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||ms(e.text.charCodeAt(e.pos+1)))&&(!n||aye(t,Fe.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function vW(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!ms(e.text.charCodeAt(r+1))||n&&!aye(t,Fe.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function oye(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function sye(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&ms(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const GC=/^[ \t]*$/,lye=/-->/,cye=/\?>/,IC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,lye],[/^\s*<\?/,cye],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,GC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,GC]];function uye(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=IC.length-(n?1:0);i<a;i++)if(IC[i][0].test(r))return i;return-1}function HL(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function $d(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Fe.CodeText?e[r].to=n:e.push(yn(Fe.CodeText,t,n))}const Lw={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for($d(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){$d(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==Fe.CodeText?$d(o,c.from,c.to):o.push(c);s=[]}$d(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&$d(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Fe.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Fe.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=rye(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=BL(t.text,t.text.length,o),l=[yn(Fe.CodeMark,r,r+a)];o<s&&l.push(yn(Fe.CodeInfo,e.lineStart+o,e.lineStart+s));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=a&&t.skipSpace(u)==t.text.length){for(let O of t.markers)l.push(O);l.push(yn(Fe.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||$d(l,e.lineStart-1,e.lineStart);for(let p of t.markers)l.push(p);let O=e.lineStart+t.basePos,f=e.lineStart+t.text.length;O<f&&$d(l,O,f)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Fe.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=iye(t);return n<0?!1:(e.startContext(Fe.Blockquote,t.pos),e.addNode(Fe.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if($W(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Fe.HorizontalRule,n),!0},BulletList(e,t){let n=yW(t,e,!1);if(n<0)return!1;e.block.type!=Fe.BulletList&&e.startContext(Fe.BulletList,t.basePos,t.next);let r=HL(t,t.pos+1);return e.startContext(Fe.ListItem,t.basePos,r-t.baseIndent),e.addNode(Fe.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=vW(t,e,!1);if(n<0)return!1;e.block.type!=Fe.OrderedList&&e.startContext(Fe.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=HL(t,t.pos+n);return e.startContext(Fe.ListItem,t.basePos,r-t.baseIndent),e.addNode(Fe.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=oye(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=BL(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!ms(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Fe.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Fe.HeaderMark,o-r,a-r);let l=s.finish(Fe.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=uye(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=IC[n][1],a=[],o=i!=GC;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let c of t.markers)a.push(c)}o&&e.nextLine();let s=i==lye?Fe.CommentBlock:i==cye?Fe.ProcessingInstructionBlock:Fe.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class lut{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
|
|
904
|
+
`);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let a=this.ranges[i].to;if(a>=r||(n=n.slice(0,a-(r-n.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,s=this.lineAfter(o);n+=s,r=o+s.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,a=t+n;if(r>0?i>a:i>=a)break;let o=this.ranges[++this.rangeIndex].from;n+=o-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let a=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let s=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-s}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==n?this.chunk[o+2]=r:this.chunk.push(t,n,r,a),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:a}=this.lang,o=new Y$e(n,t?t.state.tabSize:4,t?nQ(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=I$e(a.token,o,this.state);if(s&&(i=this.emitToken(this.lang.tokenTable.resolve(s),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=pn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:cct,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new pn(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new pn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function I$e(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const cW=Object.create(null),Qy=[fi.none],cct=new tg(Qy),AL=[],UL=Object.create(null),Z$e=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Z$e[e]=V$e(cW,t);class D$e{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Z$e)}resolve(t){return t?this.table[t]||(this.table[t]=V$e(this.extra,t)):0}}const uct=new D$e(cW);function dX(e,t){AL.indexOf(e)>-1||(AL.push(e),console.warn(t))}function V$e(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):dX(c,`Modifier ${c} used at start of tag`):l.length?dX(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:dX(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=UL[i];if(a)return a.id;let o=UL[i]=fi.define({id:Qy.length,name:r,props:[jn({[r]:n})]});return Qy.push(o),o.id}function Oct(e,t){let n=fi.define({id:Qy.length,name:"Document",props:[fO.add(()=>e),Ar.add(()=>r=>t.getIndent(r))],top:!0});return Qy.push(n),n}xr.RTL,xr.LTR;function ze(e){return new bn(Ge.define(e))}function Nu(e){return xe(()=>Promise.resolve().then(()=>C0t),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const dct=[ye.of({name:"C",extensions:["c","h","ino"],load(){return xe(()=>Promise.resolve().then(()=>TB),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return xe(()=>Promise.resolve().then(()=>TB),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Nu("Cassandra")}}),ye.of({name:"CSS",extensions:["css"],load(){return xe(()=>Promise.resolve().then(()=>BOt),void 0,import.meta.url).then(e=>e.css())}}),ye.of({name:"Go",extensions:["go"],load(){return xe(()=>import("./index-CJ8BPUHQ.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(e=>e.go())}}),ye.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return xe(()=>Promise.resolve().then(()=>Ydt),void 0,import.meta.url).then(e=>e.html())}}),ye.of({name:"Java",extensions:["java"],load(){return xe(()=>Promise.resolve().then(()=>W0t),void 0,import.meta.url).then(e=>e.java())}}),ye.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return xe(()=>Promise.resolve().then(()=>Bw),void 0,import.meta.url).then(e=>e.javascript())}}),ye.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return xe(()=>Promise.resolve().then(()=>Vft),void 0,import.meta.url).then(e=>e.json())}}),ye.of({name:"JSX",extensions:["jsx"],load(){return xe(()=>Promise.resolve().then(()=>Bw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ye.of({name:"LESS",extensions:["less"],load(){return xe(()=>Promise.resolve().then(()=>lft),void 0,import.meta.url).then(e=>e.less())}}),ye.of({name:"Liquid",extensions:["liquid"],load(){return xe(()=>Promise.resolve().then(()=>Svt),void 0,import.meta.url).then(e=>e.liquid())}}),ye.of({name:"MariaDB SQL",load(){return Nu("MariaSQL")}}),ye.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return xe(()=>Promise.resolve().then(()=>Hdt),void 0,import.meta.url).then(e=>e.markdown())}}),ye.of({name:"MS SQL",load(){return Nu("MSSQL")}}),ye.of({name:"MySQL",load(){return Nu("MySQL")}}),ye.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return xe(()=>Promise.resolve().then(()=>tvt),void 0,import.meta.url).then(e=>e.php())}}),ye.of({name:"PLSQL",extensions:["pls"],load(){return Nu("PLSQL")}}),ye.of({name:"PostgreSQL",load(){return Nu("PostgreSQL")}}),ye.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return xe(()=>Promise.resolve().then(()=>Sgt),void 0,import.meta.url).then(e=>e.python())}}),ye.of({name:"Rust",extensions:["rs"],load(){return xe(()=>Promise.resolve().then(()=>a$t),void 0,import.meta.url).then(e=>e.rust())}}),ye.of({name:"Sass",extensions:["sass"],load(){return xe(()=>Promise.resolve().then(()=>ZF),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ye.of({name:"SCSS",extensions:["scss"],load(){return xe(()=>Promise.resolve().then(()=>ZF),void 0,import.meta.url).then(e=>e.sass())}}),ye.of({name:"SQL",extensions:["sql"],load(){return Nu("StandardSQL")}}),ye.of({name:"SQLite",load(){return Nu("SQLite")}}),ye.of({name:"TSX",extensions:["tsx"],load(){return xe(()=>Promise.resolve().then(()=>Bw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ye.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return xe(()=>Promise.resolve().then(()=>Bw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ye.of({name:"WebAssembly",extensions:["wat","wast"],load(){return xe(()=>Promise.resolve().then(()=>kvt),void 0,import.meta.url).then(e=>e.wast())}}),ye.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return xe(()=>Promise.resolve().then(()=>Vgt),void 0,import.meta.url).then(e=>e.xml())}}),ye.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return xe(()=>import("./index-D7fnBkIK.js"),__vite__mapDeps([7,1,2,3,4,5,6]),import.meta.url).then(e=>e.yaml())}}),ye.of({name:"APL",extensions:["dyalog","apl"],load(){return xe(()=>Promise.resolve().then(()=>n1t),void 0,import.meta.url).then(e=>ze(e.apl))}}),ye.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return xe(()=>Promise.resolve().then(()=>r1t),void 0,import.meta.url).then(e=>ze(e.asciiArmor))}}),ye.of({name:"ASN.1",extensions:["asn","asn1"],load(){return xe(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>ze(e.asn1({})))}}),ye.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return xe(()=>Promise.resolve().then(()=>l1t),void 0,import.meta.url).then(e=>ze(e.asterisk))}}),ye.of({name:"Brainfuck",extensions:["b","bf"],load(){return xe(()=>Promise.resolve().then(()=>u1t),void 0,import.meta.url).then(e=>ze(e.brainfuck))}}),ye.of({name:"Cobol",extensions:["cob","cpy"],load(){return xe(()=>Promise.resolve().then(()=>U1t),void 0,import.meta.url).then(e=>ze(e.cobol))}}),ye.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.csharp))}}),ye.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"ClojureScript",extensions:["cljs"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return xe(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>ze(e.gss))}}),ye.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return xe(()=>Promise.resolve().then(()=>T1t),void 0,import.meta.url).then(e=>ze(e.cmake))}}),ye.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return xe(()=>Promise.resolve().then(()=>H1t),void 0,import.meta.url).then(e=>ze(e.coffeeScript))}}),ye.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return xe(()=>Promise.resolve().then(()=>rxt),void 0,import.meta.url).then(e=>ze(e.commonLisp))}}),ye.of({name:"Cypher",extensions:["cyp","cypher"],load(){return xe(()=>Promise.resolve().then(()=>bxt),void 0,import.meta.url).then(e=>ze(e.cypher))}}),ye.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return xe(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>ze(e.cython))}}),ye.of({name:"Crystal",extensions:["cr"],load(){return xe(()=>Promise.resolve().then(()=>pxt),void 0,import.meta.url).then(e=>ze(e.crystal))}}),ye.of({name:"D",extensions:["d"],load(){return xe(()=>Promise.resolve().then(()=>Pxt),void 0,import.meta.url).then(e=>ze(e.d))}}),ye.of({name:"Dart",extensions:["dart"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.dart))}}),ye.of({name:"diff",extensions:["diff","patch"],load(){return xe(()=>Promise.resolve().then(()=>Txt),void 0,import.meta.url).then(e=>ze(e.diff))}}),ye.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return xe(()=>Promise.resolve().then(()=>Gxt),void 0,import.meta.url).then(e=>ze(e.dockerFile))}}),ye.of({name:"DTD",extensions:["dtd"],load(){return xe(()=>Promise.resolve().then(()=>Dxt),void 0,import.meta.url).then(e=>ze(e.dtd))}}),ye.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return xe(()=>Promise.resolve().then(()=>Bxt),void 0,import.meta.url).then(e=>ze(e.dylan))}}),ye.of({name:"EBNF",load(){return xe(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>ze(e.ebnf))}}),ye.of({name:"ECL",extensions:["ecl"],load(){return xe(()=>Promise.resolve().then(()=>aSt),void 0,import.meta.url).then(e=>ze(e.ecl))}}),ye.of({name:"edn",extensions:["edn"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"Eiffel",extensions:["e"],load(){return xe(()=>Promise.resolve().then(()=>OSt),void 0,import.meta.url).then(e=>ze(e.eiffel))}}),ye.of({name:"Elm",extensions:["elm"],load(){return xe(()=>Promise.resolve().then(()=>wSt),void 0,import.meta.url).then(e=>ze(e.elm))}}),ye.of({name:"Erlang",extensions:["erl"],load(){return xe(()=>Promise.resolve().then(()=>VSt),void 0,import.meta.url).then(e=>ze(e.erlang))}}),ye.of({name:"Esper",load(){return xe(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>ze(e.esper))}}),ye.of({name:"Factor",extensions:["factor"],load(){return xe(()=>Promise.resolve().then(()=>MSt),void 0,import.meta.url).then(e=>ze(e.factor))}}),ye.of({name:"FCL",load(){return xe(()=>Promise.resolve().then(()=>KSt),void 0,import.meta.url).then(e=>ze(e.fcl))}}),ye.of({name:"Forth",extensions:["forth","fth","4th"],load(){return xe(()=>Promise.resolve().then(()=>tQt),void 0,import.meta.url).then(e=>ze(e.forth))}}),ye.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return xe(()=>Promise.resolve().then(()=>lQt),void 0,import.meta.url).then(e=>ze(e.fortran))}}),ye.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.fSharp))}}),ye.of({name:"Gas",extensions:["s"],load(){return xe(()=>Promise.resolve().then(()=>uQt),void 0,import.meta.url).then(e=>ze(e.gas))}}),ye.of({name:"Gherkin",extensions:["feature"],load(){return xe(()=>Promise.resolve().then(()=>OQt),void 0,import.meta.url).then(e=>ze(e.gherkin))}}),ye.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return xe(()=>Promise.resolve().then(()=>wQt),void 0,import.meta.url).then(e=>ze(e.groovy))}}),ye.of({name:"Haskell",extensions:["hs"],load(){return xe(()=>Promise.resolve().then(()=>TQt),void 0,import.meta.url).then(e=>ze(e.haskell))}}),ye.of({name:"Haxe",extensions:["hx"],load(){return xe(()=>Promise.resolve().then(()=>KH),void 0,import.meta.url).then(e=>ze(e.haxe))}}),ye.of({name:"HXML",extensions:["hxml"],load(){return xe(()=>Promise.resolve().then(()=>KH),void 0,import.meta.url).then(e=>ze(e.hxml))}}),ye.of({name:"HTTP",load(){return xe(()=>Promise.resolve().then(()=>KQt),void 0,import.meta.url).then(e=>ze(e.http))}}),ye.of({name:"IDL",extensions:["pro"],load(){return xe(()=>Promise.resolve().then(()=>a_t),void 0,import.meta.url).then(e=>ze(e.idl))}}),ye.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return xe(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>ze(e.jsonld))}}),ye.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return xe(()=>Promise.resolve().then(()=>c_t),void 0,import.meta.url).then(e=>ze(e.jinja2))}}),ye.of({name:"Julia",extensions:["jl"],load(){return xe(()=>Promise.resolve().then(()=>j_t),void 0,import.meta.url).then(e=>ze(e.julia))}}),ye.of({name:"Kotlin",extensions:["kt","kts"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.kotlin))}}),ye.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return xe(()=>Promise.resolve().then(()=>U_t),void 0,import.meta.url).then(e=>ze(e.liveScript))}}),ye.of({name:"Lua",extensions:["lua"],load(){return xe(()=>Promise.resolve().then(()=>V_t),void 0,import.meta.url).then(e=>ze(e.lua))}}),ye.of({name:"mIRC",extensions:["mrc"],load(){return xe(()=>Promise.resolve().then(()=>pkt),void 0,import.meta.url).then(e=>ze(e.mirc))}}),ye.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return xe(()=>Promise.resolve().then(()=>ekt),void 0,import.meta.url).then(e=>ze(e.mathematica))}}),ye.of({name:"Modelica",extensions:["mo"],load(){return xe(()=>Promise.resolve().then(()=>Qkt),void 0,import.meta.url).then(e=>ze(e.modelica))}}),ye.of({name:"MUMPS",extensions:["mps"],load(){return xe(()=>Promise.resolve().then(()=>Ykt),void 0,import.meta.url).then(e=>ze(e.mumps))}}),ye.of({name:"Mbox",extensions:["mbox"],load(){return xe(()=>Promise.resolve().then(()=>dkt),void 0,import.meta.url).then(e=>ze(e.mbox))}}),ye.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return xe(()=>Promise.resolve().then(()=>Vkt),void 0,import.meta.url).then(e=>ze(e.nginx))}}),ye.of({name:"NSIS",extensions:["nsh","nsi"],load(){return xe(()=>Promise.resolve().then(()=>Mkt),void 0,import.meta.url).then(e=>ze(e.nsis))}}),ye.of({name:"NTriples",extensions:["nt","nq"],load(){return xe(()=>Promise.resolve().then(()=>Lkt),void 0,import.meta.url).then(e=>ze(e.ntriples))}}),ye.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.objectiveC))}}),ye.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.objectiveCpp))}}),ye.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.oCaml))}}),ye.of({name:"Octave",extensions:["m"],load(){return xe(()=>Promise.resolve().then(()=>aPt),void 0,import.meta.url).then(e=>ze(e.octave))}}),ye.of({name:"Oz",extensions:["oz"],load(){return xe(()=>Promise.resolve().then(()=>gPt),void 0,import.meta.url).then(e=>ze(e.oz))}}),ye.of({name:"Pascal",extensions:["p","pas"],load(){return xe(()=>Promise.resolve().then(()=>xPt),void 0,import.meta.url).then(e=>ze(e.pascal))}}),ye.of({name:"Perl",extensions:["pl","pm"],load(){return xe(()=>Promise.resolve().then(()=>SPt),void 0,import.meta.url).then(e=>ze(e.perl))}}),ye.of({name:"Pig",extensions:["pig"],load(){return xe(()=>Promise.resolve().then(()=>kPt),void 0,import.meta.url).then(e=>ze(e.pig))}}),ye.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return xe(()=>Promise.resolve().then(()=>IPt),void 0,import.meta.url).then(e=>ze(e.powerShell))}}),ye.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return xe(()=>Promise.resolve().then(()=>ZPt),void 0,import.meta.url).then(e=>ze(e.properties))}}),ye.of({name:"ProtoBuf",extensions:["proto"],load(){return xe(()=>Promise.resolve().then(()=>FPt),void 0,import.meta.url).then(e=>ze(e.protobuf))}}),ye.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return xe(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([8,9]),import.meta.url).then(e=>ze(e.pug))}}),ye.of({name:"Puppet",extensions:["pp"],load(){return xe(()=>Promise.resolve().then(()=>KPt),void 0,import.meta.url).then(e=>ze(e.puppet))}}),ye.of({name:"Q",extensions:["q"],load(){return xe(()=>Promise.resolve().then(()=>o5t),void 0,import.meta.url).then(e=>ze(e.q))}}),ye.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return xe(()=>Promise.resolve().then(()=>f5t),void 0,import.meta.url).then(e=>ze(e.r))}}),ye.of({name:"RPM Changes",load(){return xe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ze(e.rpmChanges))}}),ye.of({name:"RPM Spec",extensions:["spec"],load(){return xe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ze(e.rpmSpec))}}),ye.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return xe(()=>Promise.resolve().then(()=>w5t),void 0,import.meta.url).then(e=>ze(e.ruby))}}),ye.of({name:"SAS",extensions:["sas"],load(){return xe(()=>Promise.resolve().then(()=>_5t),void 0,import.meta.url).then(e=>ze(e.sas))}}),ye.of({name:"Scala",extensions:["scala"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.scala))}}),ye.of({name:"Scheme",extensions:["scm","ss"],load(){return xe(()=>Promise.resolve().then(()=>W5t),void 0,import.meta.url).then(e=>ze(e.scheme))}}),ye.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return xe(()=>Promise.resolve().then(()=>I5t),void 0,import.meta.url).then(e=>ze(e.shell))}}),ye.of({name:"Sieve",extensions:["siv","sieve"],load(){return xe(()=>Promise.resolve().then(()=>L5t),void 0,import.meta.url).then(e=>ze(e.sieve))}}),ye.of({name:"Smalltalk",extensions:["st"],load(){return xe(()=>Promise.resolve().then(()=>H5t),void 0,import.meta.url).then(e=>ze(e.smalltalk))}}),ye.of({name:"Solr",load(){return xe(()=>Promise.resolve().then(()=>i2t),void 0,import.meta.url).then(e=>ze(e.solr))}}),ye.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.sml))}}),ye.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return xe(()=>Promise.resolve().then(()=>O2t),void 0,import.meta.url).then(e=>ze(e.sparql))}}),ye.of({name:"Spreadsheet",alias:["excel","formula"],load(){return xe(()=>Promise.resolve().then(()=>d2t),void 0,import.meta.url).then(e=>ze(e.spreadsheet))}}),ye.of({name:"Squirrel",extensions:["nut"],load(){return xe(()=>Promise.resolve().then(()=>bd),void 0,import.meta.url).then(e=>ze(e.squirrel))}}),ye.of({name:"Stylus",extensions:["styl"],load(){return xe(()=>Promise.resolve().then(()=>j2t),void 0,import.meta.url).then(e=>ze(e.stylus))}}),ye.of({name:"Swift",extensions:["swift"],load(){return xe(()=>Promise.resolve().then(()=>eTt),void 0,import.meta.url).then(e=>ze(e.swift))}}),ye.of({name:"sTeX",load(){return xe(()=>Promise.resolve().then(()=>IK),void 0,import.meta.url).then(e=>ze(e.stex))}}),ye.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return xe(()=>Promise.resolve().then(()=>IK),void 0,import.meta.url).then(e=>ze(e.stex))}}),ye.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return xe(()=>Promise.resolve().then(()=>cJ),void 0,import.meta.url).then(e=>ze(e.verilog))}}),ye.of({name:"Tcl",extensions:["tcl"],load(){return xe(()=>Promise.resolve().then(()=>iTt),void 0,import.meta.url).then(e=>ze(e.tcl))}}),ye.of({name:"Textile",extensions:["textile"],load(){return xe(()=>Promise.resolve().then(()=>lTt),void 0,import.meta.url).then(e=>ze(e.textile))}}),ye.of({name:"TiddlyWiki",load(){return xe(()=>Promise.resolve().then(()=>TTt),void 0,import.meta.url).then(e=>ze(e.tiddlyWiki))}}),ye.of({name:"Tiki wiki",load(){return xe(()=>Promise.resolve().then(()=>zTt),void 0,import.meta.url).then(e=>ze(e.tiki))}}),ye.of({name:"TOML",extensions:["toml"],load(){return xe(()=>Promise.resolve().then(()=>ATt),void 0,import.meta.url).then(e=>ze(e.toml))}}),ye.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return xe(()=>Promise.resolve().then(()=>NTt),void 0,import.meta.url).then(e=>ze(e.troff))}}),ye.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return xe(()=>Promise.resolve().then(()=>iXt),void 0,import.meta.url).then(e=>ze(e.ttcn))}}),ye.of({name:"TTCN_CFG",extensions:["cfg"],load(){return xe(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>ze(e.ttcnCfg))}}),ye.of({name:"Turtle",extensions:["ttl"],load(){return xe(()=>Promise.resolve().then(()=>sXt),void 0,import.meta.url).then(e=>ze(e.turtle))}}),ye.of({name:"Web IDL",extensions:["webidl"],load(){return xe(()=>Promise.resolve().then(()=>eRt),void 0,import.meta.url).then(e=>ze(e.webIDL))}}),ye.of({name:"VB.NET",extensions:["vb"],load(){return xe(()=>Promise.resolve().then(()=>wXt),void 0,import.meta.url).then(e=>ze(e.vb))}}),ye.of({name:"VBScript",extensions:["vbs"],load(){return xe(()=>Promise.resolve().then(()=>SXt),void 0,import.meta.url).then(e=>ze(e.vbScript))}}),ye.of({name:"Velocity",extensions:["vtl"],load(){return xe(()=>Promise.resolve().then(()=>kXt),void 0,import.meta.url).then(e=>ze(e.velocity))}}),ye.of({name:"Verilog",extensions:["v"],load(){return xe(()=>Promise.resolve().then(()=>cJ),void 0,import.meta.url).then(e=>ze(e.verilog))}}),ye.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return xe(()=>Promise.resolve().then(()=>zXt),void 0,import.meta.url).then(e=>ze(e.vhdl))}}),ye.of({name:"XQuery",extensions:["xy","xquery"],load(){return xe(()=>Promise.resolve().then(()=>uRt),void 0,import.meta.url).then(e=>ze(e.xQuery))}}),ye.of({name:"Yacas",extensions:["ys"],load(){return xe(()=>Promise.resolve().then(()=>vRt),void 0,import.meta.url).then(e=>ze(e.yacas))}}),ye.of({name:"Z80",extensions:["z80"],load(){return xe(()=>Promise.resolve().then(()=>QRt),void 0,import.meta.url).then(e=>ze(e.z80))}}),ye.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return xe(()=>Promise.resolve().then(()=>$R),void 0,import.meta.url).then(e=>ze(e.mscgen))}}),ye.of({name:"Xù",extensions:["xu"],load(){return xe(()=>Promise.resolve().then(()=>$R),void 0,import.meta.url).then(e=>ze(e.xu))}}),ye.of({name:"MsGenny",extensions:["msgenny"],load(){return xe(()=>Promise.resolve().then(()=>$R),void 0,import.meta.url).then(e=>ze(e.msgenny))}}),ye.of({name:"Vue",extensions:["vue"],load(){return xe(()=>Promise.resolve().then(()=>Cvt),void 0,import.meta.url).then(e=>e.vue())}}),ye.of({name:"Angular Template",load(){return xe(()=>Promise.resolve().then(()=>ebt),void 0,import.meta.url).then(e=>e.angular())}})];class uW{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=Mn(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),a=i.search(M$e(t,!1));return a<0?null:{from:r+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function WL(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function fct(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let a=1;a<i.length;a++)n[i[a]]=!0}let r=WL(t)+WL(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Ob(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:fct(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function iP(e,t){return n=>{for(let r=Mn(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class NL{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function nf(e){return e.selection.main.from}function M$e(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",a=r[r.length-1]!="$";return!i&&!a?e:new RegExp(`${i?"^":""}(?:${r})${a?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const OW=Zf.define();function hct(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Le.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const YL=new WeakMap;function pct(e){if(!Array.isArray(e))return e;let t=YL.get(e);return t||YL.set(e,t=Ob(e)),t}const aQ=_n.define(),_y=_n.define();class mct{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=yo(t,n),i=Rc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(yo(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let b=yo(t,0),x=Rc(b),Q=x==t.length?0:-100;if(b!=n[0])if(b==r[0])Q+=-200;else return null;return this.ret(Q,[0,x])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let b=0,x=Math.min(t.length,200);b<x&&c<l;){let Q=yo(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=Rc(Q)}if(c<l)return null}let u=0,O=0,f=!1,p=0,m=-1,g=-1,y=/[a-z]/.test(t),v=!0;for(let b=0,x=Math.min(t.length,200),Q=0;b<x&&O<l;){let w=yo(t,b);s<0&&(u<l&&w==n[u]&&(a[u++]=b),p<l&&(w==n[p]||w==r[p]?(p==0&&(m=b),g=b+1,p++):p=0));let S,_=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=i0e(w))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||_==1&&y||Q==0&&_!=0)&&(n[O]==w||r[O]==w&&(f=!0)?o[O++]=b:o.length&&(v=!1)),Q=_,b+=Rc(w)}return O==l&&o[0]==0&&v?this.result(-100+(f?-200:0),o,t):p==l&&m==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):p==l?this.ret(-900-t.length,[m,g]):O==l?this.result(-100+(f?-200:0)+-700+(v?0:-1100),o,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],a=0;for(let o of n){let s=o+(this.astral?Rc(yo(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class gct{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const Ci=mt.define({combine(e){return ng(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:$ct,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>GL(t(r),n(r)),optionClass:(t,n)=>r=>GL(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function GL(e,t){return e?t?e+" "+t:e:t}function $ct(e,t,n,r,i,a){let o=e.textDirection==xr.RTL,s=o,l=!1,c="top",u,O,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,g=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,O=Math.min(400,s?f:p);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let b=i.bottom-t.bottom;b>=g||b>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let y=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${O/v}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function yct(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,a){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&o.appendChild(document.createTextNode(s.slice(l,u)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(s.slice(u,O))),f.className="cm-completionMatchedText",l=O}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function fX(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class vct{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:a,selected:o}=i.open,s=t.state.facet(Ci);this.optionContent=yct(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=fX(a.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,O;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(O=/-(\d+)$/.exec(u.id))&&+O[1]<c.length){this.applyCompletion(t,c[+O[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Ci).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:_y.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:a,selected:o,disabled:s}=r.open;(!i.open||i.open.options!=a)&&(this.range=fX(a.length,o,t.state.facet(Ci).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),s!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=fX(n.options.length,n.selected,this.view.state.facet(Ci).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let a=typeof i=="string"?document.createTextNode(i):i(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Va(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&wct(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.space;if(!a){let o=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(a.bottom,n.bottom)-10||i.bottom<Math.max(a.top,n.top)+10?null:this.view.state.facet(Ci).positionInfo(this.view,n,i,r,a,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let a=null;for(let o=r.from;o<r.to;o++){let{completion:s,match:l}=t[o],{section:c}=s;if(c){let f=typeof c=="string"?c:c.name;if(f!=a&&(o>r.from||r.from==0))if(a=f,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let p=i.appendChild(document.createElement("completion-section"));p.textContent=f}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let O=this.optionClass(s);O&&(u.className=O);for(let f of this.optionContent){let p=f(s,this.view.state,this.view,l);p&&u.appendChild(p)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function bct(e,t){return n=>new vct(n,e,t)}function wct(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function IL(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function xct(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let O=typeof u=="string"?u:u.name;r.some(f=>f.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Ci);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let O of c.result.options)i(new NL(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),f,p=a.filterStrict?new gct(O):new mct(O);for(let m of c.result.options)if(f=p.match(m.label)){let g=m.displayLabel?u?u(m,f.matched):[]:f.matched;i(new NL(m,c.source,g,f.score+(m.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(f,p)=>{var m,g;return((m=f.rank)!==null&&m!==void 0?m:1e9)-((g=p.rank)!==null&&g!==void 0?g:1e9)||(f.name<p.name?-1:1)};for(let f of r.sort(O))u-=1e5,c[f.name]=u;for(let f of n){let{section:p}=f.completion;p&&(f.score+=c[typeof p=="string"?p:p.name])}}let o=[],s=null,l=a.compareCompletions;for(let c of n.sort((u,O)=>O.score-u.score||l(u.completion,O.completion))){let u=c.completion;!s||s.label!=u.label||s.detail!=u.detail||s.type!=null&&u.type!=null&&s.type!=u.type||s.apply!=u.apply||s.boost!=u.boost?o.push(c):IL(c.completion)>IL(s)&&(o[o.length-1]=c),s=c.completion}return o}class up{constructor(t,n,r,i,a,o){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=o}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new up(this.options,ZL(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(c=>c.isPending))return i.setDisabled();let s=xct(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ci).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<s.length;u++)if(s[u].completion==c){l=u;break}}return new up(s,ZL(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Tct,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new up(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new up(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class oQ{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new oQ(kct,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ci),a=(r.override||n.languageDataAt("autocomplete",nf(n)).map(pct)).map(l=>(this.active.find(u=>u.source==l)||new ts(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(dW));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Sct(a,this.active)||s?o=up.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new ts(l.source,0):l));for(let l of t.effects)l.is(F$e)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new oQ(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Qct:_ct}}function Sct(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}const Qct={"aria-autocomplete":"list"},_ct={};function ZL(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const kct=[];function L$e(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(OW);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class ts{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=L$e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ts(i.source,0)),r&4&&i.state==0&&(i=new ts(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(aQ))i=new ts(i.source,1,a.value);else if(a.is(_y))i=new ts(i.source,0);else if(a.is(dW))for(let o of a.value)o.source==i.source&&(i=o);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(nf(t.state))}}class _p extends ts{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=nf(t.state);if(s>o||!i||n&2&&(nf(t.startState)==this.from||s<this.limit))return new ts(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Pct(i.validFor,t.state,a,o)?new _p(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new uW(t.state,s,!1)))?new _p(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:nf(t.state)):new ts(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new _p(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ts(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Pct(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):M$e(e,!0).test(i)}const dW=_n.define({map(e,t){return e.map(n=>n.map(t))}}),F$e=_n.define(),Ia=eo.define({create(){return oQ.start()},update(e,t){return e.update(t)},provide:e=>[rW.from(e,t=>t.tooltip),Pt.contentAttributes.from(e,t=>t.attrs)]});function fW(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ia).active.find(i=>i.source==t.source);return r instanceof _p?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},hct(e.state,n,r.from,r.to)),{annotations:OW.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Tct=bct(Ia,fW);function Mw(e,t="option"){return n=>{let r=n.state.field(Ia,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ci).interactionDelay)return!1;let i=1,a;t=="page"&&(a=y$e(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t=="page"?0:o-1:s>=o&&(s=t=="page"?o-1:0),n.dispatch({effects:F$e.of(s)}),!0}}const Xct=e=>{let t=e.state.field(Ia,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ci).interactionDelay?!1:fW(e,t.open.options[t.open.selected])},DL=e=>e.state.field(Ia,!1)?(e.dispatch({effects:aQ.of(!0)}),!0):!1,Rct=e=>{let t=e.state.field(Ia,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:_y.of(null)}),!0)};class Ect{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const qct=50,jct=1e3,Cct=xi.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Ia).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ia),n=e.state.facet(Ci);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ia)==t)return;let r=e.transactions.some(a=>{let o=L$e(a,n);return o&8||(a.selection||a.docChanged)&&!(o&3)});for(let a=0;a<this.running.length;a++){let o=this.running[a];if(r||o.context.abortOnDocChange&&e.docChanged||o.updates.length+e.transactions.length>qct&&Date.now()-o.time>jct){for(let s of o.context.abortListeners)try{s()}catch(l){Va(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(aQ)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(o=>o.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of e.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Ia);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ci).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=nf(t),r=new uW(t,n,e.explicit,this.view),i=new Ect(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:_y.of(null)}),Va(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ci).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ci),r=this.view.state.field(Ia);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=nf(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new _p(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new ts(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:dW.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ia,!1);if(t&&t.tooltip&&this.view.state.facet(Ci).closeOnBlur){let n=t.open&&y$e(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:_y.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:aQ.of(!1)}),20),this.composing=0}}}),zct=typeof navigator=="object"&&/Win/.test(navigator.platform),Act=FO.highest(Pt.domEventHandlers({keydown(e,t){let n=t.state.field(Ia,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(zct&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&fW(t,r),!1}})),B$e=Pt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Uct{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class hW{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Mi.TrackDel),r=t.mapPos(this.to,1,Mi.TrackDel);return n==null||r==null?null:new hW(this.field,n,r)}}class pW{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),o=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(tP);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let s=this.fieldPositions.map(l=>new hW(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:s}}static parse(t){let n=[],r=[],i=[],a;for(let o of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let s=a[1]?+a[1]:null,l=a[2]||a[3]||"",c=-1,u=l.replace(/\\[{}]/g,O=>O[1]);for(let O=0;O<n.length;O++)(s!=null?n[O].seq==s:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(s==null||n[O].seq!=null&&n[O].seq<s);)O++;n.splice(O,0,{seq:s,name:u}),c=O;for(let f of i)f.field>=c&&f.field++}i.push(new Uct(c,r.length,a.index,a.index+u.length)),o=o.slice(0,a.index)+l+o.slice(a.index+a[0].length)}o=o.replace(/\\([{}])/g,(s,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(o)}return new pW(r,i)}}let Wct=On.widget({widget:new class extends xu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Nct=On.mark({class:"cm-snippetField"});class rg{constructor(t,n){this.ranges=t,this.active=n,this.deco=On.set(t.map(r=>(r.from==r.to?Wct:Nct).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new rg(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const db=_n.define({map(e,t){return e&&e.map(t)}}),Yct=_n.define(),ky=eo.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(db))return n.value;if(n.is(Yct)&&e)return new rg(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Pt.decorations.from(e,t=>t?t.deco:On.none)});function mW(e,t){return Le.create(e.filter(n=>n.field==t).map(n=>Le.range(n.from,n.to)))}function Gct(e){let t=pW.parse(e);return(n,r,i,a)=>{let{text:o,ranges:s}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:Vn.of(o)},scrollIntoView:!0,annotations:r?[OW.of(r),Li.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=mW(s,0)),s.some(u=>u.field>0)){let u=new rg(s,0),O=c.effects=[db.of(u)];n.state.field(ky,!1)===void 0&&O.push(_n.appendConfig.of([ky,Mct,Lct,B$e]))}n.dispatch(n.state.update(c))}}function H$e(e){return({state:t,dispatch:n})=>{let r=t.field(ky,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(o=>o.field==i+e);return n(t.update({selection:mW(r.ranges,i),effects:db.of(a?null:new rg(r.ranges,i)),scrollIntoView:!0})),!0}}const Ict=({state:e,dispatch:t})=>e.field(ky,!1)?(t(e.update({effects:db.of(null)})),!0):!1,Zct=H$e(1),Dct=H$e(-1),Vct=[{key:"Tab",run:Zct,shift:Dct},{key:"Escape",run:Ict}],VL=mt.define({combine(e){return e.length?e[0]:Vct}}),Mct=FO.highest(Kk.compute([VL],e=>e.facet(VL)));function gr(e,t){return Object.assign(Object.assign({},t),{apply:Gct(e)})}const Lct=Pt.domEventHandlers({mousedown(e,t){let n=t.state.field(ky,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(a=>a.from<=r&&a.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:mW(n.ranges,i.field),effects:db.of(n.ranges.some(a=>a.field>i.field)?new rg(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Py={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Gd=_n.define({map(e,t){let n=t.mapPos(e,-1,Mi.TrackAfter);return n??void 0}}),gW=new class extends $f{};gW.startSide=1;gW.endSide=-1;const K$e=eo.define({create(){return Qn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(Gd)&&(e=e.update({add:[gW.range(n.value,n.value+1)]}));return e}});function I0n(){return[Bct,K$e]}const hX="()[]{}<>«»»«[]{}";function J$e(e){for(let t=0;t<hX.length;t+=2)if(hX.charCodeAt(t)==e)return hX.charAt(t+1);return i0e(e<128?e:e+1)}function eye(e,t){return e.languageDataAt("closeBrackets",t)[0]||Py}const Fct=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Bct=Pt.inputHandler.of((e,t,n,r)=>{if((Fct?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Rc(yo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Kct(e.state,r);return a?(e.dispatch(a),!0):!1}),Hct=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=eye(e,e.selection.main.head).brackets||Py.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=Jct(e.doc,o.head);for(let l of r)if(l==s&&aP(e.doc,o.head)==J$e(yo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Le.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Z0n=[{key:"Backspace",run:Hct}];function Kct(e,t){let n=eye(e,e.selection.main.head),r=n.brackets||Py.brackets;for(let i of r){let a=J$e(yo(i,0));if(t==i)return a==i?nut(e,i,r.indexOf(i+i+i)>-1,n):eut(e,i,a,n.before||Py.before);if(t==a&&tye(e,e.selection.main.from))return tut(e,i,a)}return null}function tye(e,t){let n=!1;return e.field(K$e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function aP(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Rc(yo(n,0)))}function Jct(e,t){let n=e.sliceString(t-2,t);return Rc(yo(n,0))==n.length?n:n.slice(1)}function eut(e,t,n,r){let i=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:Gd.of(o.to+t.length),range:Le.range(o.anchor+t.length,o.head+t.length)};let s=aP(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Gd.of(o.head+t.length),range:Le.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function tut(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&aP(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Le.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function nut(e,t,n,r){let i=r.stringPrefixes||Py.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Gd.of(s.to+t.length),range:Le.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=aP(e.doc,l),u;if(c==t){if(ML(e,l))return{changes:{insert:t+t,from:l},effects:Gd.of(l+t.length),range:Le.cursor(l+t.length)};if(tye(e,l)){let f=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+f.length,insert:f},range:Le.cursor(l+f.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=LL(e,l-2*t.length,i))>-1&&ML(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Gd.of(l+t.length),range:Le.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=es.Word&&LL(e,l,i)>-1&&!rut(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Gd.of(l+t.length),range:Le.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ML(e,t){let n=Mn(e).resolveInner(t+1);return n.parent&&n.from==t}function rut(e,t,n,r){let i=Mn(e).resolveInner(t,-1),a=r.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function LL(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=es.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=es.Word)return a}return-1}function D0n(e={}){return[Act,Ia,Ci.of(e),Cct,aut,B$e]}const iut=[{key:"Ctrl-Space",run:DL},{mac:"Alt-`",run:DL},{key:"Escape",run:Rct},{key:"ArrowDown",run:Mw(!0)},{key:"ArrowUp",run:Mw(!1)},{key:"PageDown",run:Mw(!0,"page")},{key:"PageUp",run:Mw(!1,"page")},{key:"Enter",run:Xct}],aut=FO.highest(Kk.computeN([Ci],e=>e.facet(Ci).defaultKeymap?[iut]:[]));class sQ{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new sQ(t,n,r,o,a,[],[])}constructor(t,n,r,i,a,o,s){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=o,this.positions=s,this.hashProp=[[Vt.contextHash,i]]}addChild(t,n){t.prop(Vt.contextHash)!=this.hash&&(t=new pn(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new pn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new pn(fi.none,i,a,o,this.hashProp)})}}var Fe;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(Fe||(Fe={}));class out{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let sut=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return S$(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}};function FL(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==Fe.OrderedList?vW:yW)(n,t,!1);return r>0&&(e.type!=Fe.BulletList||$W(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const nye={[Fe.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(yn(Fe.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(ms(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Fe.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Fe.OrderedList]:FL,[Fe.BulletList]:FL,[Fe.Document](){return!0}};function ms(e){return e==32||e==9||e==10||e==13}function S$(e,t=0){for(;t<e.length&&ms(e.charCodeAt(t));)t++;return t}function BL(e,t,n){for(;t>n&&ms(e.charCodeAt(t-1));)t--;return t}function rye(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function iye(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function $W(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!ms(a))return-1}return n&&e.next==45&&sye(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Oye.SetextHeading)>-1||r<3?-1:1}function aye(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function yW(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||ms(e.text.charCodeAt(e.pos+1)))&&(!n||aye(t,Fe.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function vW(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!ms(e.text.charCodeAt(r+1))||n&&!aye(t,Fe.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function oye(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function sye(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&ms(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const GC=/^[ \t]*$/,lye=/-->/,cye=/\?>/,IC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,lye],[/^\s*<\?/,cye],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,GC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,GC]];function uye(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=IC.length-(n?1:0);i<a;i++)if(IC[i][0].test(r))return i;return-1}function HL(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function $d(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Fe.CodeText?e[r].to=n:e.push(yn(Fe.CodeText,t,n))}const Lw={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for($d(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){$d(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==Fe.CodeText?$d(o,c.from,c.to):o.push(c);s=[]}$d(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&$d(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Fe.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Fe.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=rye(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=BL(t.text,t.text.length,o),l=[yn(Fe.CodeMark,r,r+a)];o<s&&l.push(yn(Fe.CodeInfo,e.lineStart+o,e.lineStart+s));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=a&&t.skipSpace(u)==t.text.length){for(let O of t.markers)l.push(O);l.push(yn(Fe.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||$d(l,e.lineStart-1,e.lineStart);for(let p of t.markers)l.push(p);let O=e.lineStart+t.basePos,f=e.lineStart+t.text.length;O<f&&$d(l,O,f)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Fe.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=iye(t);return n<0?!1:(e.startContext(Fe.Blockquote,t.pos),e.addNode(Fe.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if($W(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Fe.HorizontalRule,n),!0},BulletList(e,t){let n=yW(t,e,!1);if(n<0)return!1;e.block.type!=Fe.BulletList&&e.startContext(Fe.BulletList,t.basePos,t.next);let r=HL(t,t.pos+1);return e.startContext(Fe.ListItem,t.basePos,r-t.baseIndent),e.addNode(Fe.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=vW(t,e,!1);if(n<0)return!1;e.block.type!=Fe.OrderedList&&e.startContext(Fe.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=HL(t,t.pos+n);return e.startContext(Fe.ListItem,t.basePos,r-t.baseIndent),e.addNode(Fe.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=oye(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=BL(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!ms(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Fe.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Fe.HeaderMark,o-r,a-r);let l=s.finish(Fe.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=uye(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=IC[n][1],a=[],o=i!=GC;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let c of t.markers)a.push(c)}o&&e.nextLine();let s=i==lye?Fe.CommentBlock:i==cye?Fe.ProcessingInstructionBlock:Fe.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class lut{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
|
|
905
905
|
`+n.scrub(),a=this.advance(i);return a>-1&&a<i.length?this.complete(t,r,a):!1}finish(t,n){return(this.stage==2||this.stage==3)&&S$(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,yn(Fe.LinkReference,this.start,this.start+r,this.elts)),!0}nextStage(t){return t?(this.pos=t.to-this.start,this.elts.push(t),this.stage++,!0):(t===!1&&(this.stage=-1),!1)}advance(t){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(vye(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(yn(Fe.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage($ye(t,S$(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=S$(t,this.pos),r=0;if(n>this.pos){let i=yye(t,n,this.start);if(i){let a=pX(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=pX(t,this.pos)),r>0&&r<t.length?r:-1}else return pX(t,this.pos)}}}function pX(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!ms(n))return-1}return t}class cut{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:sye(n),a=n.next;if(i<0)return!1;let o=yn(Fe.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,yn(a==61?Fe.SetextHeading1:Fe.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const Oye={LinkReference(e,t){return t.content.charCodeAt(0)==91?new lut(t):null},SetextHeading(){return new cut}},uut=[(e,t)=>oye(t)>=0,(e,t)=>rye(t)>=0,(e,t)=>iye(t)>=0,(e,t)=>yW(t,e,!0)>=0,(e,t)=>vW(t,e,!0)>=0,(e,t)=>$W(t,e,!0)>=0,(e,t)=>uye(t,e,!0)>=0],Out={text:"",end:0};class dut{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new sut,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=i[i.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=i[0].from,this.block=sQ.create(Fe.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new mut(r,n):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:t}=this;for(;;){for(let r=0;;){let i=t.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;r<t.markers.length&&(!i||t.markers[r].from<i.end);){let a=t.markers[r++];this.addNode(a.type,a.from,a.to)}if(!i)break;this.finishContext()}if(t.pos<t.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(t.basePos))return null;e:for(;;){for(let r of this.parser.blockParsers)if(r){let i=r(this,t);if(i!=!1){if(i==!0)return null;t.forward();continue e}}break}let n=new out(this.lineStart+t.pos,t.text.slice(t.pos));for(let r of this.parser.leafBlockParsers)if(r){let i=r(this,n);i&&n.parsers.push(i)}e:for(;this.nextLine()&&t.pos!=t.text.length;){if(t.indent<t.baseIndent+4){for(let r of this.parser.endLeafBlock)if(r(this,t,n))break e}for(let r of n.parsers)if(r.nextLine(this,t,n))return null;n.content+=`
|
|
906
906
|
`+t.scrub();for(let r of t.markers)n.marks.push(r)}return this.finishLeaf(n),null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}reuseFragment(t){if(!this.fragments.moveTo(this.absoluteLineStart+t,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let n=this.fragments.takeNodes(this);return n?(this.absoluteLineStart+=n,this.lineStart=bye(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(t=this.depth-1){return this.parser.nodeSet.types[this.stack[t].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(t){let n=Out;if(n.end=t,t>=this.to)n.text="";else if(n.text=this.lineChunkAt(t),n.end+=n.text.length,this.ranges.length>1){let r=this.absoluteLineStart,i=this.rangeI;for(;this.ranges[i].to<n.end;){i++;let a=this.ranges[i].from,o=this.lineChunkAt(a);n.end=a+o.length,n.text=n.text.slice(0,this.ranges[i-1].to-r)+o,r=n.end-n.text.length}}return n}readLine(){let{line:t}=this,{text:n,end:r}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=r,t.reset(n);t.depth<this.stack.length;t.depth++){let i=this.stack[t.depth],a=this.parser.skipContextMarkup[i.type];if(!a)throw new Error("Unhandled block context "+Fe[i.type]);if(!a(i,this,t))break;t.forward()}}lineChunkAt(t){let n=this.input.chunk(t),r;if(this.input.lineChunks)r=n==`
|
|
907
907
|
`?"":n;else{let i=n.indexOf(`
|
|
@@ -939,7 +939,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
939
939
|
`)?{...i,capture:o}:{...i,capture:fp(o,i.buffer,i.caret,"typing")}}return wN(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function AQ(e){return Ya(e)?{arm:e.arm,typingAt:null,value:""}:e}function rEt(e,t){let n=0;const r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;let i=e.length,a=t.length;for(;i>n&&a>n&&e[i-1]===t[a-1];)i--,a--;return{top:n,bottom:i,inserted:t.slice(n,a)}}function iEt(e,t,n,r,i){const a=rEt(t,n),o=Jf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:AQ(e),buffer:n,caret:r};else{const l=wN(e,n,r,a);l?s=l:Ya(e)&&a.inserted.includes(`
|
|
940
940
|
`)&&(s={capture:AQ(e),buffer:n,caret:r})}return{...s,capture:fp(s.capture,s.buffer,s.caret,i)}}function aEt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Jf(t);if(o===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const s=t.arm===null?o.start:t.arm.start,l=f_e(i,t.value),c=l+UP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Za,buffer:u,caret:s+c.length,payload:{index:i,key:h_e(a,e.draw),value:t.value,marker:l}}}const oEt=e=>Ya(e)&&e.value!=="";function sEt(e,t){const n=Jf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,token:null};const r=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Za,buffer:t.slice(0,n.start)+t.slice(n.end),caret:n.start,token:{span:{start:r,end:n.start},text:t.slice(r,n.start)}}}function lEt(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function cEt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Jf(e);return o===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=o.start?{kind:"passthrough",capture:{...e,typingAt:o.start+r.length},buffer:i,caret:a,payload:null}:n.start>=o.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:AQ(e),buffer:i,caret:a,payload:null}}function uEt(e){const{capture:t,buffer:n,caret:r,pasted:i}=e;if(t.arm===null)return null;if(t.typingAt!==null&&t.value!==""){if(i==="")return null;const u=wN(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=Kn(i);if(!a)return i===""?null:cEt(t,n,e.selection,i);const o=t.arm,s=f_e(e.index,a),l=s+UP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Za,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:h_e(e.taken,e.draw),value:a,marker:s}}}const d_e=e=>`${H4t(e)} chars`,f_e=(e,t)=>`[Credential #${e}, ${d_e(t)}]`;function OEt(e){Rl.lastIndex=0;const t=Rl.exec(e);return Rl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function dEt(e){Rl.lastIndex=0;const t=Rl.exec(e);if(Rl.lastIndex=0,t===null||t[0]!==e)return null;const n=Number.parseInt(t[1],10);return{index:n,label:`#${n}`,chars:Number.parseInt(t[2],10)}}function Qb(e,t){if(OEt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const CR=/\[credential ([A-Za-z_][A-Za-z0-9_]*) \((\d+) chars\) \u2014 available to bash and eval as \$([A-Za-z_][A-Za-z0-9_]*); its value cannot be read\]/y,zR=/\[credential NOT stored \u2014 [^\]\n]*\]/y,AR=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,fEt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&D6.test(t[1])?t[1]:""};function hEt(e,t){if(e.charCodeAt(t)!==91)return null;CR.lastIndex=t;const n=CR.exec(e);if(CR.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};zR.lastIndex=t;const r=zR.exec(e);if(zR.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};AR.lastIndex=t;const i=AR.exec(e);return AR.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:fEt(i[0])}:null}function WP(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=hEt(e,r);if(i===null){r++;continue}r>n&&t.push({kind:"text",text:e.slice(n,r)}),t.push(i),r+=i.text.length,n=r}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}function _J(e,t){const n=[];for(const r of t){const i=Qb(e,r);i!==null&&n.push({at:i.start,payload:r})}return n.sort((r,i)=>r.at-i.at).map(r=>r.payload)}function pEt(e,t=""){return e==="unconfirmed"?t?`[credential unconfirmed — it may be held as $${t}, so check list_variables before assuming it is missing]`:"[credential unconfirmed — the session may hold it, so check list_variables before assuming it is missing]":e==="unreachable"?"[credential NOT stored — the session could not be reached; try again]":e==="rejected-key"?"[credential NOT stored — the store rejected its name]":"[credential NOT stored — its value did not survive; ask the operator to paste it again]"}const mEt=e=>`[credential ${e.key} (${d_e(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function gEt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Qb(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of l_e(e,r))i.push({span:o,payload:null});let a=e;for(const{span:o,payload:s}of i.sort((l,c)=>c.span.start-l.span.start)){const l=s===null?"lost":n.get(s.index),c=s===null||l!==void 0?pEt(l??"lost",s?.key):mEt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const $Et=(e,t,n)=>h("ui.chat.credential_notice.cleared",{key:e,index:t,undoCap:n}),yEt=e=>h("ui.chat.credential_notice.clear_label",{index:e}),vEt=(e,t)=>h("ui.chat.credential_notice.chip_title",{index:e,chars:t}),bEt=(e,t,n)=>$Et(e,t,n),wEt=()=>h("ui.chat.credential_notice.undo"),xEt=e=>h("ui.notices.credentials.removed",{index:e}),SEt=e=>e.unredacted!==null?e.unredacted:e.armed?REt():e.cleared!==null?bEt(e.cleared.key,e.cleared.index,e.undoCap):null;function QEt(e){const{buffer:t,payload:n}=e,r=Qb(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===UP?r.end+1:r.end;return{cleared:!0,buffer:t.slice(0,r.start)+t.slice(i),caret:r.start,removed:t.slice(r.start,i)}}function _Et(e){const{buffer:t,cleared:n}=e;return n.removed===""||t!==n.buffer?null:{buffer:t.slice(0,n.caret)+n.removed+t.slice(n.caret),caret:n.caret+n.removed.length}}const kJ=e=>h("ui.notices.credentials.stored",{keys:Vs(e)});function PJ(e){return h("ui.notices.credentials.unstored",{count:e.length,keys:Vs([...e].sort())})}const kEt=()=>h("ui.chat.credential_notice.unconfirmed_alone"),PEt=e=>e===""?kEt():h("ui.chat.credential_notice.unconfirmed_labelled",{key:e}),TEt=()=>h("ui.chat.credential_notice.operator_move"),XEt=e=>`${e} ${TEt()}`;function TJ(e){return h("ui.notices.credentials.unconfirmed",{count:e.length,keys:Vs([...e].sort())})}const REt=()=>h("ui.chat.credential_notice.armed"),EEt=()=>h("ui.chat.credential_notice.typing"),qEt=()=>h("ui.chat.credential_notice.empty_span"),jEt=()=>h("ui.chat.credential_notice.escape_held"),CEt=()=>h("ui.chat.credential_notice.discarded"),zEt=()=>h("ui.chat.credential_notice.empty_span_draft"),AEt=e=>h("ui.chat.credential_notice.unredacted",{length:e});function UEt(e,t){const n=Jf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const XJ=(e,t)=>e&&e.over===t?e.chars:null,WEt=e=>{const t=Math.floor(4294967296/e)*e,n=new Uint32Array(1);for(;;)if(globalThis.crypto.getRandomValues(n),n[0]<t)return n[0]%e},NEt=16,YEt=16;function h_e(e=[],t=WEt){const n=new Set(e);for(let r=0;r<NEt;r++){const i=SJ+RJ(8,t);if(!n.has(i))return i}return SJ+RJ(YEt,t)}const RJ=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=xJ[t(xJ.length)];return n},GEt=8,IEt=256,ZEt=/^[/@$#]/,DEt=/^\w+:\/\//,VEt=/^[A-Za-z]+$/,MEt=/^\d+$/,LEt=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],FEt=3,BEt=20,HEt=/^[A-Za-z0-9_\-+/=.]+$/,KEt=new RegExp(`^[^${tu}@]+@[^${tu}@]+\\.[A-Za-z]{2,}$`),JEt=/^[\w.-]+(?:\/[\w.-]+)+$/,eqt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,tqt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,nqt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,rqt=/^[\w.-]+:\d{2,5}$/,iqt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,aqt=/^[a-z]+(?:_[a-z]+)+$/,oqt=/^[a-z]+(?:-[a-z]+)+$/,sqt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,lqt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,cqt=/\d{4,}/,EJ=e=>{const t=e.trim();return t.length<GEt||t.length>IEt||Ms.test(t)||ZEt.test(t)||DEt.test(t)||c8(t)!==null||KEt.test(t)||JEt.test(t)||eqt.test(t)||tqt.test(t)||nqt.test(t)||rqt.test(t)||iqt.test(t)||aqt.test(t)||oqt.test(t)||sqt.test(t)||lqt.test(t)&&cqt.test(t)||VEt.test(t)||MEt.test(t)?!1:LEt.filter(r=>r.test(t)).length>=FEt?!0:t.length>=BEt&&HEt.test(t)},p_e=X("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),m_e=X("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),uqt=({chars:e})=>(be(),d.jsx("span",{className:"shrink-0",children:h("ui.chat.credential_notice.chip_chars",{chars:e})})),g_e=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>d.jsxs("span",{className:X("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?m_e:p_e,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?d.jsx(lk,{"aria-hidden":"true",className:"size-3 shrink-0"}):d.jsx(u9e,{"aria-hidden":"true",className:"size-3 shrink-0"}),d.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&d.jsx(uqt,{chars:t}),i&&d.jsx("button",{type:"button","aria-label":a,onClick:i,className:"pointer-events-auto -mr-1 flex shrink-0 cursor-pointer items-center rounded-xs p-0.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-offset-1! active:bg-sunken",children:d.jsx(Zr,{"aria-hidden":"true",className:"size-3"})}),r&&d.jsx("span",{className:"sr-only",children:r})]}),Gy="#lo-credential/",Oqt=`${Gy}unstored`,qJ=`${Gy}unconfirmed`,dqt=/^\d+$/,$_e=e=>e.kind==="stored"?`${Gy}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${qJ}/${e.key}`:qJ:Oqt;function fqt(e){if(!e||!e.startsWith(Gy))return null;const t=e.slice(Gy.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return D6.test(a)?{kind:"unconfirmed",key:a}:null}const n=t.lastIndexOf("/");if(n===-1)return null;const r=t.slice(0,n),i=t.slice(n+1);return!D6.test(r)||!dqt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function jJ(e,t){const n=fqt(e);if(n===null)return null;const r=WP(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return $_e(i)!==e?null:n}const NP=()=>e=>{const t=n=>{if(!n.children)return;const r=[];let i=!1;for(const a of n.children){if(a.type!=="text"||typeof a.value!="string"){t(a),r.push(a);continue}const o=WP(a.value);if(o.length===1&&o[0].kind==="text"){r.push(a);continue}i=!0;for(const s of o){if(s.kind==="text"){r.push({type:"text",value:s.text});continue}r.push({type:"link",url:$_e(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},hqt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?PEt(e.key):h("ui.chat.page_chrome.credential_not_stored"),pqt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?XEt(t):t,mqt=({citation:e,title:t})=>(be(),d.jsx(g_e,{tone:e.kind==="stored"?"live":"warning",label:hqt(e),chars:e.kind==="stored"?e.chars:null,title:pqt(e,t),className:"align-middle"})),gqt=(e,t)=>typeof t=="string"?jJ(e,t):t==null?jJ(e,""):null,$qt=e=>({href:t,title:n,children:r})=>{const i=gqt(t,r);if(i===null){const a=e;return d.jsx(a,{href:t,title:n,children:r})}return d.jsx(mqt,{citation:i,title:n})},y_e=e=>kit(e)?"artifact":e.startsWith("data:")?"data":e.startsWith("blob:")||vpe(e)?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",xN=e=>{const t=y_e(e);return t==="other"?"path":t},UR={id:"open-file",get label(){return h("ui.common.file_actions.open_file")}},yqt={id:"show-in-canvas",get label(){return h("ui.common.file_actions.show_in_canvas")}},vqt={id:"save-as",get label(){return h("ui.chat.image_actions.save_as")}},WR={id:"open-folder",get label(){return h("ui.common.file_actions.open_folder")}},NR={id:"copy-file-path",get label(){return h("ui.common.file_actions.copy_file_path")}},Wh={id:"copy-image",get label(){return h("ui.chat.image_actions.copy_image")}},bqt={id:"copy-image-url",get label(){return h("ui.chat.image_actions.copy_image_url")}},wqt={id:"open-in-browser",get label(){return h("ui.chat.image_actions.open_in_browser")}};function v_e(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[yqt]:[],...a?[{id:"expand-image",get label(){return h("ui.chat.image_actions.expand_image")}}]:[]];switch(e){case"artifact":return[...o,...i?[UR,WR,NR]:[],vqt,...r==="video"||r==="audio"?[]:[Wh]];case"path":return[...o,UR,WR,NR,...r==="video"||r==="audio"?[]:[Wh]];case"data":return[...o,Wh];case"blob":return i?[...o,UR,WR,NR,Wh]:[Wh];case"http":return[...xqt(n)?[Wh]:[],bqt,wqt];case"other":return[]}}const b_e=(e,t)=>v_e(e,t).length>0;function xqt(e){try{const t=new URL(e),n=t.hostname==="localhost"||t.hostname==="127.0.0.1";return t.protocol==="http:"&&n&&(t.port==="1111"||t.port==="8080")}catch{return!1}}const SN=e=>e.startsWith("file://")?e.slice(7):e;function w_e(e){const t=e.indexOf(",");if(t===-1)throw new Error("Malformed data URL");const n=e.slice(5,t),r=e.slice(t+1),i=n.split(";")[0]||"application/octet-stream";if(n.endsWith(";base64")){const s=atob(r),l=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)l[c]=s.charCodeAt(c);return new Blob([l],{type:i})}const a=decodeURIComponent(r),o=new Uint8Array(a.length);for(let s=0;s<a.length;s+=1)o[s]=a.charCodeAt(s);return new Blob([o],{type:i})}async function CJ(e,t,n){if(e==="data")return w_e(t);if(e==="blob"){const o=FOe(n??t);if(o===null)throw new Error("These image bytes are not available in this window");return o}if(e==="http"){const o=await fetch(n??t);if(!o.ok)throw new Error(`The image server answered ${o.status}`);return o.blob()}const r=window.api?.readFileBytes;if(typeof r!="function")throw new Error("This window cannot read local files");const i=SN(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Ek(i)})}const Sqt=e=>e.trim().toLowerCase()!=="image/png";async function Qqt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!Sqt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await _qt(t);if(n.naturalWidth===0||n.naturalHeight===0)throw new Error("This image could not be decoded for the clipboard");const r=document.createElement("canvas");r.width=n.naturalWidth,r.height=n.naturalHeight;const i=r.getContext("2d");if(i===null)throw new Error("This window cannot re-encode the image for the clipboard");i.drawImage(n,0,0);const a=await new Promise(o=>{r.toBlob(o,"image/png")});if(a===null)throw new Error("This image could not be re-encoded for the clipboard");return a}finally{URL.revokeObjectURL(t)}}function _qt(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error("This image could not be decoded for the clipboard")),r.src=e})}const kqt=6e4;function Pqt(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),kqt)}const Tqt=32*1024*1024;function J0n(e,t){if(!e.remote)return null;const n=e.origin_device??null;return{fileId:e.id,sessionId:t,deviceName:n?.name||n?.id||"",readKind:e.remote_read?.kind??null,unreadable:e.remote_unreadable??(e.remote_read?null:"outside_session_files"),ownerPath:e.ref.type==="path"?e.ref.path:null,sizeBytes:e.size_bytes}}function YP(e){const t=e.deviceName;switch(e.unreadable){case"missing":return h("ui.canvas.files.remoteReason.missing",{device:t});case"too_large":return h("ui.canvas.files.remoteReason.tooLarge",{device:t});case"sensitive":return h("ui.canvas.files.remoteReason.sensitive",{device:t});case"not_referenced":return h("ui.canvas.files.remoteReason.notReferenced",{device:t});default:return h("ui.canvas.files.remoteReason.workspace",{device:t})}}function Xqt(e){return e.sizeBytes===null||e.sizeBytes<=Tqt}function Rqt(e){return h("ui.canvas.files.remoteTooLargeToOpen",{device:e.deviceName})}function e$n(e){return e.unreadable?YP(e):null}function t$n(e,t){return t?void 0:e}function x_e(e){return e?h("ui.canvas.files.remoteUnreachable",{device:e}):h("ui.canvas.files.remoteUnreachableUnnamed")}function n$n(e,{mediaKind:t,canShowInCanvas:n,canExpand:r,landedPath:i}){const a=e.deviceName,o=e.ownerPath,s=o?[{id:"copy-owner-path",label:h("ui.canvas.files.remoteCopyOwnerPath",{device:a}),disabledReason:null,target:o}]:[];if(e.unreadable){const u=YP(e);return[...n?[{id:"show-in-canvas",label:h("ui.common.file_actions.show_in_canvas"),disabledReason:u,target:null}]:[],{id:"download",label:h("ui.canvas.files.remoteDownload"),disabledReason:u,target:null},...s,{id:"save-as",label:h("ui.chat.image_actions.save_as"),disabledReason:u,target:null}]}const l=Xqt(e),c=[];return n&&c.push({id:"show-in-canvas",label:h("ui.common.file_actions.show_in_canvas"),disabledReason:l?null:Rqt(e),target:null}),r&&t==="image"&&c.push({id:"expand-image",label:h("ui.chat.image_actions.expand_image"),disabledReason:null,target:null}),i?c.push({id:"open-file",label:h("ui.common.file_actions.open_file"),disabledReason:null,target:i},{id:"open-folder",label:h("ui.common.file_actions.open_folder"),disabledReason:null,target:i},{id:"copy-file-path",label:h("ui.common.file_actions.copy_file_path"),disabledReason:null,target:i}):c.push({id:"download",label:h("ui.canvas.files.remoteDownload"),disabledReason:null,target:null},...s),l&&(c.push({id:"save-as",label:h("ui.chat.image_actions.save_as"),disabledReason:null,target:null}),t==="image"&&c.push({id:"copy-image",label:h("ui.chat.image_actions.copy_image"),disabledReason:null,target:null})),c}function r$n(e){if(e.unsupported_reason==="peer_update_required"){const t=e.device_name||null,n=t??h("ui.canvas.files.remoteDeviceFallback"),r=h("ui.canvas.files.remotePeerUpdate",{device:n});return t?`${r}
|
|
941
941
|
${h("ui.canvas.files.remotePeerUpdateHow",{device:n})}`:r}return Eqt}const Eqt="Remote files cannot be opened on this device.",qqt={"expand-image":d.jsx(QOe,{"aria-hidden":"true"}),"open-file":d.jsx(Nv,{"aria-hidden":"true"}),"show-in-canvas":d.jsx(SOe,{"aria-hidden":"true"}),"save-as":d.jsx(dk,{"aria-hidden":"true"}),"open-folder":d.jsx(Vp,{"aria-hidden":"true"}),"copy-file-path":d.jsx(DA,{"aria-hidden":"true"}),"copy-image":d.jsx(GO,{"aria-hidden":"true"}),"copy-image-url":d.jsx(h9e,{"aria-hidden":"true"}),"open-in-browser":d.jsx(Dp,{"aria-hidden":"true"})},zJ=(e,t,n)=>n instanceof qk?t:n instanceof Bp?x_e(""):e;function jqt({file:e,src:t,resolvePath:n,missing:r,onShowInCanvas:i,mediaKind:a,onExpand:o,saveName:s}){return v_e(xN(e),{canShowInCanvas:!!i,source:t??e,mediaKind:a,artifactPathActions:!!n,canExpand:!!o}).filter(l=>(l.id!=="save-as"||!!s)&&(!r||l.id==="copy-file-path"))}const S_e=({file:e,src:t,label:n,open:r,onOpenChange:i,onCloseAutoFocus:a,triggerTabIndex:o,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:f,resolveBytes:p,tooltip:m=h("ui.chat.image_actions.actions"),"aria-label":g})=>{be();const y=xN(e),v=jqt({file:e,src:t,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:f});if(v.length===0)return null;const b=async(_,k,R)=>{try{await navigator.clipboard.writeText(_),Ls(k)}catch(E){console.error(`${R}: `,E),Jn(R)}},x=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const _=p?await p():await CJ(y,e,t),k=await Qqt(_);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),Ls(h("ui.notices.files.image_copied"))}catch(_){console.error("Failed to copy image: ",_),Jn(zJ(h("ui.notices.files.image_copy_failed"),h("ui.notices.files.image_copy_failed_gone"),_))}},Q=async()=>{try{const _=p?await p():await CJ(y,e,t);Pqt(_,f??"download")}catch(_){console.error("Failed to save file: ",_),Jn(zJ(h("ui.notices.files.save_failed"),h("ui.notices.files.save_failed_gone"),_))}},w=async _=>{let k=SN(e);if(s&&["open-file","open-folder","copy-file-path"].includes(_.id))try{k=await s()}catch{Jn(h("ui.canvas.files.prepareError"));return}switch(_.id){case"expand-image":O?.();return;case"open-file":Ou(k);return;case"open-folder":CP(k);return;case"show-in-canvas":c?.();return;case"copy-file-path":b(k,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":x();return;case"save-as":Q();return;case"copy-image-url":b(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":yN(t??e);return}},S=g??(n!=null?h("ui.common.actions.actions_for_name",{name:n}):h("ui.chat.image_actions.actions"));return d.jsxs(ck,{open:r,onOpenChange:i,children:[d.jsx($t,{content:m,children:d.jsx(uk,{asChild:!0,children:d.jsx(ve,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":S,tabIndex:o,onClick:_=>_.stopPropagation(),children:d.jsx(gS,{"aria-hidden":"true"})})})}),d.jsxs(Ok,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:_=>_.stopPropagation(),children:[s&&d.jsx("div",{role:"note",className:X("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:h("ui.canvas.files.pathCopyNote")}),v.map(_=>d.jsxs(Fo,{onSelect:()=>w(_),children:[qqt[_.id],d.jsx("span",{children:_.label})]},_.id))]})]})},Cqt=({src:e,alt:t,title:n,className:r})=>{const i=xb(),a=e??"",o=y_e(a);if(o==="other")return d.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=b_e(o,{canShowInCanvas:s,source:a});return d.jsxs("span",{className:X("group/mdimg relative inline-block max-w-full"),children:[d.jsx("img",{src:e,alt:t,title:n,className:r}),l&&d.jsx("span",{"data-markdown-image":"",className:X("pointer-events-none absolute top-1 right-1 z-[2] opacity-0","transition-opacity duration-fast ease-out-quart","group-hover/mdimg:pointer-events-auto group-hover/mdimg:opacity-100","group-focus-within/mdimg:pointer-events-auto group-focus-within/mdimg:opacity-100","has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100"),children:d.jsx(S_e,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||Ou(SN(a))})}:void 0})})]})};function zqt(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:s,mathText:o,mathTextData:s}};function e(l){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function t(){this.buffer()}function n(){const l=this.resume(),c=this.stack[this.stack.length-1];c.type,c.meta=l}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c;const O=u.data.hChildren[0];O.type,O.tagName,O.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function a(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function o(l){const c=this.resume(),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function s(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}const Aqt={tokenize:Uqt,concrete:!0,name:"mathFlow"},AJ={tokenize:Wqt,partial:!0};function Uqt(e,t,n){const r=this,i=r.events[r.events.length-1],a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return s;function s(b){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(b)}function l(b){return b===36?(e.consume(b),o++,l):o<2?n(b):(e.exit("mathFlowFenceSequence"),un(e,c,"whitespace")(b))}function c(b){return b===null||xt(b)?O(b):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(b))}function u(b){return b===null||xt(b)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(b)):b===36?n(b):(e.consume(b),u)}function O(b){return e.exit("mathFlowFence"),r.interrupt?t(b):e.attempt(AJ,f,y)(b)}function f(b){return e.attempt({tokenize:v,partial:!0},y,p)(b)}function p(b){return(a?un(e,m,"linePrefix",a+1):m)(b)}function m(b){return b===null?y(b):xt(b)?e.attempt(AJ,f,y)(b):(e.enter("mathFlowValue"),g(b))}function g(b){return b===null||xt(b)?(e.exit("mathFlowValue"),m(b)):(e.consume(b),g)}function y(b){return e.exit("mathFlow"),t(b)}function v(b,x,Q){let w=0;return un(b,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(R){return b.enter("mathFlowFence"),b.enter("mathFlowFenceSequence"),_(R)}function _(R){return R===36?(w++,b.consume(R),_):w<o?Q(R):(b.exit("mathFlowFenceSequence"),un(b,k,"whitespace")(R))}function k(R){return R===null||xt(R)?(b.exit("mathFlowFence"),x(R)):Q(R)}}}function Wqt(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Nqt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:Yqt,previous:Gqt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(g){return i.enter("mathText"),i.enter("mathTextSequence"),O(g)}function O(g){return g===36?(i.consume(g),s++,O):s<2&&!n?o(g):(i.exit("mathTextSequence"),f(g))}function f(g){return g===null?o(g):g===36?(c=i.enter("mathTextSequence"),l=0,m(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),f):xt(g)?(i.enter("lineEnding"),i.consume(g),i.exit("lineEnding"),f):(i.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===36||xt(g)?(i.exit("mathTextData"),f(g)):(i.consume(g),p)}function m(g){return g===36?(i.consume(g),l++,m):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(g)):(c.type="mathTextData",p(g))}}}function Yqt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Gqt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Iqt(e){return{flow:{36:Aqt},text:{36:Nqt()}}}function Q_e(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}const El=92,Zqt=40,Dqt=41,__e=91,QN=93,M6=32,xO=e=>e!==null&&e<-2,js=e=>e===M6||e===-2||e===-1,k_e=e=>e===94||e===95||e===123||e===125,P_e=e=>e!==null&&(e>=65&&e<=90||e>=97&&e<=122||e===123||e===125),YR=new WeakMap,UJ=new WeakMap,T_e=e=>Object.prototype.hasOwnProperty.call(e,"interrupt")?Object.getPrototypeOf(e):e,L6="mathTextDisplay";function Vqt(e,t,n){let r=Dqt,i=!1,a,o=!1,s=!1,l=0,c;const u=this,O={tokenize:_,partial:!0};return f;function f(k){return k!==El?n(k):(l=u.now().offset,c=T_e(u),a=e.enter("mathText"),e.enter("mathTextSequence"),e.consume(k),p)}function p(k){if(k===__e)r=QN,i=!0,a.type=L6;else if(k!==Zqt)return n(k);const R=YR.get(c)?.get(r);return R!==void 0&&l>R?n(k):(e.consume(k),e.exit("mathTextSequence"),m)}function m(k){return k===null?x(k):k===El?e.check(O,w,g)(k):k===M6?(e.enter("space"),e.consume(k),e.exit("space"),m):xO(k)?(e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),m):g(k)}function g(k){return e.enter("mathTextData"),k===El?v(k):y(k)}function y(k){return k===null||k===M6||xO(k)?(e.exit("mathTextData"),m(k)):k===El?e.check(O,Q,v)(k):(o=!0,k_e(k)&&(s=!0),e.consume(k),y)}function v(k){return o=!0,e.consume(k),b}function b(k){return k===null||xO(k)||js(k)?y(k):(P_e(k)&&(s=!0),e.consume(k),y)}function x(k){let R=YR.get(c);R||(R=new Map,YR.set(c,R));const E=R.get(r);return(E===void 0||l<E)&&R.set(r,l),n(k)}function Q(k){return e.exit("mathTextData"),w(k)}function w(k){return!o||i&&!s?n(k):(e.enter("mathTextSequence"),e.consume(k),S)}function S(k){return e.consume(k),e.exit("mathTextSequence"),e.exit(a.type),t}function _(k,R,E){return T=>(k.enter("mathTextSequence"),k.consume(T),q=>q!==r?E(q):(k.consume(q),k.exit("mathTextSequence"),R))}}const Mqt={name:"mathTextBackslash",tokenize:Vqt,resolve:Q_e},Lqt={partial:!0,tokenize(e,t,n){return r=>r===null?t(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),i=>this.parser.lazy[this.now().line]?n(i):t(i))}},WJ={partial:!0,tokenize(e,t,n){return a=>(e.enter("mathFlowFenceSequence"),e.consume(a),o=>o!==QN?n(o):(e.consume(o),e.exit("mathFlowFenceSequence"),r));function r(a){return js(a)?(e.enter("whitespace"),i(a)):a===null||xO(a)?t(a):n(a)}function i(a){return js(a)?(e.consume(a),i):(e.exit("whitespace"),a===null||xO(a)?t(a):n(a))}}};function Fqt(e,t,n){const r=this.events[this.events.length-1],i=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0;let a=!1,o=!1,s=0,l=!1;const c=this,u=T_e(this);let O=0;return f;function f(C){if(C!==El)return n(C);O=c.now().offset;const U=UJ.get(u);return U&&O>U[0]&&O<U[1]?n(C):(e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),e.consume(C),p)}function p(C){return C!==__e?n(C):(e.consume(C),e.exit("mathFlowFenceSequence"),m)}function m(C){return js(C)?(e.enter("whitespace"),g(C)):y(C)}function g(C){return js(C)?(e.consume(C),g):(e.exit("whitespace"),y(C))}function y(C){return C===null?b(C):(e.exit("mathFlowFence"),o=!0,w(C))}function v(C){return o?e.attempt(Lqt,x,b)(C):b(C)}function b(C){return l||UJ.set(u,[O,c.now().offset]),n(C)}function x(C){return o=!1,s=i,s>0&&js(C)?(e.enter("linePrefix"),Q(C)):w(C)}function Q(C){return s>0&&js(C)?(s--,e.consume(C),Q):(e.exit("linePrefix"),w(C))}function w(C){return C===null?b(C):xO(C)?v(C):C===El?e.check(WJ,T,S)(C):S(C)}function S(C){return e.enter("mathFlowValue"),C===El?k(C):_(C)}function _(C){return C===null||xO(C)?(e.exit("mathFlowValue"),w(C)):C===El?e.check(WJ,E,k)(C):(js(C)||(o=!0),k_e(C)&&(a=!0),e.consume(C),_)}function k(C){return o=!0,e.consume(C),R}function R(C){return C===null||xO(C)||js(C)?_(C):C===QN?(l=!0,n(C)):(P_e(C)&&(a=!0),e.consume(C),_)}function E(C){return e.exit("mathFlowValue"),T(C)}function T(C){return a?(e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),e.consume(C),q):(l=!0,n(C))}function q(C){return e.consume(C),e.exit("mathFlowFenceSequence"),A}function A(C){return js(C)?(e.enter("whitespace"),G(C)):I(C)}function G(C){return js(C)?(e.consume(C),G):(e.exit("whitespace"),I(C))}function I(C){return e.exit("mathFlowFence"),e.exit("mathFlow"),t(C)}}const Bqt={name:"mathFlowBracket",tokenize:Fqt,concrete:!0},Hqt={flow:{[El]:[Bqt]},text:{[El]:[Mqt]}},Kqt={enter:{[L6](e){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-display"]},hChildren:[]}},e),this.buffer()}},exit:{[L6](e){const t=this.resume(),n=this.stack[this.stack.length-1];this.exit(e),n.value=t,n.data.hChildren.push({type:"text",value:t})}}},hp=36,NJ=e=>e!==null&&e<-2,YJ=e=>e===null||e===32||e<0,GJ=e=>e!==null&&e>=48&&e<=57,IJ=92,Jqt=e=>e===94||e===95||e===123||e===125,ZJ=e=>e!==null&&(e>=65&&e<=90||e>=97&&e<=122),ejt=e=>e===44||e===46||e===59||e===58||e===33||e===63,tjt=96,X_e=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:Q_e,previous:njt,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c=!1,u=!1,O=!1,f=0,p=0,m="letters",g=!1,y=!1,v=!1,b,x;return Q;function Q(T){return r.enter("mathText"),r.enter("mathTextSequence"),w(T)}function w(T){return T===hp?(r.consume(T),s++,w):s<2&&!t||s===1&&YJ(T)?a(T):(c=s===1&&GJ(T),r.exit("mathTextSequence"),S(T))}function S(T){return T===null?a(T):T===hp?(x=r.enter("mathTextSequence"),b=0,l=o.previous,E(T)):T===32?(r.enter("space"),r.consume(T),r.exit("space"),S):NJ(T)?(r.enter("lineEnding"),r.consume(T),r.exit("lineEnding"),S):(r.enter("mathTextData"),p=0,m="letters",R(T))}function _(){const T=m!=="other"&&p>=2&&f===0;T&&g&&(y=!0),g=T}function k(T,q){T===tjt&&(v=!0),!q&&T===123&&f++,!q&&T===125&&f>0&&f--,m==="letters"&&!q&&ZJ(T)?p++:m==="letters"&&p>=2&&ejt(T)?m="punct":m="other"}function R(T){return T===null||T===32||T===hp||NJ(T)?(O=!1,_(),r.exit("mathTextData"),S(T)):(k(T,O||T===IJ),O?(u=!0,O=!1):T===IJ?O=!0:Jqt(T)&&(u=!0),r.consume(T),R)}function E(T){return T===hp?(r.consume(T),b++,E):b===s?s===1&&(YJ(l)||GJ(T))||s===1&&c&&!u||s===1&&c&&(ZJ(T)||T===95||v||y)?a(T):(r.exit("mathTextSequence"),r.exit("mathText"),i(T)):(x.type="mathTextData",R(T))}}};function njt(e){return e!==hp||this.events[this.events.length-1][1].type==="characterEscape"}const rjt=Iqt().flow,ijt=X_e();function GP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?ijt:X_e(e);n.push({flow:rjt,text:{[hp]:i}}),n.push(Hqt),r.push(zqt()),r.push(Kqt)}const ajt=/\$(?!\d)(.+?)\$/,ojt=/\$\$([\s\S]+?)\$\$/,sjt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,ljt=/\\[a-zA-Z]+(\{[^}]*\})?/,cjt=/\\\([\s\S]+?\\\)/,ujt=/\\\[[\s\S]+?\\\]/,Ojt=/^ {0,3}(?:`{3,}|~{3,})[ \t]*math[ \t]*$/m,djt=/(?<![\\$])\$(?=\d)([^$]*)\$(?![\dA-Za-z_])/g,fjt=/\\[^ \r\n$]|[\^_{}]/,hjt=/[^ \t\r\n]$/,pjt=/^[A-Za-z]{2,}[,.;:!?]?$/,mjt=e=>{let t=0,n=!1,r=!1,i="";const a=()=>{if(i==="")return!1;const o=t===0&&pjt.test(i),s=o&&r;return r=o,i="",s};for(const o of e){if(o===" "||o===`
|
|
942
|
-
`||o==="\r"){if(n=!1,a())return!0;continue}i+=n||o==="\\"?"\0":o,!n&&o==="{"&&t++,!n&&o==="}"&&t>0&&t--,n=!n&&o==="\\"}return a()},gjt=e=>{const t=new RegExp(djt.source,"g");let n=t.exec(e);for(;n!==null;){const r=n[1];if(hjt.test(r)&&fjt.test(r)&&!r.includes("`")&&!mjt(r))return!0;t.lastIndex=n.index+1,n=t.exec(e)}return!1},DJ=e=>ajt.test(e)||ojt.test(e)||cjt.test(e)||ujt.test(e)||Ojt.test(e)||gjt(e)||sjt.test(e)?!0:ljt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),$jt=e=>{const t=WP(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},yjt=e=>WP(e).filter(t=>t.kind!=="text").length,vjt=e=>{if(!DJ(e))return!1;const t=$jt(e);return t===null?!0:DJ(t)||t.includes("$")?!1:yjt(e)<2},R_e=Object.freeze(["canvas","surface","ink","inkMuted","accent","borderControl"]),E_e=Object.freeze(UA.filter(e=>!["overlayShadow","scrim"].includes(e))),q_e=65536,j_e=/^#[0-9a-fA-F]{6}$/,bjt=(e,t)=>Object.hasOwn(e,t),VJ=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),wa=e=>{throw new Error(e)},wjt={canvas:["surface","elevated","sunken","messageSurface","mediaSurface","rowHover","rowSelected","accentWash","accentAltWash","successWash","warningWash","dangerWash","infoWash"],surface:["elevated","rowHover","rowSelected"],ink:["inkMuted","inkDim","inkDisabled"],inkMuted:["inkDim"],accent:["accentHover","accentActive","accentWash","chartBarHover"],borderControl:["hairline","hairlineStrong"]},Iy=(e,t)=>{const n={...e};for(const r of R_e){const i=$qe(t.seeds?.[r]);if(!i)continue;const a=g2(e[r]),o=g2(i);n[r]=i;for(const s of wjt[r]){const l=g2(e[s]);n[s]=yqe({l:o.l+l.l-a.l,c:a.c>.01?o.c*l.c/a.c:l.c,h:o.h+l.h-a.h})}}n.accent.toUpperCase()!==e.accent.toUpperCase()&&(n.onAccent=vqe(n.accent,[e.onAccent,n.ink,n.canvas,"#000000","#FFFFFF"]));for(const r of E_e)j_e.test(t.overrides?.[r]??"")&&(n[r]=t.overrides[r]);for(const r of["overlayShadow","scrim"]){const i=t.overrides?.[r];typeof i=="string"&&/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(i)&&(n[r]=e[r].replace(/\/\s*[\d.]+\)/,`/ ${i})`))}return n},_N=(e,t)=>mqe(e,t),i$n=(e,t)=>{const n=Iy(e,t),r=xqe(n,t.base,e,{pinned:Object.keys(t.overrides??{}),maxEvaluations:320,lightnessOnly:!0}).palette;if(!r||Object.keys(t.overrides??{}).some(s=>r[s]!==n[s]))return null;const a={...t.overrides};for(const s of E_e)r[s]!==n[s]&&(a[s]=r[s]);const o={...t,overrides:a};return _N(Iy(e,o),t.base).length?null:o},C_e=(e,t,{id:n="custom-import",now:r=Date.now()}={})=>{(typeof e!="string"||new TextEncoder().encode(e).length>q_e)&&wa("import_size");let i;try{i=JSON.parse(e)}catch{wa("import_invalid_json")}VJ(i)||wa("import_format");const a=new Set(["format","version","name","base","seeds","overrides","id","updatedAt"]);Object.keys(i).some(s=>!a.has(s))&&wa("import_unsafe"),i.format!=="local-operator-theme"&&wa("import_format"),i.version!==1&&wa("import_version"),(typeof i.base!="string"||!t(i.base))&&wa("import_base"),(typeof i.name!="string"||!i.name.trim()||i.name.trim().length>60)&&wa("import_name");const o={};for(const s of["seeds","overrides"]){(!bjt(i,s)||!VJ(i[s]))&&wa("import_roles");const l={};for(const[c,u]of Object.entries(i[s]))(!(s==="seeds"?R_e:UA).includes(c)||typeof u!="string")&&wa("import_roles"),["overlayShadow","scrim"].includes(c)?(/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(u)||wa("import_roles"),l[c]=u):(j_e.test(u)||wa("import_roles"),l[c]=u.toUpperCase());o[s]=l}return{format:"local-operator-theme",version:1,id:n,name:i.name.trim(),base:i.base,...o,updatedAt:r}},xjt=(e,t)=>{if(e==null)return[];(typeof e!="string"||e.length>q_e*lS)&&wa("load_error");let n;try{n=JSON.parse(e)}catch{wa("load_error")}const r=Array.isArray(n)?n:n?.version===1?n.themes:null;Array.isArray(r)||wa("load_error");const i=[],a=new Set;for(const o of r.slice(0,lS))try{const s=gqe(o,{isThemeName:t,isRole:c=>UA.includes(c)});if(!s||a.has(s.id))continue;const l=C_e(JSON.stringify(o),t,{id:s.id,now:s.updatedAt});i.push(l),a.add(l.id)}catch{}return i},Sjt=e=>JSON.stringify({format:"local-operator-theme",version:1,name:e.name,base:e.base,seeds:e.seeds,overrides:e.overrides},null,2),a$n=(e,t)=>{const n=new Set(t.map(r=>r.name));if(!n.has(e))return e;for(let r=2;r<=lS+1;r++){const i=`${e.slice(0,54)} (${r})`;if(!n.has(i))return i}return e},o$n=(e,t)=>{const n=bqe({composed:!0,capturePairs:!0});return wqe(n,{id:t,palette:e}),{findings:n.log,readings:n.readings}};let NO={themes:[],error:!1,loading:!1};const F6=new Set,z_e=()=>{for(const e of F6)e()},MJ=()=>NO,Qjt=e=>(F6.add(e),()=>{F6.delete(e)}),LJ=()=>{try{NO={themes:xjt(localStorage.getItem(wA),fue).filter(t=>{const n=$A(t.base)?.palette;return n&&_N(Iy(n,t),t.base).length===0}),error:!1,loading:!1}}catch{NO={themes:[],error:!0,loading:!1}}z_e()},kN=()=>$.useSyncExternalStore(Qjt,MJ,MJ),_jt=e=>NO.themes.find(t=>t.id===e),A_e=e=>{localStorage.setItem(wA,JSON.stringify({version:1,themes:e})),NO={themes:e,error:!1,loading:!1},z_e()},s$n=e=>{const t=Sqe(e.id);if(!t)throw new Error("invalid custom theme id");const n=C_e(Sjt(e),fue,{id:t,now:e.updatedAt}),r=$A(n.base)?.palette;if(!r||_N(Iy(r,n),n.base).length)throw new Error("contrast");if(!_jt(n.id)&&NO.themes.length>=lS)throw new Error("limit");A_e([n,...NO.themes.filter(i=>i.id!==n.id)])},l$n=e=>A_e(NO.themes.filter(t=>t.id!==e));typeof window<"u"&&(LJ(),window.addEventListener("storage",e=>{(e.key===wA||e.key===null)&&LJ()}));const kjt=()=>{const e=It(i=>i.themeName),t=It(i=>i.contrast),n=It(i=>i.accent),r=It(i=>i.customThemeId);return $.useMemo(()=>({themeName:e,contrast:t,accent:n,customThemeId:r}),[e,t,n,r])},Pjt=e=>{const t=e?$A(e.base)?.palette:void 0;return t&&e?Iy(t,e):void 0},Tjt=()=>{const e=kjt(),t=kN();return $.useMemo(()=>{const n=t.themes.find(a=>a.id===e.customThemeId),r=Pjt(n),i=n?.base;return{appearance:e,savedPalette:r,savedBase:i,resolved:Qqe(e,r,i)}},[e,t])},IP=()=>Tjt().resolved,c$n=()=>IP().palette.mode==="dark",tn="var(--color-ink)",Oc="var(--color-ink-muted)",ml="var(--color-surface)",Zu="var(--color-elevated)",dc="var(--color-sunken)",ea="var(--color-hairline)",Du="var(--color-control)",Nh="var(--color-accent)",K0="var(--color-accent-wash)",Xjt="var(--color-accent-alt-wash)",Rjt="var(--color-on-accent)",Ejt="var(--color-info)",U_e="var(--color-info-wash)",qjt="var(--color-success)",W_e="var(--color-success-wash)",jjt="var(--color-warning)",B6="var(--color-warning-wash)",Cjt="var(--color-warning-border)",GR="var(--color-danger)",H6="var(--color-danger-wash)",FJ=[K0,Xjt,U_e,W_e,B6,H6],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),zjt=()=>{const e={primaryColor:Vu("--color-accent"),secondaryColor:Vu("--color-success"),tertiaryColor:Vu("--color-info"),mainBkg:Vu("--color-elevated"),clusterBkg:Vu("--color-sunken"),clusterBorder:Vu("--color-hairline"),edgeLabelBackground:Vu("--color-surface"),quadrant1Fill:Vu("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:ml,primaryTextColor:tn,primaryBorderColor:Du,secondaryTextColor:tn,secondaryBorderColor:ea,tertiaryTextColor:tn,tertiaryBorderColor:ea,lineColor:Oc,arrowheadColor:Oc,textColor:tn,secondBkg:dc,border1:Du,border2:ea,labelColor:tn,nodeBkg:Zu,nodeBorder:Du,nodeTextColor:tn,defaultLinkColor:Oc,titleColor:tn,noteBkgColor:B6,noteBorderColor:Cjt,noteTextColor:tn,actorBkg:Zu,actorBorder:Du,actorTextColor:tn,actorLineColor:ea,signalColor:Oc,signalTextColor:tn,labelBoxBkgColor:Zu,labelBoxBorderColor:ea,labelTextColor:tn,loopTextColor:tn,activationBkgColor:K0,activationBorderColor:Nh,sequenceNumberColor:ml,sectionBkgColor:dc,sectionBkgColor2:ml,altSectionBkgColor:dc,excludeBkgColor:dc,taskBkgColor:K0,taskBorderColor:Du,taskTextColor:tn,taskTextLightColor:tn,taskTextDarkColor:tn,taskTextOutsideColor:tn,taskTextClickableColor:Nh,activeTaskBkgColor:K0,activeTaskBorderColor:Nh,gridColor:ea,doneTaskBkgColor:dc,doneTaskBorderColor:ea,critBkgColor:H6,critBorderColor:GR,todayLineColor:Nh,transitionColor:Oc,transitionLabelColor:tn,stateLabelColor:tn,stateBkg:Zu,labelBackgroundColor:ml,compositeBackground:dc,altBackground:dc,compositeTitleBackground:Zu,compositeBorder:ea,innerEndBackground:tn,specialStateColor:tn,classText:tn,attributeBackgroundColorOdd:ml,attributeBackgroundColorEven:dc,rowOdd:ml,rowEven:dc,errorBkgColor:H6,errorTextColor:GR,pieTitleTextColor:tn,pieSectionTextColor:tn,pieLegendTextColor:tn,pieStrokeColor:ml,pieOuterStrokeColor:ea,requirementBackground:Zu,requirementBorderColor:Du,requirementTextColor:tn,relationColor:Oc,relationLabelBackground:ml,relationLabelColor:tn,branchLabelColor:Rjt,commitLabelColor:tn,commitLabelBackground:ml,tagLabelColor:tn,tagLabelBackground:K0,tagLabelBorder:Du,quadrant2Fill:U_e,quadrant3Fill:W_e,quadrant4Fill:B6,quadrant2TextFill:tn,quadrant3TextFill:tn,quadrant4TextFill:tn,quadrantPointFill:Nh,archEdgeColor:Oc,archEdgeArrowColor:Oc,archGroupBorderColor:ea,scaleLabelColor:tn,packet:{startByteColor:tn,endByteColor:tn,labelColor:tn,titleColor:tn,blockStrokeColor:Du,blockFillColor:Zu},radar:{axisColor:Oc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:ea,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:ml,titleColor:tn,xAxisTitleColor:tn,xAxisLabelColor:tn,xAxisTickColor:ea,xAxisLineColor:ea,yAxisTitleColor:tn,yAxisLabelColor:tn,yAxisTickColor:ea,yAxisLineColor:ea,plotColorPalette:[Nh,Ejt,qjt,jjt,GR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Zu,t[`surfacePeer${n}`]=ea;for(let n=0;n<8;n++)t[`fillType${n}`]=FJ[n%FJ.length];return{...t,...e}};let IR=null,BJ=null;const Ajt=async e=>{IR||(IR=xe(async()=>{const{default:n}=await import("./mermaid.core-DyOJXgnf.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([10,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await IR;return BJ!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:zjt()}),BJ=e),t},HJ=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>d.jsxs("div",{"data-lo-floating":"",className:X("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[d.jsx($t,{content:h("ui.chat.mermaid.zoom_in"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_in"),onClick:n,children:d.jsx(EOe,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.zoom_out"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_out"),onClick:r,children:d.jsx(qOe,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.pan_hint"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.pan"),children:d.jsx(W9e,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.reset_view"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.reset_view"),onClick:i,children:d.jsx(pk,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.save_svg"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.save_svg"),onClick:a,children:d.jsx(dk,{})})}),d.jsx($t,{content:t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),onClick:o,children:d.jsx(GO,{className:X(t&&"text-success")})})}),s]}),K6=({title:e,children:t})=>d.jsxs(is,{variant:"danger",role:"alert",className:"my-4",children:[d.jsx(ap,{children:e}),d.jsx(fS,{children:t})]}),Ujt=({error:e})=>(be(),d.jsxs(K6,{title:h("ui.chat.mermaid.error_title"),children:[e?.message||h("ui.chat.mermaid.unexpected_error")," ",h("ui.chat.mermaid.error_contained")]}));class Wjt extends $.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||d.jsx(Ujt,{error:this.state.error}):this.props.children}}const Njt=$.memo(({chart:e,id:t})=>{be();const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[f,p]=$.useState({scale:1,x:0,y:0}),[m,g]=$.useState({scale:1,x:0,y:0}),[y,v]=$.useState(!1),[b,x]=$.useState({x:0,y:0}),[Q,w]=$.useState("idle"),[S,_]=$.useState("idle"),k=IP().id,R=$.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const N=await Ajt(k),ce=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:ee}=await N.render(ce,e);if(!ee||typeof ee!="string"||ee.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(ee)}catch(N){console.error("Mermaid rendering error:",N);const ce=N instanceof Error?N.message:"Failed to render mermaid diagram";a(ce),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{R().catch(N=>{console.error("Error in renderDiagram effect:",N),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const E=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ce=r.current.getBoundingClientRect(),ee=document.createElement("div");ee.innerHTML=l;const D=ee.querySelector("svg");if(!D)return 1;const ne=D.getBoundingClientRect?.()?.width||Number.parseFloat(D.getAttribute("width")||"0")||D.viewBox?.baseVal?.width||800,J=D.getBoundingClientRect?.()?.height||Number.parseFloat(D.getAttribute("height")||"0")||D.viewBox?.baseVal?.height||600,L=ce.width*.9/ne,B=ce.height*.9/J;return Math.min(L,B,1)}catch(N){return console.error("Error calculating fullscreen scale:",N),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const N=E();g({scale:N,x:0,y:0})}catch(N){console.error("Error setting fullscreen transform:",N)}},100)},[u,l,E]);const T=$.useCallback((N=!1)=>{try{(N?g:p)(ee=>({...ee,scale:Math.min(ee.scale*1.2,10)}))}catch(ce){console.error("Error in zoom in:",ce)}},[]),q=$.useCallback((N=!1)=>{try{(N?g:p)(ee=>({...ee,scale:Math.max(ee.scale/1.2,.1)}))}catch(ce){console.error("Error in zoom out:",ce)}},[]),A=$.useCallback((N=!1)=>{try{const ce=N?g:p;if(N){const ee=E();ce({scale:ee,x:0,y:0})}else ce({scale:1,x:0,y:0})}catch(ce){console.error("Error in reset:",ce)}},[E]),G=$.useCallback(()=>{if(l)try{const N=new Blob([l],{type:"image/svg+xml"}),ce=URL.createObjectURL(N),ee=document.createElement("a");ee.href=ce,ee.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(ce)}catch(N){console.error("Failed to save SVG:",N)}},[l]),I=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),C=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),_("copied"),setTimeout(()=>_("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),U=$.useCallback(N=>{try{v(!0),x({x:N.clientX,y:N.clientY}),N.preventDefault()}catch(ce){console.error("Error in mouse down:",ce)}},[]),Y=$.useCallback((N,ce=!1)=>{try{if(!y)return;const ee=N.clientX-b.x,D=N.clientY-b.y;(ce?g:p)(J=>({...J,x:J.x+ee,y:J.y+D})),x({x:N.clientX,y:N.clientY})}catch(ee){console.error("Error in mouse move:",ee)}},[y,b]),V=$.useCallback(()=>{try{v(!1)}catch(N){console.error("Error in mouse up:",N)}},[]),z=$.useCallback((N,ce=!1)=>{try{N.preventDefault();const ee=N.deltaY>0?.9:1.1;(ce?g:p)(ne=>({...ne,scale:Math.min(Math.max(ne.scale*ee,.1),5)}))}catch(ee){console.error("Error in wheel:",ee)}},[]),Z=$.useCallback(N=>{try{O(N)}catch(ce){console.error("Error toggling fullscreen:",ce)}},[]);if(i)return d.jsxs(K6,{title:h("ui.chat.mermaid.error_title"),children:[i,d.jsx("span",{className:X("mt-2 block text-ink-muted"),children:h("ui.chat.mermaid.chart_label")}),d.jsx("span",{className:X("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(N=!1)=>{try{const ce=N?r:n,ee=N?m:f;return d.jsx("div",{ref:ce,className:X("mermaid flex w-full items-center justify-center",N?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:U,onMouseMove:D=>Y(D,N),onMouseUp:V,onMouseLeave:V,onWheel:D=>z(D,N),children:o?d.jsx("div",{className:X("p-4 text-body-sm text-ink-muted"),children:h("ui.chat.mermaid.loading")}):l?d.jsx("div",{className:X("flex h-full w-full items-center justify-center"),style:{transform:`translate(${ee.x}px, ${ee.y}px) scale(${ee.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ce){return console.error("Error rendering diagram content:",ce),d.jsx(K6,{title:h("ui.chat.mermaid.rendering_error"),children:h("ui.chat.mermaid.render_failed")})}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:X("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[K(!1),d.jsx(HJ,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>T(!1),onZoomOut:()=>q(!1),onReset:()=>A(!1),onSave:G,onCopy:I,children:d.jsx($t,{content:h("ui.chat.mermaid.fullscreen"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.open_fullscreen"),onClick:()=>Z(!0),children:d.jsx(QOe,{})})})})]}),d.jsx(Mp,{open:u,onClose:()=>Z(!1),title:h("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:d.jsxs("div",{className:X("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[K(!0),d.jsx(HJ,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>T(!0),onZoomOut:()=>q(!0),onReset:()=>A(!0),onSave:G,onCopy:C,children:d.jsx($t,{content:h("ui.chat.mermaid.close_fullscreen"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.close_fullscreen"),onClick:()=>Z(!1),children:d.jsx(Zr,{})})})})]})})]})}),Yjt=$.memo(e=>d.jsx(Wjt,{children:d.jsx(Njt,{...e})}));let N_e=!1,ZR=null;const Gjt=()=>(ZR||(ZR=xe(()=>Promise.resolve({}),__vite__mapDeps([11]),import.meta.url).then(e=>(N_e=!0,e))),ZR),Ijt=/language-(\w+)/,Zjt=xA,Djt=new RegExp(`^[^${tu}\\d*+-]`),Vjt=/\n$/,Y_e=({href:e,children:t})=>{const n=jQe(e),r=xb();return!n||n.kind==="other"?d.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):d.jsx("a",{href:n.target,"data-lo-kind":n.kind,"data-lo-target":n.target,draggable:!1,target:n.kind==="url"?"_blank":void 0,rel:n.kind==="url"?"noopener noreferrer":void 0,onClick:n.kind==="file"?i=>Fjt(i,r):void 0,children:t})},Mjt=e=>jQe(e)?.kind==="file",Ljt=UQe,Fjt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(AQe)??"file",i=n.getAttribute(Ljt),a=qRt({kind:r,hasHighlight:HRt(n),canOpenInCanvas:$N(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||Ou(i)});return}Ou(i)}},J6=(e,t)=>t==="href"&&Mjt(e)?e:Zfe(e),Zy={a:Y_e,table:z8,img:Cqt,code:({node:e,className:t,children:n,...r})=>Ijt.exec(t??"")?.[1]==="mermaid"?d.jsx(Yjt,{chart:String(n).replace(Vjt,"")}):d.jsx("code",{dir:"ltr",className:t,...r,children:n})},Bjt={...Zy,a:$qt(Y_e)},Hjt=[cs],Kjt=[cs,GP],Jjt=[cs,zP],e3t=[cs,GP,zP],t3t=[cs,NP,AP],n3t=[cs,GP,NP,AP],r3t=[cs,zP,NP,AP],i3t=[cs,GP,zP,NP,AP],a3t={"000":Hjt,"001":t3t,"010":Jjt,"011":r3t,100:Kjt,101:n3t,110:e3t,111:i3t},o3t=[],s3t={throwOnError:!1,strict:"ignore",trust:!1,errorColor:"var(--lo-danger)"},l3t=[[xit,s3t]],G_e=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),I_e=(e,t,n,r)=>{const i=$.useMemo(()=>vjt(e),[e]),[a,o]=$.useState(N_e),s=i&&a;$.useEffect(()=>{if(!i||a)return;let O=!1;return Gjt().then(()=>{O||o(!0)}),()=>{O=!0}},[i,a]);const l=a3t[`${s?1:0}${t?1:0}${n?1:0}`],c=n&&r?r.join("\0"):"";return{remarkPlugins:$.useMemo(()=>c===""?l:[[N4t,{names:c.split("\0")}],...l],[l,c]),rehypePlugins:s?l3t:o3t}},Z_e=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=Vit(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=ARt(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return gN(i,window.api?.probeFiles,Pue,CRt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>zQe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},Dy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,skillNames:a,documentId:o})=>{const s=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:l,rehypePlugins:c}=I_e(s,r,i,a),u=G_e(t);return Z_e(s,r,o),d.jsx("div",{className:X("lo-markdown",n),style:u,children:d.jsx(ly,{remarkPlugins:l,rehypePlugins:c,urlTransform:J6,components:i?Bjt:Zy,children:s})})});Dy.displayName="MarkdownRenderer";const KJ={...Zy,a:({children:e})=>d.jsx(d.Fragment,{children:e})},D_e=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:yJ(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=HQe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=I_e(n,t,!1);if(Z_e(e,t),r!==null){const o=yJ(r.before);return d.jsxs(d.Fragment,{children:[o.trim()!==""&&d.jsx(ly,{remarkPlugins:i,rehypePlugins:a,urlTransform:J6,components:t?Zy:KJ,children:o}),d.jsx(c3t,{info:r.info,body:r.body})]})}return d.jsx(ly,{remarkPlugins:i,rehypePlugins:a,urlTransform:J6,components:t?Zy:KJ,children:n})});D_e.displayName="ParsedBlock";const c3t=({info:e,body:t})=>{const n=e.split(Zjt)[0];return d.jsx("pre",{children:d.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
|
|
942
|
+
`||o==="\r"){if(n=!1,a())return!0;continue}i+=n||o==="\\"?"\0":o,!n&&o==="{"&&t++,!n&&o==="}"&&t>0&&t--,n=!n&&o==="\\"}return a()},gjt=e=>{const t=new RegExp(djt.source,"g");let n=t.exec(e);for(;n!==null;){const r=n[1];if(hjt.test(r)&&fjt.test(r)&&!r.includes("`")&&!mjt(r))return!0;t.lastIndex=n.index+1,n=t.exec(e)}return!1},DJ=e=>ajt.test(e)||ojt.test(e)||cjt.test(e)||ujt.test(e)||Ojt.test(e)||gjt(e)||sjt.test(e)?!0:ljt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),$jt=e=>{const t=WP(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},yjt=e=>WP(e).filter(t=>t.kind!=="text").length,vjt=e=>{if(!DJ(e))return!1;const t=$jt(e);return t===null?!0:DJ(t)||t.includes("$")?!1:yjt(e)<2},R_e=Object.freeze(["canvas","surface","ink","inkMuted","accent","borderControl"]),E_e=Object.freeze(UA.filter(e=>!["overlayShadow","scrim"].includes(e))),q_e=65536,j_e=/^#[0-9a-fA-F]{6}$/,bjt=(e,t)=>Object.hasOwn(e,t),VJ=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),wa=e=>{throw new Error(e)},wjt={canvas:["surface","elevated","sunken","messageSurface","mediaSurface","rowHover","rowSelected","accentWash","accentAltWash","successWash","warningWash","dangerWash","infoWash"],surface:["elevated","rowHover","rowSelected"],ink:["inkMuted","inkDim","inkDisabled"],inkMuted:["inkDim"],accent:["accentHover","accentActive","accentWash","chartBarHover"],borderControl:["hairline","hairlineStrong"]},Iy=(e,t)=>{const n={...e};for(const r of R_e){const i=$qe(t.seeds?.[r]);if(!i)continue;const a=g2(e[r]),o=g2(i);n[r]=i;for(const s of wjt[r]){const l=g2(e[s]);n[s]=yqe({l:o.l+l.l-a.l,c:a.c>.01?o.c*l.c/a.c:l.c,h:o.h+l.h-a.h})}}n.accent.toUpperCase()!==e.accent.toUpperCase()&&(n.onAccent=vqe(n.accent,[e.onAccent,n.ink,n.canvas,"#000000","#FFFFFF"]));for(const r of E_e)j_e.test(t.overrides?.[r]??"")&&(n[r]=t.overrides[r]);for(const r of["overlayShadow","scrim"]){const i=t.overrides?.[r];typeof i=="string"&&/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(i)&&(n[r]=e[r].replace(/\/\s*[\d.]+\)/,`/ ${i})`))}return n},_N=(e,t)=>mqe(e,t),i$n=(e,t)=>{const n=Iy(e,t),r=xqe(n,t.base,e,{pinned:Object.keys(t.overrides??{}),maxEvaluations:320,lightnessOnly:!0}).palette;if(!r||Object.keys(t.overrides??{}).some(s=>r[s]!==n[s]))return null;const a={...t.overrides};for(const s of E_e)r[s]!==n[s]&&(a[s]=r[s]);const o={...t,overrides:a};return _N(Iy(e,o),t.base).length?null:o},C_e=(e,t,{id:n="custom-import",now:r=Date.now()}={})=>{(typeof e!="string"||new TextEncoder().encode(e).length>q_e)&&wa("import_size");let i;try{i=JSON.parse(e)}catch{wa("import_invalid_json")}VJ(i)||wa("import_format");const a=new Set(["format","version","name","base","seeds","overrides","id","updatedAt"]);Object.keys(i).some(s=>!a.has(s))&&wa("import_unsafe"),i.format!=="local-operator-theme"&&wa("import_format"),i.version!==1&&wa("import_version"),(typeof i.base!="string"||!t(i.base))&&wa("import_base"),(typeof i.name!="string"||!i.name.trim()||i.name.trim().length>60)&&wa("import_name");const o={};for(const s of["seeds","overrides"]){(!bjt(i,s)||!VJ(i[s]))&&wa("import_roles");const l={};for(const[c,u]of Object.entries(i[s]))(!(s==="seeds"?R_e:UA).includes(c)||typeof u!="string")&&wa("import_roles"),["overlayShadow","scrim"].includes(c)?(/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(u)||wa("import_roles"),l[c]=u):(j_e.test(u)||wa("import_roles"),l[c]=u.toUpperCase());o[s]=l}return{format:"local-operator-theme",version:1,id:n,name:i.name.trim(),base:i.base,...o,updatedAt:r}},xjt=(e,t)=>{if(e==null)return[];(typeof e!="string"||e.length>q_e*lS)&&wa("load_error");let n;try{n=JSON.parse(e)}catch{wa("load_error")}const r=Array.isArray(n)?n:n?.version===1?n.themes:null;Array.isArray(r)||wa("load_error");const i=[],a=new Set;for(const o of r.slice(0,lS))try{const s=gqe(o,{isThemeName:t,isRole:c=>UA.includes(c)});if(!s||a.has(s.id))continue;const l=C_e(JSON.stringify(o),t,{id:s.id,now:s.updatedAt});i.push(l),a.add(l.id)}catch{}return i},Sjt=e=>JSON.stringify({format:"local-operator-theme",version:1,name:e.name,base:e.base,seeds:e.seeds,overrides:e.overrides},null,2),a$n=(e,t)=>{const n=new Set(t.map(r=>r.name));if(!n.has(e))return e;for(let r=2;r<=lS+1;r++){const i=`${e.slice(0,54)} (${r})`;if(!n.has(i))return i}return e},o$n=(e,t)=>{const n=bqe({composed:!0,capturePairs:!0});return wqe(n,{id:t,palette:e}),{findings:n.log,readings:n.readings}};let NO={themes:[],error:!1,loading:!1};const F6=new Set,z_e=()=>{for(const e of F6)e()},MJ=()=>NO,Qjt=e=>(F6.add(e),()=>{F6.delete(e)}),LJ=()=>{try{NO={themes:xjt(localStorage.getItem(wA),fue).filter(t=>{const n=$A(t.base)?.palette;return n&&_N(Iy(n,t),t.base).length===0}),error:!1,loading:!1}}catch{NO={themes:[],error:!0,loading:!1}}z_e()},kN=()=>$.useSyncExternalStore(Qjt,MJ,MJ),_jt=e=>NO.themes.find(t=>t.id===e),A_e=e=>{localStorage.setItem(wA,JSON.stringify({version:1,themes:e})),NO={themes:e,error:!1,loading:!1},z_e()},s$n=e=>{const t=Sqe(e.id);if(!t)throw new Error("invalid custom theme id");const n=C_e(Sjt(e),fue,{id:t,now:e.updatedAt}),r=$A(n.base)?.palette;if(!r||_N(Iy(r,n),n.base).length)throw new Error("contrast");if(!_jt(n.id)&&NO.themes.length>=lS)throw new Error("limit");A_e([n,...NO.themes.filter(i=>i.id!==n.id)])},l$n=e=>A_e(NO.themes.filter(t=>t.id!==e));typeof window<"u"&&(LJ(),window.addEventListener("storage",e=>{(e.key===wA||e.key===null)&&LJ()}));const kjt=()=>{const e=It(i=>i.themeName),t=It(i=>i.contrast),n=It(i=>i.accent),r=It(i=>i.customThemeId);return $.useMemo(()=>({themeName:e,contrast:t,accent:n,customThemeId:r}),[e,t,n,r])},Pjt=e=>{const t=e?$A(e.base)?.palette:void 0;return t&&e?Iy(t,e):void 0},Tjt=()=>{const e=kjt(),t=kN();return $.useMemo(()=>{const n=t.themes.find(a=>a.id===e.customThemeId),r=Pjt(n),i=n?.base;return{appearance:e,savedPalette:r,savedBase:i,resolved:Qqe(e,r,i)}},[e,t])},IP=()=>Tjt().resolved,c$n=()=>IP().palette.mode==="dark",tn="var(--color-ink)",Oc="var(--color-ink-muted)",ml="var(--color-surface)",Zu="var(--color-elevated)",dc="var(--color-sunken)",ea="var(--color-hairline)",Du="var(--color-control)",Nh="var(--color-accent)",K0="var(--color-accent-wash)",Xjt="var(--color-accent-alt-wash)",Rjt="var(--color-on-accent)",Ejt="var(--color-info)",U_e="var(--color-info-wash)",qjt="var(--color-success)",W_e="var(--color-success-wash)",jjt="var(--color-warning)",B6="var(--color-warning-wash)",Cjt="var(--color-warning-border)",GR="var(--color-danger)",H6="var(--color-danger-wash)",FJ=[K0,Xjt,U_e,W_e,B6,H6],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),zjt=()=>{const e={primaryColor:Vu("--color-accent"),secondaryColor:Vu("--color-success"),tertiaryColor:Vu("--color-info"),mainBkg:Vu("--color-elevated"),clusterBkg:Vu("--color-sunken"),clusterBorder:Vu("--color-hairline"),edgeLabelBackground:Vu("--color-surface"),quadrant1Fill:Vu("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:ml,primaryTextColor:tn,primaryBorderColor:Du,secondaryTextColor:tn,secondaryBorderColor:ea,tertiaryTextColor:tn,tertiaryBorderColor:ea,lineColor:Oc,arrowheadColor:Oc,textColor:tn,secondBkg:dc,border1:Du,border2:ea,labelColor:tn,nodeBkg:Zu,nodeBorder:Du,nodeTextColor:tn,defaultLinkColor:Oc,titleColor:tn,noteBkgColor:B6,noteBorderColor:Cjt,noteTextColor:tn,actorBkg:Zu,actorBorder:Du,actorTextColor:tn,actorLineColor:ea,signalColor:Oc,signalTextColor:tn,labelBoxBkgColor:Zu,labelBoxBorderColor:ea,labelTextColor:tn,loopTextColor:tn,activationBkgColor:K0,activationBorderColor:Nh,sequenceNumberColor:ml,sectionBkgColor:dc,sectionBkgColor2:ml,altSectionBkgColor:dc,excludeBkgColor:dc,taskBkgColor:K0,taskBorderColor:Du,taskTextColor:tn,taskTextLightColor:tn,taskTextDarkColor:tn,taskTextOutsideColor:tn,taskTextClickableColor:Nh,activeTaskBkgColor:K0,activeTaskBorderColor:Nh,gridColor:ea,doneTaskBkgColor:dc,doneTaskBorderColor:ea,critBkgColor:H6,critBorderColor:GR,todayLineColor:Nh,transitionColor:Oc,transitionLabelColor:tn,stateLabelColor:tn,stateBkg:Zu,labelBackgroundColor:ml,compositeBackground:dc,altBackground:dc,compositeTitleBackground:Zu,compositeBorder:ea,innerEndBackground:tn,specialStateColor:tn,classText:tn,attributeBackgroundColorOdd:ml,attributeBackgroundColorEven:dc,rowOdd:ml,rowEven:dc,errorBkgColor:H6,errorTextColor:GR,pieTitleTextColor:tn,pieSectionTextColor:tn,pieLegendTextColor:tn,pieStrokeColor:ml,pieOuterStrokeColor:ea,requirementBackground:Zu,requirementBorderColor:Du,requirementTextColor:tn,relationColor:Oc,relationLabelBackground:ml,relationLabelColor:tn,branchLabelColor:Rjt,commitLabelColor:tn,commitLabelBackground:ml,tagLabelColor:tn,tagLabelBackground:K0,tagLabelBorder:Du,quadrant2Fill:U_e,quadrant3Fill:W_e,quadrant4Fill:B6,quadrant2TextFill:tn,quadrant3TextFill:tn,quadrant4TextFill:tn,quadrantPointFill:Nh,archEdgeColor:Oc,archEdgeArrowColor:Oc,archGroupBorderColor:ea,scaleLabelColor:tn,packet:{startByteColor:tn,endByteColor:tn,labelColor:tn,titleColor:tn,blockStrokeColor:Du,blockFillColor:Zu},radar:{axisColor:Oc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:ea,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:ml,titleColor:tn,xAxisTitleColor:tn,xAxisLabelColor:tn,xAxisTickColor:ea,xAxisLineColor:ea,yAxisTitleColor:tn,yAxisLabelColor:tn,yAxisTickColor:ea,yAxisLineColor:ea,plotColorPalette:[Nh,Ejt,qjt,jjt,GR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Zu,t[`surfacePeer${n}`]=ea;for(let n=0;n<8;n++)t[`fillType${n}`]=FJ[n%FJ.length];return{...t,...e}};let IR=null,BJ=null;const Ajt=async e=>{IR||(IR=xe(async()=>{const{default:n}=await import("./mermaid.core-D7wfsRjY.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([10,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await IR;return BJ!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:zjt()}),BJ=e),t},HJ=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>d.jsxs("div",{"data-lo-floating":"",className:X("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[d.jsx($t,{content:h("ui.chat.mermaid.zoom_in"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_in"),onClick:n,children:d.jsx(EOe,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.zoom_out"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_out"),onClick:r,children:d.jsx(qOe,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.pan_hint"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.pan"),children:d.jsx(W9e,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.reset_view"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.reset_view"),onClick:i,children:d.jsx(pk,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.save_svg"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.save_svg"),onClick:a,children:d.jsx(dk,{})})}),d.jsx($t,{content:t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),onClick:o,children:d.jsx(GO,{className:X(t&&"text-success")})})}),s]}),K6=({title:e,children:t})=>d.jsxs(is,{variant:"danger",role:"alert",className:"my-4",children:[d.jsx(ap,{children:e}),d.jsx(fS,{children:t})]}),Ujt=({error:e})=>(be(),d.jsxs(K6,{title:h("ui.chat.mermaid.error_title"),children:[e?.message||h("ui.chat.mermaid.unexpected_error")," ",h("ui.chat.mermaid.error_contained")]}));class Wjt extends $.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||d.jsx(Ujt,{error:this.state.error}):this.props.children}}const Njt=$.memo(({chart:e,id:t})=>{be();const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[f,p]=$.useState({scale:1,x:0,y:0}),[m,g]=$.useState({scale:1,x:0,y:0}),[y,v]=$.useState(!1),[b,x]=$.useState({x:0,y:0}),[Q,w]=$.useState("idle"),[S,_]=$.useState("idle"),k=IP().id,R=$.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const N=await Ajt(k),ce=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:ee}=await N.render(ce,e);if(!ee||typeof ee!="string"||ee.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(ee)}catch(N){console.error("Mermaid rendering error:",N);const ce=N instanceof Error?N.message:"Failed to render mermaid diagram";a(ce),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{R().catch(N=>{console.error("Error in renderDiagram effect:",N),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const E=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ce=r.current.getBoundingClientRect(),ee=document.createElement("div");ee.innerHTML=l;const D=ee.querySelector("svg");if(!D)return 1;const ne=D.getBoundingClientRect?.()?.width||Number.parseFloat(D.getAttribute("width")||"0")||D.viewBox?.baseVal?.width||800,J=D.getBoundingClientRect?.()?.height||Number.parseFloat(D.getAttribute("height")||"0")||D.viewBox?.baseVal?.height||600,L=ce.width*.9/ne,B=ce.height*.9/J;return Math.min(L,B,1)}catch(N){return console.error("Error calculating fullscreen scale:",N),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const N=E();g({scale:N,x:0,y:0})}catch(N){console.error("Error setting fullscreen transform:",N)}},100)},[u,l,E]);const T=$.useCallback((N=!1)=>{try{(N?g:p)(ee=>({...ee,scale:Math.min(ee.scale*1.2,10)}))}catch(ce){console.error("Error in zoom in:",ce)}},[]),q=$.useCallback((N=!1)=>{try{(N?g:p)(ee=>({...ee,scale:Math.max(ee.scale/1.2,.1)}))}catch(ce){console.error("Error in zoom out:",ce)}},[]),A=$.useCallback((N=!1)=>{try{const ce=N?g:p;if(N){const ee=E();ce({scale:ee,x:0,y:0})}else ce({scale:1,x:0,y:0})}catch(ce){console.error("Error in reset:",ce)}},[E]),G=$.useCallback(()=>{if(l)try{const N=new Blob([l],{type:"image/svg+xml"}),ce=URL.createObjectURL(N),ee=document.createElement("a");ee.href=ce,ee.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(ce)}catch(N){console.error("Failed to save SVG:",N)}},[l]),I=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),C=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),_("copied"),setTimeout(()=>_("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),U=$.useCallback(N=>{try{v(!0),x({x:N.clientX,y:N.clientY}),N.preventDefault()}catch(ce){console.error("Error in mouse down:",ce)}},[]),Y=$.useCallback((N,ce=!1)=>{try{if(!y)return;const ee=N.clientX-b.x,D=N.clientY-b.y;(ce?g:p)(J=>({...J,x:J.x+ee,y:J.y+D})),x({x:N.clientX,y:N.clientY})}catch(ee){console.error("Error in mouse move:",ee)}},[y,b]),V=$.useCallback(()=>{try{v(!1)}catch(N){console.error("Error in mouse up:",N)}},[]),z=$.useCallback((N,ce=!1)=>{try{N.preventDefault();const ee=N.deltaY>0?.9:1.1;(ce?g:p)(ne=>({...ne,scale:Math.min(Math.max(ne.scale*ee,.1),5)}))}catch(ee){console.error("Error in wheel:",ee)}},[]),Z=$.useCallback(N=>{try{O(N)}catch(ce){console.error("Error toggling fullscreen:",ce)}},[]);if(i)return d.jsxs(K6,{title:h("ui.chat.mermaid.error_title"),children:[i,d.jsx("span",{className:X("mt-2 block text-ink-muted"),children:h("ui.chat.mermaid.chart_label")}),d.jsx("span",{className:X("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(N=!1)=>{try{const ce=N?r:n,ee=N?m:f;return d.jsx("div",{ref:ce,className:X("mermaid flex w-full items-center justify-center",N?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:U,onMouseMove:D=>Y(D,N),onMouseUp:V,onMouseLeave:V,onWheel:D=>z(D,N),children:o?d.jsx("div",{className:X("p-4 text-body-sm text-ink-muted"),children:h("ui.chat.mermaid.loading")}):l?d.jsx("div",{className:X("flex h-full w-full items-center justify-center"),style:{transform:`translate(${ee.x}px, ${ee.y}px) scale(${ee.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ce){return console.error("Error rendering diagram content:",ce),d.jsx(K6,{title:h("ui.chat.mermaid.rendering_error"),children:h("ui.chat.mermaid.render_failed")})}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:X("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[K(!1),d.jsx(HJ,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>T(!1),onZoomOut:()=>q(!1),onReset:()=>A(!1),onSave:G,onCopy:I,children:d.jsx($t,{content:h("ui.chat.mermaid.fullscreen"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.open_fullscreen"),onClick:()=>Z(!0),children:d.jsx(QOe,{})})})})]}),d.jsx(Mp,{open:u,onClose:()=>Z(!1),title:h("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:d.jsxs("div",{className:X("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[K(!0),d.jsx(HJ,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>T(!0),onZoomOut:()=>q(!0),onReset:()=>A(!0),onSave:G,onCopy:C,children:d.jsx($t,{content:h("ui.chat.mermaid.close_fullscreen"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.close_fullscreen"),onClick:()=>Z(!1),children:d.jsx(Zr,{})})})})]})})]})}),Yjt=$.memo(e=>d.jsx(Wjt,{children:d.jsx(Njt,{...e})}));let N_e=!1,ZR=null;const Gjt=()=>(ZR||(ZR=xe(()=>Promise.resolve({}),__vite__mapDeps([11]),import.meta.url).then(e=>(N_e=!0,e))),ZR),Ijt=/language-(\w+)/,Zjt=xA,Djt=new RegExp(`^[^${tu}\\d*+-]`),Vjt=/\n$/,Y_e=({href:e,children:t})=>{const n=jQe(e),r=xb();return!n||n.kind==="other"?d.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):d.jsx("a",{href:n.target,"data-lo-kind":n.kind,"data-lo-target":n.target,draggable:!1,target:n.kind==="url"?"_blank":void 0,rel:n.kind==="url"?"noopener noreferrer":void 0,onClick:n.kind==="file"?i=>Fjt(i,r):void 0,children:t})},Mjt=e=>jQe(e)?.kind==="file",Ljt=UQe,Fjt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(AQe)??"file",i=n.getAttribute(Ljt),a=qRt({kind:r,hasHighlight:HRt(n),canOpenInCanvas:$N(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||Ou(i)});return}Ou(i)}},J6=(e,t)=>t==="href"&&Mjt(e)?e:Zfe(e),Zy={a:Y_e,table:z8,img:Cqt,code:({node:e,className:t,children:n,...r})=>Ijt.exec(t??"")?.[1]==="mermaid"?d.jsx(Yjt,{chart:String(n).replace(Vjt,"")}):d.jsx("code",{dir:"ltr",className:t,...r,children:n})},Bjt={...Zy,a:$qt(Y_e)},Hjt=[cs],Kjt=[cs,GP],Jjt=[cs,zP],e3t=[cs,GP,zP],t3t=[cs,NP,AP],n3t=[cs,GP,NP,AP],r3t=[cs,zP,NP,AP],i3t=[cs,GP,zP,NP,AP],a3t={"000":Hjt,"001":t3t,"010":Jjt,"011":r3t,100:Kjt,101:n3t,110:e3t,111:i3t},o3t=[],s3t={throwOnError:!1,strict:"ignore",trust:!1,errorColor:"var(--lo-danger)"},l3t=[[xit,s3t]],G_e=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),I_e=(e,t,n,r)=>{const i=$.useMemo(()=>vjt(e),[e]),[a,o]=$.useState(N_e),s=i&&a;$.useEffect(()=>{if(!i||a)return;let O=!1;return Gjt().then(()=>{O||o(!0)}),()=>{O=!0}},[i,a]);const l=a3t[`${s?1:0}${t?1:0}${n?1:0}`],c=n&&r?r.join("\0"):"";return{remarkPlugins:$.useMemo(()=>c===""?l:[[N4t,{names:c.split("\0")}],...l],[l,c]),rehypePlugins:s?l3t:o3t}},Z_e=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=Vit(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=ARt(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return gN(i,window.api?.probeFiles,Pue,CRt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>zQe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},Dy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,skillNames:a,documentId:o})=>{const s=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:l,rehypePlugins:c}=I_e(s,r,i,a),u=G_e(t);return Z_e(s,r,o),d.jsx("div",{className:X("lo-markdown",n),style:u,children:d.jsx(ly,{remarkPlugins:l,rehypePlugins:c,urlTransform:J6,components:i?Bjt:Zy,children:s})})});Dy.displayName="MarkdownRenderer";const KJ={...Zy,a:({children:e})=>d.jsx(d.Fragment,{children:e})},D_e=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:yJ(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=HQe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=I_e(n,t,!1);if(Z_e(e,t),r!==null){const o=yJ(r.before);return d.jsxs(d.Fragment,{children:[o.trim()!==""&&d.jsx(ly,{remarkPlugins:i,rehypePlugins:a,urlTransform:J6,components:t?Zy:KJ,children:o}),d.jsx(c3t,{info:r.info,body:r.body})]})}return d.jsx(ly,{remarkPlugins:i,rehypePlugins:a,urlTransform:J6,components:t?Zy:KJ,children:n})});D_e.displayName="ParsedBlock";const c3t=({info:e,body:t})=>{const n=e.split(Zjt)[0];return d.jsx("pre",{children:d.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
|
|
943
943
|
`)?"":`
|
|
944
944
|
`}`})})},V_e=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=t4t());const i=r.current;a4t(i,e);const{blockStart:a}=i,o=a+o4t(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&Djt.test(e.slice(i.cursor)))&&i.fence===null&&i.blankRunStart>=a&&i.cursor<o&&e.slice(i.cursor,o).trim().length>0&&(s=e.slice(a,i.blankRunStart),l=i.cursor);const c=e.slice(l,o),u=i.blocks.map((f,p)=>({key:p,source:f,closed:!0}));s!==null&&u.push({key:i.blocks.length,source:s,closed:!0}),c!==""&&u.push({key:u.length,source:c,closed:!1});const O=G_e(t);return d.jsx("div",{className:X("lo-markdown",n),style:O,children:u.map(f=>d.jsx(D_e,{source:f.source,closed:f.closed},f.key))})};V_e.displayName="StreamingMarkdown";const ez=({mark:e,name:t,className:n})=>{const r=Tue(It(o=>o.agentAvatarSize)),i=kqe[r],a=_qe[r];return d.jsx("div",{className:X("flex",a.className,n),"data-turn-avatar-gap":a.px,children:d.jsx(OBe,{mark:e,boxClassName:i.className,glyphClassName:i.glyphClassName,hitClassName:i.hitClassName,alt:t??"",agentName:t})})},fa=({isUser:e,children:t,className:n})=>e?d.jsx("div",{className:X("flex w-full justify-end",n),children:t}):d.jsx("div",{className:X("group relative w-full",n),children:t}),PN=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},u3t=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()+1),Math.max(1,t.getTime()-e)};let TN=PN(Date.now()),Tc=null,JJ=0,eee=0,tee=0;const Dx=new Set,O3t=1e3,d3t=()=>typeof performance>"u"?Date.now():performance.now(),M_e=()=>{const e=Date.now(),t=e+u3t(e),n=d3t();Tc!==null&&t===JJ&&Math.abs(e-eee-(n-tee))<=O3t||(Tc!==null&&clearTimeout(Tc),JJ=t,eee=e,tee=n,Tc=setTimeout(()=>{Tc=null,TN=PN(Date.now());for(const r of Dx)r();M_e()},t-e),Tc.unref?.())},f3t=e=>(Dx.add(e),TN=PN(Date.now()),M_e(),()=>{Dx.delete(e),Dx.size===0&&Tc!==null&&(clearTimeout(Tc),Tc=null)}),nee=()=>TN,h3t=()=>$.useSyncExternalStore(f3t,nee,nee),p3t=e=>new Date(e+1e3),m3t=()=>p3t(h3t()),u$n=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":zv(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},g3t=(e,t=new Date)=>{if(e==null)return"";try{const n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return"";const r=Av(n,{hour:"numeric",minute:"2-digit"});if(n.toDateString()===t.toDateString())return r;const i=new Date(t);if(i.setDate(t.getDate()-1),n.toDateString()===i.toDateString())return h("ui.common.time.yesterday_at",{time:r});const a=zv(n,{month:"short",day:"numeric"});return n.getFullYear()===t.getFullYear()?`${a}, ${r}`:`${a}, ${n.getFullYear()}, ${r}`}catch(n){return console.error("Error formatting turn timestamp:",n),""}},$3t=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":SA(t,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}catch(t){return console.error("Error formatting calendar date-time:",t),""}},y3t=(e,t)=>{switch(e){case"turn":return h("ui.chat.user_turn.stamp.sent",{date:t});case"answer":return h("ui.chat.user_turn.stamp.answered",{date:t});case"tool":return h("ui.chat.user_turn.stamp.ran",{date:t})}},UQ=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=m3t();if(Number.isNaN(r.getTime()))return null;const a=$3t(r);return d.jsx($t,{content:a,side:"bottom",delayDuration:1200,children:d.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":y3t(t,a),className:X("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:d.jsx("bdi",{children:g3t(r,i)})})})},XN=({replies:e,onRemoveReply:t})=>(be(),d.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[d.jsx(_Oe,{size:12,"aria-hidden":"true"}),d.jsx("span",{className:"text-meta",children:h("ui.chat.reply.replying_to")})]}),e.map(n=>d.jsxs("div",{className:"flex items-center gap-2 border-hairline border-s-2 py-0.5 ps-2",children:[d.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&d.jsx(ve,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"data-reply-chip-remove":!0,"aria-label":h("ui.chat.reply.remove"),children:d.jsx(Zr,{"aria-hidden":"true"})})]},n.id))]})),v3t=({children:e,className:t})=>d.jsx("span",{"aria-hidden":!0,className:X("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),tz={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},ree=C3,DR={start:0,offset:0};async function b3t(e,t,n){const{start:r,offset:i}=n;try{const a=await Te(e.childId?{op:"subagents.diff",sessionId:e.sessionId,childId:e.childId,callId:t,start:r,offset:i,limit:C3}:{op:"sessions.diff",sessionId:e.sessionId,callId:t,start:r,offset:i,limit:C3}),o=Vqe(a,n);if(!o)throw new Error("malformed diff page");return o}catch(a){if(a instanceof vn&&a.status===404)return"not_found";throw a}}function VR(e){return e!=="not_found"&&e.state==="archived"}function w3t(e,t){const[n,r]=$.useState({kind:"loading"}),i=$.useRef(0),a=$.useRef([]),{sessionId:o,childId:s}=e,l=$.useCallback(async(O,f)=>{const p=++i.current,m={sessionId:o,childId:s};r({kind:"loading"});try{const g=[],y=async Q=>{if(i.current!==p)throw iee;return b3t(m,t,Q)};let b=f==="before"?{start:Gqe(O.start),offset:0}:O,x=await y(b);if(f==="before"){let Q=0;for(;VR(x);){const w=aw(x);if(!w||Iqe(w,O)>=0||w.start>x.start&&++Q>ree)break;g.push(b),b=w,x=await y(b)}VR(x)&&(x=Zqe(x,O))}if(f==="last"){let Q=0;for(;VR(x);){const w=aw(x);if(!w)break;w.start>x.start&&++Q>ree?(g.length=0,Q=0,b={start:Math.max(0,x.totalRows-1),offset:0}):(g.push(b),b=w),x=await y(b)}}if(i.current!==p)return;x==="not_found"?r({kind:"notice",notice:"not_found"}):x.state!=="archived"?r({kind:"notice",notice:x.state}):(f!=="exact"&&(a.current=g),r({kind:"page",page:x}))}catch(g){if(g===iee||i.current!==p)return;r({kind:"error",cursor:O,mode:f})}},[o,s,t]);$.useEffect(()=>(a.current=[],l(DR,"exact"),()=>{i.current+=1}),[l]);const c=n.kind==="page"?n.page:null,u=c?.totalRows??0;return{state:n,first:()=>{a.current=[],l(DR,"exact")},prev:()=>{if(!c)return;const O=a.current.pop();O!==void 0?l(O,"exact"):l({start:c.start,offset:c.offset},"before")},next:()=>{const O=c?aw(c):null;!c||!O||(a.current.push({start:c.start,offset:c.offset}),l(O,"exact"))},last:()=>{a.current=[],l({start:Dqe(u),offset:0},"last")},retry:()=>{n.kind==="error"?l(n.cursor,n.mode):l(DR,"exact")},canPrev:!!(c&&(c.start>0||c.offset>0)),canNext:!!(c&&aw(c))}}const iee=Symbol("diff-history-cancelled"),x3t=500,S3t=1e4;function T1(e){const t=e?.closest("[data-lo-canonical-transcript]"),n=e?.nextElementSibling;if(!t||!e||!(n instanceof HTMLElement))return;t.scrollTop+=n.getBoundingClientRect().top-t.getBoundingClientRect().top;const r=e.ownerDocument.defaultView,i=Number.parseFloat(r?.getComputedStyle(e).marginBottom??"")||0;for(let a=0;a<3;a+=1){const o=n.getBoundingClientRect().top-(e.getBoundingClientRect().bottom+i);if(Math.abs(o)<1)break;t.scrollTop+=o}}const Mu="cursor-pointer text-ink-dim underline underline-offset-2 transition-colors duration-fast ease-out-quart hover:text-ink aria-disabled:cursor-default aria-disabled:no-underline aria-disabled:text-ink-disabled aria-disabled:hover:text-ink-disabled focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent",Q3t=({scope:e,callId:t,headerRows:n,onBack:r,onNotice:i})=>{const a=w3t(e,t),{state:o}=a,s=o.kind==="notice"?o.notice:null;$.useEffect(()=>{s&&i?.(s)},[s]);const l=$.useRef(0);o.kind==="page"&&o.page.start===0&&o.page.offset===0&&(l.current=Xue(o.page.rows));const c=n??l.current,u=$.useRef(null),O=$.useRef(null),f=$.useRef(!1),p=$.useRef(null);o.kind==="page"?p.current=o.page:o.kind==="notice"&&(p.current=null);const m=$.useRef(!1),g=(T,q)=>()=>{T&&(m.current=!!u.current?.contains(document.activeElement),f.current=!0,q())};$.useLayoutEffect(()=>{f.current=!0,T1(O.current),O.current?.focus({preventScroll:!0})},[]);const y=$.useRef(0),v=$.useRef(()=>{});$.useEffect(()=>{const T=O.current?.closest("[data-lo-canonical-transcript]");if(!T)return;let q=0;const A=()=>performance.now()<y.current,G=()=>{q=0,A()&&(T1(O.current),q=requestAnimationFrame(G))},I=()=>{q===0&&A()&&(q=requestAnimationFrame(G))},C=()=>{f.current=!1,m.current=!1,y.current=0,q&&cancelAnimationFrame(q),q=0};v.current=I;const U=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{A()&&T1(O.current)});U?.observe(T.querySelector("[data-lo-transcript-content]")??T),u.current&&U?.observe(u.current);const Y=["wheel","pointerdown","keydown","touchstart"];for(const V of Y)T.addEventListener(V,C,{capture:!0,passive:!0});return I(),()=>{v.current=()=>{},q&&cancelAnimationFrame(q),U?.disconnect();for(const V of Y)T.removeEventListener(V,C,{capture:!0})}},[]),$.useLayoutEffect(()=>{f.current&&(T1(O.current),y.current=performance.now()+(o.kind==="loading"?S3t:x3t),v.current(),o.kind!=="loading"&&(f.current=!1)),m.current&&!u.current?.contains(document.activeElement)&&O.current?.focus({preventScroll:!0}),o.kind!=="loading"&&(m.current=!1)},[o]);const b=o.kind==="page"?o.page:null,x=b??(o.kind==="notice"?null:p.current),Q=x&&x.rows.length>0?Pqe(x,c):null,w=b??(o.kind==="error"?p.current:null),S=w?Tqe(w):null,_=b?.clippedRows.length??0,k=Q!==null&&o.kind!=="error",R=k&&b!==null&&S!==null&&S.lines.length>0,E=o.kind==="loading"?Xqe():o.kind==="error"?Rqe():o.kind==="notice"?Rue(o.notice):S&&S.lines.length===0?Eqe():"";return d.jsxs("div",{ref:u,"data-diff-history":"","aria-busy":o.kind==="loading",children:[d.jsxs("nav",{ref:O,tabIndex:-1,"aria-label":qqe(),className:X("flex flex-wrap items-baseline gap-x-3 gap-y-1 text-ink-dim focus:outline-none","sticky top-0 z-10 -mx-3 -mt-3 mb-2 bg-sunken px-3 pt-3 pb-1"),children:[k&&d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:Mu,"aria-disabled":!a.canPrev,onClick:g(a.canPrev,a.first),children:jqe()}),d.jsx("button",{type:"button",className:Mu,"aria-disabled":!a.canPrev,onClick:g(a.canPrev,a.prev),children:nI()})]}),d.jsx("span",{"data-diff-history-range":"","aria-live":"polite",children:Q?rI(Q.first,Q.last,Q.total):null}),k&&d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:Mu,"aria-disabled":!a.canNext,onClick:g(a.canNext,a.next),children:iI()}),d.jsx("button",{type:"button",className:Mu,"aria-disabled":!a.canNext,onClick:g(a.canNext,a.last),children:Cqe()})]}),d.jsx("button",{type:"button",className:X(Mu,"ms-auto"),onClick:r,children:zqe()})]}),d.jsx("output",{"data-diff-history-status":"",className:"block text-ink-dim",children:E}),o.kind==="error"&&d.jsx("button",{type:"button",className:Mu,onClick:g(!0,a.retry),children:Aqe()}),S?.hunkHeader&&d.jsx("span",{"data-diff-hunk-context":"",className:X(tz.hunk,"block"),children:S.hunkHeader}),S?.lines.map(T=>d.jsxs("span",{"data-diff-line":T.index,className:X(tz[T.kind],"block"),children:[T.text,T.continued&&d.jsxs("span",{className:"text-ink-dim","data-diff-continued":"",children:[" ",Uqe()]}),T.continues&&d.jsxs("span",{className:"text-ink-dim","data-diff-continues":"",children:[" ",Wqe()]}),T.clipped&&d.jsxs("span",{className:"text-ink-dim","data-diff-clipped":"",children:[" ",Nqe()]})]},T.index)),_>0&&d.jsx("span",{className:"mt-2 block text-ink-dim",children:Yqe(_)}),R&&Q&&d.jsxs("div",{"data-diff-history-foot":"",className:"mt-2 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-ink-dim",children:[d.jsx("button",{type:"button",className:Mu,"aria-disabled":!a.canPrev,onClick:g(a.canPrev,a.prev),children:nI()}),d.jsx("span",{children:rI(Q.first,Q.last,Q.total)}),d.jsx("button",{type:"button",className:Mu,"aria-disabled":!a.canNext,onClick:g(a.canNext,a.next),children:iI()})]})]})},aee="group/diff-toggle block w-full cursor-pointer bg-sunken text-start text-ink-dim underline underline-offset-2 transition-colors duration-fast ease-out-quart hover:text-ink focus-visible:outline-none",_3t=({line:e,index:t})=>d.jsx("span",{"data-diff-line":t,className:X(tz[e.kind],"block"),children:e.text}),k3t=({diff:e,truncatedRows:t=0,history:n,className:r})=>{const[i,a]=$.useState(!1),[o,s]=$.useState(!1),l=e.length===0&&!!n?.descriptor,c=t>0||l,u=c?n?.descriptor??null:null,O=u?.state==="archived"&&n?.scope?n:null,[f,p]=$.useState(null),m=O&&!f?O:null,g=f??(u&&u.state!=="archived"?u.state:null),y=$.useId(),v=$.useRef(null),b=$.useRef(null),x=$.useRef(null),Q=$.useRef(null),w=Mqe(e,{expanded:i}),S=Xue(e),_=l?2:S;$.useLayoutEffect(()=>{const R=x.current;if(R)if(x.current=null,i){const E=v.current?.querySelector(`[data-diff-line="${Lqe}"]`);if(E){const T=E.getBoundingClientRect().top-R.scroller.getBoundingClientRect().top;R.scroller.scrollTop+=T-R.top}}else v.current?.scrollIntoView({block:"nearest"})},[i]);const k=()=>{const R=v.current?.closest("[data-lo-canonical-transcript]");R&&b.current&&(x.current={scroller:R,top:b.current.getBoundingClientRect().top-R.getBoundingClientRect().top}),a(E=>!E)};return d.jsxs("div",{id:y,ref:v,className:X("rounded-md bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",i||o?"overflow-x-clip":X("overflow-y-auto overflow-x-hidden",c?g&&!f?"max-h-[776px]":"max-h-[758px]":"max-h-[740px]"),r),children:[o&&O?.scope&&d.jsx(Q3t,{scope:O.scope,callId:O.callId,headerRows:l?void 0:S,onNotice:p,onBack:()=>{s(!1),requestAnimationFrame(()=>{v.current?.scrollIntoView({block:"nearest"}),(Q.current??b.current)?.focus({preventScroll:!0})})}}),(!o||f)&&(w.withheld?d.jsx("span",{className:"block text-ink-dim",children:Fqe()}):w.lines.map((R,E)=>d.jsx(_3t,{line:R,index:E},E))),!o&&!w.withheld&&c&&(m?d.jsx("button",{type:"button",ref:Q,"data-diff-view-full":"",onClick:()=>s(!0),className:aee,children:d.jsx("span",{className:"block group-focus-visible/diff-toggle:outline group-focus-visible/diff-toggle:outline-2 group-focus-visible/diff-toggle:outline-accent group-focus-visible/diff-toggle:outline-offset-[-2px]",children:Bqe(u?.state==="archived"?Math.max(0,u.rows-_):0)})}):d.jsxs(d.Fragment,{children:[t>0&&!f&&d.jsx("span",{className:"block text-ink-dim",children:Hqe(t)}),g&&d.jsx("span",{"data-diff-full-notice":g,className:"block text-ink-dim",children:Rue(g)})]})),(!o||f)&&w.expandable&&!m&&d.jsx("button",{type:"button",ref:b,"aria-expanded":i,"aria-controls":y,onClick:k,className:X(aee,"sticky -mb-3 pb-3",i?"bottom-0":"-bottom-3"),children:d.jsx("span",{className:"block group-focus-visible/diff-toggle:outline group-focus-visible/diff-toggle:outline-2 group-focus-visible/diff-toggle:outline-accent group-focus-visible/diff-toggle:outline-offset-[-2px]",children:i?Kqe():Jqe(w.hidden)})})]})},P3t=(e,t=72)=>{let i=e.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim();if(i.length>t){const a=i.slice(0,t),o=a.lastIndexOf(" ");i=`${a.slice(0,o>32?o:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},oee=e=>e.startsWith("file://")?e.slice(7):e,T3t={READ:{verb:"ui.chat.trace.action.read.settled",runningVerb:"ui.chat.trace.action.read.running",icon:gOe},WRITE:{verb:"ui.chat.trace.action.write.settled",runningVerb:"ui.chat.trace.action.write.running",icon:VA},EDIT:{verb:"ui.chat.trace.action.edit.settled",runningVerb:"ui.chat.trace.action.edit.running",icon:rAe},CODE:{verb:"ui.chat.trace.action.code.settled",runningVerb:"ui.chat.trace.action.code.running",icon:yOe},DELEGATE:{verb:"ui.chat.trace.action.delegate.settled",runningVerb:"ui.chat.trace.action.delegate.running",icon:vAe},DONE:{verb:"ui.chat.trace.action.done.settled",runningVerb:"ui.chat.trace.action.done.running",icon:CA},ASK:{verb:"ui.chat.trace.action.ask.settled",runningVerb:"ui.chat.trace.action.ask.running",icon:Zp},BYE:{verb:"ui.chat.trace.action.bye.settled",runningVerb:"ui.chat.trace.action.bye.running",icon:vze}},X3t={verb:"ui.chat.trace.action.fallback.settled",runningVerb:"ui.chat.trace.action.fallback.running",icon:yOe},R3t=(e,t,n,r)=>{const i=e?T3t[e]:X3t;let a;if(t)a=oee(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=oee(s[0]):s.length>1&&(a=h("ui.chat.trace.object.file_count",{count:s.length}))}const o=!a&&r?P3t(r):"";return{verb:h(i.verb),runningVerb:h(i.runningVerb),object:a,narration:o||void 0,icon:i.icon}},see="min-h-5 py-0",E3t=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>d.jsxs("span",{className:X("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[d.jsx(v3t,{className:X(a?"text-danger":"text-ink-dim",o&&Bde),children:e}),d.jsxs("span",{className:X(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[d.jsxs("span",{...U2,className:X("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?d.jsxs("span",{...U2,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?d.jsxs("span",{...U2,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),lee=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:a=!1,defaultOpen:o=!1,details:s,className:l,verbOverride:c,object:u,glyph:O,wrap:f,dense:p=!1})=>{const m=R3t(e,t,n,r),g=c??(i?m.runningVerb:m.verb),y=a?nu:m.icon,v=a||!c||!O?d.jsx(y,{}):O,b=d.jsx(E3t,{icon:v,verb:g,object:c?u:m.object,narration:c?r:m.narration,running:i,failed:a,wrap:f}),x=f?"firstLine":"center";return s?d.jsx(zi,{summary:b,chevron:"leading",summaryAlign:x,defaultOpen:o,className:l,rowClassName:p?see:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):d.jsx(zi,{disabled:!0,summary:b,summaryAlign:x,className:l,rowClassName:p?see:void 0})};function qi(e){return e.normalize("NFKC").trim().replace(/\s+/g," ").toLocaleLowerCase()}function RN(e,t,n){const r=e.trim(),i=t.trim();return r===""||qi(r)===qi(i)?n.unnamed(i):n.named(r,i)}const Vy="all";function O$n(e){return e}function d$n(e){return e===Vy?Vy:e}function nz(e){return e.kind==="agent"?CN(e.display_label,null):ZP(e.display_label)}function q3t(e,t){const n=e.name?.trim();if(n)return n;const r=e.members.filter(a=>a.state!=="removed"&&!(a.kind==="human"&&a.account_id===t));if(e.kind==="dm"){const a=r.find(o=>o.state==="active")??r[0];return a?nz(a):null}const i=r.filter(a=>a.state==="active").map(nz).filter(a=>a!==null);return i.length===0?null:i.length<=3?i.join(", "):`${i.slice(0,2).join(", ")} +${i.length-2}`}function f$n(e){return e.discoverable===!0&&e.member===!1}function j3t(e){return e.notify??(e.muted?"mute":"all")}function C3t(e){return j3t(e)==="mute"}function h$n(e){return C3t(e)?"quiet":"attention"}function p$n(e){return e==="mute"?"all":"mute"}const m$n=[{value:"all",labelKey:"ui.teamBridge.agentNotify.all"},{value:"mention",labelKey:"ui.teamBridge.agentNotify.mention"},{value:"mute",labelKey:"ui.teamBridge.agentNotify.mute"}];function L_e(e,t){return t?e.members.find(n=>n.kind==="agent"&&n.account_id===t&&n.state==="active")??null:null}function EN(e){const t=e.notify;return t==="all"||t==="mention"||t==="mute"?t:null}function g$n(e,t){const n=L_e(e,t);return n?{notify:EN(n)}:void 0}function $$n(e,t,n){const r=L_e(t,n),i=r?EN(r):null;return i===null?e:z3t(e,{conversationId:t.id,tenantId:t.tenant_id},n,i)}function z3t(e,t,n,r){return{...e,conversations:e.conversations.map(i=>i.id===t.conversationId&&i.tenant_id===t.tenantId?{...i,members:i.members.map(a=>a.kind==="agent"&&a.account_id===n&&a.state==="active"?{...a,notify:r}:a)}:i)}}function y$n(e,t,n,r,i){return{...e,conversations:e.conversations.map(a=>a.id===t.conversationId&&a.tenant_id===t.tenantId?{...a,members:a.members.map(o=>{if(o.kind!=="agent"||o.account_id!==n||o.state!=="active"||EN(o)!==r)return o;if(i!==null)return{...o,notify:i};const{notify:s,...l}=o;return l})}:a)}}const v$n=[{value:"all",labelKey:"ui.teamBridge.notify.all"},{value:"mention",labelKey:"ui.teamBridge.notify.mention"},{value:"mute",labelKey:"ui.teamBridge.notify.mute"}];function b$n(e){return e==="mention"||e==="mute"?e:"all"}function w$n(e,t,n,r){return{...e,conversations:e.conversations.map(i=>i.id===t&&(!r||i.tenant_id===r)?{...i,notify:n,muted:n==="mute"}:i)}}function x$n(e){return e.kind==="channel"&&e.status==="open"&&!e.builtin&&e.can_administer===!0}function S$n(e){return e.kind==="channel"&&e.status==="archived"&&!e.builtin&&e.can_administer===!0}const F_e=(e,t,n)=>e.id===t&&(!n||e.tenant_id===n);function Q$n(e,t,n){return{...e,conversations:e.conversations.filter(r=>!F_e(r,t,n))}}function _$n(e,t,n,r){return{...e,conversations:e.conversations.map(i=>F_e(i,t,r)?{...i,status:n}:i)}}function k$n(e,t){const n=new Set(e.map(r=>r.id));return[...e,...t.filter(r=>!n.has(r.id))]}function P$n(e){return e.filter(t=>t.kind==="channel"&&t.status==="archived")}function T$n(e){return typeof e=="object"&&e!==null&&e.code==="not_a_member"}function X$n(e,t,n=[]){const r=Y3t(e,n).channels,i=r.findIndex(l=>l.id===t),a=i>=0?r[i+1]??r[i-1]:cee(r,n),o=e.filter(l=>l.id!==t),s=a&&a.id!==t?a:cee(o,n);return s?{type:"conversation",id:s.id}:null}function R$n(e,t){const n=new Set(e.conversations.map(r=>r.id));return{...t,conversations:[...e.conversations,...t.conversations.filter(r=>!n.has(r.id))]}}function E$n(e,t){return e.isError&&e.variables?.conversationId===t}function q$n(e){return e.members.length>0?e.members.filter(t=>t.state==="active").length:e.member_count??0}function j$n(e){let t=0,n=0;for(const r of e.members)r.state==="active"&&(t+=1),r.state==="invited"&&(n+=1);return{active:t,invited:n}}function A3t(e){return[...e].sort((t,n)=>t.seq-n.seq)}function C$n(e,t=[],n){const r=new Map(t.map(l=>[l.tenant_id,l.unread])),i=e.filter(l=>l.status==="active");if(!n)return i.map(l=>({tenantId:l.tenant_id,name:l.tenant_name,role:l.role,unread:r.get(l.tenant_id)??0}));const a=new Map(i.map(l=>[l.tenant_id,l])),o=new Set,s=[];for(const l of n){if(o.has(l.tenant_id))continue;o.add(l.tenant_id);const c=a.get(l.tenant_id);s.push({tenantId:l.tenant_id,name:l.tenant_name?.trim()||c?.tenant_name?.trim()||l.tenant_id,role:c?.role??"",unread:r.get(l.tenant_id)??0})}return s}function z$n(e,t,n,r){if(n)return t;if(e.length===1)return e[0].tenantId;if(e.length>1)return Vy;const i=new Set((r??[]).map(a=>a.tenant_id));return t===Vy&&i.size===1?[...i][0]:t}function A$n(e,t){return e.find(n=>n.tenantId===t)??null}function qN(e){const t=n=>{const r=Date.parse(n);return Number.isNaN(r)?Number.NEGATIVE_INFINITY:r};return[...e].sort((n,r)=>{const i=t(r.last_message_at)-t(n.last_message_at);return i!==0?i:n.id.localeCompare(r.id)})}function U$n(e){return e?.status?.tenants??null}function W$n(e,t){return e!==null?{pending:!1,failed:!1}:{pending:t.isLoading,failed:t.isError}}function U3t(e,t){return t.find(n=>n.tenantId===e.tenant_id)?.name??null}function N$n(e,t,n){return t!==Vy?[...e]:qN(e).filter(r=>U3t(r,n)!==null)}function Y$n(e){return e?e.state==="signed_out"?"signed_out":e.state==="update_required"||e.update_required?"update_required":e.state==="unavailable"?"unavailable":e.surface_state==="A"?"plan_required":e.state!=="ready"?null:e.surface_state==="E"?"off":(e.surface_state==="C"||e.surface_state==="D")&&e.local?.enabled===!1?"off_local":null:null}function Vx(e){return e.display_label.trim()||e.account_id}function G$n(e){const t=e,n=typeof t?.status=="number"?t.status:null,r=typeof t?.code=="string"?t.code:null;return n===401?"sign_in":n===403&&r==="bridge_not_available"?"plan":n===403?"refused":n===422||r==="invalid_request"?"invalid":n===400||n===404||t?.name==="ZodError"?"outdated":n===null?"unreachable":"server"}function W3t(e,t){return t&&e.account_id===t?"self":e.bridge_enabled&&(e.bridge_state==="active"||e.bridge_state==="paused")?e.bridge_state==="paused"?"paused":"openable":"unavailable"}function rz(e,t,n){const r=e.filter(i=>i.kind!=="dm"||i.status==="archived"||!i.members.some(o=>o.kind==="human"&&o.account_id===t&&o.state!=="removed")?!1:n?i.members.some(o=>o.kind==="human"&&o.account_id===n&&o.state!=="removed"):!0);return r.length===0?null:qN(r)[0]??null}function I$n(e){return e.trim().charAt(0).toUpperCase()||"?"}function N3t(e,t){const n=[];for(const r of e){if(t&&r.account_id===t)continue;const i=r.agent;!i||i.state==="disabled"||n.push({person:r,endpointId:i.endpoint_id,agentName:i.name.trim(),paused:i.state==="paused"})}return n}function iz(e,t,n){const r=e.filter(i=>i.kind==="dm"&&i.status!=="archived"&&i.members.some(a=>a.kind==="agent"&&a.account_id===t&&a.state!=="removed")&&(!n||i.members.some(a=>a.kind==="human"&&a.account_id===n&&a.state!=="removed")));return r.length===0?null:qN(r)[0]??null}const az=["general","humans","agents"];function B_e(e,t,n){const r=az.indexOf(e.builtin)-az.indexOf(t.builtin);if(r!==0)return r;const i=o=>{const s=n.indexOf(o);return s<0?Number.POSITIVE_INFINITY:s},a=i(e.tenant_id)-i(t.tenant_id);return a!==0&&!Number.isNaN(a)?a:e.tenant_id.localeCompare(t.tenant_id)}function cee(e,t=[]){const n=r=>e.filter(i=>i.builtin===r).sort((i,a)=>B_e(i,a,t))[0];return n("general")??n("humans")??e[0]}function Z$n(e){switch(e){case"general":return"ui.teamBridge.builtin.general_topic";case"humans":return"ui.teamBridge.builtin.humans_topic";case"agents":return"ui.teamBridge.builtin.agents_topic";default:return null}}function Y3t(e,t=[]){const n=[],r=[],i=[],a=[];for(const o of e)o.kind==="channel"?o.builtin&&az.includes(o.builtin)?n.push(o):r.push(o):o.kind==="group"?i.push(o):a.push(o);return n.sort((o,s)=>B_e(o,s,t)),{channels:[...n,...r],groups:i,directs:a}}function D$n(e,t,n,r){const i=new Set;for(const a of t){if(r!==void 0&&a.account_id===r)continue;const o=rz(e,a.account_id,r);o&&i.add(o.id)}for(const a of n){const o=iz(e,a.person.account_id,r);o&&i.add(o.id)}return e.filter(a=>!i.has(a.id))}function V$n(e){return`${e.kind}:${e.accountId}`}function M$n(e,t,n){if(e===null)return null;switch(e.type){case"conversation":return t.find(r=>r.id===e.id)??null;case"person":return rz(t,e.accountId,n);case"chief":return iz(t,e.accountId,n);case"compose":{if(e.recipients.length!==1)return null;const[r]=e.recipients;return r.kind==="agent"?iz(t,r.accountId,n):rz(t,r.accountId,n)}}}function G3t(e){return jN(e.trim())??e}function I3t(e){const t=e.ownerLabel?.trim();if(e.agentName!==void 0&&t){const n=e.agentName.trim();return n!==""&&qi(n)!==qi(t)?n:t}return G3t(e.label)}function Z3t(e){return e.kind==="agent"?{account_id:e.accountId,kind:"agent",endpoint_id:e.endpointId,display_label:I3t(e).slice(0,64)}:{account_id:e.accountId,kind:"human",display_label:e.label.slice(0,64)}}function L$n(e,t,n){const r=e.filter(a=>{const o=W3t(a,t);return o==="openable"||o==="paused"}).map(a=>({kind:"human",accountId:a.account_id,label:Vx(a)})),i=N3t(e,t).map(a=>({kind:"agent",accountId:a.person.account_id,endpointId:a.endpointId,agentName:a.agentName,ownerLabel:Vx(a.person),label:RN(a.agentName,Vx(a.person),n)}));return[...r,...i]}function F$n(e){if(e.length===0)return null;const t=e.map(Z3t);return{kind:e.length===1?"dm":"group",visibility:"private",agentCapable:e.some(n=>n.kind==="agent"),members:t}}const D3t="Member";function ZP(e){const t=e.trim();return t===""||t===D3t?null:t}const WQ={"(":")","(":")"},H_e=256;function V3t(e,t){if(e.length>H_e)return null;const n=qi(t);if(n==="")return null;for(let r=0;r<e.length;r+=1){const i=WQ[e[r]];if(i===void 0||!e.endsWith(i))continue;const a=e.slice(r+1,e.length-i.length),o=e.slice(0,r).trim();if(o!==""&&qi(a)===n)return o}return null}function M3t(e){const t=new Set(Object.values(WQ)),n=[];for(const r of e){const i=WQ[r];if(i!==void 0)n.push(i);else if(t.has(r)&&n.pop()!==r)return!1}return n.length===0}function jN(e){if(e.length>H_e)return null;for(let t=0;t<e.length;t+=1){const n=WQ[e[t]];if(n===void 0||!e.endsWith(n))continue;const r=e.slice(t+1,e.length-n.length),i=e.slice(0,t).trim();if(i!==""&&M3t(r)&&qi(i)===qi(r))return i}return null}const K_e=["'s chief of staff","’s chief of staff"],L3t=64;function F3t(e){const t=e.replace(/[\s\u0085]+/gu," ").trim(),n=new TextEncoder().encode(t);let r=L3t-K_e[0].length;if(n.length<=r)return t;for(;r>0&&(n[r]&192)===128;)r-=1;return new TextDecoder().decode(n.subarray(0,r)).trim()}function CN(e,t){const n=ZP(e);if(n===null||t!==null&&qi(n)===qi(t)||t!==null&&[t,F3t(t)].some(r=>K_e.some(i=>qi(n)===qi(`${r}${i}`))))return null;if(t!==null){const r=V3t(n,t);if(r!==null)return qi(r)===qi(t)?null:r}return jN(n)!==null?null:n}function J_e(e,t){const n=nz(e);if(n!==null||e.kind!=="agent")return n;const r=ZP(e.display_label),i=r===null?null:jN(r);return i===null?null:t.unnamed(i)}function B$n(e,t){const n=e.ownerLabel.trim();return n===""?J_e({kind:"agent",display_label:e.label},t):RN(CN(e.label,n)??"",n,t)}function H$n(e,t,n,r){const i=t.find(l=>l.account_id===e.account_id),a=i?Vx(i):null;if(e.kind==="human"){const l=ZP(e.display_label),c=r&&r.accountId===e.account_id&&r.name.trim()||null;return a??c??l}const o=i?.agent?.name.trim()??"",s=o!==""&&(a===null||qi(o)!==qi(a))?o:CN(e.display_label,a);return a?RN(s??"",a,n):s??J_e({kind:"agent",display_label:e.display_label},n)}const B3t=5*6e4;function MR(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function K$n(e,t){const n=MR(t),r=MR(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1)),i=[];let a=null,o=null;for(const s of A3t(e)){const l=new Date(s.created_at),c=!Number.isNaN(l.getTime()),u=c?MR(l):null;u!==null&&u!==o&&i.push({type:"day",key:u,date:l,relative:u===n?"today":u===r?"yesterday":null});const O=a!==null&&c&&u===o&&a.sender.account_id===s.sender.account_id&&a.sender.kind===s.sender.kind&&l.getTime()-Date.parse(a.created_at)<B3t;i.push({type:"message",message:s,continuation:O}),a=s,u!==null&&(o=u)}return i}const uee="Team Bridge create answered for another tenant",LR=new WeakMap;async function J$n(e){if(LR.get(e.remembered)?.has(e.draftKey))throw new Error(uee);let t=e.remembered.get(e.draftKey);if(t===void 0){const n=await e.create(e.input);if(!n.id)throw new Error("create returned no conversation id");if(e.tenantId!==void 0&&typeof n.tenant_id=="string"&&n.tenant_id!==e.tenantId){const r=LR.get(e.remembered)??new Set;throw r.add(e.draftKey),LR.set(e.remembered,r),new Error(uee)}t={id:n.id,tenantId:n.tenant_id??e.tenantId},e.remembered.set(e.draftKey,t)}return e.onCreated?.(t),await e.post(t.id,{clientRef:e.clientRef,body:e.body,tenantId:t.tenantId}),e.remembered.delete(e.draftKey),t}const H3t=["channel","here","everyone"];function eyn(e){const{body:t,candidates:n,self:r}=e;if(!t||!t.includes("@"))return null;const i=r?[...n,{kind:"human",accountId:r.accountId,label:r.label}]:n,a=c=>r!==null&&c===r.accountId;if(Array.isArray(e.mentions)){const c=[];for(const u of e.mentions){if(!u||typeof u!="object")continue;if(u.kind==="channel"){const f=H3t.find(p=>eke(t,[{label:p,viewer:!1}],!0).some(m=>m.kind==="mention"));f&&c.push({label:f,viewer:!1});continue}const O=i.find(f=>f.kind===u.kind&&f.accountId===u.account_id);O&&O.label!==""&&c.push({label:O.label,viewer:a(u.account_id)})}return c.length>0?{source:"message",runs:c,caseSensitive:!0}:null}const o=c=>r!==null&&r.labelUnique===!0&&c.kind==="human"&&c.accountId===r.accountId&&!n.some(u=>u.accountId!==r.accountId&&qi(u.label)===qi(c.label)),s=new Map;for(const c of i)c.label===""||!t.includes(`@${c.label}`)||s.set(c.label,(s.get(c.label)??!1)||o(c));const l=[...s].map(([c,u])=>({label:c,viewer:u}));return l.length>0?{source:"fallback",runs:l,caseSensitive:!0}:null}const Oee=/[\p{L}\p{N}_]/u;function eke(e,t,n=!0){const r=(l,c)=>n?l===c:l.toLocaleLowerCase()===c.toLocaleLowerCase(),i=[...t].sort((l,c)=>c.label.length-l.label.length),a=[];let o="",s=0;for(;s<e.length;){const l=s===0?"":e.charAt(s-1),c=e.charAt(s)==="@"&&!Oee.test(l)&&l!=="."?i.find(O=>{const f=s+1+O.label.length;return r(e.slice(s+1,f),O.label)&&!Oee.test(e.charAt(f))}):void 0;if(!c){o+=e.charAt(s),s+=1;continue}o&&a.push({kind:"text",text:o}),o="";const u=s+1+c.label.length;a.push({kind:"mention",text:e.slice(s,u),viewer:c.viewer}),s=u}return o&&a.push({kind:"text",text:o}),a}const K3t="team-bridge-mention rounded-sm px-0.5 font-medium bg-accent-wash text-accent",J3t="team-bridge-mention rounded-sm px-0.5 font-medium bg-warning-wash text-warning";function e7t(e){return()=>t=>{_k(t,"text",(n,r,i)=>{if(!i||r===void 0||!n.value.includes("@"))return;const a=eke(n.value,e);if(a.some(o=>o.kind==="mention"))return i.children.splice(r,1,...a.map(o=>o.kind==="text"?{type:"text",value:o.text}:{type:"mention",data:{hName:"span",hProperties:{className:o.viewer?J3t:K3t,"data-mention":o.viewer?"viewer":"other"}},children:[{type:"text",value:o.text}]})),r+a.length})}}const t7t=/^(https?:|mailto:)/i,n7t={a:({href:e,children:t})=>typeof e=="string"&&t7t.test(e)?d.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:t}):d.jsx("span",{className:"font-mono text-mono-sm",children:t}),img:({alt:e,src:t})=>d.jsx("span",{className:"text-ink-muted",children:e||(typeof t=="string"?t:"")}),table:z8},tke=$.memo(({children:e,className:t,mentions:n,style:r})=>{const i=$.useMemo(()=>n?.length?[cs,e7t(n)]:[cs],[n]);return d.jsx("div",{className:X("lo-markdown",t),style:r,children:d.jsx(ly,{remarkPlugins:i,components:n7t,children:e})})});tke.displayName="TeamBridgeMarkdown";const nke=8,r7t="… deeper values not shown",i7t="(empty)";function a7t(e){return`… ${e} more line${e===1?"":"s"}`}const dee=.5;function o7t(e,t,n,r){if(!Number.isFinite(t)||t<=0)return 0;let i=0;for(const a of e){if(a.height<=0)continue;const o=Math.max(1,Math.round(a.height/t));for(let s=1;s<=o;s++)a.top+s*t>n+r&&i++}return i}function rke(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function zN(e){return typeof e=="object"&&e!==null}function ike(e,t,n,r){if(n>nke){r.push({key:t,value:r7t,depth:n});return}if(zN(e)){for(const[a,o]of Object.entries(e))ike(o,t?`${t}.${a}`:a,n+1,r);return}const i=rke(e);i!==null&&r.push({key:t,value:i,depth:n})}function ake(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))ike(r,n,1,t);return t}const s7t=512;function l7t(e,t){if(t)return!0;if(!e)return!1;let n=s7t;const r=(i,a)=>{if(n--<=0||a>nke)return!0;if(!zN(i))return rke(i)!==null;for(const o of Object.values(i))if(r(o,a+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function c7t(e){if(!e)return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!zN(n))return null;const r=ake(n);return r.length>0?r:[{key:"",value:i7t,depth:1}]}const u7t=8,My="max-h-[min(320px,40vh)]",oke=My,ske=({line:e})=>d.jsxs("div",{className:X("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*u7t},children:[e.key?d.jsxs("span",{className:X("text-ink-muted"),children:[e.key,": "]}):null,d.jsx("span",{className:X("text-ink-dim"),children:e.value})]}),fee=({lines:e,section:t})=>d.jsx("div",{className:X("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>d.jsx(ske,{line:n},r))});function hee(e){const[t,n]=$.useState(0),[r,i]=$.useState(!1);return $.useLayoutEffect(()=>{const a=e.current;if(!a)return;const o=a.firstElementChild,s=()=>{const c=o??a,u=Number.parseFloat(getComputedStyle(c).lineHeight);if(!Number.isFinite(u)||u<=0){n(0),i(!1);return}const O=a.getBoundingClientRect(),f=c.getBoundingClientRect();i(f.height>O.height+dee);const p=c.children.length>0?Array.from(c.children):[c];n(o7t(p.map(m=>{const g=m.getBoundingClientRect();return{top:g.top,height:g.height}}),u,O.bottom,dee))};s(),a.addEventListener("scroll",s,{passive:!0});const l=new ResizeObserver(s);return l.observe(o??a),()=>{a.removeEventListener("scroll",s),l.disconnect()}}),{lines:t,overflowing:r}}const pee=({lines:e,overflowing:t})=>t?d.jsx("span",{className:X("mt-1 block text-ink-dim"),children:e>0?a7t(e):" "}):null,O7t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{be();const a=ake(e),o=c7t(t),s=$.useRef(null),l=$.useRef(null),c=hee(s),u=hee(l);return a.length===0&&!t&&!i?null:d.jsxs("div",{className:X("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),children:[a.length>0&&d.jsxs("div",{"data-detail-section":"input",children:[d.jsx("div",{ref:s,className:X(My,"overflow-auto"),children:d.jsx(fee,{lines:a,section:"input"})}),d.jsx(pee,{lines:c.lines,overflowing:c.overflowing})]}),i&&d.jsx("div",{className:X("whitespace-normal font-sans text-body-sm text-ink-muted",a.length>0&&"mt-3"),"data-detail-section":"note",children:i}),t&&d.jsxs("div",{className:X(a.length>0&&"mt-3"),"data-detail-section":"output",children:[d.jsx("span",{className:X("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?h("ui.chat.canonical.tool_row.detail_section.interrupted"):n?h("ui.chat.canonical.tool_row.detail_section.error"):h("ui.chat.canonical.tool_row.detail_section.output")}),d.jsx("div",{ref:l,className:X(My,"overflow-auto"),children:o?d.jsx(fee,{lines:o,section:"result-json"}):d.jsx("pre",{className:X("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),d.jsx(pee,{lines:u.lines,overflowing:u.overflowing})]})]})},lke=({view:e,isError:t,note:n=null,children:r})=>{const i=n??e.outcome,a=e.internals.length>0||!!e.raw;return d.jsxs("div",{className:X("flex w-full flex-col gap-2 rounded-md bg-sunken p-3 font-sans text-body-sm"),"data-bridge-detail":"",children:[e.headline?d.jsx("div",{className:X("font-medium text-ink"),"data-detail-section":"bridge-target",children:e.headline}):null,e.body?d.jsx("div",{className:X(My,"overflow-auto text-ink"),"data-detail-section":"bridge-body",children:d.jsx(tke,{children:e.body})}):null,i?d.jsx("div",{className:X("whitespace-normal",t?"text-danger":"text-ink-muted"),"data-detail-section":"bridge-outcome",children:i}):null,r,a?d.jsx(zi,{chevron:"trailing",chevronClassName:"text-ink-dim",summary:d.jsx("span",{className:X("text-ink-dim text-meta"),children:h("ui.chat.canonical.tool_row.bridge.detail.details")}),triggerData:{"data-detail-section":"bridge-details"},children:d.jsxs("div",{className:X(My,"overflow-auto pt-1 font-mono text-mono-sm"),children:[e.internals.map(o=>d.jsx(ske,{line:{key:o.key,value:o.value,depth:1}},o.key)),e.raw?d.jsx("pre",{className:X("mt-2 whitespace-pre-wrap break-words font-mono text-ink-dim"),children:e.raw}):null]})}):null]})},d7t="mcp__",f7t={bash:PAe,read:ey,write:zI,edit:zI,glob:Vp,grep:Yv,todo:m9e,wake:Nf,list_variables:YI,read_variable:YI,browser:AI,console:kOe,project:hze,project_delete:XAe,web_search:AI,web_fetch:dk,task:l$,agent:l$,send:$S,peer:l9e,sessions:oAe,bridge:E9e};function h7t(e){const t=e.trim().toLowerCase(),n=f7t[t];return n||(t.startsWith(d7t)?POe:ZAe)}const p7t=ZA,m7t=b9e,g7t=y9e,$7t=Q9e,y7t=xOe,mee="min-h-5 py-0",gee={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},v7t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?gee.plain:gee[tje(t)],b7t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",w7t=({added:e,removed:t})=>e<=0&&t<=0?null:d.jsxs("span",{className:X("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&d.jsxs("span",{className:X("text-success"),children:["+",e]}),t>0&&d.jsxs("span",{className:X("text-danger"),children:["-",t]})]}),x7t={running:"",success:"ui.chat.canonical.tool_row.outcome.succeeded",error:"ui.chat.canonical.tool_row.outcome.failed",interrupted:"ui.chat.canonical.tool_row.outcome.interrupted","not-run":"ui.chat.canonical.tool_row.outcome.never_ran",partial:"",receipt:""},FR=e=>{const t=x7t[e];return t===""?"":h(t)},S7t=1e3;function Q7t(e){const[t,n]=$.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return $.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,S7t);return()=>window.clearInterval(i)},[e]),t}const _7t=({toolName:e="",outcome:t,deliveryState:n=null,failureWord:r=null,durationS:i,startedAt:a})=>{const o=t==="running",s=Q7t(o?a??null:null),l=t==="error"||t==="not-run",c=t==="partial",u=nje(n,e),O=c?u:l?u??r??FR(t):null,f=c?"text-warning":"text-danger",p=c?rje(n,e):null,m=X("font-medium text-meta",f,c&&(p?"hidden @[40rem]/toolrow:inline":"hidden @[19rem]/toolrow:inline")),g=X("font-medium text-meta",f,"hidden @[20rem]/toolrow:inline @[40rem]/toolrow:hidden"),y=c?ije(n,e):null,v=c?aje(n,e):void 0,b=c?n==="mailbox"?m7t:n==="unconfirmed"?g7t:n==="inbox_only"?$7t:n==="awaiting_acceptance"?y7t:null:t==="interrupted"?p7t:null,x=b&&c?"text-warning":"text-ink-dim",Q=o?a==null?"":_O(s??0):QA(i);return d.jsxs("span",{className:X("flex shrink-0 items-center gap-1.5"),children:[O?d.jsx("span",{className:m,title:v,"aria-hidden":y?!0:void 0,children:O}):null,O&&p?d.jsx("span",{className:g,title:v,"aria-hidden":y?!0:void 0,"data-status-word":"short",children:p}):null,d.jsxs("span",{className:X("flex shrink-0 [&_svg]:size-3.5",b&&"size-3.5",x),children:[b?d.jsx(b,{"aria-hidden":!0}):null,!l&&FR(t)?d.jsx("span",{className:X("sr-only"),children:FR(t)}):null,y?d.jsx("span",{className:X("sr-only"),children:y}):null]}),d.jsx("span",{className:X("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:Q})]})},Hc=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,summaryWrap:o=!1,summaryIsCopy:s=!1,outcome:l,deliveryState:c=null,settledVerb:u=null,failureWord:O=null,durationS:f,startedAt:p=null,added:m=0,removed:g=0,details:y,defaultOpen:v=!1,className:b,media:x})=>{const Q=Fl(),w=l==="running",S=l==="error",_=h7t(e),k=M$(e),{verb:R,object:E}=Eue(e,r,i,w,t,u??eje(c)),T=d.jsxs("span",{className:X("flex min-w-0 flex-1 items-center gap-2"),children:[d.jsx("span",{"aria-hidden":!0,className:X("flex size-3.5 shrink-0 [&_svg]:size-3.5",v7t(l,e)),children:d.jsx(_,{})}),n?null:d.jsx("span",{"data-trace-verb":"",className:X("min-w-0 truncate text-body-sm",b7t(l)),title:`${R} (${k})`,children:R}),d.jsx("span",{className:X(o?"min-w-0 flex-1 break-words whitespace-normal font-mono text-ink-muted text-mono-sm":"min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:E,children:a?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),d.jsx("span",{className:X("sr-only"),children:h("ui.chat.canonical.tool_row.pending")})]}):d.jsx("bdi",{dir:s?Q:"ltr",children:E})}),d.jsx(w7t,{added:m,removed:g}),d.jsx(_7t,{toolName:e,outcome:l,deliveryState:c,failureWord:O,durationS:f,startedAt:p})]}),q=w?{"data-glass-state":"running"}:void 0,A=w?"bg-elevated":S?"bg-danger-wash":"hover:bg-row-hover",G=y?d.jsx(zi,{summary:T,chevron:"leading",defaultOpen:v,className:X("@container/toolrow",b),triggerData:q,rowClassName:mee,triggerClassName:X("-mx-2 rounded-sm px-2",A),children:y}):d.jsx(zi,{disabled:!0,summary:T,triggerData:q,rowClassName:mee,className:X("@container/toolrow",(w||S)&&X("-mx-2 rounded-sm px-2",A),b)});return x?d.jsxs("div",{className:X("flex flex-col"),children:[G,x]}):G},k7t=3,P7t=2;function T7t(e){const t={incoming:0,job_result:0,wake:0,monitor_prompt:0};let n=!1,r=!1;for(const{record:o}of e){const s=que(o);s&&(t[s]+=1),o.kind==="custom"&&(o.receipt?.expectsReply===!0&&(n=!0),o.receipt?.steer===!0&&(r=!0))}const i=[],a=(o,s)=>{o>0&&i.push(s(o))};return a(t.incoming,o=>h("ui.chat.canonical.fold.receipt.incoming",{count:o})),a(t.job_result,o=>h("ui.chat.canonical.fold.receipt.job_result",{count:o})),a(t.wake,o=>h("ui.chat.canonical.fold.receipt.wake",{count:o})),a(t.monitor_prompt,o=>h("ui.chat.canonical.fold.receipt.monitor_prompt",{count:o})),a(e.length-t.incoming-t.job_result-t.wake-t.monitor_prompt,o=>h("ui.chat.canonical.fold.receipt.other",{count:o})),n&&i.push(h("ui.chat.canonical.fold.receipt.reply_requested")),r&&i.push(h("ui.chat.canonical.fold.receipt.steered")),i}const cke=e=>{const t=e.toLowerCase();return t==="read"||t==="grep"||t==="glob"||t==="ls"||t==="list"?"files":t==="search_the_web"||t==="web_search"||t==="search"?"web":t==="bash"||t==="exec"||t==="shell"||t==="run"?"commands":t==="edit"||t==="write"||t==="multiedit"?"edits":t==="task"||t==="delegate"?"delegated":t==="fetch"||t==="web_fetch"||t==="fetch_url"?"searches":null},X7t=(e,t,n)=>{switch(e){case"files":return h("ui.chat.canonical.fold.sentence.files",{count:t});case"searches":return h("ui.chat.canonical.fold.sentence.searches",{count:t});case"web":return n?h("ui.chat.canonical.fold.sentence.web_follow",{count:t}):h("ui.chat.canonical.fold.sentence.web_lead",{count:t});case"commands":return n?h("ui.chat.canonical.fold.sentence.commands_follow",{count:t}):h("ui.chat.canonical.fold.sentence.commands_lead",{count:t});case"edits":return n?h("ui.chat.canonical.fold.sentence.edits_follow",{count:t}):h("ui.chat.canonical.fold.sentence.edits_lead",{count:t});case"delegated":return n?h("ui.chat.canonical.fold.sentence.delegated_follow",{count:t}):h("ui.chat.canonical.fold.sentence.delegated_lead",{count:t})}},uke=()=>h("ui.chat.canonical.fold.unit_separator"),Oke=e=>{const t=new Map;let n=0;for(const o of e){const s=cke(o.name);s===null?n+=1:t.set(s,(t.get(s)??0)+1)}const r=AN(e);if(n>0||t.size>2){const o=dke(r);return{units:o.length===0?[h("ui.chat.canonical.fold.count.actions",{count:e.length})]:o,prose:!1,countUnits:r}}const i=["files","searches","web","commands","edits","delegated"],a=[];for(const o of i){const s=t.get(o)??0;s!==0&&a.push(X7t(o,s,a.length>0))}return a.length===0?{units:[h("ui.chat.canonical.fold.count.actions",{count:e.length})],prose:!0,countUnits:r}:{units:[a.length===1?a[0]:h("ui.chat.canonical.fold.sentence.join",{first:a[0],second:a[1]})],prose:!0,countUnits:r}},R7t=e=>Oke(e).units;function E7t(e){return R7t(e).join(uke())}const BR={agent:{sort:"agent",label:e=>h("ui.chat.canonical.fold.count.agent",{count:e})},team:{sort:"team",label:e=>h("ui.chat.canonical.fold.count.team",{count:e})},team_delete:{sort:"team deletion",label:e=>h("ui.chat.canonical.fold.count.team_delete",{count:e})},hub:{sort:"subagent",label:e=>h("ui.chat.canonical.fold.count.hub",{count:e})},secret:{sort:"secret",label:e=>h("ui.chat.canonical.fold.count.secret",{count:e})},project:{sort:"project",label:e=>h("ui.chat.canonical.fold.count.project",{count:e})},project_delete:{sort:"project deletion",label:e=>h("ui.chat.canonical.fold.count.project_delete",{count:e})},wake:{sort:"wake",label:e=>h("ui.chat.canonical.fold.count.wake",{count:e})},jobs:{sort:"job check",label:e=>h("ui.chat.canonical.fold.count.jobs",{count:e})},console:{sort:"console",label:e=>h("ui.chat.canonical.fold.count.console",{count:e})},network:{sort:"network call",label:e=>h("ui.chat.canonical.fold.count.network",{count:e})},browser:{sort:"browser action",label:e=>h("ui.chat.canonical.fold.count.browser",{count:e})},todo:{sort:"todo update",label:e=>h("ui.chat.canonical.fold.count.todo",{count:e})},send:{sort:"message",label:e=>h("ui.chat.canonical.fold.count.send",{count:e})},ask:{sort:"question",label:e=>h("ui.chat.canonical.fold.count.ask",{count:e})},wait:{sort:"wait",label:e=>h("ui.chat.canonical.fold.count.wait",{count:e})},lsp:{sort:"code lookup",label:e=>h("ui.chat.canonical.fold.count.lsp",{count:e})},web_read:{sort:"page",label:e=>h("ui.chat.canonical.fold.count.web_read",{count:e})},list_variables:{sort:"variable lookup",label:e=>h("ui.chat.canonical.fold.count.list_variables",{count:e})},read_variable:{sort:"variable read",label:e=>h("ui.chat.canonical.fold.count.read_variable",{count:e})},sessions:{sort:"session",label:e=>h("ui.chat.canonical.fold.count.sessions",{count:e})}},HR=5,dke=e=>{if(e.length<=HR)return e.map(r=>r.label);const t=e.slice(0,HR),n=e.slice(HR).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),h("ui.chat.canonical.fold.count.other_actions",{count:n})]},AN=e=>{const t=new Map,n=(o,s)=>{const l=t.get(o);l?l.count+=1:t.set(o,{kind:s,count:1})};for(const o of e){const s=o.name.toLowerCase();if(s==="bash"||s==="exec"||s==="shell"||s==="run"){n("kind:shell",{sort:"shell",label:c=>h("ui.chat.canonical.fold.count.shell",{count:c})});continue}if(s==="eval"){n("kind:python",{sort:"python",label:c=>h("ui.chat.canonical.fold.count.python",{count:c})});continue}const l=cke(o.name);if(l==="files")n("class:files",{sort:"file",label:c=>h("ui.chat.canonical.fold.count.file",{count:c})});else if(l==="searches")n("class:searches",{sort:"search",label:c=>h("ui.chat.canonical.fold.count.search",{count:c})});else if(l==="web")n("class:web",{sort:"web search",label:c=>h("ui.chat.canonical.fold.count.web",{count:c})});else if(l==="edits")n("class:edits",{sort:"edit",label:c=>h("ui.chat.canonical.fold.count.edit",{count:c})});else if(l==="delegated")n("class:delegated",{sort:"task",label:c=>h("ui.chat.canonical.fold.count.task",{count:c})});else if(s==="todo")(o.op??"").toLowerCase()==="view"?n("kind:todo:view",{sort:"todo read",label:c=>h("ui.chat.canonical.fold.count.todo_read",{count:c})}):n("kind:todo",BR.todo);else if(s==="jobs")(o.op??"").toLowerCase()==="cancel"?n("kind:jobs:cancel",{sort:"job cancellation",label:c=>h("ui.chat.canonical.fold.count.jobs_cancel",{count:c})}):n("kind:jobs",BR.jobs);else if(s==="bridge")oje.has((o.op??"").toLowerCase())?n("kind:bridge:post",{sort:"team message",label:c=>`${c} ${c===1?h("ui.chat.canonical.fold.bridge_post.one"):h("ui.chat.canonical.fold.bridge_post.other")}`}):n("kind:bridge",{sort:"team action",label:c=>`${c} ${c===1?h("ui.chat.canonical.fold.bridge.one"):h("ui.chat.canonical.fold.bridge.other")}`});else{const c=BR[s];if(c)n(`kind:${s}`,c);else{const u=M$(o.name);n(`name:${u}`,{sort:u,label:O=>h("ui.chat.canonical.fold.count.named",{count:O,name:u})})}}}const r=["class:files","class:searches","class:web","kind:shell","kind:python","class:edits","class:delegated","kind:agent","kind:team","kind:hub"],i=[];for(const o of r){const s=t.get(o);s&&i.push({key:o,label:s.kind.label(s.count),count:s.count})}const a=[...t.entries()].filter(([o])=>!r.includes(o)).sort(([,o],[,s])=>s.count-o.count||o.kind.sort.localeCompare(s.kind.sort));for(const[o,s]of a)i.push({key:o,label:s.kind.label(s.count),count:s.count});return i};function q7t(e){return e.running===!0?typeof e.startedAtMs!="number"?null:{startMs:e.startedAtMs,endMs:null}:typeof e.endedAtMs!="number"||typeof e.durationS!="number"?null:{startMs:e.endedAtMs-e.durationS*1e3,endMs:e.endedAtMs}}function j7t(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=q7t(i);a&&(t=t===null?a.startMs:Math.min(t,a.startMs),a.endMs!==null&&(n=n===null?a.endMs:Math.max(n,a.endMs)))}return t===null||n===null&&!r?null:{startedAtMs:t,endedAtMs:n,running:r}}function C7t(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return Eue(n.name,n.summary??"",null,!0,n.op)}return null}function z7t(e,t){let n=0;for(let r=e.length-1;r>=0&&t(e[r]);r-=1)n+=1;return n}function A7t(e,t){const n=[];let r=[];const i=()=>{if(r.length===0)return;const a=r.filter(O=>t.isReceipt?.(O)),o=r.filter(O=>t.isFoldable(O)).map(O=>{const f={name:t.nameOf(O),failed:t.failedOf(O),durationS:t.durationOf?t.durationOf(O):null,startedAtMs:t.startedAtOf?t.startedAtOf(O):null,endedAtMs:t.endedAtOf?t.endedAtOf(O):null};return t.summaryOf&&(f.summary=t.summaryOf(O)),t.opOf&&(f.op=t.opOf(O)),t.runningOf&&(f.running=t.runningOf(O)),t.executingOf&&(f.executing=t.executingOf(O)),f}),s=a.length?t.receiptSummaryOf?.(a)??[]:[],l=s.length>0?s:a.length>0?[`${a.length} receipt${a.length===1?"":"s"}`]:[],c=t.isReceipt?z7t(r,t.isReceipt):0,u=t.liveTurn===!0&&t.latchedFoldIds!==void 0&&r.some(O=>t.latchedFoldIds?.has(O.record.id)===!0);if(o.length>=k7t||c>=P7t||u){const O=(()=>{if(o.length===0)return{units:[],prose:!1,countUnits:[]};const f=AN(o);return l.length>0?{units:dke(f),prose:!1,countUnits:f}:Oke(o)})();n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:o,summary:{units:[...O.units,...l],prose:O.prose,countUnits:O.countUnits},failedCount:o.filter(f=>f.failed).length,span:j7t(o),live:C7t(o)})}else for(const O of r)n.push({kind:"row",row:O});r=[]};for(const a of e){if((a.gap==="turn"||a.gap==="first")&&i(),t.isFoldable(a)||t.isReceipt?.(a)){r.push(a);continue}i(),n.push({kind:"row",row:a})}return i(),n}function U7t(e,t,n){const r=new Set;for(const i of e)t.has(i)&&r.add(i);for(const i of n)if(i.kind==="run")for(const a of i.rows)r.add(a.record.id);return r}const $ee=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&que(n.record)==="incoming")))for(const r of n.record.images??[])Yp(r)&&t.push(r);return t},Mx=5,W7t=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<Mx?{shown:Math.max(e,0),more:0}:{shown:Mx-1,more:e-(Mx-1)},N7t=e=>{const t=Mx-1;if(e<=0)return[];if(e<=t)return[e];const n=Array.from({length:Math.floor(e/t)},()=>t),r=e%t;return r===1?(n[n.length-1]=t-1,n.push(2)):r>1&&n.push(r),n},NQ=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function YQ(e){return e.record.kind==="tool"?e.record.durationS:null}function fke(e){let t=null;for(const n of e){const r=YQ(n);typeof r=="number"&&(t=(t??0)+r)}return t}function Y7t(e,t){const n=new Map,r=t.opensRun??(l=>l.gap==="turn"||l.gap==="first");let i=0,a=0,o=null,s=null;for(const l of e){if(r(l)&&(i=0,a=0,o=null,s=null),t.isAction(l)){i+=1,t.failedOf(l)&&(a+=1,s??=l.record.id);const c=t.durationOf?t.durationOf(l):null;typeof c=="number"&&(o=(o??0)+c)}l.closesTurn&&n.set(l.record.id,{actions:i,failed:a,durationS:o,firstFailedId:s})}return n}const G7t="min-h-5 py-0",I7t=(e,t)=>e.map(n=>t==="rtl"?`${n}`:n).join(uke()),Z7t=1e3;function D7t(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,Z7t);return()=>window.clearInterval(i)},[e]),t}const V7t=({summary:e,span:t,live:n,open:r,onOpenChange:i,className:a,condensedMedia:o,mediaCount:s=0,recordIds:l,children:c})=>{const u=Fl(),O=D7t(t?.running===!0),f=t===null?null:Math.max(0,((t.running?O:t.endedAtMs??O)-t.startedAtMs)/1e3),p=f===null?"":QA(f),m=$.useRef(null),g=()=>{m.current?.querySelector("button[aria-expanded]")?.focus(),i(!0)};return d.jsxs("div",{ref:m,className:a,"data-fold-ids":l.join(" "),children:[d.jsx(zi,{animate:r||!o,open:r,onOpenChange:i,rowClassName:G7t,triggerClassName:X("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:d.jsxs("span",{className:X("flex min-w-0 flex-1 items-center gap-2"),children:[n!==null&&!r&&d.jsxs(d.Fragment,{children:[d.jsxs("span",{"data-fold-live":"",className:X("min-w-0 shrink-[100000] truncate"),title:`${n.verb} ${n.object}`,children:[d.jsx("span",{className:X("text-accent"),children:n.verb})," ",d.jsx("span",{className:X("font-mono text-mono-sm text-ink-muted"),children:n.object})]}),d.jsx("span",{"aria-hidden":!0,className:X("text-ink-dim text-meta"),children:"·"})]}),d.jsx("span",{className:X("min-w-0 break-words text-body-sm text-ink-muted"),title:I7t(e.units,u),"data-fold-summary":"",children:e.units.map((y,v)=>d.jsxs($.Fragment,{children:[v>0&&d.jsx("span",{"aria-hidden":"true",children:" · "}),d.jsx("span",{className:X(e.prose?"whitespace-normal":"whitespace-nowrap"),children:d.jsx("bdi",{dir:u,children:y})})]},y))}),NQ(s)!==null&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,className:X("text-ink-dim text-meta"),children:"·"}),d.jsx("span",{className:X("shrink-0 text-ink-muted text-meta"),children:NQ(s)})]}),p!==""&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,className:X("text-ink-dim text-meta"),children:"·"}),d.jsx("span",{"data-fold-span":"",className:X("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:p})]})]}),children:d.jsx("div",{className:X("flex flex-col"),children:c})}),!r&&o&&o(g)]})},yee=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],M7t=80,L7t=1e3,hke=({activity:e,phase:t,startedAt:n,clock:r,className:i})=>{const[a,o]=$.useState(0),[s,l]=$.useState(()=>n===void 0?0:Math.floor((Date.now()-n)/1e3)),[c,u]=$.useState(!1),O=r!==!1&&!c,f=m8("(prefers-reduced-motion: reduce)"),p=$.useRef(n??Date.now()),m=$.useRef(t),g=$.useRef(n);if(m.current!==t)m.current=t,g.current=n,p.current=n??Date.now(),c&&u(!1),l(0);else if(g.current!==n){const b=g.current!==void 0&&n===void 0;g.current=n,u(b),b||(p.current=n,l(Math.floor((Date.now()-n)/1e3)))}const y=$.useRef(r!==!1),v=$.useRef(t);return $.useEffect(()=>{const b=r!==!1,x=y.current,Q=v.current===t;y.current=b,v.current=t,!x&&b&&Q&&l(Math.floor((Date.now()-p.current)/1e3))},[r,t]),$.useEffect(()=>{const b=O?window.setInterval(()=>l(Math.floor((Date.now()-p.current)/1e3)),L7t):null;if(f)return o(0),()=>{b!==null&&window.clearInterval(b)};const x=window.setInterval(()=>o(Q=>(Q+1)%yee.length),M7t);return()=>{window.clearInterval(x),b!==null&&window.clearInterval(b)}},[f,O]),d.jsxs("div",{className:X("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[d.jsx("span",{"aria-hidden":!0,className:X("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:yee[a]}),d.jsx("span",{className:X("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),d.jsx("span",{"aria-hidden":!0,className:X("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?_O(s):""})]})},F7t="min-h-5 py-0",Lu=()=>d.jsx("span",{"aria-hidden":!0,className:X("text-ink-dim text-meta"),children:"·"}),B7t=({recordIds:e,segmentIds:t,anchorRecordId:n,className:r,durationS:i,actionCount:a,partial:o=!1,title:s,stampTs:l,label:c=null,completed:u=!1,open:O,onOpenChange:f,children:p,condensedMedia:m,mediaCount:g=0,group:y=null,episode:v=null})=>{be();const b=o?h("ui.chat.canonical.fold.count.actions_partial",{count:a}):h("ui.chat.canonical.fold.count.actions",{count:a}),x=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,Q=v?.receipts??y?.count,w=Q===void 0?null:`At least ${Q} messages — earlier rows are not loaded`,S=$.useRef(null),_=()=>{S.current?.querySelector("button[aria-expanded]")?.focus(),f(!0)};return c===null&&i===null&&a===0&&y===null&&v===null&&g===0?null:d.jsxs("div",{ref:S,className:X("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u&&!v?.active?"true":void 0,"data-segment-active":v?.active?"true":void 0,"data-record-id":n,children:[d.jsx(zi,{open:O,onOpenChange:f,chevron:"trailing",rowClassName:F7t,triggerClassName:X("-ms-2 -me-2 w-[calc(100%+1rem)] rounded-sm ps-2 pe-6","hover:bg-row-hover"),chevronClassName:X("-mr-6","text-ink-muted"),summary:d.jsxs("span",{className:X("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&!v?.active&&d.jsx(d.Fragment,{children:d.jsx(CA,{"aria-hidden":!0,className:X("size-3.5 shrink-0 text-success")})}),v?.active?d.jsxs(d.Fragment,{children:[c!==null&&d.jsx(Lu,{}),d.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?w??void 0:void 0,"aria-label":o?w??void 0:void 0,children:o?`${v.receipts}+`:v.receipts}),a>0&&d.jsxs(d.Fragment,{children:[d.jsx(Lu,{}),d.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?x:void 0,children:d.jsx("bdi",{children:b})})]}),v.phaseLine!==null&&d.jsxs(d.Fragment,{children:[d.jsx(Lu,{}),d.jsx(hke,{activity:v.phaseLine.activity,phase:v.phaseLine.phase,startedAt:v.phaseLine.startedAt,clock:v.phaseLine.clock,className:"min-w-0"})]})]}):y!==null?d.jsxs(d.Fragment,{children:[c!==null&&d.jsx(Lu,{}),d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),title:o?w??void 0:void 0,"aria-label":o?w??void 0:void 0,children:o?`${v?.receipts??y.count}+`:`${v?.receipts??y.count}`}),y.spanS!==null&&d.jsxs(d.Fragment,{children:[d.jsx(Lu,{}),d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),children:_O(y.spanS)})]})]}):d.jsxs(d.Fragment,{children:[c!==null&&(i!==null||a>0)&&d.jsx(Lu,{}),i!==null&&d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),children:h("ui.chat.canonical.turn_summary.took",{duration:_O(i)})}),i!==null&&a>0&&d.jsx(Lu,{}),a>0&&d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),title:o?x:void 0,"aria-label":o?x:void 0,children:d.jsx("bdi",{children:b})})]}),NQ(g)!==null&&d.jsxs(d.Fragment,{children:[d.jsx(Lu,{}),d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),children:NQ(g)})]}),u&&!v?.active&&d.jsx("span",{className:X("sr-only"),children:h("ui.chat.canonical.turn_summary.completed")}),l!==null&&d.jsx("span",{className:X("ms-auto"),children:d.jsx(UQ,{timestamp:l,scope:"answer"})})]}),children:d.jsx("div",{className:X("flex flex-col"),children:p})}),!O&&m&&d.jsx("div",{className:X("pb-2"),children:m(_)})]})},pke="lo-missing-session-notice";function H7t(e){return e===!0?{kind:"temporary",title:"ui.chat.canonical.temporary_deleted.title",detail:"ui.chat.canonical.temporary_deleted.detail",actions:[{key:"ui.chat.canonical.temporary_deleted.new",temporary:!0},{key:"ui.chat.canonical.temporary_deleted.back",temporary:!1}]}:{kind:"generic",title:"ui.chat.canonical.transcript.missing_session",detail:"ui.chat.canonical.transcript.missing_session_detail",actions:[{key:"ui.chat.canonical.transcript.start_new_chat",temporary:!1}]}}function mke(e){const t=$.useRef(null);return $.useEffect(()=>{e&&t.current?.focus({preventScroll:!0})},[]),t}const du=({children:e,className:t,boundary:n="hairline",...r})=>d.jsx("div",{className:X("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm",n==="control"?["bg-media-surface","border border-transparent","transition-colors duration-fast ease-out-quart","group-hover/tile:border-control group-focus-visible/tile:border-control"]:["border border-hairline","bg-sunken"],t),...r,children:e}),K7t="could not be displayed. It may have been moved, renamed, or deleted.",UN="could not be displayed. Its stored copy is not available to this reader.",gke="could not be played. Its stored copy is not available to this reader.",$ke=gke,Xf=({name:e,detail:t=K7t,className:n,compact:r=!1})=>r?d.jsx("div",{className:X("flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken",n),role:"img","aria-label":`${e} ${t}`,title:`${e} ${t}`,children:d.jsx(WI,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):d.jsxs("div",{className:X("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[d.jsx(WI,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),d.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[d.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),_b=({name:e,onRetry:t,className:n,compact:r=!1,device:i=null,focusOnMount:a=!1})=>{const o=mke(a),s=i?h("ui.canvas.files.remoteUnreachable",{device:i}):null,l=s??h("ui.chat.attachments.owner_unreachable"),c=h("ui.chat.attachments.retry_fetch");return r?d.jsxs("button",{ref:o,type:"button",onClick:u=>{u.stopPropagation(),t()},className:X("flex h-[78px] w-[117px] flex-col items-center justify-center gap-1 rounded-sm border border-control bg-sunken hover:bg-row-hover",n),"aria-label":`${e} ${l} ${c}`,title:`${e} ${l} ${c}`,"data-attachment-retryable":"",children:[d.jsx(yI,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),d.jsx("span",{className:"text-ink-muted text-meta","aria-hidden":!0,children:c})]}):d.jsxs("div",{className:X("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),"data-attachment-retryable":"",children:[d.jsx(yI,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),d.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[d.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),s?d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,children:" · "}),s]}):` ${l}`]}),d.jsx("button",{ref:o,type:"button",onClick:u=>{u.stopPropagation(),t()},className:"shrink-0 rounded-sm px-1 text-accent text-body-sm hover:underline",children:c})]})},WN=({device:e,compact:t=!1,video:n=!1,focusOnMount:r=!1})=>{const i=mke(r),a=h("ui.canvas.files.remoteFetching",{device:e}),o=r?{ref:i,tabIndex:-1,"aria-busy":!0}:{};return t?d.jsx("output",{...o,"aria-label":a,title:a,className:"flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken","data-attachment-pending":"",children:d.jsx(ti,{size:"sm",className:"text-ink-dim"})}):n?d.jsxs("output",{...o,className:"flex aspect-video w-[427px] max-w-full flex-col items-center justify-center gap-2 self-start rounded-sm border border-hairline bg-sunken px-3","data-attachment-pending":"","data-attachment-pending-video":"",children:[d.jsx(ti,{size:"sm",className:"text-ink-dim"}),d.jsx("span",{className:"min-w-0 max-w-full truncate text-body-sm text-ink-muted",children:a})]}):d.jsxs("output",{...o,className:"flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2","data-attachment-pending":"",children:[d.jsx(ti,{size:"sm",className:"text-ink-dim"}),d.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink-muted",children:a})]})},J7t="flex min-h-11 min-w-11 shrink-0 items-center justify-center text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink disabled:pointer-events-none disabled:text-ink-disabled",GQ=4,yke=2,eCt=2,vke=4,bke=GQ+yke,tCt=.8,nCt=24,vee=.3,bee=1;function rCt(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+yke)/bke))}function iCt(e,t){const n=Math.min(e,t-e);return Number.isFinite(n)?Math.max(0,Math.min(1,n/nCt)):0}function aCt(e,t){if(t<=0)return[];if(e.length===0)return new Array(t).fill(0);const n=new Array(t),r=e.length/t;for(let i=0;i<t;i+=1){const a=Math.floor(i*r),o=Math.max(a+1,Math.floor((i+1)*r));let s=0;for(let l=a;l<o&&l<e.length;l+=1){const c=e[l];Number.isFinite(c)&&c>s&&(s=c)}n[i]=Math.max(0,Math.min(1,s))}return n}function wke(e,t,n){const r=rCt(t),i=e===null?null:aCt(e,r),a=[],o=Math.max(1,r-1);for(let s=0;s<r;s+=1){const l=s*bke,c=l+GQ/2,O=(i===null?0:i[s])*n*tCt,f=Math.max(vke,Math.round(O)),p=vee+(bee-vee)*(s/o);a.push({x:l,width:GQ,height:f,alpha:Math.min(bee,p)*iCt(c,t)})}return a}function C$(e){if(!Number.isFinite(e)||e<=0)return"0:00";const t=Math.floor(e),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}function oCt(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return 0;const r=Math.max(0,Math.min(1,e/t));return!Number.isFinite(n)||n<=0?0:r*n}function sCt(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}const wee=(e,t)=>h("ui.chat.audio.position_value",{current:C$(e),total:C$(t)}),lCt=4,xee=1,xke=({ownerId:e,src:t,label:n,peaks:r,durationHint:i=null,hideUnknownTotal:a=!1,variant:o="full",className:s})=>{const l=be(),c=Zi(D=>D.ownerId===e),u=Zi(D=>D.ownerId===e?D.status:"idle"),O=Zi(D=>D.ownerId===e?D.duration:0),[f,p]=$.useState(!1),[m,g]=$.useState(!1);$.useEffect(()=>{(u==="loading"||u==="playing")&&g(!1)},[u]);const y=O>0?O:i??0,v=c&&u==="playing",b=c&&u==="loading",x=m||c&&u==="error",Q=$.useRef(null),w=$.useRef(null),S=$.useRef(null),_=$.useRef(null),k=$.useRef(null),[R,E]=$.useState({width:0,height:0,dpr:1});$.useEffect(()=>{const D=Q.current;if(!D)return;const ne=()=>{const L=D.getBoundingClientRect();E({width:L.width,height:L.height,dpr:window.devicePixelRatio||1})};ne();const J=new ResizeObserver(ne);return J.observe(D),()=>J.disconnect()},[]);const T=$.useCallback(D=>{if(!D||R.width<=0)return;const ne=D.getContext("2d");if(!ne)return;D.width=Math.max(1,Math.round(R.width*R.dpr)),D.height=Math.max(1,Math.round(R.height*R.dpr)),ne.setTransform(R.dpr,0,0,R.dpr,0,0),ne.clearRect(0,0,R.width,R.height);const J=getComputedStyle(D).color,L=wke(r,R.width,R.height);ne.fillStyle=J;for(const B of L)ne.globalAlpha=B.alpha,ne.beginPath(),ne.roundRect(B.x,(R.height-B.height)/2,B.width,B.height,eCt),ne.fill();ne.globalAlpha=1},[R.width,R.height,R.dpr,r]);$.useEffect(()=>{T(w.current),T(S.current)},[T]);const q=$.useRef(null),A=$.useCallback(D=>{const ne=sCt(D,y),J=S.current;Q.current?.style.setProperty("--sound-progress",`${ne*100}%`),J&&(J.style.clipPath=`inset(0 ${(1-ne)*100}% 0 0)`);const L=C$(D);k.current&&k.current.textContent!==L&&(k.current.textContent=L);const B=_.current;B&&(B.setAttribute("aria-valuenow",String(Math.floor(D))),B.setAttribute("aria-valuetext",wee(D,y)))},[y,l]);$.useEffect(()=>{const D=v||f,ne=()=>A(c?XT()?.currentTime??0:U.current);if(!D){ne();return}let J=0;const L=()=>{const B=q.current??XT()?.currentTime??0;A(B),J=requestAnimationFrame(L)};return J=requestAnimationFrame(L),()=>cancelAnimationFrame(J)},[v,f,c,A]);const G=$.useCallback(async()=>(g(!1),Zi.getState().play(e,t,{onError:()=>g(!0)})),[e,t]),I=$.useCallback(D=>{const ne=Zi.getState();if(v){ne.seek(e,D),A(D);return}G().then(J=>{J!==!1&&(Zi.getState().seek(e,D),A(D))})},[e,v,G,A]),C=$.useCallback(async()=>{if(v){Zi.getState().pause(e);return}g(!1),await Zi.getState().toggle(e,t,{onError:()=>g(!0)})},[e,t,v]),U=$.useRef(0),Y=$.useRef(null),V=$.useCallback(D=>{const ne=Q.current;if(!ne)return 0;const J=ne.getBoundingClientRect();return oCt(D-J.left,J.width,y)},[y]),z=D=>{if(b)return;D.currentTarget.setPointerCapture?.(D.pointerId),Y.current={pointerId:D.pointerId,startX:D.clientX,moved:!1,pendingX:D.clientX,raf:0}},Z=D=>{const ne=Y.current;!ne||ne.pointerId!==D.pointerId||(Math.abs(D.clientX-ne.startX)>lCt&&(ne.moved||p(!0),ne.moved=!0),ne.pendingX=D.clientX,ne.moved&&ne.raf===0&&(ne.raf=requestAnimationFrame(()=>{const J=Y.current;if(!J)return;J.raf=0;const L=V(J.pendingX);q.current=L,Zi.getState().scrub(e,L),A(L)})))},K=D=>{const ne=Y.current;if(!ne||ne.pointerId!==D.pointerId)return;ne.raf!==0&&cancelAnimationFrame(ne.raf),Y.current=null,q.current=null,D.currentTarget.releasePointerCapture?.(D.pointerId);const J=V(D.clientX);if(ne.moved){U.current=J,p(!1),Zi.getState().seek(e,J),A(J);return}I(J)},N=D=>{const ne=XT(),J=c&&ne?ne.currentTime:0;if(D.key===" "||D.key==="Enter"){D.preventDefault(),C();return}let L=null;if(D.key==="ArrowLeft"?L=J-xee:D.key==="ArrowRight"?L=J+xee:D.key==="Home"?L=0:D.key==="End"&&(L=y),L===null)return;D.preventDefault();const B=Math.max(0,Math.min(y,L));I(B)},ce=o==="compact",ee=h("ui.chat.audio.position_label",{label:n});return d.jsxs("div",{"data-sound-player":o,"data-sound-peaks":r?"stored":"flat","data-sound-status":x?"error":f?"scrubbing":c?u:"idle",className:X("flex w-full min-w-0 items-center gap-2",ce?"gap-1.5":"gap-2",s),children:[d.jsx("button",{type:"button",className:J7t,disabled:b,onClick:()=>void C(),"aria-label":v?h("ui.chat.audio.pause_label",{label:n}):h("ui.chat.audio.play_label",{label:n}),children:b?d.jsx(ti,{size:"sm"}):v?d.jsx($Oe,{size:22,"aria-hidden":"true"}):d.jsx(lze,{size:22,"aria-hidden":"true"})}),d.jsx("div",{ref:_,role:"slider",tabIndex:0,"aria-label":ee,"aria-valuemin":0,"aria-valuemax":Math.max(0,Math.round(y)),"aria-valuenow":0,"aria-valuetext":wee(0,y),"data-sound-slider":"",className:X("group relative min-h-11 min-w-0 flex-1 cursor-pointer touch-none select-none","rounded-sm outline-offset-2 focus-visible:outline-2 focus-visible:outline-accent",x&&"cursor-default"),onPointerDown:z,onPointerMove:Z,onPointerUp:K,onPointerCancel:K,onKeyDown:N,children:d.jsxs("div",{ref:Q,className:"absolute inset-0",children:[d.jsx("canvas",{ref:w,className:"absolute inset-0 h-full w-full text-ink-dim"}),d.jsx("canvas",{ref:S,style:{clipPath:"inset(0 100% 0 0)"},className:"absolute inset-0 h-full w-full text-ink-muted"}),d.jsx("span",{"data-sound-thumb":"",className:X("pointer-events-none absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-ink-muted group-hover:bg-ink group-focus-visible:bg-accent",f&&"bg-accent"),style:{left:"var(--sound-progress, 0%)"}})]})}),d.jsx("span",{ref:k,"data-sound-time":"",className:X("min-w-10 shrink-0 text-center text-meta text-ink-muted tabular-nums"),children:C$(0)}),d.jsx("span",{"data-sound-total":"","aria-hidden":a&&y<=0?!0:void 0,className:X("min-w-10 shrink-0 text-center text-meta text-ink-dim tabular-nums",a&&y<=0&&"invisible"),children:C$(y)}),x?d.jsx("span",{"data-sound-error":"",className:X("shrink-0 text-meta text-ink-muted"),children:h("ui.chat.canonical.sound.player_failed")}):null]})};function KR(e){return e.live_state.trim().toLowerCase()==="attached"}function tyn(e,t){return e.keep||!e.lost?null:{body:e.lost,confirmLabel:e.to==="local"?h("ui.mesh.mesh_drop.recall_it"):h("ui.mesh.mesh_drop.move_it"),risky:t}}function nyn(e){return e.keep?h("ui.mesh.mesh_actions.the_original_stays_where_it_is"):e.to==="local"?h("ui.mesh.mesh_actions.the_copy_there_is_deleted_once_it"):h("ui.mesh.mesh_actions.the_copy_here_is_deleted_once_it")}function Zd(e,t){return h("ui.mesh.mesh_drop.copy_loss",{source:e,destination:t})}function See(e,t){return h("ui.mesh.mesh_drop.running_now",{conversation:e.name||h("ui.mesh.mesh_drop.this_conversation"),where:t})}function Qee(e,t,n){return e?L$(e,n,!0):t}function cCt(e,t,n){if(e.suspect)return{kind:"refused",code:"suspect_device",sentence:h("ui.mesh.mesh_drop.duplicate_key",{device:L$(e,n,!0),reason:e.reason?` (${e.reason})`:""}),remedy:{kind:"open",label:h("ui.mesh.mesh_drop.see_this_device"),deviceId:t}};if(!e.reachable){const r=jue(Cue(e));return{kind:"refused",code:"unreachable",sentence:h("ui.mesh.mesh_drop.reach_refusal",{device:L$(e,n,!0),reach:r,reason:e.reason?` (${e.reason})`:""}),reach:r,remedy:{kind:"resume",label:h("ui.mesh.mesh_actions.check_again")}}}return null}function ryn(e,t,n){const{session:r,ownerDeviceId:i}=e,{selfDeviceId:a,devices:o,networks:s}=n,l=[...o.keys()],c=o.get(i),u=c?L$(c,l,!0):L$({id:i,name:r.owner_device_name});if(t.kind==="ground")return{kind:"none"};if(t.kind==="network"){const v=s.get(t.networkId);return{kind:"refused",code:"not_a_device",sentence:h("ui.mesh.mesh_drop.network_not_destination",{network:v?.label??h("ui.mesh.mesh_drop.a_network")}),remedy:null}}if(sje(r))return{kind:"refused",code:"busy",sentence:h("ui.mesh.mesh_drop.turn_in_flight",{conversation:r.name||h("ui.mesh.mesh_drop.this_conversation")}),remedy:{kind:"wait",label:h("ui.mesh.mesh_actions.wait_for_the_turn_to_finish"),waitS:300},plan:{sessionId:r.id,to:t.deviceId===a?"local":t.deviceId,keep:!1,verb:t.deviceId===a?h("ui.mesh.mesh_card.recall_to_this_device"):h("ui.mesh.mesh_card.move_to",{device:Qee(o.get(t.deviceId),t.deviceId,l)}),waitS:0,lost:null}};if(i===t.deviceId)return{kind:"none"};const O=o.get(t.deviceId),f=O?cCt(O,t.deviceId,l):{code:"unknown_device",sentence:h("ui.mesh.mesh_drop.that_device_is_no_longer_in_any"),remedy:null};if(f)return{kind:"refused",...f};const p=Qee(O,t.deviceId,l);if(!(r.locality==="local")){if(c&&!c.reachable){const v=jue(Cue(c));return{kind:"refused",code:"unreachable",sentence:h("ui.mesh.mesh_drop.owner_reach_refusal",{device:u,reach:v,reason:c.reason?` (${c.reason})`:""}),reach:v,remedy:{kind:"resume",label:h("ui.mesh.mesh_actions.check_again")}}}if(t.deviceId!==a)return{kind:"refused",code:"third_device",sentence:h("ui.mesh.mesh_drop.recall_first",{owner:u}),remedy:null}}if(t.deviceId===a){const v={sessionId:r.id,to:"local",keep:!1,verb:h("ui.mesh.mesh_card.recall_to_this_device"),waitS:0,lost:KR(r)?`${See(r,h("ui.mesh.mesh_drop.on_owner",{owner:u}))} ${Zd(u,h("ui.mesh.mesh_drop.this_device"))}`:Zd(u,h("ui.mesh.mesh_drop.this_device"))};return{kind:"plan",plan:v,risky:KR(r),alternatives:[{...v,keep:!0,verb:h("ui.mesh.mesh_card.copy_here_leave_it_there"),lost:null}]}}if(r.locality==="local"&&t.deviceId===i)return{kind:"none"};const g=KR(r),y={sessionId:r.id,to:t.deviceId,keep:!1,verb:h("ui.mesh.mesh_card.move_to",{device:p}),waitS:0,lost:g?`${See(r,h("ui.mesh.mesh_drop.on_this_device"))} ${Zd(h("ui.mesh.mesh_drop.this_device"),p)}`:Zd(h("ui.mesh.mesh_drop.this_device"),p)};return{kind:"plan",plan:y,risky:g,alternatives:[{...y,keep:!0,verb:h("ui.mesh.mesh_card.copy_to",{device:p}),lost:null}]}}function iyn(e){return e.kind==="refused"?h("ui.mesh.mesh_drop.drop_refusal",{sentence:e.sentence}):e.kind==="plan"?e.plan.verb:null}function uCt(e){switch(e.kind){case"draft":return e.name;case"local":return"";default:return e.name}}function ayn(e){switch(e.kind){case"draft":return e.deviceId?h("ui.chat.device.label.new_on",{name:e.name}):h("ui.chat.device.label.new_on_this_device");case"local":return h("ui.chat.device.label.on_this_device");case"remote":case"gone":return h("ui.chat.device.label.on",{name:e.name});case"moving":return h("ui.chat.device.label.moving_to",{name:e.name})}}function oyn(e){switch(e.kind){case"draft":return e.deviceId?h("ui.chat.device.sentence.draft_elsewhere",{name:e.name}):h("ui.chat.device.sentence.draft_here");case"local":return h("ui.chat.device.sentence.local");case"remote":return e.reachable===!1?e.reason?h("ui.chat.device.sentence.remote_did_not_answer_reason",{name:e.name,reason:e.reason}):h("ui.chat.device.sentence.remote_did_not_answer",{name:e.name}):h("ui.chat.device.sentence.remote",{name:e.name});case"gone":return e.reachable===!1?h("ui.chat.device.sentence.gone_did_not_answer",{name:e.name}):h("ui.chat.device.sentence.gone",{name:e.name});case"moving":return h("ui.chat.device.sentence.moving",{name:e.name})}}const OCt=()=>h("ui.chat.device.footer.move_deletes_copy");function syn(e){switch(e){case"enabled":return null;case"unknown":return h("ui.chat.device_move.gate.checking");case"unpaired":return h("ui.chat.device_move.gate.unpaired");case"below-version":return h("ui.chat.device_move.gate.below_version")}}function lyn(e){return e==="unknown"?"dim":"warning"}const dCt=()=>h("ui.chat.device.row.not_here_why"),fCt=()=>h("ui.chat.device.label.this_device"),hCt=()=>h("ui.chat.device.sentence.pairing_guidance"),pCt=()=>h("ui.chat.device.sentence.mesh_read_failure");function mCt(e){return h("ui.chat.device.sentence.move_in_flight",{name:e})}const cyn=()=>h("ui.chat.device.notice.move_hold_detail");function JR(e){return h("ui.chat.device.row.conversations",{count:e})}function uyn(e){return`${e} ${e===1?"device":"devices"}`}function _ee(e){return e.canTransfer?e.reachable?h("ui.chat.device_move.ineligible.cannot_receive"):h("ui.chat.device_move.ineligible.no_answer"):h("ui.chat.device_move.ineligible.no_transfer")}function Oyn(e){const{draft:t,host:n,move:r,reachableFor:i}=e;return r?.kind==="moving"?{kind:"moving",deviceId:r.deviceId,name:r.name}:r?.kind==="moved"?r.receipt.locality==="local"||r.deviceId==="local"?{kind:"local"}:r.receipt.source_retired?{kind:"gone",deviceId:r.deviceId,name:r.name,reachable:i(r.deviceId)}:{kind:"remote",deviceId:r.deviceId,name:r.name,reachable:i(r.deviceId),reason:""}:t?{kind:"draft",deviceId:t.deviceId,name:t.name}:n?{kind:"remote",deviceId:n.deviceId,name:n.name,reachable:i(n.deviceId),reason:""}:{kind:"local"}}function dyn(e){const{placement:t,selfDeviceId:n,networks:r,peers:i}=e,a=t.kind==="local"||t.kind==="remote"||t.kind==="gone"||t.kind==="moving",o=t.kind==="gone",s=t.kind==="remote"||t.kind==="draft"||t.kind==="gone"?t.deviceId:null,l=t.kind==="local"||t.kind==="draft"&&t.deviceId===null,c=new Map(i.map(y=>[y.device_id,y])),u=e.selfName.trim(),O={deviceId:n,name:u||fCt(),facts:u?[JR(e.selfConversations),h("ui.chat.device.fact.this_device")]:[JR(e.selfConversations)],state:l?"current":e.canTransfer?"candidate":"ineligible",why:l||e.canTransfer?void 0:_ee({canTransfer:!1,reachable:!0})},f=r.map(y=>{const v=y.members.filter(b=>b.device_id!==n&&b.active).map(b=>{const x=c.get(b.device_id),Q=[b.role,x?.session_count!=null?JR(x.session_count):""].filter(Boolean);!b.reachable&&!a&&Q.push("unreachable");const w=e.canTransfer&&b.capabilities.includes("move")&&b.reachable,S=s!==null&&b.device_id===s,_=a&&(!w||o&&!S);return{deviceId:b.device_id,name:b.name,facts:Q,state:S?"current":_?"ineligible":"candidate",why:_?w?dCt():_ee({canTransfer:e.canTransfer,reachable:b.reachable}):void 0}});return{key:y.network_id,name:y.name,count:v.length,rows:v}}),p=r.some(y=>y.members.some(v=>v.device_id!==n&&v.active&&v.reachable)),m=r.some(y=>y.members.some(v=>v.device_id!==n&&v.active&&e.canTransfer&&!v.reachable)),g=e.meshRead==="failed";return{heading:a?h("ui.chat.device.picker.heading.move"):h("ui.chat.device.picker.heading.start"),self:O,sections:f,footer:t.kind==="local"||t.kind==="remote"||t.kind==="moving"?OCt():t.kind==="gone"?Zd(t.name,h("ui.mesh.mesh_drop.this_device")):null,guidance:e.meshRead==="ok"&&r.length===0?hCt():null,readFailure:g?pCt():null,inFlight:e.busy?mCt(uCt(t)||h("ui.chat.device_move.another_device")):null,offerCheckAgain:g||r.length>0&&(!p||m)}}function fyn(e){const{engaged:t,name:n,from:r,newSessionId:i,sourceRetired:a}=e;return r!==null?{verb:h("ui.chat.device_move.result.back.verb"),detail:a?h("ui.chat.device_move.result.back.detail_deleted",{from:r}):h("ui.chat.device_move.result.back.detail"),second:null}:a?t===!0?{verb:h("ui.chat.device_move.result.moved.verb",{name:n}),detail:h("ui.chat.device_move.result.moved.detail_running"),second:null}:{verb:h("ui.chat.device_move.result.moved.verb",{name:n}),detail:h("ui.chat.device_move.result.moved.detail_there"),second:h("ui.chat.device_move.result.moved.second",{name:n})}:{verb:h("ui.chat.device_move.result.copied.verb",{name:n}),detail:h("ui.chat.device_move.result.copied.detail",{name:n,id:i.slice(-6)}),second:t===!0?null:h("ui.chat.device_move.result.copied.second",{name:n})}}function gCt(e,t){return e.trim()||t.slice(-8)}function hyn(e){const t={sessionId:e.sessionId,waitS:0},n=e.destination.name,r=h("ui.mesh.mesh_drop.this_device");return e.recall?{plan:{...t,to:"local",keep:!1,verb:h("ui.chat.device_move.plan.recall"),lost:Zd(e.source??h("ui.chat.device_move.other_device"),h("ui.mesh.mesh_drop.this_device"))},alternatives:[{...t,to:"local",keep:!0,verb:h("ui.chat.device_move.plan.copy_here"),lost:null}]}:{plan:{...t,to:e.destination.deviceId,keep:!1,verb:h("ui.chat.device_move.plan.move",{name:n}),lost:Zd(r,n)},alternatives:[{...t,to:e.destination.deviceId,keep:!0,verb:h("ui.chat.device_move.plan.copy",{name:n}),lost:null}]}}function pyn(e){let t=0;for(const n of e)n.locality!=="remote"&&(t+=1);return t}function Ske(e){return gCt(typeof e.owner_device_name=="string"?e.owner_device_name:"",typeof e.owner_device=="string"?e.owner_device:"")||"another device"}function myn(e){const t=new Map,n=e?.networks;if(!Array.isArray(n))return t;for(const r of n){if(r===null||typeof r!="object")continue;const i=r,a=typeof i.name=="string"?i.name.trim():"";if(!(!a||!Array.isArray(i.members)))for(const o of i.members){if(o===null||typeof o!="object")continue;const s=o.device_id;typeof s!="string"||s===""||t.has(s)||t.set(s,a)}}return t}function gyn(e,t){const n=Ske(e),r=(t??"").trim();return r?`on ${n} · ${r}`:`on ${n}`}function $yn(e){return e.reachable!==!1?"":`unreachable · ${(typeof e.unreachable_reason=="string"?e.unreachable_reason.trim():"")||"it did not answer"}`}function NN(e){return fn(t=>{if(!e)return null;const n=t.sessions.find(r=>r.session_id===e);return!n||n.locality!=="remote"?null:Ske(n)})}function kee(e){const t=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.peaks)?e.peaks:null;if(!t||t.length===0)return null;const n=[];for(const r of t){if(typeof r!="number"||!Number.isFinite(r))return null;n.push(Math.max(0,Math.min(1,r)))}return n}const e4=new Map,YN=Symbol("waveform-pending"),GN=Symbol("waveform-unkept");async function $Ct(e,t){try{const n=await Ba({op:"sessions.attachment.waveform",sessionId:e.sessionId,digest:t},null);if(n.kind==="json")return kee(n.body);if(n.kind==="bytes"){const r=new TextDecoder().decode(n.data);try{return kee(JSON.parse(r))}catch{return null}}return n.status===504?YN:n.status===409?GN:null}catch{return null}}function Qke(e,t){const n=t?.sessionId??null,r=t?.childId??null,[i,a]=$.useState(()=>e?yCt(e):null);return $.useEffect(()=>{if(!e||!n){a(null);return}let o=!0,s;const l=c=>{vCt({sessionId:n,childId:r},e).then(u=>{if(!o)return;if(u===GN){a(null);return}if(u!==YN){a(u);return}const O=tb[c];O!==void 0&&(s=setTimeout(()=>{s=void 0,o&&l(c+1)},O))})};return l(0),()=>{o=!1,s!==void 0&&clearTimeout(s)}},[e,n,r]),i}function yCt(e){return oz.get(e)??null}const oz=new Map;function vCt(e,t){const n=e4.get(t);if(n)return n;const r=$Ct(e,t).then(i=>i===YN||i===GN?(e4.delete(t),i):(oz.set(t,i),i)).catch(()=>(oz.set(t,null),null));return e4.set(t,r),r}function _ke(e){return`sound:${e.attachment??e.id}`}const DP=({audio:e,scope:t,label:n,ownerId:r})=>{const i=nb(e,t),a=Qke(e.attachment,t),o=NN(t?.sessionId),[s,l]=$.useState(!1);return i.state==="missing"?d.jsx(Xf,{name:n,detail:$ke}):i.state==="retryable"?d.jsx(_b,{name:n,onRetry:()=>{l(!0),i.retry()},device:o,focusOnMount:s}):i.state==="resolving"&&i.pending&&o?d.jsx(WN,{device:o,focusOnMount:s}):i.state==="resolving"?d.jsx("div",{className:X("inline-block max-w-full self-start"),"aria-hidden":!0,children:d.jsx(du,{"data-attachment-reserved":""})}):d.jsx("div",{className:X("w-full max-w-[560px] self-start"),children:d.jsx(xke,{ownerId:r??_ke(e),src:i.url,label:n,peaks:a,durationHint:e.durationS??null})})},Xd=1,kke=4,Pee=(e,t)=>Math.min(kke,Math.max(Xd,e+t)),y0=Object.freeze({x:0,y:0}),t4=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),n4=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,bCt=(e,t)=>h("ui.common.viewer.position",{kind:"image",index:e+1,count:t}),Tee=(e,t,n)=>{const r=Math.max(0,n-1)/2,i=t.width*r||0,a=t.height*r||0;return{x:Math.min(i,Math.max(-i,e.x)),y:Math.min(a,Math.max(-a,e.y))}},wCt="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",xCt="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",Xee=e=>X(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),SCt="opacity-85",Yh="bg-surface/85 disabled:bg-surface/85",IN=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a,pending:o=!1,group:s,layerRef:l,mediaKind:c="image",mediaLabel:u="image",layerAttributes:O})=>{be();const f=c==="video",p=(J,L)=>u==="asset"?h("ui.common.viewer.position",{kind:"asset",index:J+1,count:L}):bCt(J,L),[m,g]=$.useState(null),y=e!==void 0&&m===e,[v,b]=$.useState(Xd),[x,Q]=$.useState(y0),w=$.useRef(e);$.useLayoutEffect(()=>{w.current!==e&&(w.current=e,b(Xd),Q(y0))},[e]);const[S,_]=$.useState(!0),k=$.useRef(null);$.useEffect(()=>{if(!n)return;let J;const L=()=>{clearTimeout(J),J=setTimeout(()=>{const ae=k.current;if(ae&&(ae.matches(":hover")||ae.contains(document.activeElement))){L();return}_(!1)},zhe)},B=()=>{_(!0),L()};return _(!0),L(),document.addEventListener("pointermove",B,{passive:!0}),document.addEventListener("pointerdown",B,{passive:!0}),document.addEventListener("keydown",B),document.addEventListener("focusin",B),()=>{clearTimeout(J),document.removeEventListener("pointermove",B),document.removeEventListener("pointerdown",B),document.removeEventListener("keydown",B),document.removeEventListener("focusin",B)}},[n]);const R=s?.onPrev,E=s?.onNext,T=s!==void 0&&s.count>1,q=T?xCt:wCt,A=$.useRef(null),G=l??A;$.useEffect(()=>{if(!n||!T)return;const J=L=>{L.defaultPrevented||L.metaKey||L.ctrlKey||L.altKey||(L.key==="ArrowLeft"?(L.preventDefault(),R?.()):L.key==="ArrowRight"&&(L.preventDefault(),E?.()))};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[n,T,R,E]),gA(n,"lightbox");const I=$.useRef(null),C=!f&&e!==void 0&&!y,U=v===Xd&&x.x===y0.x&&x.y===y0.y,Y=J=>{if(!C)return;b(J);const L=I.current;L&&Q(B=>Tee(B,{width:L.clientWidth,height:L.clientHeight},J))},V=()=>{C&&(b(Xd),Q(y0))},z=$.useRef(null),[Z,K]=$.useState(!1),N=C&&v>Xd,ce=J=>{!N||J.button!==0||(J.currentTarget.setPointerCapture(J.pointerId),z.current={pointerId:J.pointerId,startX:J.clientX,startY:J.clientY,pan:x},K(!0))},ee=J=>{const L=z.current,B=I.current;!L||L.pointerId!==J.pointerId||!B||Q(Tee({x:L.pan.x+(J.clientX-L.startX),y:L.pan.y+(J.clientY-L.startY)},{width:B.clientWidth,height:B.clientHeight},v))},D=J=>{z.current?.pointerId===J.pointerId&&(z.current=null,K(!1))},ne=e!==void 0&&!y?d.jsx("div",{ref:I,"data-image-viewport":"",tabIndex:-1,className:X(q,"relative h-fit w-fit overflow-hidden leading-none outline-none",N&&(Z?"cursor-grabbing":"cursor-grab"),N&&"touch-none"),onPointerDown:ce,onPointerMove:ee,onPointerUp:D,onPointerCancel:D,children:f?d.jsx("video",{src:e,controls:!0,autoPlay:!0,className:X(q,"block object-contain"),"data-lightbox-video":"",onError:()=>g(e),children:t}):d.jsx("img",{src:e,alt:t,draggable:!1,className:X(q,"block select-none object-contain"),style:U?void 0:{transform:`translate(${x.x}px, ${x.y}px) scale(${v})`},onError:()=>g(e)})}):e===void 0&&o?d.jsx("div",{className:Xee(q),"aria-hidden":"true"}):d.jsx("div",{className:Xee(q),children:a});return d.jsx(EA,{open:n,onOpenChange:r,children:d.jsxs(qA,{ref:G,tabIndex:-1,onOpenAutoFocus:J=>{J.preventDefault(),(I.current??G.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:J=>{const L=i?.current;L&&(J.preventDefault(),L.focus())},className:X("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",q,"gap-0 rounded-none bg-transparent p-0 shadow-none"),...O,children:[d.jsx(jA,{className:"sr-only",children:t}),T&&s?d.jsx("div",{"aria-live":"polite",className:"sr-only",children:p(s.index,s.count)}):null,ne,d.jsxs("div",{ref:k,"data-image-viewer-controls":"",className:X("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",S?"opacity-100 duration-fast":`${SCt} duration-base`),children:[T&&s?.filmstrip?d.jsx("div",{className:"pointer-events-auto fixed inset-x-0 bottom-4 mx-auto w-fit max-w-[calc(100vw-256px)]",children:s.filmstrip}):null,T?d.jsxs(d.Fragment,{children:[d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.previous",{kind:u}),title:h("ui.common.viewer.previous",{kind:u}),onClick:s?.onPrev,className:X("pointer-events-auto fixed top-0 bottom-0 left-4 my-auto",Yh),"data-image-viewer-prev":"",children:d.jsx(L6e,{"aria-hidden":"true"})}),d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.next",{kind:u}),title:h("ui.common.viewer.next",{kind:u}),onClick:s?.onNext,className:X("pointer-events-auto fixed top-0 right-4 bottom-0 my-auto",Yh),"data-image-viewer-next":"",children:d.jsx(Bue,{"aria-hidden":"true"})})]}):null,!f&&d.jsxs("div",{className:"pointer-events-auto fixed right-4 bottom-4 flex items-center gap-1",children:[d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.zoom_out"),title:h("ui.common.viewer.zoom_out"),disabled:!C||v===Xd,onClick:()=>Y(Pee(v,-1)),className:Yh,children:d.jsx(qOe,{"aria-hidden":"true"})}),d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.zoom_in"),title:h("ui.common.viewer.zoom_in"),disabled:!C||v===kke,onClick:()=>Y(Pee(v,1)),className:Yh,children:d.jsx(EOe,{"aria-hidden":"true"})}),d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.reset_view"),title:h("ui.common.viewer.reset_view"),disabled:!C||U,onClick:V,className:Yh,children:d.jsx(pk,{"aria-hidden":"true"})})]}),d.jsx(w7e,{asChild:!0,children:d.jsx(ve,{variant:"ghost",size:"icon-sm",className:X("pointer-events-auto fixed top-4 right-4",Yh),"aria-label":h("ui.common.viewer.close",{kind:u}),title:h("ui.common.viewer.close",{kind:u}),children:d.jsx(Zr,{"aria-hidden":"true"})})})]})]})})};IN.displayName="ImageLightbox";const QCt={full:"max-h-[240px] max-w-full object-contain",thumbnail:["h-[76px] w-[115px] object-contain","motion-safe:transition-transform motion-safe:duration-fast motion-safe:ease-out-quart","motion-safe:group-hover/tile:scale-[1.04]"].join(" ")},_Ct=/[/\\]/,Ree=e=>{const t=e.split(_Ct);return t[t.length-1]},Pke=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:o,pathActions:s})=>{be();const[l,c]=$.useState(!1),[u,O]=$.useState(!1),[f,p]=$.useState(!1),m=$.useRef(null),g=It(E=>E.setCanvasOpen),{setViewMode:y}=Nd(),v=$.useCallback(async()=>{const E=Ree(e),T=I=>{I&&console.error("Error processing file:",I);const C=e.startsWith("file://")?e.substring(7):e;window.api.openFile(C).catch(U=>{console.error("Error opening file:",U)})},{setFiles:q,setOpenTabs:A,setSelectedTab:G}=Nd.getState();if(e.startsWith("data:"))if(Y6(E)){const I=e,C={id:I,title:E,path:I,content:e,type:IS(e)},Y=Nd.getState().conversations?.[n],V=Y?.files??[],z=Y?.openTabs??[],Z=(()=>{const ce=V.findIndex(ee=>ee.id===I);return ce!==-1?[...V.slice(0,ce),C,...V.slice(ce+1)]:[...V,C]})();q(n,Z);const N=z.some(ce=>ce.id===I)?z:[...z,{id:I,title:E}];A(n,N),G(n,I),g(!0),y(n,"documents")}else g(!0),y(n,"files");else{const I=e.startsWith("file://")?e.substring(7):e;try{const C=await window.api.readFile(I);if(C.success&&Y6(E)){const U=I,Y={id:U,title:E,path:I,content:C.data,type:IS(e)},z=Nd.getState().conversations?.[n],Z=z?.files??[],K=z?.openTabs??[],N=(()=>{const D=Z.findIndex(ne=>ne.id===U);return D!==-1?[...Z.slice(0,D),Y,...Z.slice(D+1)]:[...Z,Y]})();q(n,N);const ee=K.some(D=>D.id===U)?K:[...K,{id:U,title:E}];A(n,ee),G(n,U),g(!0),y(n,"documents");return}g(!0),y(n,"files")}catch(C){const U=C instanceof Error?C.message:String(C??"Unknown error reading file");return T(U)}}},[e,g,y,n]),b=()=>{c(!0)},x=xN(e),w=(x==="path"||x==="data")&&n!==""||!!s?.onShowInCanvas,S=b_e(x,{canShowInCanvas:w,source:t,artifactPathActions:!!s}),_=x==="path",k=r??Ree(e);if(l)return d.jsx(Xf,{name:k,compact:i==="thumbnail"});const R=d.jsx(du,{boundary:i==="thumbnail"?"control":"hairline",children:d.jsx("img",{className:X(QCt[i],u?"opacity-100":"opacity-0"),src:t,alt:k,loading:"lazy",decoding:"async",onLoad:()=>O(!0),onError:b})});return d.jsxs("div",{className:"group relative inline-block",children:[d.jsx("button",{ref:m,type:"button",className:X("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>p(!0),"aria-label":o?o.label:h("ui.chat.attachments.expand_aria",{name:k}),title:o?o.title:h("ui.chat.attachments.expand_title",{name:k}),"aria-current":o?.current?"true":void 0,children:R}),S&&d.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 end-1 z-[2] opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",onClick:E=>{E.stopPropagation()},onKeyDown:E=>E.stopPropagation(),children:d.jsx(S_e,{file:e,src:t,label:k,onShowInCanvas:s?.onShowInCanvas??(w?v:void 0),resolvePath:s?.resolvePath})}),o?null:a?a({open:f,onOpenChange:p,restoreFocusTo:m}):d.jsx(IN,{src:t,label:k,open:f,onOpenChange:p,restoreFocusTo:m,fallback:d.jsx(Xf,{name:k,detail:_?void 0:UN})})]})});Pke.displayName="ImageAttachment";function ZN(e,t){return h("ui.chat.canonical.media.image_label",{position:e,count:t})}function kCt(e,t){return h("ui.chat.canonical.media.sound_label",{position:e,count:t})}const PCt=(e,t,n)=>e.name??ZN(t+1,n),X1=(e,t)=>h("ui.chat.canonical.lightbox.show_image",{index:e,count:t}),TCt={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},XCt=({cold:e,children:t})=>e?d.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,RCt=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=PCt})=>{be();const s=e.length,[l,c]=$.useState(()=>t4(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(t4(t,s)));const f=t4(l,s),p=e[f]??TCt,m=o(p,f,s),g=B8(p,n),y=$.useRef(null),v=$.useRef(null),[b,x]=$.useState(!1),Q=$.useCallback(U=>{y.current=U,x(U!==null)},[]),w=U=>{const Y=y.current?.querySelector(`[data-image-slot="${U+1}"] button`);Y?Y.focus():v.current?.focus()},S=U=>{const Y=n4(f,s,U),V=y.current?.contains(document.activeElement)??!1;c(Y),V&&w(Y)},_=()=>S(-1),k=()=>S(1),R=JSON.stringify([n?.sessionId,n?.childId,e.map(U=>[U.id,U.attachment,U.mimeType])]),[E,T]=$.useState(()=>({identity:R,open:r,indices:new Set}));(E.identity!==R||E.open!==r)&&T({identity:R,open:r,indices:new Set});const q=$.useCallback(U=>{T(Y=>{if(!r||Y.identity!==R||!Y.open||U.every(z=>Y.indices.has(z)))return Y;const V=new Set(Y.indices);for(const z of U)V.add(z);return{...Y,indices:V}})},[R,r]),A=n4(f,s,-1),G=n4(f,s,1);$.useEffect(()=>{r&&q([f,A,G])},[r,f,A,G,q]),$.useEffect(()=>{const U=y.current;if(!r||!b||!U||typeof IntersectionObserver>"u")return;let Y=!0;const V=new IntersectionObserver(z=>{Y&&q(z.filter(Z=>Z.isIntersecting).map(Z=>Number(Z.target.dataset.imageSlot)-1))},{root:U});for(const z of U.querySelectorAll("[data-image-slot]"))V.observe(z);return()=>{Y=!1,V.disconnect()}},[r,b,q]);const I=(U,Y)=>!!U.data||!U.attachment||Y===f||Y===A||Y===G||E.identity===R&&E.open&&E.indices.has(Y);$.useEffect(()=>{(y.current?.querySelector(`[data-image-slot="${f+1}"]`)??y.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[b,f]);const C=s>1?d.jsx("ul",{role:"list",ref:Q,"aria-label":h("ui.chat.canonical.lightbox.filmstrip_aria",{count:s,count_display:String(s)}),"data-image-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((U,Y)=>d.jsx("li",{"data-image-slot":Y+1,className:X("flex shrink-0 scroll-mx-px rounded-sm leading-none",Y===f&&"ring-1 ring-ink"),children:d.jsx(XCt,{cold:!!U.attachment&&!U.data,children:I(U,Y)?d.jsx(eh,{image:U,scope:n,size:"thumbnail",label:o(U,Y,s),press:{onPress:()=>c(Y),label:X1(Y+1,s),title:X1(Y+1,s),current:Y===f}}):d.jsx("button",{type:"button","aria-label":X1(Y+1,s),title:X1(Y+1,s),className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{q([Y]),c(Y)},children:d.jsx(du,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},U.id))}):void 0;return d.jsx(IN,{src:g.state==="ready"?g.url:void 0,pending:g.state==="resolving",label:m,open:r,onOpenChange:i,restoreFocusTo:a,fallback:g.state==="retryable"?d.jsx(_b,{name:m,onRetry:g.retry}):d.jsx(Xf,{name:m,detail:UN}),layerRef:v,group:{index:f,count:s,onPrev:_,onNext:k,filmstrip:C}})},eh=({image:e,scope:t,label:n,size:r,group:i,press:a,pathActions:o})=>{const s=B8(e,t),l=NN(t?.sessionId),[c,u]=$.useState(!1);if(s.state==="resolving"&&s.pending&&l&&!a)return d.jsx(WN,{device:l,compact:r==="thumbnail",focusOnMount:c});if(s.state==="resolving"){const f=d.jsx(du,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""});return a?d.jsx("button",{type:"button","aria-label":a.label,title:a.title,"aria-current":a.current||void 0,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:a.onPress,children:f}):d.jsx("div",{className:X("inline-block max-w-full"),"aria-hidden":!0,children:f})}if(s.state==="retryable")return d.jsx(_b,{name:n,compact:r==="thumbnail",onRetry:()=>{u(!0),s.retry()},device:l,focusOnMount:c});if(s.state==="missing")return d.jsx(Xf,{name:n,compact:r==="thumbnail",detail:UN});const O=s.url;return d.jsx("div",{className:X("inline-block max-w-full"),children:d.jsx(Pke,{file:O,src:O,label:n,size:r,conversationId:t?.sessionId??"",press:a,pathActions:o,overlay:i?f=>d.jsx(RCt,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:f.open,onOpenChange:f.onOpenChange,restoreFocusTo:f.restoreFocusTo}):void 0})})};function ECt(){return h("ui.chat.checkpoint.generating_name")}const qCt={rest:"scale-x-60 bg-ink-dim",preview:"scale-x-90 bg-ink-muted",active:"scale-x-100 bg-ink",unloaded:"scale-x-40 bg-ink-dim opacity-75"};function jCt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function Tke(e,t){return h("ui.chat.checkpoint.turn",{turn:e,total:t})}function CCt(e,t){const n=Tke(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function zCt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function ACt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function UCt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const WCt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function NCt(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);return Number.isNaN(t.getTime())?"":Av(t,{hour:"numeric",minute:"2-digit"})}function YCt(e,t){if(e.kind==="user"){const r=NCt(e.ts);return r?h("ui.chat.checkpoint.jump_user",{turn:e.turn,total:t,clock:r}):h("ui.chat.checkpoint.jump_user_no_clock",{turn:e.turn,total:t})}const n=e.naming?.state==="ready"?e.naming.name?.trim():"";return n?h("ui.chat.checkpoint.jump_agent",{turn:e.turn,total:t,name:n}):h("ui.chat.checkpoint.jump_agent_unnamed",{turn:e.turn,total:t})}function GCt(e,t){const n=e.checkpoints.find(i=>i.id===t);return n?n.kind==="completion"?n.naming?.state??null:e.checkpoints.find(i=>i.kind==="completion"&&i.turn===n.turn)?.naming?.state??null:null}function r4(e,t){const n=[];for(const r of t)GCt(e,r)==="pending"&&n.push(r);return n}const ICt=120,Eee=80,Nc=10,IQ=24,ZCt=2,sz=420,Xke=32;function VP(e,t){return(t?ZCt:0)+IQ+e*Nc}function qee(e,t){return VP(e,t)+IQ}function DCt(e,t,n){if(t<=0)return{start:0,end:0};const r=Xke*Nc,i=Math.floor(Math.max(0,e)/r),a=i*r-sz,o=(i+1)*r+2*sz,s=VP(0,n),l=Math.max(0,Math.floor((a-s)/Nc)),c=Math.min(t,Math.ceil((o-s)/Nc));return{start:Math.min(l,c),end:c}}function VCt(e,t,n,r,i=24){const a=VP(e,t),o=a+Nc;return a<n+i?Math.max(0,a-i):o>n+r-i?o-r+i:null}const MCt=()=>h("ui.chat.canonical.checkpoint_rail.label"),LCt={complete:Ai,error:nu,interrupted:ZA,open:ize},FCt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},BCt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?LCt[n]:null,i=ACt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:X("text-body-sm font-medium text-ink"),children:[Tke(e.turn,t),a&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":"true",children:" · "}),d.jsx("span",{className:X("font-normal text-ink-muted"),children:a})]})]}),zCt(e)&&d.jsx("p",{className:X("text-ink-dim text-meta"),children:ECt()}),i&&d.jsx("p",{className:X("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&d.jsx("div",{className:X("flex items-center gap-1.5 text-ink-dim text-meta"),children:d.jsxs("span",{className:X("flex items-center gap-1",FCt[n]),children:[d.jsx(r,{"aria-hidden":"true",className:X("size-3.5 shrink-0")}),WCt[n]]})})]})},HCt=$.memo(function({checkpoint:t,state:n,label:r,top:i,roving:a,registerTick:o,onPreview:s,onPreviewEnd:l,onFocusMark:c,onBlurMark:u,onActivate:O,onKeyMark:f,describedBy:p}){const m=g=>{g.pointerType!=="touch"&&s(t.id)};return d.jsx("button",{ref:g=>o(t.id,g),type:"button","data-checkpoint-id":t.id,"data-mark-state":n,"aria-label":r,"aria-describedby":p,tabIndex:a?0:-1,className:X("group pointer-events-auto absolute start-0 block h-2.5 w-7"),style:{top:i},onPointerMove:m,onPointerLeave:l,onFocus:()=>c(t.id),onBlur:u,onClick:()=>O(t.id),onKeyDown:g=>f(g,t.id),children:d.jsx("span",{"aria-hidden":"true",className:X("ms-auto me-1.5 block h-0.5 w-5 origin-right rtl:origin-left rounded-full","transition-[transform,background-color] duration-fast ease-out-quart","motion-reduce:transition-none",qCt[n])})})}),KCt=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{be();const s=$.useId(),[l,c]=$.useState(null),[u,O]=$.useState(null),[f,p]=$.useState(null),m=$.useRef(t);m.current=t;const g=$.useRef(new Map),y=$.useRef(null),v=$.useMemo(()=>new Map(t.map((Oe,we)=>[Oe.id,we])),[t]),b=$.useRef(v);b.current=v;const x=$.useRef(i);x.current=i;const[Q,w]=$.useState({sessionId:"",top:0}),S=Xke*Nc,_=$.useCallback(Oe=>{const we=Math.floor(Math.max(0,Oe)/S)*S;w(Je=>Je.sessionId===e&&Je.top===we?Je:{sessionId:e,top:we})},[S,e]),k=Q.sessionId===e?Q.top:Math.max(0,qee(t.length,i)-sz),R=$.useRef(null),E=$.useRef(null),T=$.useCallback(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),q=$.useCallback((Oe,we)=>{T();const Je=()=>{O(Oe),p(m.current.find(ct=>ct.id===Oe)??null)};if(we<=0){Je();return}R.current=setTimeout(()=>{R.current=null,Je()},we)},[T]),A=$.useCallback(Oe=>{if(T(),Oe<=0){O(null);return}E.current=setTimeout(()=>{E.current=null,O(null)},Oe)},[T]),G=$.useRef(e);$.useEffect(()=>{G.current!==e&&(G.current=e,T(),L.current=null,c(null),O(null),p(null))},[e,T]);const I=$.useRef(null);$.useLayoutEffect(()=>{const Oe=y.current;if(!(t.length===0||Oe===null)){if(o!==null&&C.current===e){I.current=e,_(Oe.scrollTop);return}I.current!==e&&(I.current=e,Oe.scrollTop=qee(t.length,i),_(Oe.scrollTop))}},[o,i,t.length,e,_]);const C=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const Oe=y.current,we=b.current.get(o);if(Oe===null||we===void 0)return;C.current=e;const Je=VCt(we,x.current,Oe.scrollTop,Oe.clientHeight);Je!==null&&(Oe.scrollTop=Je),_(Oe.scrollTop)},[o,e,_]),$.useEffect(()=>()=>T(),[T]);const U=$.useRef(r);$.useEffect(()=>{U.current=r});const Y=$.useMemo(()=>UCt(t),[t]),V=u&&f?.id===u?f:null,z=u&&g.current.get(u)||null,Z=$.useMemo(()=>({current:z}),[z]),K=V!==null&&z!==null;$.useEffect(()=>{U.current(K&&u?u:null)},[K,u]);const N=$.useCallback((Oe,we)=>{we?g.current.set(Oe,we):g.current.delete(Oe)},[]),[ce,ee]=$.useState(null),D=ce&&v.has(ce)?ce:t[0]?.id??null,ne=$.useRef(null),J=$.useCallback(Oe=>{const we=Math.max(0,Math.min(t.length-1,Oe)),Je=t[we];if(!Je)return;ee(Je.id);const ct=g.current.get(Je.id);if(ct){ct.focus();return}const nt=y.current;nt!==null&&(nt.scrollTop=Math.max(0,VP(we,i)+Nc/2-nt.clientHeight/2),_(nt.scrollTop)),ne.current=Je.id},[i,t,_]);$.useLayoutEffect(()=>{const Oe=ne.current;if(Oe===null)return;const we=g.current.get(Oe);we&&(ne.current=null,we.focus())});const L=$.useRef(null),B=$.useCallback(Oe=>{L.current!==Oe&&(L.current=Oe,c(Oe),q(Oe,ICt))},[q]),ae=$.useCallback(()=>{L.current=null,c(Oe=>Oe===null?Oe:null),A(Eee)},[A]),ie=$.useCallback(Oe=>{L.current=Oe,ee(Oe),c(we=>we===Oe?we:Oe),q(Oe,0)},[q]),ke=$.useCallback(()=>{L.current=null,c(Oe=>Oe===null?Oe:null),A(Eee)},[A]),fe=$.useCallback(Oe=>{A(0),L.current=null,c(null),n(Oe)},[A,n]),_e=$.useCallback((Oe,we)=>{if(Oe.key==="Escape"){A(0);return}const Je=v.get(we);if(Je!==void 0){if(Oe.key==="ArrowDown"){Oe.preventDefault(),Oe.stopPropagation(),J(Je+1);return}if(Oe.key==="ArrowUp"){Oe.preventDefault(),Oe.stopPropagation(),J(Je-1);return}if(Oe.key==="Home"){Oe.preventDefault(),Oe.stopPropagation(),J(0);return}Oe.key==="End"&&(Oe.preventDefault(),Oe.stopPropagation(),J(t.length-1))}},[t.length,A,J,v]),qe=DCt(k,t.length,i),Ce=[];for(let Oe=qe.start;Oe<qe.end;Oe+=1)Ce.push(Oe);for(const Oe of[D,u,l]){const we=Oe===null?void 0:v.get(Oe);we!==void 0&&(we<qe.start||we>=qe.end)&&!Ce.includes(we)&&Ce.push(we)}return Ce.sort((Oe,we)=>Oe-we),t.length===0&&!i?null:d.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":MCt(),className:X("pointer-events-none absolute inset-y-0 end-3 z-10 hidden w-7 select-none","flex-col justify-center","@[900px]/chatcol:flex"),children:[d.jsxs("div",{"data-rail-frame":"","data-checkpoint-count":t.length,ref:y,onScroll:Oe=>_(Oe.currentTarget.scrollTop),className:X("max-h-[min(calc(100%-4rem),420px)] w-7 overflow-y-auto overscroll-contain","[&::-webkit-scrollbar]:hidden","[mask-image:linear-gradient(to_bottom,transparent_0,#000_24px,#000_calc(100%-24px),transparent_100%)]"),children:[i&&d.jsx("span",{"aria-hidden":"true","data-rail-building":"",className:X("ms-auto me-1.5 block h-0.5 w-5 animate-pulse-visible rounded-full bg-ink-dim")}),d.jsx("div",{"data-rail-track":"",className:"relative py-6",style:{height:t.length*Nc+2*IQ},children:Ce.map(Oe=>{const we=t[Oe];return d.jsx(HCt,{checkpoint:we,top:IQ+Oe*Nc,state:jCt({id:we.id,previewId:l,activeId:o,loaded:a?a.has(we.id):!0}),label:YCt(we,Y),roving:we.id===D,registerTick:N,onPreview:B,onPreviewEnd:ae,onFocusMark:ie,onBlurMark:ke,onActivate:fe,onKeyMark:_e,describedBy:K&&u===we.id?s:void 0},we.id)})})]}),d.jsxs(x7e,{open:K,onOpenChange:Oe=>{Oe||A(0)},children:[d.jsx(S7e,{virtualRef:Z}),V&&d.jsx(Q7e,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":V.kind==="user"?h("ui.chat.transcript_copy.row.your_message"):CCt(V,Y),onOpenAutoFocus:Oe=>Oe.preventDefault(),onCloseAutoFocus:Oe=>Oe.preventDefault(),onFocusOutside:Oe=>{const we=Oe.detail?.originalEvent?.target;we instanceof Element&&we.closest("[data-lo-checkpoint-rail]")&&Oe.preventDefault()},className:X("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:V.kind==="user"?d.jsx("div",{"data-checkpoint-card-text":"",className:X("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:V.text}):d.jsx(BCt,{checkpoint:V,turnCount:Y})})]})]})},JCt=$.memo(KCt),e6t={cold:"ui.chat.canonical.loading.cold",revalidating:"ui.chat.canonical.loading.revalidating",older:"ui.chat.canonical.loading.older",remote:"ui.chat.canonical.loading.remote"};function Rke(e){return h(e6t[e])}const lz=({variant:e,announce:t=!0,isSmallView:n=!1,className:r})=>{be();const i=d.jsxs(d.Fragment,{children:[d.jsx("span",{"data-lo-loading-mark":!0,className:"inline-flex shrink-0",children:d.jsx(ti,{size:"sm",className:"border-2 forced-colors:border-[CanvasText] forced-colors:border-t-[Highlight]"})}),d.jsx("span",{"data-lo-loading-pill":!0,className:"min-w-0 truncate rounded-full bg-accent/10 px-2 text-ink-muted text-meta",children:Rke(e)})]}),a=X("flex min-w-0 items-center gap-2 font-sans",n&&"gap-1.5",r);return t?d.jsx("output",{"aria-label":e==="cold"?h("ui.chat.canonical.loading.region_label"):void 0,"data-lo-conversation-loading":e,className:a,children:i}):d.jsx("span",{"data-lo-conversation-loading":e,className:a,children:i})};function t6t(e,t){if(!t)return e;let n=!1;const r=[];for(const i of e){if(i.kind==="peer"||i.kind==="tool"&&i.toolName==="send"){n=!0;continue}r.push(i)}return n?r:e}const n6t=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function r6t(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function Eke(e,t){const n=[["[data-turn-summary]","data-run-ids"],["[data-fold-ids]","data-fold-ids"]];for(const[r,i]of n)for(const a of e.querySelectorAll(r)){const o=a.getAttribute("data-segment-ids");if(o!==null?!o.split(" ").includes(t):!n6t(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function i6t(e,t){return r6t(e,t)||Eke(e,t)!==null}const a6t=3;function o6t(e,t,n){const r=i=>{if(n.isCurrent&&!n.isCurrent()){n.onMissing();return}const a=e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`);if(a){const l=a.querySelector("button[aria-expanded]");l?.getAttribute("aria-expanded")==="false"&&l.click(),n.onRevealed(a);return}if(i>=a6t){n.onMissing();return}const s=Eke(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const jee=(e,t,n)=>ZN(t+1,n),Cee=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{be();const{shown:a,more:o}=W7t(e.length,{uncapped:r}),s=N7t(a),l=s.length>1,c=new Set;for(let O=0,f=0;f<s.length;f+=1)c.add(O),O+=s[f];const u=e.slice(0,a).map((O,f)=>d.jsx("li",{className:X("flex leading-none",l&&c.has(f)&&"col-start-1"),children:d.jsx(eh,{image:O,scope:t,size:"thumbnail",label:jee(O,f,e.length),group:{images:e,index:f,labelFor:jee}})},O.id));return d.jsxs("ul",{role:"list","aria-label":h("ui.chat.canonical.fold.images_aria",{count_display:String(e.length),count:e.length}),"data-fold-media":"",className:X("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ms-5":"ms-0"),children:[u,o>0&&d.jsx("li",{className:X("flex h-[78px] items-center leading-none"),children:d.jsx(ve,{variant:"outline",size:"sm",onClick:n,"aria-label":h("ui.chat.canonical.fold.more_images",{count_display:String(o),count:o}),title:h("ui.chat.canonical.fold.more_images",{count:o,count_display:String(o)}),children:`+${o}`})},"fold-media-more")]})};function zee(e,t){if(t.length===0)return!1;const n=e.find(i=>i.ids[0]===t[0]);return n?n.open:e.find(i=>i.ids.some(a=>t.includes(a)))?.open??!1}function s6t(e,t,n,r){if(t.length===0)return[...e];const i=t[0],a=[];let o=!1;for(const s of e){if(!(s.ids[0]===i||s.ids.some(c=>t.includes(c)))){a.push(s);continue}o||(a.push({ids:[...t],open:n}),o=!0)}return o||a.push({ids:[...t],open:n}),a.filter(s=>s.ids.some(l=>r.has(l)))}function l6t(e,t){return e===null?{session:t,key:String(t)}:t===null||t===e.session?e:e.session===null?{session:t,key:e.key}:{session:t,key:t}}const c6t=({video:e,scope:t,label:n})=>{const r=nb(e,t),[i,a]=$.useState(!1),o=NN(t?.sessionId),[s,l]=$.useState(!1);return r.state==="retryable"?d.jsx(_b,{name:n,onRetry:()=>{l(!0),r.retry()},device:o,focusOnMount:s}):r.state==="resolving"&&r.pending&&o?d.jsx(WN,{device:o,video:!0,focusOnMount:s}):r.state==="missing"||i?d.jsx(Xf,{name:n,detail:gke}):r.state==="resolving"?d.jsx("div",{className:X("inline-block max-w-full self-start"),"aria-hidden":!0,children:d.jsx(du,{"data-attachment-reserved":""})}):d.jsx("div",{className:X("inline-block max-w-full self-start"),children:d.jsx(du,{children:d.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:X("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})};function u6t({items:e,summary:t,scope:n}){return be(),d.jsxs("div",{"data-sound-batch":"",className:X("flex w-full min-w-0 max-w-[560px] flex-col gap-4"),children:[d.jsx("p",{className:X("text-meta text-ink-muted break-words [overflow-wrap:anywhere]"),children:t}),d.jsx("ul",{className:"flex min-w-0 flex-col gap-4",children:e.map(r=>d.jsxs("li",{"data-sound-batch-item":"",className:X("min-w-0"),children:[d.jsx("p",{className:X("text-body text-ink break-words [overflow-wrap:anywhere]"),children:r.status==="completed"?r.label:h("ui.chat.canonical.sound.batch.item_status",{status:r.status,label:r.label})}),r.error?d.jsx("p",{className:X("text-body-sm text-ink break-words [overflow-wrap:anywhere]"),children:r.error}):r.audio?d.jsx(DP,{audio:r.audio,ownerId:`${_ke(r.audio)}:batch:${r.audio.id}:${r.id}`,scope:n,label:r.label}):d.jsx("p",{className:X("text-meta text-ink-muted"),children:h("ui.chat.canonical.sound.batch_attachment_unavailable")}),d.jsx("p",{className:X("text-meta text-ink-dim"),children:r.costCaption??h("ui.chat.canonical.sound.cost.unknown")})]},r.id))})]})}function yyn({sessionId:e,runningSound:t,available:n,onInterrupt:r,onRestoreFocus:i}){const[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(e);$.useEffect(()=>{const p=l.current!==e;l.current=e,!(!p&&t)&&a&&(o(!1),i())},[e,t,a,i]);const c=$.useCallback(()=>{o(!1),i()},[i]),u=$.useCallback(()=>{if(!e||!n)return;const p=s.current?.querySelector("[data-sound-stop-confirmation] button");if(p){p.focus();return}if(t){o(!0);return}r()},[e,n,t,r]),O=$.useCallback(()=>{o(!1),i(),r()},[r,i]),f=$.useMemo(()=>a&&t?d.jsx(qke,{onKeepWaiting:c,onRequestStop:O}):null,[a,t,c,O]);return{paneRef:s,stop:u,confirmation:f}}function qke({onKeepWaiting:e,onRequestStop:t}){be();const n=$.useRef(null),r=$.useId();return $.useEffect(()=>{n.current?.focus();const i=a=>{a.key!=="Escape"||a.isComposing||a.defaultPrevented||(a.preventDefault(),a.stopPropagation(),e())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[e]),d.jsxs("fieldset",{"data-sound-stop-confirmation":"","aria-label":h("ui.chat.canonical.sound.stop.confirm_label"),className:"flex flex-col items-start gap-2",children:[d.jsx("p",{className:"text-meta text-ink","aria-live":"polite",children:h("ui.chat.canonical.sound.stop.question")}),d.jsx("p",{id:r,className:"text-body-sm text-ink-dim",children:h("ui.chat.canonical.sound.stop.warning")}),d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx(ve,{ref:n,"aria-describedby":r,variant:"ghost",size:"sm",onClick:e,children:h("ui.chat.canonical.sound.stop.keep_waiting")}),d.jsx(ve,{variant:"secondary",size:"sm",onClick:t,children:h("ui.chat.canonical.sound.stop.request_stop")})]})]})}const O6t=1e3;function d6t(e){const[t,n]=$.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return $.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,O6t);return()=>window.clearInterval(i)},[e]),t}function f6t(){return d.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:X("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:d.jsx("span",{className:X("absolute inset-0","animate-shimmer","bg-gradient-to-r from-transparent via-elevated to-transparent","bg-[length:200%_100%]","bg-[position:-200%_50%]","bg-no-repeat")})})}const Aee=44,h6t=240,i4=12,p6t=Array.from({length:240},(e,t)=>Math.min(1,.18+Math.abs(Math.sin(t/7)*Math.cos(t/17))*.72));function m6t({state:e}){const t=wke(p6t,h6t-i4*2,Aee);return d.jsx("div",{"aria-hidden":!0,"data-sound-loading-tile":"","data-sound-loading":e,className:X("relative flex w-[240px] max-w-full items-center overflow-hidden rounded-sm bg-sunken"),style:{height:Aee},children:d.jsx("div",{className:X("flex w-full items-center"),style:{paddingLeft:i4,paddingRight:i4},children:t.map((n,r)=>d.jsx("span",{"data-sound-loading-bar":"",className:X("shrink-0 rounded-[2px]",e==="running"?"animate-pulse-visible bg-ink-muted":e==="queued"?"bg-ink-disabled":e==="stopped"?"bg-ink-dim":"bg-ink-muted"),style:{width:GQ,height:e==="failed"?vke:n.height,marginRight:n===t.at(-1)?0:2,animationDelay:e==="running"?`${r%12*90}ms`:void 0}},n.x))})})}function Bu(e){return e==="sound-effect"?"sound_effect":e}function ZQ(e){const t=h("ui.chat.canonical.image_gen.cancel.running");return e?`${t} ${h("ui.chat.canonical.image_gen.cancel.checking")}`:t}function jke(e,t){return!e||e.vendorStopped===null?null:e.vendorStopped?h("ui.chat.canonical.image_gen.cancel.queued"):ZQ(t&&e.settling)}function g6t(e){switch(e){case"audio_rate_limited":return h("ui.chat.canonical.image_gen.error_class.audio_rate_limited");case"unknown_tool":return h("ui.chat.canonical.image_gen.error_class.unknown_tool");case"invalid_arguments":return h("ui.chat.canonical.image_gen.error_class.invalid_arguments");case"duplicate_id":return h("ui.chat.canonical.image_gen.error_class.duplicate_id");case"denied":return h("ui.chat.canonical.image_gen.error_class.denied");case"gate_failed":return h("ui.chat.canonical.image_gen.error_class.gate_failed");default:{const t=e.replace(/_/g," ");return t.charAt(0).toUpperCase()+t.slice(1)}}}function $6t({view:e,elapsed:t}){let n,r=null,i=!1;switch(e.state){case"queued":n=e.composing?h("ui.chat.canonical.image_gen.state.writing_request"):h("ui.chat.canonical.image_gen.state.queued"),r=e.queuePosition!==null?h("ui.chat.canonical.image_gen.state.queue_ahead",{count:e.queuePosition}):e.argumentBytes>0?ox(e.argumentBytes):null;break;case"running":n=e.batchProgress?h("ui.chat.canonical.image_gen.state.running_batch",{material:Bu(e.material),total:e.batchProgress.total}):h("ui.chat.canonical.image_gen.state.running",{material:Bu(e.material)}),r=t===null?null:_O(t);break;case"cancelling":n=e.generating?ZQ(!0):h("ui.chat.canonical.image_gen.cancel.queued");break;case"done":n=e.receipt==="already-finished"?h("ui.chat.canonical.image_gen.state.already_finished"):e.batch?h("ui.chat.canonical.image_gen.state.done_batch",{material:Bu(e.material)}):h("ui.chat.canonical.image_gen.state.done",{material:Bu(e.material)}),r=e.receipt==="already-finished"||e.durationS===null?null:QA(e.durationS);break;case"failed":n=e.batch?h("ui.chat.canonical.image_gen.state.failed_batch",{material:Bu(e.material)}):e.message??(e.errorCode==="audio_rate_limited"?h("ui.chat.canonical.image_gen.error.audio_rate_limited"):h("ui.chat.canonical.image_gen.state.failed",{material:Bu(e.material)})),i=!0;break;case"cancelled":{const a=!!(e.settlementCaption||e.settled),o=jke(e.cancel,!a),s=e.message?a?lCe(e.message):e.message:e.generating?ZQ(!a):h("ui.chat.canonical.image_gen.cancel.queued");n=e.batch?h("ui.chat.canonical.image_gen.state.cancelled_batch",{material:Bu(e.material??"sound-effect")}):o??s;break}}return d.jsxs("p",{className:X("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[d.jsx("span",{className:X("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:d.jsxs("span",{className:X("shrink-0 text-meta text-ink-dim"),children:["· ",d.jsx("bdi",{dir:"auto",children:r})]})]})}function y6t({line:e}){return d.jsx("p",{"data-imagegen-log":"",title:e,className:X("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function Qd({line:e,prominent:t=!1}){return d.jsx("p",{"data-imagegen-note":"",className:X("min-w-0 text-body-sm",t?"text-ink-muted":"text-ink-dim"),children:e})}function v6t(e,t){return e==="cancel"?h("ui.chat.canonical.image_gen.control.stop"):e==="restart"?t==="failed"?h("ui.common.actions.retry"):h("ui.chat.canonical.image_gen.control.restart"):h("ui.chat.canonical.image_gen.control.edit_and_restart")}const b6t=({view:e,scope:t,actions:n})=>{be();const[r,i]=$.useState(!1),a=$.useCallback(()=>i(!1),[]),o=$.useRef(null),s=$.useRef(!1);$.useLayoutEffect(()=>{s.current&&!r&&(o.current?.querySelector("[data-imagegen-controls] button")??o.current)?.focus(),s.current=r},[r]),$.useLayoutEffect(()=>{const w=o.current;return()=>{w?.contains(document.activeElement)&&w.closest("[data-chat-pane]")?.querySelector("textarea")?.focus()}},[]);const l=e.state==="running"&&(e.material==="voiceover"||e.material==="sound-effect");$.useEffect(()=>{l||i(!1)},[l]);const c=e.state==="running"||e.state==="cancelling"?e.startedAtMs:null,u=d6t(c),O=uCe(e,n),f={cancel:n?.onCancel,restart:n?.onRestart,editRestart:n?.onEditRestart},p=e.state==="running"||e.state==="cancelling",m=p&&(e.state==="running"||e.generating),g="material"in e?e.material:void 0,y=g==="voiceover"||g==="sound-effect",v=y?e.state==="queued"?"queued":e.state==="cancelling"?e.generating?"stopped":null:m?"running":e.state==="failed"?"failed":e.state==="cancelled"?"stopped":null:null,b=e.state==="cancelled"&&!e.batch&&!!jke(e.cancel,!0),x=y&&!b&&(e.state==="failed"?e.batch?.some(w=>w.status==="cancelled"):e.state==="cancelled"&&(e.batch?.some(w=>w.status==="cancelled")||e.message))?ZQ(!0):null,Q=p&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return d.jsxs("div",{ref:o,tabIndex:-1,"data-imagegen-card":e.state,className:X("flex w-full flex-col gap-2"),children:[v?d.jsx(m6t,{state:v}):m?d.jsx(f6t,{}):null,e.state==="failed"&&(e.material==="voiceover"||e.material==="sound-effect")&&e.errorCode?d.jsx("p",{className:X("text-meta text-ink-dim"),children:g6t(e.errorCode)}):null,d.jsx($6t,{view:e,elapsed:u}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.costCaption?d.jsx(Qd,{line:e.costCaption,prominent:!!e.batch}):null,(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batchNote?d.jsx(Qd,{line:e.batchNote,prominent:!0}):null,e.state==="running"&&e.batchProgress?.note?d.jsx(Qd,{line:e.batchProgress.note}):null,e.state==="cancelled"&&e.settlementCaption?d.jsx(Qd,{line:e.settlementCaption}):null,e.state==="cancelled"&&e.settlementPending?d.jsx(Qd,{line:h("ui.chat.canonical.image_gen.settlement.pending")}):null,x?d.jsx(Qd,{line:x}):null,l&&r?d.jsx(qke,{onKeepWaiting:a,onRequestStop:()=>{i(!1),n?.onCancel?.()}}):null,e.state==="running"&&typeof e.note=="string"?d.jsx(Qd,{line:e.note}):null,m&&e.progress.fraction!==null?d.jsx(_7e,{"aria-label":h("ui.chat.canonical.image_gen.progress"),className:X("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,Q===null?null:d.jsx(y6t,{line:Q}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batch?d.jsx(u6t,{items:e.batch,summary:e.batchSummary??h("ui.chat.canonical.image_gen.batch_summary",{count_display:String(e.batch.length),count:e.batch.length}),scope:t}):e.state==="done"&&e.images.length>0?d.jsx("div",{className:X("flex flex-col gap-2"),children:e.images.map((w,S)=>{const _=h("ui.chat.canonical.image_gen.state.done",{material:Bu(w.kind==="audio"?e.material:w.kind??"image")}),k=e.images.length===1?_:`${_} ${S+1}`;return w.kind==="video"?d.jsx(c6t,{video:w,scope:t,label:k},w.id):w.kind==="audio"?d.jsx(DP,{audio:w,scope:t,label:k},w.id):d.jsx(eh,{image:w,scope:t,label:k},w.id)})}):null,O.length>0&&!(l&&r)?d.jsx("div",{"data-imagegen-controls":"",className:X("flex items-center gap-2"),children:O.map(w=>d.jsx(ve,{variant:"secondary",size:"sm",disabled:w.disabled,title:w.kind==="cancel"?e.state==="queued"||e.state==="cancelling"&&!e.generating?h("ui.chat.canonical.image_gen.control.stop_hint_queued"):h("ui.chat.canonical.image_gen.control.stop_hint_running"):void 0,onClick:w.kind==="cancel"&&l?()=>{const S=o.current?.closest("[data-chat-pane]")?.querySelector("[data-sound-stop-confirmation] button");if(S){S.focus();return}i(!0)}:f[w.kind],children:v6t(w.kind,e.state)},w.kind))}):null]})},sg="data-lo-quote-toolkit";function cz(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const Uee=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${sg}]`)??null,w6t=e=>e.nodeType===Node.ELEMENT_NODE,x6t=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>w6t(r)&&r.hasAttribute(sg));return n===-1?t.length:n},S6t=(e,t)=>Math.abs(e.top-t.top)<.5&&Math.abs(e.left-t.left)<.5&&Math.abs(e.right-t.right)<.5&&Math.abs(e.bottom-t.bottom)<.5,Q6t=e=>{const t=Array.from(document.querySelectorAll(`[${sg}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>S6t(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function Rp(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(Uee(n.startContainer)||Uee(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,x6t(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:Q6t(n)}}const Wee="[data-lo-canonical-transcript]",_6t="[data-lo-transcript-content]",Nee=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),k6t=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function Cke(e){const{turnRef:t,visible:n,lines:r,measureKey:i,belowWhenOffFirstLine:a}=e,o=$.useRef(null),[s,l]=$.useState(null),c=$.useRef(r);c.current=r;const u=$.useCallback(()=>{const O=t.current,f=o.current;if(!O||!f){l(null);return}const p=c.current();if(!p||p.length===0){l(null);return}const m=Ctt({lines:p,container:Nee((O.closest(Wee)??O).getBoundingClientRect()),viewport:k6t(),size:{width:f.offsetWidth,height:f.offsetHeight},row:Nee(O.getBoundingClientRect()),belowWhenOffFirstLine:a}),g=O.getBoundingClientRect(),y=m?{top:m.top-g.top,left:m.left-g.left,placement:m.placement}:null;l(v=>v===y||v&&y&&v.top===y.top&&v.left===y.left&&v.placement===y.placement?v:y)},[t,a]);return $.useLayoutEffect(()=>{if(!n){l(null);return}u();let O=0;const f=()=>{O||(O=requestAnimationFrame(()=>{O=0,u()}))};document.addEventListener("scroll",f,!0),document.addEventListener("selectionchange",f),window.addEventListener("resize",f);const p=t.current?.closest(Wee),m=p?.querySelector(_6t),g=new ResizeObserver(f);return p&&g.observe(p),m&&g.observe(m),()=>{O&&cancelAnimationFrame(O),document.removeEventListener("scroll",f,!0),document.removeEventListener("selectionchange",f),window.removeEventListener("resize",f),g.disconnect()}},[n,u,t,i]),{controlRef:o,placement:s}}function zke(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(Rp(e.current)?.text??null);return i(),document.addEventListener("selectionchange",i),()=>document.removeEventListener("selectionchange",i)},[e]);const r=$.useCallback(()=>n(null),[]);return{text:t,clear:r}}const rp="data-lo-link-toolbar",P6t=120,T6t=2;function Ake(e){const[t,n]=$.useState(null),[r,i]=$.useState(!1),a=$.useRef(null);a.current=t;const o=$.useRef(null),s=$.useRef(null),l=$.useCallback(()=>{const u=e.current;if(!u){o.current=null,n(p=>p===null?p:null),i(p=>p===!1?p:!1);return}const O=GRt(u);if(O){n(p=>p===O?p:O),i(p=>p===!0?p:!0);return}if(i(p=>p===!1?p:!1),NQe()){n(p=>p===null?p:null);return}const f=o.current&&u.contains(o.current)?o.current:null;n(p=>p===f?p:f)},[e]);$.useEffect(()=>{const u=e.current;if(!u)return;let O=0;const f=_=>{O&&(clearTimeout(O),O=0),o.current=_,l()},p=_=>{if(O&&clearTimeout(O),!_){O=0,o.current=null,l();return}o.current!==_&&(s.current=null,O=setTimeout(()=>{O=0,o.current=_,l()},P6t))},m=(_,k)=>{const R=o.current;if(!R||!u.contains(R))return!1;const E=u.querySelector(`[${rp}]`),T=uU+T6t;for(const q of[R,E]){if(!q)continue;const A=q.getBoundingClientRect();if(!(A.width<=0||A.height<=0)&&_>=A.left-T&&_<=A.right+T&&k>=A.top-T&&k<=A.bottom+T)return!0}return!1},g=_=>{const k=_.target;if(k?.closest(`[${sg}]`))return;const R=k?.closest(np)??null;!R&&m(_.clientX,_.clientY)||p(R)},y=_=>{const k=_.relatedTarget;k&&u.contains(k)||m(_.clientX,_.clientY)||f(null)},v=_=>{const k=_.target?.closest(np);if(k){if(k===s.current){s.current=null;return}f(k)}},b=_=>{const k=_.relatedTarget;k&&u.contains(k)||f(null)},x=()=>Array.from(u.querySelectorAll(`[${rp}] button:not([disabled])`)),Q=_=>{const k=_.target;if(!k)return!1;if(k.closest(`[${rp}]`)){const q=x(),A=q.indexOf(k);if(A===-1)return!1;if(_.shiftKey&&A===0){const G=o.current;return G instanceof HTMLElement?(G.focus(),!0):!1}if(!_.shiftKey&&A===q.length-1){const G=Array.from(u.querySelectorAll(np)),I=o.current,C=I?G.indexOf(I)+1:-1,U=C>0?G[C]:void 0;return U?(U.focus(),!0):!1}return!1}if(_.shiftKey)return!1;const E=k.closest(np);if(!E||!u.contains(E))return!1;o.current!==E&&f(E);const[T]=x();return T?(T.focus(),!0):!1},w=_=>{if(_.key==="Tab"&&Q(_)){_.preventDefault();return}if(!(_.key==="ContextMenu"||_.shiftKey&&_.key==="F10"))return;const R=_.target?.closest(np);!R||!u.contains(R)||(_.preventDefault(),f(R),requestAnimationFrame(()=>{u.querySelector(`[${rp}] button`)?.focus()}))},S=_=>{const k=_.target;k&&u.contains(k)||f(null)};return u.addEventListener("pointerover",g),u.addEventListener("pointerout",y),u.addEventListener("focusin",v),u.addEventListener("focusout",b),u.addEventListener("keydown",w),document.addEventListener("pointerdown",S,!0),document.addEventListener("selectionchange",l),l(),()=>{O&&clearTimeout(O),u.removeEventListener("pointerover",g),u.removeEventListener("pointerout",y),u.removeEventListener("focusin",v),u.removeEventListener("focusout",b),u.removeEventListener("keydown",w),document.removeEventListener("pointerdown",S,!0),document.removeEventListener("selectionchange",l)}},[e,l]);const c=$.useCallback(()=>{s.current=a.current,o.current=null,l()},[l]);return $.useEffect(()=>{if(!t)return;const u=O=>{if(O.key!=="Escape"||O.target?.closest(`[${rp}]`))return;const p=window.getSelection();p&&!p.isCollapsed&&p.removeAllRanges(),c()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,c]),{subject:t,quoteAvailable:r,dismiss:c}}function Uke(e,t,n){const r=Fn(i=>i.addReply);return $.useCallback(()=>{const a=Rp(t.current)?.text??(NQe()?null:n?.()??null);a&&(r(e,{id:ka(),text:a}),window.getSelection()?.removeAllRanges(),O8())},[r,e,t,n])}const Wke=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{be();const a=n.getAttribute(UQe)??"",o=n.getAttribute("data-lo-kind")??"file",s=xb(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=Uke(e,t,l),{text:u}=zke(t),{speak:O}=Km(),f=zk(e),p=u??l(),m=p===null?null:Jp(e,Ck(p).text);$me(m);const g=Uk({key:m,getText:()=>Rp(t.current)?.text??l(),play:({text:I})=>O(Jp(e,I),Ak(f,I))}),[y,v]=$.useState(!1),[b,x]=$.useState(()=>Zx(a)??null),{controlRef:Q,placement:w}=Cke({turnRef:t,visible:!0,lines:()=>{const I=n.getClientRects();return Array.from(I,C=>({top:C.top,left:C.left,right:C.right,bottom:C.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const I=Zx(a);if(x(I??null),v(!1),I!==void 0)return;let C=!0;return zRt(a,window.api?.probeFiles).then(()=>{C&&x(Zx(a)??null)}),()=>{C=!1}},[a]);const S=o==="file"&&$N(s,a),_=IQe({target:a,isDirectory:b?.exists===!0&&!b.isFile,probe:b,canOpenInCanvas:S}),k=DRt({kind:o,target:a,probe:b,quotable:r,canOpenInCanvas:S});if(!k||!a)return null;const R=async()=>{await Sb(a)&&v(!0)},E=async()=>{if(o==="url"){await mJ(o,a);return}s&&_&&await s.openInCanvas(a)||await mJ(o,a)||x(null)},T=async()=>{await Ou(a)||x(null)},q=async()=>{await CP(a)||x(null)},A={quote:d.jsx(TOe,{}),copy:y?d.jsx(Ai,{}):d.jsx(GO,{}),open:_?d.jsx(H9e,{}):o==="url"?d.jsx(Dp,{}):d.jsx(Nv,{}),"open-default":d.jsx(q6e,{}),"open-folder":d.jsx(Vp,{})},G={quote:c,copy:()=>{R()},open:()=>{E()},"open-default":()=>{T()},"open-folder":()=>{q()}};return d.jsxs(OU,{[sg]:"",[rp]:"",ref:Q,label:k.label,className:X("absolute z-20",!w&&"invisible"),style:w?{top:w.top,left:w.left}:void 0,onKeyDown:I=>{if(I.key!=="Escape")return;window.getSelection()?.removeAllRanges();const C=n;I.preventDefault(),i(),C.focus?.()},children:[k.actions.map(I=>d.jsxs($.Fragment,{children:[d.jsx($t,{content:I.id==="copy"&&y?h("ui.common.actions.copied"):I.label,side:w?.placement==="below"?"bottom":"top",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":I.id==="copy"&&y?h("ui.common.actions.copied"):I.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:G[I.id],children:A[I.id]})}),I.id==="quote"&&d.jsx(Wk,{control:g,side:w?.placement==="below"?"bottom":"top"})]},I.id)),k.note&&d.jsx("span",{className:"max-w-56 truncate ps-1 text-ink-dim text-meta",title:k.noteTitle??k.note,children:k.note})]})};function X6t({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:e==="commentary"?["copy"]:e==="response"?["copy","speak",...n]:["copy","speak",...n]}function uz(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const Yee=96;function R6t(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Yee?t:`${t.slice(0,Yee-1).trimEnd()}…`}function E6t(){return h("ui.chat.response_actions.answer_label")}function q6t(){return h("ui.chat.response_actions.yours_label")}const j6t="pointer-events-none opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100";function Gee(e){return e?"opacity-100":j6t}const Nke=2e3,C6t=1e4;function vyn(e){const{request:t}=e;return t?e.now-t.requestedAt>C6t?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let Iee=0,R1=0;const z6t=Si(e=>({request:null,requestPanel:(t,n,r,i)=>{Iee+=1,e({request:{destination:t,nonce:Iee,requestedAt:Date.now(),invoker:n??null,...r?{sessionId:r}:{},...i?.id?{entryId:i.id}:{},...i?.id&&i.excerpt?{entryExcerpt:i.excerpt}:{},...r&&i?.subjectName?{subjectName:i.subjectName}:{}}})},consumePanel:t=>e(n=>n.request?.nonce===t?{request:null}:n),presenterClaimed:!1,claimPresenter:()=>{R1+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,R1=Math.max(0,R1-1),R1===0&&e({presenterClaimed:!1}))}}})),A6t=(e,t)=>{let n=e;for(;n!==null;){if(n.matches(":hover"))return!0;if(n===t)break;n=n.parentElement}const r=e.ownerDocument.activeElement;return r!==null&&t.contains(r)},U6t=9e4,Zee=new Set,W6t=2600,Lx=$.memo(function({bodyText:t,kind:n="answer",agentId:r,speechId:i,revealId:a,revealAt:o,conversationId:s,entryId:l,overlay:c=!1,overlayClassName:u}){const[O,f]=$.useState(!1),[p,m]=$.useState(!1),g=$.useRef(null),y=$.useRef(null),v=$.useRef(null),b=$.useRef(null),{playSpeech:x}=Km(),Q=zk(r??null),w=Uk({key:i?mme(i):null,getText:()=>t,play:({text:A})=>{i&&x(i,Q,A)}}),S=z6t(A=>A.requestPanel),_=!!(s&&l);be();const k=X6t({role:n,forkable:_}),R=O||w.active;$.useEffect(()=>()=>{g.current!==null&&clearTimeout(g.current)},[]),$.useEffect(()=>{if(!a||o===void 0||Zee.has(a)||(Zee.add(a),Date.now()-o>U6t))return;const A=y.current;if(A===null)return;const G=A.closest(".group")??A;if(A6t(A,G))return;m(!0);const I=()=>{m(!1),G.removeEventListener("pointerenter",I),G.removeEventListener("focusin",I)};return G.addEventListener("pointerenter",I),G.addEventListener("focusin",I),()=>{G.removeEventListener("pointerenter",I),G.removeEventListener("focusin",I)}},[a,o]),$.useEffect(()=>{if(p)return b.current=setTimeout(()=>{b.current=null,m(!1)},W6t),()=>{b.current!==null&&clearTimeout(b.current)}},[p]);const E=async()=>{await Sb(t)&&(f(!0),g.current!==null&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,f(!1)},Nke))},T=()=>{!s||!l||S("session.fork",v.current,s,{id:l,excerpt:R6t(t)})},q={copy:d.jsx($t,{content:O?h("ui.chat.response_actions.copied"):h("ui.chat.response_actions.copy"),side:"bottom",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":O?h("ui.chat.response_actions.copied"):h("ui.chat.response_actions.copy"),className:X("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:E,children:O?d.jsx(Ai,{"aria-hidden":"true"}):d.jsx(GO,{"aria-hidden":"true"})})}),speak:d.jsx(Wk,{control:w,side:"bottom",className:X("text-ink-dim hover:bg-transparent hover:text-ink")}),fork:d.jsx($t,{content:h("ui.chat.pickers.destination_pickers.fork_from_this_message"),side:"bottom",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.pickers.destination_pickers.fork_from_this_message"),ref:v,className:X("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:T,children:d.jsx(Bze,{"aria-hidden":"true"})})})};return d.jsx("div",{role:"toolbar","aria-label":n==="user"?q6t():n==="commentary"?h("ui.chat.commentary_actions.label"):n==="response"?h("ui.chat.response_actions.label"):E6t(),ref:y,onAnimationEnd:A=>{A.target===A.currentTarget&&m(!1)},...p?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:n==="commentary"?{"data-lo-gutter-actions":""}:n==="response"?{"data-lo-response-actions":""}:{"data-lo-answer-actions":""},className:X(c?X("absolute z-10 flex h-8 items-center gap-1","-top-2 end-0",Gee(R),u):X("flex h-8 shrink-0 items-center gap-1",Gee(R))),children:k.map(A=>d.jsx($.Fragment,{children:q[A]},A))})}),N6t="video",Yke="music",Y6t=e=>(e.jobType===N6t||e.jobType===Yke)&&gf(e)&&e.music?.stage!=="cancel_requested",G6t=()=>h("ui.chat.run_controls.job.not_found"),I6t=e=>e instanceof vn&&e.status===null,byn=(e,t)=>I6t(t)?e<1:!1,wyn=e=>e instanceof vn&&e.status===404&&e.message===vue?G6t():To(e,h("ui.chat.run_controls.job.cancel_failed")),Z6t=new Set(["generate_music","modify_music"]),DN=e=>Z6t.has(e),D6t=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function VN(e){return!D6t(e)||e.material!=="music"?null:typeof e.job_id=="string"&&e.job_id.length>0?e.job_id:null}function V6t(e){const t=/^background job '[^\n]*' (completed|failed|cancelled|paused)\b/.exec(e);return t?t[1]:null}function M6t(e){const t=new Map,n=new Map;for(const r of e){if(r.kind!=="custom"||!r.jobId)continue;const i={status:V6t(r.text),receipt:r.music??null},a=r.music?.job;a&&a!==r.jobId?n.set(a,i):t.set(r.jobId,i)}for(const[r,i]of n)t.set(r,{...t.get(r)??{status:null,receipt:null},successor:i});return t}function xyn(e){const t=new Map,n=new Map;for(const r of e){if(r.jobType!==Yke)continue;const i=r.music?.job;i&&i!==r.id?n.set(i,r):t.set(r.id,r)}return{rows:t,successors:n}}const Gke=$.createContext(null),Ike=$.createContext(new Map);function Zke(e){if(!e||e.tracks.length===0)return null;let t=0,n;for(const r of e.tracks){const i=r.cost;if(!i||typeof i.amount_usd!="number"||n!==void 0&&i.basis!==n)return null;n=i.basis,t+=i.amount_usd}return Cv({cost_usd:t,billing_basis:n})}function L6t(e,{settlement:t,row:n,successorRow:r}){const i=t?.successor;if(!i&&!r||!(t?.status==="cancelled"||n?.status==="cancelled"||n?.music?.stage==="cancel_requested"||r?.music?.stage==="cancel_requested"))return null;if(i){const c=i.receipt?.tracks??[],u=c.filter(O=>O.images.length>0).length;return{...e,state:u>0?"finished_after_cancel":"cancelled",completed:c.length,total:c.length,cost:Zke(i.receipt)}}const o=r,s=o.music?.completed??0,l=o.music?.total??0;return gf(o)?{...e,state:"cancel_requested",completed:s,total:l,cost:null}:{...e,state:o.status==="done"?"finished_after_cancel":"cancelled",completed:l,total:l,cost:null}}function Dke({toolName:e,details:t,row:n,settlement:r,successorRow:i,liveLoaded:a=!1}){if(!DN(e))return null;const o=VN(t);if(o===null)return null;const l={jobId:o,modify:e==="modify_music",cost:null,cancelRow:null},c=L6t(l,{settlement:r,row:n,successorRow:i});if(c)return c;if(r?.successor||i)return Dke({toolName:e,details:t,row:i??n,settlement:r?.successor??(r?{status:r.status,receipt:r.receipt}:void 0),liveLoaded:a});if(r){const u=r.receipt?.tracks??[],O=u.filter(p=>p.images.length>0).length,f=r.status==="cancelled"?"cancelled":r.status==="failed"||u.length>0&&O===0?"failed":r.status==="completed"||O>0?"done":"unavailable";return{...l,state:f,completed:u.length,total:u.length,cost:f==="done"?null:Zke(r.receipt)}}if(n){const u=n.music?.completed??0,O=n.music?.total??0;if(!gf(n)){const m=n.status==="cancelled"?"cancelled":n.status==="failed"?"failed":"done";return{...l,state:m,completed:O,total:O}}const f=n.music?.stage,p=f==="cancel_requested"?"cancel_requested":f==="polling"||n.status==="running"?"generating":"queued";return{...l,state:p,completed:u,total:O,cancelRow:Y6t(n)?n:null}}return{...l,state:a?"unavailable":"queued",completed:0,total:0}}const F6t=({active:e,settled:t=!1,completed:n,total:r,attribution:i})=>d.jsxs("div",{"data-music-processing":"",className:X("flex min-w-0 flex-col gap-1 py-1"),children:[d.jsxs("div",{className:X("flex items-center gap-2 text-ink-muted text-body-sm"),children:[d.jsx(A9e,{size:14,"aria-hidden":"true"}),d.jsx("span",{children:h("ui.music.label")}),typeof r=="number"&&r>0&&d.jsx("span",{children:h("ui.music.progress",{completed:(n??0).toLocaleString(),total:r.toLocaleString()})})]}),d.jsx("svg",{"data-music-motif":"",width:"240",height:"44",viewBox:"0 0 240 44","aria-hidden":"true",className:X("max-w-full text-ink-dim",e&&!t&&"motion-safe:animate-pulse",t&&"opacity-40"),children:[0,1,2,3].map(a=>d.jsx("g",{transform:`translate(${a*64},0)`,children:[{id:0,height:8},{id:1,height:20},{id:2,height:32},{id:3,height:20},{id:4,height:12}].map(({height:o,id:s})=>d.jsx("rect",{x:s*6,y:(44-o)/2,width:"4",height:o,rx:"2",fill:"currentColor"},s))},a))}),i&&d.jsx("p",{className:X("text-body-sm text-ink"),children:i})]}),B6t=e=>{switch(e.state){case"queued":return h("ui.music.queued");case"generating":return e.modify?h("ui.music.modifying"):e.total>1?h("ui.music.generating_tracks",{count:e.total}):h("ui.music.generating");case"cancel_requested":return h("ui.music.cancel_requested");case"done":return h("ui.music.ready");case"failed":return h("ui.music.job_failed");case"cancelled":return h("ui.music.job_cancelled");case"finished_after_cancel":return h("ui.music.finished_after_cancel");case"unavailable":return h("ui.music.job_status.unavailable")}},H6t=new Set(["done","failed","cancelled","finished_after_cancel"]),K6t=({view:e,onCancel:t})=>{const n=e.cost;return d.jsxs("div",{"data-music-generating":e.jobId,"data-music-state":e.state,className:X("mt-2 flex min-w-0 items-start gap-2"),children:[d.jsxs("div",{className:X("flex min-w-0 flex-1 flex-col"),children:[d.jsxs("p",{"aria-live":"polite",className:X("text-body-sm",e.state==="failed"?"text-danger":"text-ink"),children:[B6t(e),n&&d.jsxs("span",{className:X("text-ink-muted"),children:[" ",n]})]}),d.jsx(F6t,{active:e.state==="generating",settled:H6t.has(e.state),completed:e.completed,total:e.total})]}),e.cancelRow&&t&&d.jsx(ve,{variant:"ghost",size:"sm","data-music-cancel":e.jobId,"aria-label":h("ui.chat.run_details.job_cancel_aria",{label:e.cancelRow.label}),className:X("h-6 shrink-0 px-1.5 hover:bg-danger-wash hover:text-danger"),onClick:r=>t(r.currentTarget.getBoundingClientRect()),children:h("ui.common.actions.cancel")})]})},J6t=5e3,ezt=(e,t)=>{const n=$.useContext(Gke),r=$.useContext(Ike),i=VN(t),a=i?n?.rows.get(i):void 0,o=i?n?.successors?.get(i):void 0,s=i?r.get(i):void 0,l=i!==null&&n?.loaded===!0&&!a&&!o&&!s,[c,u]=$.useState(null);return $.useEffect(()=>{if(!l||i===null)return;const O=setTimeout(()=>u(i),J6t);return()=>clearTimeout(O)},[l,i]),Dke({toolName:e,details:t,row:a,settlement:s,successorRow:o,liveLoaded:l&&c===i})},tzt=({view:e})=>{const n=$.useContext(Gke)?.request??null,r=e.cancelRow;return d.jsx(K6t,{view:e,onCancel:n&&r?i=>n(r,{left:i.left,top:i.top,bottom:i.bottom,right:i.right}):void 0})},nzt=({receipt:e,scope:t})=>d.jsxs("div",{"data-music-result":"",className:X("mt-2 flex min-w-0 flex-col gap-3"),children:[e.attribution&&d.jsx("p",{className:X("text-body-sm text-ink"),children:e.attribution}),e.tracks.length===0&&d.jsx("p",{className:X("text-body-sm text-ink-muted"),children:h("ui.music.empty")}),e.tracks.map(n=>{const r=n.title||h("ui.music.track",{index:(n.variantIndex+1).toLocaleString()}),i=n.cost?Cv({cost_usd:n.cost.amount_usd,billing_basis:n.cost.basis}):null;return d.jsxs("div",{"data-music-track":n.id,className:X("flex min-w-0 flex-col gap-1"),children:[d.jsx("p",{className:X("text-body-sm text-ink"),children:r}),n.title&&e.tracks.length>1&&d.jsx("p",{className:X("text-body-sm text-ink-muted"),children:h("ui.music.track",{index:(n.variantIndex+1).toLocaleString()})}),n.images.map(a=>d.jsx(DP,{audio:a,scope:t,label:a.name||r},a.id)),n.error&&d.jsx("p",{className:X("text-body-sm text-danger"),children:h("ui.music.failed")}),i&&d.jsx("p",{className:X("text-body-sm text-ink-muted"),children:i})]},n.id)})]}),Vke="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",E1="@min-[260px]/olderhistory:hidden",q1="@max-[260px]/olderhistory:hidden",Mke="lo-older-history-hint",rzt=({state:e,loadingVariant:t="older",transportDown:n=!1,onLoadOlder:r,onRetryHydration:i})=>{be();const a=e==="loading"?Rke(t):e==="failed"?n?h("ui.chat.canonical.older_history.transport.long"):h("ui.chat.canonical.older_history.failed.long"):e==="unproven"?h("ui.chat.canonical.older_history.unproven.long"):null,o=e==="loading";return d.jsxs("div",{className:Vke,children:[d.jsx("output",{className:"sr-only","aria-live":"polite",children:a}),e==="failed"&&n?d.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:[d.jsx("span",{className:E1,children:h("ui.chat.canonical.older_history.transport.short")}),d.jsx("span",{className:q1,children:h("ui.chat.canonical.older_history.transport.long")})]}):e==="failed"?d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"min-w-0 truncate text-danger text-meta",title:h("ui.chat.canonical.older_history.failed.long"),children:[d.jsx("span",{className:E1,children:h("ui.chat.canonical.older_history.failed.short")}),d.jsx("span",{className:q1,children:h("ui.chat.canonical.older_history.failed.long")})]}),d.jsx(ve,{variant:"ghost",size:"sm",className:"shrink-0",onClick:r,children:h("ui.chat.canonical.older_history.try_again")})]}):o?d.jsx(ve,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:s=>{s.preventDefault()},className:"min-w-0 text-ink-muted",children:d.jsx(lz,{variant:t,announce:!1})}):e==="idle"?d.jsx(ve,{variant:"ghost",size:"sm",onClick:r,children:h("ui.chat.canonical.older_history.load")}):e==="windowed"?d.jsxs("span",{id:Mke,className:"min-w-0 truncate text-ink-dim text-meta",title:n?h("ui.chat.canonical.older_history.windowed.title"):h("ui.chat.canonical.older_history.windowed.title_gesture"),children:[d.jsx("span",{className:E1,children:n?h("ui.chat.canonical.older_history.windowed.title"):h("ui.chat.canonical.older_history.windowed.short_gesture")}),d.jsx("span",{className:q1,children:n?h("ui.chat.canonical.older_history.windowed.title"):h("ui.chat.canonical.older_history.windowed.title_gesture")})]}):e==="unproven"?d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",title:h("ui.chat.canonical.older_history.unproven.long"),children:[d.jsx("span",{className:E1,children:h("ui.chat.canonical.older_history.unproven.short")}),d.jsx("span",{className:q1,children:h("ui.chat.canonical.older_history.unproven.long")})]}),!n&&i&&d.jsx(ve,{variant:"ghost",size:"sm",className:"shrink-0",onClick:i,children:h("ui.chat.canonical.older_history.try_again")})]}):d.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:h("ui.chat.canonical.older_history.conversation_start")})]})},izt=()=>d.jsx("div",{"aria-hidden":"true",className:Vke}),azt="/settings?section=providers",Dee="/settings?section=providers&provider=radient",ozt="/settings?section=radient",Vee=/sign in to radient/i,szt=[/insufficient credits/i,/credit balance is too low/i],lzt=[/rate limit or quota/i],czt=[/insufficient credits/i,/\bHTTP 402\b/i];function Lke(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function MN(e){return Lke(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&czt.some(n=>n.test(e.text)):!1}function uzt(e){if(!MN(e))return null;const t=/rate limit or quota( exceeded)?\s*/i;if(!t.test(e.headline))return{label:"billing",headline:e.headline};const n=e.headline.replace(t,"").trim(),r=/^\((HTTP \d{3})\):?\s*(.*)$/i.exec(n),i=(r?r[2]:n.replace(/^:\s*/,"")).trim(),a=r?` (${r[1]})`:"";return{label:"billing",headline:i?h("ui.chat.provider_error.headline.out_of_credits",{status:a,body:i}):h("ui.chat.provider_error.headline.out_of_credits_refused",{status:a})}}function Ozt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function Mee(e){const t=Lke(e.provider)||Vee.test(e.text);let n=Ozt(e.category);return MN(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(Vee.test(e.text)?n="sign-in":szt.some(r=>r.test(e.text))?n="billing":lzt.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:h("ui.chat.provider_error.action.sign_in_radient"),to:Dee}:n==="billing"&&t?{label:h("ui.chat.provider_error.action.open_radient_account"),to:ozt}:{label:h("ui.chat.provider_error.action.open_provider_settings"),to:t?Dee:azt}}const Fke=({conversationId:e,turnRef:t,allowQuote:n=!0})=>{be();const{text:r,clear:i}=zke(t),a=r!==null,o=Uke(e,t);$.useEffect(()=>{const v=t.current;if(!v||!a)return;const b=v.closest("[data-record-id]")??v,x=[...b.querySelectorAll("[data-lo-gutter-actions], [data-lo-user-actions], [data-lo-answer-actions], [data-lo-response-actions]")];b.setAttribute("data-lo-selection-active","");for(const Q of x)Q.setAttribute("inert",""),Q.setAttribute("aria-hidden","true");return()=>{b.removeAttribute("data-lo-selection-active");for(const Q of x)Q.removeAttribute("inert"),Q.removeAttribute("aria-hidden")}},[a,t]);const[s,l]=$.useState(!1),c=$.useRef(null);$.useEffect(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);const u=$.useCallback(async()=>{const v=Rp(t.current)?.text??r;v&&await Sb(v)&&(l(!0),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l(!1)},Nke))},[r,t]),{controlRef:O,placement:f}=Cke({turnRef:t,visible:a,lines:()=>Rp(t.current)?.lines??null}),{speak:p}=Km(),m=zk(e),g=r===null?null:Jp(e,Ck(r).text);$me(g);const y=Uk({key:g,getText:()=>Rp(t.current)?.text??null,play:({text:v})=>p(Jp(e,v),Ak(m,v))});return $.useEffect(()=>{if(!a)return;const v=b=>{b.key!=="Escape"||b.defaultPrevented||(window.getSelection()?.removeAllRanges(),i())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[a,i]),a?d.jsxs(OU,{[sg]:"",ref:O,label:h("ui.chat.transcript_copy.selection.toolbar"),className:X("absolute z-20",!f&&"invisible"),style:f?{top:f.top,left:f.left}:void 0,children:[n&&d.jsx($t,{content:h("ui.chat.transcript_copy.selection.quote"),side:f?.placement==="below"?"bottom":"top",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.transcript_copy.selection.quote"),className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:o,children:d.jsx(TOe,{})})}),d.jsx($t,{content:s?h("ui.chat.transcript_copy.toast.copied_selection"):h("ui.chat.transcript_copy.selection.copy"),side:f?.placement==="below"?"bottom":"top",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":s?h("ui.chat.transcript_copy.toast.copied_selection"):h("ui.chat.transcript_copy.selection.copy"),className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:()=>{u()},children:s?d.jsx(Ai,{}):d.jsx(GO,{})})}),d.jsx(Wk,{control:y,side:f?.placement==="below"?"bottom":"top"})]}):null},Bke={all:["radient-prices"],prices:()=>[...Bke.all,"prices"]},dzt=()=>{const e=St({queryKey:Bke.prices(),queryFn:()=>N8({operation:"prices"}),staleTime:36e5,refetchOnWindowFocus:!1,refetchOnMount:!0,refetchInterval:!1,retry:3});return{prices:e.data,isLoading:e.isLoading,isFetching:e.isFetching,error:e.error,pricesQuery:e}},Lee="https://console.radienthq.com/dashboard/verification",fzt="https://console.radienthq.com",Fee="https://console.radienthq.com/dashboard/billing",Bee=()=>h("ui.common.account.top_up");function hzt(e){return!e.email_verified&&e.signup_grant!=="claimed"}const Syn=e=>typeof e!="number"||!Number.isFinite(e)?h("ui.common.account.free_credits_unknown"):h("ui.common.account.free_credits",{amount:`$${e.toFixed(2)}`}),Oz=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,pzt=e=>typeof e!="number"||!Number.isFinite(e)?h("ui.common.account.free_credits_unknown"):h("ui.common.account.free_credits",{amount:Oz(e)});function dz(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}const Qyn="/settings?section=radient";function Hke(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const mzt=(e,t)=>e==="pending"?{sentence:h("ui.common.account.verify_pending",{amount:t}),action:h("ui.common.account.open_verification")}:e==="expired"?{sentence:h("ui.common.account.verify_expired",{amount:t}),action:h("ui.common.account.request_new_link")}:{sentence:h("ui.common.account.verify_none"),action:h("ui.common.account.open_verification")};function gzt(e,t){if(e===void 0)return{state:"unknown",lines:[h("ui.common.account.out_unknown_verify"),h("ui.common.account.out_unknown_top_up")],links:[{label:h("ui.common.account.open_verification"),url:Lee},{label:Bee(),url:Fee}]};if(hzt(e)){const i=dz(e.claim_url,Lee),{action:a}=mzt(e.signup_grant,"");if(e.signup_grant==="none")return{state:"unverified",lines:[h("ui.common.account.out_unverified_none")],links:[{label:a,url:i}]};const o=pzt(e.grant_amount??t);return{state:"unverified",lines:[h("ui.common.account.out_unverified_claim",{amount:o}),e.signup_grant==="expired"?h("ui.common.account.out_unverified_expired"):h("ui.common.account.out_unverified_inbox")],links:[{label:a,url:i}]}}const n=e.first_topup,r=[h("ui.common.account.out_verified")];return n!==void 0&&n.bonus_received===!1&&Number.isFinite(n.bonus_amount)&&Number.isFinite(n.minimum_purchase)&&r.push(h("ui.common.account.first_top_up_bonus",{bonus:Oz(n.bonus_amount),minimum:Oz(n.minimum_purchase)})),{state:"verified",lines:r,links:[{label:Bee(),url:dz(n?.topup_url,Fee)}]}}const $zt=5*1e3,yzt=({action:e})=>{const{user:t,accountRead:n}=khe({staleTime:$zt,retryOnMount:!1}),r=dr(),{prices:i}=dzt(),o=r.isPending||n==="checking"?null:gzt(n==="ready"?t?.verification:void 0,i?.default_new_credits);return d.jsxs("div",{className:"mt-1 flex flex-col items-start gap-2 ps-6",children:[o?d.jsxs("div",{"data-radient-credits-state":o.state,className:"flex max-w-[60ch] items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[d.jsx(Ip,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),d.jsx("div",{className:"min-w-0 text-body-sm text-ink",children:o.lines.map(s=>d.jsx("p",{className:"[&:not(:first-child)]:mt-1",children:s},s))})]}):null,d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?.links.map(s=>d.jsx(ve,{variant:"secondary",size:"sm",onClick:()=>Hke(s.url),children:s.label},s.url)),d.jsx(ve,{variant:"ghost",size:"sm",asChild:!0,children:d.jsx(mOe,{to:e.to,children:e.label})})]})]})},J0="data-jump-highlight",vzt=1400,a4=new WeakMap;function fz(e){const t=a4.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(J0);e.removeAttribute(J0),n&&e.offsetHeight,e.setAttribute(J0,""),a4.set(e,window.setTimeout(()=>{a4.delete(e),e.removeAttribute(J0)},vzt))}const Fx=24,Kke=6,hz=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),Hee=async e=>{for(let t=0;t<Kke;t+=1){if(e())return;await hz()}},Jke=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},bzt=e=>{const t=Jke(e.loadOlder),n=()=>Hee(()=>e.reachable()||e.rowDistance()!==null);return{loadOne:t,loadThrough:async i=>{const a=e.hasHeadroom??(()=>!0);let o=0;for(;;){if(e.reachable())return"landed";const s=e.rowDistance();if(s!==null){if(i.maxRows!==void 0&&s>i.maxRows)return"over-budget";if(!a()&&o<i.maxPages&&(o+=1,await t())){await n();continue}return e.mount(s),await Hee(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},wzt=12,xzt=1200,Szt=Kke,Qzt=Szt+2,_zt=2,kzt=30,Kee=1,v0=Fx;let Gh=0;async function Pzt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await bzt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:wzt,maxRows:xzt})==="landed"}async function Tzt(e,t,n){if(!n()||!t.isConnected)return;Gh+=1;const r=Gh;gx(e,t,"reversed",v0);const i=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);let a=!1;const o=()=>{a=!0},s=l=>{i.has(l.key)&&(a=!0)};e.addEventListener("wheel",o,{passive:!0,once:!0}),e.addEventListener("pointerdown",o,{passive:!0,once:!0}),e.addEventListener("touchstart",o,{passive:!0,once:!0}),window.addEventListener("keydown",s);try{let l=0,c=!1;for(let u=0;u<Qzt&&(await hz(),!(!n()||!t.isConnected||a||r!==Gh));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-v0;if(Math.abs(O)<=Kee){if(l+=1,l>=_zt){c=!0;break}continue}l=0,gx(e,t,"reversed",v0)}if(c&&!a&&r===Gh){const u=e,O=t,f=()=>{a=!0};u.addEventListener("wheel",f,{passive:!0,once:!0}),u.addEventListener("pointerdown",f,{passive:!0,once:!0}),u.addEventListener("touchstart",f,{passive:!0,once:!0}),window.addEventListener("keydown",s),(async()=>{try{for(let p=0;p<kzt;p+=1){if(await hz(),!n()||a||r!==Gh||!u.isConnected||!O.isConnected)return;const m=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-v0;if(Math.abs(m)<=Kee)continue;gx(u,O,"reversed",v0);const g=u.ownerDocument?.defaultView;g!=null&&u.dispatchEvent(new g.Event("scroll"))}}finally{u.removeEventListener("wheel",f),u.removeEventListener("pointerdown",f),u.removeEventListener("touchstart",f),window.removeEventListener("keydown",s)}})()}}finally{e.removeEventListener("wheel",o),e.removeEventListener("pointerdown",o),e.removeEventListener("touchstart",o),window.removeEventListener("keydown",s)}if(n()&&!a&&r===Gh){const l=e.ownerDocument?.defaultView;l!=null&&e.dispatchEvent(new l.Event("scroll"))}}function ePe(e,t,n,r=()=>!0){return r()?new Promise(i=>{o6t(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}fz(a),Tzt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(J0)&&fz(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const mO=120,j1=400,Xzt=.5,Rzt=320,Ezt=900,C1=64,MP=2,o4=24,s4=3,qzt=4,Ly=12,pz=Ly,jzt=120,Czt=.35,Jee=12,zzt=8,Azt=Ly,Uzt=.5,ete=()=>({armed:!1,deliberate:!1,retained:!1,busy:!1,continuation:!1,clampLatched:!1,actFetchSpent:!1,travelledSinceLatch:!1,actTravelled:!1,pressDemand:!1,pageWidenOwed:!1,turnedAround:!1,lastInputAt:Number.NEGATIVE_INFINITY,failures:0,chainFetch:0,chainWiden:0,chainInvisible:0,actAsks:0,revealsThisAct:0}),tPe=e=>Math.min(Ezt,Math.max(Rzt,Math.round(e*Xzt))),Wzt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=j1?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=j1?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=j1?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,actTravelled:e.actTravelled||t.travelledPx>=C1,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=j1,r={...e,actFetchSpent:n?!1:e.actFetchSpent,actAsks:n?0:e.actAsks,revealsThisAct:n?0:e.revealsThisAct,travelledSinceLatch:n?!1:e.travelledSinceLatch,actTravelled:n?t.travelledPx>=C1:e.actTravelled||t.travelledPx>=C1,continuation:!1,turnedAround:!1,chainFetch:0,chainInvisible:0,chainWiden:0,lastInputAt:t.at};return t.deliberate?{...r,clampLatched:!1,failures:0,deliberate:!0,actFetchSpent:!1,actAsks:0,revealsThisAct:0,actTravelled:!1,pressDemand:!1,...e.busy?{retained:!0}:{armed:!0}}:t.atHardTop&&t.continuous&&e.clampLatched&&!n?t.travelledPx>=C1&&!e.travelledSinceLatch?{...r,armed:!0,pressDemand:!1,clampLatched:!1,travelledSinceLatch:!0}:!e.armed&&e.clampLatched&&!e.actTravelled?{...e,armed:!0,pressDemand:!0,lastInputAt:t.at}:{...e,lastInputAt:t.at}:e.busy?{...r,retained:!0,pressDemand:!1}:{...r,armed:!0,pressDemand:!1}},b0=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=MP,pageWidenOwed:e.pageWidenOwed&&t!=="widen",actFetchSpent:t==="fetch"?!0:e.actFetchSpent,chainWiden:t==="widen"?e.chainWiden+1:e.chainWiden,chainFetch:t==="fetch"?e.chainFetch+1:e.chainFetch,actAsks:t==="fetch"?e.actAsks+1:e.actAsks,revealsThisAct:e.revealsThisAct+1,chainInvisible:e.chainInvisible}}),Nzt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!nPe(t).inZone?!1:t.distanceFromTopPx<=MP?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=pz?!1:n-e.lastInputAt>=mO:!0;function nPe(e,t=tPe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const Yzt=(e,t,n)=>{if(e.busy)return{action:"none",state:e};const r=t.hiddenRows>0?"widen":t.hasMore?"fetch":"none";if(r==="none")return{action:"none",state:e.armed||e.continuation?{...e,armed:!1,deliberate:!1,continuation:!1}:e};if(t.followingTail&&t.scrollable)return e.armed?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e};const i=tPe(t.clientHeight),{inZone:a}=nPe(t,i),o=n-e.lastInputAt>=mO||t.distanceFromTopPx<=MP,s=e.revealsThisAct<Azt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<Jee&&s)return o?b0({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed){if(e.deliberate)return b0(e,r,t);if(r==="fetch"&&e.failures>=s4)return{action:"none",state:{...e,armed:!1}};if(!o)return{action:"none",state:e};if(!a)return{action:"none",state:{...e,armed:!1}};if(r==="fetch"&&e.actFetchSpent){const l=n-e.lastInputAt>=mO;return l&&e.clampLatched&&!e.actTravelled&&e.pressDemand&&e.actAsks<pz?b0(e,r,t):l?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e}}return b0(e,r,t)}if(e.continuation){const l=e.actAsks<pz,c=l&&e.chainInvisible>0&&e.chainInvisible<Ly;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<Jee:(c||l&&e.chainFetch<qzt)&&e.failures<s4)?b0({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},tte=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<zzt,l=r===null&&t&&i!==null&&i<Math.max(jzt,Czt*a),c=s||t&&o===0||l;return{...e,busy:!1,failures:t?0:e.failures,armed:e.retained,pressDemand:e.retained&&e.pressDemand,deliberate:e.retained?e.deliberate:!1,retained:!1,turnedAround:!1,pageWidenOwed:t&&n>0,actFetchSpent:c?!1:e.actFetchSpent,chainInvisible:c?Math.min(e.chainInvisible+1,Ly):0,continuation:t&&n>0||c&&e.chainInvisible+1<Ly||!e.retained&&!e.turnedAround}},Gzt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),Izt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),Zzt=(e,t,n,r)=>n===r?rPe(e,t):null,rPe=(e,t)=>{if(!e||!t||e.id!==t.id||e.extent===t.extent)return 0;const n=t.viewportOffset-e.viewportOffset;return Math.abs(n)<Uzt?0:n};function DQ({path:e}){switch(L8(e)){case"image":return d.jsx(bOe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return d.jsx(wOe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return d.jsx(ey,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return d.jsx(Nv,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}function Dzt(e,t){try{return $N(e,t)}catch{return!1}}function kb(e,t,n,r){const i=$.useCallback(async s=>{try{const l=r?await r():e,[c]=await window.api.probeFiles([l],t??void 0);if(!c?.resolved.startsWith("/"))throw new Error("File path has no session working directory");await s(c.resolved)}catch{Jn(h("ui.chat.highlights.file_resolution_failed"))}},[e,t,r]),a=Dzt(n??null,e),o=$.useCallback(()=>{i(async s=>{a&&n&&await n.openInCanvas(s)||await Ou(s)})},[i,a,n]);return{canOpenInCanvas:a,press:o,withTarget:i}}const LP=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1,resolveActionPath:o,missing:s=!1}){be();const{canOpenInCanvas:l,withTarget:c}=kb(t,r,i,o),[u,O]=$.useState(!1),f=n?h("ui.common.actions.actions_for_name",{name:n}):h("ui.common.actions.file_actions_menu.file_actions");return d.jsxs(ck,{children:[d.jsx($t,{content:h("ui.common.actions.file_actions_menu.file_actions"),children:d.jsx(uk,{asChild:!0,children:a?d.jsx(ve,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":f,children:d.jsx(gS,{"aria-hidden":"true"})}):d.jsx("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center text-ink-dim opacity-0 group-hover:opacity-100 focus-visible:opacity-100","aria-label":f,children:d.jsx(gS,{"aria-hidden":"true",className:"size-3.5"})})})}),d.jsxs(Ok,{align:"end",className:"min-w-45",children:[l&&!s&&d.jsxs(Fo,{onSelect:()=>{c(p=>i?.openInCanvas(p))},children:[d.jsx(SOe,{"aria-hidden":"true"}),d.jsx("span",{children:h("ui.chat.canonical.supplement.file_actions.open_in_canvas")})]}),!s&&d.jsxs(Fo,{onSelect:()=>{c(Ou)},children:[d.jsx(Nv,{"aria-hidden":"true"}),d.jsx("span",{children:h("ui.chat.canonical.supplement.file_actions.open_in_default_app")})]}),!s&&d.jsxs(Fo,{onSelect:()=>{c(CP)},children:[d.jsx(Vp,{"aria-hidden":"true"}),d.jsx("span",{children:h("ui.chat.canonical.supplement.file_actions.reveal_in_finder")})]}),d.jsxs(Fo,{onSelect:()=>{(o&&!s?o():Promise.resolve(t)).then(p=>navigator.clipboard.writeText(p)).then(()=>O(!0)).catch(()=>Jn(h("ui.notices.files.copy_path_failed")))},children:[d.jsx(DA,{"aria-hidden":"true"}),d.jsx("span",{children:u?h("ui.common.actions.copied"):h("ui.common.file_actions.copy_file_path")})]})]})]})});function Vzt(e){return e.materialisable===!1&&!e.stored?"gone":e.exists===!0?"present":e.exists===!1?e.stored?"retained":"gone":e.stored?"present":"gone"}const LN=(e,t,n)=>`${e}:${t??`#${n}`}`;function Mzt(e){if(!e||typeof e.message_id!="string"||!e.message_id||e.kind!=="document"&&e.kind!=="image")return null;const t=typeof e.attachment=="string"&&e.attachment?e.attachment:null;return{key:LN(e.message_id,t,e.index??0),messageId:e.message_id,ts:Math.round((typeof e.ts=="number"?e.ts:0)*1e3),kind:e.kind,digest:t,data:null,filename:e.filename??null,mimeType:e.mime_type??(e.kind==="image"?"image/png":"application/octet-stream"),bytes:typeof e.bytes=="number"?e.bytes:null,path:e.path??null,storedPath:e.stored_path??null,availability:Vzt(e),index:typeof e.index=="number"?e.index:0,materialisable:typeof e.materialisable=="boolean"?e.materialisable:null,originExists:typeof e.exists=="boolean"?e.exists:null}}function Lzt(e,t,n){return{key:LN(e.id,t.attachment,n),messageId:e.id,ts:e.ts,kind:"document",digest:t.attachment,data:null,filename:t.filename,mimeType:t.mimeType,bytes:t.bytes>0?t.bytes:null,path:t.path,storedPath:t.storedPath,availability:"unknown",materialisable:null}}function Fzt(e,t,n){return{key:LN(e.id,t.attachment,n),messageId:e.id,ts:e.ts,kind:"image",digest:t.attachment,data:t.data,filename:t.name??null,mimeType:t.mimeType,bytes:t.sizeBytes??null,path:null,storedPath:null,availability:"unknown",materialisable:null}}function iPe(e){const t=[];for(const n of e??[])n.kind==="user"&&((n.documents??[]).forEach((r,i)=>{t.push(Lzt(n,r,i))}),n.images.forEach((r,i)=>{r.kind!==void 0&&r.kind!=="image"||t.push(Fzt(n,r,i))}));return t}function Bzt(e,t,n=!1){const r=e?.state==="ready",i=r?(e?.items??[]).map(Mzt).filter(m=>m!==null):[],a=!n||e?.state==="unsupported"?"none":r?i.length>0&&i.every(m=>m.materialisable===null)?"none":"ready":"pending",o=new Map(i.map(m=>[m.key,m])),s=new Map;for(const m of i){const g=`${m.messageId}:${m.kind}`;s.set(g,(s.get(g)??0)+1)}const l=iPe(t),c=new Map,u=Kzt({items:i,verdicts:a}),O=new Map;for(const m of l){const g=`${m.messageId}:${m.kind}`;O.set(g,(O.get(g)??0)+1)}const f=new Map,p=[...i];for(const m of l){const g=`${m.messageId}:${m.kind}`,y=f.get(g)??0;if(f.set(g,y+1),o.has(m.key))continue;const v=mz(u,{messageId:m.messageId,kind:m.kind,position:y,count:O.get(g)??0,digest:m.digest,path:m.path}),b=v===null?m:{...m,materialisable:v};if(b.digest===null){const x=`${b.messageId}:${b.kind}`,Q=c.get(x)??0;if(c.set(x,Q+1),Q<(s.get(x)??0))continue}o.set(b.key,b),p.push(b)}return p.sort((m,g)=>g.ts-m.ts),{items:p,complete:r,truncated:!!e?.truncated,verdicts:a}}const Pb={digests:new Set,slots:new Map,paths:new Set,verdicts:"none",judged:new Map},Hzt={...Pb,verdicts:"pending"};function Kzt(e){const t=e.verdicts??"none";if(t==="pending")return Hzt;const n=new Set,r=new Set,i=new Map,a=new Map;for(const s of e.items){if(typeof s.materialisable!="boolean"||s.index===void 0)continue;const l=`${s.messageId}:${s.kind}`;i.set(l,(i.get(l)??0)+1);const c=s.materialisable===!1;c&&s.digest&&n.add(s.digest),c&&s.path&&r.add(s.path);const u=a.get(l)??[];u.push({index:s.index,refused:c}),a.set(l,u)}const o=new Map;for(const[s,l]of a)l.some(c=>c.refused)&&(l.sort((c,u)=>c.index-u.index),o.set(s,l.map(c=>c.refused)));return!o.size&&t==="none"?Pb:{digests:n,slots:o,paths:r,verdicts:t,judged:i}}function mz(e,t){if(t.digest&&e.digests.has(t.digest)||t.path&&e.paths.has(t.path))return!1;if(e.verdicts==="pending")return"pending";const n=`${t.messageId}:${t.kind}`,r=e.slots.get(n);return r&&(r.length!==t.count||r[t.position])?!1:e.verdicts==="ready"&&(e.judged.get(n)??0)<t.count?"pending":null}function nte(e,t){return e&&t!==!1&&t!=="pending"}function _yn(e){return new Set(e.items.map(t=>t.digest).filter(t=>t!==null))}function kyn(e,t,n=0,r=!0){const i=dr(),a=i.data!==void 0,o=kn(i.data,"session_attachments"),s=$.useMemo(()=>iPe(t),[t]),l=s.map(R=>`${R.key}:${R.digest??""}`).join("|"),[c,u]=$.useState({key:"",value:null,state:"loading"}),O=`${e??"draft"}:${o}`,[f,p]=$.useState(0),{echoIds:m,durableIds:g}=$.useMemo(()=>{const R=new Set(s.map(q=>q.messageId)),E=[],T=[];for(const q of t??[])q.kind!=="user"||!R.has(q.id)||(q.local||q.provisional?E:T).push(q.id);return{echoIds:E.join(`
|
|
945
945
|
`),durableIds:T.join(`
|
|
@@ -1071,4 +1071,4 @@ ${g}`,K=A.current;A.current=Z,!(K===null||K===Z)&&(uOn(K.split(`
|
|
|
1071
1071
|
|
|
1072
1072
|
${yr}`:xs,re),Gi=Hi?void 0:async xs=>(Ee=await rl(M,xs),ai(Ee.text)),p2=ai(Be.text),qu=await e(p2,$e.map(xs=>xs.path),he,M,Gi,Db());return qu!==!1&&(il.current=!1,ad.current=!1),qu!==!1&&Ee&&(Ee.stored.length>0&&Ls(kJ(Ee.stored)),Ee.refused.length>0&&Kh(PJ(Ee.refused)),Ee.unconfirmed.length>0&&Kh(TJ(Ee.unconfirmed))),qu===!1?qu:Z8(qu)?(The(qu,kg),qu):(kg(),qu)},[e,$e,re,kg,rl,Hi,Zb,L?.onOpenDraftPicker,Db,Se,Ue,Tg,B5,q,ae]),Ki=fn(M=>OHe(M.drafts,f)),{inputValue:Xe,setInputValue:Ln,handleKeyDown:Rg,handleSubmit:ph,textareaRef:Dt,sendInFlight:Xu,appendTranscriptText:Vb}=ZFe({conversationId:f,onSubmit:Xg,scrollToBottom:x,draftHeld:Ya(Ni),transcriptless:N,draftUnredacted:Pu}),Ru=Xu||Ki;$.useEffect(()=>{Xe===""&&!Xu&&!Ki&&(il.current=!1,ad.current=!1)},[Xe,Xu,Ki]);const mh=XJ(xg,Xe),[Xr,Pi]=$.useState(0),[ac,Eg]=$.useState(!1),gh=gfn(f),al=ie??!1,lt=ihn({inputValue:Xe,selectionStart:Xr,sessionId:gh,paneHasSession:al,activeProfile:{team:L?.frontend?.active_team,agent:L?.frontend?.active_agent},activeModel:VQ(L?.frontend?.effective_model??L?.frontend?.selected_model),activeSpec:L?.frontend?.effective_model??L?.frontend?.selected_model,cwd:q}),Mb=tc&&!(lt.open&<.phase==="argument"),hr=afn({text:Xe,caret:Xr,cwd:q,attached:al,commandNames:lt.commandNames,argumentWords:lt.argumentWords,enabled:!Ya(Ni)});$.useEffect(()=>{Pg.current=hr.vocabulary.map(M=>M.name)},[hr.vocabulary]);const Eo=bdn({text:Xe,caret:Xr,cwd:q,enabled:ne,unsupported:J}),ri=hhn({text:Xe,cwd:q,enabled:ne}),$h=$.useMemo(()=>[...ri.resolved.values()].filter(M=>M.outside).length,[ri.resolved]),ii=$.useRef(null),qg=$.useRef(null),jg=$.useRef(null);$.useLayoutEffect(()=>{f!==void 0&&jg.current!==f&&Xe&&(jg.current=f,ii.current=Xe.length,Pi(Xe.length))},[Xe,f]);const Lb=$.useRef(Xe);$.useLayoutEffect(()=>{Lb.current=Xe;const M=Dt.current,he=ii.current;!M||he===null||(ii.current=null,M.setSelectionRange(he,he))},[Xe,Dt,Tr]);const Cg=$.useCallback(()=>[...hh.current,...[...Rn.current.values()].map(M=>M.key)],[]),zg=$.useCallback((M,he)=>{f&&(Ya(M)||Fn.getState().setCurrentInput(f,he,Pu(he)))},[f,Pu]),ya=$.useCallback(M=>{const he=M.payload??null;he&&(Rn.current.set(he.index,he),tl.current=Math.max(tl.current,he.index+1)),M.buffer!==Lb.current&&(ii.current=M.caret,Pi(M.caret)),rc.current=M.buffer,Tu.current!==null&&!M.buffer.includes(Tu.current.trim())&&(Tu.current=null),nl.current!==null&&!M.buffer.includes(nl.current.text.trim())&&(nl.current=null),ro(M.capture),Ln(M.buffer),zg(M.capture,M.buffer)},[zg,ro,Ln]);$.useLayoutEffect(()=>{rc.current!==Xe&&(rc.current=Xe,nEt(Pr.current)&&(ro(Za),Tr(null)))},[Xe,ro,Tr]),$.useEffect(()=>{Pr.current=Za,ro(Za),Rn.current.clear(),tl.current=1,fh.current=!1,nl.current=null,Tu.current=null,ic.current=null,Tr(null),$s(null),ys(null)},[f,ro,Tr]);const od=Fn(M=>f?M.getUnredactedChars(f):0),oc=Fn(M=>f?M.getCurrentInput(f):"");$.useEffect(()=>{od<=0||!oc||Xe!==oc||uh.current?.over!==oc&&Tr({chars:od,over:oc})},[od,oc,Xe,Tr]),$.useLayoutEffect(()=>{const M=uh.current;M&&M.over!==Xe&&Tr(null)},[Xe,Tr]),$.useLayoutEffect(()=>{const M=dh.current;M&&M.over!==Xe&&nc(null)},[Xe,nc]),$.useEffect(()=>{fh.current&&(_J(Xe,Rn.current.values()).length>0||(Rn.current.clear(),tl.current=1,fh.current=!1))},[Xe,Gb]),$.useEffect(()=>{Ni.arm===null||!Hi||_g.current!==Hi&&(_g.current=Hi,Te({op:"sessions.credential",sessionId:Hi,action:"list"}).then(M=>{hh.current=bN(M)}).catch(()=>{}))},[Ni.arm,Hi]);const sd=$.useCallback(()=>{const M=Pr.current;if(!Ya(M))return!1;const he=aEt({capture:M,buffer:Xe,caret:Dt.current?.selectionEnd??Xe.length,index:tl.current,taken:Cg()});return he.minted?(ya(he),Tr(null),!0):!1},[ya,Xe,Cg,Tr]),ld=$.useCallback(M=>{const he=Pr.current;if(!Ya(he))return!1;const Ee=M.currentTarget,Be={start:Ee.selectionStart??Xe.length,end:Ee.selectionEnd??Xe.length};if(M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing)return sd();if(M.key==="Escape"){if(oEt(he)&&!vs(Xe,he))return $s({buffer:Xe,value:he.value}),!0;const En=he.value!=="",wn=sEt(he,Xe);return wn.cancelled?(nl.current=wn.token,Tr(null),En&&ys(wn.buffer),ya(wn),!0):!1}return M.key==="Enter"?(ya(QJ(he,Xe,Be,`
|
|
1073
1073
|
`)),!0):M.key==="Tab"?!0:Array.from(M.key).length===1&&!M.ctrlKey&&!M.metaKey&&!M.altKey&&!M.nativeEvent.isComposing?(ya(QJ(he,Xe,Be,M.key)),!0):!1},[Xe,ya,sd,Tr,vs]),io=$.useCallback((M,he,Ee="typed")=>Kfn({gesture:Ee,draft:M,caret:he,commandNames:lt.commandNames,promptCommands:lt.promptCommands,armedOnlyCommands:lt.armedOnlyCommands,valueArgumentCommands:lt.valueArgumentCommands,argumentCommands:lt.argumentCommands,argumentShapes:lt.argumentShapes,prefixingCommands:lt.prefixingCommands,commandLockedWords:$hn,unmaskedRunWord:Fb(M)?Qg.current?.word:void 0,nameListCommands:lt.nameListCommands,enabled:lt.available&&!!B}),[lt.commandNames,lt.promptCommands,lt.armedOnlyCommands,lt.valueArgumentCommands,lt.argumentCommands,lt.argumentShapes,lt.prefixingCommands,lt.nameListCommands,lt.available,B]),ol=$.useCallback((M,he,Ee)=>{ii.current=he,Ln(M),Pi(he),ae?.(Ee)},[ae,Ln]),Ji=$.useCallback(M=>{const he=nl.current;if(he!==null&&he.text.trim().length>0&&M.includes(he.text.trim()))return he.text.trim();const Ee=Tu.current;return Ee!==null&&Ee.trim().length>0&&M.includes(Ee.trim())?Ee.trim():null},[]),Ag=$.useCallback(M=>lEt(M,nl.current)?"send":Ji(M)===null?"typed":"pick",[Ji]),Fb=$.useCallback(M=>{const he=Qg.current;return he!==null&&K4t(M,he.run)},[]),sl=$.useCallback((M,he)=>{const Ee=Ag(M);if(Ee==="send")return{kind:"send"};const Be=Ee==="pick"?io(M,he,"pick"):io(M,he);if(Ee!=="pick"||Be.kind!=="send")return Be;const rn=Ji(M);if(rn===null)return Be;const En=M.indexOf(rn);return En<0?Be:io(M,En+rn.length,"pick")},[Ag,io,Ji]),Ug=$.useMemo(()=>{if(ac)return[];const M=_dn({draft:Xe,commandNames:lt.commandNames,nameListCommands:lt.nameListCommands,nameChoices:lt.nameChoices,picking:lt.open&<.matches.length>0});if(M.length===0)return M;const he=io(Xe,Xr,"typed");return kdn(M,Xe,{sendsAsWritten:he.kind==="send"})},[Xe,Xr,ac,io,lt.commandNames,lt.nameListCommands,lt.nameChoices,lt.open,lt.matches.length]),Bb=$.useMemo(()=>ac?[]:Idn({draft:Xe,vocabulary:hr.vocabulary,settled:hr.settled,picking:hr.open,expands:sl(Xe,Xr).kind==="send"}),[Xe,Xr,ac,hr.vocabulary,hr.settled,hr.open,sl]),Hb=$.useMemo(()=>[...Ug,...Bb],[Ug,Bb]),H5=f4e(Hb),cd=$.useCallback(async(M,he,Ee)=>{const Be=B;if(!Be)return;if(M.kind==="whole"||M.kind==="splice"){const En=lt.commands.find(yr=>yr.name===M.command.name||yr.aliases.includes(M.command.name)),wn=Kn(M.command.args??"");if(En?.destination==="session.model"&&wn){const yr=e5e(lt.argumentList.rows,wn);if(yr){wO.getState().openConnect({providerId:yr});return}}if(En?.destination==="session.tags"){if(!Kn(M.command.args??"")){const yr=M.kind==="splice"?M.start:0,ai=M.kind==="splice"?M.end:he.length,Gi=Cc(he,yr,ai,`/${En.name} `);ii.current=Gi.caret,Ln(Gi.text),Pi(Gi.caret)}lt.reopen();return}}if(M.kind==="list-open"){if(lt.open&<.matches.length>0)return;ae?.(h("ui.chat.composer_notes.slash_needs_name",{command:M.command.name}));return}if(M.kind==="unrecognised"){await Be(M.command),ii.current=Ee,Ln(he),Pi(Ee);return}if(M.kind==="reassemble"){ol(M.text,M.caret,Efn(M.text.trim(),al));return}if(await Be(M.command)==="consumed"){const En=M.kind==="whole"?"":M.text,wn=M.kind==="whole"?0:M.caret;if(ii.current=wn,Ln(En),Pi(wn),M.locked===!0){const yr=UEt(he,Pr.current),Gi=!(M.kind==="whole"?yr:yr.slice(M.start,M.end)).includes(i_e);ic.current=Gi?{text:yr,caret:Ee,plain:$m(M.command.args).length}:null,ae?.(qfn(M.command.name,{dialog:al&<.commandNames.has(M.command.name),undo:Gi},E3))}return}ii.current=Ee,Ln(he),Pi(Ee)},[B,ae,Ln,lt.commandNames,lt.open,lt.matches.length,lt.commands,lt.argumentList.rows,lt.reopen,ol,al]),oe=!!(t&&m),ue=!!s,Re=D||oe||ue||!!o?.blocksInput,[Ie,kt]=$.useState(null),[Ve,Jt]=$.useState(null),[Gt,Rr]=$.useState(!1),sn=$.useRef(null),pr=$.useRef(null),Yi=$.useRef(Xe);$.useEffect(()=>{Yi.current=Xe},[Xe]),$.useEffect(()=>{kt(null),Jt(null)},[f]),$.useEffect(()=>{Ie!==null&&sn.current?.focus()},[Ie]),$.useEffect(()=>{if(!Gt)return;const M=document.activeElement;M!==null&&M!==document.body&&!pr.current?.contains(M)||pr.current?.focus()},[Gt]);const mn=$.useRef(!1);$.useEffect(()=>{if(Ie===null||l!==null&&l.key===Ie.key)return;if(kt(null),Jt(l===null?h("ui.chat.composer.secret_fill_gone"):h("ui.chat.composer.secret_fill_changed")),mn.current){mn.current=!1;return}const M=document.activeElement;M!==null&&M!==document.body&&M!==Dt.current&&!pr.current?.contains(M)||Dt.current?.focus()},[l,Ie,Dt]),$.useEffect(()=>{Jt(null)},[Xe]),$.useEffect(()=>{Ie!==null&&Xe.trim()!==Ie.value&&kt(null)},[Xe,Ie]);const Mr=$.useCallback(M=>!l||!EJ(M)?!1:(mn.current=!1,kt({value:M.trim(),key:l.key}),!0),[l]),ln=$.useCallback(()=>{kt(null),Jt(null),Dt.current?.focus()},[Dt]),Eu=$.useCallback(M=>{switch(M){case"locked":return h("ui.chat.composer.secret_fill_locked");case"stale":return h("ui.chat.composer.secret_fill_changed");case"multi":return h("ui.chat.composer.secret_fill_multi");case"refused":return h("ui.chat.composer.secret_fill_refused");case"unavailable":return h("ui.chat.composer.secret_fill_unavailable")}},[]),K5=$.useCallback(async()=>{if(Ie===null||l===null||Gt)return;if(!l.fillable){kt(null),Jt(h("ui.chat.composer.secret_fill_multi")),l.onOpen(),mn.current=!0;return}Rr(!0);let M;try{M=await l.onFill(Ie.value,Ie.key)}catch{M="unavailable"}finally{Rr(!1)}if(kt(null),M==="sent"){Yi.current.trim()===Ie.value&&Ln(""),Dt.current?.focus();return}Jt(Eu(M));const he=M==="unavailable"?!1:l.onOpen({focus:!1});mn.current=he,he||Dt.current?.focus()},[l,Ie,Gt,Eu,Ln,Dt]),J5=$.useCallback(()=>{kt(null),ph(),Dt.current?.focus()},[ph,Dt]),Lr=R||E,Kb=$.useCallback(()=>{kr(!0)},[]),e2=$.useCallback(async M=>{const he=VQ(M.model);if(!(Re||!X5e(M)||M.id!=="model-default"||!he)){lt.close();try{await T5e(he,(Ee,Be)=>Te({op:"settings.edit",key:Ee,value:Be})),Ln(""),ae?.(h("ui.chat.composer_notes.default_saved",{model:`${he.provider}/${he.model_id}`}))}catch(Ee){ae?.(h("ui.chat.composer_notes.default_not_saved",{reason:Ee instanceof Error?Ee.message:h("ui.chat.composer_notes.default_not_saved_fallback")}))}}},[Re,lt.close,Ln,ae]),t2=$.useCallback(async(M,he)=>{if(M.kind==="action"){he.run&&await e2(M.row);return}if(Re)return;if(M.kind==="argument"&<.inline?.source==="session-tags"&&he.run){await lt.actOnTagRow(M.row);return}const Ee=Ohn(Xe,Xr,M,lt.commandNames,lt.argumentWords,lt.inline?.nameThenMessage??!1);if(!Ee)return;if(lt.close(),he.run&&M.kind==="argument"&&!al&&B){const wn=Jcn(lt.inline?.source);if(wn){const yr=H$(Xe,Xr,lt.commandNames),ai=yr?Kn(Cc(Xe,yr.start,yr.end,"").text):"";fn.getState().restageDraft({kind:wn,name:M.row.value},ai);return}}dp.lastIndex=0;const Be=dp.exec(Ee.text);if(Tu.current=Be?Be[0].trim():null,M.kind==="command"&&he.run&&pA(M,lt.armedOnlyCommands)){const wn=Jfn({draft:Ee.text,caret:Ee.caret,commandNames:lt.commandNames,armedOnlyCommands:lt.armedOnlyCommands});if(wn.kind==="armed"){ol(wn.text,wn.caret,Rfn(wn.text.trim(),M.command.destination,VRe(M.command.destination)?al:!0));return}}if(ya({capture:fp(Pr.current,Ee.text,Ee.caret,"completion"),buffer:Ee.text,caret:Ee.caret}),!(he.run&&(M.kind==="command"?v4e(M.command.destination,lt.effectiveEntry(M.command.destination)):lt.inline?.runs??!1)&&!!B))return;const En=io(Ee.text,Ee.caret,"pick");En.kind!=="send"&&await cd(En,Xe,Xr)},[Xe,Xr,lt,ya,B,io,cd,ol,al,Re,e2]),XG=$.useCallback(M=>{const he=$fn(Xe,Xr,M,lt.commandNames);he&&(ii.current=he.caret,Ln(he.text),Pi(he.caret))},[Xe,Xr,lt.commandNames,Ln]),RG=$.useCallback(M=>{if(Re)return;const he=u4e(Xe,Xr);if(!he)return;const Ee=JOn(M),Be=Xe.slice(he.end,he.end+1),rn=he.start>0&&(Be===" "||Be===`
|
|
1074
|
-
`)?1:0,En=Cc(Xe,he.start,he.end+rn,Ee),wn=Ee.endsWith('"')?En.caret-1:En.caret;ii.current=wn,Ln(En.text),Pi(wn),Eo.remember(M.path),Eo.close()},[Xe,Xr,Eo,Ln,Re]),n2=$.useCallback(M=>{if(Re||!hr.token)return;const he=Gdn(Xe,hr.token,M.name);hr.close(),ii.current=he.caret,Ln(he.text),Pi(he.caret)},[Xe,hr,Ln,Re]),R4e=$.useCallback(M=>{const he=ic.current;return he===null||!(M.metaKey||M.ctrlKey)||M.altKey||M.shiftKey||M.key.toLowerCase()!=="z"?!1:(ic.current=null,ii.current=he.caret,he.plain>0&&Tr({chars:he.plain,over:he.text}),Ln(he.text),Pi(he.caret),!0)},[Tr,Ln]),E4e=$.useCallback(M=>{if(Re)return;if(ld(M)){M.preventDefault();return}if(M.key==="Escape"&&Ie!==null){if(M.preventDefault(),Gt)return;ln();return}if(j4e(M)){M.preventDefault();return}if(R4e(M)){M.preventDefault();return}if(wdn(M,Eo,RG)){M.preventDefault();return}if(uhn(M,lt,t2,XG)){M.preventDefault();return}if(lfn(M,hr,n2)){M.preventDefault();return}if(nt!==null&&M.key==="Escape"){M.preventDefault(),P7(c??"");return}if(nt!==null&&UBe(M)){const Be=nt.turns.at(-1),rn=Be?wr.getState().streams[Be.asideId]:void 0;if(!Be||nt.queued!==void 0||!Ghe(rn,u,O))return;M.preventDefault();const En=c??"",wn=Date.now(),yr=NBe(gt.current,Be.asideId,wn);if(yr==="arm"){gt.current={turnId:Be.asideId,at:wn},wr.getState().setAsideNotice(En,ID(E3));return}if(yr==="ignore")return;gt.current=null,Nhe(En).catch(()=>{});return}if(M.key==="Backspace"||M.key==="Delete"){const Be=IOn(Xr,M.key==="Backspace"?"back":"forward",ri.spans,ri.resolved);if(Be&&!M.nativeEvent.isComposing){const rn=Cc(Xe,Be.start,Be.end,"");ii.current=rn.caret,Pi(rn.caret),Ln(rn.text),M.preventDefault();return}}const he=Dt.current,Ee=khn();if(Ee&&vNe(M,{value:Xe,selectionStart:he?.selectionStart??null,selectionEnd:he?.selectionEnd??null})){Ee.focus(),M.preventDefault();return}if(Lr&&M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing){M.preventDefault(),Kb();return}if(M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing){const Be=sl(Xe,Xr);if(Be.kind!=="send"){M.preventDefault(),cd(Be,Xe,Xr);return}if(Mr(Xe)){M.preventDefault();return}}Rg(M)},[lt,t2,XG,hr,n2,Mr,Rg,ld,Ie,ln,sl,cd,Xe,Xr,Re,nt,c,u,O]),EG=$.useRef(null),ll=$.useCallback(M=>{mA=!1,Dt.current?.focus({preventScroll:M?.preventScroll===!0})},[Dt]),q4e=$.useCallback(()=>{c8(Xe)!==null&&Ln("")},[Xe,Ln]);$.useImperativeHandle(we,()=>({focusInput:ll,openWorkingDirectoryMenu:()=>{EG.current?.openMenu()},submitNow:()=>{Mr(Xe)||ph()},consumeApprovalAnswerDraft:q4e}));const qG=$.useCallback(()=>Dt.current,[Dt]);$.useEffect(()=>TWe(ll,qG),[ll,qG]);const cl=$.useRef(null),jG=$.useRef(Xe);$.useLayoutEffect(()=>{jG.current=Xe},[Xe]);const CG=$.useCallback(M=>{cl.current===M&&(cl.current=null,Rn.current.delete(M.index))},[]),Jb=$.useCallback(M=>{if(cl.current!==M)return!1;const he=_Et({buffer:jG.current,cleared:M.cleared});return he?(Rn.current.set(M.index,M.payload),cl.current===M&&(cl.current=null),M.toastId!==null&&s$(M.toastId),ya({capture:fp(Pr.current,he.buffer,he.caret,"arrival"),buffer:he.buffer,caret:he.caret}),nc(null),!0):!1},[ya,nc]);$.useLayoutEffect(()=>{const M=cl.current;M!==null&&M.cleared.buffer!==Xe&&(M.toastId!==null&&s$(M.toastId),CG(M))},[Xe,CG]);const j4e=$.useCallback(M=>{const he=cl.current;return he===null||!(M.metaKey||M.ctrlKey)||M.altKey||M.shiftKey||M.key.toLowerCase()!=="z"?!1:(Jb(he),!0)},[Jb]),zG=$.useCallback(M=>{Jb(M)&&ll()},[ll,Jb]),C4e=$.useCallback(M=>{if(Re)return;const he=Rn.current.get(M);if(!he)return;const Ee=QEt({buffer:Xe,payload:he});if(!Ee.cleared)return;const Be=cl.current;Be&&(cl.current=null,Rn.current.delete(Be.index),Be.toastId!==null&&s$(Be.toastId));const rn={index:M,payload:he,cleared:Ee,toastId:null};cl.current=rn,ya({capture:fp(Pr.current,Ee.buffer,Ee.caret,"arrival"),buffer:Ee.buffer,caret:Ee.caret}),nc({key:he.key,index:M,over:Ee.buffer}),rn.toastId=Kh(xEt(M),{action:{label:wEt(),onClick:()=>zG(rn)}}),ll()},[ya,ll,Re,Xe,nc,zG]),z4e=Se,A4e=Re||Se||Ue||Xe.trim().length>0;$.useEffect(()=>{const M=Dt.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[Xe,Dt,Se,Ue,We]);const r2=!!o?.blocksInput&&Xe==="",ew=$.useRef(null);$.useLayoutEffect(()=>{const M=Dt.current;if(!M||!r2){M&&ew.current!==null&&(M.style.overflowY=""),ew.current=null;return}ew.current!==M.placeholder&&(ew.current=M.placeholder,oue(M))}),$.useEffect(()=>{const M=Dt.current;if(!M||!r2||typeof ResizeObserver>"u")return;let he=M.clientWidth;const Ee=new ResizeObserver(()=>{M.clientWidth!==he&&(he=M.clientWidth,oue(M))});return Ee.observe(M),()=>Ee.disconnect()},[r2,Dt]);const AG=$.useRef(!1);$.useEffect(()=>{const M=Se||Ue,he=AG.current&&!M;if(AG.current=M,!ee&&!he||Re||M)return;const Ee=document.activeElement;!(Ee&&(Ee.tagName==="INPUT"||Ee.tagName==="TEXTAREA"||Ee.getAttribute("role")==="tab"))&&!R&&Dt.current?.focus({preventScroll:!0})},[ee,Re,Se,Ue,Dt,R]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(M=>{Tt(M.platform)}).catch(M=>{console.error("Failed to get platform info:",M)})},[]);const bs=$.useRef(null),U4e=250,UG=$.useRef(qe);$.useEffect(()=>{UG.current=qe}),$.useEffect(()=>(Qce("message-input",Se||We),()=>Qce("message-input",!1)),[Se,We]),$.useEffect(()=>{UG.current?.(Se)},[Se]);const ws=$.useCallback(M=>{rt(!1);const he=Yt.current;if(!he)return;const Ee=bs.current?.startedAt??null,Be=Ee===null?Number.POSITIVE_INFINITY:performance.now()-Ee;if(bs.current=null,he.state==="inactive"){ft(!1);return}(M==="abort"||Be<U4e)&&(he.onstop=()=>{if(he.stream)for(const rn of he.stream.getTracks())rn.stop();yt(null),or.current=[],Nt.current=null,Ye(rn=>Bh(rn,{type:"discarded"}))}),he.stop(),ft(!1)},[]);$.useEffect(()=>()=>{const M=bs.current!==null;bs.current=null;const he=Yt.current;if(he&&he.state!=="inactive"){ws("abort");return}M&&rt(!1)},[ws]);const i2=$.useCallback((M="release")=>{const he=bs.current;if(he){if(he.startedAt===null){bs.current=null,rt(!1);return}ws(M)}},[ws]),WG=$.useCallback(async()=>{if(!(Re||!Dr)&&!bs.current)if(navigator?.mediaDevices?.getUserMedia){const M={startedAt:null};bs.current=M,rt(!0);try{const he=await navigator.mediaDevices.getUserMedia({audio:!0});if(bs.current!==M){for(const Ee of he.getTracks())Ee.stop();return}Yt.current=new MediaRecorder(he),or.current=[],Yt.current.ondataavailable=Ee=>{or.current.push(Ee.data)},Yt.current.onstop=()=>{const Ee=new Blob(or.current,{type:"audio/webm"});it(null),yt(Ee);for(const Be of he.getTracks())Be.stop()},Yt.current.start(),M.startedAt=performance.now(),rt(!1),ft(!0),yt(null)}catch(he){if(bs.current!==M)return;bs.current=null,rt(!1),console.error("Error accessing microphone:",he),Jn(h("ui.canvas.inline_edit.error_accessing_microphone_please_ensure_microphone_permissions_are_gran"))}}else console.error("This runtime exposes no MediaRecorder"),Jn(h("ui.canvas.inline_edit.dictation_is_not_available_on_this_device"))},[Dr,Re]),a2=$.useCallback(()=>{Se&&ws("release")},[Se,ws]),o2=$.useCallback(()=>{Se&&ws("abort")},[Se,ws]),W4e=$.useCallback(()=>{if(!(!Se||Zt!=="idle")&&!(Re||R||E||Ru)){if(Yt.current?.state!=="recording"){ws("release");return}Nt.current={draftAtPress:Xe,transcript:null},Ye(M=>Bh(M,{type:"press"})),ws("release")}},[Se,Zt,Re,R,E,Ru,Xe,ws]);$.useEffect(()=>{if(!Se&&!We)return;const M=he=>{if(Se){if(he.key==="Enter"){const Ee=he.target;if(Ee instanceof Element&&Ee.closest("[data-lo-composer-controls] button"))return;he.preventDefault(),a2()}else he.key==="Escape"&&(he.preventDefault(),o2());return}he.key==="Escape"&&(he.preventDefault(),i2("abort"),rt(!1))};return window.addEventListener("keydown",M),()=>{window.removeEventListener("keydown",M)}},[Se,We,a2,o2,i2]);const tw=$.useCallback(()=>{Nt.current&&(Nt.current=null,Ye(M=>Bh(M,{type:"transcript",usable:!1})))},[]),NG=$.useCallback(async()=>{if(!Wt)return;on.current?.abort();const M=new AbortController;on.current=M;try{_t(!0);const he=await KA.createTranscriptionWithRetry(IO.baseUrl,{file:new File([Wt],"recording.webm",{type:"audio/webm"})},{signal:M.signal,onRetry:({attempt:Ee,total:Be,delayMs:rn,error:En})=>{console.warn(`Transcription attempt ${Ee}/${Be} failed with a transient upstream fault; retrying in ${rn} ms.`,En)}});if(he.result?.text){const Ee=he.result?.text||"";ad.current=!0,Vb(Ee),Nt.current&&(Nt.current.transcript=Ee,Ye(Be=>Bh(Be,{type:"transcript",usable:!0})))}else _o(K8e()),tw();it(null),yt(null)}catch(he){if(M.signal.aborted){tw();return}console.error("Error transcribing audio:",he),tw();const Ee=mk(he);it(Ee?R8e(he):null),Ee||Jn(WOe(he))}finally{on.current===M&&_t(!1)}},[Wt,Vb,tw]),N4e=$.useCallback(()=>{it(null),at(M=>M+1)},[]);$.useEffect(()=>{if(!Wt){At.current=null;return}At.current?.blob===Wt&&At.current.attempt===Ct||(At.current={blob:Wt,attempt:Ct},NG())},[Wt,Ct,NG]);const YG=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const M=Dt.current;if(M===null)return;const he=new IntersectionObserver(Ee=>{const Be=Ee[Ee.length-1];Be!==void 0&&(YG.current=Be.isIntersecting)});return he.observe(M),()=>he.disconnect()},[Dt]),hun(ce,MRe.MESSAGE_INPUT,{start:WG,stop:i2},()=>!!(!Re&&!Se&&!Ue&&Dr&&YG.current));const s2=(M=!1)=>{if(Re||R)return!1;if(E)return Kb(),!1;if(!Xe.trim()&&$e.length===0||M&&Ya(Ni)||M&&r&&Ecn(Xe))return!1;if(sd())return!0;const he=sl(Xe,Xr);if(he.kind!=="send")return M?!1:(cd(he,Xe,Xr),!0);if(M){if(l&&EJ(Xe))return!1}else if(Mr(Xe))return!0;return ph(),!0},Y4e=M=>{M.preventDefault(),s2()},GG=$.useRef(s2);GG.current=s2,$.useEffect(()=>{if(Zt==="ready-to-submit"){if(Ue)return;const M=Nt.current;if(!M||M.transcript===null){Ye("idle");return}const{intact:he}=Rcn({draftAtPress:M.draftAtPress,transcript:M.transcript,current:Xe,join:k7});Nt.current=null;const Ee=he?GG.current(!0):!1;Ye(Be=>Bh(Be,{type:"checked",draftIntact:he&&Ee}));return}Zt==="submitting"&&!Ru&&Ye(M=>Bh(M,{type:"settled",sendBusy:!1}))},[Zt,Ue,Xe,Ru]);const l2=$.useCallback(M=>{Re&&M.preventDefault()},[Re]),IG=$.useCallback(M=>{!Re&&!Lr||(M.preventDefault(),Lr&&!Re&&Kb())},[Re,Lr,Kb]),G4e=M=>{f&&pe(f,M)},I4e=async()=>{const M=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!M.canceled&&M.filePaths.length>0&&f)for(const he of M.filePaths)Ke(f,{id:ka(),path:$I(he)})},Z4e=M=>{if(Re)return;const he=M.clipboardData?.getData("text/plain")??"";if(he&&Pr.current.arm!==null){const Be=M.currentTarget,rn=uEt({capture:Pr.current,buffer:Xe,caret:Be.selectionEnd??Xe.length,selection:{start:Be.selectionStart??Xe.length,end:Be.selectionEnd??Xe.length},pasted:he,index:tl.current,taken:Cg()});if(rn){M.preventDefault(),ya(rn),Tr(null);return}}Qun(M.clipboardData??null)?M.preventDefault():he&&(Qg.current=J4t(he));const Ee=M.clipboardData?.items;if(Ee){for(let Be=0;Be<Ee.length;Be++)if(Ee[Be].type.indexOf("image")!==-1||Ee[Be].kind==="file"){const rn=Ee[Be].getAsFile();if(rn){const En=new FileReader;En.onload=wn=>{wn.target?.result&&f&&Ke(f,{id:ka(),path:wn.target.result})},En.readAsDataURL(rn)}}}},D4e=M=>{Re||M.dataTransfer?.types.includes("Files")&&(M.preventDefault(),M.stopPropagation(),M.dataTransfer.dropEffect="copy",c2(!0))},V4e=M=>{M.currentTarget.contains(M.relatedTarget)||c2(!1)},M4e=M=>{if(c2(!1),Re)return;const he=M.dataTransfer?.files;!he||he.length===0||(M.preventDefault(),M.stopPropagation(),f&&L4e(f,Array.from(he)))},L4e=async(M,he)=>{for(const Ee of he){const Be=window.api?.getPathForFile?window.api.getPathForFile(Ee):"";if(Be){Ke(M,{id:ka(),path:$I(Be)});continue}const rn=await _hn(Ee);rn&&Ke(M,{id:ka(),path:rn})}},[ZG,c2]=$.useState(!1),F4e=M=>{Re||(Xe||y?.(),ii.current=M.length,Ln(M),Pi(M.length),Dt.current?.focus())},u2=Ya(Ni)?Ni.value!==""?vs(Xe,Ni)?jEt():EEt():Hi?qEt():zEt():wg!==null&&wg===Xe?CEt():SEt({unredacted:mh!==null?AEt(mh):null,armed:Ni.arm!==null&&u_e(Xe,Xe.length)!==null,cleared:Oh===null?null:{key:Oh.key,index:Oh.index},undoCap:S4e(pi==="darwin")}),B4e=lun(pi==="darwin"?"mac":pi==="win32"?"win":"linux",!N),O2=$.useRef(null),H4e=M=>{f&&(O2.current=re.findIndex(he=>he.id===M),me(f,M))};$.useEffect(()=>{const M=O2.current;if(M===null)return;O2.current=null;const he=document.querySelectorAll(PWe),Ee=he[Math.min(M,he.length-1)];Ee?Ee.focus():ll()},[re,ll]);const qo=$.useMemo(()=>{const he=gI(Xe,re)!==""||$e.length>0,Ee=R||S?.message&&Ome.test(S.message)?[{get label(){return h("ui.chat.composer.connect_provider")},onClick:()=>wO.getState().openConnect()}]:[];return{message:S?.messageKey?h(S.messageKey):S?.message,muted:S?.muted===!0,polite:S?.polite===!0,actions:[...S?.actions??[],...Ee],retry:S?.retry===!0,clear:S?.muted!==!0&&(S?.onClear!==void 0||he)}},[S,Xe,re,$e,R,Je]),yh=SUt(),DG=X("block text-body-sm",U?"px-2 pb-1":"px-4 pb-2",mh!==null?"text-warning":"text-ink-muted"),d2=X("flex flex-wrap items-center gap-2 text-body-sm text-ink-muted",U?"px-2 pb-1":"px-4 pb-2"),VG=ue&&Xe.length>0,K4e=d.jsx("output",{className:X(jr,"block pb-2",yh.issue.kind==="hidden"&&"hidden"),children:d.jsx(Ydn,{issue:yh.issue,onSignIn:yh.start,onCancel:yh.cancel,onDismiss:yh.dismiss,isSmallView:U,onFocusComposer:()=>Dt.current?.focus()})}),vh=e7e(L),J4e=vh&&!_ue(vh)&&!t7e(vh,n7e(yh.issue))?d.jsx("output",{className:X(jr,"block pb-2"),children:d.jsx(tun,{access:vh,isSmallView:U,onSwitchModel:L?.onCommand?()=>L.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>wO.getState().openConnect({providerId:vh.provider})})}):null,MG=We||!Se&&!Ue&&!(t&&m),f2=Se?"recording":Ue?"transcribing":We?"preparing":"idle",eEe=Xe.trim()!==""||$e.length>0,bh=kcn(f2,Zt),h2=Pcn(f2),Ur=_cn({dictation:f2,alive:!!Q?.active,stopping:Q?.stopping===!0,hasPayload:eEe,refused:Re||Lr,sendBusy:Ru,sendRecording:Zt,reviewRequired:Ya(Ni)}),tEe=Ur.role==="stop-busy"?"stop":Ur.role,{ignore:nEe,arming:rEe}=S3(h2??"none"),{ignore:iEe,arming:aEe}=S3(bh),{ignore:LG,arming:FG}=S3(tEe),nw=$.useRef(!1),oEe=`${bh}|${Ur.role}|${h2}`;$.useEffect(()=>{if(!nw.current)return;const M=document.activeElement;M&&M!==document.body||(nw.current=!1,Dt.current?.focus({preventScroll:!0}))},[oEe]);const sEe=d.jsxs("form",{onSubmit:Y4e,"data-chat-region":"composer","aria-label":ZOe("composer"),tabIndex:-1,className:"w-full",children:[d.jsx(SI,{fallback:null,children:d.jsx(Qcn,{frontend:L?.frontend,askFrontend:L?.asks,runDetails:ke,isSmallView:U,askExpanded:Y,onAskToggle:V,askOutcomes:z,onNote:ae,onFocusComposer:()=>Dt.current?.focus()},f)}),!r7e(vh)&&K4e,J4e,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Xe.trim().length>0?d.jsx("p",{id:eue,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,qo.message!==void 0&&d.jsxs("div",{role:qo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":S?.message===o7e.queuedSend?!0:void 0,className:X(jr,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",U?"px-2 pb-1":"px-4 pb-2"),children:[d.jsxs("p",{className:X("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",qo.muted?"text-ink-muted":"text-danger"),children:[!qo.muted&&d.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:d.jsx(nu,{size:14,"aria-hidden":"true"})}),d.jsx("span",{className:X("min-w-0 break-words",!qo.muted&&"font-medium"),children:qo.message})]}),(qo.retry||qo.clear||qo.actions.length>0)&&d.jsxs(d.Fragment,{children:[qo.actions.map(M=>d.jsx(ve,{type:"button",variant:"link",size:"sm",className:X("min-h-6 cursor-pointer text-body-sm underline"),onClick:M.onClick,children:M.label},M.label)),qo.retry&&S?.onRetry&&d.jsx(ve,{type:"button",variant:"link",size:"sm",className:X("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>S.onRetry?.(),children:i7e()}),qo.clear&&S?.onClear&&d.jsx(ve,{type:"button",variant:"link",size:"sm","aria-label":h("ui.chat.composer.clear_message"),className:X("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>S.onClear?.(),children:a7e()})]})]}),w&&d.jsx("output",{className:X(jr,"block text-body-sm text-ink-muted",U?"px-2 pb-1":"px-4 pb-2"),children:w}),c&&nt!==null&&d.jsx(TOn,{sessionId:c,sessionStreaming:u,adoptQueueSupported:O,isSmallView:U,onReturnFocus:()=>Dt.current?.focus()}),_?d.jsx("div",{className:X(jr,U?"px-2 pb-2":"px-4 pb-2"),children:_}):null,d.jsxs("div",{className:X(jr,"relative w-full"),children:[d.jsx(ohn,{state:lt,onPick:t2,onActionPick:e2}),d.jsx(Sdn,{state:Eo,onPick:RG}),d.jsx(sfn,{state:hr,onPick:n2}),!N&&!lt.open&&!Eo.open&&!hr.open&&d.jsx(iNt,{visible:v,onClick:x,hasNewActivity:b}),d.jsx("output",{id:Fce,className:X(jr,u2?DG:"hidden"),children:u2}),VG&&d.jsx("output",{id:Bce,className:X(jr,DG),children:h("ui.chat.composer.secret_closure_notice")}),l&&Ie===null&&d.jsxs("output",{id:Hce,className:X(d2,jr),children:[d.jsx("span",{className:"min-w-0",children:h("ui.chat.composer.secret_ask_notice")}),d.jsx(ve,{type:"button",size:"sm",variant:"secondary","data-lo-ask-item-toggle":"",onClick:()=>l.onOpen(),children:h("ui.chat.composer.secret_ask_open")})]}),Ve!==null&&Ie===null&&d.jsx("output",{id:yhn,className:X(d2,jr),children:d.jsx("span",{className:"min-w-0",children:Ve})}),Ie!==null&&d.jsxs("fieldset",{ref:pr,tabIndex:-1,id:vhn,"aria-labelledby":Kce,"aria-busy":Gt,onKeyDown:M=>{M.key==="Escape"&&(M.preventDefault(),!Gt&&ln())},className:X("m-0 min-w-0 border-0 p-0",d2,jr),children:[d.jsxs("span",{id:Kce,className:"min-w-0",children:[Gt?h("ui.chat.composer.secret_confirm_sending"):h("ui.chat.composer.secret_confirm_message"),d.jsx("span",{className:X("whitespace-nowrap",Gt&&"invisible"),"aria-hidden":Gt||void 0,children:` ${h("ui.chat.composer.secret_confirm_chars",{count:Ie.value.length})}`})]}),d.jsx(ve,{ref:sn,type:"button",size:"sm",disabled:Gt,onClick:K5,children:l?.fillable?h("ui.chat.composer.secret_confirm_put"):h("ui.chat.composer.secret_confirm_put_multi")}),d.jsx(ve,{type:"button",size:"sm",variant:"secondary",disabled:Gt,onClick:J5,children:h("ui.chat.composer.secret_confirm_send")}),d.jsx(ve,{type:"button",size:"sm",variant:"ghost",disabled:Gt,onClick:ln,children:h("ui.chat.composer.secret_confirm_cancel")})]}),$h>0&&d.jsx("span",{id:Jce,className:"sr-only",children:h("ui.chat.composer_notes.outside_mentions",{count:$h})}),i&&d.jsx("span",{id:tue,className:"sr-only",children:h("ui.chat.composer.delivery_remedies_hint")}),d.jsxs("div",{"data-glass-region":"composer",className:X(Thn,ZG?void 0:Xhn,U?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",jr,ZG&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(re.length>0||$e.length>0)&&d.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[re.length>0&&d.jsx(XN,{replies:re,onRemoveReply:H4e}),$e.length>0&&d.jsx(rKe,{attachments:$e,onRemoveAttachment:G4e,disabled:Re||Se||Ue,byteSizes:Oe})]}),d.jsxs("div",{className:"relative isolate w-full",children:[d.jsx(Gun,{text:Xe,payloads:Rn.current,capture:Ni,held:vs(Xe,Ni),fieldRef:Dt,mirrorRef:qg,isSmallView:U}),d.jsx(odn,{text:Xe,spans:ri.spans,resolved:ri.resolved,fieldRef:Dt,isSmallView:U}),d.jsx(Rdn,{draft:Xe,runs:Hb,textareaRef:Dt,fieldClassName:H_(U),refused:Re,children:d.jsx("textarea",{ref:Dt,"data-region-entry":!0,className:X(H_(U),"block",U?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",H5?"text-transparent caret-ink":"text-ink","outline-none placeholder:text-ink-dim",o?.blocksInput?"read-only:text-ink-muted read-only:placeholder:text-ink-muted disabled:text-ink-disabled disabled:placeholder:text-ink-disabled":"read-only:text-ink-disabled read-only:placeholder:text-ink-disabled disabled:text-ink-disabled disabled:placeholder:text-ink-disabled"),placeholder:Se?h(Ps.recording):UFe({unavailable:D,secretAnswer:ue,inputDisabled:Re,awaitingAnswer:r,asideAttached:nt!==null,sendingUnsettled:Ki||Xu,awaitingReply:n,stopping:Q?.stopping===!0,noProvider:R,idle:Ce,hostLine:o?.placeholder??null}),value:Xe,onCompositionStart:()=>Eg(!0),onCompositionEnd:()=>Eg(!1),onChange:M=>{il.current=!0;const he=M.target.value,Ee=M.target.selectionStart??he.length;ic.current=null;const Be=iEt(Pr.current,Xe,he,Ee,"typing");Be.buffer!==he?(ii.current=Be.caret,Pi(Be.caret)):Pi(Ee),Be.capture!==Pr.current&&ro(Be.capture),!Xe&&Be.buffer&&y?.(),rc.current=Be.buffer,zg(Be.capture,Be.buffer),Ln(Be.buffer),Date.now()-zn.current>=whn&&S?.onDismiss?.()},onSelect:M=>{const he=M.target,Ee=ii.current;if(Ee!==null){he.selectionStart===Ee&&(ii.current=null);return}Pi(he.selectionStart),ro(fp(Pr.current,Xe,he.selectionStart,"caret"))},onKeyDown:E4e,onPointerDown:()=>{mA=!0},onPaste:Z4e,rows:1,readOnly:Re,"aria-disabled":Re||void 0,"aria-label":h("ui.chat.composer.message"),role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Xe.trim().length>0?eue:null,u2?Fce:null,VG?Bce:null,l&&Ie===null?Hce:null,$h>0?Jce:null,D?pke:null,i?tue:null].filter(Boolean).join(" ")||void 0,"aria-expanded":lt.open||Eo.open,"aria-controls":lt.open?lt.listId:Eo.open?Eo.listId:void 0,"aria-activedescendant":(lt.open?lt.activeDescendantId:Eo.activeDescendantId)??void 0})}),d.jsx(Wun,{small:U,text:Xe,payloads:Rn.current,capture:Ni,mirrorRef:qg,fieldRef:Dt,onClear:Re?null:C4e,onControlUnmounted:ll})]}),(Se||We&&MG)&&d.jsx(_pe,{isRecording:Se,preparingLabel:!Se&&We?U?h("ui.chat.composer.starting"):h("ui.chat.composer.starting_recording"):null,sendsNow:Ur.role==="send-recording"&&Ur.enabled}),Ue&&d.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[d.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:h("ui.chat.composer.processing_audio")}),Zt==="idle"&&d.jsx(k4e,{})]}),L?.settingsIntents&&d.jsx(aun,{...L.settingsIntents,restoreFocus:()=>Dt.current?.focus()}),Ae!==null&&!Ue&&Wt!==null&&d.jsxs("div",{"data-dictation-retry":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[d.jsx(nu,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),d.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:Ae}),d.jsx(ve,{type:"button",variant:"link",size:"sm",className:"h-7 shrink-0 px-2 underline",onClick:N4e,children:h("ui.common.actions.retry")})]}),d.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[L&&d.jsx(SI,{fallback:null,children:d.jsx(HJe,{frontend:L.frontend,onCommand:L.onCommand,effortEntities:L.effortEntities,draft:L.draft,onOpenDraftPicker:L.onOpenDraftPicker,draftResolution:L.draftResolution,held:L.held,contextHeld:L.contextHeld,readingsDropped:L.readingsDropped,pendingModel:L.pendingModel,pendingEffort:L.settingsIntents?Gp(L.settingsIntents.slots).effort:null,pendingModelQueued:L.settingsIntents?.slots?.model?.state==="queued_next_step",costChannels:L.costChannels,controlsThirdBox:z4e})}),d.jsxs("div",{className:"contents",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[d.jsx($t,{content:h("ui.chat.composer.attach_file"),children:d.jsx("span",{children:d.jsx(ve,{variant:"ghost",size:U?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:l2,onClick:I4e,"aria-label":h("ui.chat.composer.attach_file"),"data-tour-tag":"chat-input-attach-file-button",disabled:Re||Se||Ue,children:d.jsx(J9e,{"aria-hidden":"true"})})})}),ct!==void 0&&d.jsx(zdn,{ref:EG,currentWorkingDirectory:ct,writePath:A,pending:I,pendingAccepted:C,readOnlyReason:A?void 0:G??ZRe()})]}),d.jsxs("div",{"data-lo-composer-controls":!0,onFocus:()=>{nw.current=!0},onBlur:M=>{M.target.isConnected&&(nw.current=!1)},className:"ms-auto flex order-3 shrink-0 items-center gap-1",children:[h2==="confirm"&&d.jsx($t,{content:h("ui.chat.composer.insert_transcript_hint"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"c",variant:"outline",size:U?"icon-sm":"icon",type:"button",className:X("border-success-border bg-success-wash text-success hover:bg-success-wash",aEe&&"opacity-72"),onClick:M=>{iEe(M.detail)||a2()},"aria-label":h("ui.chat.composer.insert_transcript"),children:d.jsx(Ai,{"aria-hidden":"true"})})})},"confirm"),(bh==="mic"||bh==="mic-preparing")&&MG&&d.jsx($t,{content:d.jsx(mun,{text:We?h("ui.chat.composer.starting_recording"):Dr?(()=>{const M=N8t(B4e,OA()?.label??null);return M===null?h("ui.chat.composer.start_recording"):h("ui.chat.composer.start_recording_hint",{shortcut:M7e(M.shortcut),pushToTalk:M.pushToTalk})})():Vr}),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"a",variant:"ghost",size:U?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:l2,onClick:WG,"aria-label":h("ui.chat.composer.start_recording"),"aria-busy":We||void 0,disabled:Re||!Dr,children:We?d.jsx(ti,{size:"sm"}):d.jsx(j9e,{"aria-hidden":"true"})})})},"mic"),bh==="spinner"&&d.jsx(ve,{"data-composer-slot":"a",variant:"ghost",size:U?"icon-sm":"icon",type:"button",className:"text-ink-dim","aria-busy":!0,"aria-disabled":!0,"aria-label":h("ui.chat.composer.processing_audio"),onClick:M=>M.preventDefault(),children:d.jsx(ti,{size:"sm"})},"spinner"),bh==="cancel"&&d.jsx($t,{content:h("ui.chat.composer.cancel_recording_hint"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"a",variant:"outline",size:U?"icon-sm":"icon",type:"button",className:X("text-danger hover:bg-danger-wash hover:text-danger focus-visible:bg-danger-wash",rEe&&"opacity-72"),onClick:M=>{nEe(M.detail)||o2()},"aria-label":h("ui.chat.composer.cancel_recording"),children:d.jsx(Zr,{"aria-hidden":"true"})})})},"cancel"),(Ur.role==="send-recording"||Ur.role==="send-recording-busy")&&d.jsx($t,{content:h("ui.chat.composer.send_recording_hint"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"b",variant:"primary",size:U?"icon-sm":"icon",type:"button",className:X("rounded-full disabled:bg-surface",(Ur.role==="send-recording-busy"||FG)&&"opacity-72"),"aria-busy":Ur.role==="send-recording-busy"||void 0,"aria-disabled":Ur.role==="send-recording-busy"||void 0,onPointerDown:IG,onClick:M=>{Ur.role!=="send-recording-busy"&&(LG(M.detail)||W4e())},disabled:!Ur.enabled&&Ur.role!=="send-recording-busy","aria-label":nt!==null&&!r?h("ui.chat.composer.ask_aside"):h("ui.chat.composer.send_recording"),children:d.jsx($S,{"aria-hidden":"true"})})})},"send-recording"),Ur.role==="connecting"&&d.jsx(ve,{"data-composer-slot":"b",variant:"secondary",size:U?"icon-sm":"icon",type:"button",className:"rounded-full","aria-busy":!0,"aria-disabled":!0,"aria-label":h("ui.chat.composer.placeholder.sending"),onClick:M=>M.preventDefault(),children:d.jsx(ti,{size:"sm"})},"connecting"),(Ur.role==="stop"||Ur.role==="stop-busy")&&Q&&d.jsx($t,{content:h("ui.chat.composer.stop_work_hint"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"b",variant:"danger",size:U?"icon-sm":"icon",type:"button",onClick:M=>{Ur.role!=="stop-busy"&&(LG(M.detail)||Q.onStop())},"aria-label":h("ui.chat.composer.stop"),"aria-keyshortcuts":"Escape","data-stopping":Q.stopping===!0?"true":void 0,"aria-busy":Q.stopping===!0?!0:void 0,className:X("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]",FG&&"opacity-72"),children:d.jsx(V3,{"aria-hidden":"true"})})})},"stop"),t&&m&&d.jsx($t,{content:h("ui.chat.composer.stop_agent"),children:d.jsx("span",{children:d.jsx(ve,{variant:"danger",size:U?"icon-sm":"icon",type:"button",onClick:()=>g?.(m),"aria-label":h("ui.chat.composer.stop_agent"),children:d.jsx(V3,{"aria-hidden":"true"})})})}),(Ur.role==="send"||Ur.role==="steer")&&!(t&&m)&&d.jsx($t,{content:nt!==null&&!r?h("ui.chat.composer.ask_aside"):Ur.role==="steer"?h("ui.chat.composer.steer_hint"):h("ui.chat.composer.send_message"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"b",variant:"primary",size:U?"icon-sm":"icon",type:"submit",onPointerDown:IG,disabled:!Ur.enabled,className:"rounded-full disabled:bg-surface","aria-label":nt!==null&&!r?h("ui.chat.composer.ask_aside"):h("ui.chat.composer.send_message"),children:d.jsx($S,{"aria-hidden":"true"})})})},Ur.role)]})]})]})]})]}),R&&!tc?d.jsx("div",{className:X("mt-2",jr),children:d.jsx($On,{})}):null,(R||E)&&Cn?d.jsx("div",{className:X("mt-2",jr),children:d.jsx("output",{className:"block text-body-sm text-ink-muted",children:E?h("ui.chat.composer_notes.hint.choose_model"):h("ui.chat.composer_notes.hint.connect_provider")})}):null]});return d.jsxs("div",{className:X(Hhe,"flex w-full flex-col items-center",ki?"grow":"shrink-0","transition-none",Z?void 0:mHe,U?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:V5,onDragOver:D4e,onDragLeave:V4e,onDrop:M4e,children:[d.jsx("div",{"data-lo-composer-splash":"",className:X("flex w-full flex-col items-center justify-center",ki?"grow":null,"transition-none"),children:d.jsx("div",{ref:Yb,className:X(Mb?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:Mb?d.jsxs(d.Fragment,{children:[d.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:d.jsx(ghn,{className:"size-8",tone:"ink-muted"})}),R?null:d.jsx("h2",{className:"text-center text-ink text-title",children:h("ui.chat.composer.welcome")}),R?d.jsx("div",{className:X("w-full",jr),children:d.jsx(gOn,{})}):d.jsxs("div",{className:X("flex flex-col gap-3",jr),children:[d.jsx(Udn,{band:Nb,splash:M5,foot:vg,suggestions:yg,disabled:A4e,onRefusedPress:l2,onSelect:F4e,focusComposer:()=>Dt.current?.focus()}),d.jsx(Aun,{suspended:Xe.trim().length>0,mentionsEnabled:ne})]})]}):null})}),tc?d.jsx("div",{className:X("mb-2 mt-2",jr),children:d.jsx(mOn,{selection:D5})}):null,d.jsx("div",{ref:bg,"data-lo-composer-foot":"",className:"w-full",children:sEe})]})});function oue(e){e.style.height="auto",e.style.height=`${Math.ceil(e.scrollHeight)}px`,e.style.overflowY=e.scrollHeight<=e.clientHeight+1?"hidden":""}const Ehn=$.memo(Rhn);Ehn.displayName="MessageInput";const TG=1024,aS=1024*1024,Z5=.85,qhn=new Set(["image/png","image/jpeg","image/webp"]),jhn=[{maxEdge:TG,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function Chn(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function zhn(e){const t=Uint8Array.fromBase64;if(typeof t=="function")return t.call(Uint8Array,e);const n=atob(e),r=new Uint8Array(n.length);for(let i=0;i<n.length;i+=1)r[i]=n.charCodeAt(i);return r}function sue(e){const t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";const r=32768;for(let i=0;i<e.length;i+=r)n+=String.fromCharCode(...e.subarray(i,i+r));return btoa(n)}async function Ahn(e,t,n,r,i,a=!1){const o=Math.max(e.width,e.height),s=o>r?r/o:1,l=Math.max(1,Math.round(e.width*s)),c=Math.max(1,Math.round(e.height*s)),u=new OffscreenCanvas(l,c),O=u.getContext("2d");if(!O)return null;O.drawImage(e,0,0,l,c);const f=[],p=await u.convertToBlob({type:"image/png"}),m=new Uint8Array(await p.arrayBuffer());if(m.byteLength<=aS&&f.push({bytes:m,mime_type:"image/png"}),m.byteLength>aS||i<Z5){const v=new OffscreenCanvas(l,c),b=v.getContext("2d");if(!b)return null;b.fillStyle="#ffffff",b.fillRect(0,0,l,c),b.drawImage(e,0,0,l,c);const x=await v.convertToBlob({type:"image/jpeg",quality:i}),Q=new Uint8Array(await x.arrayBuffer());f.push({bytes:Q,mime_type:"image/jpeg"}),m.byteLength>aS&&Q.byteLength>m.byteLength&&f.push({bytes:m,mime_type:"image/png"})}let g=null,y=Number.POSITIVE_INFINITY;for(const v of f)v.bytes.byteLength<y&&(g=v,y=v.bytes.byteLength);return g?a&&s<1?{data_b64:sue(g.bytes),mime_type:g.mime_type}:y>=n?t:{data_b64:sue(g.bytes),mime_type:g.mime_type,...t.origin_path?{origin_path:t.origin_path}:{}}:null}async function vbn(e,t=TG,n=Z5,r={}){const i=await T4e(e);if(!i)return e;try{return await X4e(e,i,t,n,r.edgeIsHard??!1)}finally{i.close()}}async function T4e(e){if(!qhn.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([zhn(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function X4e(e,t,n,r,i=!1){const a=Chn(e.data_b64);try{return Math.max(t.width,t.height)<=n&&a<=aS&&r>=Z5?e:await Ahn(t,e,a,n,r,i)??e}catch{return e}}async function Uhn(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>T4e(i)));try{return await Whn(e,r,t,n)}finally{for(const i of r)i?.close()}}async function Whn(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,f)=>{const p=t[f];return p?X4e(O,p,c,u):Promise.resolve(O)})),a=await i(TG,Z5);if(r(a)<=n)return a;let o=e,s=r(e);const l=c=>{const u=r(c);return u<s&&(o=c,s=u),u};l(a);for(const c of jhn){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const lue=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,Nhn=/^file:\/\//,cue={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"},q3=e=>e.replace(Nhn,"");async function bbn(e,t,n){const r=[],i=[],a=[],o=e.filter(u=>{if(lue.test(u))return!1;const O=u.split(".").pop()?.toLowerCase()??"";return!cue[O]}),s=Math.max(0,o.length-U3),l=s===0;for(const u of e){const O=lue.exec(u);if(O){r.push({data_b64:O[3],mime_type:O[1]});continue}const f=u.split(".").pop()?.toLowerCase()??"",p=cue[f];if(p){if(!window.api?.readFile){a.push({name:tf(u),kind:"read"});continue}const x=await window.api.readFile(q3(u),"base64");x.success?r.push({data_b64:x.data,mime_type:p,...u.startsWith("data:")?{}:{origin_path:q3(u)}}):a.push({name:tf(u),kind:"read"});continue}const m=tf(u);if(n?.remoteOwned){a.push({name:m,kind:"remote"});continue}if(!l)continue;const g=window.api?.uploadAttachment;if(!g){a.push({name:m,kind:"upload",detail:h("ui.chat.attachment_refusal.cannot_upload")});continue}const y=u.startsWith("data:")?{kind:"dataUrl",dataUrl:u,name:m}:{kind:"path",path:q3(u),name:m},v=await g(y);if(!v.success){a.push({name:m,kind:"upload",detail:v.error});continue}const b=v.attachment;i.push({digest:b.digest,name:b.name??m,mime_type:b.mime_type,bytes:b.bytes,...b.path?{path:b.path}:{}})}const c=Math.max(0,r.length-W3);return{images:await Uhn(r.slice(0,W3),ik,u=>y7(t,u)),files:i.slice(0,U3),failures:a,overflow:c,fileOverflow:s}}const Yhn=/\.+$/,uue=e=>typeof e=="string"?tf(e):e.name,Ghn=e=>e?.trim().replace(Yhn,"")??"",Ihn=e=>h("ui.chat.attachment_refusal.clause.read",{name:e}),Zhn=(e,t)=>{const n=Ghn(t);return n?h("ui.chat.attachment_refusal.clause.upload_reason",{name:e,reason:n}):h("ui.chat.attachment_refusal.clause.upload",{name:e})},Dhn=e=>h("ui.chat.attachment_refusal.clause.remote",{name:e});function wbn(e){if(e.length===0)return null;const t=e.map(uue),n=e.length>0&&e.every(a=>typeof a!="string"&&a.kind==="remote");if(e.every(a=>typeof a=="string"||a.kind==="read"))return t.length===1?h("ui.chat.attachment_refusal.read_one",{name:t[0]??""}):h("ui.chat.attachment_refusal.read_many",{names:Vs(t)});if(n)return t.length===1?h("ui.chat.attachment_refusal.remote_one",{name:t[0]??""}):h("ui.chat.attachment_refusal.remote_many",{names:Vs(t)});const i=e.map(a=>typeof a=="string"||a.kind==="read"?Ihn(uue(a)):a.kind==="remote"?Dhn(a.name):Zhn(a.name,a.detail));return h(t.length===1?"ui.chat.attachment_refusal.mixed_one":"ui.chat.attachment_refusal.mixed_many",{clauses:mue(i)})}function xbn(e){if(e<=0)return null;const t=W3,n=t+e;return e===1?h("ui.chat.attachment_refusal.images_one",{total:n,cap:t}):h("ui.chat.attachment_refusal.images_many",{total:n,cap:t,dropped:e})}function Sbn(e){if(e<=0)return null;const t=U3,n=t+e;return e===1?h("ui.chat.attachment_refusal.files_one",{total:n,cap:t}):h("ui.chat.attachment_refusal.files_many",{total:n,cap:t,dropped:e})}function Qbn(){const[e,t]=$.useState(null),[n,r]=$.useState(null),i=$.useRef(null),a=$.useCallback(async o=>{i.current=o,t(s=>s&&s.id!==o?null:s),r(s=>s&&s.id!==o?null:s);try{const s=await Te({op:"sessions.get",sessionId:o});if(i.current!==o)return;t({id:o,frontend:s.payload.frontend.snapshot})}catch{}try{const s=await Te({op:"commands.entities",sessionId:o,command:"effort"});if(i.current!==o)return;r({id:o,entities:s.entities})}catch{}},[]);return{frontend:e?.frontend??null,effortEntities:n?.entities,refresh:a}}function _bn(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function kbn(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function Pbn(e,t){return e==="pause"?{text:h("ui.notices.aida.paused_receipt"),kind:"success"}:e==="resume"?{text:h("ui.notices.aida.resumed_receipt"),kind:"success"}:{kind:"info",text:t.paused?h("ui.notices.aida.paused"):h("ui.notices.aida.active")}}function Vhn(e){return To(e,h("ui.notices.aida.unreachable"))}const Tbn="The chief of staff is switched off on this install.",Mhn="aida_no_provider",Lhn="aida_disabled";function Xbn(e,t){const n=e instanceof vn?e.code:void 0;return n===Lhn?null:n===Mhn?{kind:"info",text:h("ui.notices.aida.account_required",{name:t})}:{kind:"error",text:h("ui.notices.aida.open_fallback",{name:t,detail:Vhn(e)})}}function Rbn(e,t){if(e.held===!0)return`${t} is already open in another window, so she will say hello there.`;const n=e.greeting_state==="delivered"||e.greeting_state==="skipped"||e.greeting_state==null&&e.greeted===!0;return e.paused&&!n?`${t} is paused, so she will say hello when you resume her: type /aida resume.`:null}function Ebn(e){const t=e?.greeting_state;return t==null||t==="owed"}function Fhn(e){return e.eventKey===e.storeKey&&!e.focused}let Oue=!1;function qbn(){if(Oue)return;Oue=!0;const e=Fn.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{Fhn({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&(s7e(),Fn.persist?.rehydrate?.()?.catch?.(()=>{}))};window.addEventListener("storage",t)}export{eWe as $,iP as A,Ob as B,Df as C,Ar as D,Ot as E,_r as F,Ir as G,os as H,oW as I,ma as J,Mn as K,Xn as L,tr as M,GU as N,ps as O,m8 as P,upn as Q,Xpn as R,Mpn as S,Jpn as T,s8 as U,Bpn as V,yWe as W,mWe as X,Vpn as Y,dWe as Z,Cpn as _,lr as a,dun as a$,qpn as a0,jpn as a1,Rpn as a2,Upn as a3,Wpn as a4,Npn as a5,Lpn as a6,tLe as a7,zc as a8,Dpn as a9,dpn as aA,rpn as aB,fpn as aC,Mp as aD,wY as aE,CY as aF,svn as aG,vc as aH,cr as aI,JKe as aJ,dy as aK,lvn as aL,Qbn as aM,oY as aN,N8 as aO,x7 as aP,Iv as aQ,IO as aR,uFe as aS,Tbn as aT,bbn as aU,wbn as aV,xbn as aW,Sbn as aX,Nmn as aY,qit as aZ,Nd as a_,HI as aa,Zpn as ab,Ls as ac,_o as ad,fde as ae,oWe as af,Epn as ag,nWe as ah,Ipn as ai,Jn as aj,zpn as ak,KMe as al,Ypn as am,sWe as an,lWe as ao,PO as ap,Kpn as aq,t7 as ar,FMe as as,JMe as at,eLe as au,e7 as av,$mn as aw,Hpn as ax,Apn as ay,pk as az,el as b,VMe as b$,Mm as b0,Wd as b1,Ehn as b2,yNe as b3,nmn as b4,Qjt as b5,apn as b6,spn as b7,qbn as b8,Kmn as b9,B2e as bA,Bvn as bB,gFt as bC,toe as bD,eoe as bE,hTe as bF,BY as bG,h5 as bH,aLt as bI,iLt as bJ,km as bK,rLt as bL,nLt as bM,f_ as bN,zb as bO,LY as bP,VY as bQ,Md as bR,d_ as bS,L6e as bT,Yv as bU,Kh as bV,h8e as bW,Hke as bX,U2 as bY,APe as bZ,AI as b_,Bmn as ba,_jt as bb,Pjt as bc,opn as bd,SFe as be,hS as bf,XAe as bg,W6e as bh,dk as bi,u$n as bj,Cs as bk,Ud as bl,pFe as bm,zi as bn,Fl as bo,I9e as bp,kOe as bq,ryn as br,iyn as bs,gS as bt,Zd as bu,Ma as bv,$Mt as bw,zY as bx,M2e as by,jb as bz,M5e as c,ly as c$,B6e as c0,A6e as c1,Jin as c2,fBe as c3,Ize as c4,YI as c5,l$ as c6,yOe as c7,Phe as c8,jr as c9,lUe as cA,Ppn as cB,aOe as cC,kee as cD,t6e as cE,s$ as cF,x_e as cG,E9e as cH,Vp as cI,VA as cJ,DA as cK,Nv as cL,ey as cM,CAe as cN,Y9e as cO,o9e as cP,fk as cQ,oPe as cR,xke as cS,dvn as cT,t4 as cU,IN as cV,n4 as cW,Dp as cX,qOe as cY,EOe as cZ,QOe as c_,mHe as ca,Hhe as cb,V3 as cc,cgn as cd,Qpn as ce,_pn as cf,Spn as cg,VUe as ch,Tpn as ci,zUe as cj,lY as ck,mOe as cl,dx as cm,lgn as cn,D8 as co,dBe as cp,Ahe as cq,ogn as cr,sgn as cs,wAe as ct,xe as cu,ppn as cv,X9e as cw,hUe as cx,JA as cy,Wmn as cz,Ivn as d,Kd as d$,cs as d0,SOe as d1,mD as d2,Mmn as d3,Lmn as d4,Vx as d5,W3t as d6,RN as d7,J_e as d8,Z3t as d9,OA as dA,N8t as dB,M7e as dC,rKe as dD,j9e as dE,J9e as dF,j3t as dG,m$n as dH,b$n as dI,p$n as dJ,v$n as dK,f$n as dL,cee as dM,h8t as dN,ES as dO,WI as dP,zHe as dQ,DO as dR,CHe as dS,K8 as dT,Pqt as dU,ty as dV,Zv as dW,du as dX,FOe as dY,ny as dZ,Hd as d_,qi as da,Nf as db,I$n as dc,w7 as dd,Oy as de,H$n as df,V$n as dg,Gee as dh,C6e as di,Qun as dj,vbn as dk,Z5 as dl,TG as dm,KA as dn,K8e as dp,mk as dq,R8e as dr,WOe as ds,hun as dt,MRe as du,Qce as dv,ZFe as dw,TWe as dx,xhe as dy,lun as dz,Mvn as e,khe as e$,yS as e0,Ife as e1,_k as e2,jfe as e3,t7t as e4,eyn as e5,B$n as e6,K$n as e7,A3t as e8,tke as e9,P$n as eA,x$n as eB,rz as eC,O$n as eD,iz as eE,q$n as eF,S$n as eG,X$n as eH,G$n as eI,g$n as eJ,Y$n as eK,U$n as eL,C$n as eM,W$n as eN,vzt as eO,E$n as eP,L_e as eQ,T$n as eR,Od as eS,Rmn as eT,aFe as eU,Ac as eV,Kin as eW,R5 as eX,E5 as eY,btn as eZ,T5 as e_,N3t as ea,D$n as eb,A$n as ec,Vy as ed,d$n as ee,nz as ef,ZP as eg,C3t as eh,h$n as ei,q3t as ej,vOe as ek,$Fe as el,F$n as em,J$n as en,tf as eo,MPe as ep,Qyn as eq,qmn as er,N$n as es,Y3t as et,k$n as eu,M$n as ev,U3t as ew,L$n as ex,Z$n as ey,j$n as ez,Zvn as f,dz as f$,ipn as f0,F8t as f1,B8t as f2,fz as f3,NLe as f4,UOe as f5,PFe as f6,VPe as f7,f5e as f8,$3t as f9,Uyn as fA,Zi as fB,Cyn as fC,DPe as fD,Wyn as fE,I8t as fF,Kyn as fG,Myn as fH,Lyn as fI,Byn as fJ,Fyn as fK,Y8t as fL,G8t as fM,Gyn as fN,i8 as fO,Z8t as fP,Zyn as fQ,Ayn as fR,zyn as fS,Nyn as fT,Iyn as fU,Dyn as fV,She as fW,Fmn as fX,dzt as fY,mzt as fZ,Syn as f_,GO as fa,kN as fb,Iy as fc,dAt as fd,fAt as fe,$Pe as ff,Bx as fg,m6e as fh,IP as fi,lNt as fj,qz as fk,cfn as fl,lbn as fm,_c as fn,cbn as fo,Ofn as fp,v5e as fq,POe as fr,yN as fs,Lcn as ft,Ou as fu,Vyn as fv,lze as fw,J7t as fx,Hyn as fy,Yyn as fz,Fvn as g,QFe as g$,Lee as g0,mun as g1,Lan as g2,ji as g3,fc as g4,Dmn as g5,hWt as g6,Rd as g7,fUt as g8,o$n as g9,bIt as gA,vIt as gB,yIt as gC,$It as gD,a5 as gE,nIt as gF,tIt as gG,gIt as gH,mIt as gI,w8e as gJ,In as gK,oA as gL,I6e as gM,SVe as gN,RVe as gO,dZe as gP,cy as gQ,wVe as gR,ahe as gS,OOe as gT,uOe as gU,Ymn as gV,Gmn as gW,g8e as gX,Imn as gY,Zmn as gZ,sUe as g_,R_e as ga,E_e as gb,s$n as gc,i$n as gd,LJ as ge,l$n as gf,q_e as gg,Sjt as gh,a$n as gi,C_e as gj,VAe as gk,lpn as gl,sbn as gm,_Fe as gn,RFe as go,Ovn as gp,cf as gq,n2e as gr,BQ as gs,l_ as gt,uoe as gu,XMt as gv,lv as gw,xIt as gx,SIt as gy,wIt as gz,_re as h,Tgn as h$,MLe as h0,Hmn as h1,lYe as h2,cYe as h3,Pa as h4,XWe as h5,ry as h6,NNe as h7,hk as h8,HNe as h9,o4 as hA,Ygn as hB,Ez as hC,sNt as hD,iNt as hE,Ggn as hF,gf as hG,Y6t as hH,F6t as hI,Yet as hJ,Dgn as hK,dNt as hL,nze as hM,Zp as hN,Zgn as hO,Y0 as hP,sY as hQ,Vte as hR,Xgn as hS,Kpe as hT,hAe as hU,Jgn as hV,Hgn as hW,z7 as hX,vet as hY,wet as hZ,R6e as h_,Mde as ha,Dy as hb,BNe as hc,emn as hd,fmn as he,dmn as hf,O8 as hg,r0n as hh,hvn as hi,fvn as hj,Fet as hk,Bgn as hl,Lgn as hm,Fgn as hn,t0n as ho,n0n as hp,ket as hq,jgn as hr,Egn as hs,b3t as ht,Agn as hu,zgn as hv,Ugn as hw,Wgn as hx,Ngn as hy,Pgn as hz,Dvn as i,kgn as i$,Hpe as i0,Cgn as i1,uUe as i2,gx as i3,i0n as i4,F9e as i5,JJe as i6,u0n as i7,qgn as i8,Kgn as i9,Oyn as iA,dyn as iB,gCt as iC,u8 as iD,RWe as iE,V6e as iF,ghn as iG,r9e as iH,NAe as iI,ROe as iJ,q6e as iK,QKe as iL,PKe as iM,XKe as iN,$gn as iO,ygn as iP,vgn as iQ,IKe as iR,Qgn as iS,wgn as iT,AKe as iU,kpe as iV,_gn as iW,Kze as iX,NKe as iY,bgn as iZ,LKe as i_,Vgn as ia,Zet as ib,e0n as ic,Tet as id,Mgn as ie,mNt as ig,U7 as ih,Cet as ii,byn as ij,wyn as ik,XRe as il,qyn as im,vWt as io,mCt as ip,tyn as iq,Y6e as ir,nyn as is,cyn as it,fyn as iu,oyn as iv,ayn as iw,uyn as ix,hyn as iy,pyn as iz,Lvn as j,FO as j$,xgn as j0,kKe as j1,Yn as j2,Sgn as j3,SAe as j4,rmn as j5,iy as j6,fNt as j7,K8t as j8,Mk as j9,qge as jA,kit as jB,Eit as jC,IS as jD,rP as jE,Pt as jF,W0n as jG,Le as jH,_$e as jI,Xlt as jJ,CO as jK,Tlt as jL,Vn as jM,eo as jN,mt as jO,Xl as jP,Vt as jQ,Zf as jR,Li as jS,ng as jT,xr as jU,_n as jV,Ri as jW,Fc as jX,Vw as jY,nQ as jZ,tP as j_,g0n as ja,d0n as jb,_it as jc,hat as jd,O0n as je,CU as jf,zU as jg,jU as jh,Age as ji,ZS as jj,qU as jk,jge as jl,m0n as jm,J0n as jn,r$n as jo,Eqt as jp,bLe as jq,yLe as jr,xmn as js,kmn as jt,wmn as ju,_mn as jv,Smn as jw,Qmn as jx,vde as jy,ZWe as jz,av as k,ET as k$,R0n as k0,xi as k1,QL as k2,yo as k3,Rc as k4,i0e as k5,On as k6,Wn as k7,yf as k8,es as k9,tb as kA,qk as kB,l9t as kC,Bp as kD,c$n as kE,K0n as kF,YP as kG,nb as kH,Qke as kI,bpe as kJ,Ek as kK,Xqt as kL,Rqt as kM,QHe as kN,qQe as kO,mN as kP,k7 as kQ,_pe as kR,k4e as kS,$S as kT,Ntt as kU,k8e as kV,P8e as kW,S_e as kX,f0n as kY,bk as kZ,dfe as k_,w0n as ka,X0n as kb,xu as kc,Z0n as kd,A0n as ke,iut as kf,E0n as kg,q0n as kh,Q0n as ki,U0n as kj,x0n as kk,S0n as kl,z0n as km,N0n as kn,Y0n as ko,I0n as kp,D0n as kq,P0n as kr,T0n as ks,_0n as kt,Kk as ku,k0n as kv,vpe as kw,EQe as kx,F8 as ky,s9t as kz,O_ as l,$bn as l$,ont as l0,ant as l1,Ofe as l2,mmn as l3,Gfe as l4,$a as l5,MO as l6,Jv as l7,o0n as l8,jYe as l9,wvn as lA,Yvn as lB,qp as lC,Gvn as lD,mfn as lE,eze as lF,$he as lG,xpn as lH,nde as lI,UD as lJ,z6t as lK,tfe as lL,pmn as lM,myn as lN,SNt as lO,vpn as lP,pbn as lQ,pUe as lR,gbn as lS,gyn as lT,$yn as lU,Q5e as lV,bvn as lW,gpn as lX,Bze as lY,ypn as lZ,pfn as l_,vnt as la,DVe as lb,PS as lc,S8 as ld,f7 as le,Yfe as lf,FYe as lg,TYe as lh,IYe as li,KZ as lj,cDe as lk,h9e as ll,TOe as lm,fbn as ln,X3 as lo,m4e as lp,hbn as lq,dbn as lr,dfn as ls,ubn as lt,Obn as lu,JLe as lv,iun as lw,A$ as lx,mbn as ly,mp as lz,Vvn as m,EWe as m$,$pn as m0,mpn as m1,bpn as m2,xUe as m3,hfn as m4,Pyn as m5,n$n as m6,e$n as m7,o9t as m8,Qqt as m9,A5e as mA,R2 as mB,Lm as mC,syn as mD,lyn as mE,ign as mF,agn as mG,OBe as mH,XFe as mI,nvn as mJ,rvn as mK,ivn as mL,$Ae as mM,dUe as mN,xyn as mO,hgn as mP,CUe as mQ,Kzt as mR,Fv as mS,Pmn as mT,ghe as mU,imn as mV,GWe as mW,amn as mX,uWe as mY,phe as mZ,SUe as m_,CP as ma,Tyn as mb,v9t as mc,nte as md,b9t as me,h0n as mf,jqt as mg,Nze as mh,_yn as mi,t$n as mj,Xyn as mk,Ryn as ml,aPe as mm,g3t as mn,IOe as mo,k2 as mp,PRt as mq,L8 as mr,DQ as ms,Xf as mt,Pke as mu,p0n as mv,Lze as mw,zdn as mx,kyn as my,qYt as mz,K5e as n,cmn as n$,CKe as n0,Gke as n1,obn as n2,mgn as n3,pHe as n4,bhe as n5,CLe as n6,wLe as n7,ymn as n8,vmn as n9,pgn as nA,Rgn as nB,Ign as nC,$Nt as nD,Kvn as nE,ybn as nF,kWe as nG,yyn as nH,jUe as nI,cY as nJ,yvn as nK,$vn as nL,vvn as nM,mvn as nN,pvn as nO,tbn as nP,omn as nQ,Ade as nR,Nde as nS,$8 as nT,Ude as nU,Wde as nV,Omn as nW,umn as nX,yk as nY,jde as nZ,pNe as n_,bmn as na,nLe as nb,Cmn as nc,qAt as nd,bPe as ne,qcn as nf,ZRe as ng,Hvn as nh,sh as ni,_bn as nj,Pbn as nk,Vhn as nl,kbn as nm,Jvn as nn,VRe as no,ugn as np,fgn as nq,Ogn as nr,dgn as ns,Umn as nt,q5e as nu,C6t as nv,eun as nw,wNe as nx,dHe as ny,fHe as nz,pIt as o,Xbn as o$,c8 as o0,smn as o1,lmn as o2,abn as o3,vyn as o4,ebn as o5,R$n as o6,TUe as o7,w$n as o8,y$n as o9,Wvn as oA,kvn as oB,Nvn as oC,wUt as oD,Iun as oE,qvn as oF,jvn as oG,RUt as oH,Svn as oI,YNt as oJ,xvn as oK,Qvn as oL,UNt as oM,Tvn as oN,zvn as oO,Cvn as oP,HP as oQ,Evn as oR,Rvn as oS,Xvn as oT,Pvn as oU,FA as oV,JRe as oW,P5e as oX,v7 as oY,Ebn as oZ,Rbn as o_,$$n as oa,EN as ob,z3t as oc,Q$n as od,_$n as oe,Vmn as of,Jx as og,H9e as oh,wO as oi,Xmn as oj,_Le as ok,Tmn as ol,lFe as om,uYe as on,SUt as oo,t5e as op,Avn as oq,Jyn as or,tvn as os,a5e as ot,hu as ou,evn as ov,_he as ow,xUt as ox,_vn as oy,Uvn as oz,vm as p,sun as p0,LRe as p1,jyn as p2,j8t as p3,FRe as p4,rbn as p5,avn as p6,DUt as p7,q8t as p8,ibn as p9,zmn as pA,K6e as pB,gvn as pC,hmn as pD,kpn as pE,tmn as pF,DFe as pG,Amn as pH,Km as pI,a0n as pJ,_Ue as pK,Eyn as pL,JUt as pM,tgn as pN,Jmn as pO,egn as pP,Lg as pQ,ngn as pR,hpn as pS,Tjt as pT,lx as pU,rgn as pV,cpn as pW,ggn as pX,c0n as pY,Qz as pa,GPe as pb,s5e as pc,ovn as pd,nbn as pe,UPe as pf,WPe as pg,U8t as ph,OWt as pi,O5e as pj,u5e as pk,V7e as pl,Tte as pm,cvn as pn,uvn as po,LLe as pp,FLe as pq,Emn as pr,wpn as ps,PUe as pt,Fpn as pu,Gpn as pv,jmn as pw,z$n as px,X8t as py,npn as pz,wl as q,Zc as r,FQ as s,i5 as t,jn as u,P as v,bY as w,Tn as x,gr as y,bn as z};
|
|
1074
|
+
`)?1:0,En=Cc(Xe,he.start,he.end+rn,Ee),wn=Ee.endsWith('"')?En.caret-1:En.caret;ii.current=wn,Ln(En.text),Pi(wn),Eo.remember(M.path),Eo.close()},[Xe,Xr,Eo,Ln,Re]),n2=$.useCallback(M=>{if(Re||!hr.token)return;const he=Gdn(Xe,hr.token,M.name);hr.close(),ii.current=he.caret,Ln(he.text),Pi(he.caret)},[Xe,hr,Ln,Re]),R4e=$.useCallback(M=>{const he=ic.current;return he===null||!(M.metaKey||M.ctrlKey)||M.altKey||M.shiftKey||M.key.toLowerCase()!=="z"?!1:(ic.current=null,ii.current=he.caret,he.plain>0&&Tr({chars:he.plain,over:he.text}),Ln(he.text),Pi(he.caret),!0)},[Tr,Ln]),E4e=$.useCallback(M=>{if(Re)return;if(ld(M)){M.preventDefault();return}if(M.key==="Escape"&&Ie!==null){if(M.preventDefault(),Gt)return;ln();return}if(j4e(M)){M.preventDefault();return}if(R4e(M)){M.preventDefault();return}if(wdn(M,Eo,RG)){M.preventDefault();return}if(uhn(M,lt,t2,XG)){M.preventDefault();return}if(lfn(M,hr,n2)){M.preventDefault();return}if(nt!==null&&M.key==="Escape"){M.preventDefault(),P7(c??"");return}if(nt!==null&&UBe(M)){const Be=nt.turns.at(-1),rn=Be?wr.getState().streams[Be.asideId]:void 0;if(!Be||nt.queued!==void 0||!Ghe(rn,u,O))return;M.preventDefault();const En=c??"",wn=Date.now(),yr=NBe(gt.current,Be.asideId,wn);if(yr==="arm"){gt.current={turnId:Be.asideId,at:wn},wr.getState().setAsideNotice(En,ID(E3));return}if(yr==="ignore")return;gt.current=null,Nhe(En).catch(()=>{});return}if(M.key==="Backspace"||M.key==="Delete"){const Be=IOn(Xr,M.key==="Backspace"?"back":"forward",ri.spans,ri.resolved);if(Be&&!M.nativeEvent.isComposing){const rn=Cc(Xe,Be.start,Be.end,"");ii.current=rn.caret,Pi(rn.caret),Ln(rn.text),M.preventDefault();return}}const he=Dt.current,Ee=khn();if(Ee&&vNe(M,{value:Xe,selectionStart:he?.selectionStart??null,selectionEnd:he?.selectionEnd??null})){Ee.focus(),M.preventDefault();return}if(Lr&&M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing){M.preventDefault(),Kb();return}if(M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing){const Be=sl(Xe,Xr);if(Be.kind!=="send"){M.preventDefault(),cd(Be,Xe,Xr);return}if(Mr(Xe)){M.preventDefault();return}}Rg(M)},[lt,t2,XG,hr,n2,Mr,Rg,ld,Ie,ln,sl,cd,Xe,Xr,Re,nt,c,u,O]),EG=$.useRef(null),ll=$.useCallback(M=>{mA=!1,Dt.current?.focus({preventScroll:M?.preventScroll===!0})},[Dt]),q4e=$.useCallback(()=>{c8(Xe)!==null&&Ln("")},[Xe,Ln]);$.useImperativeHandle(we,()=>({focusInput:ll,openWorkingDirectoryMenu:()=>{EG.current?.openMenu()},submitNow:()=>{Mr(Xe)||ph()},consumeApprovalAnswerDraft:q4e}));const qG=$.useCallback(()=>Dt.current,[Dt]);$.useEffect(()=>TWe(ll,qG),[ll,qG]);const cl=$.useRef(null),jG=$.useRef(Xe);$.useLayoutEffect(()=>{jG.current=Xe},[Xe]);const CG=$.useCallback(M=>{cl.current===M&&(cl.current=null,Rn.current.delete(M.index))},[]),Jb=$.useCallback(M=>{if(cl.current!==M)return!1;const he=_Et({buffer:jG.current,cleared:M.cleared});return he?(Rn.current.set(M.index,M.payload),cl.current===M&&(cl.current=null),M.toastId!==null&&s$(M.toastId),ya({capture:fp(Pr.current,he.buffer,he.caret,"arrival"),buffer:he.buffer,caret:he.caret}),nc(null),!0):!1},[ya,nc]);$.useLayoutEffect(()=>{const M=cl.current;M!==null&&M.cleared.buffer!==Xe&&(M.toastId!==null&&s$(M.toastId),CG(M))},[Xe,CG]);const j4e=$.useCallback(M=>{const he=cl.current;return he===null||!(M.metaKey||M.ctrlKey)||M.altKey||M.shiftKey||M.key.toLowerCase()!=="z"?!1:(Jb(he),!0)},[Jb]),zG=$.useCallback(M=>{Jb(M)&&ll()},[ll,Jb]),C4e=$.useCallback(M=>{if(Re)return;const he=Rn.current.get(M);if(!he)return;const Ee=QEt({buffer:Xe,payload:he});if(!Ee.cleared)return;const Be=cl.current;Be&&(cl.current=null,Rn.current.delete(Be.index),Be.toastId!==null&&s$(Be.toastId));const rn={index:M,payload:he,cleared:Ee,toastId:null};cl.current=rn,ya({capture:fp(Pr.current,Ee.buffer,Ee.caret,"arrival"),buffer:Ee.buffer,caret:Ee.caret}),nc({key:he.key,index:M,over:Ee.buffer}),rn.toastId=Kh(xEt(M),{action:{label:wEt(),onClick:()=>zG(rn)}}),ll()},[ya,ll,Re,Xe,nc,zG]),z4e=Se,A4e=Re||Se||Ue||Xe.trim().length>0;$.useEffect(()=>{const M=Dt.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[Xe,Dt,Se,Ue,We]);const r2=!!o?.blocksInput&&Xe==="",ew=$.useRef(null);$.useLayoutEffect(()=>{const M=Dt.current;if(!M||!r2){M&&ew.current!==null&&(M.style.overflowY=""),ew.current=null;return}ew.current!==M.placeholder&&(ew.current=M.placeholder,oue(M))}),$.useEffect(()=>{const M=Dt.current;if(!M||!r2||typeof ResizeObserver>"u")return;let he=M.clientWidth;const Ee=new ResizeObserver(()=>{M.clientWidth!==he&&(he=M.clientWidth,oue(M))});return Ee.observe(M),()=>Ee.disconnect()},[r2,Dt]);const AG=$.useRef(!1);$.useEffect(()=>{const M=Se||Ue,he=AG.current&&!M;if(AG.current=M,!ee&&!he||Re||M)return;const Ee=document.activeElement;!(Ee&&(Ee.tagName==="INPUT"||Ee.tagName==="TEXTAREA"||Ee.getAttribute("role")==="tab"))&&!R&&Dt.current?.focus({preventScroll:!0})},[ee,Re,Se,Ue,Dt,R]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(M=>{Tt(M.platform)}).catch(M=>{console.error("Failed to get platform info:",M)})},[]);const bs=$.useRef(null),U4e=250,UG=$.useRef(qe);$.useEffect(()=>{UG.current=qe}),$.useEffect(()=>(Qce("message-input",Se||We),()=>Qce("message-input",!1)),[Se,We]),$.useEffect(()=>{UG.current?.(Se)},[Se]);const ws=$.useCallback(M=>{rt(!1);const he=Yt.current;if(!he)return;const Ee=bs.current?.startedAt??null,Be=Ee===null?Number.POSITIVE_INFINITY:performance.now()-Ee;if(bs.current=null,he.state==="inactive"){ft(!1);return}(M==="abort"||Be<U4e)&&(he.onstop=()=>{if(he.stream)for(const rn of he.stream.getTracks())rn.stop();yt(null),or.current=[],Nt.current=null,Ye(rn=>Bh(rn,{type:"discarded"}))}),he.stop(),ft(!1)},[]);$.useEffect(()=>()=>{const M=bs.current!==null;bs.current=null;const he=Yt.current;if(he&&he.state!=="inactive"){ws("abort");return}M&&rt(!1)},[ws]);const i2=$.useCallback((M="release")=>{const he=bs.current;if(he){if(he.startedAt===null){bs.current=null,rt(!1);return}ws(M)}},[ws]),WG=$.useCallback(async()=>{if(!(Re||!Dr)&&!bs.current)if(navigator?.mediaDevices?.getUserMedia){const M={startedAt:null};bs.current=M,rt(!0);try{const he=await navigator.mediaDevices.getUserMedia({audio:!0});if(bs.current!==M){for(const Ee of he.getTracks())Ee.stop();return}Yt.current=new MediaRecorder(he),or.current=[],Yt.current.ondataavailable=Ee=>{or.current.push(Ee.data)},Yt.current.onstop=()=>{const Ee=new Blob(or.current,{type:"audio/webm"});it(null),yt(Ee);for(const Be of he.getTracks())Be.stop()},Yt.current.start(),M.startedAt=performance.now(),rt(!1),ft(!0),yt(null)}catch(he){if(bs.current!==M)return;bs.current=null,rt(!1),console.error("Error accessing microphone:",he),Jn(h("ui.canvas.inline_edit.error_accessing_microphone_please_ensure_microphone_permissions_are_gran"))}}else console.error("This runtime exposes no MediaRecorder"),Jn(h("ui.canvas.inline_edit.dictation_is_not_available_on_this_device"))},[Dr,Re]),a2=$.useCallback(()=>{Se&&ws("release")},[Se,ws]),o2=$.useCallback(()=>{Se&&ws("abort")},[Se,ws]),W4e=$.useCallback(()=>{if(!(!Se||Zt!=="idle")&&!(Re||R||E||Ru)){if(Yt.current?.state!=="recording"){ws("release");return}Nt.current={draftAtPress:Xe,transcript:null},Ye(M=>Bh(M,{type:"press"})),ws("release")}},[Se,Zt,Re,R,E,Ru,Xe,ws]);$.useEffect(()=>{if(!Se&&!We)return;const M=he=>{if(Se){if(he.key==="Enter"){const Ee=he.target;if(Ee instanceof Element&&Ee.closest("[data-lo-composer-controls] button"))return;he.preventDefault(),a2()}else he.key==="Escape"&&(he.preventDefault(),o2());return}he.key==="Escape"&&(he.preventDefault(),i2("abort"),rt(!1))};return window.addEventListener("keydown",M),()=>{window.removeEventListener("keydown",M)}},[Se,We,a2,o2,i2]);const tw=$.useCallback(()=>{Nt.current&&(Nt.current=null,Ye(M=>Bh(M,{type:"transcript",usable:!1})))},[]),NG=$.useCallback(async()=>{if(!Wt)return;on.current?.abort();const M=new AbortController;on.current=M;try{_t(!0);const he=await KA.createTranscriptionWithRetry(IO.baseUrl,{file:new File([Wt],"recording.webm",{type:"audio/webm"})},{signal:M.signal,onRetry:({attempt:Ee,total:Be,delayMs:rn,error:En})=>{console.warn(`Transcription attempt ${Ee}/${Be} failed with a transient upstream fault; retrying in ${rn} ms.`,En)}});if(he.result?.text){const Ee=he.result?.text||"";ad.current=!0,Vb(Ee),Nt.current&&(Nt.current.transcript=Ee,Ye(Be=>Bh(Be,{type:"transcript",usable:!0})))}else _o(K8e()),tw();it(null),yt(null)}catch(he){if(M.signal.aborted){tw();return}console.error("Error transcribing audio:",he),tw();const Ee=mk(he);it(Ee?R8e(he):null),Ee||Jn(WOe(he))}finally{on.current===M&&_t(!1)}},[Wt,Vb,tw]),N4e=$.useCallback(()=>{it(null),at(M=>M+1)},[]);$.useEffect(()=>{if(!Wt){At.current=null;return}At.current?.blob===Wt&&At.current.attempt===Ct||(At.current={blob:Wt,attempt:Ct},NG())},[Wt,Ct,NG]);const YG=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const M=Dt.current;if(M===null)return;const he=new IntersectionObserver(Ee=>{const Be=Ee[Ee.length-1];Be!==void 0&&(YG.current=Be.isIntersecting)});return he.observe(M),()=>he.disconnect()},[Dt]),hun(ce,MRe.MESSAGE_INPUT,{start:WG,stop:i2},()=>!!(!Re&&!Se&&!Ue&&Dr&&YG.current));const s2=(M=!1)=>{if(Re||R)return!1;if(E)return Kb(),!1;if(!Xe.trim()&&$e.length===0||M&&Ya(Ni)||M&&r&&Ecn(Xe))return!1;if(sd())return!0;const he=sl(Xe,Xr);if(he.kind!=="send")return M?!1:(cd(he,Xe,Xr),!0);if(M){if(l&&EJ(Xe))return!1}else if(Mr(Xe))return!0;return ph(),!0},Y4e=M=>{M.preventDefault(),s2()},GG=$.useRef(s2);GG.current=s2,$.useEffect(()=>{if(Zt==="ready-to-submit"){if(Ue)return;const M=Nt.current;if(!M||M.transcript===null){Ye("idle");return}const{intact:he}=Rcn({draftAtPress:M.draftAtPress,transcript:M.transcript,current:Xe,join:k7});Nt.current=null;const Ee=he?GG.current(!0):!1;Ye(Be=>Bh(Be,{type:"checked",draftIntact:he&&Ee}));return}Zt==="submitting"&&!Ru&&Ye(M=>Bh(M,{type:"settled",sendBusy:!1}))},[Zt,Ue,Xe,Ru]);const l2=$.useCallback(M=>{Re&&M.preventDefault()},[Re]),IG=$.useCallback(M=>{!Re&&!Lr||(M.preventDefault(),Lr&&!Re&&Kb())},[Re,Lr,Kb]),G4e=M=>{f&&pe(f,M)},I4e=async()=>{const M=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!M.canceled&&M.filePaths.length>0&&f)for(const he of M.filePaths)Ke(f,{id:ka(),path:$I(he)})},Z4e=M=>{if(Re)return;const he=M.clipboardData?.getData("text/plain")??"";if(he&&Pr.current.arm!==null){const Be=M.currentTarget,rn=uEt({capture:Pr.current,buffer:Xe,caret:Be.selectionEnd??Xe.length,selection:{start:Be.selectionStart??Xe.length,end:Be.selectionEnd??Xe.length},pasted:he,index:tl.current,taken:Cg()});if(rn){M.preventDefault(),ya(rn),Tr(null);return}}Qun(M.clipboardData??null)?M.preventDefault():he&&(Qg.current=J4t(he));const Ee=M.clipboardData?.items;if(Ee){for(let Be=0;Be<Ee.length;Be++)if(Ee[Be].type.indexOf("image")!==-1||Ee[Be].kind==="file"){const rn=Ee[Be].getAsFile();if(rn){const En=new FileReader;En.onload=wn=>{wn.target?.result&&f&&Ke(f,{id:ka(),path:wn.target.result})},En.readAsDataURL(rn)}}}},D4e=M=>{Re||M.dataTransfer?.types.includes("Files")&&(M.preventDefault(),M.stopPropagation(),M.dataTransfer.dropEffect="copy",c2(!0))},V4e=M=>{M.currentTarget.contains(M.relatedTarget)||c2(!1)},M4e=M=>{if(c2(!1),Re)return;const he=M.dataTransfer?.files;!he||he.length===0||(M.preventDefault(),M.stopPropagation(),f&&L4e(f,Array.from(he)))},L4e=async(M,he)=>{for(const Ee of he){const Be=window.api?.getPathForFile?window.api.getPathForFile(Ee):"";if(Be){Ke(M,{id:ka(),path:$I(Be)});continue}const rn=await _hn(Ee);rn&&Ke(M,{id:ka(),path:rn})}},[ZG,c2]=$.useState(!1),F4e=M=>{Re||(Xe||y?.(),ii.current=M.length,Ln(M),Pi(M.length),Dt.current?.focus())},u2=Ya(Ni)?Ni.value!==""?vs(Xe,Ni)?jEt():EEt():Hi?qEt():zEt():wg!==null&&wg===Xe?CEt():SEt({unredacted:mh!==null?AEt(mh):null,armed:Ni.arm!==null&&u_e(Xe,Xe.length)!==null,cleared:Oh===null?null:{key:Oh.key,index:Oh.index},undoCap:S4e(pi==="darwin")}),B4e=lun(pi==="darwin"?"mac":pi==="win32"?"win":"linux",!N),O2=$.useRef(null),H4e=M=>{f&&(O2.current=re.findIndex(he=>he.id===M),me(f,M))};$.useEffect(()=>{const M=O2.current;if(M===null)return;O2.current=null;const he=document.querySelectorAll(PWe),Ee=he[Math.min(M,he.length-1)];Ee?Ee.focus():ll()},[re,ll]);const qo=$.useMemo(()=>{const he=gI(Xe,re)!==""||$e.length>0,Ee=R||S?.message&&Ome.test(S.message)?[{get label(){return h("ui.chat.composer.connect_provider")},onClick:()=>wO.getState().openConnect()}]:[];return{message:S?.messageKey?h(S.messageKey):S?.message,muted:S?.muted===!0,polite:S?.polite===!0,actions:[...S?.actions??[],...Ee],retry:S?.retry===!0,clear:S?.muted!==!0&&(S?.onClear!==void 0||he)}},[S,Xe,re,$e,R,Je]),yh=SUt(),DG=X("block text-body-sm",U?"px-2 pb-1":"px-4 pb-2",mh!==null?"text-warning":"text-ink-muted"),d2=X("flex flex-wrap items-center gap-2 text-body-sm text-ink-muted",U?"px-2 pb-1":"px-4 pb-2"),VG=ue&&Xe.length>0,K4e=d.jsx("output",{className:X(jr,"block pb-2",yh.issue.kind==="hidden"&&"hidden"),children:d.jsx(Ydn,{issue:yh.issue,onSignIn:yh.start,onCancel:yh.cancel,onDismiss:yh.dismiss,isSmallView:U,onFocusComposer:()=>Dt.current?.focus()})}),vh=e7e(L),J4e=vh&&!_ue(vh)&&!t7e(vh,n7e(yh.issue))?d.jsx("output",{className:X(jr,"block pb-2"),children:d.jsx(tun,{access:vh,isSmallView:U,onSwitchModel:L?.onCommand?()=>L.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>wO.getState().openConnect({providerId:vh.provider})})}):null,MG=We||!Se&&!Ue&&!(t&&m),f2=Se?"recording":Ue?"transcribing":We?"preparing":"idle",eEe=Xe.trim()!==""||$e.length>0,bh=kcn(f2,Zt),h2=Pcn(f2),Ur=_cn({dictation:f2,alive:!!Q?.active,stopping:Q?.stopping===!0,hasPayload:eEe,refused:Re||Lr,sendBusy:Ru,sendRecording:Zt,reviewRequired:Ya(Ni)}),tEe=Ur.role==="stop-busy"?"stop":Ur.role,{ignore:nEe,arming:rEe}=S3(h2??"none"),{ignore:iEe,arming:aEe}=S3(bh),{ignore:LG,arming:FG}=S3(tEe),nw=$.useRef(!1),oEe=`${bh}|${Ur.role}|${h2}`;$.useEffect(()=>{if(!nw.current)return;const M=document.activeElement;M&&M!==document.body||(nw.current=!1,Dt.current?.focus({preventScroll:!0}))},[oEe]);const sEe=d.jsxs("form",{onSubmit:Y4e,"data-chat-region":"composer","aria-label":ZOe("composer"),tabIndex:-1,className:"w-full",children:[d.jsx(SI,{fallback:null,children:d.jsx(Qcn,{frontend:L?.frontend,askFrontend:L?.asks,runDetails:ke,isSmallView:U,askExpanded:Y,onAskToggle:V,askOutcomes:z,onNote:ae,onFocusComposer:()=>Dt.current?.focus()},f)}),!r7e(vh)&&K4e,J4e,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Xe.trim().length>0?d.jsx("p",{id:eue,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,qo.message!==void 0&&d.jsxs("div",{role:qo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":S?.message===o7e.queuedSend?!0:void 0,className:X(jr,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",U?"px-2 pb-1":"px-4 pb-2"),children:[d.jsxs("p",{className:X("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",qo.muted?"text-ink-muted":"text-danger"),children:[!qo.muted&&d.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:d.jsx(nu,{size:14,"aria-hidden":"true"})}),d.jsx("span",{className:X("min-w-0 break-words",!qo.muted&&"font-medium"),children:qo.message})]}),(qo.retry||qo.clear||qo.actions.length>0)&&d.jsxs(d.Fragment,{children:[qo.actions.map(M=>d.jsx(ve,{type:"button",variant:"link",size:"sm",className:X("min-h-6 cursor-pointer text-body-sm underline"),onClick:M.onClick,children:M.label},M.label)),qo.retry&&S?.onRetry&&d.jsx(ve,{type:"button",variant:"link",size:"sm",className:X("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>S.onRetry?.(),children:i7e()}),qo.clear&&S?.onClear&&d.jsx(ve,{type:"button",variant:"link",size:"sm","aria-label":h("ui.chat.composer.clear_message"),className:X("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>S.onClear?.(),children:a7e()})]})]}),w&&d.jsx("output",{className:X(jr,"block text-body-sm text-ink-muted",U?"px-2 pb-1":"px-4 pb-2"),children:w}),c&&nt!==null&&d.jsx(TOn,{sessionId:c,sessionStreaming:u,adoptQueueSupported:O,isSmallView:U,onReturnFocus:()=>Dt.current?.focus()}),_?d.jsx("div",{className:X(jr,U?"px-2 pb-2":"px-4 pb-2"),children:_}):null,d.jsxs("div",{className:X(jr,"relative w-full"),children:[d.jsx(ohn,{state:lt,onPick:t2,onActionPick:e2}),d.jsx(Sdn,{state:Eo,onPick:RG}),d.jsx(sfn,{state:hr,onPick:n2}),!N&&!lt.open&&!Eo.open&&!hr.open&&d.jsx(iNt,{visible:v,onClick:x,hasNewActivity:b}),d.jsx("output",{id:Fce,className:X(jr,u2?DG:"hidden"),children:u2}),VG&&d.jsx("output",{id:Bce,className:X(jr,DG),children:h("ui.chat.composer.secret_closure_notice")}),l&&Ie===null&&d.jsxs("output",{id:Hce,className:X(d2,jr),children:[d.jsx("span",{className:"min-w-0",children:h("ui.chat.composer.secret_ask_notice")}),d.jsx(ve,{type:"button",size:"sm",variant:"secondary","data-lo-ask-item-toggle":"",onClick:()=>l.onOpen(),children:h("ui.chat.composer.secret_ask_open")})]}),Ve!==null&&Ie===null&&d.jsx("output",{id:yhn,className:X(d2,jr),children:d.jsx("span",{className:"min-w-0",children:Ve})}),Ie!==null&&d.jsxs("fieldset",{ref:pr,tabIndex:-1,id:vhn,"aria-labelledby":Kce,"aria-busy":Gt,onKeyDown:M=>{M.key==="Escape"&&(M.preventDefault(),!Gt&&ln())},className:X("m-0 min-w-0 border-0 p-0",d2,jr),children:[d.jsxs("span",{id:Kce,className:"min-w-0",children:[Gt?h("ui.chat.composer.secret_confirm_sending"):h("ui.chat.composer.secret_confirm_message"),d.jsx("span",{className:X("whitespace-nowrap",Gt&&"invisible"),"aria-hidden":Gt||void 0,children:` ${h("ui.chat.composer.secret_confirm_chars",{count:Ie.value.length})}`})]}),d.jsx(ve,{ref:sn,type:"button",size:"sm",disabled:Gt,onClick:K5,children:l?.fillable?h("ui.chat.composer.secret_confirm_put"):h("ui.chat.composer.secret_confirm_put_multi")}),d.jsx(ve,{type:"button",size:"sm",variant:"secondary",disabled:Gt,onClick:J5,children:h("ui.chat.composer.secret_confirm_send")}),d.jsx(ve,{type:"button",size:"sm",variant:"ghost",disabled:Gt,onClick:ln,children:h("ui.chat.composer.secret_confirm_cancel")})]}),$h>0&&d.jsx("span",{id:Jce,className:"sr-only",children:h("ui.chat.composer_notes.outside_mentions",{count:$h})}),i&&d.jsx("span",{id:tue,className:"sr-only",children:h("ui.chat.composer.delivery_remedies_hint")}),d.jsxs("div",{"data-glass-region":"composer",className:X(Thn,ZG?void 0:Xhn,U?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",jr,ZG&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(re.length>0||$e.length>0)&&d.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[re.length>0&&d.jsx(XN,{replies:re,onRemoveReply:H4e}),$e.length>0&&d.jsx(rKe,{attachments:$e,onRemoveAttachment:G4e,disabled:Re||Se||Ue,byteSizes:Oe})]}),d.jsxs("div",{className:"relative isolate w-full",children:[d.jsx(Gun,{text:Xe,payloads:Rn.current,capture:Ni,held:vs(Xe,Ni),fieldRef:Dt,mirrorRef:qg,isSmallView:U}),d.jsx(odn,{text:Xe,spans:ri.spans,resolved:ri.resolved,fieldRef:Dt,isSmallView:U}),d.jsx(Rdn,{draft:Xe,runs:Hb,textareaRef:Dt,fieldClassName:H_(U),refused:Re,children:d.jsx("textarea",{ref:Dt,"data-region-entry":!0,className:X(H_(U),"block",U?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",H5?"text-transparent caret-ink":"text-ink","outline-none placeholder:text-ink-dim",o?.blocksInput?"read-only:text-ink-muted read-only:placeholder:text-ink-muted disabled:text-ink-disabled disabled:placeholder:text-ink-disabled":"read-only:text-ink-disabled read-only:placeholder:text-ink-disabled disabled:text-ink-disabled disabled:placeholder:text-ink-disabled"),placeholder:Se?h(Ps.recording):UFe({unavailable:D,secretAnswer:ue,inputDisabled:Re,awaitingAnswer:r,asideAttached:nt!==null,sendingUnsettled:Ki||Xu,awaitingReply:n,stopping:Q?.stopping===!0,noProvider:R,idle:Ce,hostLine:o?.placeholder??null}),value:Xe,onCompositionStart:()=>Eg(!0),onCompositionEnd:()=>Eg(!1),onChange:M=>{il.current=!0;const he=M.target.value,Ee=M.target.selectionStart??he.length;ic.current=null;const Be=iEt(Pr.current,Xe,he,Ee,"typing");Be.buffer!==he?(ii.current=Be.caret,Pi(Be.caret)):Pi(Ee),Be.capture!==Pr.current&&ro(Be.capture),!Xe&&Be.buffer&&y?.(),rc.current=Be.buffer,zg(Be.capture,Be.buffer),Ln(Be.buffer),Date.now()-zn.current>=whn&&S?.onDismiss?.()},onSelect:M=>{const he=M.target,Ee=ii.current;if(Ee!==null){he.selectionStart===Ee&&(ii.current=null);return}Pi(he.selectionStart),ro(fp(Pr.current,Xe,he.selectionStart,"caret"))},onKeyDown:E4e,onPointerDown:()=>{mA=!0},onPaste:Z4e,rows:1,readOnly:Re,"aria-disabled":Re||void 0,"aria-label":h("ui.chat.composer.message"),role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Xe.trim().length>0?eue:null,u2?Fce:null,VG?Bce:null,l&&Ie===null?Hce:null,$h>0?Jce:null,D?pke:null,i?tue:null].filter(Boolean).join(" ")||void 0,"aria-expanded":lt.open||Eo.open,"aria-controls":lt.open?lt.listId:Eo.open?Eo.listId:void 0,"aria-activedescendant":(lt.open?lt.activeDescendantId:Eo.activeDescendantId)??void 0})}),d.jsx(Wun,{small:U,text:Xe,payloads:Rn.current,capture:Ni,mirrorRef:qg,fieldRef:Dt,onClear:Re?null:C4e,onControlUnmounted:ll})]}),(Se||We&&MG)&&d.jsx(_pe,{isRecording:Se,preparingLabel:!Se&&We?U?h("ui.chat.composer.starting"):h("ui.chat.composer.starting_recording"):null,sendsNow:Ur.role==="send-recording"&&Ur.enabled}),Ue&&d.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[d.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:h("ui.chat.composer.processing_audio")}),Zt==="idle"&&d.jsx(k4e,{})]}),L?.settingsIntents&&d.jsx(aun,{...L.settingsIntents,restoreFocus:()=>Dt.current?.focus()}),Ae!==null&&!Ue&&Wt!==null&&d.jsxs("div",{"data-dictation-retry":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[d.jsx(nu,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),d.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:Ae}),d.jsx(ve,{type:"button",variant:"link",size:"sm",className:"h-7 shrink-0 px-2 underline",onClick:N4e,children:h("ui.common.actions.retry")})]}),d.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[L&&d.jsx(SI,{fallback:null,children:d.jsx(HJe,{frontend:L.frontend,onCommand:L.onCommand,effortEntities:L.effortEntities,draft:L.draft,onOpenDraftPicker:L.onOpenDraftPicker,draftResolution:L.draftResolution,held:L.held,contextHeld:L.contextHeld,readingsDropped:L.readingsDropped,pendingModel:L.pendingModel,pendingEffort:L.settingsIntents?Gp(L.settingsIntents.slots).effort:null,pendingModelQueued:L.settingsIntents?.slots?.model?.state==="queued_next_step",costChannels:L.costChannels,controlsThirdBox:z4e})}),d.jsxs("div",{className:"contents",children:[d.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[d.jsx($t,{content:h("ui.chat.composer.attach_file"),children:d.jsx("span",{children:d.jsx(ve,{variant:"ghost",size:U?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:l2,onClick:I4e,"aria-label":h("ui.chat.composer.attach_file"),"data-tour-tag":"chat-input-attach-file-button",disabled:Re||Se||Ue,children:d.jsx(J9e,{"aria-hidden":"true"})})})}),ct!==void 0&&d.jsx(zdn,{ref:EG,currentWorkingDirectory:ct,writePath:A,pending:I,pendingAccepted:C,readOnlyReason:A?void 0:G??ZRe()})]}),d.jsxs("div",{"data-lo-composer-controls":!0,onFocus:()=>{nw.current=!0},onBlur:M=>{M.target.isConnected&&(nw.current=!1)},className:"ms-auto flex order-3 shrink-0 items-center gap-1",children:[h2==="confirm"&&d.jsx($t,{content:h("ui.chat.composer.insert_transcript_hint"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"c",variant:"outline",size:U?"icon-sm":"icon",type:"button",className:X("border-success-border bg-success-wash text-success hover:bg-success-wash",aEe&&"opacity-72"),onClick:M=>{iEe(M.detail)||a2()},"aria-label":h("ui.chat.composer.insert_transcript"),children:d.jsx(Ai,{"aria-hidden":"true"})})})},"confirm"),(bh==="mic"||bh==="mic-preparing")&&MG&&d.jsx($t,{content:d.jsx(mun,{text:We?h("ui.chat.composer.starting_recording"):Dr?(()=>{const M=N8t(B4e,OA()?.label??null);return M===null?h("ui.chat.composer.start_recording"):h("ui.chat.composer.start_recording_hint",{shortcut:M7e(M.shortcut),pushToTalk:M.pushToTalk})})():Vr}),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"a",variant:"ghost",size:U?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:l2,onClick:WG,"aria-label":h("ui.chat.composer.start_recording"),"aria-busy":We||void 0,disabled:Re||!Dr,children:We?d.jsx(ti,{size:"sm"}):d.jsx(j9e,{"aria-hidden":"true"})})})},"mic"),bh==="spinner"&&d.jsx(ve,{"data-composer-slot":"a",variant:"ghost",size:U?"icon-sm":"icon",type:"button",className:"text-ink-dim","aria-busy":!0,"aria-disabled":!0,"aria-label":h("ui.chat.composer.processing_audio"),onClick:M=>M.preventDefault(),children:d.jsx(ti,{size:"sm"})},"spinner"),bh==="cancel"&&d.jsx($t,{content:h("ui.chat.composer.cancel_recording_hint"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"a",variant:"outline",size:U?"icon-sm":"icon",type:"button",className:X("text-danger hover:bg-danger-wash hover:text-danger focus-visible:bg-danger-wash",rEe&&"opacity-72"),onClick:M=>{nEe(M.detail)||o2()},"aria-label":h("ui.chat.composer.cancel_recording"),children:d.jsx(Zr,{"aria-hidden":"true"})})})},"cancel"),(Ur.role==="send-recording"||Ur.role==="send-recording-busy")&&d.jsx($t,{content:h("ui.chat.composer.send_recording_hint"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"b",variant:"primary",size:U?"icon-sm":"icon",type:"button",className:X("rounded-full disabled:bg-surface",(Ur.role==="send-recording-busy"||FG)&&"opacity-72"),"aria-busy":Ur.role==="send-recording-busy"||void 0,"aria-disabled":Ur.role==="send-recording-busy"||void 0,onPointerDown:IG,onClick:M=>{Ur.role!=="send-recording-busy"&&(LG(M.detail)||W4e())},disabled:!Ur.enabled&&Ur.role!=="send-recording-busy","aria-label":nt!==null&&!r?h("ui.chat.composer.ask_aside"):h("ui.chat.composer.send_recording"),children:d.jsx($S,{"aria-hidden":"true"})})})},"send-recording"),Ur.role==="connecting"&&d.jsx(ve,{"data-composer-slot":"b",variant:"secondary",size:U?"icon-sm":"icon",type:"button",className:"rounded-full","aria-busy":!0,"aria-disabled":!0,"aria-label":h("ui.chat.composer.placeholder.sending"),onClick:M=>M.preventDefault(),children:d.jsx(ti,{size:"sm"})},"connecting"),(Ur.role==="stop"||Ur.role==="stop-busy")&&Q&&d.jsx($t,{content:h("ui.chat.composer.stop_work_hint"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"b",variant:"danger",size:U?"icon-sm":"icon",type:"button",onClick:M=>{Ur.role!=="stop-busy"&&(LG(M.detail)||Q.onStop())},"aria-label":h("ui.chat.composer.stop"),"aria-keyshortcuts":"Escape","data-stopping":Q.stopping===!0?"true":void 0,"aria-busy":Q.stopping===!0?!0:void 0,className:X("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]",FG&&"opacity-72"),children:d.jsx(V3,{"aria-hidden":"true"})})})},"stop"),t&&m&&d.jsx($t,{content:h("ui.chat.composer.stop_agent"),children:d.jsx("span",{children:d.jsx(ve,{variant:"danger",size:U?"icon-sm":"icon",type:"button",onClick:()=>g?.(m),"aria-label":h("ui.chat.composer.stop_agent"),children:d.jsx(V3,{"aria-hidden":"true"})})})}),(Ur.role==="send"||Ur.role==="steer")&&!(t&&m)&&d.jsx($t,{content:nt!==null&&!r?h("ui.chat.composer.ask_aside"):Ur.role==="steer"?h("ui.chat.composer.steer_hint"):h("ui.chat.composer.send_message"),children:d.jsx("span",{children:d.jsx(ve,{"data-composer-slot":"b",variant:"primary",size:U?"icon-sm":"icon",type:"submit",onPointerDown:IG,disabled:!Ur.enabled,className:"rounded-full disabled:bg-surface","aria-label":nt!==null&&!r?h("ui.chat.composer.ask_aside"):h("ui.chat.composer.send_message"),children:d.jsx($S,{"aria-hidden":"true"})})})},Ur.role)]})]})]})]})]}),R&&!tc?d.jsx("div",{className:X("mt-2",jr),children:d.jsx($On,{})}):null,(R||E)&&Cn?d.jsx("div",{className:X("mt-2",jr),children:d.jsx("output",{className:"block text-body-sm text-ink-muted",children:E?h("ui.chat.composer_notes.hint.choose_model"):h("ui.chat.composer_notes.hint.connect_provider")})}):null]});return d.jsxs("div",{className:X(Hhe,"flex w-full flex-col items-center",ki?"grow":"shrink-0","transition-none",Z?void 0:mHe,U?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:V5,onDragOver:D4e,onDragLeave:V4e,onDrop:M4e,children:[d.jsx("div",{"data-lo-composer-splash":"",className:X("flex w-full flex-col items-center justify-center",ki?"grow":null,"transition-none"),children:d.jsx("div",{ref:Yb,className:X(Mb?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:Mb?d.jsxs(d.Fragment,{children:[d.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:d.jsx(ghn,{className:"size-8",tone:"ink-muted"})}),R?null:d.jsx("h2",{className:"text-center text-ink text-title",children:h("ui.chat.composer.welcome")}),R?d.jsx("div",{className:X("w-full",jr),children:d.jsx(gOn,{})}):d.jsxs("div",{className:X("flex flex-col gap-3",jr),children:[d.jsx(Udn,{band:Nb,splash:M5,foot:vg,suggestions:yg,disabled:A4e,onRefusedPress:l2,onSelect:F4e,focusComposer:()=>Dt.current?.focus()}),d.jsx(Aun,{suspended:Xe.trim().length>0,mentionsEnabled:ne})]})]}):null})}),tc?d.jsx("div",{className:X("mb-2 mt-2",jr),children:d.jsx(mOn,{selection:D5})}):null,d.jsx("div",{ref:bg,"data-lo-composer-foot":"",className:"w-full",children:sEe})]})});function oue(e){e.style.height="auto",e.style.height=`${Math.ceil(e.scrollHeight)}px`,e.style.overflowY=e.scrollHeight<=e.clientHeight+1?"hidden":""}const Ehn=$.memo(Rhn);Ehn.displayName="MessageInput";const TG=1024,aS=1024*1024,Z5=.85,qhn=new Set(["image/png","image/jpeg","image/webp"]),jhn=[{maxEdge:TG,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function Chn(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function zhn(e){const t=Uint8Array.fromBase64;if(typeof t=="function")return t.call(Uint8Array,e);const n=atob(e),r=new Uint8Array(n.length);for(let i=0;i<n.length;i+=1)r[i]=n.charCodeAt(i);return r}function sue(e){const t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";const r=32768;for(let i=0;i<e.length;i+=r)n+=String.fromCharCode(...e.subarray(i,i+r));return btoa(n)}async function Ahn(e,t,n,r,i,a=!1){const o=Math.max(e.width,e.height),s=o>r?r/o:1,l=Math.max(1,Math.round(e.width*s)),c=Math.max(1,Math.round(e.height*s)),u=new OffscreenCanvas(l,c),O=u.getContext("2d");if(!O)return null;O.drawImage(e,0,0,l,c);const f=[],p=await u.convertToBlob({type:"image/png"}),m=new Uint8Array(await p.arrayBuffer());if(m.byteLength<=aS&&f.push({bytes:m,mime_type:"image/png"}),m.byteLength>aS||i<Z5){const v=new OffscreenCanvas(l,c),b=v.getContext("2d");if(!b)return null;b.fillStyle="#ffffff",b.fillRect(0,0,l,c),b.drawImage(e,0,0,l,c);const x=await v.convertToBlob({type:"image/jpeg",quality:i}),Q=new Uint8Array(await x.arrayBuffer());f.push({bytes:Q,mime_type:"image/jpeg"}),m.byteLength>aS&&Q.byteLength>m.byteLength&&f.push({bytes:m,mime_type:"image/png"})}let g=null,y=Number.POSITIVE_INFINITY;for(const v of f)v.bytes.byteLength<y&&(g=v,y=v.bytes.byteLength);return g?a&&s<1?{data_b64:sue(g.bytes),mime_type:g.mime_type}:y>=n?t:{data_b64:sue(g.bytes),mime_type:g.mime_type,...t.origin_path?{origin_path:t.origin_path}:{}}:null}async function vbn(e,t=TG,n=Z5,r={}){const i=await T4e(e);if(!i)return e;try{return await X4e(e,i,t,n,r.edgeIsHard??!1)}finally{i.close()}}async function T4e(e){if(!qhn.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([zhn(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function X4e(e,t,n,r,i=!1){const a=Chn(e.data_b64);try{return Math.max(t.width,t.height)<=n&&a<=aS&&r>=Z5?e:await Ahn(t,e,a,n,r,i)??e}catch{return e}}async function Uhn(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>T4e(i)));try{return await Whn(e,r,t,n)}finally{for(const i of r)i?.close()}}async function Whn(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,f)=>{const p=t[f];return p?X4e(O,p,c,u):Promise.resolve(O)})),a=await i(TG,Z5);if(r(a)<=n)return a;let o=e,s=r(e);const l=c=>{const u=r(c);return u<s&&(o=c,s=u),u};l(a);for(const c of jhn){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const lue=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,Nhn=/^file:\/\//,cue={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"},q3=e=>e.replace(Nhn,"");async function bbn(e,t,n){const r=[],i=[],a=[],o=e.filter(u=>{if(lue.test(u))return!1;const O=u.split(".").pop()?.toLowerCase()??"";return!cue[O]}),s=Math.max(0,o.length-U3),l=s===0;for(const u of e){const O=lue.exec(u);if(O){r.push({data_b64:O[3],mime_type:O[1]});continue}const f=u.split(".").pop()?.toLowerCase()??"",p=cue[f];if(p){if(!window.api?.readFile){a.push({name:tf(u),kind:"read"});continue}const x=await window.api.readFile(q3(u),"base64");x.success?r.push({data_b64:x.data,mime_type:p,...u.startsWith("data:")?{}:{origin_path:q3(u)}}):a.push({name:tf(u),kind:"read"});continue}const m=tf(u);if(n?.remoteOwned){a.push({name:m,kind:"remote"});continue}if(!l)continue;const g=window.api?.uploadAttachment;if(!g){a.push({name:m,kind:"upload",detail:h("ui.chat.attachment_refusal.cannot_upload")});continue}const y=u.startsWith("data:")?{kind:"dataUrl",dataUrl:u,name:m}:{kind:"path",path:q3(u),name:m},v=await g(y);if(!v.success){a.push({name:m,kind:"upload",detail:v.error});continue}const b=v.attachment;i.push({digest:b.digest,name:b.name??m,mime_type:b.mime_type,bytes:b.bytes,...b.path?{path:b.path}:{}})}const c=Math.max(0,r.length-W3);return{images:await Uhn(r.slice(0,W3),ik,u=>y7(t,u)),files:i.slice(0,U3),failures:a,overflow:c,fileOverflow:s}}const Yhn=/\.+$/,uue=e=>typeof e=="string"?tf(e):e.name,Ghn=e=>e?.trim().replace(Yhn,"")??"",Ihn=e=>h("ui.chat.attachment_refusal.clause.read",{name:e}),Zhn=(e,t)=>{const n=Ghn(t);return n?h("ui.chat.attachment_refusal.clause.upload_reason",{name:e,reason:n}):h("ui.chat.attachment_refusal.clause.upload",{name:e})},Dhn=e=>h("ui.chat.attachment_refusal.clause.remote",{name:e});function wbn(e){if(e.length===0)return null;const t=e.map(uue),n=e.length>0&&e.every(a=>typeof a!="string"&&a.kind==="remote");if(e.every(a=>typeof a=="string"||a.kind==="read"))return t.length===1?h("ui.chat.attachment_refusal.read_one",{name:t[0]??""}):h("ui.chat.attachment_refusal.read_many",{names:Vs(t)});if(n)return t.length===1?h("ui.chat.attachment_refusal.remote_one",{name:t[0]??""}):h("ui.chat.attachment_refusal.remote_many",{names:Vs(t)});const i=e.map(a=>typeof a=="string"||a.kind==="read"?Ihn(uue(a)):a.kind==="remote"?Dhn(a.name):Zhn(a.name,a.detail));return h(t.length===1?"ui.chat.attachment_refusal.mixed_one":"ui.chat.attachment_refusal.mixed_many",{clauses:mue(i)})}function xbn(e){if(e<=0)return null;const t=W3,n=t+e;return e===1?h("ui.chat.attachment_refusal.images_one",{total:n,cap:t}):h("ui.chat.attachment_refusal.images_many",{total:n,cap:t,dropped:e})}function Sbn(e){if(e<=0)return null;const t=U3,n=t+e;return e===1?h("ui.chat.attachment_refusal.files_one",{total:n,cap:t}):h("ui.chat.attachment_refusal.files_many",{total:n,cap:t,dropped:e})}function Qbn(){const[e,t]=$.useState(null),[n,r]=$.useState(null),i=$.useRef(null),a=$.useCallback(async o=>{i.current=o,t(s=>s&&s.id!==o?null:s),r(s=>s&&s.id!==o?null:s);try{const s=await Te({op:"sessions.get",sessionId:o});if(i.current!==o)return;t({id:o,frontend:s.payload.frontend.snapshot})}catch{}try{const s=await Te({op:"commands.entities",sessionId:o,command:"effort"});if(i.current!==o)return;r({id:o,entities:s.entities})}catch{}},[]);return{frontend:e?.frontend??null,effortEntities:n?.entities,refresh:a}}function _bn(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function kbn(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function Pbn(e,t){return e==="pause"?{text:h("ui.notices.aida.paused_receipt"),kind:"success"}:e==="resume"?{text:h("ui.notices.aida.resumed_receipt"),kind:"success"}:{kind:"info",text:t.paused?h("ui.notices.aida.paused"):h("ui.notices.aida.active")}}function Vhn(e){return To(e,h("ui.notices.aida.unreachable"))}const Tbn="The chief of staff is switched off on this install.",Mhn="aida_no_provider",Lhn="aida_disabled";function Xbn(e,t){const n=e instanceof vn?e.code:void 0;return n===Lhn?null:n===Mhn?{kind:"info",text:h("ui.notices.aida.account_required",{name:t})}:{kind:"error",text:h("ui.notices.aida.open_fallback",{name:t,detail:Vhn(e)})}}function Rbn(e,t){if(e.held===!0)return`${t} is already open in another window, so she will say hello there.`;const n=e.greeting_state==="delivered"||e.greeting_state==="skipped"||e.greeting_state==null&&e.greeted===!0;return e.paused&&!n?`${t} is paused, so she will say hello when you resume her: type /aida resume.`:null}function Ebn(e){const t=e?.greeting_state;return t==null||t==="owed"}function Fhn(e){return e.eventKey===e.storeKey&&!e.focused}let Oue=!1;function qbn(){if(Oue)return;Oue=!0;const e=Fn.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{Fhn({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&(s7e(),Fn.persist?.rehydrate?.()?.catch?.(()=>{}))};window.addEventListener("storage",t)}export{eWe as $,iP as A,Ob as B,Df as C,Ar as D,Ot as E,_r as F,Ir as G,os as H,oW as I,ma as J,Mn as K,Xn as L,tr as M,GU as N,ps as O,m8 as P,upn as Q,Xpn as R,Mpn as S,Jpn as T,s8 as U,Bpn as V,yWe as W,mWe as X,Vpn as Y,dWe as Z,Cpn as _,lr as a,dun as a$,qpn as a0,jpn as a1,Rpn as a2,Upn as a3,Wpn as a4,Npn as a5,Lpn as a6,tLe as a7,zc as a8,Dpn as a9,dpn as aA,rpn as aB,fpn as aC,Mp as aD,wY as aE,CY as aF,svn as aG,vc as aH,cr as aI,JKe as aJ,dy as aK,lvn as aL,Qbn as aM,oY as aN,N8 as aO,x7 as aP,Iv as aQ,IO as aR,uFe as aS,Tbn as aT,bbn as aU,wbn as aV,xbn as aW,Sbn as aX,Nmn as aY,qit as aZ,Nd as a_,HI as aa,Zpn as ab,Ls as ac,_o as ad,fde as ae,oWe as af,Epn as ag,nWe as ah,Ipn as ai,Jn as aj,zpn as ak,KMe as al,Ypn as am,sWe as an,lWe as ao,PO as ap,Kpn as aq,t7 as ar,FMe as as,JMe as at,eLe as au,e7 as av,$mn as aw,Hpn as ax,Apn as ay,pk as az,el as b,VMe as b$,Mm as b0,Wd as b1,Ehn as b2,yNe as b3,nmn as b4,Qjt as b5,apn as b6,spn as b7,qbn as b8,Kmn as b9,B2e as bA,Bvn as bB,gFt as bC,toe as bD,eoe as bE,hTe as bF,BY as bG,h5 as bH,aLt as bI,iLt as bJ,km as bK,rLt as bL,nLt as bM,f_ as bN,zb as bO,LY as bP,VY as bQ,Md as bR,d_ as bS,L6e as bT,Yv as bU,Kh as bV,h8e as bW,Hke as bX,U2 as bY,APe as bZ,AI as b_,Bmn as ba,_jt as bb,Pjt as bc,opn as bd,SFe as be,hS as bf,XAe as bg,W6e as bh,dk as bi,u$n as bj,Cs as bk,Ud as bl,pFe as bm,zi as bn,Fl as bo,I9e as bp,kOe as bq,ryn as br,iyn as bs,gS as bt,Zd as bu,Ma as bv,$Mt as bw,zY as bx,M2e as by,jb as bz,M5e as c,ly as c$,B6e as c0,A6e as c1,Jin as c2,fBe as c3,Ize as c4,YI as c5,l$ as c6,yOe as c7,Phe as c8,jr as c9,lUe as cA,Ppn as cB,aOe as cC,kee as cD,t6e as cE,s$ as cF,x_e as cG,E9e as cH,Vp as cI,VA as cJ,DA as cK,Nv as cL,ey as cM,CAe as cN,Y9e as cO,o9e as cP,fk as cQ,oPe as cR,xke as cS,dvn as cT,t4 as cU,IN as cV,n4 as cW,Dp as cX,qOe as cY,EOe as cZ,QOe as c_,mHe as ca,Hhe as cb,V3 as cc,cgn as cd,Qpn as ce,_pn as cf,Spn as cg,VUe as ch,Tpn as ci,zUe as cj,lY as ck,mOe as cl,dx as cm,lgn as cn,D8 as co,dBe as cp,Ahe as cq,ogn as cr,sgn as cs,wAe as ct,xe as cu,ppn as cv,X9e as cw,hUe as cx,JA as cy,Wmn as cz,Ivn as d,Kd as d$,cs as d0,SOe as d1,mD as d2,Mmn as d3,Lmn as d4,Vx as d5,W3t as d6,RN as d7,J_e as d8,Z3t as d9,OA as dA,N8t as dB,M7e as dC,rKe as dD,j9e as dE,J9e as dF,j3t as dG,m$n as dH,b$n as dI,p$n as dJ,v$n as dK,f$n as dL,cee as dM,h8t as dN,ES as dO,WI as dP,zHe as dQ,DO as dR,CHe as dS,K8 as dT,Pqt as dU,ty as dV,Zv as dW,du as dX,FOe as dY,ny as dZ,Hd as d_,qi as da,Nf as db,I$n as dc,w7 as dd,Oy as de,H$n as df,V$n as dg,Gee as dh,C6e as di,Qun as dj,vbn as dk,Z5 as dl,TG as dm,KA as dn,K8e as dp,mk as dq,R8e as dr,WOe as ds,hun as dt,MRe as du,Qce as dv,ZFe as dw,TWe as dx,xhe as dy,lun as dz,Mvn as e,khe as e$,yS as e0,Ife as e1,_k as e2,jfe as e3,t7t as e4,eyn as e5,B$n as e6,K$n as e7,A3t as e8,tke as e9,P$n as eA,x$n as eB,rz as eC,O$n as eD,iz as eE,q$n as eF,S$n as eG,X$n as eH,G$n as eI,g$n as eJ,Y$n as eK,U$n as eL,C$n as eM,W$n as eN,vzt as eO,E$n as eP,L_e as eQ,T$n as eR,Od as eS,Rmn as eT,aFe as eU,Ac as eV,Kin as eW,R5 as eX,E5 as eY,btn as eZ,T5 as e_,N3t as ea,D$n as eb,A$n as ec,Vy as ed,d$n as ee,nz as ef,ZP as eg,C3t as eh,h$n as ei,q3t as ej,vOe as ek,$Fe as el,F$n as em,J$n as en,tf as eo,MPe as ep,Qyn as eq,qmn as er,N$n as es,Y3t as et,k$n as eu,M$n as ev,U3t as ew,L$n as ex,Z$n as ey,j$n as ez,Zvn as f,dz as f$,ipn as f0,F8t as f1,B8t as f2,fz as f3,NLe as f4,UOe as f5,PFe as f6,VPe as f7,f5e as f8,$3t as f9,Uyn as fA,Zi as fB,Cyn as fC,DPe as fD,Wyn as fE,I8t as fF,Kyn as fG,Myn as fH,Lyn as fI,Byn as fJ,Fyn as fK,Y8t as fL,G8t as fM,Gyn as fN,i8 as fO,Z8t as fP,Zyn as fQ,Ayn as fR,zyn as fS,Nyn as fT,Iyn as fU,Dyn as fV,She as fW,Fmn as fX,dzt as fY,mzt as fZ,Syn as f_,GO as fa,kN as fb,Iy as fc,dAt as fd,fAt as fe,$Pe as ff,Bx as fg,m6e as fh,IP as fi,lNt as fj,qz as fk,cfn as fl,lbn as fm,_c as fn,cbn as fo,Ofn as fp,v5e as fq,POe as fr,yN as fs,Lcn as ft,Ou as fu,Vyn as fv,lze as fw,J7t as fx,Hyn as fy,Yyn as fz,Fvn as g,QFe as g$,Lee as g0,mun as g1,Lan as g2,ji as g3,fc as g4,Dmn as g5,hWt as g6,Rd as g7,fUt as g8,o$n as g9,bIt as gA,vIt as gB,yIt as gC,$It as gD,a5 as gE,nIt as gF,tIt as gG,gIt as gH,mIt as gI,w8e as gJ,I6e as gK,In as gL,oA as gM,SVe as gN,RVe as gO,dZe as gP,cy as gQ,wVe as gR,ahe as gS,OOe as gT,uOe as gU,Ymn as gV,Gmn as gW,g8e as gX,Imn as gY,Zmn as gZ,sUe as g_,R_e as ga,E_e as gb,s$n as gc,i$n as gd,LJ as ge,l$n as gf,q_e as gg,Sjt as gh,a$n as gi,C_e as gj,VAe as gk,lpn as gl,sbn as gm,_Fe as gn,RFe as go,Ovn as gp,cf as gq,n2e as gr,BQ as gs,l_ as gt,uoe as gu,XMt as gv,lv as gw,xIt as gx,SIt as gy,wIt as gz,_re as h,wet as h$,MLe as h0,Hmn as h1,lYe as h2,cYe as h3,Pa as h4,XWe as h5,ry as h6,NNe as h7,hk as h8,HNe as h9,o4 as hA,Ygn as hB,Ez as hC,sNt as hD,iNt as hE,Ggn as hF,gf as hG,Y6t as hH,F6t as hI,Yet as hJ,Dgn as hK,dNt as hL,nze as hM,Zp as hN,Zgn as hO,Y0 as hP,sY as hQ,Vte as hR,hAe as hS,Xgn as hT,Kpe as hU,Jgn as hV,Hgn as hW,Qet as hX,CS as hY,z7 as hZ,vet as h_,Mde as ha,Dy as hb,BNe as hc,emn as hd,fmn as he,dmn as hf,O8 as hg,r0n as hh,hvn as hi,fvn as hj,Fet as hk,Bgn as hl,Lgn as hm,Fgn as hn,t0n as ho,n0n as hp,ket as hq,jgn as hr,Egn as hs,b3t as ht,Agn as hu,zgn as hv,Ugn as hw,Wgn as hx,Ngn as hy,Pgn as hz,Dvn as i,bgn as i$,R6e as i0,Tgn as i1,Hpe as i2,Cgn as i3,uUe as i4,gx as i5,i0n as i6,F9e as i7,JJe as i8,u0n as i9,hyn as iA,pyn as iB,Oyn as iC,dyn as iD,gCt as iE,u8 as iF,RWe as iG,V6e as iH,ghn as iI,r9e as iJ,NAe as iK,ROe as iL,q6e as iM,QKe as iN,PKe as iO,XKe as iP,$gn as iQ,ygn as iR,vgn as iS,IKe as iT,Qgn as iU,wgn as iV,AKe as iW,kpe as iX,_gn as iY,Kze as iZ,NKe as i_,qgn as ia,Kgn as ib,Vgn as ic,Zet as id,e0n as ie,Tet as ig,Mgn as ih,mNt as ii,U7 as ij,Cet as ik,byn as il,wyn as im,XRe as io,qyn as ip,vWt as iq,mCt as ir,tyn as is,Y6e as it,nyn as iu,cyn as iv,fyn as iw,oyn as ix,ayn as iy,uyn as iz,Lvn as j,nQ as j$,LKe as j0,kgn as j1,xgn as j2,kKe as j3,Yn as j4,Sgn as j5,SAe as j6,rmn as j7,iy as j8,fNt as j9,vde as jA,ZWe as jB,qge as jC,kit as jD,Eit as jE,IS as jF,rP as jG,Pt as jH,W0n as jI,Le as jJ,_$e as jK,Xlt as jL,CO as jM,Tlt as jN,Vn as jO,eo as jP,mt as jQ,Xl as jR,Vt as jS,Zf as jT,Li as jU,ng as jV,xr as jW,_n as jX,Ri as jY,Fc as jZ,Vw as j_,K8t as ja,Mk as jb,g0n as jc,d0n as jd,_it as je,hat as jf,O0n as jg,CU as jh,zU as ji,jU as jj,Age as jk,ZS as jl,qU as jm,jge as jn,m0n as jo,J0n as jp,r$n as jq,Eqt as jr,bLe as js,yLe as jt,xmn as ju,kmn as jv,wmn as jw,_mn as jx,Smn as jy,Qmn as jz,av as k,bk as k$,tP as k0,FO as k1,R0n as k2,xi as k3,QL as k4,yo as k5,Rc as k6,i0e as k7,On as k8,Wn as k9,F8 as kA,s9t as kB,tb as kC,qk as kD,l9t as kE,Bp as kF,c$n as kG,K0n as kH,YP as kI,nb as kJ,Qke as kK,bpe as kL,Ek as kM,Xqt as kN,Rqt as kO,QHe as kP,qQe as kQ,mN as kR,k7 as kS,_pe as kT,k4e as kU,$S as kV,Ntt as kW,k8e as kX,P8e as kY,S_e as kZ,f0n as k_,yf as ka,es as kb,w0n as kc,X0n as kd,xu as ke,Z0n as kf,A0n as kg,iut as kh,E0n as ki,q0n as kj,Q0n as kk,U0n as kl,x0n as km,S0n as kn,z0n as ko,N0n as kp,Y0n as kq,I0n as kr,D0n as ks,P0n as kt,T0n as ku,_0n as kv,Kk as kw,k0n as kx,vpe as ky,EQe as kz,O_ as l,ypn as l$,dfe as l0,ET as l1,ont as l2,ant as l3,Ofe as l4,mmn as l5,Gfe as l6,$a as l7,MO as l8,Jv as l9,mbn as lA,mp as lB,wvn as lC,Yvn as lD,qp as lE,Gvn as lF,mfn as lG,eze as lH,$he as lI,xpn as lJ,nde as lK,UD as lL,z6t as lM,tfe as lN,pmn as lO,myn as lP,SNt as lQ,vpn as lR,pbn as lS,pUe as lT,gbn as lU,gyn as lV,$yn as lW,Q5e as lX,bvn as lY,gpn as lZ,Bze as l_,o0n as la,jYe as lb,vnt as lc,DVe as ld,PS as le,S8 as lf,f7 as lg,Yfe as lh,FYe as li,TYe as lj,IYe as lk,KZ as ll,cDe as lm,h9e as ln,TOe as lo,fbn as lp,X3 as lq,m4e as lr,hbn as ls,dbn as lt,dfn as lu,ubn as lv,Obn as lw,JLe as lx,iun as ly,A$ as lz,Vvn as m,phe as m$,pfn as m0,$bn as m1,$pn as m2,mpn as m3,bpn as m4,xUe as m5,hfn as m6,Pyn as m7,n$n as m8,e$n as m9,kyn as mA,qYt as mB,A5e as mC,R2 as mD,Lm as mE,syn as mF,lyn as mG,ign as mH,agn as mI,OBe as mJ,XFe as mK,nvn as mL,rvn as mM,ivn as mN,$Ae as mO,dUe as mP,xyn as mQ,hgn as mR,CUe as mS,Kzt as mT,Fv as mU,Pmn as mV,ghe as mW,imn as mX,GWe as mY,amn as mZ,uWe as m_,o9t as ma,Qqt as mb,CP as mc,Tyn as md,v9t as me,nte as mf,b9t as mg,h0n as mh,jqt as mi,Nze as mj,_yn as mk,t$n as ml,Xyn as mm,Ryn as mn,aPe as mo,g3t as mp,IOe as mq,k2 as mr,PRt as ms,L8 as mt,DQ as mu,Xf as mv,Pke as mw,p0n as mx,Lze as my,zdn as mz,K5e as n,jde as n$,SUe as n0,EWe as n1,CKe as n2,Gke as n3,obn as n4,mgn as n5,pHe as n6,bhe as n7,CLe as n8,wLe as n9,dHe as nA,fHe as nB,pgn as nC,Rgn as nD,Ign as nE,$Nt as nF,Kvn as nG,ybn as nH,kWe as nI,yyn as nJ,jUe as nK,cY as nL,yvn as nM,$vn as nN,vvn as nO,mvn as nP,pvn as nQ,tbn as nR,omn as nS,Ade as nT,Nde as nU,$8 as nV,Ude as nW,Wde as nX,Omn as nY,umn as nZ,yk as n_,ymn as na,vmn as nb,bmn as nc,nLe as nd,Cmn as ne,qAt as nf,bPe as ng,qcn as nh,ZRe as ni,Hvn as nj,sh as nk,_bn as nl,Pbn as nm,Vhn as nn,kbn as no,Jvn as np,VRe as nq,ugn as nr,fgn as ns,Ogn as nt,dgn as nu,Umn as nv,q5e as nw,C6t as nx,eun as ny,wNe as nz,pIt as o,Ebn as o$,pNe as o0,cmn as o1,c8 as o2,smn as o3,lmn as o4,abn as o5,vyn as o6,ebn as o7,R$n as o8,TUe as o9,_vn as oA,Uvn as oB,Wvn as oC,kvn as oD,Nvn as oE,wUt as oF,Iun as oG,qvn as oH,jvn as oI,RUt as oJ,Svn as oK,YNt as oL,xvn as oM,Qvn as oN,UNt as oO,Tvn as oP,zvn as oQ,Cvn as oR,HP as oS,Evn as oT,Rvn as oU,Xvn as oV,Pvn as oW,FA as oX,JRe as oY,P5e as oZ,v7 as o_,w$n as oa,y$n as ob,$$n as oc,EN as od,z3t as oe,Q$n as of,_$n as og,Vmn as oh,Jx as oi,H9e as oj,wO as ok,Xmn as ol,_Le as om,Tmn as on,lFe as oo,uYe as op,SUt as oq,t5e as or,Avn as os,Jyn as ot,tvn as ou,a5e as ov,hu as ow,evn as ox,_he as oy,xUt as oz,vm as p,Rbn as p0,Xbn as p1,sun as p2,LRe as p3,jyn as p4,j8t as p5,FRe as p6,rbn as p7,avn as p8,DUt as p9,X8t as pA,npn as pB,zmn as pC,K6e as pD,gvn as pE,hmn as pF,kpn as pG,tmn as pH,DFe as pI,Amn as pJ,Km as pK,a0n as pL,_Ue as pM,Eyn as pN,JUt as pO,tgn as pP,Jmn as pQ,egn as pR,Lg as pS,ngn as pT,hpn as pU,Tjt as pV,lx as pW,rgn as pX,cpn as pY,ggn as pZ,c0n as p_,q8t as pa,ibn as pb,Qz as pc,GPe as pd,s5e as pe,ovn as pf,nbn as pg,UPe as ph,WPe as pi,U8t as pj,OWt as pk,O5e as pl,u5e as pm,V7e as pn,Tte as po,cvn as pp,uvn as pq,LLe as pr,FLe as ps,Emn as pt,wpn as pu,PUe as pv,Fpn as pw,Gpn as px,jmn as py,z$n as pz,wl as q,Zc as r,FQ as s,i5 as t,jn as u,P as v,bY as w,Tn as x,gr as y,bn as z};
|