local-operator-ui 0.34.55 → 0.34.56
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 +1 -1
- package/out/renderer/assets/{_basePickBy-Be_5LfVS.js → _basePickBy-BZpmSLU-.js} +1 -1
- package/out/renderer/assets/{_baseUniq-hdy9kmQQ.js → _baseUniq-5Fk4AsiY.js} +1 -1
- package/out/renderer/assets/{agent-details-page-CLbcLEwm.js → agent-details-page-BEoctGwH.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-Bf5Aw-Jn.js → agent-hub-page-DVtEYZne.js} +1 -1
- package/out/renderer/assets/{agents-page-BpaQBOFJ.js → agents-page-CqlFD0Ps.js} +3 -3
- package/out/renderer/assets/{arc-CgN-UZqL.js → arc-Cgq0RekE.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DowMu2Qf.js → architectureDiagram-IEHRJDOE-SKpw5bNL.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-DgKTIFqt.js → blockDiagram-JOT3LUYC-jQv0ffHr.js} +1 -1
- package/out/renderer/assets/{book-open-yKrSTgbR.js → book-open--60aKTv6.js} +1 -1
- package/out/renderer/assets/browser-page-jc3r193W.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-CJ6FJJMN.js → browser-webauthn-prompt-PeVRs-qh.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-Ctyv3nA_.js → c4Diagram-VJAJSXHY-BlRyRK9C.js} +1 -1
- package/out/renderer/assets/channel-BpN7da5J.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-CW43fWPt.js → chunk-4BMEZGHF-BBVAaHlr.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-BfdEIIIg.js → chunk-A2AXSNBT-sJR5i1wN.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-Bx4nZ-57.js → chunk-AEK57VVT-C8IWMgPw.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-BA6hwejS.js → chunk-D6G4REZN-DTfUS03C.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-Civ6_Z-P.js → chunk-RZ5BOZE2-DiGk8o7V.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-BVPRrS8K.js → chunk-XZIHB7SX-Mamouuqj.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-IcRW-YOl.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-IcRW-YOl.js +1 -0
- package/out/renderer/assets/clone-Dri7yO5y.js +1 -0
- package/out/renderer/assets/{console-mirror-D12eLWy7.js → console-mirror-Ch4jKiRK.js} +1 -1
- package/out/renderer/assets/{consoleCapture-B5s47GGM.js → consoleCapture-BYlfSgpd.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-oIWpPfzj.js → conversation-input-sync-Cs9wr7F7.js} +4 -4
- package/out/renderer/assets/{dagre-OKDRZEBW-CayNWWG3.js → dagre-OKDRZEBW-D5TY-UFL.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-CNrEYtm4.js → diagram-SSKATNLV-BTiHJkCz.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-jzZ7n3uT.js → diagram-VNBRO52H-CBxLprav.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-9BaZ6ZkV.js → erDiagram-Q7BY3M3F-9aF5V3AY.js} +1 -1
- package/out/renderer/assets/{error-boundary-BfL6ia-P.js → error-boundary-B5YLbOOu.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CptBIl13.js → flowDiagram-4HSFHLVR-BXlN8K06.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CgcFEyO7.js → ganttDiagram-APWFNJXF-1FcF-Cau.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-cmMetjXL.js → gitGraphDiagram-7IBYFJ6S-CjCM20j_.js} +1 -1
- package/out/renderer/assets/{graph-R1Ok41yA.js → graph-CGuSrplO.js} +1 -1
- package/out/renderer/assets/{index-BFzgup69.js → index-5brl9P13.js} +1 -1
- package/out/renderer/assets/{index-pufheB69.css → index-BUuvY2SU.css} +1 -1
- package/out/renderer/assets/{index-Dsm4DzII.js → index-CalJ1cZq.js} +1 -1
- package/out/renderer/assets/{index-CsR1USrT.js → index-DbzmFwlT.js} +1 -1
- package/out/renderer/assets/{index-CNvEPxPr.js → index-rnB6EiBX.js} +3 -3
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-DeSmG1nL.js → infoDiagram-PH2N3AL5-Bqs15-nE.js} +1 -1
- package/out/renderer/assets/{installer-BM-QRi7Y.js → installer-DZXz4Bgj.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I--ZNfC2qt.js → journeyDiagram-U35MCT3I-BkSqHNi1.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-kUi3-HdL.js → kanban-definition-NDS4AKOZ-CGnCYoin.js} +1 -1
- package/out/renderer/assets/{layout-DQq3NfPk.js → layout-BM7AzCJ1.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-D0vembfV.js → legacy-agents-page-B8f2tJOf.js} +1 -1
- package/out/renderer/assets/{mermaid.core-kSHzKq9G.js → mermaid.core-C14g_ZP7.js} +5 -5
- package/out/renderer/assets/{mesh-page-BhfRHXQS.js → mesh-page-DCCummN5.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BsJiNdkz.js → mindmap-definition-ALO5MXBD-D7Z-SM4X.js} +1 -1
- package/out/renderer/assets/{mini-DngBC0gl.js → mini-CcJI0pQs.js} +1 -1
- package/out/renderer/assets/{notebook-pen-BbGvgaYT.js → notebook-pen-Dj0km82T.js} +1 -1
- package/out/renderer/assets/{org-access-DVLt_Z75.js → org-access-D0eAQUWQ.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-J1G29FUu.js → org-surface-gate-Bgznt94a.js} +1 -1
- package/out/renderer/assets/{page-header-BSVtXSul.js → page-header-B3mzM2nC.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-D9NPKlbA.js → pieDiagram-IB7DONF6-3pVvYdop.js} +1 -1
- package/out/renderer/assets/{projects-page-CV3ap9Ch.js → projects-page-T2Yw-kRf.js} +1 -1
- package/out/renderer/assets/{publication-validation-CXXK8RMX.js → publication-validation-BIJPIOf1.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-Dp6sSgy_.js → quadrantDiagram-7GDLP6J5-Dttg4cdR.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-BdYaxH9C.js → radar-MK3ICKWK-Bd7wnpF5.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-2gyRX5Xg.js → radient-auth-buttons-MPoHRsQX.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CSxZpxDc.js → requirementDiagram-KVF5MWMF-Jiaz4ehK.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DNfJtnGS.js → sankeyDiagram-QLVOVGJD-C4tMl9ww.js} +1 -1
- package/out/renderer/assets/{schedules-page-BMY6s4UJ.js → schedules-page-CR7bLqQt.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-wP1VuU8h.js → sequenceDiagram-X6HHIX6F-DncET3lE.js} +1 -1
- package/out/renderer/assets/{settings-page-CVUD4U35.js → settings-page-B_D-wGm4.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-BRguDCdq.js → stateDiagram-DGXRK772-BI1ziKRV.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-Bqeb-TkR.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-Sovor235.js → timeline-definition-BDJGKUSR-DxR2rlJV.js} +1 -1
- package/out/renderer/assets/{ui-preferences-store-g6-xQ9NA.js → ui-preferences-store-D1IJShox.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-CKVzPGPY.js → use-download-agent-mutation-C6TvAwyM.js} +1 -1
- package/out/renderer/assets/{use-memberships-query-BgAi_tHu.js → use-memberships-query-AlVCuF9E.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-Ba7FspxL.js → use-session-snapshot-XM0bTxHC.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BBlbpFBv.js → xychartDiagram-VJFVF3MP-CJW_dOUR.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +1 -1
- package/out/renderer/assets/browser-page-CKyYrwF0.js +0 -1
- package/out/renderer/assets/channel-DaruqAQQ.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-D8vhGZVf.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-D8vhGZVf.js +0 -1
- package/out/renderer/assets/clone-HcmO38Fx.js +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CqO4MBYu.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 K,j as h,i as Q2e,c as q,g as tr,t as H,B as $se,k as Jy,L as Xd,d as F6,C as rb,h as mn,e as Qq}from"./index-CsR1USrT.js";import{aQ as vp,aR as NQ,aS as yse,aT as vse,aU as f$,A as af,aV as k2e,aW as YQ,aX as P2e,J as bse,aY as B6,aZ as _2e,B as H6,a_ as T2e,a$ as R2e,e as wa,g as oc,R as km,E as wse,C as K6,b0 as ju,b1 as X2e,u as er,b2 as E2e,b3 as q2e,b4 as j2e,b5 as C2e,b6 as pN,b7 as A2e,ax as z2e,aF as U2e,b8 as W2e,aL as N2e,b9 as Y2e,ba as G2e,az as mN,aA as I2e,bb as GQ,bc as bp,bd as Z2e,be as gN,bf as D2e,bg as V2e,bh as Sse,bi as $N,M as xse,bj as Qse,bk as M2e,bl as L2e,bm as F2e,bn as B2e,aN as J6,bo as H2e,D as K2e,r as yN,bp as R_,y as J2e,bq as eRe,x as kse,br as kq}from"./ui-preferences-store-g6-xQ9NA.js";import{ad as tRe,c as Ve,B as Ee,aq as eA,D as tA,a as nA,b as nRe,d as rA,f as rRe,l as Nt,x as H1,y as Pse,T as of,z as Zd,g as $u,X as Ji,u as Pr,ae as Pq,aF as iRe,aG as aRe,aH as oRe,A as Vl,S as bs,p as _se,q as iA,r as aA,s as oA,w as El,m as P0,n as _0,aE as sA,o as wp,aK as sRe,a1 as lRe,a2 as cRe,a3 as uRe,ap as ORe,a0 as IQ,N as dRe,Y as fRe,Z as hRe,_ as pRe,I as io,F as Tse,G as Rse,H as Xse,J as Ese,K as _q,M as mRe,e as Tq,L as qse,C as gRe,k as Qo,P as $Re,Q as yRe,R as vN,U as bN,V as vRe,W as wN,ar as bRe,aL as wRe,h as SRe,t as X_,v as SN,E as xN}from"./error-boundary-BfL6ia-P.js";const xRe="superseded_completion_token",QRe="store_busy",kRe="session_is_remote",PRe="owner_build_behind";function _Re(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function Ed(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function jse(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const Cse=e=>typeof e?.goal_status=="string",Ase=e=>(e?.goal??"").trim().length>0;function TRe(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const T0={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."},QN={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},RRe={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},XRe={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},ERe={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},qRe={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function kN(e){return e?e===T0.notPaired?XRe:e===T0.serverDown?RRe:e===T0.frameBudget?qRe:QN:QN}async function lA(e){if(window.api?.desktop)try{return await jRe(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ut?n:NRe(n)?new tu(yse,vse):new Ut(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new Ut(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Ut(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function jRe(e,t){const n=B6(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=_2e(t.op,n);a(new Ut(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const zse="This server did not answer the request for its desktop controls.";class Ut extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,i,a,o){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=i,this.retryAfterMs=a,this.detail=o}}class tu extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function Wo(e,t){return e instanceof Ut||e instanceof tu?vp(e.code)?NQ[e.code]:e.message:t}function CRe(e,t,n,r){return typeof r=="string"?r:n===f$.noCredential?af.noCredential:n===f$.transportFailed?af.transportFailed:k2e(YQ(e).path,t)}async function Te(e){const t=await lA(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Ut(t.status,r??zse,void 0,CRe(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&ARe(n?.result),n?.result}function ARe(e){if(typeof e!="object"||e===null)return;const t=P2e(e.delegated_cleanup_notice);t&&bse.getState().receive(t)}async function zRe(){try{await Te({op:"delegated_cleanup_notice.ack"})}catch{}}async function Yon(){bse.getState().dismiss(),await zRe()}function Use(e){return e instanceof Ut&&e.code===H6}function URe(e){if(!(e instanceof Ut))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===PRe:e.code===kRe}function WRe(e){return e instanceof tu&&e.code===vse}function NRe(e){return e instanceof Error&&e.message.includes(yse)}async function jn(e){const t=await lA(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function YRe(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Te({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function GRe(e,t){const n=window.api?.desktop?.stream;if(n){const a=n.subscribe(e,t);return()=>a.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),T2e(r,"/__desktop/stream",e.orderIds??[]));const i=new EventSource(`/__desktop/stream?${r}`);return i.onmessage=a=>{t({kind:"data",data:a.data})},i.onerror=()=>{i.readyState===EventSource.CLOSED&&(t({kind:"error",detail:T0.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function SO(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),i=r.headers.get("content-type")??"";if(!r.ok){let a="The media request failed.",o;if(i.includes("application/json"))try{const l=(await r.json())?.detail;if(typeof l=="string")a=l;else if(typeof l=="object"&&l!==null){const c=l;typeof c.text=="string"&&c.text.trim()?a=c.text:typeof c.message=="string"&&c.message.trim()&&(a=c.message),typeof c.code=="string"&&(o=c.code)}}catch{}return{status:r.status,kind:"error",detail:a,code:o!==void 0&&vp(o)?o:a===f$.noCredential?af.noCredential:void 0}}return i.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:i||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function h$(e){return e.kind==="error"?vp(e.code)?new tu(NQ[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const Rq=e=>({revision:Ko(e),demand:e.orderDemand}),Dd=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Sp(e,t,n,r,i,a={}){let o=e;const s=t.journal_generation;if(t.reconcile===!0){const d=typeof s=="string"&&s.length>0?s:void 0;return o.orderNeedsReconcile&&o.orderWantedGeneration===d?o.journalMode?o:{...o,journalMode:!0}:{...o,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:d,orderDemand:d!==void 0?{generation:d}:{}}}if(typeof s!="string"||s.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!o.journalMode?{...o,journalMode:!0}:o;if(r&&t.journal_order_state==="ready"&&i&&o.orderNeedsReconcile&&o.orderDemand===i.demand&&(o={...o,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),s!==o.journalGeneration&&!r)return o.orderNeedsReconcile&&o.orderWantedGeneration===s?o:{...o,orderNeedsReconcile:!0,orderWantedGeneration:s,orderDemand:{generation:s}};let l=o.journalMode?o:{...o,journalMode:!0};if(s!==o.journalGeneration&&(l={...o,journalMode:!0,journalGeneration:s,orderRevision:(o.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:o.orderNeedsReconcile,orderWantedGeneration:o.orderWantedGeneration,orderDemand:o.orderDemand},a.peer===!0)){const d=(o.orderRevision??0)+1,f=new Map;for(const p of o.records){const m=p.sourceEntryId??(p.kind==="tool"||p.kind==="supplement"?null:p.id);typeof m=="string"&&m.length>0&&m.length<=128&&f.set(m,d)}l={...l,...f.size>0?{journalBodyOwed:f}:{},journalSourceVoid:void 0}}let c=l.journalPositions??new Map;const u=c,O=(d,f,p)=>{if(!Dd(p))return;const m=c.get(d);m&&m.seq>=p||(c===u&&(c=new Map(c)),c.set(d,{entryId:f,seq:p}))};for(const[d,f]of Object.entries(t.journal_ordinals??{}))O(d,d,f);for(const d of n)typeof d.id=="string"&&(O(d.id,d.id,d.journal_seq),d.role==="tool"&&typeof d.tool_call_id=="string"&&O(`tool:${d.tool_call_id}`,d.id,d.journal_seq),typeof d.anchor=="string"&&O(`supplement:${d.anchor}`,d.id,d.journal_seq));return c!==u&&(l={...l,journalPositions:c}),l}function cA(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const i=n,a=r;return t.tool_calls.forEach((o,s)=>{!o||typeof o.id!="string"||(n.get(o.id)!==t.id&&(n===i&&(n=new Map(n)),n.set(o.id,t.id)),r.get(o.id)!==s&&(r===a&&(r=new Map(r)),r.set(o.id,s)))}),n===i&&r===a?e:{...e,journalCallOwners:n,journalCallSlots:r}}function Wse(e,t){const n=new Set(e.map(a=>a.id));let r=!1,i;for(let a=0;a<e.length;a++){const o=e[a];if(o.kind==="user"&&o.provisional===!0){i=o;continue}!t(o)&&i&&(o.sourceAdmissionAnchor===void 0||!n.has(o.sourceAdmissionAnchor))&&(e[a]={...o,sourceAdmissionAnchor:i.id},r=!0),i=e[a]}return r}function Nse(e,t,n,r,i){const a=[],o=new Set;let s=e,l;for(;s!==void 0;){if(i.has(s.id)){l=i.get(s.id);break}if(n(s)){l=r(s);break}if(s.kind==="user"&&s.provisional===!0||o.has(s.id))break;o.add(s.id),a.push(s.id),s=s.sourceAdmissionAnchor?t.get(s.sourceAdmissionAnchor):void 0}for(const c of a)i.set(c,l);return l}function Yse(e,t){const n=new Map;return r=>{if(!r)return;const i=t(r);if(i===void 0)return;const a=[],o=new Set;let s=r,l=!0;for(;s;){if(n.has(s.id)){l=n.get(s.id)===!0;break}if(o.has(s.id)||t(s)===void 0){l=!1;break}o.add(s.id),a.push(s.id),s=s.sourceAdmissionAnchor===void 0?void 0:e.get(s.sourceAdmissionAnchor)}for(const c of a)n.set(c,l);return l?i:void 0}}function K1(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const i=new Map;t.forEach((o,s)=>{if(o.kind!=="tool")return;const l=n.get(o.toolCallId);if(l===void 0||!r.has(o.toolCallId))return;const c=i.get(l);c?c.push(s):i.set(l,[s])});let a=t;for(const o of i.values()){if(o.length<2)continue;const s=o.map(l=>t[l]).sort((l,c)=>(r.get(l.toolCallId)??0)-(r.get(c.toolCallId)??0));s.every((l,c)=>l===t[o[c]])||(a===t&&(a=t.slice()),o.forEach((l,c)=>{a[l]=s[c]}))}return a}function Gse(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return IRe(e,t);const n=e.journalGeneration,r=e.journalPositions;let i=!1;const a=t.map(f=>{let m=[r?.get(f.sourceEntryId??f.id),r?.get(f.id)].filter(v=>v!==void 0).sort((v,S)=>S.seq-v.seq)[0];if(f.journalGeneration===n&&Dd(f.journalSeq)&&(!m||f.journalSeq>m.seq)&&(m={entryId:f.sourceEntryId??f.id,seq:f.journalSeq}),!m||!n||!(f.kind==="user"&&(f.provisional===!0||f.local===!0))&&f.sourceEntryId===m.entryId&&f.journalSeq===m.seq&&f.journalGeneration===n)return f;i=!0;let y={...f,sourceEntryId:m.entryId,journalSeq:m.seq,journalGeneration:n};if(y.kind==="user"){const{provisional:v,local:S,...x}=y;y=x}return y});Wse(a,f=>f.journalGeneration===n&&Dd(f.journalSeq))&&(i=!0);const s=new Map,l=new Map(a.map(f=>[f.id,f])),c=Yse(l,f=>f!==void 0&&f.journalGeneration===n&&Dd(f.journalSeq)?f.journalSeq:void 0),u=f=>c(f)!==void 0,O=(f,p)=>{const m=c(f);if(f.kind==="user"&&f.provisional===!0&&m===void 0)return[1,0,0,0,p];const g=f.kind==="supplement"?f.anchor:f.kind==="tool"?e.journalCallOwners?.get(f.toolCallId)??e.argsByCall.get(f.toolCallId)?.anchorId:void 0,y=typeof g=="string"?c(l.get(g)):void 0,v=m===void 0?Nse(f,l,u,c,s):void 0,S=y??m??v;return S===void 0?[1,0,0,0,p]:[0,S,y!==void 0?1:m!==void 0?0:2,m??Number.MAX_SAFE_INTEGER,p]},d=a.map((f,p)=>({record:f,index:p,rank:O(f,p)}));return d.sort((f,p)=>{for(let m=0;m<f.rank.length;m++){const g=f.rank[m]-p.rank[m];if(g)return g}return 0}),!i&&d.every((f,p)=>f.index===p)?K1(e,t):K1(e,d.map(f=>f.record))}function IRe(e,t){const n=e.journalGeneration,r=e.journalPositions,i=new Map;for(const m of t){let y=[r?.get(m.sourceEntryId??m.id),r?.get(m.id)].filter(v=>v!==void 0).sort((v,S)=>S.seq-v.seq)[0];m.journalGeneration===n&&Dd(m.journalSeq)&&(!y||m.journalSeq>y.seq)&&(y={entryId:m.sourceEntryId??m.id,seq:m.journalSeq}),y&&i.set(m.id,y)}const a=m=>m===void 0?void 0:i.get(m.id)??r?.get(m.sourceEntryId??m.id)??r?.get(m.id);let o=!1;const s=t.slice();Wse(s,m=>m.journalGeneration===n&&Dd(m.journalSeq))&&(o=!0);const c=new Map,u=new Map(s.map(m=>[m.id,m])),O=Yse(u,m=>a(m)?.seq),d=m=>O(m)!==void 0,f=(m,g)=>{const y=O(m);if(m.kind==="user"&&m.provisional===!0&&y===void 0)return[1,0,0,0,g];const v=m.kind==="supplement"?m.anchor:m.kind==="tool"?e.journalCallOwners?.get(m.toolCallId)??e.argsByCall.get(m.toolCallId)?.anchorId:void 0,S=typeof v=="string"?O(u.get(v)):void 0,x=y===void 0?Nse(m,u,d,O,c):void 0,b=S??y??x;return b===void 0?[1,0,0,0,g]:[0,b,S!==void 0?1:y!==void 0?0:2,y??Number.MAX_SAFE_INTEGER,g]},p=s.map((m,g)=>({record:m,index:g,rank:f(m,g)}));return p.sort((m,g)=>{for(let y=0;y<m.rank.length;y++){const v=m.rank[y]-g.rank[y];if(v)return v}return 0}),!o&&p.every((m,g)=>m.index===g)?K1(e,t):K1(e,p.map(m=>m.record))}function xl(e){const t=e.records.filter(i=>i.kind==="user"&&i.provisional===!0),n=e.records.filter(i=>i.journalGeneration!==e.journalGeneration||!Dd(i.journalSeq)),r=[...t,...n].map(i=>i.sourceEntryId??(i.kind==="tool"||i.kind==="supplement"?null:i.id));if(r.push(...uA(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let i=r.length-1;i>=0;i--){const a=r[i];typeof a=="string"&&e.journalSourceVoid.has(a)&&r.splice(i,1)}return[...new Set(r.filter(i=>typeof i=="string"&&i.length>0&&i.length<=128))]}function uA(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const i=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof i=="string"&&i.length>0&&i.length<=128&&t.add(i)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Ise(e,t){const n=e.journalPositions;return xl(e).filter(r=>!n?.has(r)&&!t?.has(r))}const Ko=e=>e.orderRevision??0;async function ZRe(e){const t=new Map,n=s=>{let l=t.get(s);return l||(l=new Set,t.set(s,l)),l},r=(s,l)=>l==="payload"?uA(s):l==="lookup"?Ise(s):xl(s);let i=e.getTranscript().journalGeneration,a=0,o=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const s=e.getTranscript(),l=Rq(s),c=l.revision,u=e.sweep?.(s,n);if(u?.kind==="none")return{kind:"complete",transcript:s};const O=u?.kind??"authority",d=R2e(r(s,O).filter(g=>!n(O).has(g)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),f=await e.read(d,O);if(!e.isCurrent()||Ko(e.getTranscript())!==c)return{kind:"stale"};if(e.commit(f,c,l),!e.isCurrent())return{kind:"stale"};const p=e.getTranscript(),m=e.page(f);if(m.journal_order_state==="ready"&&m.journal_generation===p.journalGeneration){m.journal_generation!==i&&(t.clear(),i=m.journal_generation);for(const v of d)n(O).add(v);if(p.orderNeedsReconcile){if(p.orderDemand===l.demand||a===1)return{kind:"waiting"};a++,t.clear();continue}if(O==="payload"){const v=(m.source_retry_ids??[]).filter(S=>typeof S=="string"&&S.length>0&&S.length<=128);if(v.length>0&&d.length>1&&o===0){o++;for(const S of v)n("payload").delete(S);continue}}const g=e.sweep?.(p,n);if(g?.kind==="none")return{kind:"complete",transcript:p};const y=g?.kind??"authority";if(r(p,y).some(v=>!n(y).has(v)))continue;return{kind:"complete",transcript:p}}if(!p.orderNeedsReconcile||p.orderDemand===l.demand||a===1)return{kind:"waiting"};a++,t.clear()}}function Vs(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const i=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof i=="string"&&i?i:e.id}function E_(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function PN(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function Gon(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const a of t){if(!a.settled||typeof a.run_key!="string"||a.run_key.length===0)continue;const o=E_(a.action_count);if(o===null)continue;const s={actions:o,workedSeconds:PN(a.worked_seconds),failed:E_(a.failed_count)??0,complete:a.complete!==!1,openingUserId:typeof a.opening_user_id=="string"&&a.opening_user_id.length>0?a.opening_user_id:null,closingAnswerId:typeof a.closing_answer_id=="string"&&a.closing_answer_id.length>0?a.closing_answer_id:null,crossSessionActions:E_(a.cross_session_action_count),crossSessionWorkedSeconds:PN(a.cross_session_worked_seconds)};n.set(a.run_key,s),s.openingUserId!==null&&n.set(s.openingUserId,s),s.closingAnswerId!==null&&n.set(s.closingAnswerId,s)}if(n.size===0)return null;const r=new Set;for(const a of e.entries)r.add(Vs(a));const i=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:i?Vs(i):null}}}function DRe(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(a=>a.opening_user_id===n.id))return null;const i=Math.round((n.ts??0)*1e3);return i>0?{id:n.id,tsMs:i}:null}function VRe(e,t,n){const r=DRe(e),i=e?.entries;if(r===null||!i||i.length===0)return!1;const a=Math.round((i[i.length-1].ts??0)*1e3);if(!(a>r.tsMs))return!1;for(const[o,s]of t)if(!n.has(o)&&(s===null||!(s>r.tsMs)||!(s<a)))return!1;return!0}const OA=new Set,va="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",No=new RegExp(`[${va}]`),ZQ=new RegExp(`[${va}]+`),MRe=new RegExp(`[${va}]+`,"g"),LRe=new RegExp(`^[${va}]+|[${va}]+$`,"g"),FRe=new RegExp(`^[${va}]+`),BRe=new RegExp(`[^${va}]`);function nn(e){return e.replace(LRe,"")}function nu(e){return e.replace(FRe,"")}function HRe(e,t){return t===0||No.test(e[t-1])}function Zse(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&HRe(e,n)&&t.push(n);return t}function DQ(e,t){let n=t===null||t>e.length?e.length:t;n<0&&(n=0);const r=e.lastIndexOf(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-5brl9P13.js","./index-DbzmFwlT.js","./index-BUuvY2SU.css","./ui-preferences-store-D1IJShox.js","./error-boundary-B5YLbOOu.js","./index-CalJ1cZq.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-C14g_ZP7.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as $,b as K,j as h,i as Q2e,c as q,g as tr,t as H,B as $se,k as Jy,L as Xd,d as F6,C as rb,h as mn,e as Qq}from"./index-DbzmFwlT.js";import{aQ as vp,aR as NQ,aS as yse,aT as vse,aU as f$,A as af,aV as k2e,aW as YQ,aX as P2e,J as bse,aY as B6,aZ as _2e,B as H6,a_ as T2e,a$ as R2e,e as wa,g as oc,R as km,E as wse,C as K6,b0 as ju,b1 as X2e,u as er,b2 as E2e,b3 as q2e,b4 as j2e,b5 as C2e,b6 as pN,b7 as A2e,ax as z2e,aF as U2e,b8 as W2e,aL as N2e,b9 as Y2e,ba as G2e,az as mN,aA as I2e,bb as GQ,bc as bp,bd as Z2e,be as gN,bf as D2e,bg as V2e,bh as Sse,bi as $N,M as xse,bj as Qse,bk as M2e,bl as L2e,bm as F2e,bn as B2e,aN as J6,bo as H2e,D as K2e,r as yN,bp as R_,y as J2e,bq as eRe,x as kse,br as kq}from"./ui-preferences-store-D1IJShox.js";import{ad as tRe,c as Ve,B as Ee,aq as eA,D as tA,a as nA,b as nRe,d as rA,f as rRe,l as Nt,x as H1,y as Pse,T as of,z as Zd,g as $u,X as Ji,u as Pr,ae as Pq,aF as iRe,aG as aRe,aH as oRe,A as Vl,S as bs,p as _se,q as iA,r as aA,s as oA,w as El,m as P0,n as _0,aE as sA,o as wp,aK as sRe,a1 as lRe,a2 as cRe,a3 as uRe,ap as ORe,a0 as IQ,N as dRe,Y as fRe,Z as hRe,_ as pRe,I as io,F as Tse,G as Rse,H as Xse,J as Ese,K as _q,M as mRe,e as Tq,L as qse,C as gRe,k as Qo,P as $Re,Q as yRe,R as vN,U as bN,V as vRe,W as wN,ar as bRe,aL as wRe,h as SRe,t as X_,v as SN,E as xN}from"./error-boundary-B5YLbOOu.js";const xRe="superseded_completion_token",QRe="store_busy",kRe="session_is_remote",PRe="owner_build_behind";function _Re(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function Ed(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function jse(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const Cse=e=>typeof e?.goal_status=="string",Ase=e=>(e?.goal??"").trim().length>0;function TRe(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const T0={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."},QN={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},RRe={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},XRe={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},ERe={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},qRe={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function kN(e){return e?e===T0.notPaired?XRe:e===T0.serverDown?RRe:e===T0.frameBudget?qRe:QN:QN}async function lA(e){if(window.api?.desktop)try{return await jRe(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ut?n:NRe(n)?new tu(yse,vse):new Ut(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new Ut(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Ut(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function jRe(e,t){const n=B6(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=_2e(t.op,n);a(new Ut(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const zse="This server did not answer the request for its desktop controls.";class Ut extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,i,a,o){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=i,this.retryAfterMs=a,this.detail=o}}class tu extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function Wo(e,t){return e instanceof Ut||e instanceof tu?vp(e.code)?NQ[e.code]:e.message:t}function CRe(e,t,n,r){return typeof r=="string"?r:n===f$.noCredential?af.noCredential:n===f$.transportFailed?af.transportFailed:k2e(YQ(e).path,t)}async function Te(e){const t=await lA(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Ut(t.status,r??zse,void 0,CRe(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&ARe(n?.result),n?.result}function ARe(e){if(typeof e!="object"||e===null)return;const t=P2e(e.delegated_cleanup_notice);t&&bse.getState().receive(t)}async function zRe(){try{await Te({op:"delegated_cleanup_notice.ack"})}catch{}}async function Yon(){bse.getState().dismiss(),await zRe()}function Use(e){return e instanceof Ut&&e.code===H6}function URe(e){if(!(e instanceof Ut))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===PRe:e.code===kRe}function WRe(e){return e instanceof tu&&e.code===vse}function NRe(e){return e instanceof Error&&e.message.includes(yse)}async function jn(e){const t=await lA(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function YRe(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Te({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function GRe(e,t){const n=window.api?.desktop?.stream;if(n){const a=n.subscribe(e,t);return()=>a.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),T2e(r,"/__desktop/stream",e.orderIds??[]));const i=new EventSource(`/__desktop/stream?${r}`);return i.onmessage=a=>{t({kind:"data",data:a.data})},i.onerror=()=>{i.readyState===EventSource.CLOSED&&(t({kind:"error",detail:T0.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function SO(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),i=r.headers.get("content-type")??"";if(!r.ok){let a="The media request failed.",o;if(i.includes("application/json"))try{const l=(await r.json())?.detail;if(typeof l=="string")a=l;else if(typeof l=="object"&&l!==null){const c=l;typeof c.text=="string"&&c.text.trim()?a=c.text:typeof c.message=="string"&&c.message.trim()&&(a=c.message),typeof c.code=="string"&&(o=c.code)}}catch{}return{status:r.status,kind:"error",detail:a,code:o!==void 0&&vp(o)?o:a===f$.noCredential?af.noCredential:void 0}}return i.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:i||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function h$(e){return e.kind==="error"?vp(e.code)?new tu(NQ[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const Rq=e=>({revision:Ko(e),demand:e.orderDemand}),Dd=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Sp(e,t,n,r,i,a={}){let o=e;const s=t.journal_generation;if(t.reconcile===!0){const d=typeof s=="string"&&s.length>0?s:void 0;return o.orderNeedsReconcile&&o.orderWantedGeneration===d?o.journalMode?o:{...o,journalMode:!0}:{...o,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:d,orderDemand:d!==void 0?{generation:d}:{}}}if(typeof s!="string"||s.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!o.journalMode?{...o,journalMode:!0}:o;if(r&&t.journal_order_state==="ready"&&i&&o.orderNeedsReconcile&&o.orderDemand===i.demand&&(o={...o,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),s!==o.journalGeneration&&!r)return o.orderNeedsReconcile&&o.orderWantedGeneration===s?o:{...o,orderNeedsReconcile:!0,orderWantedGeneration:s,orderDemand:{generation:s}};let l=o.journalMode?o:{...o,journalMode:!0};if(s!==o.journalGeneration&&(l={...o,journalMode:!0,journalGeneration:s,orderRevision:(o.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:o.orderNeedsReconcile,orderWantedGeneration:o.orderWantedGeneration,orderDemand:o.orderDemand},a.peer===!0)){const d=(o.orderRevision??0)+1,f=new Map;for(const p of o.records){const m=p.sourceEntryId??(p.kind==="tool"||p.kind==="supplement"?null:p.id);typeof m=="string"&&m.length>0&&m.length<=128&&f.set(m,d)}l={...l,...f.size>0?{journalBodyOwed:f}:{},journalSourceVoid:void 0}}let c=l.journalPositions??new Map;const u=c,O=(d,f,p)=>{if(!Dd(p))return;const m=c.get(d);m&&m.seq>=p||(c===u&&(c=new Map(c)),c.set(d,{entryId:f,seq:p}))};for(const[d,f]of Object.entries(t.journal_ordinals??{}))O(d,d,f);for(const d of n)typeof d.id=="string"&&(O(d.id,d.id,d.journal_seq),d.role==="tool"&&typeof d.tool_call_id=="string"&&O(`tool:${d.tool_call_id}`,d.id,d.journal_seq),typeof d.anchor=="string"&&O(`supplement:${d.anchor}`,d.id,d.journal_seq));return c!==u&&(l={...l,journalPositions:c}),l}function cA(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const i=n,a=r;return t.tool_calls.forEach((o,s)=>{!o||typeof o.id!="string"||(n.get(o.id)!==t.id&&(n===i&&(n=new Map(n)),n.set(o.id,t.id)),r.get(o.id)!==s&&(r===a&&(r=new Map(r)),r.set(o.id,s)))}),n===i&&r===a?e:{...e,journalCallOwners:n,journalCallSlots:r}}function Wse(e,t){const n=new Set(e.map(a=>a.id));let r=!1,i;for(let a=0;a<e.length;a++){const o=e[a];if(o.kind==="user"&&o.provisional===!0){i=o;continue}!t(o)&&i&&(o.sourceAdmissionAnchor===void 0||!n.has(o.sourceAdmissionAnchor))&&(e[a]={...o,sourceAdmissionAnchor:i.id},r=!0),i=e[a]}return r}function Nse(e,t,n,r,i){const a=[],o=new Set;let s=e,l;for(;s!==void 0;){if(i.has(s.id)){l=i.get(s.id);break}if(n(s)){l=r(s);break}if(s.kind==="user"&&s.provisional===!0||o.has(s.id))break;o.add(s.id),a.push(s.id),s=s.sourceAdmissionAnchor?t.get(s.sourceAdmissionAnchor):void 0}for(const c of a)i.set(c,l);return l}function Yse(e,t){const n=new Map;return r=>{if(!r)return;const i=t(r);if(i===void 0)return;const a=[],o=new Set;let s=r,l=!0;for(;s;){if(n.has(s.id)){l=n.get(s.id)===!0;break}if(o.has(s.id)||t(s)===void 0){l=!1;break}o.add(s.id),a.push(s.id),s=s.sourceAdmissionAnchor===void 0?void 0:e.get(s.sourceAdmissionAnchor)}for(const c of a)n.set(c,l);return l?i:void 0}}function K1(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const i=new Map;t.forEach((o,s)=>{if(o.kind!=="tool")return;const l=n.get(o.toolCallId);if(l===void 0||!r.has(o.toolCallId))return;const c=i.get(l);c?c.push(s):i.set(l,[s])});let a=t;for(const o of i.values()){if(o.length<2)continue;const s=o.map(l=>t[l]).sort((l,c)=>(r.get(l.toolCallId)??0)-(r.get(c.toolCallId)??0));s.every((l,c)=>l===t[o[c]])||(a===t&&(a=t.slice()),o.forEach((l,c)=>{a[l]=s[c]}))}return a}function Gse(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return IRe(e,t);const n=e.journalGeneration,r=e.journalPositions;let i=!1;const a=t.map(f=>{let m=[r?.get(f.sourceEntryId??f.id),r?.get(f.id)].filter(v=>v!==void 0).sort((v,S)=>S.seq-v.seq)[0];if(f.journalGeneration===n&&Dd(f.journalSeq)&&(!m||f.journalSeq>m.seq)&&(m={entryId:f.sourceEntryId??f.id,seq:f.journalSeq}),!m||!n||!(f.kind==="user"&&(f.provisional===!0||f.local===!0))&&f.sourceEntryId===m.entryId&&f.journalSeq===m.seq&&f.journalGeneration===n)return f;i=!0;let y={...f,sourceEntryId:m.entryId,journalSeq:m.seq,journalGeneration:n};if(y.kind==="user"){const{provisional:v,local:S,...x}=y;y=x}return y});Wse(a,f=>f.journalGeneration===n&&Dd(f.journalSeq))&&(i=!0);const s=new Map,l=new Map(a.map(f=>[f.id,f])),c=Yse(l,f=>f!==void 0&&f.journalGeneration===n&&Dd(f.journalSeq)?f.journalSeq:void 0),u=f=>c(f)!==void 0,O=(f,p)=>{const m=c(f);if(f.kind==="user"&&f.provisional===!0&&m===void 0)return[1,0,0,0,p];const g=f.kind==="supplement"?f.anchor:f.kind==="tool"?e.journalCallOwners?.get(f.toolCallId)??e.argsByCall.get(f.toolCallId)?.anchorId:void 0,y=typeof g=="string"?c(l.get(g)):void 0,v=m===void 0?Nse(f,l,u,c,s):void 0,S=y??m??v;return S===void 0?[1,0,0,0,p]:[0,S,y!==void 0?1:m!==void 0?0:2,m??Number.MAX_SAFE_INTEGER,p]},d=a.map((f,p)=>({record:f,index:p,rank:O(f,p)}));return d.sort((f,p)=>{for(let m=0;m<f.rank.length;m++){const g=f.rank[m]-p.rank[m];if(g)return g}return 0}),!i&&d.every((f,p)=>f.index===p)?K1(e,t):K1(e,d.map(f=>f.record))}function IRe(e,t){const n=e.journalGeneration,r=e.journalPositions,i=new Map;for(const m of t){let y=[r?.get(m.sourceEntryId??m.id),r?.get(m.id)].filter(v=>v!==void 0).sort((v,S)=>S.seq-v.seq)[0];m.journalGeneration===n&&Dd(m.journalSeq)&&(!y||m.journalSeq>y.seq)&&(y={entryId:m.sourceEntryId??m.id,seq:m.journalSeq}),y&&i.set(m.id,y)}const a=m=>m===void 0?void 0:i.get(m.id)??r?.get(m.sourceEntryId??m.id)??r?.get(m.id);let o=!1;const s=t.slice();Wse(s,m=>m.journalGeneration===n&&Dd(m.journalSeq))&&(o=!0);const c=new Map,u=new Map(s.map(m=>[m.id,m])),O=Yse(u,m=>a(m)?.seq),d=m=>O(m)!==void 0,f=(m,g)=>{const y=O(m);if(m.kind==="user"&&m.provisional===!0&&y===void 0)return[1,0,0,0,g];const v=m.kind==="supplement"?m.anchor:m.kind==="tool"?e.journalCallOwners?.get(m.toolCallId)??e.argsByCall.get(m.toolCallId)?.anchorId:void 0,S=typeof v=="string"?O(u.get(v)):void 0,x=y===void 0?Nse(m,u,d,O,c):void 0,b=S??y??x;return b===void 0?[1,0,0,0,g]:[0,b,S!==void 0?1:y!==void 0?0:2,y??Number.MAX_SAFE_INTEGER,g]},p=s.map((m,g)=>({record:m,index:g,rank:f(m,g)}));return p.sort((m,g)=>{for(let y=0;y<m.rank.length;y++){const v=m.rank[y]-g.rank[y];if(v)return v}return 0}),!o&&p.every((m,g)=>m.index===g)?K1(e,t):K1(e,p.map(m=>m.record))}function xl(e){const t=e.records.filter(i=>i.kind==="user"&&i.provisional===!0),n=e.records.filter(i=>i.journalGeneration!==e.journalGeneration||!Dd(i.journalSeq)),r=[...t,...n].map(i=>i.sourceEntryId??(i.kind==="tool"||i.kind==="supplement"?null:i.id));if(r.push(...uA(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let i=r.length-1;i>=0;i--){const a=r[i];typeof a=="string"&&e.journalSourceVoid.has(a)&&r.splice(i,1)}return[...new Set(r.filter(i=>typeof i=="string"&&i.length>0&&i.length<=128))]}function uA(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const i=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof i=="string"&&i.length>0&&i.length<=128&&t.add(i)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Ise(e,t){const n=e.journalPositions;return xl(e).filter(r=>!n?.has(r)&&!t?.has(r))}const Ko=e=>e.orderRevision??0;async function ZRe(e){const t=new Map,n=s=>{let l=t.get(s);return l||(l=new Set,t.set(s,l)),l},r=(s,l)=>l==="payload"?uA(s):l==="lookup"?Ise(s):xl(s);let i=e.getTranscript().journalGeneration,a=0,o=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const s=e.getTranscript(),l=Rq(s),c=l.revision,u=e.sweep?.(s,n);if(u?.kind==="none")return{kind:"complete",transcript:s};const O=u?.kind??"authority",d=R2e(r(s,O).filter(g=>!n(O).has(g)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),f=await e.read(d,O);if(!e.isCurrent()||Ko(e.getTranscript())!==c)return{kind:"stale"};if(e.commit(f,c,l),!e.isCurrent())return{kind:"stale"};const p=e.getTranscript(),m=e.page(f);if(m.journal_order_state==="ready"&&m.journal_generation===p.journalGeneration){m.journal_generation!==i&&(t.clear(),i=m.journal_generation);for(const v of d)n(O).add(v);if(p.orderNeedsReconcile){if(p.orderDemand===l.demand||a===1)return{kind:"waiting"};a++,t.clear();continue}if(O==="payload"){const v=(m.source_retry_ids??[]).filter(S=>typeof S=="string"&&S.length>0&&S.length<=128);if(v.length>0&&d.length>1&&o===0){o++;for(const S of v)n("payload").delete(S);continue}}const g=e.sweep?.(p,n);if(g?.kind==="none")return{kind:"complete",transcript:p};const y=g?.kind??"authority";if(r(p,y).some(v=>!n(y).has(v)))continue;return{kind:"complete",transcript:p}}if(!p.orderNeedsReconcile||p.orderDemand===l.demand||a===1)return{kind:"waiting"};a++,t.clear()}}function Vs(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const i=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof i=="string"&&i?i:e.id}function E_(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function PN(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function Gon(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const a of t){if(!a.settled||typeof a.run_key!="string"||a.run_key.length===0)continue;const o=E_(a.action_count);if(o===null)continue;const s={actions:o,workedSeconds:PN(a.worked_seconds),failed:E_(a.failed_count)??0,complete:a.complete!==!1,openingUserId:typeof a.opening_user_id=="string"&&a.opening_user_id.length>0?a.opening_user_id:null,closingAnswerId:typeof a.closing_answer_id=="string"&&a.closing_answer_id.length>0?a.closing_answer_id:null,crossSessionActions:E_(a.cross_session_action_count),crossSessionWorkedSeconds:PN(a.cross_session_worked_seconds)};n.set(a.run_key,s),s.openingUserId!==null&&n.set(s.openingUserId,s),s.closingAnswerId!==null&&n.set(s.closingAnswerId,s)}if(n.size===0)return null;const r=new Set;for(const a of e.entries)r.add(Vs(a));const i=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:i?Vs(i):null}}}function DRe(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(a=>a.opening_user_id===n.id))return null;const i=Math.round((n.ts??0)*1e3);return i>0?{id:n.id,tsMs:i}:null}function VRe(e,t,n){const r=DRe(e),i=e?.entries;if(r===null||!i||i.length===0)return!1;const a=Math.round((i[i.length-1].ts??0)*1e3);if(!(a>r.tsMs))return!1;for(const[o,s]of t)if(!n.has(o)&&(s===null||!(s>r.tsMs)||!(s<a)))return!1;return!0}const OA=new Set,va="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",No=new RegExp(`[${va}]`),ZQ=new RegExp(`[${va}]+`),MRe=new RegExp(`[${va}]+`,"g"),LRe=new RegExp(`^[${va}]+|[${va}]+$`,"g"),FRe=new RegExp(`^[${va}]+`),BRe=new RegExp(`[^${va}]`);function nn(e){return e.replace(LRe,"")}function nu(e){return e.replace(FRe,"")}function HRe(e,t){return t===0||No.test(e[t-1])}function Zse(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&HRe(e,n)&&t.push(n);return t}function DQ(e,t){let n=t===null||t>e.length?e.length:t;n<0&&(n=0);const r=e.lastIndexOf(`
|
|
3
3
|
`,n-1)+1,i=e.indexOf(`
|
|
4
4
|
`,n),a=i===-1?e.length:i;let o=e.slice(r,a);return o.endsWith("\r")&&(o=o.slice(0,-1)),{line:o,lineStart:r,column:n-r}}function KRe(e,t){if(t.size===0)return null;for(const n of Zse(e)){const r=e.slice(n+1),i=r.indexOf(" ");if(i!==-1&&t.has(r.slice(0,i).toLowerCase()))return n}return null}function dA(e,t,n){const r=KRe(e,n);let i=null;for(const a of Zse(e)){if(a===r)return t>a?a:i;a<=t&&(i=a)}return i}function ev(e,t=null,n=OA){const{line:r,lineStart:i,column:a}=DQ(e,t),o=dA(r,a,n);if(o===null)return null;let s=o+1;for(;s<r.length&&!No.test(r[s]);)s++;return a>s?null:{start:i+o,query:r.slice(o+1,s),end:i+s}}function p$(e,t=null,n=OA){const{line:r,lineStart:i,column:a}=DQ(e,t),o=dA(r,a,n);return o===null?null:{start:i+o,end:i+r.length}}function VQ(e,t,n=null,r=OA){const{line:i,lineStart:a,column:o}=DQ(e,n),s=r.size>0?r:new Set(t.map(f=>f.toLowerCase())),l=dA(i,o,s);if(l===null)return null;const c=i.slice(l+1),u=c.indexOf(" ");if(u===-1)return null;const O=c.slice(0,u);if(!t.some(f=>f.toLowerCase()===O.toLowerCase()))return null;const d=l+1+O.length;return o<=d?null:{value:c.slice(u+1),start:a+d+1,end:a+i.length,tokenStart:a+l}}function Xq(e,t){return nn(e.slice(0,t))===""}function JRe(e,t,n,r){const i=VQ(e,r,t,n);if(i!==null&&Xq(e,i.tokenStart))return"argument";const a=ev(e,t,n);return a!==null&&Xq(e,a.start)?"command":null}function gO(e,t,n,r){let i=t,a=n;const o=s=>s>=0&&s<e.length&&`
|
|
5
5
|
`.includes(e[s]);return r===""?i>0&&o(i-1)?i-=1:o(a)&&(a+=1):i===0&&o(a)&&(a+=1),{text:`${e.slice(0,i)}${r}${e.slice(a)}`,caret:i+r.length}}const eXe=/^\$([A-Za-z0-9][A-Za-z0-9._-]*)/,tXe=/<skill name="([^"]*)" invocation="([^"]*)">/;function _N(e,t){const n=nu(e),r=eXe.exec(n);if(!r)return null;const i=r[1];let a=t.includes(i)?i:void 0;if(a===void 0){const s=i.toLowerCase();a=t.find(l=>l.toLowerCase()===s)}if(a===void 0)return null;const o=nn(n.slice(r[0].length));return{name:a,request:o,token:r[0],typed:nn(n)}}function nXe(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\n/g," ")}function rXe(e){return e.replace(/ /g,`
|
|
@@ -823,7 +823,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
823
823
|
`))};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=Ge.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((Ot.mac||Ot.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:Hn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);W9(t,c,Ge.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:mme.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=N$(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||ftt(t.parent)||document,this.viewState=new BD(t.state||Wn.create(t)),t.scrollTo&&t.scrollTo.is(Ab)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ih).map(i=>new OT(i));for(let i of this.plugins)i.update(this);this.observer=new Xnt(this),this.inputState=new ent(this),this.inputState.ensureHandlers(this.plugins),this.docView=new XD(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 Hi?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 d of t){if(d.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=d.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,l=null;t.some(d=>d.annotation(Tme))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Rme(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=zS.create(this,a,t),i.flags|=s;let O=this.viewState.scrollTarget;try{this.updateState=2;for(let d of t){if(O&&(O=O.map(d.changes)),d.scrollIntoView){let{main:f}=d.state.selection;O=new cp(f.empty?f:Ge.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of d.effects)f.is(Ab)&&(O=f.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=WS.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(O0)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Gb)!=i.state.facet(Gb)&&(this.viewState.mustMeasureContent=!0),(n||r||O||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(P3))try{d(i)}catch(f){to(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!Sme(this,u)&&c.force&&lp(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 BD(t),this.plugins=t.facet(Ih).map(r=>new OT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new XD(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(Ih),r=t.state.facet(Ih);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new OT(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){to(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(Zpe(r))a=-1,o=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(i);a=f.from,o=f.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(f=>{try{return f.read(this)}catch(p){return to(this.state,p),eV}}),O=zS.create(this,this.state,[]),d=!1;O.flags|=l,n?n.flags|=l:n=O,this.updateState=2,O.empty||(this.updatePlugins(O),this.inputState.update(O),this.updateAttrs(),d=this.docView.update(O),d&&this.docViewUpdate());for(let f=0;f<c.length;f++)if(u[f]!=eV)try{let p=c[f];p.write&&p.write(u[f],this)}catch(p){to(this.state,p)}if(d&&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 p=(a<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(a).top)-o;if(p>1||p<-1){i=i+p,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(P3))s(n)}get themeClasses(){return E3+" "+(this.state.facet(X3)?jme:qme)+" "+this.state.facet(Gb)}updateAttrs(){let t=tV(this,gme,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(zc)?"true":"false",class:"cm-content",style:`${Ot.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),tV(this,A9,n);let r=this.observer.ignore(()=>{let i=w3(this.contentDOM,this.contentAttrs,n),a=w3(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(O0);let t=this.state.facet(Pt.cspNonce);RO.mount(this.root,this.styleModules.concat(Tnt).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 fT(this,t,AD(this,t,n,r))}moveByGroup(t,n){return fT(this,t,AD(this,t,n,r=>Dtt(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 Ge.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return Ztt(this,t,n,r)}moveVertically(t,n,r){return fT(this,t,Vtt(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(),wme(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[cO.find(a,t-i.from,-1,n)];return vv(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(fme)||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>jnt)return ame(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||ime(a.isolates,r=RD(this,t))))return a.order;r||(r=RD(this,t));let i=_tt(t.text,n,r);return this.bidiCache.push(new WS(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Ot.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Gpe(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 Ab.of(new cp(typeof t=="number"?Ge.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 Ab.of(new cp(Ge.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 Ri.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Ri.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=RO.newName(),i=[Gb.of(r),O0.of(q3(`.${r}`,t))];return n&&n.dark&&i.push(X3.of(!0)),i}static baseTheme(t){return YO.lowest(O0.of(q3("."+E3,t,Cme)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&dr.get(r)||dr.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}Pt.styleModule=O0;Pt.inputHandler=Ome;Pt.clipboardInputFilter=j9;Pt.clipboardOutputFilter=C9;Pt.scrollHandler=pme;Pt.focusChangeEffect=dme;Pt.perLineTextDirection=fme;Pt.exceptionSink=ume;Pt.updateListener=P3;Pt.editable=zc;Pt.mouseSelectionStyle=cme;Pt.dragMovesSelection=lme;Pt.clickAddsSelectionRange=sme;Pt.decorations=Y$;Pt.outerDecorations=$me;Pt.atomicRanges=z9;Pt.bidiIsolatedRanges=yme;Pt.scrollMargins=vme;Pt.darkTheme=X3;Pt.cspNonce=ht.define({combine:e=>e.length?e[0]:""});Pt.contentAttributes=A9;Pt.editorAttributes=gme;Pt.lineWrapping=Pt.contentAttributes.of({class:"cm-lineWrapping"});Pt.announce=Pn.define();const jnt=4096,eV={};class WS{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 WS(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function tV(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&&b3(o,n)}return n}const Cnt=Ot.mac?"mac":Ot.windows?"win":Ot.linux?"linux":"key";function Ant(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 Ib(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 znt=YO.default(Pt.domEventHandlers({keydown(e,t){return zme(Ame(t.state),e,t,"editor")}})),Xk=ht.define({enables:znt}),nV=new WeakMap;function Ame(e){let t=e.facet(Xk),n=nV.get(t);return n||nV.set(t,n=Wnt(t.reduce((r,i)=>r.concat(i),[]))),n}function Ycn(e,t,n){return zme(Ame(e.state),t,e,n)}let tO=null;const Unt=4e3;function Wnt(e,t=Cnt){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,d;let f=n[o]||(n[o]=Object.create(null)),p=s.split(/ (?!$)/).map(y=>Ant(y,t));for(let y=1;y<p.length;y++){let v=p.slice(0,y).join(" ");i(v,!0),f[v]||(f[v]={preventDefault:!0,stopPropagation:!1,run:[S=>{let x=tO={view:S,prefix:v,scope:o};return setTimeout(()=>{tO==x&&(tO=null)},Unt),!0}]})}let m=p.join(" ");i(m,!1);let g=f[m]||(f[m]={preventDefault:!1,stopPropagation:!1,run:((d=(O=f._any)===null||O===void 0?void 0:O.run)===null||d===void 0?void 0:d.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.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 d in u)u[d].run.push(f=>O(f,j3))}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 j3=null;function zme(e,t,n,r){j3=t;let i=ltt(t),a=Po(i,0),o=Ac(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;tO&&tO.view==n&&tO.scope==r&&(s=tO.prefix+" ",Qme.indexOf(t.keyCode)<0&&(c=!0,tO=null));let O=new Set,d=g=>{if(g){for(let y of g.run)if(!O.has(y)&&(O.add(y),y(n)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[s+Ib(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Ot.windows&&t.ctrlKey&&t.altKey)&&(p=XO[t.keyCode])&&p!=i?(d(f[s+Ib(p,t,!0)])||t.shiftKey&&(m=W$[t.keyCode])!=i&&m!=p&&d(f[s+Ib(m,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(f[s+Ib(i,t,!0)])&&(l=!0),!l&&d(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),j3=null,l}class Sv{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=Ume(t);return[new Sv(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return Nnt(t,n,r)}}function Ume(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 rV(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 Nnt(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=Ume(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),d=s.right-(u?parseInt(u.paddingRight):0),f=T3(e,r,1),p=T3(e,i,-1),m=f.type==Na.Text?f:null,g=p.type==Na.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=rV(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=rV(e,i,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(S(n.from,n.to,m));{let b=m?S(n.from,null,m):x(f,!1),w=g?S(null,n.to,g):x(p,!0),Q=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&b.bottom+e.defaultLineHeight/2<w.top?Q.push(y(O,b.bottom,d,w.top)):b.bottom<w.top&&e.elementAtHeight((b.bottom+w.top)/2).type==Na.Text&&(b.bottom=w.top=(b.bottom+w.top)/2),v(b).concat(Q).concat(v(w))}function y(b,w,Q,k){return new Sv(t,b-l.left,w-l.top,Q-b,k-w)}function v({top:b,bottom:w,horizontal:Q}){let k=[];for(let _=0;_<Q.length;_+=2)k.push(y(Q[_],b,Q[_+1],w));return k}function S(b,w,Q){let k=1e9,_=-1e9,R=[];function E(C,W,G,N,V){let F=e.coordsAtPos(C,C==Q.to?-2:2),z=e.coordsAtPos(G,G==Q.from?2:-2);!F||!z||(k=Math.min(F.top,z.top,k),_=Math.max(F.bottom,z.bottom,_),V==Xr.LTR?R.push(a&&W?O:F.left,a&&N?d:z.right):R.push(!a&&N?O:z.left,!a&&W?d:F.right))}let T=b??Q.from,j=w??Q.to;for(let C of e.visibleRanges)if(C.to>T&&C.from<j)for(let W=Math.max(C.from,T),G=Math.min(C.to,j);;){let N=e.state.doc.lineAt(W);for(let V of e.bidiSpans(N)){let F=V.from+N.from,z=V.to+N.from;if(F>=G)break;z>W&&E(Math.max(F,W),b==null&&F<=T,Math.min(z,G),w==null&&z>=j,V.dir)}if(W=N.to+1,W>=G)break}return R.length==0&&E(T,b==null,j,w==null,e.textDirection),{top:k,bottom:_,horizontal:R}}function x(b,w){let Q=s.top+(w?b.top:b.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function Ynt(e,t){return e.constructor==t.constructor&&e.eq(t)}class Gnt{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(b1)!=t.state.facet(b1)&&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(b1);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)=>!Ynt(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 b1=ht.define();function Wme(e){return[Ri.define(t=>new Gnt(t,e)),b1.of(e)]}const G$=ht.define({combine(e){return Am(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function Gcn(e={}){return[G$.of(e),Int,Znt,Dnt,hme.of(!0)]}function Nme(e){return e.startState.facet(G$)!=e.state.facet(G$)}const Int=Wme({above:!0,markers(e){let{state:t}=e,n=t.facet(G$),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:Ge.cursor(i.head,i.head>i.anchor?-1:1);for(let l of Sv.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=Nme(e);return n&&iV(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){iV(t.state,e)},class:"cm-cursorLayer"});function iV(e,t){t.style.animationDuration=e.facet(G$).cursorBlinkRate+"ms"}const Znt=Wme({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:Sv.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Nme(e)},class:"cm-selectionLayer"}),Dnt=YO.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"}}}})),Yme=Pn.define({map(e,t){return e==null?null:t.mapPos(e)}}),h0=lo.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(Yme)?r.value:n,e)}}),Vnt=Ri.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(h0);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(h0)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(h0),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(h0)!=e&&this.view.dispatch({effects:Yme.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 Icn(){return[h0,Vnt]}function aV(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 Mnt(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 Lnt{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 hf,r=n.add.bind(n);for(let{from:i,to:a}of Mnt(t,this.maxLength))aV(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 d=[],f,p=(m,g,y)=>d.push(y.range(m,g));if(l==c)for(this.regexp.lastIndex=u-l.from;(f=this.regexp.exec(l.text))&&f.index<O-l.from;)this.addMatch(f,t,f.index+l.from,p);else aV(t.state.doc,this.regexp,u,O,(m,g)=>this.addMatch(g,t,m,p));n=n.update({filterFrom:u,filterTo:O,filter:(m,g)=>m<u||g>O,add:d})}}return n}}const C3=/x/.unicode!=null?"gu":"g",Fnt=new RegExp(`[\0-\b
|
|
824
824
|
--\u2028\u2029\uFEFF-]`,C3),Bnt={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 mT=null;function Hnt(){var e;if(mT==null&&typeof document<"u"&&document.body){let t=document.body.style;mT=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return mT||!1}const w1=ht.define({combine(e){let t=Am(e,{render:null,specialChars:Fnt,addSpecialChars:null});return(t.replaceTabs=!Hnt())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,C3)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,C3)),t}});function Zcn(e={}){return[w1.of(e),Knt()]}let oV=null;function Knt(){return oV||(oV=Ri.fromClass(class{constructor(e){this.view=e,this.decorations=on.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(w1)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Lnt({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=Po(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=TO(o.text,s,r-o.from);return on.replace({widget:new nrt((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=on.replace({widget:new trt(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(w1);e.startState.facet(w1)!=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 Jnt="•";function ert(e){return e>=32?Jnt:e==10?"":String.fromCharCode(9216+e)}class trt extends Su{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=ert(this.code),r=t.state.phrase("Control character")+" "+(Bnt[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 nrt extends Su{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 Dcn(){return irt}const rrt=on.line({class:"cm-activeLine"}),irt=Ri.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(rrt.range(i.from)),t=i.from)}return on.set(n)}},{decorations:e=>e.decorations});class art extends Su{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?qp(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=vv(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 Vcn(e){let t=Ri.fromClass(class{constructor(n){this.view=n,this.placeholder=e?on.set([on.widget({widget:new art(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 A3=2e3;function ort(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>A3||n.off>A3||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(Ge.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=h3(c.text,o,e.tabSize,!0);if(u<0)a.push(Ge.cursor(c.to));else{let O=h3(c.text,s,e.tabSize);a.push(Ge.range(c.from+u,c.from+O))}}}return a}function srt(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function sV(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>A3?-1:i==r.length?srt(e,t.clientX):TO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function lrt(e,t){let n=sV(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=sV(e,i);if(!s)return r;let l=ort(e.state,n,s);return l.length?o?Ge.create(l.concat(r.ranges)):Ge.create(l):r}}:null}function Mcn(e){let t=n=>n.altKey&&n.button==0;return Pt.mouseSelectionStyle.of((n,r)=>t(r)?lrt(n,r):null)}const crt={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},urt={style:"cursor: crosshair"};function Lcn(e={}){let[t,n]=crt[e.key||"Alt"],r=Ri.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?urt:null})]}const wg="-10000px";class Gme{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 d=this.tooltips[O];d&&d.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 Ort(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const gT=ht.define({combine:e=>{var t,n,r;return{position:Ot.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)||Ort}}}),lV=new WeakMap,G9=Ri.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(gT);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 Gme(e,I9,(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(gT);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=wg,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(Ot.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==wg&&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=U9(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(gT).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],d=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=wg;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=(t=lV.get(c))!==null&&t!==void 0?t:d.bottom-d.top,y=c.offset||frt,v=this.view.textDirection==Xr.LTR,S=d.width>r.right-r.left?v?r.left:r.right-d.width:v?Math.max(r.left,Math.min(O.left-(f?14:0)+y.x,r.right-m)):Math.min(Math.max(r.left,O.left-m+(f?14:0)-y.x),r.right-m),x=this.above[s];!l.strictSide&&(x?O.top-g-p-y.y<r.top:O.bottom+g+p+y.y>r.bottom)&&x==r.bottom-O.bottom>O.top-r.top&&(x=this.above[s]=!x);let b=(x?O.top-r.top:r.bottom-O.bottom)-p;if(b<g&&c.resize!==!1){if(b<this.view.defaultLineHeight){u.style.top=wg;continue}lV.set(c,g),u.style.height=(g=b)/a+"px"}else u.style.height&&(u.style.height="");let w=x?O.top-g-p-y.y:O.bottom+p+y.y,Q=S+m;if(c.overlap!==!0)for(let k of o)k.left<Q&&k.right>S&&k.top<w+g&&k.bottom>w&&(w=x?k.top-g-2-p:k.bottom+p+2);if(this.position=="absolute"?(u.style.top=(w-e.parent.top)/a+"px",cV(u,(S-e.parent.left)/i)):(u.style.top=w/a+"px",cV(u,S/i)),f){let k=O.left+(v?y.x:-y.x)-(S+14-7);f.style.left=k/i+"px"}c.overlap!==!0&&o.push({left:S,top:w,right:Q,bottom:w+g}),u.classList.toggle("cm-tooltip-above",x),u.classList.toggle("cm-tooltip-below",!x),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=wg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function cV(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const drt=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"}}}),frt={x:0,y:0},I9=ht.define({enables:[G9,drt]}),NS=ht.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class Ek{static create(t){return new Ek(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Gme(t,NS,(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 hrt=I9.compute([NS],e=>{let t=e.facet(NS);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:Ek.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class prt{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 lO)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=>to(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(G9),n=t?t.manager.tooltips.findIndex(r=>r.create==Ek.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&&!mrt(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:!grt(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 Zb=4;function mrt(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-Zb&&t.clientX<=r+Zb&&t.clientY>=i-Zb&&t.clientY<=a+Zb}function grt(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 Fcn(e,t={}){let n=Pn.define(),r=lo.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,Bi.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($rt)&&(i=[]);return i},provide:i=>NS.from(i)});return{active:r,extension:[r,Ri.define(i=>new prt(i,e,r,n,t.hoverTime||300)),hrt]}}function Ime(e,t){let n=e.plugin(G9);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const $rt=Pn.define(),uV=ht.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 Bcn(e,t){let n=e.plugin(Zme),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const Zme=Ri.fromClass(class{constructor(e){this.input=e.state.facet(dV),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(uV);this.top=new Db(e,!0,t.topContainer),this.bottom=new Db(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(uV);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Db(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Db(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(dV);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 Db{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=OV(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=OV(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 OV(e){let t=e.nextSibling;return e.remove(),t}const dV=ht.define({enables:Zme});class lu extends ff{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}lu.prototype.elementClass="";lu.prototype.toDOM=void 0;lu.prototype.mapMode=Bi.TrackBefore;lu.prototype.startSide=lu.prototype.endSide=-1;lu.prototype.point=!0;const S1=ht.define(),yrt=ht.define(),vrt={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>kn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Z0=ht.define();function brt(e){return[Dme(),Z0.of({...vrt,...e})]}const fV=ht.define({combine:e=>e.some(t=>t)});function Dme(e){return[wrt]}const wrt=Ri.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(Z0).map(t=>new pV(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(fV),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(fV)!=!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=kn.iter(this.view.state.facet(S1),this.view.viewport.from),r=[],i=this.gutters.map(a=>new Srt(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==Na.Text&&o){z3(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==Na.Text){z3(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(Z0),n=e.state.facet(Z0),r=e.docChanged||e.heightChanged||e.viewportChanged||!kn.eq(e.startState.facet(S1),e.state.facet(S1),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 pV(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 hV(e){return Array.isArray(e)?e:[e]}function z3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Srt{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=kn.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 Vme(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=[];z3(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(yrt)){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 pV{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=hV(n.markers(t)),n.initialSpacer&&(this.spacer=new Vme(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=hV(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!kn.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 Vme{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":""),xrt(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 xrt(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 Qrt=ht.define(),krt=ht.define(),Zh=ht.define({combine(e){return Am(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 $T extends lu{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function yT(e,t){return e.state.facet(Zh).formatNumber(t,e.state)}const Prt=Z0.compute([Zh],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Qrt)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new $T(yT(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(krt)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(Zh)!=t.state.facet(Zh),initialSpacer(t){return new $T(yT(t,mV(t.state.doc.lines)))},updateSpacer(t,n){let r=yT(n.view,mV(n.view.state.doc.lines));return r==t.number?t:new $T(r)},domEventHandlers:e.facet(Zh).domEventHandlers}));function Hcn(e={}){return[Zh.of(e),Dme(),Prt]}function mV(e){let t=9;for(;t<e;)t=t*10+9;return t}const _rt=new class extends lu{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Trt=S1.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(_rt.range(i)))}return kn.of(t)});function Kcn(){return Trt}let Rrt=0;class rt{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=Rrt++}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 rt&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new rt(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 YS(t);return r=>r.modified.indexOf(n)>-1?r:YS.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let Xrt=0;class YS{constructor(t){this.name=t,this.instances=[],this.id=Xrt++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&Ert(n,s.modified));if(r)return r;let i=[],a=new rt(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=qrt(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(YS.get(s,l));return a}}function Ert(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function qrt(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 An(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 d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!d)throw new RangeError("Invalid path: "+i);if(a.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),O+=d[0].length,O==i.length)break;let f=i[O++];if(O==i.length&&f=="!"){o=0;break}if(f!="/")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 GS(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return Mme.add(t)}const Mme=new Yt;let GS=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}};GS.empty=new GS([],2,null);function Lme(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 jrt(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Crt(e,t,n,r=0,i=e.length){let a=new Art(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class Art{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(f=>!f.scope||f.scope(o)));let c=i,u=zrt(t)||GS.empty,O=jrt(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 d=t.tree&&t.tree.prop(Yt.mounted);if(d&&d.overlay){let f=t.node.enter(d.overlay[0].from+s,1),p=this.highlighters.filter(g=>!g.scope||g.scope(d.tree.type)),m=t.firstChild();for(let g=0,y=s;;g++){let v=g<d.overlay.length?d.overlay[g]:null,S=v?v.from+s:l,x=Math.max(n,y),b=Math.min(r,S);if(x<b&&m)for(;t.from<b&&(this.highlightRange(t,x,b,i,a),this.startSpan(Math.min(b,t.to),c),!(t.to>=S||!t.nextSibling())););if(!v||S>r)break;y=v.to+s,y>n&&(this.highlightRange(f.cursor(),Math.max(n,v.from+s),Math.min(r,y),"",p),this.startSpan(Math.min(r,y),c))}m&&t.parent()}else if(t.firstChild()){d&&(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 zrt(e){let t=e.type.prop(Mme);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const tt=rt.define,Vb=tt(),Lu=tt(),gV=tt(Lu),$V=tt(Lu),Fu=tt(),Mb=tt(Fu),vT=tt(Fu),Sl=tt(),ld=tt(Sl),gl=tt(),$l=tt(),U3=tt(),Sg=tt(U3),Lb=tt(),P={comment:Vb,lineComment:tt(Vb),blockComment:tt(Vb),docComment:tt(Vb),name:Lu,variableName:tt(Lu),typeName:gV,tagName:tt(gV),propertyName:$V,attributeName:tt($V),className:tt(Lu),labelName:tt(Lu),namespace:tt(Lu),macroName:tt(Lu),literal:Fu,string:Mb,docString:tt(Mb),character:tt(Mb),attributeValue:tt(Mb),number:vT,integer:tt(vT),float:tt(vT),bool:tt(Fu),regexp:tt(Fu),escape:tt(Fu),color:tt(Fu),url:tt(Fu),keyword:gl,self:tt(gl),null:tt(gl),atom:tt(gl),unit:tt(gl),modifier:tt(gl),operatorKeyword:tt(gl),controlKeyword:tt(gl),definitionKeyword:tt(gl),moduleKeyword:tt(gl),operator:$l,derefOperator:tt($l),arithmeticOperator:tt($l),logicOperator:tt($l),bitwiseOperator:tt($l),compareOperator:tt($l),updateOperator:tt($l),definitionOperator:tt($l),typeOperator:tt($l),controlOperator:tt($l),punctuation:U3,separator:tt(U3),bracket:Sg,angleBracket:tt(Sg),squareBracket:tt(Sg),paren:tt(Sg),brace:tt(Sg),content:Sl,heading:ld,heading1:tt(ld),heading2:tt(ld),heading3:tt(ld),heading4:tt(ld),heading5:tt(ld),heading6:tt(ld),contentSeparator:tt(Sl),list:tt(Sl),quote:tt(Sl),emphasis:tt(Sl),strong:tt(Sl),link:tt(Sl),monospace:tt(Sl),strikethrough:tt(Sl),inserted:tt(),deleted:tt(),changed:tt(),invalid:tt(),meta:Lb,documentMeta:tt(Lb),annotation:tt(Lb),processingInstruction:tt(Lb),definition:rt.defineModifier("definition"),constant:rt.defineModifier("constant"),function:rt.defineModifier("function"),standard:rt.defineModifier("standard"),local:rt.defineModifier("local"),special:rt.defineModifier("special")};for(let e in P){let t=P[e];t instanceof rt&&(t.name=e)}Lme([{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 bT;const uO=new Yt;function qk(e){return ht.define({combine:e?t=>t.concat(e):void 0})}const Z9=new Yt;class qo{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Wn.prototype.hasOwnProperty("tree")||Object.defineProperty(Wn.prototype,"tree",{get(){return Kn(this)}}),this.parser=n,this.extension=[qO.of(this),Wn.languageData.of((a,o,s)=>{let l=yV(a,o,s),c=l.type.prop(uO);if(!c)return[];let u=a.facet(c),O=l.type.prop(Z9);if(O){let d=l.resolve(o-l.from,s);for(let f of O)if(f.test(d,a)){let p=a.facet(f.facet);return f.type=="replace"?p:p.concat(u)}}return u})].concat(r)}isActiveAt(t,n,r=-1){return yV(t,n,r).type.prop(uO)==this.data}findRegions(t){let n=t.facet(qO);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(uO)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(Yt.mounted);if(s){if(s.tree.prop(uO)==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 fn&&i(c,a.positions[l]+o)}};return i(Kn(t),0),r}get allowsNesting(){return!0}}qo.setState=Pn.define();function yV(e,t,n){let r=e.facet(qO),i=Kn(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,Or.ExcludeBuffers))a.type.isTop&&(i=a);return i}class Tn extends qo{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=qk(t.languageData);return new Tn(n,t.parser.configure({props:[uO.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 Kn(e){let t=e.field(qo.state,!1);return t?t.tree:fn.empty}class Urt{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 xg=null;class $f{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 $f(t,n,[],fn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Urt(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=fn.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(Fc.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(Fc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=xg;xg=this;try{return t()}finally{xg=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=vV(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,d)=>l.push({fromA:c,toA:u,fromB:O,toB:d})),r=Fc.applyChanges(r,l),i=fn.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 $f(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=vV(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 Pk{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=xg;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 fn(yi.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 xg}}function vV(e,t,n){return Fc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class zp{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 zp(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=$f.create(t.facet(qO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new zp(r)}}qo.state=lo.define({create:zp.init,update(e,t){for(let n of t.effects)if(n.is(qo.setState))return n.value;return t.startState.facet(qO)!=t.state.facet(qO)?zp.init(t.state):e.apply(t)}});let Fme=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Fme=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const wT=typeof navigator<"u"&&(!((bT=navigator.scheduling)===null||bT===void 0)&&bT.isInputPending)?()=>navigator.scheduling.isInputPending():null,Wrt=Ri.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(qo.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(qo.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Fme(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(qo.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!wT?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>wT&&wT()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:qo.setState.of(new zp(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=>to(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()}}}),qO=ht.define({combine(e){return e.length?e[0]:null},enables:e=>[qo.state,Wrt,Pt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class yn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class $e{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 $e(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 Nrt=ht.define(),jk=ht.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 IS(e){let t=e.facet(jk);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Yrt(e,t){let n="",r=e.tabSize,i=e.facet(jk)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function Grt(e,t){e instanceof Wn&&(e=new Bme(e));for(let r of e.state.facet(Nrt)){let i=r(e,t);if(i!==void 0)return i}let n=Kn(e.state);return n.length>=t?Irt(e,n,t):null}class Bme{constructor(t,n={}){this.state=t,this.options=n,this.unit=IS(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 TO(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 Nr=new Yt;function Irt(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 Hme(r,e,n)}function Hme(e,t,n){for(let r=e;r;r=r.next){let i=Drt(r.node);if(i)return i(D9.create(t,n,r))}return 0}function Zrt(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Drt(e){let t=e.type.prop(Nr);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Yt.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>Kme(o,!0,1,void 0,a&&!Zrt(o)?i.from:void 0)}return e.parent==null?Vrt:null}function Vrt(){return 0}class D9 extends Bme{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 D9(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(Mrt(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Hme(this.context.next,this.base,this.pos)}}function Mrt(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Lrt(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 ys({closing:e,align:t=!0,units:n=1}){return r=>Kme(r,t,n,e)}function Kme(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?Lrt(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const V9=e=>e.baseIndent;function Mr({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const Frt=200;function tun(){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+Frt)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=Grt(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],f=Yrt(o,O);d!=f&&l.push({from:u.from,to:u.from+d.length,insert:f})}return l.length?[e,{changes:l,sequential:!0}]:e})}const Jme=ht.define(),jr=new Yt;function ba(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 Brt(e,t,n){let r=Kn(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(jr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!Hrt(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function Hrt(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function ZS(e,t,n){for(let r of e.facet(Jme)){let i=r(e,t,n);if(i)return i}return Brt(e,t,n)}function ege(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 Ck=Pn.define({map:ege}),xv=Pn.define({map:ege});function tge(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 yf=lo.define({create(){return on.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Ck)&&!Krt(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(ige),i=r?on.replace({widget:new iit(r(t.state,n.value))}):bV;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(xv)&&(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(bV.range(r,i))}return on.set(t,!0)}});function DS(e,t,n){var r;let i=null;return(r=e.field(yf,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function Krt(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function nge(e,t){return e.field(yf,!1)?t:t.concat(Pn.appendConfig.of(age()))}const Jrt=e=>{for(let t of tge(e)){let n=ZS(e.state,t.from,t.to);if(n)return e.dispatch({effects:nge(e.state,[Ck.of(n),rge(e,n)])}),!0}return!1},eit=e=>{if(!e.state.field(yf,!1))return!1;let t=[];for(let n of tge(e)){let r=DS(e.state,n.from,n.to);r&&t.push(xv.of(r),rge(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function rge(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 tit=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=ZS(t,i.from,i.to);a&&n.push(Ck.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:nge(e.state,n)}),!!n.length},nit=e=>{let t=e.state.field(yf,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(xv.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},nun=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Jrt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:eit},{key:"Ctrl-Alt-[",run:tit},{key:"Ctrl-Alt-]",run:nit}],rit={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},ige=ht.define({combine(e){return Am(e,rit)}});function age(e){return[yf,oit]}function oge(e,t){let{state:n}=e,r=n.facet(ige),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=DS(e.state,s.from,s.to);l&&e.dispatch({effects:xv.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 bV=on.replace({widget:new class extends Su{toDOM(e){return oge(e,null)}}});class iit extends Su{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return oge(t,this.value)}}const ait={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ST extends lu{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 run(e={}){let t={...ait,...e},n=new ST(t,!0),r=new ST(t,!1),i=Ri.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(qO)!=o.state.facet(qO)||o.startState.field(yf,!1)!=o.state.field(yf,!1)||Kn(o.startState)!=Kn(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new hf;for(let l of o.viewportLineBlocks){let c=DS(o.state,l.from,l.to)?r:ZS(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,brt({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||kn.empty},initialSpacer(){return new ST(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=DS(o.state,s.from,s.to);if(c)return o.dispatch({effects:xv.of(c)}),!0;let u=ZS(o.state,s.from,s.to);return u?(o.dispatch({effects:Ck.of(u)}),!0):!1}}}),age()]}const oit=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 Ak{constructor(t,n){this.specs=t;let r;function i(s){let l=RO.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 qo?s=>s.prop(uO)==o.data:o?s=>s==o:void 0,this.style=Lme(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new RO(r):null,this.themeType=n.themeType}static define(t,n){return new Ak(t,n||{})}}const W3=ht.define(),sge=ht.define({combine(e){return e.length?[e[0]]:null}});function xT(e){let t=e.facet(W3);return t.length?t:e.facet(sge)}function iun(e,t){let n=[lit],r;return e instanceof Ak&&(e.module&&n.push(Pt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(sge.of(e)):r?n.push(W3.computeN([Pt.darkTheme],i=>i.facet(Pt.darkTheme)==(r=="dark")?[e]:[])):n.push(W3.of(e)),n}class sit{constructor(t){this.markCache=Object.create(null),this.tree=Kn(t.state),this.decorations=this.buildDeco(t,xT(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Kn(t.state),r=xT(t.state),i=r!=xT(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 hf;for(let{from:i,to:a}of t.visibleRanges)Crt(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 lit=YO.high(Ri.fromClass(sit,{decorations:e=>e.decorations})),aun=Ak.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"}]),cit=Pt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),lge=1e4,cge="()[]{}",uge=ht.define({combine(e){return Am(e,{afterCursor:!0,brackets:cge,maxScanDistance:lge,renderMatch:dit})}}),uit=on.mark({class:"cm-matchingBracket"}),Oit=on.mark({class:"cm-nonmatchingBracket"});function dit(e){let t=[],n=e.matched?uit:Oit;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 fit=lo.define({create(){return on.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(uge);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=Fb(t.state,i.head,-1,r)||i.head>0&&Fb(t.state,i.head-1,1,r)||r.afterCursor&&(Fb(t.state,i.head,1,r)||i.head<t.state.doc.length&&Fb(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)}),hit=[fit,cit];function oun(e={}){return[uge.of(e),hit]}const M9=new Yt;function N3(e,t,n){let r=e.prop(t<0?Yt.openedBy:Yt.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 Y3(e){let t=e.type.prop(M9);return t?t(e.node):e}function Fb(e,t,n,r={}){let i=r.maxScanDistance||lge,a=r.brackets||cge,o=Kn(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=N3(l.type,n,a);if(c&&l.from<l.to){let u=Y3(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return pit(e,t,n,l,u,c,a)}}return mit(e,t,n,o,s.type,i,a)}function pit(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=Y3(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(N3(u.type,n,o))c++;else if(N3(u.type,-n,o)){if(c==0){let O=Y3(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 mit(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 d=0;!u.next().done&&d<=a;){let f=u.value;n<0&&(d+=f.length);let p=t+d*n;for(let m=n>0?0:f.length-1,g=n>0?f.length:-1;m!=g;m+=n){let y=o.indexOf(f[m]);if(!(y<0||r.resolveInner(p+m,1).type!=i))if(y%2==0==n>0)O++;else{if(O==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==l>>1};O--}}n>0&&(d+=f.length)}return u.done?{start:c,matched:!1}:null}function wV(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 Oge{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=wV(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:wV(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 git(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||$it,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||F9,mergeTokens:e.mergeTokens!==!1}}function $it(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 SV=new WeakMap;class Ce extends qo{constructor(t){let n=qk(t.languageData),r=git(t),i,a=new class extends Pk{createParse(o,s,l){return new vit(i,o,s,l)}};super(n,a,[],t.name),this.topNode=Sit(n,this),i=this,this.streamParser=r,this.stateAfter=new Yt({perNode:!0}),this.tokenTable=t.tokenTable?new pge(r.tokenTable):wit}static define(t){return new Ce(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=SV.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=L9(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 Oge(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)fge(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&&SV.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function L9(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 fn&&l<i&&L9(e,s,l,r,i);if(c)return c}return null}function dge(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 fn){if(!(l=dge(e,s,n-o,r-o,i)))break;return i?new fn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function yit(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&&L9(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=dge(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?IS(i):4),tree:fn.empty}}let vit=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=$f.get(),o=i[0].from,{state:s,tree:l}=yit(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(IS(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=$f.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==`
|
|
825
825
|
`&&(n="");else{let r=n.indexOf(`
|
|
826
|
-
`);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 Oge(n,t?t.state.tabSize:4,t?IS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=fge(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=fn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:bit,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new fn(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 fn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function fge(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 F9=Object.create(null),I$=[yi.none],bit=new Cm(I$),xV=[],QV=Object.create(null),hge=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"]])hge[e]=mge(F9,t);class pge{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),hge)}resolve(t){return t?this.table[t]||(this.table[t]=mge(this.extra,t)):0}}const wit=new pge(F9);function QT(e,t){xV.indexOf(e)>-1||(xV.push(e),console.warn(t))}function mge(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):QT(c,`Modifier ${c} used at start of tag`):l.length?QT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:QT(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=QV[i];if(a)return a.id;let o=QV[i]=yi.define({id:I$.length,name:r,props:[An({[r]:n})]});return I$.push(o),o.id}function Sit(e,t){let n=yi.define({id:I$.length,name:"Document",props:[uO.add(()=>e),Nr.add(()=>r=>t.getIndent(r))],top:!0});return I$.push(n),n}Xr.RTL,Xr.LTR;function Pe(e){return new yn(Ce.define(e))}function Uu(e){return ve(()=>Promise.resolve().then(()=>Mft),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const xit=[$e.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>mL),void 0,import.meta.url).then(e=>e.cpp())}}),$e.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ve(()=>Promise.resolve().then(()=>mL),void 0,import.meta.url).then(e=>e.cpp())}}),$e.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Uu("Cassandra")}}),$e.of({name:"CSS",extensions:["css"],load(){return ve(()=>Promise.resolve().then(()=>lst),void 0,import.meta.url).then(e=>e.css())}}),$e.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-BFzgup69.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),$e.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ve(()=>Promise.resolve().then(()=>Jst),void 0,import.meta.url).then(e=>e.html())}}),$e.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>Hft),void 0,import.meta.url).then(e=>e.java())}}),$e.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ve(()=>Promise.resolve().then(()=>Jb),void 0,import.meta.url).then(e=>e.javascript())}}),$e.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ve(()=>Promise.resolve().then(()=>ict),void 0,import.meta.url).then(e=>e.json())}}),$e.of({name:"JSX",extensions:["jsx"],load(){return ve(()=>Promise.resolve().then(()=>Jb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),$e.of({name:"LESS",extensions:["less"],load(){return ve(()=>Promise.resolve().then(()=>vlt),void 0,import.meta.url).then(e=>e.less())}}),$e.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>Amt),void 0,import.meta.url).then(e=>e.liquid())}}),$e.of({name:"MariaDB SQL",load(){return Uu("MariaSQL")}}),$e.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ve(()=>Promise.resolve().then(()=>clt),void 0,import.meta.url).then(e=>e.markdown())}}),$e.of({name:"MS SQL",load(){return Uu("MSSQL")}}),$e.of({name:"MySQL",load(){return Uu("MySQL")}}),$e.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ve(()=>Promise.resolve().then(()=>fmt),void 0,import.meta.url).then(e=>e.php())}}),$e.of({name:"PLSQL",extensions:["pls"],load(){return Uu("PLSQL")}}),$e.of({name:"PostgreSQL",load(){return Uu("PostgreSQL")}}),$e.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ve(()=>Promise.resolve().then(()=>Adt),void 0,import.meta.url).then(e=>e.python())}}),$e.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>ght),void 0,import.meta.url).then(e=>e.rust())}}),$e.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>XM),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),$e.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>XM),void 0,import.meta.url).then(e=>e.sass())}}),$e.of({name:"SQL",extensions:["sql"],load(){return Uu("StandardSQL")}}),$e.of({name:"SQLite",load(){return Uu("SQLite")}}),$e.of({name:"TSX",extensions:["tsx"],load(){return ve(()=>Promise.resolve().then(()=>Jb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),$e.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ve(()=>Promise.resolve().then(()=>Jb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),$e.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ve(()=>Promise.resolve().then(()=>Wmt),void 0,import.meta.url).then(e=>e.wast())}}),$e.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ve(()=>Promise.resolve().then(()=>ift),void 0,import.meta.url).then(e=>e.xml())}}),$e.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-Dsm4DzII.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),$e.of({name:"APL",extensions:["dyalog","apl"],load(){return ve(()=>Promise.resolve().then(()=>h$t),void 0,import.meta.url).then(e=>Pe(e.apl))}}),$e.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ve(()=>Promise.resolve().then(()=>p$t),void 0,import.meta.url).then(e=>Pe(e.asciiArmor))}}),$e.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ve(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Pe(e.asn1({})))}}),$e.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>v$t),void 0,import.meta.url).then(e=>Pe(e.asterisk))}}),$e.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>w$t),void 0,import.meta.url).then(e=>Pe(e.brainfuck))}}),$e.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>B$t),void 0,import.meta.url).then(e=>Pe(e.cobol))}}),$e.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.csharp))}}),$e.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Pe(e.clojure))}}),$e.of({name:"ClojureScript",extensions:["cljs"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Pe(e.clojure))}}),$e.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ve(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Pe(e.gss))}}),$e.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ve(()=>Promise.resolve().then(()=>Y$t),void 0,import.meta.url).then(e=>Pe(e.cmake))}}),$e.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ve(()=>Promise.resolve().then(()=>cyt),void 0,import.meta.url).then(e=>Pe(e.coffeeScript))}}),$e.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ve(()=>Promise.resolve().then(()=>pyt),void 0,import.meta.url).then(e=>Pe(e.commonLisp))}}),$e.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>qyt),void 0,import.meta.url).then(e=>Pe(e.cypher))}}),$e.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ve(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Pe(e.cython))}}),$e.of({name:"Crystal",extensions:["cr"],load(){return ve(()=>Promise.resolve().then(()=>Pyt),void 0,import.meta.url).then(e=>Pe(e.crystal))}}),$e.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>Nyt),void 0,import.meta.url).then(e=>Pe(e.d))}}),$e.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.dart))}}),$e.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>Yyt),void 0,import.meta.url).then(e=>Pe(e.diff))}}),$e.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>evt),void 0,import.meta.url).then(e=>Pe(e.dockerFile))}}),$e.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>rvt),void 0,import.meta.url).then(e=>Pe(e.dtd))}}),$e.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>lvt),void 0,import.meta.url).then(e=>Pe(e.dylan))}}),$e.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>cvt),void 0,import.meta.url).then(e=>Pe(e.ebnf))}}),$e.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>Pe(e.ecl))}}),$e.of({name:"edn",extensions:["edn"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Pe(e.clojure))}}),$e.of({name:"Eiffel",extensions:["e"],load(){return ve(()=>Promise.resolve().then(()=>Svt),void 0,import.meta.url).then(e=>Pe(e.eiffel))}}),$e.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>jvt),void 0,import.meta.url).then(e=>Pe(e.elm))}}),$e.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>ibt),void 0,import.meta.url).then(e=>Pe(e.erlang))}}),$e.of({name:"Esper",load(){return ve(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Pe(e.esper))}}),$e.of({name:"Factor",extensions:["factor"],load(){return ve(()=>Promise.resolve().then(()=>abt),void 0,import.meta.url).then(e=>Pe(e.factor))}}),$e.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>ubt),void 0,import.meta.url).then(e=>Pe(e.fcl))}}),$e.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>fbt),void 0,import.meta.url).then(e=>Pe(e.forth))}}),$e.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ve(()=>Promise.resolve().then(()=>vbt),void 0,import.meta.url).then(e=>Pe(e.fortran))}}),$e.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Pe(e.fSharp))}}),$e.of({name:"Gas",extensions:["s"],load(){return ve(()=>Promise.resolve().then(()=>wbt),void 0,import.meta.url).then(e=>Pe(e.gas))}}),$e.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Sbt),void 0,import.meta.url).then(e=>Pe(e.gherkin))}}),$e.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ve(()=>Promise.resolve().then(()=>jbt),void 0,import.meta.url).then(e=>Pe(e.groovy))}}),$e.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>Ybt),void 0,import.meta.url).then(e=>Pe(e.haskell))}}),$e.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>WF),void 0,import.meta.url).then(e=>Pe(e.haxe))}}),$e.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>WF),void 0,import.meta.url).then(e=>Pe(e.hxml))}}),$e.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>uwt),void 0,import.meta.url).then(e=>Pe(e.http))}}),$e.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>gwt),void 0,import.meta.url).then(e=>Pe(e.idl))}}),$e.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ve(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Pe(e.jsonld))}}),$e.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ve(()=>Promise.resolve().then(()=>bwt),void 0,import.meta.url).then(e=>Pe(e.jinja2))}}),$e.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>Vwt),void 0,import.meta.url).then(e=>Pe(e.julia))}}),$e.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.kotlin))}}),$e.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>Bwt),void 0,import.meta.url).then(e=>Pe(e.liveScript))}}),$e.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>i1t),void 0,import.meta.url).then(e=>Pe(e.lua))}}),$e.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>P1t),void 0,import.meta.url).then(e=>Pe(e.mirc))}}),$e.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ve(()=>Promise.resolve().then(()=>d1t),void 0,import.meta.url).then(e=>Pe(e.mathematica))}}),$e.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>z1t),void 0,import.meta.url).then(e=>Pe(e.modelica))}}),$e.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>J1t),void 0,import.meta.url).then(e=>Pe(e.mumps))}}),$e.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>x1t),void 0,import.meta.url).then(e=>Pe(e.mbox))}}),$e.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>iSt),void 0,import.meta.url).then(e=>Pe(e.nginx))}}),$e.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>aSt),void 0,import.meta.url).then(e=>Pe(e.nsis))}}),$e.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>oSt),void 0,import.meta.url).then(e=>Pe(e.ntriples))}}),$e.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.objectiveC))}}),$e.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.objectiveCpp))}}),$e.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Pe(e.oCaml))}}),$e.of({name:"Octave",extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>gSt),void 0,import.meta.url).then(e=>Pe(e.octave))}}),$e.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>TSt),void 0,import.meta.url).then(e=>Pe(e.oz))}}),$e.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>CSt),void 0,import.meta.url).then(e=>Pe(e.pascal))}}),$e.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>ASt),void 0,import.meta.url).then(e=>Pe(e.perl))}}),$e.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>WSt),void 0,import.meta.url).then(e=>Pe(e.pig))}}),$e.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>txt),void 0,import.meta.url).then(e=>Pe(e.powerShell))}}),$e.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ve(()=>Promise.resolve().then(()=>nxt),void 0,import.meta.url).then(e=>Pe(e.properties))}}),$e.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>sxt),void 0,import.meta.url).then(e=>Pe(e.protobuf))}}),$e.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ve(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>Pe(e.pug))}}),$e.of({name:"Puppet",extensions:["pp"],load(){return ve(()=>Promise.resolve().then(()=>uxt),void 0,import.meta.url).then(e=>Pe(e.puppet))}}),$e.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>$xt),void 0,import.meta.url).then(e=>Pe(e.q))}}),$e.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ve(()=>Promise.resolve().then(()=>Qxt),void 0,import.meta.url).then(e=>Pe(e.r))}}),$e.of({name:"RPM Changes",load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Pe(e.rpmChanges))}}),$e.of({name:"RPM Spec",extensions:["spec"],load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Pe(e.rpmSpec))}}),$e.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ve(()=>Promise.resolve().then(()=>jxt),void 0,import.meta.url).then(e=>Pe(e.ruby))}}),$e.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>Uxt),void 0,import.meta.url).then(e=>Pe(e.sas))}}),$e.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.scala))}}),$e.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>Pe(e.scheme))}}),$e.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ve(()=>Promise.resolve().then(()=>tQt),void 0,import.meta.url).then(e=>Pe(e.shell))}}),$e.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>oQt),void 0,import.meta.url).then(e=>Pe(e.sieve))}}),$e.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>cQt),void 0,import.meta.url).then(e=>Pe(e.smalltalk))}}),$e.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>mQt),void 0,import.meta.url).then(e=>Pe(e.solr))}}),$e.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Pe(e.sml))}}),$e.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ve(()=>Promise.resolve().then(()=>SQt),void 0,import.meta.url).then(e=>Pe(e.sparql))}}),$e.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>xQt),void 0,import.meta.url).then(e=>Pe(e.spreadsheet))}}),$e.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.squirrel))}}),$e.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>VQt),void 0,import.meta.url).then(e=>Pe(e.stylus))}}),$e.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>dkt),void 0,import.meta.url).then(e=>Pe(e.swift))}}),$e.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>RB),void 0,import.meta.url).then(e=>Pe(e.stex))}}),$e.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ve(()=>Promise.resolve().then(()=>RB),void 0,import.meta.url).then(e=>Pe(e.stex))}}),$e.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>BB),void 0,import.meta.url).then(e=>Pe(e.verilog))}}),$e.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>mkt),void 0,import.meta.url).then(e=>Pe(e.tcl))}}),$e.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>vkt),void 0,import.meta.url).then(e=>Pe(e.textile))}}),$e.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>Ykt),void 0,import.meta.url).then(e=>Pe(e.tiddlyWiki))}}),$e.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>Lkt),void 0,import.meta.url).then(e=>Pe(e.tiki))}}),$e.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>Fkt),void 0,import.meta.url).then(e=>Pe(e.toml))}}),$e.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ve(()=>Promise.resolve().then(()=>Kkt),void 0,import.meta.url).then(e=>Pe(e.troff))}}),$e.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>mPt),void 0,import.meta.url).then(e=>Pe(e.ttcn))}}),$e.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ve(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Pe(e.ttcnCfg))}}),$e.of({name:"Turtle",extensions:["ttl"],load(){return ve(()=>Promise.resolve().then(()=>yPt),void 0,import.meta.url).then(e=>Pe(e.turtle))}}),$e.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>d_t),void 0,import.meta.url).then(e=>Pe(e.webIDL))}}),$e.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>jPt),void 0,import.meta.url).then(e=>Pe(e.vb))}}),$e.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>APt),void 0,import.meta.url).then(e=>Pe(e.vbScript))}}),$e.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>WPt),void 0,import.meta.url).then(e=>Pe(e.velocity))}}),$e.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>BB),void 0,import.meta.url).then(e=>Pe(e.verilog))}}),$e.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>LPt),void 0,import.meta.url).then(e=>Pe(e.vhdl))}}),$e.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>w_t),void 0,import.meta.url).then(e=>Pe(e.xQuery))}}),$e.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>E_t),void 0,import.meta.url).then(e=>Pe(e.yacas))}}),$e.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>z_t),void 0,import.meta.url).then(e=>Pe(e.z80))}}),$e.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>X2),void 0,import.meta.url).then(e=>Pe(e.mscgen))}}),$e.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>X2),void 0,import.meta.url).then(e=>Pe(e.xu))}}),$e.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>X2),void 0,import.meta.url).then(e=>Pe(e.msgenny))}}),$e.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>Mmt),void 0,import.meta.url).then(e=>e.vue())}}),$e.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>dgt),void 0,import.meta.url).then(e=>e.angular())}})];class B9{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=Kn(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(gge(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 kV(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 Qit(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=kV(t)+kV(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Qv(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Qit(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function zk(e,t){return n=>{for(let r=Kn(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 PV{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Hd(e){return e.selection.main.from}function gge(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 H9=Yf.define();function kit(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:Ge.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const _V=new WeakMap;function Pit(e){if(!Array.isArray(e))return e;let t=_V.get(e);return t||_V.set(e,t=Qv(e)),t}const VS=Pn.define(),Z$=Pn.define();class _it{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=Po(t,n),i=Ac(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(Po(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 v=Po(t,0),S=Ac(v),x=S==t.length?0:-100;if(v!=n[0])if(v==r[0])x+=-200;else return null;return this.ret(x,[0,S])}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 v=0,S=Math.min(t.length,200);v<S&&c<l;){let x=Po(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=Ac(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,S=Math.min(t.length,200),x=0;v<S&&O<l;){let b=Po(t,v);s<0&&(u<l&&b==n[u]&&(a[u++]=v),f<l&&(b==n[f]||b==r[f]?(f==0&&(p=v),m=v+1,f++):f=0));let w,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=_pe(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||Q==1&&g||x==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),x=Q,v+=Ac(b)}return O==l&&o[0]==0&&y?this.result(-100+(d?-200:0),o,t):f==l&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):f==l?this.ret(-900-t.length,[p,m]):O==l?this.result(-100+(d?-200:0)+-700+(y?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?Ac(Po(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 Tit{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 Yi=ht.define({combine(e){return Am(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:Rit,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=>TV(t(r),n(r)),optionClass:(t,n)=>r=>TV(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function TV(e,t){return e?t?e+" "+t:e:t}function Rit(e,t,n,r,i,a){let o=e.textDirection==Xr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,f)?s=!1:!s&&f<Math.min(p,d)&&(s=!0),p<=(s?d:f))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:f);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Xit(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 d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(s.slice(u,O))),d.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 kT(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 Eit{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(Yi);this.optionContent=Xit(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=kT(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(Yi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:Z$.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=kT(a.length,o,t.state.facet(Yi).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=kT(n.options.length,n.selected,this.view.state.facet(Yi).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=>to(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&&jit(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(Yi).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 d=typeof c=="string"?c:c.name;if(d!=a&&(o>r.from||r.from==0))if(a=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=d}}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 d of this.optionContent){let f=d(s,this.view.state,this.view,l);f&&u.appendChild(f)}}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 qit(e,t){return n=>new Eit(n,e,t)}function jit(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 RV(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Cit(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(d=>d.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Yi);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 PV(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Tit(O):new _it(O);for(let p of c.result.options)if(d=f.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new PV(p,c.source,m,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,f)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=f.rank)!==null&&m!==void 0?m:1e9)||(d.name<f.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:f}=d.completion;f&&(d.score+=c[typeof f=="string"?f:f.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):RV(c.completion)>RV(s)&&(o[o.length-1]=c),s=c.completion}return o}class Dh{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 Dh(this.options,XV(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=Cit(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Yi).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 Dh(s,XV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Yit,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Dh(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 Dh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class MS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new MS(Wit,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Yi),a=(r.override||n.languageDataAt("autocomplete",Hd(n)).map(Pit)).map(l=>(this.active.find(u=>u.source==l)||new ps(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(K9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Ait(a,this.active)||s?o=Dh.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 ps(l.source,0):l));for(let l of t.effects)l.is(yge)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new MS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?zit:Uit}}function Ait(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 zit={"aria-autocomplete":"list"},Uit={};function XV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Wit=[];function $ge(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(H9);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 ps{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=$ge(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ps(i.source,0)),r&4&&i.state==0&&(i=new ps(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(VS))i=new ps(i.source,1,a.value);else if(a.is(Z$))i=new ps(i.source,0);else if(a.is(K9))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(Hd(t.state))}}class up extends ps{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=Hd(t.state);if(s>o||!i||n&2&&(Hd(t.startState)==this.from||s<this.limit))return new ps(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Nit(i.validFor,t.state,a,o)?new up(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new B9(t.state,s,!1)))?new up(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Hd(t.state)):new ps(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new up(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ps(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Nit(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):gge(e,!0).test(i)}const K9=Pn.define({map(e,t){return e.map(n=>n.map(t))}}),yge=Pn.define(),Ka=lo.define({create(){return MS.start()},update(e,t){return e.update(t)},provide:e=>[I9.from(e,t=>t.tooltip),Pt.contentAttributes.from(e,t=>t.attrs)]});function J9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ka).active.find(i=>i.source==t.source);return r instanceof up?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},kit(e.state,n,r.from,r.to)),{annotations:H9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Yit=qit(Ka,J9);function Bb(e,t="option"){return n=>{let r=n.state.field(Ka,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Yi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=Ime(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:yge.of(s)}),!0}}const Git=e=>{let t=e.state.field(Ka,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Yi).interactionDelay?!1:J9(e,t.open.options[t.open.selected])},EV=e=>e.state.field(Ka,!1)?(e.dispatch({effects:VS.of(!0)}),!0):!1,Iit=e=>{let t=e.state.field(Ka,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:Z$.of(null)}),!0)};class Zit{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Dit=50,Vit=1e3,Mit=Ri.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(Ka).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ka),n=e.state.facet(Yi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ka)==t)return;let r=e.transactions.some(a=>{let o=$ge(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>Dit&&Date.now()-o.time>Vit){for(let s of o.context.abortListeners)try{s()}catch(l){to(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(VS)))&&(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(Ka);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(Yi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Hd(t),r=new B9(t,n,e.explicit,this.view),i=new Zit(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:Z$.of(null)}),to(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(Yi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Yi),r=this.view.state.field(Ka);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=Hd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new up(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 ps(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:K9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ka,!1);if(t&&t.tooltip&&this.view.state.facet(Yi).closeOnBlur){let n=t.open&&Ime(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Z$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:VS.of(!1)}),20),this.composing=0}}}),Lit=typeof navigator=="object"&&/Win/.test(navigator.platform),Fit=YO.highest(Pt.domEventHandlers({keydown(e,t){let n=t.state.field(Ka,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Lit&&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&&J9(t,r),!1}})),vge=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 Bit{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class e8{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Bi.TrackDel),r=t.mapPos(this.to,1,Bi.TrackDel);return n==null||r==null?null:new e8(this.field,n,r)}}class t8{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(jk);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 e8(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 d of i)d.field>=c&&d.field++}i.push(new Bit(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 t8(r,i)}}let Hit=on.widget({widget:new class extends Su{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Kit=on.mark({class:"cm-snippetField"});class zm{constructor(t,n){this.ranges=t,this.active=n,this.deco=on.set(t.map(r=>(r.from==r.to?Hit:Kit).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 zm(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 kv=Pn.define({map(e,t){return e&&e.map(t)}}),Jit=Pn.define(),D$=lo.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(kv))return n.value;if(n.is(Jit)&&e)return new zm(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 n8(e,t){return Ge.create(e.filter(n=>n.field==t).map(n=>Ge.range(n.from,n.to)))}function eat(e){let t=t8.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:Hn.of(o)},scrollIntoView:!0,annotations:r?[H9.of(r),Hi.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=n8(s,0)),s.some(u=>u.field>0)){let u=new zm(s,0),O=c.effects=[kv.of(u)];n.state.field(D$,!1)===void 0&&O.push(Pn.appendConfig.of([D$,aat,oat,vge]))}n.dispatch(n.state.update(c))}}function bge(e){return({state:t,dispatch:n})=>{let r=t.field(D$,!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:n8(r.ranges,i),effects:kv.of(a?null:new zm(r.ranges,i)),scrollIntoView:!0})),!0}}const tat=({state:e,dispatch:t})=>e.field(D$,!1)?(t(e.update({effects:kv.of(null)})),!0):!1,nat=bge(1),rat=bge(-1),iat=[{key:"Tab",run:nat,shift:rat},{key:"Escape",run:tat}],qV=ht.define({combine(e){return e.length?e[0]:iat}}),aat=YO.highest(Xk.compute([qV],e=>e.facet(qV)));function xr(e,t){return Object.assign(Object.assign({},t),{apply:eat(e)})}const oat=Pt.domEventHandlers({mousedown(e,t){let n=t.state.field(D$,!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:n8(n.ranges,i.field),effects:kv.of(n.ranges.some(a=>a.field>i.field)?new zm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),V$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},zd=Pn.define({map(e,t){let n=t.mapPos(e,-1,Bi.TrackAfter);return n??void 0}}),r8=new class extends ff{};r8.startSide=1;r8.endSide=-1;const wge=lo.define({create(){return kn.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(zd)&&(e=e.update({add:[r8.range(n.value,n.value+1)]}));return e}});function lun(){return[lat,wge]}const PT="()[]{}<>«»»«[]{}";function Sge(e){for(let t=0;t<PT.length;t+=2)if(PT.charCodeAt(t)==e)return PT.charAt(t+1);return _pe(e<128?e:e+1)}function xge(e,t){return e.languageDataAt("closeBrackets",t)[0]||V$}const sat=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),lat=Pt.inputHandler.of((e,t,n,r)=>{if((sat?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Ac(Po(r,0))==1||t!=i.from||n!=i.to)return!1;let a=uat(e.state,r);return a?(e.dispatch(a),!0):!1}),cat=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=xge(e,e.selection.main.head).brackets||V$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=Oat(e.doc,o.head);for(let l of r)if(l==s&&Uk(e.doc,o.head)==Sge(Po(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ge.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},cun=[{key:"Backspace",run:cat}];function uat(e,t){let n=xge(e,e.selection.main.head),r=n.brackets||V$.brackets;for(let i of r){let a=Sge(Po(i,0));if(t==i)return a==i?hat(e,i,r.indexOf(i+i+i)>-1,n):dat(e,i,a,n.before||V$.before);if(t==a&&Qge(e,e.selection.main.from))return fat(e,i,a)}return null}function Qge(e,t){let n=!1;return e.field(wge).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function Uk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Ac(Po(n,0)))}function Oat(e,t){let n=e.sliceString(t-2,t);return Ac(Po(n,0))==n.length?n:n.slice(1)}function dat(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:zd.of(o.to+t.length),range:Ge.range(o.anchor+t.length,o.head+t.length)};let s=Uk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:zd.of(o.head+t.length),range:Ge.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function fat(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&Uk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ge.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function hat(e,t,n,r){let i=r.stringPrefixes||V$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:zd.of(s.to+t.length),range:Ge.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=Uk(e.doc,l),u;if(c==t){if(jV(e,l))return{changes:{insert:t+t,from:l},effects:zd.of(l+t.length),range:Ge.cursor(l+t.length)};if(Qge(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ge.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=CV(e,l-2*t.length,i))>-1&&jV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:zd.of(l+t.length),range:Ge.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=hs.Word&&CV(e,l,i)>-1&&!pat(e,l,t,i))return{changes:{insert:t+t,from:l},effects:zd.of(l+t.length),range:Ge.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function jV(e,t){let n=Kn(e).resolveInner(t+1);return n.parent&&n.from==t}function pat(e,t,n,r){let i=Kn(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 CV(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=hs.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))!=hs.Word)return a}return-1}function uun(e={}){return[Fit,Ka,Yi.of(e),Mit,gat,vge]}const mat=[{key:"Ctrl-Space",run:EV},{mac:"Alt-`",run:EV},{key:"Escape",run:Iit},{key:"ArrowDown",run:Bb(!0)},{key:"ArrowUp",run:Bb(!1)},{key:"PageDown",run:Bb(!0,"page")},{key:"PageUp",run:Bb(!1,"page")},{key:"Enter",run:Git}],gat=YO.highest(Xk.computeN([Yi],e=>e.facet(Yi).defaultKeymap?[mat]:[]));class LS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new LS(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=[[Yt.contextHash,i]]}addChild(t,n){t.prop(Yt.contextHash)!=this.hash&&(t=new fn(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 fn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new fn(yi.none,i,a,o,this.hashProp)})}}var De;(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"})(De||(De={}));class $at{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let yat=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 D0(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 AV(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==De.OrderedList?o8:a8)(n,t,!1);return r>0&&(e.type!=De.BulletList||i8(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const kge={[De.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push($n(De.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(_s(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[De.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[De.OrderedList]:AV,[De.BulletList]:AV,[De.Document](){return!0}};function _s(e){return e==32||e==9||e==10||e==13}function D0(e,t=0){for(;t<e.length&&_s(e.charCodeAt(t));)t++;return t}function zV(e,t,n){for(;t>n&&_s(e.charCodeAt(t-1));)t--;return t}function Pge(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 _ge(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function i8(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(!_s(a))return-1}return n&&e.next==45&&Xge(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Cge.SetextHeading)>-1||r<3?-1:1}function Tge(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function a8(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||_s(e.text.charCodeAt(e.pos+1)))&&(!n||Tge(t,De.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function o8(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&&!_s(e.text.charCodeAt(r+1))||n&&!Tge(t,De.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Rge(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 Xge(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&&_s(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const G3=/^[ \t]*$/,Ege=/-->/,qge=/\?>/,I3=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Ege],[/^\s*<\?/,qge],[/^\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,G3],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,G3]];function jge(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=I3.length-(n?1:0);i<a;i++)if(I3[i][0].test(r))return i;return-1}function UV(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 cd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==De.CodeText?e[r].to=n:e.push($n(De.CodeText,t,n))}const Hb={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(cd(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){cd(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==De.CodeText?cd(o,c.from,c.to):o.push(c);s=[]}cd(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&&cd(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=De.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(De.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Pge(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=zV(t.text,t.text.length,o),l=[$n(De.CodeMark,r,r+a)];o<s&&l.push($n(De.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($n(De.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||cd(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&cd(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(De.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=_ge(t);return n<0?!1:(e.startContext(De.Blockquote,t.pos),e.addNode(De.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(i8(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(De.HorizontalRule,n),!0},BulletList(e,t){let n=a8(t,e,!1);if(n<0)return!1;e.block.type!=De.BulletList&&e.startContext(De.BulletList,t.basePos,t.next);let r=UV(t,t.pos+1);return e.startContext(De.ListItem,t.basePos,r-t.baseIndent),e.addNode(De.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=o8(t,e,!1);if(n<0)return!1;e.block.type!=De.OrderedList&&e.startContext(De.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=UV(t,t.pos+n);return e.startContext(De.ListItem,t.basePos,r-t.baseIndent),e.addNode(De.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Rge(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=zV(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!_s(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(De.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(De.HeaderMark,o-r,a-r);let l=s.finish(De.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=jge(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=I3[n][1],a=[],o=i!=G3;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==Ege?De.CommentBlock:i==qge?De.ProcessingInstructionBlock:De.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class vat{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+`
|
|
826
|
+
`);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 Oge(n,t?t.state.tabSize:4,t?IS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=fge(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=fn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:bit,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new fn(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 fn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function fge(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 F9=Object.create(null),I$=[yi.none],bit=new Cm(I$),xV=[],QV=Object.create(null),hge=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"]])hge[e]=mge(F9,t);class pge{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),hge)}resolve(t){return t?this.table[t]||(this.table[t]=mge(this.extra,t)):0}}const wit=new pge(F9);function QT(e,t){xV.indexOf(e)>-1||(xV.push(e),console.warn(t))}function mge(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):QT(c,`Modifier ${c} used at start of tag`):l.length?QT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:QT(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=QV[i];if(a)return a.id;let o=QV[i]=yi.define({id:I$.length,name:r,props:[An({[r]:n})]});return I$.push(o),o.id}function Sit(e,t){let n=yi.define({id:I$.length,name:"Document",props:[uO.add(()=>e),Nr.add(()=>r=>t.getIndent(r))],top:!0});return I$.push(n),n}Xr.RTL,Xr.LTR;function Pe(e){return new yn(Ce.define(e))}function Uu(e){return ve(()=>Promise.resolve().then(()=>Mft),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const xit=[$e.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>mL),void 0,import.meta.url).then(e=>e.cpp())}}),$e.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ve(()=>Promise.resolve().then(()=>mL),void 0,import.meta.url).then(e=>e.cpp())}}),$e.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Uu("Cassandra")}}),$e.of({name:"CSS",extensions:["css"],load(){return ve(()=>Promise.resolve().then(()=>lst),void 0,import.meta.url).then(e=>e.css())}}),$e.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-5brl9P13.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),$e.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ve(()=>Promise.resolve().then(()=>Jst),void 0,import.meta.url).then(e=>e.html())}}),$e.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>Hft),void 0,import.meta.url).then(e=>e.java())}}),$e.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ve(()=>Promise.resolve().then(()=>Jb),void 0,import.meta.url).then(e=>e.javascript())}}),$e.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ve(()=>Promise.resolve().then(()=>ict),void 0,import.meta.url).then(e=>e.json())}}),$e.of({name:"JSX",extensions:["jsx"],load(){return ve(()=>Promise.resolve().then(()=>Jb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),$e.of({name:"LESS",extensions:["less"],load(){return ve(()=>Promise.resolve().then(()=>vlt),void 0,import.meta.url).then(e=>e.less())}}),$e.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>Amt),void 0,import.meta.url).then(e=>e.liquid())}}),$e.of({name:"MariaDB SQL",load(){return Uu("MariaSQL")}}),$e.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ve(()=>Promise.resolve().then(()=>clt),void 0,import.meta.url).then(e=>e.markdown())}}),$e.of({name:"MS SQL",load(){return Uu("MSSQL")}}),$e.of({name:"MySQL",load(){return Uu("MySQL")}}),$e.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ve(()=>Promise.resolve().then(()=>fmt),void 0,import.meta.url).then(e=>e.php())}}),$e.of({name:"PLSQL",extensions:["pls"],load(){return Uu("PLSQL")}}),$e.of({name:"PostgreSQL",load(){return Uu("PostgreSQL")}}),$e.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ve(()=>Promise.resolve().then(()=>Adt),void 0,import.meta.url).then(e=>e.python())}}),$e.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>ght),void 0,import.meta.url).then(e=>e.rust())}}),$e.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>XM),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),$e.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>XM),void 0,import.meta.url).then(e=>e.sass())}}),$e.of({name:"SQL",extensions:["sql"],load(){return Uu("StandardSQL")}}),$e.of({name:"SQLite",load(){return Uu("SQLite")}}),$e.of({name:"TSX",extensions:["tsx"],load(){return ve(()=>Promise.resolve().then(()=>Jb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),$e.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ve(()=>Promise.resolve().then(()=>Jb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),$e.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ve(()=>Promise.resolve().then(()=>Wmt),void 0,import.meta.url).then(e=>e.wast())}}),$e.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ve(()=>Promise.resolve().then(()=>ift),void 0,import.meta.url).then(e=>e.xml())}}),$e.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-CalJ1cZq.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),$e.of({name:"APL",extensions:["dyalog","apl"],load(){return ve(()=>Promise.resolve().then(()=>h$t),void 0,import.meta.url).then(e=>Pe(e.apl))}}),$e.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ve(()=>Promise.resolve().then(()=>p$t),void 0,import.meta.url).then(e=>Pe(e.asciiArmor))}}),$e.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ve(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Pe(e.asn1({})))}}),$e.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>v$t),void 0,import.meta.url).then(e=>Pe(e.asterisk))}}),$e.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>w$t),void 0,import.meta.url).then(e=>Pe(e.brainfuck))}}),$e.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>B$t),void 0,import.meta.url).then(e=>Pe(e.cobol))}}),$e.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.csharp))}}),$e.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Pe(e.clojure))}}),$e.of({name:"ClojureScript",extensions:["cljs"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Pe(e.clojure))}}),$e.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ve(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Pe(e.gss))}}),$e.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ve(()=>Promise.resolve().then(()=>Y$t),void 0,import.meta.url).then(e=>Pe(e.cmake))}}),$e.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ve(()=>Promise.resolve().then(()=>cyt),void 0,import.meta.url).then(e=>Pe(e.coffeeScript))}}),$e.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ve(()=>Promise.resolve().then(()=>pyt),void 0,import.meta.url).then(e=>Pe(e.commonLisp))}}),$e.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>qyt),void 0,import.meta.url).then(e=>Pe(e.cypher))}}),$e.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ve(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Pe(e.cython))}}),$e.of({name:"Crystal",extensions:["cr"],load(){return ve(()=>Promise.resolve().then(()=>Pyt),void 0,import.meta.url).then(e=>Pe(e.crystal))}}),$e.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>Nyt),void 0,import.meta.url).then(e=>Pe(e.d))}}),$e.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.dart))}}),$e.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>Yyt),void 0,import.meta.url).then(e=>Pe(e.diff))}}),$e.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>evt),void 0,import.meta.url).then(e=>Pe(e.dockerFile))}}),$e.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>rvt),void 0,import.meta.url).then(e=>Pe(e.dtd))}}),$e.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>lvt),void 0,import.meta.url).then(e=>Pe(e.dylan))}}),$e.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>cvt),void 0,import.meta.url).then(e=>Pe(e.ebnf))}}),$e.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>Pe(e.ecl))}}),$e.of({name:"edn",extensions:["edn"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Pe(e.clojure))}}),$e.of({name:"Eiffel",extensions:["e"],load(){return ve(()=>Promise.resolve().then(()=>Svt),void 0,import.meta.url).then(e=>Pe(e.eiffel))}}),$e.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>jvt),void 0,import.meta.url).then(e=>Pe(e.elm))}}),$e.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>ibt),void 0,import.meta.url).then(e=>Pe(e.erlang))}}),$e.of({name:"Esper",load(){return ve(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Pe(e.esper))}}),$e.of({name:"Factor",extensions:["factor"],load(){return ve(()=>Promise.resolve().then(()=>abt),void 0,import.meta.url).then(e=>Pe(e.factor))}}),$e.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>ubt),void 0,import.meta.url).then(e=>Pe(e.fcl))}}),$e.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>fbt),void 0,import.meta.url).then(e=>Pe(e.forth))}}),$e.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ve(()=>Promise.resolve().then(()=>vbt),void 0,import.meta.url).then(e=>Pe(e.fortran))}}),$e.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Pe(e.fSharp))}}),$e.of({name:"Gas",extensions:["s"],load(){return ve(()=>Promise.resolve().then(()=>wbt),void 0,import.meta.url).then(e=>Pe(e.gas))}}),$e.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Sbt),void 0,import.meta.url).then(e=>Pe(e.gherkin))}}),$e.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ve(()=>Promise.resolve().then(()=>jbt),void 0,import.meta.url).then(e=>Pe(e.groovy))}}),$e.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>Ybt),void 0,import.meta.url).then(e=>Pe(e.haskell))}}),$e.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>WF),void 0,import.meta.url).then(e=>Pe(e.haxe))}}),$e.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>WF),void 0,import.meta.url).then(e=>Pe(e.hxml))}}),$e.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>uwt),void 0,import.meta.url).then(e=>Pe(e.http))}}),$e.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>gwt),void 0,import.meta.url).then(e=>Pe(e.idl))}}),$e.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ve(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Pe(e.jsonld))}}),$e.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ve(()=>Promise.resolve().then(()=>bwt),void 0,import.meta.url).then(e=>Pe(e.jinja2))}}),$e.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>Vwt),void 0,import.meta.url).then(e=>Pe(e.julia))}}),$e.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.kotlin))}}),$e.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>Bwt),void 0,import.meta.url).then(e=>Pe(e.liveScript))}}),$e.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>i1t),void 0,import.meta.url).then(e=>Pe(e.lua))}}),$e.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>P1t),void 0,import.meta.url).then(e=>Pe(e.mirc))}}),$e.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ve(()=>Promise.resolve().then(()=>d1t),void 0,import.meta.url).then(e=>Pe(e.mathematica))}}),$e.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>z1t),void 0,import.meta.url).then(e=>Pe(e.modelica))}}),$e.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>J1t),void 0,import.meta.url).then(e=>Pe(e.mumps))}}),$e.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>x1t),void 0,import.meta.url).then(e=>Pe(e.mbox))}}),$e.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>iSt),void 0,import.meta.url).then(e=>Pe(e.nginx))}}),$e.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>aSt),void 0,import.meta.url).then(e=>Pe(e.nsis))}}),$e.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>oSt),void 0,import.meta.url).then(e=>Pe(e.ntriples))}}),$e.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.objectiveC))}}),$e.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.objectiveCpp))}}),$e.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Pe(e.oCaml))}}),$e.of({name:"Octave",extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>gSt),void 0,import.meta.url).then(e=>Pe(e.octave))}}),$e.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>TSt),void 0,import.meta.url).then(e=>Pe(e.oz))}}),$e.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>CSt),void 0,import.meta.url).then(e=>Pe(e.pascal))}}),$e.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>ASt),void 0,import.meta.url).then(e=>Pe(e.perl))}}),$e.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>WSt),void 0,import.meta.url).then(e=>Pe(e.pig))}}),$e.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>txt),void 0,import.meta.url).then(e=>Pe(e.powerShell))}}),$e.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ve(()=>Promise.resolve().then(()=>nxt),void 0,import.meta.url).then(e=>Pe(e.properties))}}),$e.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>sxt),void 0,import.meta.url).then(e=>Pe(e.protobuf))}}),$e.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ve(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>Pe(e.pug))}}),$e.of({name:"Puppet",extensions:["pp"],load(){return ve(()=>Promise.resolve().then(()=>uxt),void 0,import.meta.url).then(e=>Pe(e.puppet))}}),$e.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>$xt),void 0,import.meta.url).then(e=>Pe(e.q))}}),$e.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ve(()=>Promise.resolve().then(()=>Qxt),void 0,import.meta.url).then(e=>Pe(e.r))}}),$e.of({name:"RPM Changes",load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Pe(e.rpmChanges))}}),$e.of({name:"RPM Spec",extensions:["spec"],load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Pe(e.rpmSpec))}}),$e.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ve(()=>Promise.resolve().then(()=>jxt),void 0,import.meta.url).then(e=>Pe(e.ruby))}}),$e.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>Uxt),void 0,import.meta.url).then(e=>Pe(e.sas))}}),$e.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.scala))}}),$e.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>Pe(e.scheme))}}),$e.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ve(()=>Promise.resolve().then(()=>tQt),void 0,import.meta.url).then(e=>Pe(e.shell))}}),$e.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>oQt),void 0,import.meta.url).then(e=>Pe(e.sieve))}}),$e.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>cQt),void 0,import.meta.url).then(e=>Pe(e.smalltalk))}}),$e.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>mQt),void 0,import.meta.url).then(e=>Pe(e.solr))}}),$e.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Pe(e.sml))}}),$e.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ve(()=>Promise.resolve().then(()=>SQt),void 0,import.meta.url).then(e=>Pe(e.sparql))}}),$e.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>xQt),void 0,import.meta.url).then(e=>Pe(e.spreadsheet))}}),$e.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>dd),void 0,import.meta.url).then(e=>Pe(e.squirrel))}}),$e.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>VQt),void 0,import.meta.url).then(e=>Pe(e.stylus))}}),$e.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>dkt),void 0,import.meta.url).then(e=>Pe(e.swift))}}),$e.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>RB),void 0,import.meta.url).then(e=>Pe(e.stex))}}),$e.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ve(()=>Promise.resolve().then(()=>RB),void 0,import.meta.url).then(e=>Pe(e.stex))}}),$e.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>BB),void 0,import.meta.url).then(e=>Pe(e.verilog))}}),$e.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>mkt),void 0,import.meta.url).then(e=>Pe(e.tcl))}}),$e.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>vkt),void 0,import.meta.url).then(e=>Pe(e.textile))}}),$e.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>Ykt),void 0,import.meta.url).then(e=>Pe(e.tiddlyWiki))}}),$e.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>Lkt),void 0,import.meta.url).then(e=>Pe(e.tiki))}}),$e.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>Fkt),void 0,import.meta.url).then(e=>Pe(e.toml))}}),$e.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ve(()=>Promise.resolve().then(()=>Kkt),void 0,import.meta.url).then(e=>Pe(e.troff))}}),$e.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>mPt),void 0,import.meta.url).then(e=>Pe(e.ttcn))}}),$e.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ve(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Pe(e.ttcnCfg))}}),$e.of({name:"Turtle",extensions:["ttl"],load(){return ve(()=>Promise.resolve().then(()=>yPt),void 0,import.meta.url).then(e=>Pe(e.turtle))}}),$e.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>d_t),void 0,import.meta.url).then(e=>Pe(e.webIDL))}}),$e.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>jPt),void 0,import.meta.url).then(e=>Pe(e.vb))}}),$e.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>APt),void 0,import.meta.url).then(e=>Pe(e.vbScript))}}),$e.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>WPt),void 0,import.meta.url).then(e=>Pe(e.velocity))}}),$e.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>BB),void 0,import.meta.url).then(e=>Pe(e.verilog))}}),$e.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>LPt),void 0,import.meta.url).then(e=>Pe(e.vhdl))}}),$e.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>w_t),void 0,import.meta.url).then(e=>Pe(e.xQuery))}}),$e.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>E_t),void 0,import.meta.url).then(e=>Pe(e.yacas))}}),$e.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>z_t),void 0,import.meta.url).then(e=>Pe(e.z80))}}),$e.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>X2),void 0,import.meta.url).then(e=>Pe(e.mscgen))}}),$e.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>X2),void 0,import.meta.url).then(e=>Pe(e.xu))}}),$e.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>X2),void 0,import.meta.url).then(e=>Pe(e.msgenny))}}),$e.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>Mmt),void 0,import.meta.url).then(e=>e.vue())}}),$e.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>dgt),void 0,import.meta.url).then(e=>e.angular())}})];class B9{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=Kn(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(gge(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 kV(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 Qit(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=kV(t)+kV(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Qv(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Qit(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function zk(e,t){return n=>{for(let r=Kn(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 PV{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Hd(e){return e.selection.main.from}function gge(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 H9=Yf.define();function kit(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:Ge.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const _V=new WeakMap;function Pit(e){if(!Array.isArray(e))return e;let t=_V.get(e);return t||_V.set(e,t=Qv(e)),t}const VS=Pn.define(),Z$=Pn.define();class _it{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=Po(t,n),i=Ac(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(Po(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 v=Po(t,0),S=Ac(v),x=S==t.length?0:-100;if(v!=n[0])if(v==r[0])x+=-200;else return null;return this.ret(x,[0,S])}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 v=0,S=Math.min(t.length,200);v<S&&c<l;){let x=Po(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=Ac(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,S=Math.min(t.length,200),x=0;v<S&&O<l;){let b=Po(t,v);s<0&&(u<l&&b==n[u]&&(a[u++]=v),f<l&&(b==n[f]||b==r[f]?(f==0&&(p=v),m=v+1,f++):f=0));let w,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=_pe(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||Q==1&&g||x==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),x=Q,v+=Ac(b)}return O==l&&o[0]==0&&y?this.result(-100+(d?-200:0),o,t):f==l&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):f==l?this.ret(-900-t.length,[p,m]):O==l?this.result(-100+(d?-200:0)+-700+(y?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?Ac(Po(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 Tit{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 Yi=ht.define({combine(e){return Am(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:Rit,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=>TV(t(r),n(r)),optionClass:(t,n)=>r=>TV(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function TV(e,t){return e?t?e+" "+t:e:t}function Rit(e,t,n,r,i,a){let o=e.textDirection==Xr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,f)?s=!1:!s&&f<Math.min(p,d)&&(s=!0),p<=(s?d:f))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:f);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Xit(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 d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(s.slice(u,O))),d.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 kT(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 Eit{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(Yi);this.optionContent=Xit(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=kT(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(Yi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:Z$.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=kT(a.length,o,t.state.facet(Yi).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=kT(n.options.length,n.selected,this.view.state.facet(Yi).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=>to(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&&jit(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(Yi).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 d=typeof c=="string"?c:c.name;if(d!=a&&(o>r.from||r.from==0))if(a=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=d}}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 d of this.optionContent){let f=d(s,this.view.state,this.view,l);f&&u.appendChild(f)}}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 qit(e,t){return n=>new Eit(n,e,t)}function jit(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 RV(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Cit(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(d=>d.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Yi);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 PV(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Tit(O):new _it(O);for(let p of c.result.options)if(d=f.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new PV(p,c.source,m,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,f)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=f.rank)!==null&&m!==void 0?m:1e9)||(d.name<f.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:f}=d.completion;f&&(d.score+=c[typeof f=="string"?f:f.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):RV(c.completion)>RV(s)&&(o[o.length-1]=c),s=c.completion}return o}class Dh{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 Dh(this.options,XV(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=Cit(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Yi).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 Dh(s,XV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Yit,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Dh(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 Dh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class MS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new MS(Wit,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Yi),a=(r.override||n.languageDataAt("autocomplete",Hd(n)).map(Pit)).map(l=>(this.active.find(u=>u.source==l)||new ps(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(K9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Ait(a,this.active)||s?o=Dh.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 ps(l.source,0):l));for(let l of t.effects)l.is(yge)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new MS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?zit:Uit}}function Ait(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 zit={"aria-autocomplete":"list"},Uit={};function XV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Wit=[];function $ge(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(H9);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 ps{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=$ge(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ps(i.source,0)),r&4&&i.state==0&&(i=new ps(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(VS))i=new ps(i.source,1,a.value);else if(a.is(Z$))i=new ps(i.source,0);else if(a.is(K9))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(Hd(t.state))}}class up extends ps{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=Hd(t.state);if(s>o||!i||n&2&&(Hd(t.startState)==this.from||s<this.limit))return new ps(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Nit(i.validFor,t.state,a,o)?new up(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new B9(t.state,s,!1)))?new up(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Hd(t.state)):new ps(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new up(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ps(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Nit(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):gge(e,!0).test(i)}const K9=Pn.define({map(e,t){return e.map(n=>n.map(t))}}),yge=Pn.define(),Ka=lo.define({create(){return MS.start()},update(e,t){return e.update(t)},provide:e=>[I9.from(e,t=>t.tooltip),Pt.contentAttributes.from(e,t=>t.attrs)]});function J9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ka).active.find(i=>i.source==t.source);return r instanceof up?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},kit(e.state,n,r.from,r.to)),{annotations:H9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Yit=qit(Ka,J9);function Bb(e,t="option"){return n=>{let r=n.state.field(Ka,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Yi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=Ime(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:yge.of(s)}),!0}}const Git=e=>{let t=e.state.field(Ka,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Yi).interactionDelay?!1:J9(e,t.open.options[t.open.selected])},EV=e=>e.state.field(Ka,!1)?(e.dispatch({effects:VS.of(!0)}),!0):!1,Iit=e=>{let t=e.state.field(Ka,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:Z$.of(null)}),!0)};class Zit{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Dit=50,Vit=1e3,Mit=Ri.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(Ka).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ka),n=e.state.facet(Yi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ka)==t)return;let r=e.transactions.some(a=>{let o=$ge(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>Dit&&Date.now()-o.time>Vit){for(let s of o.context.abortListeners)try{s()}catch(l){to(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(VS)))&&(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(Ka);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(Yi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Hd(t),r=new B9(t,n,e.explicit,this.view),i=new Zit(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:Z$.of(null)}),to(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(Yi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Yi),r=this.view.state.field(Ka);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=Hd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new up(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 ps(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:K9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ka,!1);if(t&&t.tooltip&&this.view.state.facet(Yi).closeOnBlur){let n=t.open&&Ime(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Z$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:VS.of(!1)}),20),this.composing=0}}}),Lit=typeof navigator=="object"&&/Win/.test(navigator.platform),Fit=YO.highest(Pt.domEventHandlers({keydown(e,t){let n=t.state.field(Ka,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Lit&&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&&J9(t,r),!1}})),vge=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 Bit{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class e8{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Bi.TrackDel),r=t.mapPos(this.to,1,Bi.TrackDel);return n==null||r==null?null:new e8(this.field,n,r)}}class t8{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(jk);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 e8(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 d of i)d.field>=c&&d.field++}i.push(new Bit(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 t8(r,i)}}let Hit=on.widget({widget:new class extends Su{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Kit=on.mark({class:"cm-snippetField"});class zm{constructor(t,n){this.ranges=t,this.active=n,this.deco=on.set(t.map(r=>(r.from==r.to?Hit:Kit).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 zm(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 kv=Pn.define({map(e,t){return e&&e.map(t)}}),Jit=Pn.define(),D$=lo.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(kv))return n.value;if(n.is(Jit)&&e)return new zm(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 n8(e,t){return Ge.create(e.filter(n=>n.field==t).map(n=>Ge.range(n.from,n.to)))}function eat(e){let t=t8.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:Hn.of(o)},scrollIntoView:!0,annotations:r?[H9.of(r),Hi.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=n8(s,0)),s.some(u=>u.field>0)){let u=new zm(s,0),O=c.effects=[kv.of(u)];n.state.field(D$,!1)===void 0&&O.push(Pn.appendConfig.of([D$,aat,oat,vge]))}n.dispatch(n.state.update(c))}}function bge(e){return({state:t,dispatch:n})=>{let r=t.field(D$,!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:n8(r.ranges,i),effects:kv.of(a?null:new zm(r.ranges,i)),scrollIntoView:!0})),!0}}const tat=({state:e,dispatch:t})=>e.field(D$,!1)?(t(e.update({effects:kv.of(null)})),!0):!1,nat=bge(1),rat=bge(-1),iat=[{key:"Tab",run:nat,shift:rat},{key:"Escape",run:tat}],qV=ht.define({combine(e){return e.length?e[0]:iat}}),aat=YO.highest(Xk.compute([qV],e=>e.facet(qV)));function xr(e,t){return Object.assign(Object.assign({},t),{apply:eat(e)})}const oat=Pt.domEventHandlers({mousedown(e,t){let n=t.state.field(D$,!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:n8(n.ranges,i.field),effects:kv.of(n.ranges.some(a=>a.field>i.field)?new zm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),V$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},zd=Pn.define({map(e,t){let n=t.mapPos(e,-1,Bi.TrackAfter);return n??void 0}}),r8=new class extends ff{};r8.startSide=1;r8.endSide=-1;const wge=lo.define({create(){return kn.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(zd)&&(e=e.update({add:[r8.range(n.value,n.value+1)]}));return e}});function lun(){return[lat,wge]}const PT="()[]{}<>«»»«[]{}";function Sge(e){for(let t=0;t<PT.length;t+=2)if(PT.charCodeAt(t)==e)return PT.charAt(t+1);return _pe(e<128?e:e+1)}function xge(e,t){return e.languageDataAt("closeBrackets",t)[0]||V$}const sat=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),lat=Pt.inputHandler.of((e,t,n,r)=>{if((sat?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Ac(Po(r,0))==1||t!=i.from||n!=i.to)return!1;let a=uat(e.state,r);return a?(e.dispatch(a),!0):!1}),cat=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=xge(e,e.selection.main.head).brackets||V$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=Oat(e.doc,o.head);for(let l of r)if(l==s&&Uk(e.doc,o.head)==Sge(Po(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ge.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},cun=[{key:"Backspace",run:cat}];function uat(e,t){let n=xge(e,e.selection.main.head),r=n.brackets||V$.brackets;for(let i of r){let a=Sge(Po(i,0));if(t==i)return a==i?hat(e,i,r.indexOf(i+i+i)>-1,n):dat(e,i,a,n.before||V$.before);if(t==a&&Qge(e,e.selection.main.from))return fat(e,i,a)}return null}function Qge(e,t){let n=!1;return e.field(wge).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function Uk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Ac(Po(n,0)))}function Oat(e,t){let n=e.sliceString(t-2,t);return Ac(Po(n,0))==n.length?n:n.slice(1)}function dat(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:zd.of(o.to+t.length),range:Ge.range(o.anchor+t.length,o.head+t.length)};let s=Uk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:zd.of(o.head+t.length),range:Ge.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function fat(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&Uk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ge.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function hat(e,t,n,r){let i=r.stringPrefixes||V$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:zd.of(s.to+t.length),range:Ge.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=Uk(e.doc,l),u;if(c==t){if(jV(e,l))return{changes:{insert:t+t,from:l},effects:zd.of(l+t.length),range:Ge.cursor(l+t.length)};if(Qge(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ge.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=CV(e,l-2*t.length,i))>-1&&jV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:zd.of(l+t.length),range:Ge.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=hs.Word&&CV(e,l,i)>-1&&!pat(e,l,t,i))return{changes:{insert:t+t,from:l},effects:zd.of(l+t.length),range:Ge.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function jV(e,t){let n=Kn(e).resolveInner(t+1);return n.parent&&n.from==t}function pat(e,t,n,r){let i=Kn(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 CV(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=hs.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))!=hs.Word)return a}return-1}function uun(e={}){return[Fit,Ka,Yi.of(e),Mit,gat,vge]}const mat=[{key:"Ctrl-Space",run:EV},{mac:"Alt-`",run:EV},{key:"Escape",run:Iit},{key:"ArrowDown",run:Bb(!0)},{key:"ArrowUp",run:Bb(!1)},{key:"PageDown",run:Bb(!0,"page")},{key:"PageUp",run:Bb(!1,"page")},{key:"Enter",run:Git}],gat=YO.highest(Xk.computeN([Yi],e=>e.facet(Yi).defaultKeymap?[mat]:[]));class LS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new LS(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=[[Yt.contextHash,i]]}addChild(t,n){t.prop(Yt.contextHash)!=this.hash&&(t=new fn(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 fn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new fn(yi.none,i,a,o,this.hashProp)})}}var De;(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"})(De||(De={}));class $at{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let yat=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 D0(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 AV(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==De.OrderedList?o8:a8)(n,t,!1);return r>0&&(e.type!=De.BulletList||i8(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const kge={[De.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push($n(De.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(_s(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[De.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[De.OrderedList]:AV,[De.BulletList]:AV,[De.Document](){return!0}};function _s(e){return e==32||e==9||e==10||e==13}function D0(e,t=0){for(;t<e.length&&_s(e.charCodeAt(t));)t++;return t}function zV(e,t,n){for(;t>n&&_s(e.charCodeAt(t-1));)t--;return t}function Pge(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 _ge(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function i8(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(!_s(a))return-1}return n&&e.next==45&&Xge(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Cge.SetextHeading)>-1||r<3?-1:1}function Tge(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function a8(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||_s(e.text.charCodeAt(e.pos+1)))&&(!n||Tge(t,De.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function o8(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&&!_s(e.text.charCodeAt(r+1))||n&&!Tge(t,De.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Rge(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 Xge(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&&_s(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const G3=/^[ \t]*$/,Ege=/-->/,qge=/\?>/,I3=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Ege],[/^\s*<\?/,qge],[/^\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,G3],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,G3]];function jge(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=I3.length-(n?1:0);i<a;i++)if(I3[i][0].test(r))return i;return-1}function UV(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 cd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==De.CodeText?e[r].to=n:e.push($n(De.CodeText,t,n))}const Hb={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(cd(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){cd(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==De.CodeText?cd(o,c.from,c.to):o.push(c);s=[]}cd(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&&cd(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=De.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(De.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Pge(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=zV(t.text,t.text.length,o),l=[$n(De.CodeMark,r,r+a)];o<s&&l.push($n(De.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($n(De.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||cd(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&cd(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(De.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=_ge(t);return n<0?!1:(e.startContext(De.Blockquote,t.pos),e.addNode(De.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(i8(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(De.HorizontalRule,n),!0},BulletList(e,t){let n=a8(t,e,!1);if(n<0)return!1;e.block.type!=De.BulletList&&e.startContext(De.BulletList,t.basePos,t.next);let r=UV(t,t.pos+1);return e.startContext(De.ListItem,t.basePos,r-t.baseIndent),e.addNode(De.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=o8(t,e,!1);if(n<0)return!1;e.block.type!=De.OrderedList&&e.startContext(De.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=UV(t,t.pos+n);return e.startContext(De.ListItem,t.basePos,r-t.baseIndent),e.addNode(De.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Rge(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=zV(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!_s(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(De.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(De.HeaderMark,o-r,a-r);let l=s.finish(De.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=jge(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=I3[n][1],a=[],o=i!=G3;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==Ege?De.CommentBlock:i==qge?De.ProcessingInstructionBlock:De.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class vat{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+`
|
|
827
827
|
`+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)&&D0(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,$n(De.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(Zge(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push($n(De.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Gge(t,D0(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=D0(t,this.pos),r=0;if(n>this.pos){let i=Ige(t,n,this.start);if(i){let a=_T(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=_T(t,this.pos)),r>0&&r<t.length?r:-1}else return _T(t,this.pos)}}}function _T(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!_s(n))return-1}return t}class bat{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:Xge(n),a=n.next;if(i<0)return!1;let o=$n(De.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,$n(a==61?De.SetextHeading1:De.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const Cge={LinkReference(e,t){return t.content.charCodeAt(0)==91?new vat(t):null},SetextHeading(){return new bat}},wat=[(e,t)=>Rge(t)>=0,(e,t)=>Pge(t)>=0,(e,t)=>_ge(t)>=0,(e,t)=>a8(t,e,!0)>=0,(e,t)=>o8(t,e,!0)>=0,(e,t)=>i8(t,e,!0)>=0,(e,t)=>jge(t,e,!0)>=0],Sat={text:"",end:0};class xat{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new yat,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=LS.create(De.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new _at(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 $at(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+=`
|
|
828
828
|
`+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=Dge(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=Sat;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 "+De[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==`
|
|
829
829
|
`?"":n;else{let i=n.indexOf(`
|
|
@@ -857,7 +857,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
857
857
|
`,o.end),l=t.slice(o.end,s===-1?t.length:s);if(M5t.test(l))return Ja;const c=l.length-l.replace(L5t,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+Lp(e.value).length;return n<O||n>d?{arm:u,typingAt:null,value:""}:{arm:u,typingAt:O,value:e.value}}return a&&n===u.end&&t[n-1]===gP?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const Xl=e=>e.typingAt!==null,J5t=e=>e.arm!==null;function Bf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+Lp(e.value).length}}function sU(e,t,n,r){const i=Bf(e);if(i===null)return null;const{top:a,bottom:o,inserted:s}=r;if(a>i.end||o<i.start)return null;const l=Lp(e.value),c=VC(a-i.start,0,l.length),u=VC(o-i.start,0,l.length),O=Lp(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),f=a+O.length,p=t.slice(0,a)+kSe.repeat(O.length)+t.slice(f),m=O.length-s.length,g=n>=f?n+m:n;return{buffer:p,caret:g,capture:{...e,value:d}}}function dH(e,t,n,r){const i={capture:e,buffer:t.slice(0,n.start)+r+t.slice(n.end),caret:n.start+r.length},a=Xl(e)&&e.value===""&&r.startsWith("-");if(Xl(e)&&(a||r.includes(`
|
|
858
858
|
`))){const o=Sx(e);return r.includes(`
|
|
859
859
|
`)?{...i,capture:o}:{...i,capture:Lh(o,i.buffer,i.caret,"typing")}}return sU(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function Sx(e){return Xl(e)?{arm:e.arm,typingAt:null,value:""}:e}function eTt(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 tTt(e,t,n,r,i){const a=eTt(t,n),o=Bf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:Sx(e),buffer:n,caret:r};else{const l=sU(e,n,r,a);l?s=l:Xl(e)&&a.inserted.includes(`
|
|
860
|
-
`)&&(s={capture:Sx(e),buffer:n,caret:r})}return{...s,capture:Lh(s.capture,s.buffer,s.caret,i)}}function nTt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Bf(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=CSe(i,t.value),c=l+gP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ja,buffer:u,caret:s+c.length,payload:{index:i,key:WSe(a,e.draw),value:t.value,marker:l}}}function rTt(e,t){const n=Bf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=USe(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ja,buffer:i,caret:n.start+r.length,restored:DC(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:DC(r),restoredText:r}}}function fH(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function iTt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Bf(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:Sx(e),buffer:i,caret:a,payload:null}}function aTt(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=sU(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=nn(i);if(!a)return i===""?null:iTt(t,n,e.selection,i);const o=t.arm,s=CSe(e.index,a),l=s+gP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ja,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:WSe(e.taken,e.draw),value:a,marker:s}}}const jSe=e=>`${DC(e)} chars`,CSe=(e,t)=>`[Credential #${e}, ${jSe(t)}]`;function oTt(e){Il.lastIndex=0;const t=Il.exec(e);return Il.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function sTt(e){Il.lastIndex=0;const t=Il.exec(e);if(Il.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 zv(e,t){if(oTt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const L2=/\[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,F2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,B2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,lTt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&ZC.test(t[1])?t[1]:""};function cTt(e,t){if(e.charCodeAt(t)!==91)return null;L2.lastIndex=t;const n=L2.exec(e);if(L2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};F2.lastIndex=t;const r=F2.exec(e);if(F2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};B2.lastIndex=t;const i=B2.exec(e);return B2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:lTt(i[0])}:null}function $P(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=cTt(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 hH(e,t){const n=[];for(const r of t){const i=zv(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 uTt(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 OTt=e=>`[credential ${e.key} (${jSe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function dTt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=zv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of RSe(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?uTt(l??"lost",s?.key):OTt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const fTt=(e,t,n)=>`Removed ${e} (credential #${t}) from this message. Its value is gone — press ${n} to put it back, or paste it again after /credential to reuse it.`,hTt=e=>`Remove credential #${e}`,pTt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,mTt=(e,t,n)=>fTt(e,t,n),gTt="Undo",$Tt=e=>`Credential #${e} removed`,yTt=e=>e.unredacted!==null?e.unredacted:e.armed?kTt:e.cleared!==null?mTt(e.cleared.key,e.cleared.index,e.undoCap):null;function vTt(e){const{buffer:t,payload:n}=e,r=zv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===gP?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 bTt(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 pH=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function mH(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be stored (${[...e].sort().join(", ")}); the agent has been told so. Paste the value again after /credential to retry.`}const wTt="store unconfirmed",STt="Credential store unconfirmed",xTt=e=>e===""?STt:`${e} · ${wTt}`,ASe="Paste the value again after /credential to store it again.",QTt=e=>`${e} ${ASe}`;function gH(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be confirmed as stored (${[...e].sort().join(", ")}); the agent has been told to check before using it. ${ASe}`}const kTt="armed — add a space, then type or paste the secret",PTt="masked as you type — Enter turns it into a pill, Esc cancels",_Tt="masked — Enter opens the credential picker; type or paste the secret into this span",TTt="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",zSe="\0held",RTt=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===zSe?`${e} characters are now PLAIN TEXT in the composer — Enter is held: clear the box to release your words`:`${e} characters are now PLAIN TEXT in the composer — Enter will take them as /${t}'s argument, not send them`;function USe(e,t){const n=Bf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const $H=(e,t)=>e&&e.over===t?e.chars:null,XTt=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},ETt=16,qTt=16;function WSe(e=[],t=XTt){const n=new Set(e);for(let r=0;r<ETt;r++){const i=uH+yH(8,t);if(!n.has(i))return i}return uH+yH(qTt,t)}const yH=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=cH[t(cH.length)];return n},jTt=8,CTt=256,ATt=/^[/@$#]/,zTt=/^\w+:\/\//,UTt=/^[A-Za-z]+$/,WTt=/^\d+$/,NTt=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],YTt=3,GTt=20,ITt=/^[A-Za-z0-9_\-+/=.]+$/,ZTt=new RegExp(`^[^${va}@]+@[^${va}@]+\\.[A-Za-z]{2,}$`),DTt=/^[\w.-]+(?:\/[\w.-]+)+$/,VTt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,MTt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,LTt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,FTt=/^[\w.-]+:\d{2,5}$/,BTt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,HTt=/^[a-z]+(?:_[a-z]+)+$/,KTt=/^[a-z]+(?:-[a-z]+)+$/,JTt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,e2t=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,t2t=/\d{4,}/,n2t=e=>{const t=e.trim();return t.length<jTt||t.length>CTt||No.test(t)||ATt.test(t)||zTt.test(t)||wue(t)!==null||ZTt.test(t)||DTt.test(t)||VTt.test(t)||MTt.test(t)||LTt.test(t)||FTt.test(t)||BTt.test(t)||HTt.test(t)||KTt.test(t)||JTt.test(t)||e2t.test(t)&&t2t.test(t)||UTt.test(t)||WTt.test(t)?!1:NTt.filter(r=>r.test(t)).length>=YTt?!0:t.length>=GTt&&ITt.test(t)},NSe=q("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),YSe=q("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),GSe=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>h.jsxs("span",{className:q("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?YSe:NSe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(_se,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(kAe,{"aria-hidden":"true",className:"size-3 shrink-0"}),h.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&h.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&h.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:h.jsx(Ji,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),sy="#lo-credential/",r2t=`${sy}unstored`,vH=`${sy}unconfirmed`,i2t=/^\d+$/,ISe=e=>e.kind==="stored"?`${sy}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${vH}/${e.key}`:vH:r2t;function a2t(e){if(!e||!e.startsWith(sy))return null;const t=e.slice(sy.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return ZC.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!ZC.test(r)||!i2t.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function bH(e,t){const n=a2t(e);if(n===null)return null;const r=$P(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return ISe(i)!==e?null:n}const yP=()=>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=$P(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:ISe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},o2t=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?xTt(e.key):"Credential not stored",s2t=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?QTt(t):t,l2t=({citation:e,title:t})=>h.jsx(GSe,{tone:e.kind==="stored"?"live":"warning",label:o2t(e),chars:e.kind==="stored"?e.chars:null,title:s2t(e,t),className:"align-middle"}),c2t=(e,t)=>typeof t=="string"?bH(e,t):t==null?bH(e,""):null,u2t=e=>({href:t,title:n,children:r})=>{const i=c2t(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(l2t,{citation:i,title:n})},ZSe=e=>tet(e)?"artifact":e.startsWith("data:")?"data":e.startsWith("blob:")?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",DSe=e=>{const t=ZSe(e);return t==="other"?"path":t},wH={id:"open-file",label:"Open file"},O2t={id:"show-in-canvas",label:"Show in canvas"},d2t={id:"save-as",label:"Save as…"},SH={id:"open-folder",label:"Open folder"},xH={id:"copy-file-path",label:"Copy file path"},Gg={id:"copy-image",label:"Copy image"},f2t={id:"copy-image-url",label:"Copy image URL"},h2t={id:"open-in-browser",label:"Open in browser"};function VSe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[O2t]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[wH,SH,xH]:[],d2t,...r==="video"?[]:[Gg]];case"path":return[...o,wH,SH,xH,...r==="video"?[]:[Gg]];case"data":return[...o,Gg];case"blob":return[Gg];case"http":return[...p2t(n)?[Gg]:[],f2t,h2t];case"other":return[]}}const MSe=(e,t)=>VSe(e,t).length>0;function p2t(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 lU=e=>e.startsWith("file://")?e.slice(7):e;function m2t(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 QH(e,t,n){if(e==="data")return m2t(t);if(e==="blob"){const o=vde(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=lU(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:kz(i)})}const g2t=e=>e.trim().toLowerCase()!=="image/png";async function $2t(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!g2t(e.type))return e;const t=URL.createObjectURL(e);try{const n=await y2t(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 y2t(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 v2t=6e4;function b2t(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),v2t)}const N1=new Map;function w2t(e,t){const n=N1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await SO(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=_z(i.data,i.mimeType);return r.holders<=0?(Ov(a),null):(bde(t,a),a)}catch{return null}finally{N1.delete(t)}})(),N1.set(t,r),r.promise}class LSe extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function S2t(e,t){const n=Tz(t),r=n?vde(n):null;if(r)return r;const i=await SO(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")throw i.status===404?new LSe:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function x2t(e){const t=N1.get(e);t&&(t.holders-=1)}function FSe(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?Tz(e.attachment):null),[a,o]=$.useState(!1),s=t?.sessionId??null,l=t?.childId??null;$.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=yS(u);if(d)return i(d),o(!1),()=>{O=!1,vS(u)};i(null),o(!1);let f=!0;return w2t({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(yS(u))}}),()=>{O=!1,f&&x2t(u),vS(u)}},[e.attachment,n,s,l]);const c=n??r;return c?{state:"ready",url:c}:e.attachment&&s&&!a?{state:"resolving"}:{state:"missing"}}function BSe(e,t){return FSe(e,t)}const Q2t={"expand-image":h.jsx(Lce,{"aria-hidden":"true"}),"open-file":h.jsx(av,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(Mce,{"aria-hidden":"true"}),"save-as":h.jsx(iv,{"aria-hidden":"true"}),"open-folder":h.jsx(kp,{"aria-hidden":"true"}),"copy-file-path":h.jsx(Yce,{"aria-hidden":"true"}),"copy-image":h.jsx(ak,{"aria-hidden":"true"}),"copy-image-url":h.jsx(RAe,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Ice,{"aria-hidden":"true"})},kH=(e,t)=>t instanceof LSe?`${e}: it is no longer in the session`:e,HSe=({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:d,resolveBytes:f,tooltip:p="Image actions","aria-label":m})=>{const g=DSe(e),y=VSe(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(Q=>(Q.id!=="save-as"||!!d)&&(!l||Q.id==="copy-file-path"));if(y.length===0)return null;const v=async(Q,k,_)=>{try{await navigator.clipboard.writeText(Q),lf(k)}catch(R){console.error(`${_}: `,R),mi(_)}},S=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const Q=f?await f():await QH(g,e,t),k=await $2t(Q);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),lf("Image copied to clipboard")}catch(Q){console.error("Failed to copy image: ",Q),mi(kH("Failed to copy image",Q))}},x=async()=>{try{const Q=f?await f():await QH(g,e,t);b2t(Q,d??"download")}catch(Q){console.error("Failed to save file: ",Q),mi(kH("Failed to save file",Q))}},b=async Q=>{let k=lU(e);if(s&&["open-file","open-folder","copy-file-path"].includes(Q.id))try{k=await s()}catch{mi(H("ui.canvas.files.prepareError"));return}switch(Q.id){case"expand-image":O?.();return;case"open-file":jO(k);return;case"open-folder":iU(k);return;case"show-in-canvas":c?.();return;case"copy-file-path":v(k,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":S();return;case"save-as":x();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":aU(t??e);return}},w=m??`Actions for ${n??"this image"}`;return h.jsxs(iA,{open:r,onOpenChange:i,children:[h.jsx(Nt,{content:p,children:h.jsx(aA,{asChild:!0,children:h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:Q=>Q.stopPropagation(),children:h.jsx(aj,{"aria-hidden":"true"})})})}),h.jsxs(oA,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:Q=>Q.stopPropagation(),children:[s&&h.jsx("div",{role:"note",className:q("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:H("ui.canvas.files.pathCopyNote")}),y.map(Q=>h.jsxs(El,{onSelect:()=>b(Q),children:[Q2t[Q.id],h.jsx("span",{children:Q.label})]},Q.id))]})]})},k2t=({src:e,alt:t,title:n,className:r})=>{const i=hP(),a=e??"",o=ZSe(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=MSe(o,{canShowInCanvas:s,source:a});return h.jsxs("span",{className:q("group/mdimg relative inline-block max-w-full"),children:[h.jsx("img",{src:e,alt:t,title:n,className:r}),l&&h.jsx("span",{"data-markdown-image":"",className:q("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:h.jsx(HSe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||jO(lU(a))})}:void 0})})]})};function P2t(){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 _2t={tokenize:T2t,concrete:!0,name:"mathFlow"},PH={tokenize:R2t,partial:!0};function T2t(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(v){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(v)}function l(v){return v===36?(e.consume(v),o++,l):o<2?n(v):(e.exit("mathFlowFenceSequence"),an(e,c,"whitespace")(v))}function c(v){return v===null||xt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||xt(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(PH,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,f)(v)}function f(v){return(a?an(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):xt(v)?e.attempt(PH,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||xt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,S,x){let b=0;return an(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(_){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(_)}function Q(_){return _===36?(b++,v.consume(_),Q):b<o?x(_):(v.exit("mathFlowFenceSequence"),an(v,k,"whitespace")(_))}function k(_){return _===null||xt(_)?(v.exit("mathFlowFence"),S(_)):x(_)}}}function R2t(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 X2t(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:E2t,previous:q2t,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):xt(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),f(m))}function f(m){return m===null||m===32||m===36||xt(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),f)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",f(m))}}}function E2t(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 q2t(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function j2t(e){return{flow:{36:_2t},text:{36:X2t()}}}const Fh=36,_H=e=>e!==null&&e<-2,TH=e=>e===null||e===32||e<0,RH=e=>e!==null&&e>=48&&e<=57,KSe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:C2t,previous:A2t,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(g){return r.enter("mathText"),r.enter("mathTextSequence"),d(g)}function d(g){return g===Fh?(r.consume(g),s++,d):s<2&&!t||s===1&&(TH(g)||RH(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===Fh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):_H(g)?(r.enter("lineEnding"),r.consume(g),r.exit("lineEnding"),f):(r.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===Fh||_H(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===Fh?(r.consume(g),c++,m):c===s?s===1&&(TH(l)||RH(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function C2t(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 A2t(e){return e!==Fh||this.events[this.events.length-1][1].type==="characterEscape"}const z2t=j2t().flow,U2t=KSe();function vP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?U2t:KSe(e);n.push({flow:z2t,text:{[Fh]:i}}),r.push(P2t())}const W2t=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),N2t=/\$(?!\d)(.+?)\$/,Y2t=/\$\$([\s\S]+?)\$\$/,G2t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,I2t=/\\[a-zA-Z]+(\{[^}]*\})?/,XH=e=>N2t.test(e)||Y2t.test(e)||G2t.test(e)?!0:I2t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),Z2t=e=>{const t=$P(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},D2t=e=>$P(e).filter(t=>t.kind!=="text").length,V2t=e=>{if(!XH(e))return!1;const t=Z2t(e);return t===null?!0:XH(t)||t.includes("$")?!1:D2t(e)<2},Bt="var(--color-ink)",gc="var(--color-ink-muted)",bl="var(--color-surface)",Gu="var(--color-elevated)",$c="var(--color-sunken)",aa="var(--color-hairline)",Iu="var(--color-control)",Ph="var(--color-accent)",v0="var(--color-accent-wash)",M2t="var(--color-accent-alt-wash)",L2t="var(--color-on-accent)",F2t="var(--color-info)",JSe="var(--color-info-wash)",B2t="var(--color-success)",exe="var(--color-success-wash)",H2t="var(--color-warning)",MC="var(--color-warning-wash)",K2t="var(--color-warning-border)",H2="var(--color-danger)",LC="var(--color-danger-wash)",EH=[v0,M2t,JSe,exe,MC,LC],Zu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),J2t=()=>{const e={primaryColor:Zu("--color-accent"),secondaryColor:Zu("--color-success"),tertiaryColor:Zu("--color-info"),mainBkg:Zu("--color-elevated"),clusterBkg:Zu("--color-sunken"),clusterBorder:Zu("--color-hairline"),edgeLabelBackground:Zu("--color-surface"),quadrant1Fill:Zu("--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:bl,primaryTextColor:Bt,primaryBorderColor:Iu,secondaryTextColor:Bt,secondaryBorderColor:aa,tertiaryTextColor:Bt,tertiaryBorderColor:aa,lineColor:gc,arrowheadColor:gc,textColor:Bt,secondBkg:$c,border1:Iu,border2:aa,labelColor:Bt,nodeBkg:Gu,nodeBorder:Iu,nodeTextColor:Bt,defaultLinkColor:gc,titleColor:Bt,noteBkgColor:MC,noteBorderColor:K2t,noteTextColor:Bt,actorBkg:Gu,actorBorder:Iu,actorTextColor:Bt,actorLineColor:aa,signalColor:gc,signalTextColor:Bt,labelBoxBkgColor:Gu,labelBoxBorderColor:aa,labelTextColor:Bt,loopTextColor:Bt,activationBkgColor:v0,activationBorderColor:Ph,sequenceNumberColor:bl,sectionBkgColor:$c,sectionBkgColor2:bl,altSectionBkgColor:$c,excludeBkgColor:$c,taskBkgColor:v0,taskBorderColor:Iu,taskTextColor:Bt,taskTextLightColor:Bt,taskTextDarkColor:Bt,taskTextOutsideColor:Bt,taskTextClickableColor:Ph,activeTaskBkgColor:v0,activeTaskBorderColor:Ph,gridColor:aa,doneTaskBkgColor:$c,doneTaskBorderColor:aa,critBkgColor:LC,critBorderColor:H2,todayLineColor:Ph,transitionColor:gc,transitionLabelColor:Bt,stateLabelColor:Bt,stateBkg:Gu,labelBackgroundColor:bl,compositeBackground:$c,altBackground:$c,compositeTitleBackground:Gu,compositeBorder:aa,innerEndBackground:Bt,specialStateColor:Bt,classText:Bt,attributeBackgroundColorOdd:bl,attributeBackgroundColorEven:$c,rowOdd:bl,rowEven:$c,errorBkgColor:LC,errorTextColor:H2,pieTitleTextColor:Bt,pieSectionTextColor:Bt,pieLegendTextColor:Bt,pieStrokeColor:bl,pieOuterStrokeColor:aa,requirementBackground:Gu,requirementBorderColor:Iu,requirementTextColor:Bt,relationColor:gc,relationLabelBackground:bl,relationLabelColor:Bt,branchLabelColor:L2t,commitLabelColor:Bt,commitLabelBackground:bl,tagLabelColor:Bt,tagLabelBackground:v0,tagLabelBorder:Iu,quadrant2Fill:JSe,quadrant3Fill:exe,quadrant4Fill:MC,quadrant2TextFill:Bt,quadrant3TextFill:Bt,quadrant4TextFill:Bt,quadrantPointFill:Ph,archEdgeColor:gc,archEdgeArrowColor:gc,archGroupBorderColor:aa,scaleLabelColor:Bt,packet:{startByteColor:Bt,endByteColor:Bt,labelColor:Bt,titleColor:Bt,blockStrokeColor:Iu,blockFillColor:Gu},radar:{axisColor:gc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:aa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:bl,titleColor:Bt,xAxisTitleColor:Bt,xAxisLabelColor:Bt,xAxisTickColor:aa,xAxisLineColor:aa,yAxisTitleColor:Bt,yAxisLabelColor:Bt,yAxisTickColor:aa,yAxisLineColor:aa,plotColorPalette:[Ph,F2t,B2t,H2t,H2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Gu,t[`surfacePeer${n}`]=aa;for(let n=0;n<8;n++)t[`fillType${n}`]=EH[n%EH.length];return{...t,...e}};let K2=null,qH=null;const eRt=async e=>{K2||(K2=ve(async()=>{const{default:n}=await import("./mermaid.core-kSHzKq9G.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,1,2]),import.meta.url).then(({default:n})=>n));const t=await K2;return qH!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:J2t()}),qH=e),t},jH=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:q("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(Nt,{content:"Zoom in",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(aue,{})})}),h.jsx(Nt,{content:"Zoom out",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(oue,{})})}),h.jsx(Nt,{content:"Drag the diagram to pan",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(LAe,{})})}),h.jsx(Nt,{content:"Reset view",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(sk,{})})}),h.jsx(Nt,{content:"Save as SVG",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(iv,{})})}),h.jsx(Nt,{content:t?"Copied":"Copy mermaid text",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(ak,{className:q(t&&"text-success")})})}),s]}),FC=({title:e,children:t})=>h.jsxs(Vl,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(P0,{children:e}),h.jsx(_0,{children:t})]});class tRt 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||h.jsxs(FC,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const nRt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,f]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,S]=$.useState({x:0,y:0}),[x,b]=$.useState("idle"),[w,Q]=$.useState("idle"),k=er(U=>U.themeName),_=$.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 U=await eRt(k),te=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:D}=await U.render(te,e);if(!D||typeof D!="string"||D.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(D)}catch(U){console.error("Mermaid rendering error:",U);const te=U instanceof Error?U.message:"Failed to render mermaid diagram";a(te),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{_().catch(U=>{console.error("Error in renderDiagram effect:",U),a("Failed to initialize diagram rendering"),s(!1)})},[_]);const R=$.useCallback(()=>{try{if(!l||!r.current)return 1;const te=r.current.getBoundingClientRect(),D=document.createElement("div");D.innerHTML=l;const B=D.querySelector("svg");if(!B)return 1;const he=B.getBoundingClientRect?.()?.width||Number.parseFloat(B.getAttribute("width")||"0")||B.viewBox?.baseVal?.width||800,M=B.getBoundingClientRect?.()?.height||Number.parseFloat(B.getAttribute("height")||"0")||B.viewBox?.baseVal?.height||600,ee=te.width*.9/he,ne=te.height*.9/M;return Math.min(ee,ne,1)}catch(U){return console.error("Error calculating fullscreen scale:",U),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const U=R();m({scale:U,x:0,y:0})}catch(U){console.error("Error setting fullscreen transform:",U)}},100)},[u,l,R]);const E=$.useCallback((U=!1)=>{try{(U?m:f)(D=>({...D,scale:Math.min(D.scale*1.2,10)}))}catch(te){console.error("Error in zoom in:",te)}},[]),T=$.useCallback((U=!1)=>{try{(U?m:f)(D=>({...D,scale:Math.max(D.scale/1.2,.1)}))}catch(te){console.error("Error in zoom out:",te)}},[]),j=$.useCallback((U=!1)=>{try{const te=U?m:f;if(U){const D=R();te({scale:D,x:0,y:0})}else te({scale:1,x:0,y:0})}catch(te){console.error("Error in reset:",te)}},[R]),C=$.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),te=URL.createObjectURL(U),D=document.createElement("a");D.href=te,D.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(te)}catch(U){console.error("Failed to save SVG:",U)}},[l]),W=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),G=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),N=$.useCallback(U=>{try{y(!0),S({x:U.clientX,y:U.clientY}),U.preventDefault()}catch(te){console.error("Error in mouse down:",te)}},[]),V=$.useCallback((U,te=!1)=>{try{if(!g)return;const D=U.clientX-v.x,B=U.clientY-v.y;(te?m:f)(M=>({...M,x:M.x+D,y:M.y+B})),S({x:U.clientX,y:U.clientY})}catch(D){console.error("Error in mouse move:",D)}},[g,v]),F=$.useCallback(()=>{try{y(!1)}catch(U){console.error("Error in mouse up:",U)}},[]),z=$.useCallback((U,te=!1)=>{try{U.preventDefault();const D=U.deltaY>0?.9:1.1;(te?m:f)(he=>({...he,scale:Math.min(Math.max(he.scale*D,.1),5)}))}catch(D){console.error("Error in wheel:",D)}},[]),Z=$.useCallback(U=>{try{O(U)}catch(te){console.error("Error toggling fullscreen:",te)}},[]);if(i)return h.jsxs(FC,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:q("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:q("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(U=!1)=>{try{const te=U?r:n,D=U?p:d;return h.jsx("div",{ref:te,className:q("mermaid flex w-full items-center justify-center",U?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:N,onMouseMove:B=>V(B,U),onMouseUp:F,onMouseLeave:F,onWheel:B=>z(B,U),children:o?h.jsx("div",{className:q("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:q("flex h-full w-full items-center justify-center"),style:{transform:`translate(${D.x}px, ${D.y}px) scale(${D.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(te){return console.error("Error rendering diagram content:",te),h.jsx(FC,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:q("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:[J(!1),h.jsx(jH,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>T(!1),onReset:()=>j(!1),onSave:C,onCopy:W,children:h.jsx(Nt,{content:"Fullscreen",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>Z(!0),children:h.jsx(Lce,{})})})})]}),h.jsx(w$,{open:u,onClose:()=>Z(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:q("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:[J(!0),h.jsx(jH,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>T(!0),onReset:()=>j(!0),onSave:C,onCopy:G,children:h.jsx(Nt,{content:"Close fullscreen",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>Z(!1),children:h.jsx(Ji,{})})})})]})})]})}),rRt=$.memo(e=>h.jsx(tRt,{children:h.jsx(nRt,{...e})}));let txe=!1,J2=null;const iRt=()=>(J2||(J2=ve(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(txe=!0,e))),J2),aRt=/language-(\w+)/,oRt=ZQ,sRt=new RegExp(`^[^${va}\\d*+-]`),lRt=/\n$/,nxe=({href:e,children:t})=>{const n=iSe(e),r=hP();return!n||n.kind==="other"?h.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):h.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=>ORt(i,r):void 0,children:t})},cRt=e=>iSe(e)?.kind==="file",uRt=cSe,ORt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(lSe)??"file",i=n.getAttribute(uRt),a=D_t({kind:r,hasHighlight:o5t(n),canOpenInCanvas:rU(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||jO(i)});return}jO(i)}},BC=(e,t)=>t==="href"&&cRt(e)?e:kfe(e),ly={a:nxe,table:W2t,img:k2t,code:({node:e,className:t,children:n,...r})=>aRt.exec(t??"")?.[1]==="mermaid"?h.jsx(rRt,{chart:String(n).replace(lRt,"")}):h.jsx("code",{className:t,...r,children:n})},dRt={...ly,a:u2t(nxe)},fRt=[NO],hRt=[NO,vP],pRt=[NO,pP],mRt=[NO,vP,pP],gRt=[NO,yP,mP],$Rt=[NO,vP,yP,mP],yRt=[NO,pP,yP,mP],vRt=[NO,vP,pP,yP,mP],bRt={"000":fRt,"001":gRt,"010":pRt,"011":yRt,100:hRt,101:$Rt,110:mRt,111:vRt},wRt=[],SRt=[IHe],rxe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),ixe=(e,t,n)=>{const r=$.useMemo(()=>V2t(e),[e]),[i,a]=$.useState(txe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return iRt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:bRt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?SRt:wRt}},axe=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=ket(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=M_t(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return sSe(r,window.api?.probeFiles,xse).then(()=>{i&&r.some(s=>oSe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},cy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=ixe(a,r,i),l=rxe(t);return axe(a,r),h.jsx("div",{className:q("lo-markdown",n),style:l,children:h.jsx(Uj,{remarkPlugins:o,rehypePlugins:s,urlTransform:BC,components:i?dRt:ly,children:a})})});cy.displayName="MarkdownRenderer";const CH={...ly,a:({children:e})=>h.jsx(h.Fragment,{children:e})},oxe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:oH(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=wSe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=ixe(n,t,!1);if(axe(e,t),r!==null){const o=oH(r.before);return h.jsxs(h.Fragment,{children:[o.trim()!==""&&h.jsx(Uj,{remarkPlugins:i,rehypePlugins:a,urlTransform:BC,components:t?ly:CH,children:o}),h.jsx(xRt,{info:r.info,body:r.body})]})}return h.jsx(Uj,{remarkPlugins:i,rehypePlugins:a,urlTransform:BC,components:t?ly:CH,children:n})});oxe.displayName="ParsedBlock";const xRt=({info:e,body:t})=>{const n=e.split(oRt)[0];return h.jsx("pre",{children:h.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
|
|
860
|
+
`)&&(s={capture:Sx(e),buffer:n,caret:r})}return{...s,capture:Lh(s.capture,s.buffer,s.caret,i)}}function nTt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Bf(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=CSe(i,t.value),c=l+gP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ja,buffer:u,caret:s+c.length,payload:{index:i,key:WSe(a,e.draw),value:t.value,marker:l}}}function rTt(e,t){const n=Bf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=USe(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ja,buffer:i,caret:n.start+r.length,restored:DC(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:DC(r),restoredText:r}}}function fH(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function iTt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Bf(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:Sx(e),buffer:i,caret:a,payload:null}}function aTt(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=sU(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=nn(i);if(!a)return i===""?null:iTt(t,n,e.selection,i);const o=t.arm,s=CSe(e.index,a),l=s+gP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ja,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:WSe(e.taken,e.draw),value:a,marker:s}}}const jSe=e=>`${DC(e)} chars`,CSe=(e,t)=>`[Credential #${e}, ${jSe(t)}]`;function oTt(e){Il.lastIndex=0;const t=Il.exec(e);return Il.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function sTt(e){Il.lastIndex=0;const t=Il.exec(e);if(Il.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 zv(e,t){if(oTt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const L2=/\[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,F2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,B2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,lTt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&ZC.test(t[1])?t[1]:""};function cTt(e,t){if(e.charCodeAt(t)!==91)return null;L2.lastIndex=t;const n=L2.exec(e);if(L2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};F2.lastIndex=t;const r=F2.exec(e);if(F2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};B2.lastIndex=t;const i=B2.exec(e);return B2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:lTt(i[0])}:null}function $P(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=cTt(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 hH(e,t){const n=[];for(const r of t){const i=zv(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 uTt(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 OTt=e=>`[credential ${e.key} (${jSe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function dTt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=zv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of RSe(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?uTt(l??"lost",s?.key):OTt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const fTt=(e,t,n)=>`Removed ${e} (credential #${t}) from this message. Its value is gone — press ${n} to put it back, or paste it again after /credential to reuse it.`,hTt=e=>`Remove credential #${e}`,pTt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,mTt=(e,t,n)=>fTt(e,t,n),gTt="Undo",$Tt=e=>`Credential #${e} removed`,yTt=e=>e.unredacted!==null?e.unredacted:e.armed?kTt:e.cleared!==null?mTt(e.cleared.key,e.cleared.index,e.undoCap):null;function vTt(e){const{buffer:t,payload:n}=e,r=zv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===gP?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 bTt(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 pH=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function mH(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be stored (${[...e].sort().join(", ")}); the agent has been told so. Paste the value again after /credential to retry.`}const wTt="store unconfirmed",STt="Credential store unconfirmed",xTt=e=>e===""?STt:`${e} · ${wTt}`,ASe="Paste the value again after /credential to store it again.",QTt=e=>`${e} ${ASe}`;function gH(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be confirmed as stored (${[...e].sort().join(", ")}); the agent has been told to check before using it. ${ASe}`}const kTt="armed — add a space, then type or paste the secret",PTt="masked as you type — Enter turns it into a pill, Esc cancels",_Tt="masked — Enter opens the credential picker; type or paste the secret into this span",TTt="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",zSe="\0held",RTt=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===zSe?`${e} characters are now PLAIN TEXT in the composer — Enter is held: clear the box to release your words`:`${e} characters are now PLAIN TEXT in the composer — Enter will take them as /${t}'s argument, not send them`;function USe(e,t){const n=Bf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const $H=(e,t)=>e&&e.over===t?e.chars:null,XTt=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},ETt=16,qTt=16;function WSe(e=[],t=XTt){const n=new Set(e);for(let r=0;r<ETt;r++){const i=uH+yH(8,t);if(!n.has(i))return i}return uH+yH(qTt,t)}const yH=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=cH[t(cH.length)];return n},jTt=8,CTt=256,ATt=/^[/@$#]/,zTt=/^\w+:\/\//,UTt=/^[A-Za-z]+$/,WTt=/^\d+$/,NTt=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],YTt=3,GTt=20,ITt=/^[A-Za-z0-9_\-+/=.]+$/,ZTt=new RegExp(`^[^${va}@]+@[^${va}@]+\\.[A-Za-z]{2,}$`),DTt=/^[\w.-]+(?:\/[\w.-]+)+$/,VTt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,MTt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,LTt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,FTt=/^[\w.-]+:\d{2,5}$/,BTt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,HTt=/^[a-z]+(?:_[a-z]+)+$/,KTt=/^[a-z]+(?:-[a-z]+)+$/,JTt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,e2t=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,t2t=/\d{4,}/,n2t=e=>{const t=e.trim();return t.length<jTt||t.length>CTt||No.test(t)||ATt.test(t)||zTt.test(t)||wue(t)!==null||ZTt.test(t)||DTt.test(t)||VTt.test(t)||MTt.test(t)||LTt.test(t)||FTt.test(t)||BTt.test(t)||HTt.test(t)||KTt.test(t)||JTt.test(t)||e2t.test(t)&&t2t.test(t)||UTt.test(t)||WTt.test(t)?!1:NTt.filter(r=>r.test(t)).length>=YTt?!0:t.length>=GTt&&ITt.test(t)},NSe=q("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),YSe=q("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),GSe=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>h.jsxs("span",{className:q("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?YSe:NSe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(_se,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(kAe,{"aria-hidden":"true",className:"size-3 shrink-0"}),h.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&h.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&h.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:h.jsx(Ji,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),sy="#lo-credential/",r2t=`${sy}unstored`,vH=`${sy}unconfirmed`,i2t=/^\d+$/,ISe=e=>e.kind==="stored"?`${sy}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${vH}/${e.key}`:vH:r2t;function a2t(e){if(!e||!e.startsWith(sy))return null;const t=e.slice(sy.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return ZC.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!ZC.test(r)||!i2t.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function bH(e,t){const n=a2t(e);if(n===null)return null;const r=$P(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return ISe(i)!==e?null:n}const yP=()=>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=$P(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:ISe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},o2t=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?xTt(e.key):"Credential not stored",s2t=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?QTt(t):t,l2t=({citation:e,title:t})=>h.jsx(GSe,{tone:e.kind==="stored"?"live":"warning",label:o2t(e),chars:e.kind==="stored"?e.chars:null,title:s2t(e,t),className:"align-middle"}),c2t=(e,t)=>typeof t=="string"?bH(e,t):t==null?bH(e,""):null,u2t=e=>({href:t,title:n,children:r})=>{const i=c2t(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(l2t,{citation:i,title:n})},ZSe=e=>tet(e)?"artifact":e.startsWith("data:")?"data":e.startsWith("blob:")?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",DSe=e=>{const t=ZSe(e);return t==="other"?"path":t},wH={id:"open-file",label:"Open file"},O2t={id:"show-in-canvas",label:"Show in canvas"},d2t={id:"save-as",label:"Save as…"},SH={id:"open-folder",label:"Open folder"},xH={id:"copy-file-path",label:"Copy file path"},Gg={id:"copy-image",label:"Copy image"},f2t={id:"copy-image-url",label:"Copy image URL"},h2t={id:"open-in-browser",label:"Open in browser"};function VSe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[O2t]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[wH,SH,xH]:[],d2t,...r==="video"?[]:[Gg]];case"path":return[...o,wH,SH,xH,...r==="video"?[]:[Gg]];case"data":return[...o,Gg];case"blob":return[Gg];case"http":return[...p2t(n)?[Gg]:[],f2t,h2t];case"other":return[]}}const MSe=(e,t)=>VSe(e,t).length>0;function p2t(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 lU=e=>e.startsWith("file://")?e.slice(7):e;function m2t(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 QH(e,t,n){if(e==="data")return m2t(t);if(e==="blob"){const o=vde(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=lU(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:kz(i)})}const g2t=e=>e.trim().toLowerCase()!=="image/png";async function $2t(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!g2t(e.type))return e;const t=URL.createObjectURL(e);try{const n=await y2t(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 y2t(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 v2t=6e4;function b2t(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),v2t)}const N1=new Map;function w2t(e,t){const n=N1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await SO(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=_z(i.data,i.mimeType);return r.holders<=0?(Ov(a),null):(bde(t,a),a)}catch{return null}finally{N1.delete(t)}})(),N1.set(t,r),r.promise}class LSe extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function S2t(e,t){const n=Tz(t),r=n?vde(n):null;if(r)return r;const i=await SO(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")throw i.status===404?new LSe:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function x2t(e){const t=N1.get(e);t&&(t.holders-=1)}function FSe(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?Tz(e.attachment):null),[a,o]=$.useState(!1),s=t?.sessionId??null,l=t?.childId??null;$.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=yS(u);if(d)return i(d),o(!1),()=>{O=!1,vS(u)};i(null),o(!1);let f=!0;return w2t({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(yS(u))}}),()=>{O=!1,f&&x2t(u),vS(u)}},[e.attachment,n,s,l]);const c=n??r;return c?{state:"ready",url:c}:e.attachment&&s&&!a?{state:"resolving"}:{state:"missing"}}function BSe(e,t){return FSe(e,t)}const Q2t={"expand-image":h.jsx(Lce,{"aria-hidden":"true"}),"open-file":h.jsx(av,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(Mce,{"aria-hidden":"true"}),"save-as":h.jsx(iv,{"aria-hidden":"true"}),"open-folder":h.jsx(kp,{"aria-hidden":"true"}),"copy-file-path":h.jsx(Yce,{"aria-hidden":"true"}),"copy-image":h.jsx(ak,{"aria-hidden":"true"}),"copy-image-url":h.jsx(RAe,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Ice,{"aria-hidden":"true"})},kH=(e,t)=>t instanceof LSe?`${e}: it is no longer in the session`:e,HSe=({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:d,resolveBytes:f,tooltip:p="Image actions","aria-label":m})=>{const g=DSe(e),y=VSe(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(Q=>(Q.id!=="save-as"||!!d)&&(!l||Q.id==="copy-file-path"));if(y.length===0)return null;const v=async(Q,k,_)=>{try{await navigator.clipboard.writeText(Q),lf(k)}catch(R){console.error(`${_}: `,R),mi(_)}},S=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const Q=f?await f():await QH(g,e,t),k=await $2t(Q);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),lf("Image copied to clipboard")}catch(Q){console.error("Failed to copy image: ",Q),mi(kH("Failed to copy image",Q))}},x=async()=>{try{const Q=f?await f():await QH(g,e,t);b2t(Q,d??"download")}catch(Q){console.error("Failed to save file: ",Q),mi(kH("Failed to save file",Q))}},b=async Q=>{let k=lU(e);if(s&&["open-file","open-folder","copy-file-path"].includes(Q.id))try{k=await s()}catch{mi(H("ui.canvas.files.prepareError"));return}switch(Q.id){case"expand-image":O?.();return;case"open-file":jO(k);return;case"open-folder":iU(k);return;case"show-in-canvas":c?.();return;case"copy-file-path":v(k,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":S();return;case"save-as":x();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":aU(t??e);return}},w=m??`Actions for ${n??"this image"}`;return h.jsxs(iA,{open:r,onOpenChange:i,children:[h.jsx(Nt,{content:p,children:h.jsx(aA,{asChild:!0,children:h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:Q=>Q.stopPropagation(),children:h.jsx(aj,{"aria-hidden":"true"})})})}),h.jsxs(oA,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:Q=>Q.stopPropagation(),children:[s&&h.jsx("div",{role:"note",className:q("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:H("ui.canvas.files.pathCopyNote")}),y.map(Q=>h.jsxs(El,{onSelect:()=>b(Q),children:[Q2t[Q.id],h.jsx("span",{children:Q.label})]},Q.id))]})]})},k2t=({src:e,alt:t,title:n,className:r})=>{const i=hP(),a=e??"",o=ZSe(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=MSe(o,{canShowInCanvas:s,source:a});return h.jsxs("span",{className:q("group/mdimg relative inline-block max-w-full"),children:[h.jsx("img",{src:e,alt:t,title:n,className:r}),l&&h.jsx("span",{"data-markdown-image":"",className:q("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:h.jsx(HSe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||jO(lU(a))})}:void 0})})]})};function P2t(){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 _2t={tokenize:T2t,concrete:!0,name:"mathFlow"},PH={tokenize:R2t,partial:!0};function T2t(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(v){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(v)}function l(v){return v===36?(e.consume(v),o++,l):o<2?n(v):(e.exit("mathFlowFenceSequence"),an(e,c,"whitespace")(v))}function c(v){return v===null||xt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||xt(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(PH,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,f)(v)}function f(v){return(a?an(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):xt(v)?e.attempt(PH,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||xt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,S,x){let b=0;return an(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(_){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(_)}function Q(_){return _===36?(b++,v.consume(_),Q):b<o?x(_):(v.exit("mathFlowFenceSequence"),an(v,k,"whitespace")(_))}function k(_){return _===null||xt(_)?(v.exit("mathFlowFence"),S(_)):x(_)}}}function R2t(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 X2t(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:E2t,previous:q2t,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):xt(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),f(m))}function f(m){return m===null||m===32||m===36||xt(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),f)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",f(m))}}}function E2t(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 q2t(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function j2t(e){return{flow:{36:_2t},text:{36:X2t()}}}const Fh=36,_H=e=>e!==null&&e<-2,TH=e=>e===null||e===32||e<0,RH=e=>e!==null&&e>=48&&e<=57,KSe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:C2t,previous:A2t,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(g){return r.enter("mathText"),r.enter("mathTextSequence"),d(g)}function d(g){return g===Fh?(r.consume(g),s++,d):s<2&&!t||s===1&&(TH(g)||RH(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===Fh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):_H(g)?(r.enter("lineEnding"),r.consume(g),r.exit("lineEnding"),f):(r.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===Fh||_H(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===Fh?(r.consume(g),c++,m):c===s?s===1&&(TH(l)||RH(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function C2t(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 A2t(e){return e!==Fh||this.events[this.events.length-1][1].type==="characterEscape"}const z2t=j2t().flow,U2t=KSe();function vP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?U2t:KSe(e);n.push({flow:z2t,text:{[Fh]:i}}),r.push(P2t())}const W2t=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),N2t=/\$(?!\d)(.+?)\$/,Y2t=/\$\$([\s\S]+?)\$\$/,G2t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,I2t=/\\[a-zA-Z]+(\{[^}]*\})?/,XH=e=>N2t.test(e)||Y2t.test(e)||G2t.test(e)?!0:I2t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),Z2t=e=>{const t=$P(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},D2t=e=>$P(e).filter(t=>t.kind!=="text").length,V2t=e=>{if(!XH(e))return!1;const t=Z2t(e);return t===null?!0:XH(t)||t.includes("$")?!1:D2t(e)<2},Bt="var(--color-ink)",gc="var(--color-ink-muted)",bl="var(--color-surface)",Gu="var(--color-elevated)",$c="var(--color-sunken)",aa="var(--color-hairline)",Iu="var(--color-control)",Ph="var(--color-accent)",v0="var(--color-accent-wash)",M2t="var(--color-accent-alt-wash)",L2t="var(--color-on-accent)",F2t="var(--color-info)",JSe="var(--color-info-wash)",B2t="var(--color-success)",exe="var(--color-success-wash)",H2t="var(--color-warning)",MC="var(--color-warning-wash)",K2t="var(--color-warning-border)",H2="var(--color-danger)",LC="var(--color-danger-wash)",EH=[v0,M2t,JSe,exe,MC,LC],Zu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),J2t=()=>{const e={primaryColor:Zu("--color-accent"),secondaryColor:Zu("--color-success"),tertiaryColor:Zu("--color-info"),mainBkg:Zu("--color-elevated"),clusterBkg:Zu("--color-sunken"),clusterBorder:Zu("--color-hairline"),edgeLabelBackground:Zu("--color-surface"),quadrant1Fill:Zu("--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:bl,primaryTextColor:Bt,primaryBorderColor:Iu,secondaryTextColor:Bt,secondaryBorderColor:aa,tertiaryTextColor:Bt,tertiaryBorderColor:aa,lineColor:gc,arrowheadColor:gc,textColor:Bt,secondBkg:$c,border1:Iu,border2:aa,labelColor:Bt,nodeBkg:Gu,nodeBorder:Iu,nodeTextColor:Bt,defaultLinkColor:gc,titleColor:Bt,noteBkgColor:MC,noteBorderColor:K2t,noteTextColor:Bt,actorBkg:Gu,actorBorder:Iu,actorTextColor:Bt,actorLineColor:aa,signalColor:gc,signalTextColor:Bt,labelBoxBkgColor:Gu,labelBoxBorderColor:aa,labelTextColor:Bt,loopTextColor:Bt,activationBkgColor:v0,activationBorderColor:Ph,sequenceNumberColor:bl,sectionBkgColor:$c,sectionBkgColor2:bl,altSectionBkgColor:$c,excludeBkgColor:$c,taskBkgColor:v0,taskBorderColor:Iu,taskTextColor:Bt,taskTextLightColor:Bt,taskTextDarkColor:Bt,taskTextOutsideColor:Bt,taskTextClickableColor:Ph,activeTaskBkgColor:v0,activeTaskBorderColor:Ph,gridColor:aa,doneTaskBkgColor:$c,doneTaskBorderColor:aa,critBkgColor:LC,critBorderColor:H2,todayLineColor:Ph,transitionColor:gc,transitionLabelColor:Bt,stateLabelColor:Bt,stateBkg:Gu,labelBackgroundColor:bl,compositeBackground:$c,altBackground:$c,compositeTitleBackground:Gu,compositeBorder:aa,innerEndBackground:Bt,specialStateColor:Bt,classText:Bt,attributeBackgroundColorOdd:bl,attributeBackgroundColorEven:$c,rowOdd:bl,rowEven:$c,errorBkgColor:LC,errorTextColor:H2,pieTitleTextColor:Bt,pieSectionTextColor:Bt,pieLegendTextColor:Bt,pieStrokeColor:bl,pieOuterStrokeColor:aa,requirementBackground:Gu,requirementBorderColor:Iu,requirementTextColor:Bt,relationColor:gc,relationLabelBackground:bl,relationLabelColor:Bt,branchLabelColor:L2t,commitLabelColor:Bt,commitLabelBackground:bl,tagLabelColor:Bt,tagLabelBackground:v0,tagLabelBorder:Iu,quadrant2Fill:JSe,quadrant3Fill:exe,quadrant4Fill:MC,quadrant2TextFill:Bt,quadrant3TextFill:Bt,quadrant4TextFill:Bt,quadrantPointFill:Ph,archEdgeColor:gc,archEdgeArrowColor:gc,archGroupBorderColor:aa,scaleLabelColor:Bt,packet:{startByteColor:Bt,endByteColor:Bt,labelColor:Bt,titleColor:Bt,blockStrokeColor:Iu,blockFillColor:Gu},radar:{axisColor:gc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:aa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:bl,titleColor:Bt,xAxisTitleColor:Bt,xAxisLabelColor:Bt,xAxisTickColor:aa,xAxisLineColor:aa,yAxisTitleColor:Bt,yAxisLabelColor:Bt,yAxisTickColor:aa,yAxisLineColor:aa,plotColorPalette:[Ph,F2t,B2t,H2t,H2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Gu,t[`surfacePeer${n}`]=aa;for(let n=0;n<8;n++)t[`fillType${n}`]=EH[n%EH.length];return{...t,...e}};let K2=null,qH=null;const eRt=async e=>{K2||(K2=ve(async()=>{const{default:n}=await import("./mermaid.core-C14g_ZP7.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,1,2]),import.meta.url).then(({default:n})=>n));const t=await K2;return qH!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:J2t()}),qH=e),t},jH=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:q("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(Nt,{content:"Zoom in",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(aue,{})})}),h.jsx(Nt,{content:"Zoom out",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(oue,{})})}),h.jsx(Nt,{content:"Drag the diagram to pan",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(LAe,{})})}),h.jsx(Nt,{content:"Reset view",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(sk,{})})}),h.jsx(Nt,{content:"Save as SVG",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(iv,{})})}),h.jsx(Nt,{content:t?"Copied":"Copy mermaid text",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(ak,{className:q(t&&"text-success")})})}),s]}),FC=({title:e,children:t})=>h.jsxs(Vl,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(P0,{children:e}),h.jsx(_0,{children:t})]});class tRt 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||h.jsxs(FC,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const nRt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,f]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,S]=$.useState({x:0,y:0}),[x,b]=$.useState("idle"),[w,Q]=$.useState("idle"),k=er(U=>U.themeName),_=$.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 U=await eRt(k),te=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:D}=await U.render(te,e);if(!D||typeof D!="string"||D.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(D)}catch(U){console.error("Mermaid rendering error:",U);const te=U instanceof Error?U.message:"Failed to render mermaid diagram";a(te),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{_().catch(U=>{console.error("Error in renderDiagram effect:",U),a("Failed to initialize diagram rendering"),s(!1)})},[_]);const R=$.useCallback(()=>{try{if(!l||!r.current)return 1;const te=r.current.getBoundingClientRect(),D=document.createElement("div");D.innerHTML=l;const B=D.querySelector("svg");if(!B)return 1;const he=B.getBoundingClientRect?.()?.width||Number.parseFloat(B.getAttribute("width")||"0")||B.viewBox?.baseVal?.width||800,M=B.getBoundingClientRect?.()?.height||Number.parseFloat(B.getAttribute("height")||"0")||B.viewBox?.baseVal?.height||600,ee=te.width*.9/he,ne=te.height*.9/M;return Math.min(ee,ne,1)}catch(U){return console.error("Error calculating fullscreen scale:",U),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const U=R();m({scale:U,x:0,y:0})}catch(U){console.error("Error setting fullscreen transform:",U)}},100)},[u,l,R]);const E=$.useCallback((U=!1)=>{try{(U?m:f)(D=>({...D,scale:Math.min(D.scale*1.2,10)}))}catch(te){console.error("Error in zoom in:",te)}},[]),T=$.useCallback((U=!1)=>{try{(U?m:f)(D=>({...D,scale:Math.max(D.scale/1.2,.1)}))}catch(te){console.error("Error in zoom out:",te)}},[]),j=$.useCallback((U=!1)=>{try{const te=U?m:f;if(U){const D=R();te({scale:D,x:0,y:0})}else te({scale:1,x:0,y:0})}catch(te){console.error("Error in reset:",te)}},[R]),C=$.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),te=URL.createObjectURL(U),D=document.createElement("a");D.href=te,D.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(te)}catch(U){console.error("Failed to save SVG:",U)}},[l]),W=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),G=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),N=$.useCallback(U=>{try{y(!0),S({x:U.clientX,y:U.clientY}),U.preventDefault()}catch(te){console.error("Error in mouse down:",te)}},[]),V=$.useCallback((U,te=!1)=>{try{if(!g)return;const D=U.clientX-v.x,B=U.clientY-v.y;(te?m:f)(M=>({...M,x:M.x+D,y:M.y+B})),S({x:U.clientX,y:U.clientY})}catch(D){console.error("Error in mouse move:",D)}},[g,v]),F=$.useCallback(()=>{try{y(!1)}catch(U){console.error("Error in mouse up:",U)}},[]),z=$.useCallback((U,te=!1)=>{try{U.preventDefault();const D=U.deltaY>0?.9:1.1;(te?m:f)(he=>({...he,scale:Math.min(Math.max(he.scale*D,.1),5)}))}catch(D){console.error("Error in wheel:",D)}},[]),Z=$.useCallback(U=>{try{O(U)}catch(te){console.error("Error toggling fullscreen:",te)}},[]);if(i)return h.jsxs(FC,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:q("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:q("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(U=!1)=>{try{const te=U?r:n,D=U?p:d;return h.jsx("div",{ref:te,className:q("mermaid flex w-full items-center justify-center",U?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:N,onMouseMove:B=>V(B,U),onMouseUp:F,onMouseLeave:F,onWheel:B=>z(B,U),children:o?h.jsx("div",{className:q("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:q("flex h-full w-full items-center justify-center"),style:{transform:`translate(${D.x}px, ${D.y}px) scale(${D.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(te){return console.error("Error rendering diagram content:",te),h.jsx(FC,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:q("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:[J(!1),h.jsx(jH,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>T(!1),onReset:()=>j(!1),onSave:C,onCopy:W,children:h.jsx(Nt,{content:"Fullscreen",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>Z(!0),children:h.jsx(Lce,{})})})})]}),h.jsx(w$,{open:u,onClose:()=>Z(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:q("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:[J(!0),h.jsx(jH,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>T(!0),onReset:()=>j(!0),onSave:C,onCopy:G,children:h.jsx(Nt,{content:"Close fullscreen",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>Z(!1),children:h.jsx(Ji,{})})})})]})})]})}),rRt=$.memo(e=>h.jsx(tRt,{children:h.jsx(nRt,{...e})}));let txe=!1,J2=null;const iRt=()=>(J2||(J2=ve(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(txe=!0,e))),J2),aRt=/language-(\w+)/,oRt=ZQ,sRt=new RegExp(`^[^${va}\\d*+-]`),lRt=/\n$/,nxe=({href:e,children:t})=>{const n=iSe(e),r=hP();return!n||n.kind==="other"?h.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):h.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=>ORt(i,r):void 0,children:t})},cRt=e=>iSe(e)?.kind==="file",uRt=cSe,ORt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(lSe)??"file",i=n.getAttribute(uRt),a=D_t({kind:r,hasHighlight:o5t(n),canOpenInCanvas:rU(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||jO(i)});return}jO(i)}},BC=(e,t)=>t==="href"&&cRt(e)?e:kfe(e),ly={a:nxe,table:W2t,img:k2t,code:({node:e,className:t,children:n,...r})=>aRt.exec(t??"")?.[1]==="mermaid"?h.jsx(rRt,{chart:String(n).replace(lRt,"")}):h.jsx("code",{className:t,...r,children:n})},dRt={...ly,a:u2t(nxe)},fRt=[NO],hRt=[NO,vP],pRt=[NO,pP],mRt=[NO,vP,pP],gRt=[NO,yP,mP],$Rt=[NO,vP,yP,mP],yRt=[NO,pP,yP,mP],vRt=[NO,vP,pP,yP,mP],bRt={"000":fRt,"001":gRt,"010":pRt,"011":yRt,100:hRt,101:$Rt,110:mRt,111:vRt},wRt=[],SRt=[IHe],rxe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),ixe=(e,t,n)=>{const r=$.useMemo(()=>V2t(e),[e]),[i,a]=$.useState(txe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return iRt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:bRt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?SRt:wRt}},axe=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=ket(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=M_t(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return sSe(r,window.api?.probeFiles,xse).then(()=>{i&&r.some(s=>oSe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},cy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=ixe(a,r,i),l=rxe(t);return axe(a,r),h.jsx("div",{className:q("lo-markdown",n),style:l,children:h.jsx(Uj,{remarkPlugins:o,rehypePlugins:s,urlTransform:BC,components:i?dRt:ly,children:a})})});cy.displayName="MarkdownRenderer";const CH={...ly,a:({children:e})=>h.jsx(h.Fragment,{children:e})},oxe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:oH(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=wSe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=ixe(n,t,!1);if(axe(e,t),r!==null){const o=oH(r.before);return h.jsxs(h.Fragment,{children:[o.trim()!==""&&h.jsx(Uj,{remarkPlugins:i,rehypePlugins:a,urlTransform:BC,components:t?ly:CH,children:o}),h.jsx(xRt,{info:r.info,body:r.body})]})}return h.jsx(Uj,{remarkPlugins:i,rehypePlugins:a,urlTransform:BC,components:t?ly:CH,children:n})});oxe.displayName="ParsedBlock";const xRt=({info:e,body:t})=>{const n=e.split(oRt)[0];return h.jsx("pre",{children:h.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
|
|
861
861
|
`)?"":`
|
|
862
862
|
`}`})})},sxe=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=u5t());const i=r.current;h5t(i,e);const{blockStart:a}=i,o=a+p5t(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&sRt.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((d,f)=>({key:f,source:d,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=rxe(t);return h.jsx("div",{className:q("lo-markdown",n),style:O,children:u.map(d=>h.jsx(oxe,{source:d.source,closed:d.closed},d.key))})};sxe.displayName="StreamingMarkdown";const zo=({isUser:e,children:t,className:n})=>e?h.jsx("div",{className:q("flex w-full justify-end",n),children:t}):h.jsx("div",{className:q("group relative w-full",n),children:t}),cU=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},QRt=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 uU=cU(Date.now()),nO=null;const Y1=new Set,lxe=()=>{nO!==null&&clearTimeout(nO),nO=setTimeout(()=>{nO=null,uU=cU(Date.now());for(const e of Y1)e();lxe()},QRt(Date.now())),nO.unref?.()},kRt=e=>(Y1.add(e),uU=cU(Date.now()),lxe(),()=>{Y1.delete(e),Y1.size===0&&nO!==null&&(clearTimeout(nO),nO=null)}),AH=()=>uU,PRt=()=>$.useSyncExternalStore(kRt,AH,AH),_Rt=e=>new Date(e+1e3),TRt=()=>_Rt(PRt()),$un=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":COe(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},RRt=(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=UYe(n,{hour:"numeric",minute:"2-digit",hour12:!0});if(n.toDateString()===t.toDateString())return r;const i=new Date(t);if(i.setDate(t.getDate()-1),n.toDateString()===i.toDateString())return`Yesterday ${r}`;const a=COe(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),""}},XRt=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":WYe(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},ERt={turn:"Sent",answer:"Answered",tool:"Ran"},cxe=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=TRt();if(Number.isNaN(r.getTime()))return null;const a=XRt(r,{hour12:!0});return h.jsx(Nt,{content:a,side:"bottom",delayDuration:1200,children:h.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${ERt[t]} ${a}`,className:q("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:RRt(r,i)})})},OU=({replies:e,onRemoveReply:t})=>h.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[h.jsx(YAe,{size:12,"aria-hidden":"true"}),h.jsx("span",{className:"text-meta",children:"Replying to"})]}),e.map(n=>h.jsxs("div",{className:"flex items-center gap-2 border-hairline border-l-2 py-0.5 pl-2",children:[h.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"aria-label":"Remove reply",children:h.jsx(Ji,{"aria-hidden":"true"})})]},n.id))]}),qRt=({children:e,className:t})=>h.jsx("span",{"aria-hidden":!0,className:q("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),jRt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},CRt=({line:e})=>h.jsx("span",{className:q(jRt[e.kind],"block"),children:e.text}),ARt=({diff:e,className:t})=>{const n=S4e(e);return h.jsxs("div",{className:q("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-md bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>h.jsx(CRt,{line:r},i)),n.hidden>0&&h.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:x4e(n.hidden)})]})},zRt=(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()},zH=e=>e.startsWith("file://")?e.slice(7):e,URt={READ:{verb:"Read",runningVerb:"Reading",icon:LA},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:Jce},EDIT:{verb:"Edited",runningVerb:"Editing",icon:oze},CODE:{verb:"Ran code",runningVerb:"Running code",icon:Gce},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:bze},DONE:{verb:"Finished",runningVerb:"Finishing",icon:sA},ASK:{verb:"Asked",runningVerb:"Asking",icon:rk},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:J6e}},WRt={verb:"Worked on the request",runningVerb:"Working on the request",icon:Gce},NRt=(e,t,n,r)=>{const i=e?URt[e]:WRt;let a;if(t)a=zH(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=zH(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?zRt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},UH="min-h-5 py-0",YRt=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>h.jsxs("span",{className:q("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[h.jsx(qRt,{className:q(a?"text-danger":"text-ink-dim",o&&hOe),children:e}),h.jsxs("span",{className:q(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[h.jsxs("span",{...f5,className:q("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?h.jsxs("span",{...f5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?h.jsxs("span",{...f5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),WH=({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:d,dense:f=!1})=>{const p=NRt(e,t,n,r),m=c??(i?p.runningVerb:p.verb),g=a?wp:p.icon,y=a||!c||!O?h.jsx(g,{}):O,v=h.jsx(YRt,{icon:y,verb:m,object:c?u:p.object,narration:c?r:p.narration,running:i,failed:a,wrap:d}),S=d?"firstLine":"center";return s?h.jsx(ga,{summary:v,chevron:"leading",summaryAlign:S,defaultOpen:o,className:l,rowClassName:f?UH:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):h.jsx(ga,{disabled:!0,summary:v,summaryAlign:S,className:l,rowClassName:f?UH:void 0})},uxe=8,GRt="… deeper values not shown",IRt="(empty)";function ZRt(e){return`… ${e} more line${e===1?"":"s"}`}const NH=.5;function DRt(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 Oxe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function dU(e){return typeof e=="object"&&e!==null}function dxe(e,t,n,r){if(n>uxe){r.push({key:t,value:GRt,depth:n});return}if(dU(e)){for(const[a,o]of Object.entries(e))dxe(o,t?`${t}.${a}`:a,n+1,r);return}const i=Oxe(e);i!==null&&r.push({key:t,value:i,depth:n})}function fxe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))dxe(r,n,1,t);return t}const VRt=512;function MRt(e,t){if(t)return!0;if(!e)return!1;let n=VRt;const r=(i,a)=>{if(n--<=0||a>uxe)return!0;if(!dU(i))return Oxe(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 LRt(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(!dU(n))return null;const r=fxe(n);return r.length>0?r:[{key:"",value:IRt,depth:1}]}const FRt=8,HC="max-h-[min(320px,40vh)]",hxe=HC,BRt=({line:e})=>h.jsxs("div",{className:q("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*FRt},children:[e.key?h.jsxs("span",{className:q("text-ink-muted"),children:[e.key,": "]}):null,h.jsx("span",{className:q("text-ink-dim"),children:e.value})]}),YH=({lines:e,label:t})=>h.jsx("div",{className:q("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>h.jsx(BRt,{line:n},r))});function GH(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(),d=c.getBoundingClientRect();i(d.height>O.height+NH);const f=c.children.length>0?Array.from(c.children):[c];n(DRt(f.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,NH))};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 IH=({lines:e,overflowing:t})=>t?h.jsx("span",{className:q("mt-1 block text-ink-dim"),children:e>0?ZRt(e):" "}):null,HRt=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=fxe(e),o=LRt(t),s=$.useRef(null),l=$.useRef(null),c=GH(s),u=GH(l);return a.length===0&&!t&&!i?null:h.jsxs("div",{className:q("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),children:[a.length>0&&h.jsxs("div",{"data-detail-section":"input",children:[h.jsx("div",{ref:s,className:q(HC,"overflow-auto"),children:h.jsx(YH,{lines:a,label:"input"})}),h.jsx(IH,{lines:c.lines,overflowing:c.overflowing})]}),i&&h.jsx("div",{className:q("whitespace-normal font-sans text-body-sm text-ink-muted",a.length>0&&"mt-3"),"data-detail-section":"note",children:i}),t&&h.jsxs("div",{className:q(a.length>0&&"mt-3"),"data-detail-section":"output",children:[h.jsx("span",{className:q("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),h.jsx("div",{ref:l,className:q(HC,"overflow-auto"),children:o?h.jsx(YH,{lines:o,label:"result-json"}):h.jsx("pre",{className:q("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),h.jsx(IH,{lines:u.lines,overflowing:u.overflowing})]})]})},KRt="mcp__",JRt={bash:Qze,read:ok,write:BY,edit:BY,glob:kp,grep:ov,todo:EAe,wake:ik,list_variables:JY,read_variable:JY,browser:HY,console:BA,project:M6e,project_delete:Pze,web_search:HY,web_fetch:iv,task:Md,agent:Md,send:nue,peer:xAe,sessions:cze};function eXt(e){const t=e.trim().toLowerCase(),n=JRt[t];return n||(t.startsWith(KRt)?eue:Cze)}const tXt=FA,nXt=UAe,rXt=AAe,ZH="min-h-5 py-0",DH={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},iXt=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?DH.plain:DH[O4e(t)],aXt=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",oXt=({added:e,removed:t})=>e<=0&&t<=0?null:h.jsxs("span",{className:q("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&h.jsxs("span",{className:q("text-success"),children:["+",e]}),t>0&&h.jsxs("span",{className:q("text-danger"),children:["-",t]})]}),eR={running:"",success:"succeeded",error:"failed",interrupted:"interrupted","not-run":"never ran",partial:"",receipt:""},sXt=1e3;function lXt(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,sXt);return()=>window.clearInterval(i)},[e]),t}const cXt=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=lXt(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?JXe[t]:void 0,c=s?l??null:o?l??eR[e]:null,O=q("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?n4e[t]??null:null,f=s&&t?e4e[t]:void 0,p=s?t==="mailbox"?nXt:t==="unconfirmed"?rXt:null:e==="interrupted"?tXt:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":Kl(a??0):gA(n);return h.jsxs("span",{className:q("flex shrink-0 items-center gap-1.5"),children:[c?h.jsx("span",{className:O,title:f,"aria-hidden":d?!0:void 0,children:c}):null,h.jsxs("span",{className:q("flex shrink-0 [&_svg]:size-3.5",p&&"size-3.5",m),children:[p?h.jsx(p,{"aria-hidden":!0}):null,!o&&eR[e]?h.jsx("span",{className:q("sr-only"),children:eR[e]}):null,d?h.jsx("span",{className:q("sr-only"),children:d}):null]}),h.jsx("span",{className:q("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:g})]})},bO=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,outcome:o,deliveryState:s=null,durationS:l,startedAt:c=null,added:u=0,removed:O=0,details:d,defaultOpen:f=!1,className:p,media:m})=>{const g=o==="running",y=o==="error",v=eXt(e),S=sf(e),{verb:x,object:b}=rle(e,r,i,g,t,i4e(s)),w=h.jsxs("span",{className:q("flex min-w-0 flex-1 items-center gap-2"),children:[h.jsx("span",{"aria-hidden":!0,className:q("flex size-3.5 shrink-0 [&_svg]:size-3.5",iXt(o,e)),children:h.jsx(v,{})}),n?null:h.jsx("span",{"data-trace-verb":"",className:q("shrink-0 whitespace-nowrap text-body-sm",aXt(o)),title:S,children:x}),h.jsx("span",{className:q("min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:b,children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),h.jsx("span",{className:q("sr-only"),children:"pending"})]}):b}),h.jsx(oXt,{added:u,removed:O}),h.jsx(cXt,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),Q=g?{"data-glass-state":"running"}:void 0,k=g?"bg-elevated":y?"bg-danger-wash":"hover:bg-row-hover",_=d?h.jsx(ga,{summary:w,chevron:"leading",defaultOpen:f,className:q("@container/toolrow",p),triggerData:Q,rowClassName:ZH,triggerClassName:q("-mx-2 rounded-sm px-2",k),children:d}):h.jsx(ga,{disabled:!0,summary:w,triggerData:Q,rowClassName:ZH,className:q("@container/toolrow",(g||y)&&q("-mx-2 rounded-sm px-2",k),p)});return m?h.jsxs("div",{className:q("flex flex-col"),children:[_,m]}):_},uXt=3,pxe=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},KC=e=>{const t=new Map;let n=0;for(const a of e){const o=pxe(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=fXt(hXt(e));return{units:a.length===0?[`${e.length} actions`]:a,prose:!1}}const r=["files","searches","web","commands","edits","delegated"],i=[];for(const a of r){const o=t.get(a)??0;o!==0&&(a==="files"&&i.push(`Explored ${o} file${o===1?"":"s"}`),a==="searches"&&i.push(`${o} search${o===1?"":"es"}`),a==="web"&&i.push(`Searched the web ${o} time${o===1?"":"s"}`),a==="commands"&&i.push(`Ran ${o} command${o===1?"":"s"}`),a==="edits"&&i.push(`Edited ${o} file${o===1?"":"s"}`),a==="delegated"&&i.push(`Delegated ${o} task${o===1?"":"s"}`))}return i.length===0?{units:[`${e.length} actions`],prose:!0}:{units:[i.length===1?i[0]:`${i[0]}, ${i[1].charAt(0).toLowerCase()}${i[1].slice(1)}`],prose:!0}},OXt=e=>KC(e).units;function dXt(e){return OXt(e).join(" · ")}const VH={agent:{noun:"agent",plural:"agents"},team:{noun:"team",plural:"teams"},team_delete:{noun:"team deletion",plural:"team deletions"},hub:{noun:"subagent",plural:"subagents"},secret:{noun:"secret",plural:"secrets"},project:{noun:"project",plural:"projects"},project_delete:{noun:"project deletion",plural:"project deletions"},wake:{noun:"wake",plural:"wakes"},jobs:{noun:"job",plural:"jobs"},console:{noun:"console",plural:"consoles"},network:{noun:"network call",plural:"network calls"},browser:{noun:"browser action",plural:"browser actions"},todo:{noun:"todo update",plural:"todo updates"},send:{noun:"message",plural:"messages"},ask:{noun:"question",plural:"questions"},wait:{noun:"wait",plural:"waits"},lsp:{noun:"code lookup",plural:"code lookups"},web_read:{noun:"page",plural:"pages"},list_variables:{noun:"variable lookup",plural:"variable lookups"},read_variable:{noun:"variable read",plural:"variable reads"},sessions:{noun:"session",plural:"sessions"}},tR=5,fXt=e=>{if(e.length<=tR)return e.map(r=>r.label);const t=e.slice(0,tR),n=e.slice(tR).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},hXt=e=>{const t=new Map,n=(s,l)=>{const c=t.get(s);c?c.count+=1:t.set(s,{kind:l,count:1})};for(const s of e){const l=s.name.toLowerCase();if(l==="bash"||l==="exec"||l==="shell"||l==="run"){n("kind:shell",{noun:"shell",plural:null});continue}if(l==="eval"){n("kind:python",{noun:"python",plural:null});continue}const c=pxe(s.name);if(c==="files")n("class:files",{noun:"file",plural:"files"});else if(c==="searches")n("class:searches",{noun:"search",plural:"searches"});else if(c==="web")n("class:web",{noun:"web search",plural:"web searches"});else if(c==="edits")n("class:edits",{noun:"edit",plural:"edits"});else if(c==="delegated")n("class:delegated",{noun:"task",plural:"tasks"});else if(l==="todo")(s.op??"").toLowerCase()==="view"?n("kind:todo:view",{noun:"todo read",plural:"todo reads"}):n("kind:todo",VH.todo);else{const u=VH[l];if(u)n(`kind:${l}`,u);else{const O=sf(s.name);n(`name:${O}`,{noun:O,plural:null})}}}const r=["class:files","class:searches","class:web","kind:shell","kind:python","class:edits","class:delegated","kind:agent","kind:team","kind:hub"],i=[],a=(s,l)=>`${s} ${s===1||l.plural===null?l.noun:l.plural}`;for(const s of r){const l=t.get(s);l&&i.push({label:a(l.count,l.kind),count:l.count})}const o=[...t.entries()].filter(([s])=>!r.includes(s)).sort(([,s],[,l])=>l.count-s.count||s.kind.noun.localeCompare(l.kind.noun));for(const[,s]of o)i.push({label:a(s.count,s.kind),count:s.count});return i};function pXt(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 mXt(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=pXt(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 gXt(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return rle(n.name,n.summary??"",null,!0,n.op)}return null}function $Xt(e,t){const n=[];let r=[];const i=()=>{if(r.length===0)return;const a=r.filter(s=>t.isReceipt?.(s)),o=r.filter(s=>t.isFoldable(s)).map(s=>{const l={name:t.nameOf(s),failed:t.failedOf(s),durationS:t.durationOf?t.durationOf(s):null,startedAtMs:t.startedAtOf?t.startedAtOf(s):null,endedAtMs:t.endedAtOf?t.endedAtOf(s):null};return t.summaryOf&&(l.summary=t.summaryOf(s)),t.opOf&&(l.op=t.opOf(s)),t.runningOf&&(l.running=t.runningOf(s)),t.executingOf&&(l.executing=t.executingOf(s)),l});if(o.length>=uXt)n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:o,summary:{...KC(o),units:[...KC(o).units,...t.receiptSummaryOf?.(a)??[]]},failedCount:o.filter(s=>s.failed).length,span:mXt(o),live:gXt(o)});else for(const s of r)n.push({kind:"row",row:s});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}const MH=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&n.record.customType==="hub_message")))for(const r of n.record.images??[])FQ(r)&&t.push(r);return t},G1=5,yXt=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<G1?{shown:Math.max(e,0),more:0}:{shown:G1-1,more:e-(G1-1)},vXt=e=>{const t=G1-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},xx=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function Qx(e){return e.record.kind==="tool"?e.record.durationS:null}function mxe(e){let t=null;for(const n of e){const r=Qx(n);typeof r=="number"&&(t=(t??0)+r)}return t}function bXt(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 wXt="min-h-5 py-0",SXt=1e3;function xXt(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,SXt);return()=>window.clearInterval(i)},[e]),t}const QXt=({summary:e,actionCount:t,span:n,live:r,open:i,onOpenChange:a,className:o,condensedMedia:s,mediaCount:l=0,recordIds:c,children:u})=>{const O=xXt(n?.running===!0),d=n===null?null:Math.max(0,((n.running?O:n.endedAtMs??O)-n.startedAtMs)/1e3),f=d===null?"":gA(d),p=$.useRef(null),m=()=>{p.current?.querySelector("button[aria-expanded]")?.focus(),a(!0)};return h.jsxs("div",{ref:p,className:o,"data-fold-ids":c.join(" "),children:[h.jsx(ga,{animate:i||!s,open:i,onOpenChange:a,rowClassName:wXt,triggerClassName:q("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:h.jsxs("span",{className:q("flex min-w-0 flex-1 items-center gap-2"),children:[r!==null&&!i&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{"data-fold-live":"",className:q("min-w-0 shrink-[100000] truncate"),title:`${r.verb} ${r.object}`,children:[h.jsx("span",{className:q("text-accent"),children:r.verb})," ",h.jsx("span",{className:q("font-mono text-mono-sm text-ink-muted"),children:r.object})]}),h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"})]}),h.jsx("span",{className:q("min-w-0 break-words text-body-sm text-ink-muted"),title:`${t} actions`,"data-fold-summary":"",children:e.units.map((g,y)=>h.jsxs($.Fragment,{children:[y>0&&h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:q(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),xx(l)!==null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{className:q("shrink-0 text-ink-muted text-meta"),children:xx(l)})]}),f!==""&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{"data-fold-span":"",className:q("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:f})]})]}),children:h.jsx("div",{className:q("flex flex-col"),children:u})}),!i&&s&&s(m)]})},LH=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],kXt=80,PXt=1e3,gxe=({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,d=dz("(prefers-reduced-motion: reduce)"),f=$.useRef(n??Date.now()),p=$.useRef(t),m=$.useRef(n);if(p.current!==t)p.current=t,m.current=n,f.current=n??Date.now(),c&&u(!1),l(0);else if(m.current!==n){const v=m.current!==void 0&&n===void 0;m.current=n,u(v),v||(f.current=n,l(Math.floor((Date.now()-n)/1e3)))}const g=$.useRef(r!==!1),y=$.useRef(t);return $.useEffect(()=>{const v=r!==!1,S=g.current,x=y.current===t;g.current=v,y.current=t,!S&&v&&x&&l(Math.floor((Date.now()-f.current)/1e3))},[r,t]),$.useEffect(()=>{const v=O?window.setInterval(()=>l(Math.floor((Date.now()-f.current)/1e3)),PXt):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const S=window.setInterval(()=>o(x=>(x+1)%LH.length),kXt);return()=>{window.clearInterval(S),v!==null&&window.clearInterval(v)}},[d,O]),h.jsxs("div",{className:q("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[h.jsx("span",{"aria-hidden":!0,className:q("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:LH[a]}),h.jsx("span",{className:q("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),h.jsx("span",{"aria-hidden":!0,className:q("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?Kl(s):""})]})},_Xt="min-h-5 py-0",Du=()=>h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),TXt=({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:d,children:f,condensedMedia:p,mediaCount:m=0,group:g=null,episode:y=null})=>{const v=o?`${a}+ actions`:a===1?"1 action":`${a} actions`,S=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,x=y?.receipts??g?.count,b=x===void 0?null:`At least ${x} messages — earlier rows are not loaded`,w=$.useRef(null),Q=()=>{w.current?.querySelector("button[aria-expanded]")?.focus(),d(!0)};return h.jsxs("div",{ref:w,className:q("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u&&!y?.active?"true":void 0,"data-segment-active":y?.active?"true":void 0,"data-record-id":n,children:[h.jsx(ga,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:_Xt,triggerClassName:q("-ml-2 -mr-2 w-[calc(100%+1rem)] rounded-sm pl-2 pr-6","hover:bg-row-hover"),chevronClassName:q("-mr-6","text-ink-muted"),summary:h.jsxs("span",{className:q("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&!y?.active&&h.jsx(h.Fragment,{children:h.jsx(sA,{"aria-hidden":!0,className:q("size-3.5 shrink-0 text-success")})}),y?.active?h.jsxs(h.Fragment,{children:[c!==null&&h.jsx(Du,{}),h.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?b??void 0:void 0,"aria-label":o?b??void 0:void 0,children:o?`${y.receipts}+`:y.receipts}),a>0&&h.jsxs(h.Fragment,{children:[h.jsx(Du,{}),h.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?S:void 0,children:v})]}),y.phaseLine!==null&&h.jsxs(h.Fragment,{children:[h.jsx(Du,{}),h.jsx(gxe,{activity:y.phaseLine.activity,phase:y.phaseLine.phase,startedAt:y.phaseLine.startedAt,clock:y.phaseLine.clock,className:"min-w-0"})]})]}):g!==null?h.jsxs(h.Fragment,{children:[c!==null&&h.jsx(Du,{}),h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),title:o?b??void 0:void 0,"aria-label":o?b??void 0:void 0,children:o?`${y?.receipts??g.count}+`:`${y?.receipts??g.count}`}),g.spanS!==null&&h.jsxs(h.Fragment,{children:[h.jsx(Du,{}),h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:Kl(g.spanS)})]})]}):h.jsxs(h.Fragment,{children:[c!==null&&(i!==null||a>0)&&h.jsx(Du,{}),i!==null&&h.jsxs("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:["Took ",Kl(i)]}),i!==null&&a>0&&h.jsx(Du,{}),a>0&&h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),title:o?S:void 0,"aria-label":o?S:void 0,children:v})]}),xx(m)!==null&&h.jsxs(h.Fragment,{children:[h.jsx(Du,{}),h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:xx(m)})]}),u&&!y?.active&&h.jsx("span",{className:q("sr-only"),children:"completed"}),l!==null&&h.jsx("span",{className:q("ml-auto"),children:h.jsx(cxe,{timestamp:l,scope:"answer"})})]}),children:h.jsx("div",{className:q("flex flex-col"),children:f})}),!O&&p&&h.jsx("div",{className:q("pb-2"),children:p(Q)})]})},$xe="lo-missing-session-notice",Qf=({children:e,className:t,boundary:n="hairline",...r})=>h.jsx("div",{className:q("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}),RXt="could not be displayed. It may have been moved, renamed, or deleted.",fU="could not be displayed. Its stored copy is not available to this reader.",XXt="could not be played. Its stored copy is not available to this reader.",uy=({name:e,detail:t=RXt,className:n,compact:r=!1})=>r?h.jsx("div",{className:q("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:h.jsx(KY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):h.jsxs("div",{className:q("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[h.jsx(KY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),h.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[h.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),wd=1,yxe=4,FH=(e,t)=>Math.min(yxe,Math.max(wd,e+t)),Ig=Object.freeze({x:0,y:0}),nR=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),rR=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,EXt=(e,t)=>`Image ${e+1} of ${t}`,BH=(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))}},qXt="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",jXt="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",HH=e=>q(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),CXt="opacity-45",hU=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a,pending:o=!1,group:s,layerRef:l})=>{const[c,u]=$.useState(null),O=e!==void 0&&c===e,[d,f]=$.useState(wd),[p,m]=$.useState(Ig),g=$.useRef(e);$.useLayoutEffect(()=>{g.current!==e&&(g.current=e,f(wd),m(Ig))},[e]);const[y,v]=$.useState(!0),S=$.useRef(null);$.useEffect(()=>{if(!n)return;let U;const te=()=>{clearTimeout(U),U=setTimeout(()=>{const B=S.current;if(B&&(B.matches(":hover")||B.contains(document.activeElement))){te();return}v(!1)},jOe)},D=()=>{v(!0),te()};return v(!0),te(),document.addEventListener("pointermove",D,{passive:!0}),document.addEventListener("pointerdown",D,{passive:!0}),document.addEventListener("keydown",D),document.addEventListener("focusin",D),()=>{clearTimeout(U),document.removeEventListener("pointermove",D),document.removeEventListener("pointerdown",D),document.removeEventListener("keydown",D),document.removeEventListener("focusin",D)}},[n]);const x=s?.onPrev,b=s?.onNext,w=s!==void 0&&s.count>1,Q=w?jXt:qXt,k=$.useRef(null),_=l??k;$.useEffect(()=>{if(!n||!w)return;const U=te=>{te.defaultPrevented||te.metaKey||te.ctrlKey||te.altKey||(te.key==="ArrowLeft"?(te.preventDefault(),x?.()):te.key==="ArrowRight"&&(te.preventDefault(),b?.()))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[n,w,x,b]),eA(n,"image-lightbox");const R=$.useRef(null),E=e!==void 0&&!O,T=d===wd&&p.x===Ig.x&&p.y===Ig.y,j=U=>{if(!E)return;f(U);const te=R.current;te&&m(D=>BH(D,{width:te.clientWidth,height:te.clientHeight},U))},C=()=>{E&&(f(wd),m(Ig))},W=$.useRef(null),[G,N]=$.useState(!1),V=E&&d>wd,F=U=>{!V||U.button!==0||(U.currentTarget.setPointerCapture(U.pointerId),W.current={pointerId:U.pointerId,startX:U.clientX,startY:U.clientY,pan:p},N(!0))},z=U=>{const te=W.current,D=R.current;!te||te.pointerId!==U.pointerId||!D||m(BH({x:te.pan.x+(U.clientX-te.startX),y:te.pan.y+(U.clientY-te.startY)},{width:D.clientWidth,height:D.clientHeight},d))},Z=U=>{W.current?.pointerId===U.pointerId&&(W.current=null,N(!1))},J=e!==void 0&&!O?h.jsx("div",{ref:R,"data-image-viewport":"",tabIndex:-1,className:q(Q,"relative h-fit w-fit overflow-hidden leading-none outline-none",V&&(G?"cursor-grabbing":"cursor-grab"),V&&"touch-none"),onPointerDown:F,onPointerMove:z,onPointerUp:Z,onPointerCancel:Z,children:h.jsx("img",{src:e,alt:t,draggable:!1,className:q(Q,"block select-none object-contain"),style:T?void 0:{transform:`translate(${p.x}px, ${p.y}px) scale(${d})`},onError:()=>u(e)})}):e===void 0&&o?h.jsx("div",{className:HH(Q),"aria-hidden":"true"}):h.jsx("div",{className:HH(Q),children:a});return h.jsx(tA,{open:n,onOpenChange:r,children:h.jsxs(nA,{ref:_,tabIndex:-1,onOpenAutoFocus:U=>{U.preventDefault(),(R.current??_.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:U=>{const te=i?.current;te&&(U.preventDefault(),te.focus())},className:q("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",Q,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[h.jsx(rA,{className:"sr-only",children:t}),w&&s?h.jsx("div",{"aria-live":"polite",className:"sr-only",children:EXt(s.index,s.count)}):null,J,h.jsxs("div",{ref:S,"data-image-viewer-controls":"",className:q("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",y?"opacity-100 duration-fast":`${CXt} duration-base`),children:[w&&s?.filmstrip?h.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,w?h.jsxs(h.Fragment,{children:[h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Previous image",title:"Previous image",onClick:s?.onPrev,className:"pointer-events-auto fixed top-0 bottom-0 left-4 my-auto","data-image-viewer-prev":"",children:h.jsx(R6e,{"aria-hidden":"true"})}),h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Next image",title:"Next image",onClick:s?.onNext,className:"pointer-events-auto fixed top-0 right-4 bottom-0 my-auto","data-image-viewer-next":"",children:h.jsx(Pse,{"aria-hidden":"true"})})]}):null,h.jsxs("div",{className:"pointer-events-auto fixed right-4 bottom-4 flex items-center gap-1",children:[h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",title:"Zoom out",disabled:!E||d===wd,onClick:()=>j(FH(d,-1)),children:h.jsx(oue,{"aria-hidden":"true"})}),h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",title:"Zoom in",disabled:!E||d===yxe,onClick:()=>j(FH(d,1)),children:h.jsx(aue,{"aria-hidden":"true"})}),h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",title:"Reset view",disabled:!E||T,onClick:C,children:h.jsx(sk,{"aria-hidden":"true"})})]}),h.jsx(sRe,{asChild:!0,children:h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:q("pointer-events-auto fixed top-4 right-4"),"aria-label":"Close image",title:"Close image",children:h.jsx(Ji,{"aria-hidden":"true"})})})]})]})})};hU.displayName="ImageLightbox";const AXt={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(" ")},zXt=/[/\\]/,KH=e=>{const t=e.split(zXt);return t[t.length-1]},vxe=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:o})=>{const[s,l]=$.useState(!1),[c,u]=$.useState(!1),[O,d]=$.useState(!1),f=$.useRef(null),p=er(_=>_.setCanvasOpen),{setViewMode:m}=Cd(),g=$.useCallback(async()=>{const _=KH(e),R=C=>{C&&console.error("Error processing file:",C);const W=e.startsWith("file://")?e.substring(7):e;window.api.openFile(W).catch(G=>{console.error("Error opening file:",G)})},{setFiles:E,setOpenTabs:T,setSelectedTab:j}=Cd.getState();if(e.startsWith("data:"))if(YC(_)){const C=e,W={id:C,title:_,path:C,content:e,type:XS(e)},N=Cd.getState().conversations?.[n],V=N?.files??[],F=N?.openTabs??[],z=(()=>{const U=V.findIndex(te=>te.id===C);return U!==-1?[...V.slice(0,U),W,...V.slice(U+1)]:[...V,W]})();E(n,z);const J=F.some(U=>U.id===C)?F:[...F,{id:C,title:_}];T(n,J),j(n,C),p(!0),m(n,"documents")}else p(!0),m(n,"files");else{const C=e.startsWith("file://")?e.substring(7):e;try{const W=await window.api.readFile(C);if(W.success&&YC(_)){const G=C,N={id:G,title:_,path:C,content:W.data,type:XS(e)},F=Cd.getState().conversations?.[n],z=F?.files??[],Z=F?.openTabs??[],J=(()=>{const D=z.findIndex(B=>B.id===G);return D!==-1?[...z.slice(0,D),N,...z.slice(D+1)]:[...z,N]})();E(n,J);const te=Z.some(D=>D.id===G)?Z:[...Z,{id:G,title:_}];T(n,te),j(n,G),p(!0),m(n,"documents");return}p(!0),m(n,"files")}catch(W){const G=W instanceof Error?W.message:String(W??"Unknown error reading file");return R(G)}}},[e,p,m,n]),y=()=>{l(!0)},v=DSe(e),x=(v==="path"||v==="data")&&n!=="",b=MSe(v,{canShowInCanvas:x,source:t}),w=v==="path",Q=r??KH(e);if(s)return h.jsx(uy,{name:Q,compact:i==="thumbnail"});const k=h.jsx(Qf,{boundary:i==="thumbnail"?"control":"hairline",children:h.jsx("img",{className:q(AXt[i],c?"opacity-100":"opacity-0"),src:t,alt:Q,onLoad:()=>u(!0),onError:y})});return h.jsxs("div",{className:"group relative inline-block",children:[h.jsx("button",{ref:f,type:"button",className:q("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>d(!0),"aria-label":o?o.label:`Expand ${Q}`,title:o?o.title:`Click to expand ${Q}`,"aria-current":o?.current?"true":void 0,children:k}),b&&h.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 right-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:_=>{_.stopPropagation()},onKeyDown:_=>_.stopPropagation(),children:h.jsx(HSe,{file:e,src:t,label:Q,onShowInCanvas:x?g:void 0})}),o?null:a?a({open:O,onOpenChange:d,restoreFocusTo:f}):h.jsx(hU,{src:t,label:Q,open:O,onOpenChange:d,restoreFocusTo:f,fallback:h.jsx(uy,{name:Q,detail:w?void 0:fU})})]})});vxe.displayName="ImageAttachment";const UXt=(e,t,n)=>e.name??(n===1?"Image":`Image ${t+1}`),WXt={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},NXt=({cold:e,children:t})=>e?h.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,YXt=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=UXt})=>{const s=e.length,[l,c]=$.useState(()=>nR(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(nR(t,s)));const d=nR(l,s),f=e[d]??WXt,p=o(f,d,s),m=BSe(f,n),g=$.useRef(null),y=$.useRef(null),[v,S]=$.useState(!1),x=$.useCallback(N=>{g.current=N,S(N!==null)},[]),b=N=>{const V=g.current?.querySelector(`button[aria-label="Show image ${N+1} of ${s}"]`);V?V.focus():y.current?.focus()},w=N=>{const V=rR(d,s,N),F=g.current?.contains(document.activeElement)??!1;c(V),F&&b(V)},Q=()=>w(-1),k=()=>w(1),_=JSON.stringify([n?.sessionId,n?.childId,e.map(N=>[N.id,N.attachment,N.mimeType])]),[R,E]=$.useState(()=>({identity:_,open:r,indices:new Set}));(R.identity!==_||R.open!==r)&&E({identity:_,open:r,indices:new Set});const T=$.useCallback(N=>{E(V=>{if(!r||V.identity!==_||!V.open||N.every(z=>V.indices.has(z)))return V;const F=new Set(V.indices);for(const z of N)F.add(z);return{...V,indices:F}})},[_,r]),j=rR(d,s,-1),C=rR(d,s,1);$.useEffect(()=>{r&&T([d,j,C])},[r,d,j,C,T]),$.useEffect(()=>{const N=g.current;if(!r||!v||!N||typeof IntersectionObserver>"u")return;let V=!0;const F=new IntersectionObserver(z=>{V&&T(z.filter(Z=>Z.isIntersecting).map(Z=>Number(Z.target.dataset.imageSlot)-1))},{root:N});for(const z of N.querySelectorAll("[data-image-slot]"))F.observe(z);return()=>{V=!1,F.disconnect()}},[r,v,T]);const W=(N,V)=>!!N.data||!N.attachment||V===d||V===j||V===C||R.identity===_&&R.open&&R.indices.has(V);$.useEffect(()=>{(g.current?.querySelector(`[data-image-slot="${d+1}"]`)??g.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[v,d]);const G=s>1?h.jsx("ul",{role:"list",ref:x,"aria-label":`${s} images`,"data-image-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((N,V)=>h.jsx("li",{"data-image-slot":V+1,className:q("flex shrink-0 scroll-mx-px rounded-sm leading-none",V===d&&"ring-1 ring-ink"),children:h.jsx(NXt,{cold:!!N.attachment&&!N.data,children:W(N,V)?h.jsx(Ym,{image:N,scope:n,size:"thumbnail",label:o(N,V,s),press:{onPress:()=>c(V),label:`Show image ${V+1} of ${s}`,title:`Show image ${V+1} of ${s}`,current:V===d}}):h.jsx("button",{type:"button","aria-label":`Show image ${V+1} of ${s}`,title:`Show image ${V+1} of ${s}`,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{T([V]),c(V)},children:h.jsx(Qf,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},N.id))}):void 0;return h.jsx(hU,{src:m.state==="ready"?m.url:void 0,pending:m.state==="resolving",label:p,open:r,onOpenChange:i,restoreFocusTo:a,fallback:h.jsx(uy,{name:p,detail:fU}),layerRef:y,group:{index:d,count:s,onPrev:Q,onNext:k,filmstrip:G}})},Ym=({image:e,scope:t,label:n,size:r,group:i,press:a})=>{const o=BSe(e,t);if(o.state==="resolving"){const l=h.jsx(Qf,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""});return a?h.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:l}):h.jsx("div",{className:q("inline-block max-w-full"),"aria-hidden":!0,children:l})}if(o.state==="missing")return h.jsx(uy,{name:n,compact:r==="thumbnail",detail:fU});const s=o.url;return h.jsx("div",{className:q("inline-block max-w-full"),children:h.jsx(vxe,{file:s,src:s,label:n,size:r,conversationId:t?.sessionId??"",press:a,overlay:i?l=>h.jsx(YXt,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:l.open,onOpenChange:l.onOpenChange,restoreFocusTo:l.restoreFocusTo}):void 0})})},GXt="Generating name…",IXt={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 ZXt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function pU(e,t){return`Turn ${e} of ${t}`}const DXt=e=>e.charAt(0).toLowerCase()+e.slice(1);function VXt(e,t){const n=pU(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function MXt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function LXt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function FXt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const BXt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function HXt(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);if(Number.isNaN(t.getTime()))return"";const n=t.getHours(),r=t.getMinutes().toString().padStart(2,"0"),i=n%12===0?12:n%12,a=n<12?"AM":"PM";return`${i}:${r} ${a}`}function KXt(e,t){const n=DXt(pU(e.turn,t));if(e.kind==="user"){const i=HXt(e.ts);return i?`Jump to your message in ${n}, ${i}`:`Jump to your message in ${n}`}const r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`Jump to ${n}, ${r}`:`Jump to ${n}`}function JXt(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 iR(e,t){const n=[];for(const r of t)JXt(e,r)==="pending"&&n.push(r);return n}const e4t=120,JH=80,t4t="Turn checkpoints",n4t={complete:$u,error:wp,interrupted:FA,open:U6e},r4t={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},i4t=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?n4t[n]:null,i=LXt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:q("text-body-sm font-medium text-ink"),children:[pU(e.turn,t),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:q("font-normal text-ink-muted"),children:a})]})]}),MXt(e)&&h.jsx("p",{className:q("text-ink-dim text-meta"),children:GXt}),i&&h.jsx("p",{className:q("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&h.jsx("div",{className:q("flex items-center gap-1.5 text-ink-dim text-meta"),children:h.jsxs("span",{className:q("flex items-center gap-1",r4t[n]),children:[h.jsx(r,{"aria-hidden":"true",className:q("size-3.5 shrink-0")}),BXt[n]]})})]})},a4t=$.memo(function({checkpoint:t,state:n,label:r,roving:i,registerTick:a,onPreview:o,onPreviewEnd:s,onFocusMark:l,onBlurMark:c,onActivate:u,onKeyMark:O,describedBy:d}){const f=p=>{p.pointerType!=="touch"&&o(t.id)};return h.jsx("button",{ref:p=>a(t.id,p),type:"button","data-checkpoint-id":t.id,"data-mark-state":n,"aria-label":r,"aria-describedby":d,tabIndex:i?0:-1,className:q("group pointer-events-auto block h-2.5 w-7"),onPointerMove:f,onPointerLeave:s,onFocus:()=>l(t.id),onBlur:c,onClick:()=>u(t.id),onKeyDown:p=>O(p,t.id),children:h.jsx("span",{"aria-hidden":"true",className:q("ml-auto mr-1.5 block h-0.5 w-5 origin-right rounded-full","transition-[transform,background-color] duration-fast ease-out-quart","motion-reduce:transition-none",IXt[n])})})}),o4t=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{const s=$.useId(),[l,c]=$.useState(null),[u,O]=$.useState(null),[d,f]=$.useState(null),p=$.useRef(t);p.current=t;const m=$.useRef(new Map),g=$.useRef(null),y=$.useRef(null),v=$.useRef(null),S=$.useCallback(()=>{y.current!==null&&(clearTimeout(y.current),y.current=null),v.current!==null&&(clearTimeout(v.current),v.current=null)},[]),x=$.useCallback((M,ee)=>{S();const ne=()=>{O(M),f(p.current.find(ae=>ae.id===M)??null)};if(ee<=0){ne();return}y.current=setTimeout(()=>{y.current=null,ne()},ee)},[S]),b=$.useCallback(M=>{if(S(),M<=0){O(null);return}v.current=setTimeout(()=>{v.current=null,O(null)},M)},[S]),w=$.useRef(e);$.useEffect(()=>{w.current!==e&&(w.current=e,S(),Z.current=null,c(null),O(null),f(null))},[e,S]);const Q=$.useRef(null);$.useLayoutEffect(()=>{const M=g.current;if(!(t.length===0||M===null)){if(o!==null&&k.current===e){Q.current=e;return}Q.current!==e&&(Q.current=e,M.scrollTop=M.scrollHeight)}},[o,t.length,e]);const k=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const M=g.current,ee=m.current.get(o);if(M===null||ee===void 0)return;k.current=e;const ne=M.getBoundingClientRect(),ae=ee.getBoundingClientRect(),ce=ae.top-ne.top+M.scrollTop,ke=ce+ae.height,we=24;ce<M.scrollTop+we?M.scrollTop=Math.max(0,ce-we):ke>M.scrollTop+M.clientHeight-we&&(M.scrollTop=ke-M.clientHeight+we)},[o,e]),$.useEffect(()=>()=>S(),[S]);const _=$.useRef(r);$.useEffect(()=>{_.current=r});const R=$.useMemo(()=>FXt(t),[t]),E=$.useMemo(()=>new Map(t.map(M=>[M.id,KXt(M,R)])),[t,R]),T=u&&d?.id===u?d:null,j=u&&m.current.get(u)||null,C=$.useMemo(()=>({current:j}),[j]),W=T!==null&&j!==null;$.useEffect(()=>{_.current(W&&u?u:null)},[W,u]);const G=$.useCallback((M,ee)=>{ee?m.current.set(M,ee):m.current.delete(M)},[]),[N,V]=$.useState(null),F=N&&t.some(M=>M.id===N)?N:t[0]?.id??null,z=$.useCallback(M=>{const ee=Math.max(0,Math.min(t.length-1,M)),ne=t[ee];ne&&(V(ne.id),m.current.get(ne.id)?.focus())},[t]),Z=$.useRef(null),J=$.useCallback(M=>{Z.current!==M&&(Z.current=M,c(M),x(M,e4t))},[x]),U=$.useCallback(()=>{Z.current=null,c(M=>M===null?M:null),b(JH)},[b]),te=$.useCallback(M=>{Z.current=M,V(M),c(ee=>ee===M?ee:M),x(M,0)},[x]),D=$.useCallback(()=>{Z.current=null,c(M=>M===null?M:null),b(JH)},[b]),B=$.useCallback(M=>{b(0),Z.current=null,c(null),n(M)},[b,n]),he=$.useCallback((M,ee)=>{if(M.key==="Escape"){b(0);return}const ne=t.findIndex(ae=>ae.id===ee);if(!(ne<0)){if(M.key==="ArrowDown"){M.preventDefault(),M.stopPropagation(),z(ne+1);return}if(M.key==="ArrowUp"){M.preventDefault(),M.stopPropagation(),z(ne-1);return}if(M.key==="Home"){M.preventDefault(),M.stopPropagation(),z(0);return}M.key==="End"&&(M.preventDefault(),M.stopPropagation(),z(t.length-1))}},[t,b,z]);return t.length===0&&!i?null:h.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":t4t,className:q("pointer-events-none absolute inset-y-0 right-3 z-10 hidden w-7 select-none","flex-col justify-center","@[900px]/chatcol:flex"),children:[h.jsxs("div",{"data-rail-frame":"",ref:g,className:q("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&&h.jsx("span",{"aria-hidden":"true","data-rail-building":"",className:q("ml-auto mr-1.5 block h-0.5 w-5 animate-pulse-visible rounded-full bg-ink-dim")}),h.jsx("div",{"data-rail-track":"",className:"py-6",children:t.map(M=>h.jsx(a4t,{checkpoint:M,state:ZXt({id:M.id,previewId:l,activeId:o,loaded:a?a.has(M.id):!0}),label:E.get(M.id)??"",roving:M.id===F,registerTick:G,onPreview:J,onPreviewEnd:U,onFocusMark:te,onBlurMark:D,onActivate:B,onKeyMark:he,describedBy:W&&u===M.id?s:void 0},M.id))})]}),h.jsxs(lRe,{open:W,onOpenChange:M=>{M||b(0)},children:[h.jsx(cRe,{virtualRef:C}),T&&h.jsx(uRe,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":T.kind==="user"?"Your message":VXt(T,R),onOpenAutoFocus:M=>M.preventDefault(),onCloseAutoFocus:M=>M.preventDefault(),onFocusOutside:M=>{const ee=M.detail?.originalEvent?.target;ee instanceof Element&&ee.closest("[data-lo-checkpoint-rail]")&&M.preventDefault()},className:q("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:T.kind==="user"?h.jsx("div",{"data-checkpoint-card-text":"",className:q("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:T.text}):h.jsx(i4t,{checkpoint:T,turnCount:R})})]})]})},s4t=$.memo(o4t);function l4t(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 c4t=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function u4t(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function bxe(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):!c4t(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function O4t(e,t){return u4t(e,t)||bxe(e,t)!==null}const d4t=3;function f4t(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>=d4t){n.onMissing();return}const s=bxe(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const eK=(e,t,n)=>n===1?"Image":`Image ${t+1}`,tK=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=yXt(e.length,{uncapped:r}),s=vXt(a),l=s.length>1,c=new Set;for(let O=0,d=0;d<s.length;d+=1)c.add(O),O+=s[d];const u=e.slice(0,a).map((O,d)=>h.jsx("li",{className:q("flex leading-none",l&&c.has(d)&&"col-start-1"),children:h.jsx(Ym,{image:O,scope:t,size:"thumbnail",label:eK(O,d,e.length),group:{images:e,index:d,labelFor:eK}})},O.id));return h.jsxs("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-fold-media":"",className:q("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ml-5":"ml-0"),children:[u,o>0&&h.jsx("li",{className:q("flex h-[78px] items-center leading-none"),children:h.jsx(Ee,{variant:"outline",size:"sm",onClick:n,"aria-label":`+${o} more image${o===1?"":"s"}`,title:`+${o} more image${o===1?"":"s"}`,children:`+${o}`})},"fold-media-more")]})};function nK(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 h4t(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)))}const p4t=({video:e,scope:t,label:n})=>{const r=FSe(e,t),[i,a]=$.useState(!1);return r.state==="missing"||i?h.jsx(uy,{name:n,detail:XXt}):r.state==="resolving"?h.jsx("div",{className:q("inline-block max-w-full self-start"),"aria-hidden":!0,children:h.jsx(Qf,{"data-attachment-reserved":""})}):h.jsx("div",{className:q("inline-block max-w-full self-start"),children:h.jsx(Qf,{children:h.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:q("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})},wxe="generate_video",m4t=new Set(["generate_image",wxe]);function Sxe(e){return m4t.has(e)}function xxe(e){return e===wxe}function g4t(e){return xxe(e)?"video":"image"}function $4t(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 y4t(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:$4t(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 rK(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?Qxe:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const Qxe=Object.freeze({fraction:null,logs:[],queuePosition:null});function v4t(e,{stopping:t=!1}={}){const n=y4t(e.details),r=g4t(e.toolName);if(e.stopped===!0)return{state:"cancelled"};if(e.notRunKind==="skipped"||e.notRunKind==="aborted")return{state:"cancelled"};if(e.notRunReason)return{state:"failed",material:r,message:e.notRunReason,errorType:null};if(e.neverSent===!0)return{state:"cancelled"};if(e.isError===!0)return n.errorType==="media_already_completed"?{state:"done",images:e.images??[],material:r,durationS:e.durationS??null,receipt:"already-finished"}:n.stage==="cancelled"&&n.errorType===null?{state:"cancelled"}:{state:"failed",material:r,message:n.error??e.output,errorType:n.errorType};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,startedAtMs:null,progress:Qxe}:{state:"queued",composing:e.phase==="composing",argumentBytes:e.argumentBytes??0,queuePosition:n.queuePosition};case"running":{const i=e.startedAt??null;return t?{state:"cancelling",generating:!0,startedAtMs:i,progress:rK(n)}:{state:"running",material:r,startedAtMs:i,progress:rK(n),note:n.error}}case"done":return{state:"done",images:e.images??[],material:r,durationS:e.durationS??null,receipt:"generated"}}}function b4t(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 w4t(e,t){if(!xxe(e))return t?{onCancel:t}:void 0}const S4t=1e3;function x4t(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,S4t);return()=>window.clearInterval(i)},[e]),t}function Q4t(){return h.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:q("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:h.jsx("span",{className:q("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")})})}function k4t({view:e,elapsed:t}){let n,r=null,i=!1;switch(e.state){case"queued":n=e.composing?"Writing the request…":"Queued",r=e.queuePosition!==null?`${e.queuePosition} ahead`:e.argumentBytes>0?n1(e.argumentBytes):null;break;case"running":n=e.material==="video"?"Generating video…":"Generating image…",r=t===null?null:Kl(t);break;case"cancelling":n="Cancelling…";break;case"done":n=e.receipt==="already-finished"?"Already finished.":e.material==="video"?"Generated video":"Generated image",r=e.receipt==="already-finished"||e.durationS===null?null:gA(e.durationS);break;case"failed":n=e.message??(e.material==="video"?"The video could not be generated.":"The image could not be generated."),i=!0;break;case"cancelled":n="Cancelled";break}return h.jsxs("p",{className:q("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[h.jsx("span",{className:q("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:h.jsxs("span",{className:q("shrink-0 text-meta text-ink-dim"),children:["· ",r]})]})}function P4t({line:e}){return h.jsx("p",{"data-imagegen-log":"",title:e,className:q("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function _4t({line:e}){return h.jsx("p",{"data-imagegen-note":"",className:q("min-w-0 text-body-sm text-ink-dim"),children:e})}function T4t(e,t){return e==="cancel"?"Cancel":e==="restart"?t==="failed"?"Retry":"Restart":"Edit and restart"}const R4t=({view:e,scope:t,actions:n})=>{const r=e.state==="running"||e.state==="cancelling"?e.startedAtMs:null,i=x4t(r),a=b4t(e,n),o={cancel:n?.onCancel,restart:n?.onRestart,editRestart:n?.onEditRestart},s=e.state==="running"||e.state==="cancelling",l=s&&(e.state==="running"||e.generating),c=s&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return h.jsxs("div",{"data-imagegen-card":e.state,className:q("flex w-full flex-col gap-2"),children:[l?h.jsx(Q4t,{}):null,h.jsx(k4t,{view:e,elapsed:i}),e.state==="running"&&typeof e.note=="string"?h.jsx(_4t,{line:e.note}):null,l&&e.progress.fraction!==null?h.jsx(ORe,{"aria-label":"Image generation progress",className:q("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,c===null?null:h.jsx(P4t,{line:c}),e.state==="done"&&e.images.length>0?h.jsx("div",{className:q("flex flex-col gap-2"),children:e.images.map((u,O)=>{const d=u.kind==="video"?"Generated video":"Generated image",f=e.images.length===1?d:`${d} ${O+1}`;return u.kind==="video"?h.jsx(p4t,{video:u,scope:t,label:f},u.id):h.jsx(Ym,{image:u,scope:t,label:f},u.id)})}):null,a.length>0?h.jsx("div",{"data-imagegen-controls":"",className:q("flex items-center gap-2"),children:a.map(u=>h.jsx(Ee,{variant:"secondary",size:"sm",disabled:u.disabled,onClick:o[u.kind],children:T4t(u.kind,e.state)},u.kind))}):null]})},n$=1e4,kxe=/\s/,X4t=e=>{for(let t=e.length;t>0;t-=1){const n=e[t-1];if(n===`
|
|
863
863
|
`)return t;if(n==="."||n==="!"||n==="?"){const r=e[t];if(r===void 0||kxe.test(r))return t}}return-1},E4t=e=>{for(let t=e.length;t>0;t-=1)if(kxe.test(e[t-1]))return t;return-1},q4t=/[\uD800-\uDBFF]/,j4t=e=>q4t.test(e[n$-1])?n$-1:n$;function mU(e){if(e.length<=n$)return{text:e,clipped:!1};const t=e.slice(0,n$),n=X4t(t),r=E4t(t),i=n>0?n:r>0?r:j4t(t),a=e.slice(0,i).trimEnd();return{text:a.length>0?a:t,clipped:!0}}const Pxe="[speech]",C4t="Couldn't speak this aloud. Try again.",A4t="Couldn't speak this aloud. Try again.",_xe="This conversation's agent is no longer available.",z4t=new Set(["Your Radient sign-in has stopped working. Sign in again in Settings.","Your Radient credit balance is too low for speech. Add credits in the Radient Console to continue.","Speech is unavailable right now. Try again in a moment.","Speech is temporarily unavailable. Try again in a moment.","Speech is temporarily unavailable.","Sign in to Radient in Settings to enable speaking aloud.",_xe,"ElevenLabs refused your API key. Replace it.","Your ElevenLabs credit balance is too low for speech. Add credits with ElevenLabs to continue.","OpenAI refused your API key. Replace it.","Your OpenAI credit balance is too low for speech. Add credits with OpenAI to continue.","Your Radient sign-in has stopped working. Sign in again in the settings page.","Sign in to Radient in the settings page to enable text to speech."]);function U4t(e){const t=e instanceof Error?e.message:String(e);return z4t.has(t)?t:(console.error(`${Pxe} ${t}`),C4t)}function W4t(e){return(e instanceof Error?e.message:String(e))===_xe}function N4t(e){const t=e?.binding?.agent;return typeof t=="string"&&t.length>0?t:null}function Y4t(e,t){if(!e)return{state:"unknown"};const n=(t??[]).find(r=>r.name===e);return n?n.agent_id?{state:"agent",agentId:n.agent_id}:{state:"role-without-agent"}:{state:"unknown"}}const G4t=100;function I4t(e,t){if(!e)return null;const n=t?.agents??[],r=t?.total;if(typeof r=="number"&&r>n.length)return n.find(s=>s.name===e||s.id===e)?.id??null;const i=n.find(o=>o.name===e);if(i)return i.id;const a=n.find(o=>o.id===e);return a?a.id:null}async function aR(e){try{return await e()}catch{return null}}async function Z4t(e){if(!e)return null;const t=sv(zf.baseUrl),n=await aR(async()=>{const{profiles:a}=await Te({op:"profiles.list"});return Y4t(e,a)});if(n?.state==="agent")return n.agentId;if(n?.state==="role-without-agent")return null;const r=await aR(async()=>{const a=await t.agents.listAgents(1,G4t,e);return a.status<400?I4t(e,a.result??null):null});return r||await aR(async()=>{const a=await t.agents.getAgent(e);return a.status<400?a.result?.id??null:null})}function gU(e){return ar(t=>e?N4t(t.sessions.find(n=>n.session_id===e)):null)}const D4t=20,Txe=e=>`msg:${e}`,V4t=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")},kx=(e,t)=>`sel:${e}:${V4t(t)}`,$U=(e,t)=>async()=>{const n=()=>iK.speech.create({input:t}),r=await Z4t(e);return r===null?n():iK.speech.createForAgent(r,{input_text:t}).catch(i=>{if(!W4t(i))throw i;return n()})},iK=sv(zf.baseUrl),M4t=e=>{for(;e.size>D4t;){const t=e.keys().next().value;if(t===void 0)return;e.delete(t)}},oR=new Map,L4t=(e,t)=>{let n=oR.get(e);return n===void 0&&(n=t().finally(()=>{oR.delete(e)}),oR.set(e,n)),n},Uv=wa((e,t)=>({audioCache:new Map,heardKeys:new Set,loadingKey:null,playingKey:null,error:null,audioElement:null,currentUrl:null,generation:0,speak:async(n,r)=>{const i=t().generation+1;t().stopSpeech(),e({loadingKey:n,error:null,generation:i});try{let a=t().audioCache.get(n);if(a){const c=new Map(t().audioCache);c.delete(n),c.set(n,a),e({audioCache:c})}else{const c=await L4t(n,r);if(!c)throw new Error("Speech generation failed, no audio data received.");a=c;const u=new Map(t().audioCache);if(u.set(n,c),M4t(u),e({audioCache:u}),t().generation!==i)return}if(t().generation!==i)return;const o=URL.createObjectURL(a),s=new Audio(o);if(s.onended=()=>{URL.revokeObjectURL(o),e(c=>c.audioElement===s?{playingKey:null,audioElement:null,currentUrl:null}:{})},s.onerror=()=>{URL.revokeObjectURL(o);const c=t().audioElement===s;e(u=>u.audioElement===s?{error:"Error playing audio.",playingKey:null,audioElement:null,currentUrl:null}:{}),c&&(console.error(`${Pxe} playback failed for ${n}`),mi(A4t))},await s.play(),t().generation!==i){s.pause(),s.onended=null,s.onerror=null,URL.revokeObjectURL(o);return}const l=new Set(t().heardKeys);l.add(n),e({playingKey:n,loadingKey:null,audioElement:s,currentUrl:o,heardKeys:l})}catch(a){if(t().generation!==i)return;const o=a instanceof Error?a.message:"Failed to generate speech";e({error:o,loadingKey:null}),mi(U4t(a))}},stopSpeech:()=>{const{audioElement:n,currentUrl:r}=t();n&&(n.pause(),n.onended=null,n.onerror=null,r&&URL.revokeObjectURL(r)),e({playingKey:null,audioElement:null,currentUrl:null})},dismiss:n=>{const{loadingKey:r,playingKey:i,generation:a}=t();r===n&&e({generation:a+1,loadingKey:null}),i===n&&t().stopSpeech()},playSpeech:async(n,r,i)=>{await t().speak(Txe(n),$U(r,i))}}));function yU({key:e,getText:t,play:n,available:r=!0}){const{dismiss:i,stopSpeech:a,loadingKey:o,playingKey:s,audioCache:l,heardKeys:c}=Uv(),{canUseRadientSpeech:u,speechBlock:O}=KNe(),d=e!==null&&s===e,f=e!==null&&o===e,p=e!==null&&l.has(e),m=p&&e!==null&&c.has(e),g=u?null:wOe("speaking-aloud",O),y=!d&&!f&&(!u||!r);return{label:d?"Stop":f?"Loading speech. Press again to cancel.":m?"Replay speech":"Speak aloud",tooltip:d?"Stop":f?"Loading speech. Press again to cancel.":g??(m?"Replay speech":"Speak aloud"),isPlaying:d,isLoading:f,disabled:y,reason:g,active:d||f,press:()=>{if(d){a();return}if(f){e!==null&&i(e);return}if(y)return;const b=t();if(b===null||b.trim().length===0)return;const{text:w,clipped:Q}=mU(b);Q&&!p&&Qp(`Reading the first ${w.length.toLocaleString("en-US")} characters. The rest is not read aloud.`),n({text:w})}}}function Rxe(e){$.useEffect(()=>{if(e!==null)return()=>{Uv.getState().dismiss(e)}},[e])}const vU=({control:e,side:t="top"})=>{const n=$.useId(),r=e.disabled&&e.reason!==null;return h.jsx(Nt,{content:e.tooltip,side:t,children:h.jsxs("span",{className:q("flex"),tabIndex:r?0:void 0,"aria-describedby":r?n:void 0,children:[h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":e.label,className:q("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:e.press,disabled:e.disabled,children:e.isPlaying?h.jsx(s1,{"aria-hidden":"true"}):e.isLoading?h.jsx(bs,{size:"xs"}):h.jsx(qze,{"aria-hidden":"true"})}),r&&h.jsx("span",{id:n,className:"sr-only",children:e.reason})]})})},Gm="data-lo-quote-toolkit";function JC(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const aK=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${Gm}]`)??null,F4t=e=>e.nodeType===Node.ELEMENT_NODE,B4t=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>F4t(r)&&r.hasAttribute(Gm));return n===-1?t.length:n},H4t=(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,K4t=e=>{const t=Array.from(document.querySelectorAll(`[${Gm}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>H4t(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function Oy(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(aK(n.startContainer)||aK(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,B4t(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:K4t(n)}}const Xxe=8,J4t=.5;function eEt(e,t){const n={top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),bottom:Math.min(e.bottom,t.bottom)};return n.right>n.left&&n.bottom>n.top?n:null}const oK=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function tEt({lines:e,container:t,viewport:n,size:r,gap:i=Xxe,row:a,belowWhenOffFirstLine:o=!1}){if(e.length===0)return null;const s=eEt(t,n);if(!s)return null;const l=e[0],c=e[e.length-1];if(l.bottom<=s.top||l.top>=s.bottom)return null;const u=Math.max(l.bottom-l.top,1),O=a!==void 0&&l.top-a.top>u*J4t,d=l.top-i-r.height>=s.top,f=c.bottom+i+r.height<=s.bottom,m=d&&!(o&&O&&f);return{top:oK(m?l.top-i-r.height:c.bottom+i,s.top,s.bottom-r.height),left:oK(l.left,s.left,s.right-r.width),placement:m?"above":"below"}}const sK="[data-lo-canonical-transcript]",nEt="[data-lo-transcript-content]",lK=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),rEt=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function Exe(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,d=o.current;if(!O||!d){l(null);return}const f=c.current();if(!f||f.length===0){l(null);return}const p=tEt({lines:f,container:lK((O.closest(sK)??O).getBoundingClientRect()),viewport:rEt(),size:{width:d.offsetWidth,height:d.offsetHeight},row:lK(O.getBoundingClientRect()),belowWhenOffFirstLine:a}),m=O.getBoundingClientRect(),g=p?{top:p.top-m.top,left:p.left-m.left,placement:p.placement}:null;l(y=>y===g||y&&g&&y.top===g.top&&y.left===g.left&&y.placement===g.placement?y:g)},[t,a]);return $.useLayoutEffect(()=>{if(!n){l(null);return}u();let O=0;const d=()=>{O||(O=requestAnimationFrame(()=>{O=0,u()}))};document.addEventListener("scroll",d,!0),document.addEventListener("selectionchange",d),window.addEventListener("resize",d);const f=t.current?.closest(sK),p=f?.querySelector(nEt),m=new ResizeObserver(d);return f&&m.observe(f),p&&m.observe(p),()=>{O&&cancelAnimationFrame(O),document.removeEventListener("scroll",d,!0),document.removeEventListener("selectionchange",d),window.removeEventListener("resize",d),m.disconnect()}},[n,u,t,i]),{controlRef:o,placement:s}}function qxe(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(Oy(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 Wh="data-lo-link-toolbar",iEt=120,aEt=2;function jxe(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(f=>f===null?f:null),i(f=>f===!1?f:!1);return}const O=B_t(u);if(O){n(f=>f===O?f:O),i(f=>f===!0?f:!0);return}if(i(f=>f===!1?f:!1),OSe()){n(f=>f===null?f:null);return}const d=o.current&&u.contains(o.current)?o.current:null;n(f=>f===d?f:d)},[e]);$.useEffect(()=>{const u=e.current;if(!u)return;let O=0;const d=Q=>{O&&(clearTimeout(O),O=0),o.current=Q,l()},f=Q=>{if(O&&clearTimeout(O),!Q){O=0,o.current=null,l();return}o.current!==Q&&(s.current=null,O=setTimeout(()=>{O=0,o.current=Q,l()},iEt))},p=(Q,k)=>{const _=o.current;if(!_||!u.contains(_))return!1;const R=u.querySelector(`[${Wh}]`),E=Xxe+aEt;for(const T of[_,R]){if(!T)continue;const j=T.getBoundingClientRect();if(!(j.width<=0||j.height<=0)&&Q>=j.left-E&&Q<=j.right+E&&k>=j.top-E&&k<=j.bottom+E)return!0}return!1},m=Q=>{const k=Q.target;if(k?.closest(`[${Gm}]`))return;const _=k?.closest(Uh)??null;!_&&p(Q.clientX,Q.clientY)||f(_)},g=Q=>{const k=Q.relatedTarget;k&&u.contains(k)||p(Q.clientX,Q.clientY)||d(null)},y=Q=>{const k=Q.target?.closest(Uh);if(k){if(k===s.current){s.current=null;return}d(k)}},v=Q=>{const k=Q.relatedTarget;k&&u.contains(k)||d(null)},S=()=>Array.from(u.querySelectorAll(`[${Wh}] button:not([disabled])`)),x=Q=>{const k=Q.target;if(!k)return!1;if(k.closest(`[${Wh}]`)){const T=S(),j=T.indexOf(k);if(j===-1)return!1;if(Q.shiftKey&&j===0){const C=o.current;return C instanceof HTMLElement?(C.focus(),!0):!1}if(!Q.shiftKey&&j===T.length-1){const C=Array.from(u.querySelectorAll(Uh)),W=o.current,G=W?C.indexOf(W)+1:-1,N=G>0?C[G]:void 0;return N?(N.focus(),!0):!1}return!1}if(Q.shiftKey)return!1;const R=k.closest(Uh);if(!R||!u.contains(R))return!1;o.current!==R&&d(R);const[E]=S();return E?(E.focus(),!0):!1},b=Q=>{if(Q.key==="Tab"&&x(Q)){Q.preventDefault();return}if(!(Q.key==="ContextMenu"||Q.shiftKey&&Q.key==="F10"))return;const _=Q.target?.closest(Uh);!_||!u.contains(_)||(Q.preventDefault(),d(_),requestAnimationFrame(()=>{u.querySelector(`[${Wh}] button`)?.focus()}))},w=Q=>{const k=Q.target;k&&u.contains(k)||d(null)};return u.addEventListener("pointerover",m),u.addEventListener("pointerout",g),u.addEventListener("focusin",y),u.addEventListener("focusout",v),u.addEventListener("keydown",b),document.addEventListener("pointerdown",w,!0),document.addEventListener("selectionchange",l),l(),()=>{O&&clearTimeout(O),u.removeEventListener("pointerover",m),u.removeEventListener("pointerout",g),u.removeEventListener("focusin",y),u.removeEventListener("focusout",v),u.removeEventListener("keydown",b),document.removeEventListener("pointerdown",w,!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(`[${Wh}]`))return;const f=window.getSelection();f&&!f.isCollapsed&&f.removeAllRanges(),c()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,c]),{subject:t,quoteAvailable:r,dismiss:c}}function Cxe(e,t,n){const r=tn(i=>i.addReply);return $.useCallback(()=>{const a=Oy(t.current)?.text??(OSe()?null:n?.()??null);a&&(r(e,{id:Os(),text:a}),window.getSelection()?.removeAllRanges(),lz())},[r,e,t,n])}const Axe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(cSe)??"",o=n.getAttribute("data-lo-kind")??"file",s=hP(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=Cxe(e,t,l),{text:u}=qxe(t),{speak:O}=Uv(),d=gU(e),f=u??l(),p=f===null?null:kx(e,mU(f).text);Rxe(p);const m=yU({key:p,getText:()=>Oy(t.current)?.text??l(),play:({text:W})=>O(kx(e,W),$U(d,W))}),[g,y]=$.useState(!1),[v,S]=$.useState(()=>W1(a)??null),{controlRef:x,placement:b}=Exe({turnRef:t,visible:!0,lines:()=>{const W=n.getClientRects();return Array.from(W,G=>({top:G.top,left:G.left,right:G.right,bottom:G.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const W=W1(a);if(S(W??null),y(!1),W!==void 0)return;let G=!0;return V_t(a,window.api?.probeFiles).then(()=>{G&&S(W1(a)??null)}),()=>{G=!1}},[a]);const w=o==="file"&&rU(s,a),Q=hSe({target:a,isDirectory:v?.exists===!0&&!v.isFile,probe:v,canOpenInCanvas:w}),k=J_t({kind:o,target:a,probe:v,quotable:r,canOpenInCanvas:w});if(!k||!a)return null;const _=async()=>{await gSe(a)&&y(!0)},R=async()=>{if(o==="url"){await rH(o,a);return}s&&Q&&await s.openInCanvas(a)||await rH(o,a)||S(null)},E=async()=>{await jO(a)||S(null)},T=async()=>{await iU(a)||S(null)},j={quote:h.jsx(tue,{}),copy:g?h.jsx($u,{}):h.jsx(ak,{}),open:Q?h.jsx(nze,{}):o==="url"?h.jsx(Ice,{}):h.jsx(av,{}),"open-default":h.jsx(w6e,{}),"open-folder":h.jsx(kp,{})},C={quote:c,copy:()=>{_()},open:()=>{R()},"open-default":()=>{E()},"open-folder":()=>{T()}};return h.jsxs("div",{[Gm]:"",[Wh]:"",ref:x,role:"toolbar","aria-label":k.label,className:q("absolute z-10 flex h-8 items-center gap-0.5 rounded-md border border-hairline bg-elevated px-1",!b&&"invisible"),style:b?{top:b.top,left:b.left}:void 0,onMouseDown:W=>W.preventDefault(),onKeyDown:W=>{if(W.key!=="Escape")return;window.getSelection()?.removeAllRanges();const G=n;W.preventDefault(),i(),G.focus?.()},children:[k.actions.map(W=>h.jsxs($.Fragment,{children:[h.jsx(Nt,{content:W.id==="copy"&&g?"Copied":W.label,side:b?.placement==="below"?"bottom":"top",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":W.id==="copy"&&g?"Copied":W.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:C[W.id],children:j[W.id]})}),W.id==="quote"&&h.jsx(vU,{control:m,side:b?.placement==="below"?"bottom":"top"})]},W.id)),k.note&&h.jsx("span",{className:"max-w-56 truncate pl-1 text-ink-dim text-meta",title:k.noteTitle??k.note,children:k.note})]})};function oEt({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:["copy","speak",...n]}function zxe(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const cK=96;function sEt(e){const t=e.replace(/\s+/g," ").trim();return t.length<=cK?t:`${t.slice(0,cK-1).trimEnd()}…`}const lEt="Answer actions",cEt="Your message actions",uEt="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 OEt(e){return e?"opacity-100":uEt}const dEt=2e3,fEt=1e4;function yun(e){const{request:t}=e;return t?e.now-t.requestedAt>fEt?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let uK=0,Rw=0;const hEt=wa(e=>({request:null,requestPanel:(t,n,r,i)=>{uK+=1,e({request:{destination:t,nonce:uK,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:()=>{Rw+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,Rw=Math.max(0,Rw-1),Rw===0&&e({presenterClaimed:!1}))}}})),pEt=(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)},mEt=9e4,OK=new Set,gEt=2600,Uxe=$.memo(function({bodyText:t,kind:n="answer",agentId:r,speechId:i,revealId:a,revealAt:o,conversationId:s,entryId:l}){const[c,u]=$.useState(!1),[O,d]=$.useState(!1),f=$.useRef(null),p=$.useRef(null),m=$.useRef(null),g=$.useRef(null),{playSpeech:y}=Uv(),v=gU(r??null),S=yU({key:i?Txe(i):null,getText:()=>t,play:({text:E})=>{i&&y(i,v,E)}}),x=hEt(E=>E.requestPanel),w=oEt({role:n,forkable:!!(s&&l)}),Q=c||S.active;$.useEffect(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]),$.useEffect(()=>{if(!a||o===void 0||OK.has(a)||(OK.add(a),Date.now()-o>mEt))return;const E=p.current;if(E===null)return;const T=E.closest(".group")??E;if(pEt(E,T))return;d(!0);const j=()=>{d(!1),T.removeEventListener("pointerenter",j),T.removeEventListener("focusin",j)};return T.addEventListener("pointerenter",j),T.addEventListener("focusin",j),()=>{T.removeEventListener("pointerenter",j),T.removeEventListener("focusin",j)}},[a,o]),$.useEffect(()=>{if(O)return g.current=setTimeout(()=>{g.current=null,d(!1)},gEt),()=>{g.current!==null&&clearTimeout(g.current)}},[O]);const k=async()=>{await gSe(t)&&(u(!0),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,u(!1)},dEt))},_=()=>{!s||!l||x("session.fork",m.current,s,{id:l,excerpt:sEt(t)})},R={copy:h.jsx(Nt,{content:c?"Copied":"Copy",side:"bottom",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":c?"Copied":"Copy",className:q("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:k,children:c?h.jsx($u,{"aria-hidden":"true"}):h.jsx(ak,{"aria-hidden":"true"})})}),speak:h.jsx(vU,{control:S,side:"bottom"}),fork:h.jsx(Nt,{content:"Fork from this message",side:"bottom",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Fork from this message",ref:m,className:q("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:_,children:h.jsx(pAe,{"aria-hidden":"true"})})})};return h.jsx("div",{role:"toolbar","aria-label":n==="user"?cEt:lEt,ref:p,onAnimationEnd:E=>{E.target===E.currentTarget&&d(!1)},...O?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:{"data-lo-answer-actions":""},className:q("flex shrink-0 items-center gap-1",OEt(Q)),children:w.map(E=>h.jsx($.Fragment,{children:R[E]},E))})}),$Et="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",Xw="@min-[260px]/olderhistory:hidden",Ew="@max-[260px]/olderhistory:hidden",Wxe="lo-older-history-hint",yEt=({state:e,transportDown:t=!1,onLoadOlder:n,onRetryHydration:r})=>{const i=e==="loading"?"Loading earlier messages":e==="failed"?t?"Earlier messages did not load":"Could not load earlier messages":e==="unproven"?"Earlier history not loaded":null,a=e==="loading";return h.jsxs("div",{className:$Et,children:[h.jsx("output",{className:"sr-only","aria-live":"polite",children:i}),e==="failed"&&t?h.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:[h.jsx("span",{className:Xw,children:"Not loaded"}),h.jsx("span",{className:Ew,children:"Earlier messages did not load"})]}):e==="failed"?h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"min-w-0 truncate text-danger text-meta",title:"Could not load earlier messages",children:[h.jsx("span",{className:Xw,children:"Did not load"}),h.jsx("span",{className:Ew,children:"Could not load earlier messages"})]}),h.jsx(Ee,{variant:"ghost",size:"sm",className:"shrink-0",onClick:n,children:"Try again"})]}):a?h.jsxs(Ee,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"text-ink-muted",children:[h.jsx(bs,{size:"sm"}),"Loading earlier messages"]}):e==="idle"?h.jsx(Ee,{variant:"ghost",size:"sm",onClick:n,children:"Load earlier messages"}):e==="windowed"?h.jsxs("span",{id:Wxe,className:"min-w-0 truncate text-ink-dim text-meta",title:t?"Earlier history above":"Earlier history above — scroll up to load",children:[h.jsx("span",{className:Xw,children:t?"Earlier history above":"Scroll up for earlier"}),h.jsxs("span",{className:Ew,children:["Earlier history above",t?"":" — scroll up to load"]})]}):e==="unproven"?h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",title:"Earlier history not loaded",children:[h.jsx("span",{className:Xw,children:"Earlier not loaded"}),h.jsx("span",{className:Ew,children:"Earlier history not loaded"})]}),!t&&r&&h.jsx(Ee,{variant:"ghost",size:"sm",className:"shrink-0",onClick:r,children:"Try again"})]}):h.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:"Start of conversation"})]})},vEt="/settings?section=providers",dK="/settings?section=providers&provider=radient",bEt="/settings?section=radient",fK=/sign in to radient/i,wEt=[/insufficient credits/i,/credit balance is too low/i],SEt=[/rate limit or quota/i],xEt=[/insufficient credits/i,/\bHTTP 402\b/i];function Nxe(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function bU(e){return Nxe(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&xEt.some(n=>n.test(e.text)):!1}function QEt(e){if(!bU(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?`Out of credits${a}: ${i}`:`Out of credits${a}: Radient refused the request`}}function kEt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function hK(e){const t=Nxe(e.provider)||fK.test(e.text);let n=kEt(e.category);return bU(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(fK.test(e.text)?n="sign-in":wEt.some(r=>r.test(e.text))?n="billing":SEt.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:"Sign in to Radient",to:dK}:n==="billing"&&t?{label:"Open Radient account",to:bEt}:{label:"Open provider settings",to:t?dK:vEt}}const Yxe=({conversationId:e,turnRef:t})=>{const{text:n,clear:r}=qxe(t),i=n!==null,a=Cxe(e,t),{controlRef:o,placement:s}=Exe({turnRef:t,visible:i,lines:()=>Oy(t.current)?.lines??null}),{speak:l}=Uv(),c=gU(e),u=n===null?null:kx(e,mU(n).text);Rxe(u);const O=yU({key:u,getText:()=>Oy(t.current)?.text??null,play:({text:d})=>l(kx(e,d),$U(c,d))});return $.useEffect(()=>{if(!i)return;const d=f=>{f.key!=="Escape"||f.defaultPrevented||(window.getSelection()?.removeAllRanges(),r())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[i,r]),i?h.jsxs("div",{[Gm]:"",ref:o,className:q("absolute z-10 flex h-8 items-center gap-0.5 rounded-md border border-hairline bg-elevated px-1",!s&&"invisible"),style:s?{top:s.top,left:s.left}:void 0,onMouseDown:d=>d.preventDefault(),children:[h.jsx(Nt,{content:"Quote",side:s?.placement==="below"?"bottom":"top",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Quote",className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:a,children:h.jsx(tue,{})})}),h.jsx(vU,{control:O,side:s?.placement==="below"?"bottom":"top"})]}):null},Gxe={all:["radient-prices"],prices:()=>[...Gxe.all,"prices"]},PEt=()=>{const e=jt({queryKey:Gxe.prices(),queryFn:()=>mz({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}},pK="https://console.radienthq.com/dashboard/verification",mK="https://console.radienthq.com/dashboard/billing",gK="Top up in Radient console";function _Et(e){return!e.email_verified&&e.signup_grant!=="claimed"}const vun=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`$${e.toFixed(2)} in free credits`,e7=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,TEt=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`${e7(e)} in free credits`;function $K(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function REt(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const XEt=(e,t)=>e==="pending"?{sentence:`Verify your email to claim ${t}. Check your inbox for the link Radient sent.`,action:"Open verification page"}:e==="expired"?{sentence:`The link to claim ${t} has expired. Request a new one from the verification page.`,action:"Request a new link"}:{sentence:"No signup grant is attached to this account. Open the verification page to check the account.",action:"Open verification page"};function EEt(e,t){if(e===void 0)return{state:"unknown",lines:["You're out of credits. If you haven't verified your email yet, verify it to claim free credits and start using Local Operator for free.","Otherwise, top up in the Radient console."],links:[{label:"Open verification page",url:pK},{label:gK,url:mK}]};if(_Et(e)){const i=$K(e.claim_url,pK),{action:a}=XEt(e.signup_grant,"");return e.signup_grant==="none"?{state:"unverified",lines:["You haven't verified your email yet. Open the verification page to check whether free credits are waiting on your account."],links:[{label:a,url:i}]}:{state:"unverified",lines:[`You haven't verified your email yet. Verify to claim ${TEt(e.grant_amount??t)} and start using Local Operator for free.`,e.signup_grant==="expired"?"The link you were sent has expired. Request a new one on the verification page.":"Check your inbox for the link Radient sent."],links:[{label:a,url:i}]}}const n=e.first_topup,r=["You're out of credits. Top up in the Radient console."];return n!==void 0&&n.bonus_received===!1&&Number.isFinite(n.bonus_amount)&&Number.isFinite(n.minimum_purchase)&&r.push(`Get an extra ${e7(n.bonus_amount)} free on your first top-up of ${e7(n.minimum_purchase)} or more.`),{state:"verified",lines:r,links:[{label:gK,url:$K(n?.topup_url,mK)}]}}const qEt=5*1e3,jEt=({action:e})=>{const{user:t,accountRead:n}=QOe({staleTime:qEt,retryOnMount:!1}),r=Xi(),{prices:i}=PEt(),o=r.isPending||n==="checking"?null:EEt(n==="ready"?t?.verification:void 0,i?.default_new_credits);return h.jsxs("div",{className:"mt-1 flex flex-col items-start gap-2 pl-6",children:[o?h.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:[h.jsx(IQ,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),h.jsx("div",{className:"min-w-0 text-body-sm text-ink",children:o.lines.map(s=>h.jsx("p",{className:"[&:not(:first-child)]:mt-1",children:s},s))})]}):null,h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?.links.map(s=>h.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>REt(s.url),children:s.label},s.url)),h.jsx(Ee,{variant:"ghost",size:"sm",asChild:!0,children:h.jsx(Wce,{to:e.to,children:e.label})})]})]})},sR=(e,t,n="normal",r=0)=>{const a=e.scrollTop+t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-r;e.scrollTop=n==="reversed"?Math.min(0,a):Math.max(0,a)},I1=24,Ixe=6,t7=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),yK=async e=>{for(let t=0;t<Ixe;t+=1){if(e())return;await t7()}},Zxe=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},CEt=e=>{const t=Zxe(e.loadOlder),n=()=>yK(()=>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 yK(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},b0="data-jump-highlight",AEt=1400,zEt=12,UEt=1200,WEt=Ixe,NEt=WEt+2,YEt=2,GEt=30,vK=1,Zg=I1;let _h=0;async function IEt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await CEt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:zEt,maxRows:UEt})==="landed"}async function ZEt(e,t,n){if(!n()||!t.isConnected)return;_h+=1;const r=_h;sR(e,t,"reversed",Zg);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<NEt&&(await t7(),!(!n()||!t.isConnected||a||r!==_h));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-Zg;if(Math.abs(O)<=vK){if(l+=1,l>=YEt){c=!0;break}continue}l=0,sR(e,t,"reversed",Zg)}if(c&&!a&&r===_h){const u=e,O=t,d=()=>{a=!0};u.addEventListener("wheel",d,{passive:!0,once:!0}),u.addEventListener("pointerdown",d,{passive:!0,once:!0}),u.addEventListener("touchstart",d,{passive:!0,once:!0}),window.addEventListener("keydown",s),(async()=>{try{for(let f=0;f<GEt;f+=1){if(await t7(),!n()||a||r!==_h||!u.isConnected||!O.isConnected)return;const p=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-Zg;if(Math.abs(p)<=vK)continue;sR(u,O,"reversed",Zg);const m=u.ownerDocument?.defaultView;m!=null&&u.dispatchEvent(new m.Event("scroll"))}}finally{u.removeEventListener("wheel",d),u.removeEventListener("pointerdown",d),u.removeEventListener("touchstart",d),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===_h){const l=e.ownerDocument?.defaultView;l!=null&&e.dispatchEvent(new l.Event("scroll"))}}function Dxe(e,t,n,r=()=>!0){return r()?new Promise(i=>{f4t(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}bK(a),ZEt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(b0)&&bK(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const lR=new WeakMap;function bK(e){const t=lR.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(b0);e.removeAttribute(b0),n&&e.offsetHeight,e.setAttribute(b0,""),lR.set(e,window.setTimeout(()=>{lR.delete(e),e.removeAttribute(b0)},AEt))}const fO=120,qw=400,DEt=.5,VEt=320,MEt=900,jw=64,bP=2,cR=24,uR=3,LEt=4,dy=12,n7=dy,FEt=120,BEt=.35,wK=12,HEt=8,KEt=dy,JEt=.5,SK=()=>({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}),Vxe=e=>Math.min(MEt,Math.max(VEt,Math.round(e*DEt))),eqt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=qw?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=qw?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=qw?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,actTravelled:e.actTravelled||t.travelledPx>=jw,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=qw,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>=jw:e.actTravelled||t.travelledPx>=jw,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>=jw&&!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}},Dg=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=bP,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}}),tqt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!Mxe(t).inZone?!1:t.distanceFromTopPx<=bP?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=n7?!1:n-e.lastInputAt>=fO:!0;function Mxe(e,t=Vxe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const nqt=(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=Vxe(t.clientHeight),{inZone:a}=Mxe(t,i),o=n-e.lastInputAt>=fO||t.distanceFromTopPx<=bP,s=e.revealsThisAct<KEt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<wK&&s)return o?Dg({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed){if(e.deliberate)return Dg(e,r,t);if(r==="fetch"&&e.failures>=uR)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>=fO;return l&&e.clampLatched&&!e.actTravelled&&e.pressDemand&&e.actAsks<n7?Dg(e,r,t):l?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e}}return Dg(e,r,t)}if(e.continuation){const l=e.actAsks<n7,c=l&&e.chainInvisible>0&&e.chainInvisible<dy;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<wK:(c||l&&e.chainFetch<LEt)&&e.failures<uR)?Dg({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},xK=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<HEt,l=r===null&&t&&i!==null&&i<Math.max(FEt,BEt*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,dy):0,continuation:t&&n>0||c&&e.chainInvisible+1<dy||!e.retained&&!e.turnedAround}},rqt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),iqt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),aqt=(e,t,n,r)=>n===r?Lxe(e,t):null,Lxe=(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)<JEt?0:n};function Fxe({path:e}){switch(Qz(e)){case"image":return h.jsx(iAe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return h.jsx(sAe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return h.jsx(ok,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return h.jsx(av,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}function oqt(e,t){try{return rU(e,t)}catch{return!1}}function wU(e,t,n){const r=$.useCallback(async o=>{try{const[s]=await window.api.probeFiles([e],t??void 0);if(!s?.resolved.startsWith("/"))throw new Error("File path has no session working directory");await o(s.resolved)}catch{mi(H("ui.chat.highlights.file_resolution_failed"))}},[e,t]),i=oqt(n??null,e),a=$.useCallback(()=>{r(async o=>{i&&n&&await n.openInCanvas(o)||await jO(o)})},[r,i,n]);return{canOpenInCanvas:i,press:a,withTarget:r}}const Bxe=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1}){const{canOpenInCanvas:o,withTarget:s}=wU(t,r,i),[l,c]=$.useState(!1),u=`Actions for ${n||"this file"}`;return h.jsxs(iA,{children:[h.jsx(Nt,{content:"File actions",children:h.jsx(aA,{asChild:!0,children:a?h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":u,children:h.jsx(aj,{"aria-hidden":"true"})}):h.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":u,children:h.jsx(aj,{"aria-hidden":"true",className:"size-3.5"})})})}),h.jsxs(oA,{align:"end",className:"min-w-45",children:[o&&h.jsxs(El,{onSelect:()=>{s(O=>i?.openInCanvas(O))},children:[h.jsx(Mce,{"aria-hidden":"true"}),h.jsx("span",{children:"Open in canvas"})]}),h.jsxs(El,{onSelect:()=>{s(jO)},children:[h.jsx(av,{"aria-hidden":"true"}),h.jsx("span",{children:"Open in default app"})]}),h.jsxs(El,{onSelect:()=>{s(iU)},children:[h.jsx(kp,{"aria-hidden":"true"}),h.jsx("span",{children:"Reveal in Finder"})]}),h.jsxs(El,{onSelect:()=>{navigator.clipboard.writeText(t).then(()=>c(!0)).catch(()=>mi("Failed to copy file path"))},children:[h.jsx(Yce,{"aria-hidden":"true"}),h.jsx("span",{children:l?"Copied":"Copy file path"})]})]})]})}),sqt="lo-supplement",lqt="s";function cqt(e,t){return`${sqt}://${lqt}/${e}/${t}`}const uqt="[supplement] frame torn down after a second load (hostile navigation or a blocked attempt)";function Oqt(e){let t=e.parentElement;for(;t;){const n=window.getComputedStyle(t);if((n.overflowY==="auto"||n.overflowY==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function dqt({component:e,sessionId:t,documentHtml:n,documentFailed:r=!1,onRetry:i,onHeightChange:a,className:o}){const s=fle(e),[l,c]=$.useState(s),[u,O]=$.useState(!1),[d,f]=$.useState(!0),p=$.useRef(null),m=$.useRef(null),g=$.useRef(""),y=$.useRef(!1),v=$.useRef(""),S=$.useRef(()=>{}),x=$.useRef(0),b=$.useRef(s),w=$.useRef(null),Q=$.useRef(()=>{}),k=$.useRef(a),_=$.useRef(()=>{}),R=$.useCallback(E=>{y.current||(y.current=!0,v.current=E,O(!0))},[]);return $.useEffect(()=>{if(n===null)return;const E=m.current;if(!E)return;g.current=lEe();const T=window.api?.desktop?.armSupplementFrame,j=t!==null&&eS(e.attachment);let C;if(T===void 0)C=dEe(n);else if(j)C=cqt(t,e.attachment);else{R("no-address");return}let W=!1,G=!1,N=null,V=null,F=null;const z={resize:null,error:!1},Z=window.setTimeout(()=>{W||R("no-ready")},NN),J=ne=>{E.contentWindow?.postMessage(ne,"*")},U=()=>{y.current||V===null&&(J({lo:"supplement-host",t:"ping"}),V=window.setTimeout(()=>{V=null,R("no-pong")},NN))};S.current=()=>{G||y.current||(G=!0,U(),N=window.setInterval(U,oEe))};const te=ne=>{const ae=p.current;if(ae){const ce=Oqt(ae);if(ce&&ae.getBoundingClientRect().top<ce.getBoundingClientRect().top){w.current=ne,k.current?.(ne);return}}w.current=null,k.current?.(ne),ne!==b.current&&(b.current=ne,c(ne))},D=()=>{F===null&&(F=window.requestAnimationFrame(()=>{F=null;const{resize:ne,error:ae}=z;if(z.resize=null,z.error=!1,ae){R("frame-error");return}ne!==null&&te(ne)}))},B=ne=>{if(y.current||ne.source!==E.contentWindow||ne.origin!=="null")return;const ae=sEe(ne.data,g.current);if(ae){if(ae.t==="ready"){W||(W=!0,window.clearTimeout(Z));return}if(ae.t==="pong"){V!==null&&(window.clearTimeout(V),V=null);return}if(ae.t==="resize"){z.resize=hle(ae.h),f(!1),D();return}z.error=!0,D()}},he=()=>{const ne=w.current;ne!==null&&te(ne)};window.addEventListener("message",B),window.addEventListener("scroll",he,!0);let M=!1;return(async()=>{if(T)try{await T(C)}catch{}M||(E.src=C)})(),()=>{M=!0,window.clearTimeout(Z),N!==null&&window.clearInterval(N),V!==null&&window.clearTimeout(V),F!==null&&window.cancelAnimationFrame(F),window.removeEventListener("message",B),window.removeEventListener("scroll",he,!0),S.current=()=>{}}},[n,R,t,e.attachment]),k.current=a,_.current=E=>{y.current||x.current!==1||m.current?.contentWindow?.postMessage({lo:"supplement-host",t:"theme",mode:E.mode,vars:E.vars,nonce:g.current},"*")},$.useEffect(()=>OEe(E=>_.current(E)),[]),Q.current=()=>{const E=x.current+1;if(x.current=E,E>1){console.debug(uqt),R("second-load");return}_.current(dle()),S.current()},u||r?h.jsxs("div",{className:"text-ink-dim text-meta","data-supplement-frame-fallback":r?"document":v.current,children:["Couldn't render this graphic",i&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"px-1 text-ink-dim",children:"·"}),h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-frame-retry":"",onClick:()=>i(),children:"Retry"})]})]}):h.jsxs("div",{className:o,"data-supplement-frame-box":"",children:[h.jsxs("div",{ref:p,"data-supplement-frame":"",className:"relative overflow-hidden",style:{height:l,width:"100%"},children:[n!==null&&h.jsx("iframe",{ref:m,title:e.title,sandbox:"allow-scripts",onLoad:()=>Q.current(),className:"block h-full w-full border-0"}),d&&h.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 animate-shimmer bg-elevated/40 bg-gradient-to-r from-transparent via-elevated/60 to-transparent bg-[length:200%_100%] bg-[position:-200%_50%] bg-no-repeat"})]}),h.jsxs("span",{className:"block truncate text-ink-muted text-meta",title:`Source: ${e.source}`,"data-supplement-source":"",children:["Source: ",tp(e.source)]})]})}function fqt(e="200px"){const[t,n]=$.useState(()=>typeof IntersectionObserver>"u"),[r,i]=$.useState(null),a=$.useCallback(o=>i(o),[]);return $.useEffect(()=>{if(r===null||t||typeof IntersectionObserver>"u")return;const o=new IntersectionObserver(s=>{s.some(l=>l.isIntersecting)&&(n(!0),o.disconnect())},{rootMargin:e});return o.observe(r),()=>o.disconnect()},[r,e,t]),[a,t]}const hqt=150,r7=16*1024*1024,Ks=new Map,hp=[];let w0=0,Hxe=0,Kxe=0,i7=0;const bun=()=>({entries:Ks.size,queued:hp.length,active:w0,reads:Hxe,decodes:Kxe,peakActive:i7}),pqt=e=>e.artifact?`finder:${e.artifact.sessionId}:${e.artifact.childId??"self"}:${e.artifact.digest}`:`finder:${e.path}:${e.lastAgentModified??0}:${e.sizeBytes??0}`;async function mqt(e){if(e.artifact)return S2t({sessionId:e.artifact.sessionId,childId:e.artifact.childId??null},e.artifact.digest);const t=await window.api.readFileBytes(e.path,r7);if(!t.success)throw new Error(t.error??"Could not be read");return new Blob([t.data],{type:kz(e.path)})}function Jxe(){for(const[e,t]of Ks){if(Ks.size<=hqt)return;t.listeners.size||t.started||(t.state.url&&Ov(t.state.url),Ks.delete(e))}}function QK(e,t){e.state=t;for(const n of e.listeners)n(t)}function eQe(){for(;w0<4&&hp.length;){const e=hp.shift();if(!e||!e.listeners.size){e&&Ks.delete(e.key);continue}e.started=!0,w0++,Hxe++,i7=Math.max(i7,w0),(async()=>{try{if((e.document.sizeBytes??0)>r7)throw new Error("Too large to preview");const t=await mqt(e.document);if(t.size>r7)throw new Error("Too large to preview");const n=e.document.artifact?.width,r=e.document.artifact?.height,i=n&&r?Math.min(1,640/Math.max(n,r)):null,a=i&&n&&r?{resizeWidth:Math.max(1,Math.round(n*i)),resizeHeight:Math.max(1,Math.round(r*i)),resizeQuality:"high"}:{resizeWidth:640,resizeQuality:"high"};let o,s=null;if(t.type==="image/svg+xml"||e.document.path.toLowerCase().endsWith(".svg")){s=URL.createObjectURL(t);const l=new Image;l.src=s;try{await l.decode()}catch(u){throw URL.revokeObjectURL(s),u}const c=Math.min(1,640/Math.max(l.naturalWidth,l.naturalHeight));l.width=Math.max(1,Math.round(l.naturalWidth*c)),l.height=Math.max(1,Math.round(l.naturalHeight*c)),o=l}else o=await createImageBitmap(t,a);Kxe++;try{const l=Math.min(1,640/Math.max(o.width,o.height)),c=new OffscreenCanvas(Math.max(1,Math.round(o.width*l)),Math.max(1,Math.round(o.height*l))),u=c.getContext("2d");if(!u)throw new Error("Can't preview this image");u.drawImage(o,0,0,c.width,c.height);const O=await c.convertToBlob({type:"image/png"});QK(e,{state:"ready",url:_z(await O.arrayBuffer(),"image/png")})}finally{"close"in o&&o.close(),s&&URL.revokeObjectURL(s)}}catch(t){QK(e,{state:"unavailable",reason:t instanceof Error?t.message:"Could not be read"})}finally{e.started=!1,w0--,Jxe(),eQe()}})()}}function gqt(e,t){const n=pqt(e),[r,i]=$.useState({state:"loading"});return $.useEffect(()=>{if(!t)return;let a=Ks.get(n);a?.state.state==="unavailable"&&!a.listeners.size&&(Ks.delete(n),a=void 0),a?(Ks.delete(n),Ks.set(n,a)):(a={key:n,document:e,state:{state:"loading"},listeners:new Set,started:!1},Ks.set(n,a),hp.push(a)),a.listeners.add(i),i(a.state),eQe();const o=a;return()=>{if(o.listeners.delete(i),!o.started&&o.state.state==="loading"&&!o.listeners.size){const s=hp.indexOf(o);s>=0&&hp.splice(s,1),Ks.delete(n)}Jxe()}},[n,t,e]),r}const $qt="pointer-events-none absolute top-1 right-1 flex 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",yqt=$.memo(function({file:t,cwd:n,pane:r}){const{name:i,path:a}=Ole(t),o=i||a||t.path,[s,l]=fqt(),[c,u]=$.useState(null),[O,d]=$.useState(!1);$.useEffect(()=>{let S=!1;const x=window.api?.probeFiles;if(typeof x!="function"){u(null),d(!0);return}return u(null),d(!1),(async()=>{try{const[b]=await x([t.path],n??void 0),w=b?.resolved??"";S||u(w.startsWith("/")?w:null)}catch{S||u(null)}finally{S||d(!0)}})(),()=>{S=!0}},[t.path,n]);const f=$.useMemo(()=>({id:`supplement:${t.path}`,title:o,path:c??t.path,content:"",type:"image",sizeBytes:t.sizeBytes,lastAgentModified:t.mtime?t.mtime*1e3:void 0}),[t.path,o,t.sizeBytes,t.mtime,c]),p=gqt(f,l&&c!==null),{press:m}=wU(t.path,n,r),g=p.state==="ready"&&typeof p.url=="string",v=!(!O||c!==null&&p.state==="loading")&&(c===null||p.state==="unavailable");return h.jsx("li",{className:"flex leading-none","data-supplement-image-tile":"",children:h.jsxs("div",{className:"group relative",ref:s,children:[h.jsx("button",{type:"button",className:"group/tile block cursor-pointer rounded-sm","aria-label":`Open ${o}`,title:t.path,onClick:()=>void m(),children:g?h.jsx(Qf,{boundary:"control",className:"h-[78px] w-[117px]",children:h.jsx("img",{alt:"",className:"h-[76px] w-[115px] object-contain",src:p.url})}):v?h.jsx("span",{className:"flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken text-ink-dim","data-supplement-image-fallback":"",children:h.jsx(Fxe,{path:t.path})}):h.jsx(Qf,{boundary:"control",className:"h-[78px] w-[117px]"})}),h.jsx("div",{className:$qt,children:h.jsx(Bxe,{overlay:!0,actionPath:t.path,label:o,cwd:n,pane:r})})]})})}),vqt=({files:e,cwd:t,pane:n,className:r})=>h.jsx("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-supplement-images":"",className:q("grid grid-cols-[repeat(4,max-content)] gap-2",r),children:e.map(i=>h.jsx(yqt,{file:i,cwd:t,pane:n},i.path))}),bqt=2*1024*1024,Bh=new Map,OR=new Map,wqt=64,kK={html:null,failed:!1};async function Sqt(e,t){const n=`${e}:${t}`,r=OR.get(n);if(r)return r;const i=(async()=>{try{const a=await SO({op:"sessions.supplementDocument",sessionId:e,digest:t},null);if(a.kind!=="json")return null;const o=a.body,s=o&&typeof o.html=="string"?o.html:null;if(s===null||s.length>bqt)return null;for(Bh.set(n,s);Bh.size>wqt;){const l=Bh.keys().next().value;if(l===void 0)break;Bh.delete(l)}return s}catch{return null}finally{OR.delete(n)}})();return OR.set(n,i),i}function xqt(e,t,n){const[r,i]=$.useState(()=>{if(!e||!eS(t))return kK;const a=Bh.get(`${e}:${t}`);return a!==void 0?{html:a,failed:!1}:kK});return $.useEffect(()=>{if(!n||!e||!eS(t))return;const a=Bh.get(`${e}:${t}`);if(a!==void 0){i({html:a,failed:!1});return}let o=!1;return Sqt(e,t).then(s=>{o||i(s!==null?{html:s,failed:!1}:{html:null,failed:!0})}),()=>{o=!0}},[n,e,t]),r}const PK=$.memo(function({actionPath:t,cwd:n,label:r,suffix:i,size:a,pane:o}){const{press:s}=wU(t,n,o);return h.jsxs("div",{className:"group flex w-full items-center gap-2 text-meta",children:[h.jsx(Fxe,{path:t}),h.jsxs("button",{type:"button",className:"min-w-0 flex-1 truncate text-left text-ink hover:text-ink-dim","data-supplement-file":"",title:t,onClick:()=>{s()},children:[tp(r),i&&i!==r&&h.jsx("span",{className:"ml-2 text-ink-muted",children:tp(i)})]}),a&&h.jsx("span",{className:"shrink-0 text-ink-dim",children:a}),h.jsx(Bxe,{actionPath:t,label:r,cwd:n,pane:o})]})}),_K=$.memo(function({component:t,sessionId:n,onRetry:r,onHeight:i}){const a=$.useRef(null),[o,s]=$.useState(!1);$.useEffect(()=>{const u=a.current;if(u===null)return;if(typeof IntersectionObserver>"u"){s(!0);return}const O=new IntersectionObserver(d=>{for(const f of d)f.isIntersecting&&s(!0)},{rootMargin:"200px 0px"});return O.observe(u),()=>O.disconnect()},[]);const l=xqt(n,t.attachment,o),c=$.useCallback(u=>{i?.(t.attachment,u)},[i,t.attachment]);return h.jsx("div",{ref:a,"data-supplement-slot":"",children:h.jsx(dqt,{component:t,sessionId:n,documentHtml:l.html,documentFailed:l.failed,onRetry:r,onHeightChange:i?c:void 0})})}),Qqt=$.memo(function({record:t,sessionId:n,cwd:r,condensed:i=!1}){const a=hP(),[o,s]=$.useState(!1),[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,f]=$.useState(!1),[p,m]=$.useState(""),[g,y]=$.useState(!1),[v,S]=$.useState(()=>new Map),[x,b]=$.useState(0),w=Y4e(t,t.live),Q=B4e(t.cause),k=t.files,_=t.filesMore,R=t.components,E=k.length+_,T=async D=>{if(n){y(!0);try{await Te({...D,sessionId:n,job:t.job,anchor:t.anchor})}catch(B){mi(lv("Highlights could not be updated.",B))}finally{y(!1)}}},j=()=>{T({op:"supplements.cancel"})},C=()=>{T({op:"supplements.restart"})},W=()=>{const D=p.trim();D&&(f(!1),m(""),T({op:"supplements.steer",text:D}))},G=$.useCallback((D,B)=>{S(he=>{if(he.get(D)===B)return he;const M=new Map(he);return M.set(D,B),M})},[]),N=pEe(typeof window>"u"?900:window.innerHeight),{visible:V}=mEe(R,N,v);$.useEffect(()=>{b(D=>Math.max(D,V.length))},[V.length]);const F=Math.min(R.length,Math.max(x,V.length)),z=R.slice(0,F),Z=R.slice(F),J=()=>w==="preparing"||w==="files_preparing"||w==="cancelled_retry"||w==="files_cancelled_retry"||w==="failed_retry"||w==="files_failed_retry"?h.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta","data-supplement-line":"",children:[(w==="preparing"||w==="files_preparing")&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"relative inline-block size-3 overflow-hidden rounded-full bg-sunken",children:h.jsx("span",{className:"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"})}),h.jsx("span",{className:"text-ink-muted",children:G4e})]}),(w==="cancelled_retry"||w==="files_cancelled_retry")&&h.jsx("span",{className:"text-ink-muted",children:I4e}),(w==="failed_retry"||w==="files_failed_retry")&&h.jsxs("span",{className:"text-ink-muted",children:[Z4e,Q?` — ${Q}`:""]}),(w==="preparing"||w==="files_preparing")&&n&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),!d&&h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-adjust":"",onClick:()=>f(!0),children:D4e}),h.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60","data-supplement-cancel":"",disabled:g||t.state==="cancelling",onClick:j,children:V4e})]}),(w==="cancelled_retry"||w==="files_cancelled_retry"||w==="failed_retry"||w==="files_failed_retry")&&n&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-retry":"",onClick:C,children:M4e})]})]}):null,U=d?h.jsxs("div",{className:"flex items-center gap-2 text-meta","data-supplement-adjust-form":"",children:[h.jsx("input",{autoFocus:!0,className:"min-w-0 flex-1 rounded-sm border border-control bg-canvas px-1.5 py-0.5 text-ink text-meta",maxLength:q4e,placeholder:"Adjust the graphic…",value:p,onChange:D=>m(D.target.value),onKeyDown:D=>{D.key==="Enter"&&W(),D.key==="Escape"&&(f(!1),m(""))}}),h.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60",disabled:g||!p.trim(),onClick:W,children:"Send"})]}):null;if(w==="nothing")return null;let te=null;if(k.length>0||_>0){const D=[],B=[];for(const M of k)Qz(M.path)==="image"?D.push(M):B.push(M);const he=E<=2&&R.length===0&&_===0;te=h.jsxs("div",{className:"flex flex-col gap-1","data-supplement-files-summary":he?"":void 0,"data-supplement-files":he?void 0:"",children:[D.length>0&&h.jsx(vqt,{files:D,cwd:r,pane:a,className:B.length>0||_>0?"mb-1":void 0}),B.map(M=>{const{name:ee,path:ne,size:ae}=Ole(M);return h.jsx(PK,{actionPath:M.path,cwd:r,label:ee||ne,suffix:ne,size:ae,pane:a},`${M.path}:${M.name}`)}),_>0&&h.jsx(ga,{chevronClassName:"text-ink-dim",open:o,onOpenChange:s,rowClassName:"min-h-0 py-0",summary:h.jsx("span",{"data-supplement-more":"",children:o?"Show fewer":H4e(_)}),children:t.more.slice(0,20).map(M=>h.jsx(PK,{actionPath:M,cwd:r,label:M,suffix:"",size:"",pane:a},M))})]})}return i?w==="block"?te===null&&R.length===0?null:h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,"data-supplement-condensed":"",children:[te,te===null&&R.length>0&&h.jsx("div",{className:"text-ink-muted text-meta",children:J4e(R.length,"graphic")})]}):h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,"data-supplement-condensed":"",children:[te,J(),U]}):h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,children:[te,J(),t.detail?.includes("prepared:unsupported")&&h.jsx("p",{className:"text-meta text-ink-muted","data-supplement-refusal":"",children:"Inline preview unavailable. This HTML needs unsupported resources or document content. Open the file to view it."}),(w==="failed_retry"||w==="files_failed_retry")&&h.jsxs("div",{className:"flex flex-col gap-1 text-meta text-ink-muted","data-supplement-diagnostic":"",children:[h.jsx("p",{children:bEe(t)}),((t.attempts?.length??0)>0||(t.detail?.length??0)>0)&&h.jsx(ga,{open:l,onOpenChange:c,rowClassName:"min-h-6 py-0",chevronClassName:"text-ink-dim",summary:"Details",children:h.jsxs("div",{className:"max-h-[min(320px,40vh)] overflow-auto break-words font-mono text-ink-dim",children:[t.model&&h.jsxs("p",{children:["Model: ",t.model]}),h.jsxs("p",{children:["Attempts: ",t.attempts?.length??0]}),t.detail?.map(D=>h.jsx("p",{children:vEe(D)},D))]})})]}),U,w==="block"&&R.length>0&&h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-components":"",children:[z.map(D=>h.jsx(_K,{component:D,sessionId:n,onRetry:n?C:void 0,onHeight:G},D.attachment)),Z.length>0&&h.jsx(ga,{chevronClassName:"text-ink-dim",open:u,onOpenChange:O,rowClassName:"min-h-0 py-0",summary:h.jsx("span",{"data-supplement-show-all":"",children:u?"Show fewer":eEe(Z.length)}),children:Z.map(D=>h.jsx(_K,{component:D,sessionId:n,onRetry:n?C:void 0,onHeight:G},D.attachment))})]})]})});function kqt(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="f"}const Pqt=e=>e?"⌘F":"Ctrl+F";function _qt(e){switch(e){case"ready":case"building":case"unsupported":case"error":return e;default:return"error"}}function Tqt(e,t,n){return n<=0?-1:(((e<0||e>=n?t>0?-1:0:e)+t)%n+n)%n}function Rqt(e,t){return t>=0&&t<e.length?e[t]:null}function Xqt(e,t){const n=[];let r=0;for(const[i,a]of t){const o=Math.max(r,Math.min(e.length,i)),s=Math.max(o,Math.min(e.length,a));s<=o||(o>r&&n.push({text:e.slice(r,o),matched:!1}),n.push({text:e.slice(o,s),matched:!0}),r=s)}return r<e.length&&n.push({text:e.slice(r),matched:!1}),n}const Eqt={user:"You",agent:"Agent"},qqt="related match",TK="Search this conversation",jqt="Search results",Cqt="Close search";function Aqt(e){const t=e.filter(r=>r.tier==="exact").length,n=e.length-t;return n===0?e.length===1?"1 match":`${e.length} matches`:t===0?n===1?"1 related match":`${n} related matches`:`${t} exact · ${n} related`}const zqt="No messages match this search.",Uqt="Still indexing this conversation.",Wqt="Results appear as the index catches up.",Nqt="Newer messages may be missing while the index catches up.",Yqt="This conversation lives on another device, so it cannot be searched here.",Gqt="This conversation could not be searched.",Iqt="Try again",Zqt="Check again",Dqt="Could not reach that message. It is further back than the loaded history — scroll up in the transcript to load more.",Vqt="Updating — the list below is the previous search's.",Mqt="Going to that message…";function Lqt(e){return e===1?"(the first match shown)":`(first ${e} shown)`}function Fqt(e){return e.state==="building"}async function Bqt(e,t){if(e===null)return"not-mounted";const n=e.querySelector("[data-lo-transcript-content]")??e;return await Dxe(n,e,t)==="landed"?"revealed":"not-mounted"}async function Hqt(e){const t=e.query.trim().slice(0,Qse);if(t.length===0)return{query:"",state:"ready",partial:!1,hits:[],truncated:!1};const n=Math.min(Math.max(e.limit??M2e,1),L2e);return Te({op:"sessions.find",sessionId:e.sessionId,q:t,limit:n})}const Kqt=200,Jqt=1500;function ejt({sessionId:e,enabled:t}){const[n,r]=$.useState(""),[i,a]=$.useState("idle"),[o,s]=$.useState([]),[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,f]=$.useState(-1),p=$.useRef(0),m=$.useRef(0),g=$.useRef(0),y=$.useRef(""),v=$.useRef(null),S=$.useRef(null),x=$.useRef(new Set),b=$.useRef(e);b.current=e;const w=$.useCallback(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null)},[]),Q=$.useCallback((C,W)=>{x.current.has(C)||(x.current.add(C),console.warn(C,W))},[]),k=$.useCallback(()=>{p.current+=1,w(),v.current=null,g.current=0,a("idle"),s(C=>C.length===0?C:[]),c(!1),O(!1),f(-1)},[w]),_=$.useRef(()=>{}),R=$.useCallback((C,W)=>{const G=_qt(W.state);a(G);const N=G==="ready"||G==="building",V=N?W.hits:[];if(g.current=V.length,s(V),c(N&&W.truncated),O(G==="building"&&W.partial),f(V.length>0?0:-1),G==="building"&&Fqt(W)){if(v.current!==C){v.current=C;const F=p.current;S.current=setTimeout(()=>{S.current=null,p.current===F&&_.current(C,"follow-up")},Jqt)}}else w()},[w]),E=$.useCallback((C,W)=>{const G=b.current;if(!G)return;const N=p.current,V=++m.current;W==="fresh"&&(w(),v.current=null,a("loading")),Hqt({sessionId:G,query:C}).then(F=>{V!==m.current||p.current!==N||R(C,F)}).catch(F=>{V!==m.current||p.current!==N||(Q("thread search could not be answered:",F),w(),v.current=null,g.current=0,s([]),c(!1),O(!1),f(-1),a("error"))})},[R,w,Q]);_.current=E,$.useEffect(()=>{const C=`${t?"1":"0"}:${e??""}`;if(y.current!==C&&(y.current=C,x.current=new Set,k(),r(V=>V===""?V:""),!t||!e))return;if(!t||!e){k();return}const W=n.trim();if(W.length===0){k();return}const G=p.current,N=setTimeout(()=>{p.current===G&&_.current(W,"fresh")},Kqt);return()=>clearTimeout(N)},[n,t,e,k]),$.useEffect(()=>()=>w(),[w]);const T=$.useCallback(C=>{f(W=>Tqt(W,C,g.current))},[]),j=$.useCallback(()=>{const C=n.trim();!t||!e||C.length===0||_.current(C,"fresh")},[t,e,n]);return{query:n,setQuery:r,state:i,hits:o,truncated:l,partial:u,cursor:d,moveCursor:T,activeHit:Rqt(o,d),refresh:j}}const tjt=q("bg-accent-wash","before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent"),njt="bg-accent-wash font-medium text-ink underline decoration-accent decoration-2 underline-offset-2",rjt=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0,ijt=({hit:e,active:t,optionId:n,onNavigate:r})=>{const i=Xqt(e.snippet,e.ranges);return h.jsxs("li",{id:n,role:"option","aria-selected":t,onMouseDown:a=>a.preventDefault(),onClick:()=>r(e),className:q("relative flex cursor-pointer flex-col gap-0.5 px-3 py-2",t?tjt:"hover:bg-accent-wash"),children:[h.jsxs("span",{className:"flex items-center gap-1.5 text-ink-muted text-meta",children:[h.jsx("span",{children:Eqt[e.role]}),e.tier==="soft"&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:"·"}),h.jsx("span",{className:"text-ink-dim",children:qqt})]})]}),h.jsx("span",{className:"line-clamp-2 text-body-sm text-ink",children:i.map((a,o)=>a.matched?h.jsx("mark",{className:njt,children:a.text},o):h.jsx("span",{children:a.text},o))})]})},ajt=({query:e,onQueryChange:t,state:n,hits:r,cursor:i,truncated:a,partial:o,onMoveCursor:s,onNavigate:l,onRetry:c,onClose:u,isMac:O,jumping:d=!1})=>{const f=$.useId(),p=`${f}-list`,m=$.useCallback(b=>`${f}-opt-${b}`,[f]),g=$.useRef(null),y=i>=0&&i<r.length?r[i]:null,v=r.length>0,S=n==="error"||n==="building";$.useEffect(()=>{g.current?.focus(),g.current?.select()},[]),$.useEffect(()=>{i<0||document.getElementById(m(i))?.scrollIntoView({block:"nearest"})},[i,m]);const x=b=>{if(b.key==="ArrowDown"){b.preventDefault(),s(1);return}if(b.key==="ArrowUp"){b.preventDefault(),s(-1);return}if(b.key==="Enter"){b.preventDefault(),y!==null?l(y):S&&c();return}};return h.jsxs("div",{"data-lo-thread-search":"",role:"presentation",onKeyDown:b=>{b.defaultPrevented||b.key==="Escape"&&(b.preventDefault(),u())},className:"pointer-events-auto w-[26rem] max-w-full rounded-md border border-hairline bg-elevated text-body-sm text-ink shadow-overlay",children:[h.jsx("div",{className:"p-2",children:h.jsxs("div",{className:q("flex items-center gap-2 rounded-sm border border-control bg-surface px-2","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[h.jsx(ov,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-ink-dim"}),h.jsx("input",{ref:g,type:"text",value:e,onChange:b=>t(b.target.value),onKeyDown:x,maxLength:Qse,placeholder:TK,"aria-label":TK,role:"combobox","aria-expanded":v,"aria-controls":v?p:void 0,"aria-activedescendant":y!==null?m(i):void 0,"aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 border-0 bg-transparent text-body-sm text-ink outline-none placeholder:text-ink-dim"}),h.jsx(Ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":Cqt,onClick:u,children:h.jsx(Ji,{"aria-hidden":"true"})})]})}),h.jsxs("div",{className:"flex items-start gap-2 px-3 pb-2",children:[h.jsxs("p",{className:"min-w-0 flex-1 text-ink-muted text-meta",children:[n==="loading"&&(v?Vqt:"Searching…"),n==="ready"&&(r.length>0?Aqt(r):zqt),n==="building"&&(o?Nqt:Uqt),n==="unsupported"&&Yqt,n==="error"&&Gqt,n==="ready"&&a&&v&&h.jsxs("span",{className:"text-ink-dim",children:[" ",Lqt(r.length)]}),n==="building"&&!o&&h.jsxs("span",{className:"text-ink-dim",children:[" ",Wqt]})]}),S&&h.jsx(Ee,{type:"button",variant:"ghost",size:"sm",onClick:c,className:"shrink-0",children:n==="building"?Zqt:Iqt})]}),v&&h.jsx("ul",{id:p,role:"listbox","aria-label":jqt,"aria-busy":n==="loading",className:q("max-h-80 overflow-y-auto border-t border-hairline py-1",n==="loading"&&"opacity-60"),children:r.map((b,w)=>h.jsx(ijt,{hit:b,active:w===i,optionId:m(w),onNavigate:l},b.id))}),d&&h.jsx("output",{className:"block border-t border-hairline px-3 py-1.5 text-ink-muted text-meta",children:Mqt}),h.jsxs("div",{className:"flex items-center gap-3 border-t border-hairline px-3 py-1.5",children:[h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(jd,{shortcut:"↑"}),h.jsx(jd,{shortcut:"↓"}),h.jsx("span",{children:"browse"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(jd,{shortcut:"↵"}),h.jsx("span",{children:"jump"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(jd,{shortcut:"esc"}),h.jsx("span",{children:"close"})]}),h.jsx("span",{className:"ml-auto text-ink-dim text-meta",children:Pqt(O)})]})]})},ojt=({sessionId:e,containerRef:t,onReveal:n})=>{const[r,i]=$.useState(!1),[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(null),c=ejt({sessionId:e,enabled:r}),u=$.useCallback(()=>{const f=document.activeElement;l.current=f instanceof HTMLElement?f:null,i(!0)},[]),O=$.useCallback(()=>{i(!1);const f=l.current;l.current=null,f?.isConnected&&f.focus()},[]);$.useEffect(()=>{const f=p=>{if(p.defaultPrevented||!kqt(p))return;const m=p.target;if(!(!(s.current!==null&&m!==null&&s.current.contains(m))&&(S$(p.target)||$ue(p.target)===null))){if(p.preventDefault(),r){const y=s.current?.querySelector("input");y?.focus(),y?.select();return}u()}};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[r,u]);const d=$.useCallback(async f=>{o(!0);try{if(n){await n(f.id);return}await Bqt(t.current,f.id)}finally{o(!1)}},[t,n]);return r?h.jsx("div",{ref:s,className:"pointer-events-none absolute top-3 right-6 z-20 max-w-[calc(100%-1.5rem)]",children:h.jsx(ajt,{query:c.query,onQueryChange:c.setQuery,state:c.state,hits:c.hits,cursor:c.cursor,truncated:c.truncated,partial:c.partial,onMoveCursor:c.moveCursor,onNavigate:d,onRetry:c.refresh,onClose:O,isMac:rjt(),jumping:a})}):null};function sjt(e,t,n){const r=new Set,i=[0];for(const a of e){if(r.has(a.key))throw new Error(`Duplicate transcript entry: ${a.key}`);r.add(a.key);const o=t.get(a.key),s=o?.signature===a.signature&&o.width===n?o.height:a.estimate;if(!Number.isFinite(s)||s<0)throw new Error(`Invalid transcript extent: ${a.key}`);i.push(i[i.length-1]+s)}return i}function ljt(e,t){for(const[n,r]of e)t.set(n,{...r});e.clear()}function RK(e,t){let n=0,r=e.length;for(;n<r;){const i=n+r>>>1;e[i]<t?n=i+1:r=i}return n}function cjt(e,t,n,r,i){const a=e.length-1,o=new Set(i.filter(O=>O>=0&&O<a)),s=Math.max(0,RK(e,t-r)-1),l=Math.min(a,RK(e,n+r));for(let O=s;O<l;O++)e[O+1]>t-r&&e[O]<n+r&&o.add(O);const c=[];let u=0;for(const O of[...o].sort((d,f)=>d-f))u<O&&c.push({kind:"spacer",start:u,end:O,height:e[O]-e[u]}),c.push({kind:"entry",index:O}),u=O+1;return u<a&&c.push({kind:"spacer",start:u,end:a,height:e[a]-e[u]}),c}function ujt(e,t,n,r){return!e||!t||e.id!==t.id||n!==r?null:t.viewportOffset-e.viewportOffset}function Ojt(e){const t=[];let n=null;return e.forEach((r,i)=>{if((!r.candidate||r.boundary)&&(n=null),r.candidate&&n)n.indices.push(i);else{const a={key:r.firstId,indices:[i],representation:r.representation};t.push(a),n=r.candidate?a:null}}),t}function djt(e,t){return e==="inline"&&t}function tQe(e,t,n,r){const i=Math.max(24,Math.floor((r||810)/7.2)),a=t.split(`
|