local-operator-ui 0.36.2 → 0.36.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/main/index.js +6155 -13
- package/out/preload/index.js +7 -0
- package/out/renderer/assets/{_basePickBy-CcO6nPxQ.js → _basePickBy-DVPdsJYh.js} +1 -1
- package/out/renderer/assets/{_baseUniq-BH2uaUcG.js → _baseUniq-DiBAxxuH.js} +1 -1
- package/out/renderer/assets/{agent-details-page-B3JXwv1Q.js → agent-details-page-Bbf-ap4W.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-DKgp42Gz.js → agent-hub-page-CYf0qdg8.js} +1 -1
- package/out/renderer/assets/{agents-page-Bcgw5NaE.js → agents-page-Ddhn0OiX.js} +3 -3
- package/out/renderer/assets/{arc-yBH7h1fW.js → arc-Dw2y_5Ul.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CHBovRWu.js → architectureDiagram-IEHRJDOE-DEF1EAW4.js} +1 -1
- package/out/renderer/assets/{arrow-up-Di0VTM6O.js → arrow-up-D8Tgt51O.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-vW3btTHI.js → blockDiagram-JOT3LUYC-Si8mcap-.js} +1 -1
- package/out/renderer/assets/{book-open-BklxnVnC.js → book-open-DeWHPw1t.js} +1 -1
- package/out/renderer/assets/browser-page-BXSI_6KL.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-BVQVtCyj.js → browser-webauthn-prompt-bdks5x_s.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-B-omeKTH.js → c4Diagram-VJAJSXHY-D1lx9sOj.js} +1 -1
- package/out/renderer/assets/channel-Cq3l3rsO.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-DbogYOtn.js → chunk-4BMEZGHF-B1OoXuiC.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-B99o2tMG.js → chunk-A2AXSNBT-Cr084INE.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-BHrb34eS.js → chunk-AEK57VVT-6BBu10_U.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-COYEuoan.js → chunk-D6G4REZN-DIlAHP8p.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-D3q2lYwW.js → chunk-RZ5BOZE2-Da0rWE9o.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-CvTfujhG.js → chunk-XZIHB7SX-BtHW2mRW.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DoZsDzLJ.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DoZsDzLJ.js +1 -0
- package/out/renderer/assets/clone-aroLRPNj.js +1 -0
- package/out/renderer/assets/{console-mirror-BThuJoo1.js → console-mirror-BnHVC7eO.js} +1 -1
- package/out/renderer/assets/{consoleCapture-B6L7nb-J.js → consoleCapture-BxykZlLx.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-Csq2qdm5.js → conversation-input-sync-neD8lOHF.js} +5 -5
- package/out/renderer/assets/{dagre-OKDRZEBW-CvnmuVIi.js → dagre-OKDRZEBW-QJnzHJrX.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DUkL0seE.js → diagram-SSKATNLV-CblG8bwr.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DYQJ-990.js → diagram-VNBRO52H-D9VlUgES.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CQWWLpWe.js → erDiagram-Q7BY3M3F-CYdAsxl1.js} +1 -1
- package/out/renderer/assets/{error-boundary-D1EdrZoj.js → error-boundary-Tv9TlaZ8.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CHWTC3wr.js → flowDiagram-4HSFHLVR-EKGuFRMH.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CbYaNbcy.js → ganttDiagram-APWFNJXF-yTSMo4Sy.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-Dz5fATwZ.js → gitGraphDiagram-7IBYFJ6S-e48WwwO4.js} +1 -1
- package/out/renderer/assets/{graph-B4lGCZmF.js → graph-BFjFFISR.js} +1 -1
- package/out/renderer/assets/{index-DhrqAKsM.js → index-CY29neUf.js} +1 -1
- package/out/renderer/assets/index-CZI34YVW.js +829 -0
- package/out/renderer/assets/{index-CcD0LA0Q.js → index-Cb5EO4yE.js} +1 -1
- package/out/renderer/assets/index-hX_aZwq0.js +57 -0
- package/out/renderer/assets/index-vPvXCaIy.css +1 -0
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-CosR91M9.js → infoDiagram-PH2N3AL5-BWXZd-TM.js} +1 -1
- package/out/renderer/assets/{installer-JTz2AD89.js → installer-DjflOef5.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-DTj6yC5Y.js → journeyDiagram-U35MCT3I-DKPVvkIm.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-fHLLpfWW.js → kanban-definition-NDS4AKOZ-ChDhsrXv.js} +1 -1
- package/out/renderer/assets/{layout-BUgJgJ17.js → layout-BOqocwgL.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-CSbcJE7R.js → legacy-agents-page-BSdAE-Bg.js} +1 -1
- package/out/renderer/assets/library-page-BHX5kaQb.js +162 -0
- package/out/renderer/assets/{mermaid.core-DXWoCulQ.js → mermaid.core-CWiad1OO.js} +5 -5
- package/out/renderer/assets/{mesh-page-CYwyEdW1.js → mesh-page-BEVPzgDt.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-C_r984Dl.js → mindmap-definition-ALO5MXBD-2i781X8G.js} +1 -1
- package/out/renderer/assets/{mini-B2a0S_aA.js → mini-Bs0TB08-.js} +1 -1
- package/out/renderer/assets/{notebook-pen-BeIeIauS.js → notebook-pen-CcH01r1l.js} +1 -1
- package/out/renderer/assets/{org-access-B4PFRWtx.js → org-access-CJm_anOl.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-OZbS0xfm.js → org-surface-gate-DbysPTcD.js} +1 -1
- package/out/renderer/assets/{page-header-3Jm521kq.js → page-header-ggruiR-O.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-pPG5qJ25.js → pieDiagram-IB7DONF6-B9lioqV6.js} +1 -1
- package/out/renderer/assets/projects-page-ZT73ye5v.js +40 -0
- package/out/renderer/assets/{publication-validation-r9TKDPj_.js → publication-validation-CyRIAFX-.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-LLUiR4wo.js → quadrantDiagram-7GDLP6J5-D2U4lJl9.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-DfSMH1dj.js → radar-MK3ICKWK-CGhy5L8a.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-CEuhoAow.js → radient-auth-buttons-DneyxZkw.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DhHfvb40.js → requirementDiagram-KVF5MWMF-Cmc8UYRV.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DURUf6SV.js → sankeyDiagram-QLVOVGJD-B_CbdQsw.js} +1 -1
- package/out/renderer/assets/{schedules-page-DiiamPZ_.js → schedules-page-B4YBOXYX.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DTfgNRPc.js → sequenceDiagram-X6HHIX6F-Bafdaefv.js} +1 -1
- package/out/renderer/assets/{settings-page-C3aXNJLk.js → settings-page-7C4s3Pn-.js} +1 -1
- package/out/renderer/assets/{smartart-Dx8zw2rK.js → smartart-CrK5frje.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-Cp2owgQE.js → stateDiagram-DGXRK772-y86P6pOD.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CqZEeEIQ.js +1 -0
- package/out/renderer/assets/{tags-input-chips-Dwb2Ojmj.js → tags-input-chips-GdqiLTXD.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-112iCByD.js → timeline-definition-BDJGKUSR-QGAbBb-D.js} +1 -1
- package/out/renderer/assets/ui-preferences-store-C6eXGzFs.js +1 -0
- package/out/renderer/assets/{use-download-agent-mutation-BGMZQ6m9.js → use-download-agent-mutation-DS3LpOcX.js} +1 -1
- package/out/renderer/assets/{use-memberships-query-Bz3KIW6D.js → use-memberships-query-DUb5oPXP.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-C3LrO077.js → use-session-snapshot-C_Px0a_8.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BfqNCG-d.js → xychartDiagram-VJFVF3MP-xB9WOxhm.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 +2 -2
- package/out/renderer/assets/browser-page-dbyV2lDa.js +0 -1
- package/out/renderer/assets/channel-DseeJDH6.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-D-Nl2hgf.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-D-Nl2hgf.js +0 -1
- package/out/renderer/assets/clone-DYXRTfEl.js +0 -1
- package/out/renderer/assets/index-BqKNVosC.js +0 -57
- package/out/renderer/assets/index-C6uEPUVY.js +0 -829
- package/out/renderer/assets/index-CU8sWhx0.css +0 -1
- package/out/renderer/assets/library-page-97CGidrj.js +0 -162
- package/out/renderer/assets/projects-page-UaamBIPv.js +0 -40
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DD26TncZ.js +0 -1
- package/out/renderer/assets/ui-preferences-store-CfAtSgON.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 ee,j as h,i as fRe,c as q,g as er,t as J,B as Hse,k as ov,L as qd,d as dA,C as Ob,h as yn,e as Uq}from"./index-BqKNVosC.js";import{aR as xp,aS as FQ,aT as Kse,aU as Jse,aV as y$,B as lf,aW as hRe,aX as BQ,aY as pRe,L as ele,aZ as fA,a_ as mRe,C as hA,a$ as gRe,b0 as $Re,e as ta,g as lc,R as Rm,F as tle,E as pA,b1 as zu,b2 as yRe,u as Jn,b3 as vRe,b4 as bRe,b5 as wRe,b6 as SRe,b7 as UN,b8 as xRe,ay as QRe,aG as kRe,b9 as PRe,aM as _Re,ba as TRe,bb as RRe,aA as WN,aB as XRe,bc as HQ,bd as Qp,be as ERe,bf as NN,bg as qRe,bh as jRe,bi as nle,bj as YN,M as rle,bk as ile,bl as CRe,bm as ARe,bn as zRe,bo as URe,aO as mA,bp as WRe,D as NRe,s as GN,bq as W_,z as YRe,br as GRe,y as ale,bs as Wq}from"./ui-preferences-store-CfAtSgON.js";import{ag as IRe,c as Ze,a as Xe,as as gA,D as $A,b as yA,d as ZRe,e as vA,g as DRe,m as Yt,y as oS,z as ole,T as cf,B as Md,h as xu,X as ea,u as br,ah as Nq,a9 as MRe,aa as VRe,aH as LRe,A as Ll,S as Go,q as sle,r as bA,s as wA,t as SA,x as jl,n as E0,o as q0,aG as xA,p as kp,aK as FRe,a1 as BRe,a2 as HRe,a3 as KRe,a8 as JRe,a0 as KQ,N as eXe,Y as tXe,Z as nXe,_ as rXe,I as ao,F as lle,G as cle,H as ule,J as Ole,K as Yq,M as iXe,f as Gq,L as dle,C as aXe,l as _o,P as oXe,Q as sXe,R as IN,U as ZN,V as lXe,W as DN,at as cXe,aL as uXe,i as OXe,v as N_,w as MN,E as VN}from"./error-boundary-D1EdrZoj.js";const dXe="superseded_completion_token",fXe="store_busy",hXe="session_is_remote",pXe="owner_build_behind";function mXe(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 jd(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 fle(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const hle=e=>typeof e?.goal_status=="string",ple=e=>(e?.goal??"").trim().length>0;function gXe(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 j0={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."},LN={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},$Xe={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},yXe={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},vXe={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},bXe={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function FN(e){return e?e===j0.notPaired?yXe:e===j0.serverDown?$Xe:e===j0.frameBudget?bXe:LN:LN}async function QA(e){if(window.api?.desktop)try{return await wXe(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ut?n:_Xe(n)?new ou(Kse,Jse):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 wXe(e,t){const n=fA(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=mRe(t.op,n);a(new Ut(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const mle="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 ou extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function Io(e,t){return e instanceof Ut||e instanceof ou?xp(e.code)?FQ[e.code]:e.message:t}function SXe(e,t,n,r){return typeof r=="string"?r:n===y$.noCredential?lf.noCredential:n===y$.transportFailed?lf.transportFailed:hRe(BQ(e).path,t)}async function Re(e){const t=await QA(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??mle,void 0,SXe(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"&&xXe(n?.result),n?.result}function xXe(e){if(typeof e!="object"||e===null)return;const t=pRe(e.delegated_cleanup_notice);t&&ele.getState().receive(t)}async function QXe(){try{await Re({op:"delegated_cleanup_notice.ack"})}catch{}}async function lln(){ele.getState().dismiss(),await QXe()}function gle(e){return e instanceof Ut&&e.code===hA}function kXe(e){if(!(e instanceof Ut))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===pXe:e.code===hXe}function PXe(e){return e instanceof ou&&e.code===Jse}function _Xe(e){return e instanceof Error&&e.message.includes(Kse)}async function jn(e){const t=await QA(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function TXe(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Re({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 RXe(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"),gRe(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:j0.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function su(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&&xp(o)?o:a===y$.noCredential?lf.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 v$(e){return e.kind==="error"?xp(e.code)?new ou(FQ[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const Iq=e=>({revision:es(e),demand:e.orderDemand}),Vd=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Pp(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(!Vd(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 kA(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 $le(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 yle(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 vle(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 sS(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 ble(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return XXe(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&&Vd(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,...Q}=y;y=Q}return y});$le(a,f=>f.journalGeneration===n&&Vd(f.journalSeq))&&(i=!0);const s=new Map,l=new Map(a.map(f=>[f.id,f])),c=vle(l,f=>f!==void 0&&f.journalGeneration===n&&Vd(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?yle(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)?sS(e,t):sS(e,d.map(f=>f.record))}function XXe(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&&Vd(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();$le(s,m=>m.journalGeneration===n&&Vd(m.journalSeq))&&(o=!0);const c=new Map,u=new Map(s.map(m=>[m.id,m])),O=vle(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,Q=y===void 0?yle(m,u,d,O,c):void 0,b=S??y??Q;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)?sS(e,t):sS(e,p.map(m=>m.record))}function kl(e){const t=e.records.filter(i=>i.kind==="user"&&i.provisional===!0),n=e.records.filter(i=>i.journalGeneration!==e.journalGeneration||!Vd(i.journalSeq)),r=[...t,...n].map(i=>i.sourceEntryId??(i.kind==="tool"||i.kind==="supplement"?null:i.id));if(r.push(...PA(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 PA(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 wle(e,t){const n=e.journalPositions;return kl(e).filter(r=>!n?.has(r)&&!t?.has(r))}const es=e=>e.orderRevision??0;async function EXe(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"?PA(s):l==="lookup"?wle(s):kl(s);let i=e.getTranscript().journalGeneration,a=0,o=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const s=e.getTranscript(),l=Iq(s),c=l.revision,u=e.sweep?.(s,n);if(u?.kind==="none")return{kind:"complete",transcript:s};const O=u?.kind??"authority",d=$Re(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()||es(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 Y_(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function BN(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function cln(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=Y_(a.action_count);if(o===null)continue;const s={actions:o,workedSeconds:BN(a.worked_seconds),failed:Y_(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:Y_(a.cross_session_action_count),crossSessionWorkedSeconds:BN(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 qXe(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 jXe(e,t,n){const r=qXe(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 _A=new Set,ba="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",Zo=new RegExp(`[${ba}]`),JQ=new RegExp(`[${ba}]+`),CXe=new RegExp(`[${ba}]+`,"g"),AXe=new RegExp(`^[${ba}]+|[${ba}]+$`,"g"),zXe=new RegExp(`^[${ba}]+`),UXe=new RegExp(`[^${ba}]`);function on(e){return e.replace(AXe,"")}function lu(e){return e.replace(zXe,"")}function WXe(e,t){return t===0||Zo.test(e[t-1])}function Sle(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&WXe(e,n)&&t.push(n);return t}function ek(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-CY29neUf.js","./index-hX_aZwq0.js","./index-vPvXCaIy.css","./ui-preferences-store-C6eXGzFs.js","./error-boundary-Tv9TlaZ8.js","./index-Cb5EO4yE.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-CWiad1OO.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as $,b as ee,j as h,i as fRe,c as q,g as er,t as J,B as Hse,k as ov,L as qd,d as dA,C as Ob,h as yn,e as Uq}from"./index-hX_aZwq0.js";import{aR as xp,aS as FQ,aT as Kse,aU as Jse,aV as y$,B as lf,aW as hRe,aX as BQ,aY as pRe,L as ele,aZ as fA,a_ as mRe,C as hA,a$ as gRe,b0 as $Re,e as ta,g as lc,R as Rm,F as tle,E as pA,b1 as zu,b2 as yRe,u as Jn,b3 as vRe,b4 as bRe,b5 as wRe,b6 as SRe,b7 as UN,b8 as xRe,ay as QRe,aG as kRe,b9 as PRe,aM as _Re,ba as TRe,bb as RRe,aA as WN,aB as XRe,bc as HQ,bd as Qp,be as ERe,bf as NN,bg as qRe,bh as jRe,bi as nle,bj as YN,M as rle,bk as ile,bl as CRe,bm as ARe,bn as zRe,bo as URe,aO as mA,bp as WRe,D as NRe,s as GN,bq as W_,z as YRe,br as GRe,y as ale,bs as Wq}from"./ui-preferences-store-C6eXGzFs.js";import{ag as IRe,c as Ze,a as Xe,as as gA,D as $A,b as yA,d as ZRe,e as vA,g as DRe,m as Yt,y as oS,z as ole,T as cf,B as Md,h as xu,X as ea,u as br,ah as Nq,a9 as MRe,aa as VRe,aH as LRe,A as Ll,S as Go,q as sle,r as bA,s as wA,t as SA,x as jl,n as E0,o as q0,aG as xA,p as kp,aK as FRe,a1 as BRe,a2 as HRe,a3 as KRe,a8 as JRe,a0 as KQ,N as eXe,Y as tXe,Z as nXe,_ as rXe,I as ao,F as lle,G as cle,H as ule,J as Ole,K as Yq,M as iXe,f as Gq,L as dle,C as aXe,l as _o,P as oXe,Q as sXe,R as IN,U as ZN,V as lXe,W as DN,at as cXe,aL as uXe,i as OXe,v as N_,w as MN,E as VN}from"./error-boundary-Tv9TlaZ8.js";const dXe="superseded_completion_token",fXe="store_busy",hXe="session_is_remote",pXe="owner_build_behind";function mXe(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 jd(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 fle(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const hle=e=>typeof e?.goal_status=="string",ple=e=>(e?.goal??"").trim().length>0;function gXe(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 j0={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."},LN={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},$Xe={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},yXe={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},vXe={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},bXe={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function FN(e){return e?e===j0.notPaired?yXe:e===j0.serverDown?$Xe:e===j0.frameBudget?bXe:LN:LN}async function QA(e){if(window.api?.desktop)try{return await wXe(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ut?n:_Xe(n)?new ou(Kse,Jse):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 wXe(e,t){const n=fA(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=mRe(t.op,n);a(new Ut(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const mle="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 ou extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function Io(e,t){return e instanceof Ut||e instanceof ou?xp(e.code)?FQ[e.code]:e.message:t}function SXe(e,t,n,r){return typeof r=="string"?r:n===y$.noCredential?lf.noCredential:n===y$.transportFailed?lf.transportFailed:hRe(BQ(e).path,t)}async function Re(e){const t=await QA(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??mle,void 0,SXe(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"&&xXe(n?.result),n?.result}function xXe(e){if(typeof e!="object"||e===null)return;const t=pRe(e.delegated_cleanup_notice);t&&ele.getState().receive(t)}async function QXe(){try{await Re({op:"delegated_cleanup_notice.ack"})}catch{}}async function lln(){ele.getState().dismiss(),await QXe()}function gle(e){return e instanceof Ut&&e.code===hA}function kXe(e){if(!(e instanceof Ut))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===pXe:e.code===hXe}function PXe(e){return e instanceof ou&&e.code===Jse}function _Xe(e){return e instanceof Error&&e.message.includes(Kse)}async function jn(e){const t=await QA(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function TXe(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await Re({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 RXe(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"),gRe(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:j0.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function su(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&&xp(o)?o:a===y$.noCredential?lf.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 v$(e){return e.kind==="error"?xp(e.code)?new ou(FQ[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const Iq=e=>({revision:es(e),demand:e.orderDemand}),Vd=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function Pp(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(!Vd(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 kA(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 $le(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 yle(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 vle(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 sS(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 ble(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return XXe(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&&Vd(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,...Q}=y;y=Q}return y});$le(a,f=>f.journalGeneration===n&&Vd(f.journalSeq))&&(i=!0);const s=new Map,l=new Map(a.map(f=>[f.id,f])),c=vle(l,f=>f!==void 0&&f.journalGeneration===n&&Vd(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?yle(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)?sS(e,t):sS(e,d.map(f=>f.record))}function XXe(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&&Vd(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();$le(s,m=>m.journalGeneration===n&&Vd(m.journalSeq))&&(o=!0);const c=new Map,u=new Map(s.map(m=>[m.id,m])),O=vle(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,Q=y===void 0?yle(m,u,d,O,c):void 0,b=S??y??Q;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)?sS(e,t):sS(e,p.map(m=>m.record))}function kl(e){const t=e.records.filter(i=>i.kind==="user"&&i.provisional===!0),n=e.records.filter(i=>i.journalGeneration!==e.journalGeneration||!Vd(i.journalSeq)),r=[...t,...n].map(i=>i.sourceEntryId??(i.kind==="tool"||i.kind==="supplement"?null:i.id));if(r.push(...PA(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 PA(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 wle(e,t){const n=e.journalPositions;return kl(e).filter(r=>!n?.has(r)&&!t?.has(r))}const es=e=>e.orderRevision??0;async function EXe(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"?PA(s):l==="lookup"?wle(s):kl(s);let i=e.getTranscript().journalGeneration,a=0,o=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const s=e.getTranscript(),l=Iq(s),c=l.revision,u=e.sweep?.(s,n);if(u?.kind==="none")return{kind:"complete",transcript:s};const O=u?.kind??"authority",d=$Re(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()||es(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 Y_(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function BN(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function cln(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=Y_(a.action_count);if(o===null)continue;const s={actions:o,workedSeconds:BN(a.worked_seconds),failed:Y_(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:Y_(a.cross_session_action_count),crossSessionWorkedSeconds:BN(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 qXe(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 jXe(e,t,n){const r=qXe(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 _A=new Set,ba="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",Zo=new RegExp(`[${ba}]`),JQ=new RegExp(`[${ba}]+`),CXe=new RegExp(`[${ba}]+`,"g"),AXe=new RegExp(`^[${ba}]+|[${ba}]+$`,"g"),zXe=new RegExp(`^[${ba}]+`),UXe=new RegExp(`[^${ba}]`);function on(e){return e.replace(AXe,"")}function lu(e){return e.replace(zXe,"")}function WXe(e,t){return t===0||Zo.test(e[t-1])}function Sle(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&WXe(e,n)&&t.push(n);return t}function ek(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 NXe(e,t){if(t.size===0)return null;for(const n of Sle(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 TA(e,t,n){const r=NXe(e,n);let i=null;for(const a of Sle(e)){if(a===r)return t>a?a:i;a<=t&&(i=a)}return i}function sv(e,t=null,n=_A){const{line:r,lineStart:i,column:a}=ek(e,t),o=TA(r,a,n);if(o===null)return null;let s=o+1;for(;s<r.length&&!Zo.test(r[s]);)s++;return a>s?null:{start:i+o,query:r.slice(o+1,s),end:i+s}}function b$(e,t=null,n=_A){const{line:r,lineStart:i,column:a}=ek(e,t),o=TA(r,a,n);return o===null?null:{start:i+o,end:i+r.length}}function tk(e,t,n=null,r=_A){const{line:i,lineStart:a,column:o}=ek(e,n),s=r.size>0?r:new Set(t.map(f=>f.toLowerCase())),l=TA(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 Zq(e,t){return on(e.slice(0,t))===""}function YXe(e,t,n,r){const i=tk(e,r,t,n);if(i!==null&&Zq(e,i.tokenStart))return"argument";const a=sv(e,t,n);return a!==null&&Zq(e,a.start)?"command":null}function vO(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 GXe=/^\$([A-Za-z0-9][A-Za-z0-9._-]*)/,IXe=/<skill name="([^"]*)" invocation="([^"]*)">/;function HN(e,t){const n=lu(e),r=GXe.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=on(n.slice(r[0].length));return{name:a,request:o,token:r[0],typed:on(n)}}function ZXe(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\n/g," ")}function DXe(e){return e.replace(/ /g,`
|
|
@@ -829,7 +829,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
829
829
|
`))};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=Ie.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((ct.mac||ct.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:Fn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);a8(t,c,Ie.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(cn.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:ege.of(cn.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=L$(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||Qnt(t.parent)||document,this.viewState=new wM(t.state||Nn.create(t)),t.scrollTo&&t.scrollTo.is(Zb)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Lh).map(i=>new wT(i));for(let i of this.plugins)i.update(this);this.observer=new Irt(this),this.inputState=new drt(this),this.inputState.ensureHandlers(this.plugins),this.docView=new rM(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 Ki?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(fge))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=hge(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(Nn.phrases)!=this.state.facet(Nn.phrases))return this.setState(a);i=MS.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 fp(f.empty?f:Ie.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of d.effects)f.is(Zb)&&(O=f.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=LS.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(m0)!=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(Bb)!=i.state.facet(Bb)&&(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(Y3))try{d(i)}catch(f){no(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!sge(this,u)&&c.force&&dp(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 wM(t),this.plugins=t.facet(Lh).map(r=>new wT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new rM(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(Lh),r=t.state.facet(Lh);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new wT(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){no(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(_me(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 no(this.state,p),kM}}),O=MS.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]!=kM)try{let p=c[f];p.write&&p.write(u[f],this)}catch(p){no(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(Y3))s(n)}get themeClasses(){return M3+" "+(this.state.facet(D3)?$ge:gge)+" "+this.state.facet(Bb)}updateAttrs(){let t=PM(this,tge,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Gc)?"true":"false",class:"cm-content",style:`${ct.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),PM(this,n8,n);let r=this.observer.ignore(()=>{let i=A3(this.contentDOM,this.contentAttrs,n),a=A3(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(m0);let t=this.state.facet(Pt.cspNonce);EO.mount(this.root,this.styleModules.concat(Yrt).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 xT(this,t,lM(this,t,n,r))}moveByGroup(t,n){return xT(this,t,lM(this,t,n,r=>rrt(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 Ie.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return nrt(this,t,n,r)}moveVertically(t,n,r){return xT(this,t,irt(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(),oge(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.docView.coordsAt(t,n);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(t),a=this.bidiSpans(i),o=a[dO.find(a,t-i.from,-1,n)];return Pv(r,o.dir==Er.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(Hme)||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>Mrt)return Ime(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||Gme(a.isolates,r=nM(this,t))))return a.order;r||(r=nM(this,t));let i=Nnt(t.text,n,r);return this.bidiCache.push(new LS(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ct.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{kme(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 Zb.of(new fp(typeof t=="number"?Ie.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 Zb.of(new fp(Ie.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 Ti.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Ti.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=EO.newName(),i=[Bb.of(r),m0.of(V3(`.${r}`,t))];return n&&n.dark&&i.push(D3.of(!0)),i}static baseTheme(t){return ZO.lowest(m0.of(V3("."+M3,t,yge)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&ur.get(r)||ur.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}Pt.styleModule=m0;Pt.inputHandler=Fme;Pt.clipboardInputFilter=e8;Pt.clipboardOutputFilter=t8;Pt.scrollHandler=Jme;Pt.focusChangeEffect=Bme;Pt.perLineTextDirection=Hme;Pt.exceptionSink=Lme;Pt.updateListener=Y3;Pt.editable=Gc;Pt.mouseSelectionStyle=Vme;Pt.dragMovesSelection=Mme;Pt.clickAddsSelectionRange=Dme;Pt.decorations=F$;Pt.outerDecorations=nge;Pt.atomicRanges=r8;Pt.bidiIsolatedRanges=rge;Pt.scrollMargins=ige;Pt.darkTheme=D3;Pt.cspNonce=ht.define({combine:e=>e.length?e[0]:""});Pt.contentAttributes=n8;Pt.editorAttributes=tge;Pt.lineWrapping=Pt.contentAttributes.of({class:"cm-lineWrapping"});Pt.announce=_n.define();const Mrt=4096,kM={};class LS{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:Er.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 LS(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function PM(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&&C3(o,n)}return n}const Vrt=ct.mac?"mac":ct.windows?"win":ct.linux?"linux":"key";function Lrt(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 Hb(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 Frt=ZO.default(Pt.domEventHandlers({keydown(e,t){return bge(vge(t.state),e,t,"editor")}})),Nk=ht.define({enables:Frt}),_M=new WeakMap;function vge(e){let t=e.facet(Nk),n=_M.get(t);return n||_M.set(t,n=Hrt(t.reduce((r,i)=>r.concat(i),[]))),n}function uOn(e,t,n){return bge(vge(e.state),t,e,n)}let iO=null;const Brt=4e3;function Hrt(e,t=Vrt){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=>Lrt(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 Q=iO={view:S,prefix:v,scope:o};return setTimeout(()=>{iO==Q&&(iO=null)},Brt),!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,L3))}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 L3=null;function bge(e,t,n,r){L3=t;let i=vnt(t),a=Ro(i,0),o=Yc(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;iO&&iO.view==n&&iO.scope==r&&(s=iO.prefix+" ",cge.indexOf(t.keyCode)<0&&(c=!0,iO=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+Hb(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(ct.windows&&t.ctrlKey&&t.altKey)&&(p=qO[t.keyCode])&&p!=i?(d(f[s+Hb(p,t,!0)])||t.shiftKey&&(m=V$[t.keyCode])!=i&&m!=p&&d(f[s+Hb(m,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(f[s+Hb(i,t,!0)])&&(l=!0),!l&&d(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),L3=null,l}class Rv{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=wge(t);return[new Rv(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return Krt(t,n,r)}}function wge(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Er.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function TM(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 Krt(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==Er.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=wge(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=I3(e,r,1),p=I3(e,i,-1),m=f.type==Na.Text?f:null,g=p.type==Na.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=TM(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=TM(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):Q(f,!1),w=g?S(null,n.to,g):Q(p,!0),x=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&b.bottom+e.defaultLineHeight/2<w.top?x.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(x).concat(v(w))}function y(b,w,x,k){return new Rv(t,b-l.left,w-l.top,x-b,k-w)}function v({top:b,bottom:w,horizontal:x}){let k=[];for(let T=0;T<x.length;T+=2)k.push(y(x[T],b,x[T+1],w));return k}function S(b,w,x){let k=1e9,T=-1e9,_=[];function E(C,W,G,N,Z){let F=e.coordsAtPos(C,C==x.to?-2:2),z=e.coordsAtPos(G,G==x.from?2:-2);!F||!z||(k=Math.min(F.top,z.top,k),T=Math.max(F.bottom,z.bottom,T),Z==Er.LTR?_.push(a&&W?O:F.left,a&&N?d:z.right):_.push(!a&&N?O:z.left,!a&&W?d:F.right))}let R=b??x.from,j=w??x.to;for(let C of e.visibleRanges)if(C.to>R&&C.from<j)for(let W=Math.max(C.from,R),G=Math.min(C.to,j);;){let N=e.state.doc.lineAt(W);for(let Z of e.bidiSpans(N)){let F=Z.from+N.from,z=Z.to+N.from;if(F>=G)break;z>W&&E(Math.max(F,W),b==null&&F<=R,Math.min(z,G),w==null&&z>=j,Z.dir)}if(W=N.to+1,W>=G)break}return _.length==0&&E(R,b==null,j,w==null,e.textDirection),{top:k,bottom:T,horizontal:_}}function Q(b,w){let x=s.top+(w?b.top:b.bottom);return{top:x,bottom:x,horizontal:[]}}}function Jrt(e,t){return e.constructor==t.constructor&&e.eq(t)}class eit{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(R1)!=t.state.facet(R1)&&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(R1);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)=>!Jrt(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 R1=ht.define();function Sge(e){return[Ti.define(t=>new eit(t,e)),R1.of(e)]}const B$=ht.define({combine(e){return Nm(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function OOn(e={}){return[B$.of(e),tit,nit,rit,Kme.of(!0)]}function xge(e){return e.startState.facet(B$)!=e.state.facet(B$)}const tit=Sge({above:!0,markers(e){let{state:t}=e,n=t.facet(B$),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:Ie.cursor(i.head,i.head>i.anchor?-1:1);for(let l of Rv.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=xge(e);return n&&RM(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){RM(t.state,e)},class:"cm-cursorLayer"});function RM(e,t){t.style.animationDuration=e.facet(B$).cursorBlinkRate+"ms"}const nit=Sge({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:Rv.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||xge(e)},class:"cm-selectionLayer"}),rit=ZO.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"}}}})),Qge=_n.define({map(e,t){return e==null?null:t.mapPos(e)}}),y0=co.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(Qge)?r.value:n,e)}}),iit=Ti.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(y0);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(y0)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(y0),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(y0)!=e&&this.view.dispatch({effects:Qge.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 dOn(){return[y0,iit]}function XM(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 ait(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 oit{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 gf,r=n.add.bind(n);for(let{from:i,to:a}of ait(t,this.maxLength))XM(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 XM(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 F3=/x/.unicode!=null?"gu":"g",sit=new RegExp(`[\0-\b
|
|
830
830
|
--\u2028\u2029\uFEFF-]`,F3),lit={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 PT=null;function cit(){var e;if(PT==null&&typeof document<"u"&&document.body){let t=document.body.style;PT=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return PT||!1}const X1=ht.define({combine(e){let t=Nm(e,{render:null,specialChars:sit,addSpecialChars:null});return(t.replaceTabs=!cit())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,F3)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,F3)),t}});function fOn(e={}){return[X1.of(e),uit()]}let EM=null;function uit(){return EM||(EM=Ti.fromClass(class{constructor(e){this.view=e,this.decorations=cn.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(X1)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new oit({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=Ro(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=XO(o.text,s,r-o.from);return cn.replace({widget:new hit((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=cn.replace({widget:new fit(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(X1);e.startState.facet(X1)!=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 Oit="•";function dit(e){return e>=32?Oit:e==10?"":String.fromCharCode(9216+e)}class fit extends Tu{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=dit(this.code),r=t.state.phrase("Control character")+" "+(lit[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 hit extends Tu{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 hOn(){return mit}const pit=cn.line({class:"cm-activeLine"}),mit=Ti.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(pit.range(i.from)),t=i.from)}return cn.set(n)}},{decorations:e=>e.decorations});class git extends Tu{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?zp(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=Pv(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 pOn(e){let t=Ti.fromClass(class{constructor(n){this.view=n,this.placeholder=e?cn.set([cn.widget({widget:new git(e),side:1}).range(0)]):cn.none}get decorations(){return this.view.state.doc.length?cn.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,Pt.contentAttributes.of({"aria-placeholder":e})]:t}const B3=2e3;function $it(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>B3||n.off>B3||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(Ie.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=_3(c.text,o,e.tabSize,!0);if(u<0)a.push(Ie.cursor(c.to));else{let O=_3(c.text,s,e.tabSize);a.push(Ie.range(c.from+u,c.from+O))}}}return a}function yit(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function qM(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>B3?-1:i==r.length?yit(e,t.clientX):XO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function vit(e,t){let n=qM(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=qM(e,i);if(!s)return r;let l=$it(e.state,n,s);return l.length?o?Ie.create(l.concat(r.ranges)):Ie.create(l):r}}:null}function mOn(e){let t=n=>n.altKey&&n.button==0;return Pt.mouseSelectionStyle.of((n,r)=>t(r)?vit(n,r):null)}const bit={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},wit={style:"cursor: crosshair"};function gOn(e={}){let[t,n]=bit[e.key||"Alt"],r=Ti.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?wit:null})]}const kg="-10000px";class kge{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 Sit(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const _T=ht.define({combine:e=>{var t,n,r;return{position:ct.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)||Sit}}}),jM=new WeakMap,l8=Ti.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(_T);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 kge(e,c8,(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(_T);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=kg,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(ct.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==kg&&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=i8(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(_T).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=kg;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=(t=jM.get(c))!==null&&t!==void 0?t:d.bottom-d.top,y=c.offset||Qit,v=this.view.textDirection==Er.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),Q=this.above[s];!l.strictSide&&(Q?O.top-g-p-y.y<r.top:O.bottom+g+p+y.y>r.bottom)&&Q==r.bottom-O.bottom>O.top-r.top&&(Q=this.above[s]=!Q);let b=(Q?O.top-r.top:r.bottom-O.bottom)-p;if(b<g&&c.resize!==!1){if(b<this.view.defaultLineHeight){u.style.top=kg;continue}jM.set(c,g),u.style.height=(g=b)/a+"px"}else u.style.height&&(u.style.height="");let w=Q?O.top-g-p-y.y:O.bottom+p+y.y,x=S+m;if(c.overlap!==!0)for(let k of o)k.left<x&&k.right>S&&k.top<w+g&&k.bottom>w&&(w=Q?k.top-g-2-p:k.bottom+p+2);if(this.position=="absolute"?(u.style.top=(w-e.parent.top)/a+"px",CM(u,(S-e.parent.left)/i)):(u.style.top=w/a+"px",CM(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:x,bottom:w+g}),u.classList.toggle("cm-tooltip-above",Q),u.classList.toggle("cm-tooltip-below",!Q),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=kg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function CM(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const xit=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"}}}),Qit={x:0,y:0},c8=ht.define({enables:[l8,xit]}),FS=ht.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class Yk{static create(t){return new Yk(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new kge(t,FS,(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 kit=c8.compute([FS],e=>{let t=e.facet(FS);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:Yk.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class Pit{constructor(t,n,r,i,a){this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:n}=this,r=t.docView.nearest(n.target);if(!r)return;let i,a=1;if(r instanceof OO)i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let s=t.coordsAtPos(i);if(!s||n.y<s.top||n.y>s.bottom||n.x<s.left-t.defaultCharacterWidth||n.x>s.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==Er.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=>no(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(l8),n=t?t.manager.tooltips.findIndex(r=>r.create==Yk.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&&!_it(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:!Tit(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 Kb=4;function _it(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-Kb&&t.clientX<=r+Kb&&t.clientY>=i-Kb&&t.clientY<=a+Kb}function Tit(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 $On(e,t={}){let n=_n.define(),r=co.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,Hi.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(Rit)&&(i=[]);return i},provide:i=>FS.from(i)});return{active:r,extension:[r,Ti.define(i=>new Pit(i,e,r,n,t.hoverTime||300)),kit]}}function Pge(e,t){let n=e.plugin(l8);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const Rit=_n.define(),AM=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 yOn(e,t){let n=e.plugin(_ge),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const _ge=Ti.fromClass(class{constructor(e){this.input=e.state.facet(UM),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(AM);this.top=new Jb(e,!0,t.topContainer),this.bottom=new Jb(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(AM);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Jb(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Jb(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(UM);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 Jb{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=zM(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=zM(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 zM(e){let t=e.nextSibling;return e.remove(),t}const UM=ht.define({enables:_ge});class hu extends mf{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}hu.prototype.elementClass="";hu.prototype.toDOM=void 0;hu.prototype.mapMode=Hi.TrackBefore;hu.prototype.startSide=hu.prototype.endSide=-1;hu.prototype.point=!0;const E1=ht.define(),Xit=ht.define(),Eit={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Pn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},F0=ht.define();function qit(e){return[Tge(),F0.of({...Eit,...e})]}const WM=ht.define({combine:e=>e.some(t=>t)});function Tge(e){return[jit]}const jit=Ti.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(F0).map(t=>new YM(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(WM),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(WM)!=!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=Pn.iter(this.view.state.facet(E1),this.view.viewport.from),r=[],i=this.gutters.map(a=>new Cit(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){H3(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){H3(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(F0),n=e.state.facet(F0),r=e.docChanged||e.heightChanged||e.viewportChanged||!Pn.eq(e.startState.facet(E1),e.state.facet(E1),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 YM(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==Er.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function NM(e){return Array.isArray(e)?e:[e]}function H3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Cit{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=Pn.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 Rge(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=[];H3(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(Xit)){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 YM{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=NM(n.markers(t)),n.initialSpacer&&(this.spacer=new Rge(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=NM(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!Pn.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 Rge{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":""),Ait(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 Ait(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 zit=ht.define(),Uit=ht.define(),Fh=ht.define({combine(e){return Nm(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 TT extends hu{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function RT(e,t){return e.state.facet(Fh).formatNumber(t,e.state)}const Wit=F0.compute([Fh],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(zit)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new TT(RT(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(Uit)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(Fh)!=t.state.facet(Fh),initialSpacer(t){return new TT(RT(t,GM(t.state.doc.lines)))},updateSpacer(t,n){let r=RT(n.view,GM(n.view.state.doc.lines));return r==t.number?t:new TT(r)},domEventHandlers:e.facet(Fh).domEventHandlers}));function vOn(e={}){return[Fh.of(e),Tge(),Wit]}function GM(e){let t=9;for(;t<e;)t=t*10+9;return t}const Nit=new class extends hu{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Yit=E1.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(Nit.range(i)))}return Pn.of(t)});function bOn(){return Yit}let Git=0;class it{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=Git++}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 it&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new it(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 BS(t);return r=>r.modified.indexOf(n)>-1?r:BS.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let Iit=0;class BS{constructor(t){this.name=t,this.instances=[],this.id=Iit++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&Zit(n,s.modified));if(r)return r;let i=[],a=new it(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=Dit(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(BS.get(s,l));return a}}function Zit(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function Dit(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 HS(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return Xge.add(t)}const Xge=new Gt;let HS=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}};HS.empty=new HS([],2,null);function Ege(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 Mit(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Vit(e,t,n,r=0,i=e.length){let a=new Lit(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class Lit{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=Fit(t)||HS.empty,O=Mit(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(Gt.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,Q=Math.max(n,y),b=Math.min(r,S);if(Q<b&&m)for(;t.from<b&&(this.highlightRange(t,Q,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 Fit(e){let t=e.type.prop(Xge);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const tt=it.define,ew=tt(),Hu=tt(),IM=tt(Hu),ZM=tt(Hu),Ku=tt(),tw=tt(Ku),XT=tt(Ku),Ql=tt(),Od=tt(Ql),yl=tt(),vl=tt(),K3=tt(),Pg=tt(K3),nw=tt(),P={comment:ew,lineComment:tt(ew),blockComment:tt(ew),docComment:tt(ew),name:Hu,variableName:tt(Hu),typeName:IM,tagName:tt(IM),propertyName:ZM,attributeName:tt(ZM),className:tt(Hu),labelName:tt(Hu),namespace:tt(Hu),macroName:tt(Hu),literal:Ku,string:tw,docString:tt(tw),character:tt(tw),attributeValue:tt(tw),number:XT,integer:tt(XT),float:tt(XT),bool:tt(Ku),regexp:tt(Ku),escape:tt(Ku),color:tt(Ku),url:tt(Ku),keyword:yl,self:tt(yl),null:tt(yl),atom:tt(yl),unit:tt(yl),modifier:tt(yl),operatorKeyword:tt(yl),controlKeyword:tt(yl),definitionKeyword:tt(yl),moduleKeyword:tt(yl),operator:vl,derefOperator:tt(vl),arithmeticOperator:tt(vl),logicOperator:tt(vl),bitwiseOperator:tt(vl),compareOperator:tt(vl),updateOperator:tt(vl),definitionOperator:tt(vl),typeOperator:tt(vl),controlOperator:tt(vl),punctuation:K3,separator:tt(K3),bracket:Pg,angleBracket:tt(Pg),squareBracket:tt(Pg),paren:tt(Pg),brace:tt(Pg),content:Ql,heading:Od,heading1:tt(Od),heading2:tt(Od),heading3:tt(Od),heading4:tt(Od),heading5:tt(Od),heading6:tt(Od),contentSeparator:tt(Ql),list:tt(Ql),quote:tt(Ql),emphasis:tt(Ql),strong:tt(Ql),link:tt(Ql),monospace:tt(Ql),strikethrough:tt(Ql),inserted:tt(),deleted:tt(),changed:tt(),invalid:tt(),meta:nw,documentMeta:tt(nw),annotation:tt(nw),processingInstruction:tt(nw),definition:it.defineModifier("definition"),constant:it.defineModifier("constant"),function:it.defineModifier("function"),standard:it.defineModifier("standard"),local:it.defineModifier("local"),special:it.defineModifier("special")};for(let e in P){let t=P[e];t instanceof it&&(t.name=e)}Ege([{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 ET;const fO=new Gt;function Gk(e){return ht.define({combine:e?t=>t.concat(e):void 0})}const u8=new Gt;class Ao{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Nn.prototype.hasOwnProperty("tree")||Object.defineProperty(Nn.prototype,"tree",{get(){return Bn(this)}}),this.parser=n,this.extension=[CO.of(this),Nn.languageData.of((a,o,s)=>{let l=DM(a,o,s),c=l.type.prop(fO);if(!c)return[];let u=a.facet(c),O=l.type.prop(u8);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 DM(t,n,r).type.prop(fO)==this.data}findRegions(t){let n=t.facet(CO);if(n?.data==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(a,o)=>{if(a.prop(fO)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(Gt.mounted);if(s){if(s.tree.prop(fO)==this.data){if(s.overlay)for(let l of s.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+a.length});return}else if(s.overlay){let l=r.length;if(i(s.tree,s.overlay[0].from+o),r.length>l)return}}for(let l=0;l<a.children.length;l++){let c=a.children[l];c instanceof hn&&i(c,a.positions[l]+o)}};return i(Bn(t),0),r}get allowsNesting(){return!0}}Ao.setState=_n.define();function DM(e,t,n){let r=e.facet(CO),i=Bn(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,cr.ExcludeBuffers))a.type.isTop&&(i=a);return i}class Rn extends Ao{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=Gk(t.languageData);return new Rn(n,t.parser.configure({props:[fO.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Rn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Bn(e){let t=e.field(Ao.state,!1);return t?t.tree:hn.empty}class Bit{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 _g=null;class bf{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 bf(t,n,[],hn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Bit(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=hn.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(eu.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(eu.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=_g;_g=this;try{return t()}finally{_g=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=MM(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=eu.applyChanges(r,l),i=hn.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 bf(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=MM(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 Ak{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=_g;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 hn(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 _g}}function MM(e,t,n){return eu.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Yp{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 Yp(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=bf.create(t.facet(CO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Yp(r)}}Ao.state=co.define({create:Yp.init,update(e,t){for(let n of t.effects)if(n.is(Ao.setState))return n.value;return t.startState.facet(CO)!=t.state.facet(CO)?Yp.init(t.state):e.apply(t)}});let qge=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(qge=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const qT=typeof navigator<"u"&&(!((ET=navigator.scheduling)===null||ET===void 0)&&ET.isInputPending)?()=>navigator.scheduling.isInputPending():null,Hit=Ti.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(Ao.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(Ao.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=qge(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(Ao.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!qT?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>qT&&qT()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:Ao.setState.of(new Yp(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=>no(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()}}}),CO=ht.define({combine(e){return e.length?e[0]:null},enables:e=>[Ao.state,Hit,Pt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class wn{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 Kit=ht.define(),Ik=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 KS(e){let t=e.facet(Ik);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Jit(e,t){let n="",r=e.tabSize,i=e.facet(Ik)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function eat(e,t){e instanceof Nn&&(e=new jge(e));for(let r of e.state.facet(Kit)){let i=r(e,t);if(i!==void 0)return i}let n=Bn(e.state);return n.length>=t?tat(e,n,t):null}class jge{constructor(t,n={}){this.state=t,this.options=n,this.unit=KS(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 XO(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 Yr=new Gt;function tat(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 Cge(r,e,n)}function Cge(e,t,n){for(let r=e;r;r=r.next){let i=rat(r.node);if(i)return i(O8.create(t,n,r))}return 0}function nat(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function rat(e){let t=e.type.prop(Yr);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Gt.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>Age(o,!0,1,void 0,a&&!nat(o)?i.from:void 0)}return e.parent==null?iat:null}function iat(){return 0}class O8 extends jge{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 O8(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(aat(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Cge(this.context.next,this.base,this.pos)}}function aat(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function oat(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 bs({closing:e,align:t=!0,units:n=1}){return r=>Age(r,t,n,e)}function Age(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?oat(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const d8=e=>e.baseIndent;function Lr({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const sat=200;function xOn(){return Nn.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+sat)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=eat(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],f=Jit(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 zge=ht.define(),Cr=new Gt;function wa(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 lat(e,t,n){let r=Bn(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(Cr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!cat(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function cat(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function JS(e,t,n){for(let r of e.facet(zge)){let i=r(e,t,n);if(i)return i}return lat(e,t,n)}function Uge(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 Zk=_n.define({map:Uge}),Xv=_n.define({map:Uge});function Wge(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 wf=co.define({create(){return cn.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Zk)&&!uat(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Gge),i=r?cn.replace({widget:new mat(r(t.state,n.value))}):VM;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(VM.range(r,i))}return cn.set(t,!0)}});function ex(e,t,n){var r;let i=null;return(r=e.field(wf,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function uat(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(wf,!1)?t:t.concat(_n.appendConfig.of(Ige()))}const Oat=e=>{for(let t of Wge(e)){let n=JS(e.state,t.from,t.to);if(n)return e.dispatch({effects:Nge(e.state,[Zk.of(n),Yge(e,n)])}),!0}return!1},dat=e=>{if(!e.state.field(wf,!1))return!1;let t=[];for(let n of Wge(e)){let r=ex(e.state,n.from,n.to);r&&t.push(Xv.of(r),Yge(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function Yge(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 fat=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=JS(t,i.from,i.to);a&&n.push(Zk.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Nge(e.state,n)}),!!n.length},hat=e=>{let t=e.state.field(wf,!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},QOn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Oat},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:dat},{key:"Ctrl-Alt-[",run:fat},{key:"Ctrl-Alt-]",run:hat}],pat={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Gge=ht.define({combine(e){return Nm(e,pat)}});function Ige(e){return[wf,$at]}function Zge(e,t){let{state:n}=e,r=n.facet(Gge),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=ex(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 VM=cn.replace({widget:new class extends Tu{toDOM(e){return Zge(e,null)}}});class mat extends Tu{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Zge(t,this.value)}}const gat={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class jT extends hu{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 kOn(e={}){let t={...gat,...e},n=new jT(t,!0),r=new jT(t,!1),i=Ti.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(CO)!=o.state.facet(CO)||o.startState.field(wf,!1)!=o.state.field(wf,!1)||Bn(o.startState)!=Bn(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new gf;for(let l of o.viewportLineBlocks){let c=ex(o.state,l.from,l.to)?r:JS(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,qit({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||Pn.empty},initialSpacer(){return new jT(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=ex(o.state,s.from,s.to);if(c)return o.dispatch({effects:Xv.of(c)}),!0;let u=JS(o.state,s.from,s.to);return u?(o.dispatch({effects:Zk.of(u)}),!0):!1}}}),Ige()]}const $at=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 Dk{constructor(t,n){this.specs=t;let r;function i(s){let l=EO.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 Ao?s=>s.prop(fO)==o.data:o?s=>s==o:void 0,this.style=Ege(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new EO(r):null,this.themeType=n.themeType}static define(t,n){return new Dk(t,n||{})}}const J3=ht.define(),Dge=ht.define({combine(e){return e.length?[e[0]]:null}});function CT(e){let t=e.facet(J3);return t.length?t:e.facet(Dge)}function POn(e,t){let n=[vat],r;return e instanceof Dk&&(e.module&&n.push(Pt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Dge.of(e)):r?n.push(J3.computeN([Pt.darkTheme],i=>i.facet(Pt.darkTheme)==(r=="dark")?[e]:[])):n.push(J3.of(e)),n}class yat{constructor(t){this.markCache=Object.create(null),this.tree=Bn(t.state),this.decorations=this.buildDeco(t,CT(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Bn(t.state),r=CT(t.state),i=r!=CT(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 cn.none;let r=new gf;for(let{from:i,to:a}of t.visibleRanges)Vit(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=cn.mark({class:l})))},i,a);return r.finish()}}const vat=ZO.high(Ti.fromClass(yat,{decorations:e=>e.decorations})),_On=Dk.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"}]),bat=Pt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Mge=1e4,Vge="()[]{}",Lge=ht.define({combine(e){return Nm(e,{afterCursor:!0,brackets:Vge,maxScanDistance:Mge,renderMatch:xat})}}),wat=cn.mark({class:"cm-matchingBracket"}),Sat=cn.mark({class:"cm-nonmatchingBracket"});function xat(e){let t=[],n=e.matched?wat:Sat;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 Qat=co.define({create(){return cn.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Lge);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=rw(t.state,i.head,-1,r)||i.head>0&&rw(t.state,i.head-1,1,r)||r.afterCursor&&(rw(t.state,i.head,1,r)||i.head<t.state.doc.length&&rw(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return cn.set(n,!0)},provide:e=>Pt.decorations.from(e)}),kat=[Qat,bat];function TOn(e={}){return[Lge.of(e),kat]}const f8=new Gt;function eC(e,t,n){let r=e.prop(t<0?Gt.openedBy:Gt.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 tC(e){let t=e.type.prop(f8);return t?t(e.node):e}function rw(e,t,n,r={}){let i=r.maxScanDistance||Mge,a=r.brackets||Vge,o=Bn(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=eC(l.type,n,a);if(c&&l.from<l.to){let u=tC(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return Pat(e,t,n,l,u,c,a)}}return _at(e,t,n,o,s.type,i,a)}function Pat(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=tC(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(eC(u.type,n,o))c++;else if(eC(u.type,-n,o)){if(c==0){let O=tC(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 _at(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 LM(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 Fge{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=LM(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:LM(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 Tat(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Rat,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||p8,mergeTokens:e.mergeTokens!==!1}}function Rat(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 FM=new WeakMap;class Ae extends Ao{constructor(t){let n=Gk(t.languageData),r=Tat(t),i,a=new class extends Ak{createParse(o,s,l){return new Eat(i,o,s,l)}};super(n,a,[],t.name),this.topNode=Cat(n,this),i=this,this.streamParser=r,this.stateAfter=new Gt({perNode:!0}),this.tokenTable=t.tokenTable?new Jge(r.tokenTable):jat}static define(t){return new Ae(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=FM.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=h8(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 Fge(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)Hge(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&&FM.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function h8(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 hn&&l<i&&h8(e,s,l,r,i);if(c)return c}return null}function Bge(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 hn){if(!(l=Bge(e,s,n-o,r-o,i)))break;return i?new hn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function Xat(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&&h8(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=Bge(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?KS(i):4),tree:hn.empty}}let Eat=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=bf.get(),o=i[0].from,{state:s,tree:l}=Xat(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(KS(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=bf.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==`
|
|
831
831
|
`&&(n="");else{let r=n.indexOf(`
|
|
832
|
-
`);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 Fge(n,t?t.state.tabSize:4,t?KS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Hge(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=hn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:qat,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new hn(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 hn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Hge(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 p8=Object.create(null),H$=[yi.none],qat=new Wm(H$),BM=[],HM=Object.create(null),Kge=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"]])Kge[e]=e0e(p8,t);class Jge{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Kge)}resolve(t){return t?this.table[t]||(this.table[t]=e0e(this.extra,t)):0}}const jat=new Jge(p8);function AT(e,t){BM.indexOf(e)>-1||(BM.push(e),console.warn(t))}function e0e(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):AT(c,`Modifier ${c} used at start of tag`):l.length?AT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:AT(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=HM[i];if(a)return a.id;let o=HM[i]=yi.define({id:H$.length,name:r,props:[An({[r]:n})]});return H$.push(o),o.id}function Cat(e,t){let n=yi.define({id:H$.length,name:"Document",props:[fO.add(()=>e),Yr.add(()=>r=>t.getIndent(r))],top:!0});return H$.push(n),n}Er.RTL,Er.LTR;function Pe(e){return new wn(Ae.define(e))}function Yu(e){return ve(()=>Promise.resolve().then(()=>apt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Aat=[$e.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>GL),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(()=>GL),void 0,import.meta.url).then(e=>e.cpp())}}),$e.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Yu("Cassandra")}}),$e.of({name:"CSS",extensions:["css"],load(){return ve(()=>Promise.resolve().then(()=>vlt),void 0,import.meta.url).then(e=>e.css())}}),$e.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-DhrqAKsM.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(()=>Oct),void 0,import.meta.url).then(e=>e.html())}}),$e.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>cpt),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(()=>sw),void 0,import.meta.url).then(e=>e.javascript())}}),$e.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ve(()=>Promise.resolve().then(()=>mut),void 0,import.meta.url).then(e=>e.json())}}),$e.of({name:"JSX",extensions:["jsx"],load(){return ve(()=>Promise.resolve().then(()=>sw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),$e.of({name:"LESS",extensions:["less"],load(){return ve(()=>Promise.resolve().then(()=>Ect),void 0,import.meta.url).then(e=>e.less())}}),$e.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>Lgt),void 0,import.meta.url).then(e=>e.liquid())}}),$e.of({name:"MariaDB SQL",load(){return Yu("MariaSQL")}}),$e.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ve(()=>Promise.resolve().then(()=>bct),void 0,import.meta.url).then(e=>e.markdown())}}),$e.of({name:"MS SQL",load(){return Yu("MSSQL")}}),$e.of({name:"MySQL",load(){return Yu("MySQL")}}),$e.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ve(()=>Promise.resolve().then(()=>Qgt),void 0,import.meta.url).then(e=>e.php())}}),$e.of({name:"PLSQL",extensions:["pls"],load(){return Yu("PLSQL")}}),$e.of({name:"PostgreSQL",load(){return Yu("PostgreSQL")}}),$e.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ve(()=>Promise.resolve().then(()=>Lft),void 0,import.meta.url).then(e=>e.python())}}),$e.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>Tpt),void 0,import.meta.url).then(e=>e.rust())}}),$e.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>rL),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),$e.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>rL),void 0,import.meta.url).then(e=>e.sass())}}),$e.of({name:"SQL",extensions:["sql"],load(){return Yu("StandardSQL")}}),$e.of({name:"SQLite",load(){return Yu("SQLite")}}),$e.of({name:"TSX",extensions:["tsx"],load(){return ve(()=>Promise.resolve().then(()=>sw),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(()=>sw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),$e.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ve(()=>Promise.resolve().then(()=>Hgt),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(()=>mht),void 0,import.meta.url).then(e=>e.xml())}}),$e.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-CcD0LA0Q.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(()=>kyt),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(()=>Pyt),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(()=>Eyt),void 0,import.meta.url).then(e=>Pe(e.asterisk))}}),$e.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>jyt),void 0,import.meta.url).then(e=>Pe(e.brainfuck))}}),$e.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>lvt),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(()=>pd),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(()=>Jyt),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(()=>bvt),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(()=>Pvt),void 0,import.meta.url).then(e=>Pe(e.commonLisp))}}),$e.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>Dvt),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(()=>Wvt),void 0,import.meta.url).then(e=>Pe(e.crystal))}}),$e.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>Kvt),void 0,import.meta.url).then(e=>Pe(e.d))}}),$e.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>Pe(e.dart))}}),$e.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>Jvt),void 0,import.meta.url).then(e=>Pe(e.diff))}}),$e.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>dbt),void 0,import.meta.url).then(e=>Pe(e.dockerFile))}}),$e.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>pbt),void 0,import.meta.url).then(e=>Pe(e.dtd))}}),$e.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>vbt),void 0,import.meta.url).then(e=>Pe(e.dylan))}}),$e.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>bbt),void 0,import.meta.url).then(e=>Pe(e.ebnf))}}),$e.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>Tbt),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(()=>Cbt),void 0,import.meta.url).then(e=>Pe(e.eiffel))}}),$e.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>Mbt),void 0,import.meta.url).then(e=>Pe(e.elm))}}),$e.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>mwt),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(()=>gwt),void 0,import.meta.url).then(e=>Pe(e.factor))}}),$e.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>wwt),void 0,import.meta.url).then(e=>Pe(e.fcl))}}),$e.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>Qwt),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(()=>Ewt),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(()=>jwt),void 0,import.meta.url).then(e=>Pe(e.gas))}}),$e.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Cwt),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(()=>Mwt),void 0,import.meta.url).then(e=>Pe(e.groovy))}}),$e.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>Jwt),void 0,import.meta.url).then(e=>Pe(e.haskell))}}),$e.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>OB),void 0,import.meta.url).then(e=>Pe(e.haxe))}}),$e.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>OB),void 0,import.meta.url).then(e=>Pe(e.hxml))}}),$e.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>w1t),void 0,import.meta.url).then(e=>Pe(e.http))}}),$e.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>T1t),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(()=>q1t),void 0,import.meta.url).then(e=>Pe(e.jinja2))}}),$e.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>iSt),void 0,import.meta.url).then(e=>Pe(e.julia))}}),$e.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>Pe(e.kotlin))}}),$e.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>lSt),void 0,import.meta.url).then(e=>Pe(e.liveScript))}}),$e.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>mSt),void 0,import.meta.url).then(e=>Pe(e.lua))}}),$e.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>WSt),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(()=>xSt),void 0,import.meta.url).then(e=>Pe(e.mathematica))}}),$e.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>FSt),void 0,import.meta.url).then(e=>Pe(e.modelica))}}),$e.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>Oxt),void 0,import.meta.url).then(e=>Pe(e.mumps))}}),$e.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>ASt),void 0,import.meta.url).then(e=>Pe(e.mbox))}}),$e.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>mxt),void 0,import.meta.url).then(e=>Pe(e.nginx))}}),$e.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>gxt),void 0,import.meta.url).then(e=>Pe(e.nsis))}}),$e.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>$xt),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(()=>pd),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(()=>pd),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(()=>Txt),void 0,import.meta.url).then(e=>Pe(e.octave))}}),$e.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>Yxt),void 0,import.meta.url).then(e=>Pe(e.oz))}}),$e.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>Vxt),void 0,import.meta.url).then(e=>Pe(e.pascal))}}),$e.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>Lxt),void 0,import.meta.url).then(e=>Pe(e.perl))}}),$e.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>Pe(e.pig))}}),$e.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>fQt),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(()=>hQt),void 0,import.meta.url).then(e=>Pe(e.properties))}}),$e.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>yQt),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(()=>wQt),void 0,import.meta.url).then(e=>Pe(e.puppet))}}),$e.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>RQt),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(()=>zQt),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(()=>MQt),void 0,import.meta.url).then(e=>Pe(e.ruby))}}),$e.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>BQt),void 0,import.meta.url).then(e=>Pe(e.sas))}}),$e.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>Pe(e.scala))}}),$e.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>ckt),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(()=>fkt),void 0,import.meta.url).then(e=>Pe(e.shell))}}),$e.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>$kt),void 0,import.meta.url).then(e=>Pe(e.sieve))}}),$e.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>bkt),void 0,import.meta.url).then(e=>Pe(e.smalltalk))}}),$e.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>_kt),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(()=>Ckt),void 0,import.meta.url).then(e=>Pe(e.sparql))}}),$e.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>Akt),void 0,import.meta.url).then(e=>Pe(e.spreadsheet))}}),$e.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>Pe(e.squirrel))}}),$e.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>iPt),void 0,import.meta.url).then(e=>Pe(e.stylus))}}),$e.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>xPt),void 0,import.meta.url).then(e=>Pe(e.swift))}}),$e.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>nH),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(()=>nH),void 0,import.meta.url).then(e=>Pe(e.stex))}}),$e.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>wH),void 0,import.meta.url).then(e=>Pe(e.verilog))}}),$e.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>_Pt),void 0,import.meta.url).then(e=>Pe(e.tcl))}}),$e.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>EPt),void 0,import.meta.url).then(e=>Pe(e.textile))}}),$e.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>JPt),void 0,import.meta.url).then(e=>Pe(e.tiddlyWiki))}}),$e.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>o_t),void 0,import.meta.url).then(e=>Pe(e.tiki))}}),$e.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>s_t),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(()=>u_t),void 0,import.meta.url).then(e=>Pe(e.troff))}}),$e.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>__t),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(()=>X_t),void 0,import.meta.url).then(e=>Pe(e.turtle))}}),$e.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>x5t),void 0,import.meta.url).then(e=>Pe(e.webIDL))}}),$e.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>M_t),void 0,import.meta.url).then(e=>Pe(e.vb))}}),$e.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>L_t),void 0,import.meta.url).then(e=>Pe(e.vbScript))}}),$e.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>H_t),void 0,import.meta.url).then(e=>Pe(e.velocity))}}),$e.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>wH),void 0,import.meta.url).then(e=>Pe(e.verilog))}}),$e.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>o5t),void 0,import.meta.url).then(e=>Pe(e.vhdl))}}),$e.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>j5t),void 0,import.meta.url).then(e=>Pe(e.xQuery))}}),$e.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>Z5t),void 0,import.meta.url).then(e=>Pe(e.yacas))}}),$e.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>F5t),void 0,import.meta.url).then(e=>Pe(e.z80))}}),$e.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>Pe(e.mscgen))}}),$e.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>Pe(e.xu))}}),$e.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>Pe(e.msgenny))}}),$e.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>a0t),void 0,import.meta.url).then(e=>e.vue())}}),$e.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>x0t),void 0,import.meta.url).then(e=>e.angular())}})];class m8{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=Bn(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(t0e(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 KM(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 zat(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=KM(t)+KM(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Ev(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:zat(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function Mk(e,t){return n=>{for(let r=Bn(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 JM{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function ef(e){return e.selection.main.from}function t0e(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 g8=Zf.define();function Uat(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:Ie.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const eV=new WeakMap;function Wat(e){if(!Array.isArray(e))return e;let t=eV.get(e);return t||eV.set(e,t=Ev(e)),t}const tx=_n.define(),K$=_n.define();class Nat{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=Ro(t,n),i=Yc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(Ro(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=Ro(t,0),S=Yc(v),Q=S==t.length?0:-100;if(v!=n[0])if(v==r[0])Q+=-200;else return null;return this.ret(Q,[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 Q=Ro(t,v);(Q==n[c]||Q==r[c])&&(i[c++]=v),v+=Yc(Q)}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),Q=0;v<S&&O<l;){let b=Ro(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,x=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=dme(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||x==1&&g||Q==0&&x!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),Q=x,v+=Yc(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?Yc(Ro(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 Yat{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 Ni=ht.define({combine(e){return Nm(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:Gat,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 Gat(e,t,n,r,i,a){let o=e.textDirection==Er.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 Iat(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 zT(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 Zat{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(Ni);this.optionContent=Iat(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=zT(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(Ni).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:K$.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=zT(a.length,o,t.state.facet(Ni).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=zT(n.options.length,n.selected,this.view.state.facet(Ni).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=>no(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&&Mat(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(Ni).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 Dat(e,t){return n=>new Zat(n,e,t)}function Mat(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 nV(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Vat(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(Ni);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 JM(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Yat(O):new Nat(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 JM(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):nV(c.completion)>nV(s)&&(o[o.length-1]=c),s=c.completion}return o}class Bh{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 Bh(this.options,rV(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=Vat(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ni).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 Bh(s,rV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Jat,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Bh(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 Bh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class nx{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new nx(Hat,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ni),a=(r.override||n.languageDataAt("autocomplete",ef(n)).map(Wat)).map(l=>(this.active.find(u=>u.source==l)||new gs(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($8));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Lat(a,this.active)||s?o=Bh.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 gs(l.source,0):l));for(let l of t.effects)l.is(r0e)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new nx(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Fat:Bat}}function Lat(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 Fat={"aria-autocomplete":"list"},Bat={};function rV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Hat=[];function n0e(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(g8);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 gs{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=n0e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new gs(i.source,0)),r&4&&i.state==0&&(i=new gs(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(tx))i=new gs(i.source,1,a.value);else if(a.is(K$))i=new gs(i.source,0);else if(a.is($8))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(ef(t.state))}}class hp extends gs{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=ef(t.state);if(s>o||!i||n&2&&(ef(t.startState)==this.from||s<this.limit))return new gs(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Kat(i.validFor,t.state,a,o)?new hp(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new m8(t.state,s,!1)))?new hp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:ef(t.state)):new gs(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new hp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new gs(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Kat(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):t0e(e,!0).test(i)}const $8=_n.define({map(e,t){return e.map(n=>n.map(t))}}),r0e=_n.define(),Ja=co.define({create(){return nx.start()},update(e,t){return e.update(t)},provide:e=>[c8.from(e,t=>t.tooltip),Pt.contentAttributes.from(e,t=>t.attrs)]});function y8(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ja).active.find(i=>i.source==t.source);return r instanceof hp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Uat(e.state,n,r.from,r.to)),{annotations:g8.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Jat=Dat(Ja,y8);function iw(e,t="option"){return n=>{let r=n.state.field(Ja,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ni).interactionDelay)return!1;let i=1,a;t=="page"&&(a=Pge(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:r0e.of(s)}),!0}}const eot=e=>{let t=e.state.field(Ja,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ni).interactionDelay?!1:y8(e,t.open.options[t.open.selected])},iV=e=>e.state.field(Ja,!1)?(e.dispatch({effects:tx.of(!0)}),!0):!1,tot=e=>{let t=e.state.field(Ja,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:K$.of(null)}),!0)};class not{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const rot=50,iot=1e3,aot=Ti.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(Ja).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ja),n=e.state.facet(Ni);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ja)==t)return;let r=e.transactions.some(a=>{let o=n0e(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>rot&&Date.now()-o.time>iot){for(let s of o.context.abortListeners)try{s()}catch(l){no(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(tx)))&&(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(Ja);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(Ni).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=ef(t),r=new m8(t,n,e.explicit,this.view),i=new not(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:K$.of(null)}),no(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(Ni).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ni),r=this.view.state.field(Ja);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=ef(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new hp(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 gs(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:$8.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ja,!1);if(t&&t.tooltip&&this.view.state.facet(Ni).closeOnBlur){let n=t.open&&Pge(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:K$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:tx.of(!1)}),20),this.composing=0}}}),oot=typeof navigator=="object"&&/Win/.test(navigator.platform),sot=ZO.highest(Pt.domEventHandlers({keydown(e,t){let n=t.state.field(Ja,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(oot&&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&&y8(t,r),!1}})),i0e=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 lot{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class v8{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Hi.TrackDel),r=t.mapPos(this.to,1,Hi.TrackDel);return n==null||r==null?null:new v8(this.field,n,r)}}class b8{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(Ik);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 v8(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 lot(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 b8(r,i)}}let cot=cn.widget({widget:new class extends Tu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),uot=cn.mark({class:"cm-snippetField"});class Ym{constructor(t,n){this.ranges=t,this.active=n,this.deco=cn.set(t.map(r=>(r.from==r.to?cot:uot).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 Ym(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 qv=_n.define({map(e,t){return e&&e.map(t)}}),Oot=_n.define(),J$=co.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(qv))return n.value;if(n.is(Oot)&&e)return new Ym(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:cn.none)});function w8(e,t){return Ie.create(e.filter(n=>n.field==t).map(n=>Ie.range(n.from,n.to)))}function dot(e){let t=b8.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:Fn.of(o)},scrollIntoView:!0,annotations:r?[g8.of(r),Ki.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=w8(s,0)),s.some(u=>u.field>0)){let u=new Ym(s,0),O=c.effects=[qv.of(u)];n.state.field(J$,!1)===void 0&&O.push(_n.appendConfig.of([J$,got,$ot,i0e]))}n.dispatch(n.state.update(c))}}function a0e(e){return({state:t,dispatch:n})=>{let r=t.field(J$,!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:w8(r.ranges,i),effects:qv.of(a?null:new Ym(r.ranges,i)),scrollIntoView:!0})),!0}}const fot=({state:e,dispatch:t})=>e.field(J$,!1)?(t(e.update({effects:qv.of(null)})),!0):!1,hot=a0e(1),pot=a0e(-1),mot=[{key:"Tab",run:hot,shift:pot},{key:"Escape",run:fot}],aV=ht.define({combine(e){return e.length?e[0]:mot}}),got=ZO.highest(Nk.compute([aV],e=>e.facet(aV)));function Qr(e,t){return Object.assign(Object.assign({},t),{apply:dot(e)})}const $ot=Pt.domEventHandlers({mousedown(e,t){let n=t.state.field(J$,!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:w8(n.ranges,i.field),effects:qv.of(n.ranges.some(a=>a.field>i.field)?new Ym(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),ey={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Wd=_n.define({map(e,t){let n=t.mapPos(e,-1,Hi.TrackAfter);return n??void 0}}),S8=new class extends mf{};S8.startSide=1;S8.endSide=-1;const o0e=co.define({create(){return Pn.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(Wd)&&(e=e.update({add:[S8.range(n.value,n.value+1)]}));return e}});function XOn(){return[vot,o0e]}const UT="()[]{}<>«»»«[]{}";function s0e(e){for(let t=0;t<UT.length;t+=2)if(UT.charCodeAt(t)==e)return UT.charAt(t+1);return dme(e<128?e:e+1)}function l0e(e,t){return e.languageDataAt("closeBrackets",t)[0]||ey}const yot=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),vot=Pt.inputHandler.of((e,t,n,r)=>{if((yot?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Yc(Ro(r,0))==1||t!=i.from||n!=i.to)return!1;let a=wot(e.state,r);return a?(e.dispatch(a),!0):!1}),bot=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=l0e(e,e.selection.main.head).brackets||ey.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=Sot(e.doc,o.head);for(let l of r)if(l==s&&Vk(e.doc,o.head)==s0e(Ro(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ie.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},EOn=[{key:"Backspace",run:bot}];function wot(e,t){let n=l0e(e,e.selection.main.head),r=n.brackets||ey.brackets;for(let i of r){let a=s0e(Ro(i,0));if(t==i)return a==i?kot(e,i,r.indexOf(i+i+i)>-1,n):xot(e,i,a,n.before||ey.before);if(t==a&&c0e(e,e.selection.main.from))return Qot(e,i,a)}return null}function c0e(e,t){let n=!1;return e.field(o0e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function Vk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Yc(Ro(n,0)))}function Sot(e,t){let n=e.sliceString(t-2,t);return Yc(Ro(n,0))==n.length?n:n.slice(1)}function xot(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:Wd.of(o.to+t.length),range:Ie.range(o.anchor+t.length,o.head+t.length)};let s=Vk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Wd.of(o.head+t.length),range:Ie.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Qot(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&Vk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ie.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function kot(e,t,n,r){let i=r.stringPrefixes||ey.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Wd.of(s.to+t.length),range:Ie.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=Vk(e.doc,l),u;if(c==t){if(oV(e,l))return{changes:{insert:t+t,from:l},effects:Wd.of(l+t.length),range:Ie.cursor(l+t.length)};if(c0e(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:Ie.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=sV(e,l-2*t.length,i))>-1&&oV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Wd.of(l+t.length),range:Ie.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ms.Word&&sV(e,l,i)>-1&&!Pot(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Wd.of(l+t.length),range:Ie.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function oV(e,t){let n=Bn(e).resolveInner(t+1);return n.parent&&n.from==t}function Pot(e,t,n,r){let i=Bn(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 sV(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=ms.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))!=ms.Word)return a}return-1}function qOn(e={}){return[sot,Ja,Ni.of(e),aot,Tot,i0e]}const _ot=[{key:"Ctrl-Space",run:iV},{mac:"Alt-`",run:iV},{key:"Escape",run:tot},{key:"ArrowDown",run:iw(!0)},{key:"ArrowUp",run:iw(!1)},{key:"PageDown",run:iw(!0,"page")},{key:"PageUp",run:iw(!1,"page")},{key:"Enter",run:eot}],Tot=ZO.highest(Nk.computeN([Ni],e=>e.facet(Ni).defaultKeymap?[_ot]:[]));class rx{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new rx(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=[[Gt.contextHash,i]]}addChild(t,n){t.prop(Gt.contextHash)!=this.hash&&(t=new hn(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 hn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new hn(yi.none,i,a,o,this.hashProp)})}}var Me;(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"})(Me||(Me={}));class Rot{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Xot=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 B0(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 lV(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==Me.OrderedList?k8:Q8)(n,t,!1);return r>0&&(e.type!=Me.BulletList||x8(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const u0e={[Me.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(bn(Me.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Ts(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Me.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Me.OrderedList]:lV,[Me.BulletList]:lV,[Me.Document](){return!0}};function Ts(e){return e==32||e==9||e==10||e==13}function B0(e,t=0){for(;t<e.length&&Ts(e.charCodeAt(t));)t++;return t}function cV(e,t,n){for(;t>n&&Ts(e.charCodeAt(t-1));)t--;return t}function O0e(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 d0e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function x8(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(!Ts(a))return-1}return n&&e.next==45&&p0e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(y0e.SetextHeading)>-1||r<3?-1:1}function f0e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function Q8(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Ts(e.text.charCodeAt(e.pos+1)))&&(!n||f0e(t,Me.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function k8(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&&!Ts(e.text.charCodeAt(r+1))||n&&!f0e(t,Me.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function h0e(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 p0e(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&&Ts(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const nC=/^[ \t]*$/,m0e=/-->/,g0e=/\?>/,rC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,m0e],[/^\s*<\?/,g0e],[/^\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,nC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,nC]];function $0e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=rC.length-(n?1:0);i<a;i++)if(rC[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 dd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Me.CodeText?e[r].to=n:e.push(bn(Me.CodeText,t,n))}const aw={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(dd(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){dd(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==Me.CodeText?dd(o,c.from,c.to):o.push(c);s=[]}dd(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&&dd(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Me.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Me.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=O0e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=cV(t.text,t.text.length,o),l=[bn(Me.CodeMark,r,r+a)];o<s&&l.push(bn(Me.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(bn(Me.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||dd(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&&dd(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Me.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=d0e(t);return n<0?!1:(e.startContext(Me.Blockquote,t.pos),e.addNode(Me.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(x8(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Me.HorizontalRule,n),!0},BulletList(e,t){let n=Q8(t,e,!1);if(n<0)return!1;e.block.type!=Me.BulletList&&e.startContext(Me.BulletList,t.basePos,t.next);let r=uV(t,t.pos+1);return e.startContext(Me.ListItem,t.basePos,r-t.baseIndent),e.addNode(Me.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=k8(t,e,!1);if(n<0)return!1;e.block.type!=Me.OrderedList&&e.startContext(Me.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=uV(t,t.pos+n);return e.startContext(Me.ListItem,t.basePos,r-t.baseIndent),e.addNode(Me.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=h0e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=cV(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Ts(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Me.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Me.HeaderMark,o-r,a-r);let l=s.finish(Me.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=$0e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=rC[n][1],a=[],o=i!=nC;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==m0e?Me.CommentBlock:i==g0e?Me.ProcessingInstructionBlock:Me.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class Eot{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+`
|
|
832
|
+
`);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 Fge(n,t?t.state.tabSize:4,t?KS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Hge(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=hn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:qat,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new hn(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 hn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Hge(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 p8=Object.create(null),H$=[yi.none],qat=new Wm(H$),BM=[],HM=Object.create(null),Kge=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"]])Kge[e]=e0e(p8,t);class Jge{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Kge)}resolve(t){return t?this.table[t]||(this.table[t]=e0e(this.extra,t)):0}}const jat=new Jge(p8);function AT(e,t){BM.indexOf(e)>-1||(BM.push(e),console.warn(t))}function e0e(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):AT(c,`Modifier ${c} used at start of tag`):l.length?AT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:AT(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=HM[i];if(a)return a.id;let o=HM[i]=yi.define({id:H$.length,name:r,props:[An({[r]:n})]});return H$.push(o),o.id}function Cat(e,t){let n=yi.define({id:H$.length,name:"Document",props:[fO.add(()=>e),Yr.add(()=>r=>t.getIndent(r))],top:!0});return H$.push(n),n}Er.RTL,Er.LTR;function Pe(e){return new wn(Ae.define(e))}function Yu(e){return ve(()=>Promise.resolve().then(()=>apt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Aat=[$e.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>GL),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(()=>GL),void 0,import.meta.url).then(e=>e.cpp())}}),$e.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Yu("Cassandra")}}),$e.of({name:"CSS",extensions:["css"],load(){return ve(()=>Promise.resolve().then(()=>vlt),void 0,import.meta.url).then(e=>e.css())}}),$e.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-CY29neUf.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(()=>Oct),void 0,import.meta.url).then(e=>e.html())}}),$e.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>cpt),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(()=>sw),void 0,import.meta.url).then(e=>e.javascript())}}),$e.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ve(()=>Promise.resolve().then(()=>mut),void 0,import.meta.url).then(e=>e.json())}}),$e.of({name:"JSX",extensions:["jsx"],load(){return ve(()=>Promise.resolve().then(()=>sw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),$e.of({name:"LESS",extensions:["less"],load(){return ve(()=>Promise.resolve().then(()=>Ect),void 0,import.meta.url).then(e=>e.less())}}),$e.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>Lgt),void 0,import.meta.url).then(e=>e.liquid())}}),$e.of({name:"MariaDB SQL",load(){return Yu("MariaSQL")}}),$e.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ve(()=>Promise.resolve().then(()=>bct),void 0,import.meta.url).then(e=>e.markdown())}}),$e.of({name:"MS SQL",load(){return Yu("MSSQL")}}),$e.of({name:"MySQL",load(){return Yu("MySQL")}}),$e.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ve(()=>Promise.resolve().then(()=>Qgt),void 0,import.meta.url).then(e=>e.php())}}),$e.of({name:"PLSQL",extensions:["pls"],load(){return Yu("PLSQL")}}),$e.of({name:"PostgreSQL",load(){return Yu("PostgreSQL")}}),$e.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ve(()=>Promise.resolve().then(()=>Lft),void 0,import.meta.url).then(e=>e.python())}}),$e.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>Tpt),void 0,import.meta.url).then(e=>e.rust())}}),$e.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>rL),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),$e.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>rL),void 0,import.meta.url).then(e=>e.sass())}}),$e.of({name:"SQL",extensions:["sql"],load(){return Yu("StandardSQL")}}),$e.of({name:"SQLite",load(){return Yu("SQLite")}}),$e.of({name:"TSX",extensions:["tsx"],load(){return ve(()=>Promise.resolve().then(()=>sw),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(()=>sw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),$e.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ve(()=>Promise.resolve().then(()=>Hgt),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(()=>mht),void 0,import.meta.url).then(e=>e.xml())}}),$e.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-Cb5EO4yE.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(()=>kyt),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(()=>Pyt),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(()=>Eyt),void 0,import.meta.url).then(e=>Pe(e.asterisk))}}),$e.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>jyt),void 0,import.meta.url).then(e=>Pe(e.brainfuck))}}),$e.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>lvt),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(()=>pd),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(()=>Jyt),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(()=>bvt),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(()=>Pvt),void 0,import.meta.url).then(e=>Pe(e.commonLisp))}}),$e.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>Dvt),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(()=>Wvt),void 0,import.meta.url).then(e=>Pe(e.crystal))}}),$e.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>Kvt),void 0,import.meta.url).then(e=>Pe(e.d))}}),$e.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>Pe(e.dart))}}),$e.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>Jvt),void 0,import.meta.url).then(e=>Pe(e.diff))}}),$e.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>dbt),void 0,import.meta.url).then(e=>Pe(e.dockerFile))}}),$e.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>pbt),void 0,import.meta.url).then(e=>Pe(e.dtd))}}),$e.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>vbt),void 0,import.meta.url).then(e=>Pe(e.dylan))}}),$e.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>bbt),void 0,import.meta.url).then(e=>Pe(e.ebnf))}}),$e.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>Tbt),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(()=>Cbt),void 0,import.meta.url).then(e=>Pe(e.eiffel))}}),$e.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>Mbt),void 0,import.meta.url).then(e=>Pe(e.elm))}}),$e.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>mwt),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(()=>gwt),void 0,import.meta.url).then(e=>Pe(e.factor))}}),$e.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>wwt),void 0,import.meta.url).then(e=>Pe(e.fcl))}}),$e.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>Qwt),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(()=>Ewt),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(()=>jwt),void 0,import.meta.url).then(e=>Pe(e.gas))}}),$e.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Cwt),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(()=>Mwt),void 0,import.meta.url).then(e=>Pe(e.groovy))}}),$e.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>Jwt),void 0,import.meta.url).then(e=>Pe(e.haskell))}}),$e.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>OB),void 0,import.meta.url).then(e=>Pe(e.haxe))}}),$e.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>OB),void 0,import.meta.url).then(e=>Pe(e.hxml))}}),$e.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>w1t),void 0,import.meta.url).then(e=>Pe(e.http))}}),$e.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>T1t),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(()=>q1t),void 0,import.meta.url).then(e=>Pe(e.jinja2))}}),$e.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>iSt),void 0,import.meta.url).then(e=>Pe(e.julia))}}),$e.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>Pe(e.kotlin))}}),$e.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>lSt),void 0,import.meta.url).then(e=>Pe(e.liveScript))}}),$e.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>mSt),void 0,import.meta.url).then(e=>Pe(e.lua))}}),$e.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>WSt),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(()=>xSt),void 0,import.meta.url).then(e=>Pe(e.mathematica))}}),$e.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>FSt),void 0,import.meta.url).then(e=>Pe(e.modelica))}}),$e.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>Oxt),void 0,import.meta.url).then(e=>Pe(e.mumps))}}),$e.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>ASt),void 0,import.meta.url).then(e=>Pe(e.mbox))}}),$e.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>mxt),void 0,import.meta.url).then(e=>Pe(e.nginx))}}),$e.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>gxt),void 0,import.meta.url).then(e=>Pe(e.nsis))}}),$e.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>$xt),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(()=>pd),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(()=>pd),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(()=>Txt),void 0,import.meta.url).then(e=>Pe(e.octave))}}),$e.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>Yxt),void 0,import.meta.url).then(e=>Pe(e.oz))}}),$e.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>Vxt),void 0,import.meta.url).then(e=>Pe(e.pascal))}}),$e.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>Lxt),void 0,import.meta.url).then(e=>Pe(e.perl))}}),$e.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>Pe(e.pig))}}),$e.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>fQt),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(()=>hQt),void 0,import.meta.url).then(e=>Pe(e.properties))}}),$e.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>yQt),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(()=>wQt),void 0,import.meta.url).then(e=>Pe(e.puppet))}}),$e.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>RQt),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(()=>zQt),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(()=>MQt),void 0,import.meta.url).then(e=>Pe(e.ruby))}}),$e.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>BQt),void 0,import.meta.url).then(e=>Pe(e.sas))}}),$e.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>Pe(e.scala))}}),$e.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>ckt),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(()=>fkt),void 0,import.meta.url).then(e=>Pe(e.shell))}}),$e.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>$kt),void 0,import.meta.url).then(e=>Pe(e.sieve))}}),$e.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>bkt),void 0,import.meta.url).then(e=>Pe(e.smalltalk))}}),$e.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>_kt),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(()=>Ckt),void 0,import.meta.url).then(e=>Pe(e.sparql))}}),$e.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>Akt),void 0,import.meta.url).then(e=>Pe(e.spreadsheet))}}),$e.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>Pe(e.squirrel))}}),$e.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>iPt),void 0,import.meta.url).then(e=>Pe(e.stylus))}}),$e.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>xPt),void 0,import.meta.url).then(e=>Pe(e.swift))}}),$e.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>nH),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(()=>nH),void 0,import.meta.url).then(e=>Pe(e.stex))}}),$e.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>wH),void 0,import.meta.url).then(e=>Pe(e.verilog))}}),$e.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>_Pt),void 0,import.meta.url).then(e=>Pe(e.tcl))}}),$e.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>EPt),void 0,import.meta.url).then(e=>Pe(e.textile))}}),$e.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>JPt),void 0,import.meta.url).then(e=>Pe(e.tiddlyWiki))}}),$e.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>o_t),void 0,import.meta.url).then(e=>Pe(e.tiki))}}),$e.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>s_t),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(()=>u_t),void 0,import.meta.url).then(e=>Pe(e.troff))}}),$e.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>__t),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(()=>X_t),void 0,import.meta.url).then(e=>Pe(e.turtle))}}),$e.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>x5t),void 0,import.meta.url).then(e=>Pe(e.webIDL))}}),$e.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>M_t),void 0,import.meta.url).then(e=>Pe(e.vb))}}),$e.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>L_t),void 0,import.meta.url).then(e=>Pe(e.vbScript))}}),$e.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>H_t),void 0,import.meta.url).then(e=>Pe(e.velocity))}}),$e.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>wH),void 0,import.meta.url).then(e=>Pe(e.verilog))}}),$e.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>o5t),void 0,import.meta.url).then(e=>Pe(e.vhdl))}}),$e.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>j5t),void 0,import.meta.url).then(e=>Pe(e.xQuery))}}),$e.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>Z5t),void 0,import.meta.url).then(e=>Pe(e.yacas))}}),$e.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>F5t),void 0,import.meta.url).then(e=>Pe(e.z80))}}),$e.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>Pe(e.mscgen))}}),$e.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>Pe(e.xu))}}),$e.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>Pe(e.msgenny))}}),$e.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>a0t),void 0,import.meta.url).then(e=>e.vue())}}),$e.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>x0t),void 0,import.meta.url).then(e=>e.angular())}})];class m8{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=Bn(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(t0e(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 KM(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 zat(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=KM(t)+KM(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Ev(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:zat(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function Mk(e,t){return n=>{for(let r=Bn(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 JM{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function ef(e){return e.selection.main.from}function t0e(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 g8=Zf.define();function Uat(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:Ie.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const eV=new WeakMap;function Wat(e){if(!Array.isArray(e))return e;let t=eV.get(e);return t||eV.set(e,t=Ev(e)),t}const tx=_n.define(),K$=_n.define();class Nat{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=Ro(t,n),i=Yc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(Ro(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=Ro(t,0),S=Yc(v),Q=S==t.length?0:-100;if(v!=n[0])if(v==r[0])Q+=-200;else return null;return this.ret(Q,[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 Q=Ro(t,v);(Q==n[c]||Q==r[c])&&(i[c++]=v),v+=Yc(Q)}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),Q=0;v<S&&O<l;){let b=Ro(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,x=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=dme(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||x==1&&g||Q==0&&x!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),Q=x,v+=Yc(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?Yc(Ro(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 Yat{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 Ni=ht.define({combine(e){return Nm(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:Gat,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 Gat(e,t,n,r,i,a){let o=e.textDirection==Er.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 Iat(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 zT(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 Zat{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(Ni);this.optionContent=Iat(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=zT(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(Ni).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:K$.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=zT(a.length,o,t.state.facet(Ni).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=zT(n.options.length,n.selected,this.view.state.facet(Ni).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=>no(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&&Mat(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(Ni).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 Dat(e,t){return n=>new Zat(n,e,t)}function Mat(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 nV(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Vat(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(Ni);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 JM(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Yat(O):new Nat(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 JM(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):nV(c.completion)>nV(s)&&(o[o.length-1]=c),s=c.completion}return o}class Bh{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 Bh(this.options,rV(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=Vat(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ni).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 Bh(s,rV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Jat,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Bh(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 Bh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class nx{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new nx(Hat,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ni),a=(r.override||n.languageDataAt("autocomplete",ef(n)).map(Wat)).map(l=>(this.active.find(u=>u.source==l)||new gs(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($8));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Lat(a,this.active)||s?o=Bh.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 gs(l.source,0):l));for(let l of t.effects)l.is(r0e)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new nx(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Fat:Bat}}function Lat(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 Fat={"aria-autocomplete":"list"},Bat={};function rV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Hat=[];function n0e(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(g8);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 gs{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=n0e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new gs(i.source,0)),r&4&&i.state==0&&(i=new gs(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(tx))i=new gs(i.source,1,a.value);else if(a.is(K$))i=new gs(i.source,0);else if(a.is($8))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(ef(t.state))}}class hp extends gs{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=ef(t.state);if(s>o||!i||n&2&&(ef(t.startState)==this.from||s<this.limit))return new gs(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Kat(i.validFor,t.state,a,o)?new hp(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new m8(t.state,s,!1)))?new hp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:ef(t.state)):new gs(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new hp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new gs(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Kat(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):t0e(e,!0).test(i)}const $8=_n.define({map(e,t){return e.map(n=>n.map(t))}}),r0e=_n.define(),Ja=co.define({create(){return nx.start()},update(e,t){return e.update(t)},provide:e=>[c8.from(e,t=>t.tooltip),Pt.contentAttributes.from(e,t=>t.attrs)]});function y8(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ja).active.find(i=>i.source==t.source);return r instanceof hp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Uat(e.state,n,r.from,r.to)),{annotations:g8.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Jat=Dat(Ja,y8);function iw(e,t="option"){return n=>{let r=n.state.field(Ja,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ni).interactionDelay)return!1;let i=1,a;t=="page"&&(a=Pge(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:r0e.of(s)}),!0}}const eot=e=>{let t=e.state.field(Ja,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ni).interactionDelay?!1:y8(e,t.open.options[t.open.selected])},iV=e=>e.state.field(Ja,!1)?(e.dispatch({effects:tx.of(!0)}),!0):!1,tot=e=>{let t=e.state.field(Ja,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:K$.of(null)}),!0)};class not{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const rot=50,iot=1e3,aot=Ti.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(Ja).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ja),n=e.state.facet(Ni);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ja)==t)return;let r=e.transactions.some(a=>{let o=n0e(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>rot&&Date.now()-o.time>iot){for(let s of o.context.abortListeners)try{s()}catch(l){no(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(tx)))&&(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(Ja);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(Ni).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=ef(t),r=new m8(t,n,e.explicit,this.view),i=new not(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:K$.of(null)}),no(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(Ni).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ni),r=this.view.state.field(Ja);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=ef(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new hp(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 gs(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:$8.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ja,!1);if(t&&t.tooltip&&this.view.state.facet(Ni).closeOnBlur){let n=t.open&&Pge(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:K$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:tx.of(!1)}),20),this.composing=0}}}),oot=typeof navigator=="object"&&/Win/.test(navigator.platform),sot=ZO.highest(Pt.domEventHandlers({keydown(e,t){let n=t.state.field(Ja,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(oot&&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&&y8(t,r),!1}})),i0e=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 lot{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class v8{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Hi.TrackDel),r=t.mapPos(this.to,1,Hi.TrackDel);return n==null||r==null?null:new v8(this.field,n,r)}}class b8{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(Ik);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 v8(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 lot(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 b8(r,i)}}let cot=cn.widget({widget:new class extends Tu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),uot=cn.mark({class:"cm-snippetField"});class Ym{constructor(t,n){this.ranges=t,this.active=n,this.deco=cn.set(t.map(r=>(r.from==r.to?cot:uot).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 Ym(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 qv=_n.define({map(e,t){return e&&e.map(t)}}),Oot=_n.define(),J$=co.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(qv))return n.value;if(n.is(Oot)&&e)return new Ym(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:cn.none)});function w8(e,t){return Ie.create(e.filter(n=>n.field==t).map(n=>Ie.range(n.from,n.to)))}function dot(e){let t=b8.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:Fn.of(o)},scrollIntoView:!0,annotations:r?[g8.of(r),Ki.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=w8(s,0)),s.some(u=>u.field>0)){let u=new Ym(s,0),O=c.effects=[qv.of(u)];n.state.field(J$,!1)===void 0&&O.push(_n.appendConfig.of([J$,got,$ot,i0e]))}n.dispatch(n.state.update(c))}}function a0e(e){return({state:t,dispatch:n})=>{let r=t.field(J$,!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:w8(r.ranges,i),effects:qv.of(a?null:new Ym(r.ranges,i)),scrollIntoView:!0})),!0}}const fot=({state:e,dispatch:t})=>e.field(J$,!1)?(t(e.update({effects:qv.of(null)})),!0):!1,hot=a0e(1),pot=a0e(-1),mot=[{key:"Tab",run:hot,shift:pot},{key:"Escape",run:fot}],aV=ht.define({combine(e){return e.length?e[0]:mot}}),got=ZO.highest(Nk.compute([aV],e=>e.facet(aV)));function Qr(e,t){return Object.assign(Object.assign({},t),{apply:dot(e)})}const $ot=Pt.domEventHandlers({mousedown(e,t){let n=t.state.field(J$,!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:w8(n.ranges,i.field),effects:qv.of(n.ranges.some(a=>a.field>i.field)?new Ym(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),ey={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Wd=_n.define({map(e,t){let n=t.mapPos(e,-1,Hi.TrackAfter);return n??void 0}}),S8=new class extends mf{};S8.startSide=1;S8.endSide=-1;const o0e=co.define({create(){return Pn.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(Wd)&&(e=e.update({add:[S8.range(n.value,n.value+1)]}));return e}});function XOn(){return[vot,o0e]}const UT="()[]{}<>«»»«[]{}";function s0e(e){for(let t=0;t<UT.length;t+=2)if(UT.charCodeAt(t)==e)return UT.charAt(t+1);return dme(e<128?e:e+1)}function l0e(e,t){return e.languageDataAt("closeBrackets",t)[0]||ey}const yot=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),vot=Pt.inputHandler.of((e,t,n,r)=>{if((yot?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Yc(Ro(r,0))==1||t!=i.from||n!=i.to)return!1;let a=wot(e.state,r);return a?(e.dispatch(a),!0):!1}),bot=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=l0e(e,e.selection.main.head).brackets||ey.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=Sot(e.doc,o.head);for(let l of r)if(l==s&&Vk(e.doc,o.head)==s0e(Ro(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ie.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},EOn=[{key:"Backspace",run:bot}];function wot(e,t){let n=l0e(e,e.selection.main.head),r=n.brackets||ey.brackets;for(let i of r){let a=s0e(Ro(i,0));if(t==i)return a==i?kot(e,i,r.indexOf(i+i+i)>-1,n):xot(e,i,a,n.before||ey.before);if(t==a&&c0e(e,e.selection.main.from))return Qot(e,i,a)}return null}function c0e(e,t){let n=!1;return e.field(o0e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function Vk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Yc(Ro(n,0)))}function Sot(e,t){let n=e.sliceString(t-2,t);return Yc(Ro(n,0))==n.length?n:n.slice(1)}function xot(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:Wd.of(o.to+t.length),range:Ie.range(o.anchor+t.length,o.head+t.length)};let s=Vk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Wd.of(o.head+t.length),range:Ie.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Qot(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&Vk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ie.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function kot(e,t,n,r){let i=r.stringPrefixes||ey.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Wd.of(s.to+t.length),range:Ie.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=Vk(e.doc,l),u;if(c==t){if(oV(e,l))return{changes:{insert:t+t,from:l},effects:Wd.of(l+t.length),range:Ie.cursor(l+t.length)};if(c0e(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:Ie.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=sV(e,l-2*t.length,i))>-1&&oV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Wd.of(l+t.length),range:Ie.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ms.Word&&sV(e,l,i)>-1&&!Pot(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Wd.of(l+t.length),range:Ie.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function oV(e,t){let n=Bn(e).resolveInner(t+1);return n.parent&&n.from==t}function Pot(e,t,n,r){let i=Bn(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 sV(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=ms.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))!=ms.Word)return a}return-1}function qOn(e={}){return[sot,Ja,Ni.of(e),aot,Tot,i0e]}const _ot=[{key:"Ctrl-Space",run:iV},{mac:"Alt-`",run:iV},{key:"Escape",run:tot},{key:"ArrowDown",run:iw(!0)},{key:"ArrowUp",run:iw(!1)},{key:"PageDown",run:iw(!0,"page")},{key:"PageUp",run:iw(!1,"page")},{key:"Enter",run:eot}],Tot=ZO.highest(Nk.computeN([Ni],e=>e.facet(Ni).defaultKeymap?[_ot]:[]));class rx{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new rx(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=[[Gt.contextHash,i]]}addChild(t,n){t.prop(Gt.contextHash)!=this.hash&&(t=new hn(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 hn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new hn(yi.none,i,a,o,this.hashProp)})}}var Me;(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"})(Me||(Me={}));class Rot{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Xot=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 B0(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 lV(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==Me.OrderedList?k8:Q8)(n,t,!1);return r>0&&(e.type!=Me.BulletList||x8(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const u0e={[Me.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(bn(Me.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Ts(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Me.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Me.OrderedList]:lV,[Me.BulletList]:lV,[Me.Document](){return!0}};function Ts(e){return e==32||e==9||e==10||e==13}function B0(e,t=0){for(;t<e.length&&Ts(e.charCodeAt(t));)t++;return t}function cV(e,t,n){for(;t>n&&Ts(e.charCodeAt(t-1));)t--;return t}function O0e(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 d0e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function x8(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(!Ts(a))return-1}return n&&e.next==45&&p0e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(y0e.SetextHeading)>-1||r<3?-1:1}function f0e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function Q8(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Ts(e.text.charCodeAt(e.pos+1)))&&(!n||f0e(t,Me.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function k8(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&&!Ts(e.text.charCodeAt(r+1))||n&&!f0e(t,Me.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function h0e(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 p0e(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&&Ts(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const nC=/^[ \t]*$/,m0e=/-->/,g0e=/\?>/,rC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,m0e],[/^\s*<\?/,g0e],[/^\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,nC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,nC]];function $0e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=rC.length-(n?1:0);i<a;i++)if(rC[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 dd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Me.CodeText?e[r].to=n:e.push(bn(Me.CodeText,t,n))}const aw={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(dd(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){dd(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==Me.CodeText?dd(o,c.from,c.to):o.push(c);s=[]}dd(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&&dd(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Me.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Me.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=O0e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=cV(t.text,t.text.length,o),l=[bn(Me.CodeMark,r,r+a)];o<s&&l.push(bn(Me.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(bn(Me.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||dd(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&&dd(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Me.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=d0e(t);return n<0?!1:(e.startContext(Me.Blockquote,t.pos),e.addNode(Me.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(x8(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Me.HorizontalRule,n),!0},BulletList(e,t){let n=Q8(t,e,!1);if(n<0)return!1;e.block.type!=Me.BulletList&&e.startContext(Me.BulletList,t.basePos,t.next);let r=uV(t,t.pos+1);return e.startContext(Me.ListItem,t.basePos,r-t.baseIndent),e.addNode(Me.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=k8(t,e,!1);if(n<0)return!1;e.block.type!=Me.OrderedList&&e.startContext(Me.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=uV(t,t.pos+n);return e.startContext(Me.ListItem,t.basePos,r-t.baseIndent),e.addNode(Me.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=h0e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=cV(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Ts(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Me.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Me.HeaderMark,o-r,a-r);let l=s.finish(Me.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=$0e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=rC[n][1],a=[],o=i!=nC;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==m0e?Me.CommentBlock:i==g0e?Me.ProcessingInstructionBlock:Me.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class Eot{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+`
|
|
833
833
|
`+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)&&B0(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,bn(Me.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(_0e(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(bn(Me.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(k0e(t,B0(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=B0(t,this.pos),r=0;if(n>this.pos){let i=P0e(t,n,this.start);if(i){let a=WT(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=WT(t,this.pos)),r>0&&r<t.length?r:-1}else return WT(t,this.pos)}}}function WT(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!Ts(n))return-1}return t}class qot{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:p0e(n),a=n.next;if(i<0)return!1;let o=bn(Me.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,bn(a==61?Me.SetextHeading1:Me.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const y0e={LinkReference(e,t){return t.content.charCodeAt(0)==91?new Eot(t):null},SetextHeading(){return new qot}},jot=[(e,t)=>h0e(t)>=0,(e,t)=>O0e(t)>=0,(e,t)=>d0e(t)>=0,(e,t)=>Q8(t,e,!0)>=0,(e,t)=>k8(t,e,!0)>=0,(e,t)=>x8(t,e,!0)>=0,(e,t)=>$0e(t,e,!0)>=0],Cot={text:"",end:0};class Aot{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new Xot,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=rx.create(Me.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new Not(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 Rot(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+=`
|
|
834
834
|
`+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=T0e(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=Cot;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 "+Me[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==`
|
|
835
835
|
`?"":n;else{let i=n.indexOf(`
|
|
@@ -863,7 +863,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
863
863
|
`,o.end),l=t.slice(o.end,s===-1?t.length:s);if(a2t.test(l))return eo;const c=l.length-l.replace(o2t,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+Kp(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]===kP?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const ql=e=>e.typingAt!==null,O2t=e=>e.arm!==null;function Jf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+Kp(e.value).length}}function PU(e,t,n,r){const i=Jf(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=Kp(e.value),c=o7(a-i.start,0,l.length),u=o7(o-i.start,0,l.length),O=Kp(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),f=a+O.length,p=t.slice(0,a)+uxe.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 UH(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=ql(e)&&e.value===""&&r.startsWith("-");if(ql(e)&&(a||r.includes(`
|
|
864
864
|
`))){const o=Ex(e);return r.includes(`
|
|
865
865
|
`)?{...i,capture:o}:{...i,capture:Jh(o,i.buffer,i.caret,"typing")}}return PU(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function Ex(e){return ql(e)?{arm:e.arm,typingAt:null,value:""}:e}function d2t(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 f2t(e,t,n,r,i){const a=d2t(t,n),o=Jf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:Ex(e),buffer:n,caret:r};else{const l=PU(e,n,r,a);l?s=l:ql(e)&&a.inserted.includes(`
|
|
866
|
-
`)&&(s={capture:Ex(e),buffer:n,caret:r})}return{...s,capture:Jh(s.capture,s.buffer,s.caret,i)}}function h2t(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Jf(t);if(o===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const s=t.arm===null?o.start:t.arm.start,l=yxe(i,t.value),c=l+kP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:eo,buffer:u,caret:s+c.length,payload:{index:i,key:Sxe(a,e.draw),value:t.value,marker:l}}}function p2t(e,t){const n=Jf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=wxe(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:eo,buffer:i,caret:n.start+r.length,restored:a7(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:a7(r),restoredText:r}}}function WH(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function m2t(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Jf(e);return o===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=o.start?{kind:"passthrough",capture:{...e,typingAt:o.start+r.length},buffer:i,caret:a,payload:null}:n.start>=o.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:Ex(e),buffer:i,caret:a,payload:null}}function g2t(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=PU(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=on(i);if(!a)return i===""?null:m2t(t,n,e.selection,i);const o=t.arm,s=yxe(e.index,a),l=s+kP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:eo,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:Sxe(e.taken,e.draw),value:a,marker:s}}}const $xe=e=>`${a7(e)} chars`,yxe=(e,t)=>`[Credential #${e}, ${$xe(t)}]`;function $2t(e){Dl.lastIndex=0;const t=Dl.exec(e);return Dl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function y2t(e){Dl.lastIndex=0;const t=Dl.exec(e);if(Dl.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($2t(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const aR=/\[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,oR=/\[credential NOT stored \u2014 [^\]\n]*\]/y,sR=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,v2t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&i7.test(t[1])?t[1]:""};function b2t(e,t){if(e.charCodeAt(t)!==91)return null;aR.lastIndex=t;const n=aR.exec(e);if(aR.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};oR.lastIndex=t;const r=oR.exec(e);if(oR.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};sR.lastIndex=t;const i=sR.exec(e);return sR.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:v2t(i[0])}:null}function PP(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=b2t(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 NH(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 w2t(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 S2t=e=>`[credential ${e.key} (${$xe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function x2t(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 hxe(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?w2t(l??"lost",s?.key):S2t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const Q2t=(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.`,k2t=e=>`Remove credential #${e}`,P2t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,_2t=(e,t,n)=>Q2t(e,t,n),T2t="Undo",R2t=e=>`Credential #${e} removed`,X2t=e=>e.unredacted!==null?e.unredacted:e.armed?U2t:e.cleared!==null?_2t(e.cleared.key,e.cleared.index,e.undoCap):null;function E2t(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]===kP?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 q2t(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 YH=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function GH(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 j2t="store unconfirmed",C2t="Credential store unconfirmed",A2t=e=>e===""?C2t:`${e} · ${j2t}`,vxe="Paste the value again after /credential to store it again.",z2t=e=>`${e} ${vxe}`;function IH(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. ${vxe}`}const U2t="armed — add a space, then type or paste the secret",W2t="masked as you type — Enter turns it into a pill, Esc cancels",N2t="masked — Enter opens the credential picker; type or paste the secret into this span",Y2t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",bxe="\0held",G2t=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===bxe?`${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 wxe(e,t){const n=Jf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const ZH=(e,t)=>e&&e.over===t?e.chars:null,I2t=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},Z2t=16,D2t=16;function Sxe(e=[],t=I2t){const n=new Set(e);for(let r=0;r<Z2t;r++){const i=AH+DH(8,t);if(!n.has(i))return i}return AH+DH(D2t,t)}const DH=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=CH[t(CH.length)];return n},M2t=8,V2t=256,L2t=/^[/@$#]/,F2t=/^\w+:\/\//,B2t=/^[A-Za-z]+$/,H2t=/^\d+$/,K2t=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],J2t=3,eRt=20,tRt=/^[A-Za-z0-9_\-+/=.]+$/,nRt=new RegExp(`^[^${ba}@]+@[^${ba}@]+\\.[A-Za-z]{2,}$`),rRt=/^[\w.-]+(?:\/[\w.-]+)+$/,iRt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,aRt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,oRt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,sRt=/^[\w.-]+:\d{2,5}$/,lRt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,cRt=/^[a-z]+(?:_[a-z]+)+$/,uRt=/^[a-z]+(?:-[a-z]+)+$/,ORt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,dRt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,fRt=/\d{4,}/,hRt=e=>{const t=e.trim();return t.length<M2t||t.length>V2t||Zo.test(t)||L2t.test(t)||F2t.test(t)||oOe(t)!==null||nRt.test(t)||rRt.test(t)||iRt.test(t)||aRt.test(t)||oRt.test(t)||sRt.test(t)||lRt.test(t)||cRt.test(t)||uRt.test(t)||ORt.test(t)||dRt.test(t)&&fRt.test(t)||B2t.test(t)||H2t.test(t)?!1:K2t.filter(r=>r.test(t)).length>=J2t?!0:t.length>=eRt&&tRt.test(t)},xxe=q("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),Qxe=q("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),kxe=({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"?Qxe:xxe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(sle,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(Uze,{"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(ea,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),py="#lo-credential/",pRt=`${py}unstored`,MH=`${py}unconfirmed`,mRt=/^\d+$/,Pxe=e=>e.kind==="stored"?`${py}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${MH}/${e.key}`:MH:pRt;function gRt(e){if(!e||!e.startsWith(py))return null;const t=e.slice(py.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return i7.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!i7.test(r)||!mRt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function VH(e,t){const n=gRt(e);if(n===null)return null;const r=PP(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return Pxe(i)!==e?null:n}const _P=()=>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=PP(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:Pxe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},$Rt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?A2t(e.key):"Credential not stored",yRt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?z2t(t):t,vRt=({citation:e,title:t})=>h.jsx(kxe,{tone:e.kind==="stored"?"live":"warning",label:$Rt(e),chars:e.kind==="stored"?e.chars:null,title:yRt(e,t),className:"align-middle"}),bRt=(e,t)=>typeof t=="string"?VH(e,t):t==null?VH(e,""):null,wRt=e=>({href:t,title:n,children:r})=>{const i=bRt(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(vRt,{citation:i,title:n})},_xe=e=>ptt(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",Txe=e=>{const t=_xe(e);return t==="other"?"path":t},LH={id:"open-file",label:"Open file"},SRt={id:"show-in-canvas",label:"Show in canvas"},xRt={id:"save-as",label:"Save as…"},FH={id:"open-folder",label:"Open folder"},BH={id:"copy-file-path",label:"Copy file path"},Mg={id:"copy-image",label:"Copy image"},QRt={id:"copy-image-url",label:"Copy image URL"},kRt={id:"open-in-browser",label:"Open in browser"};function Rxe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[SRt]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[LH,FH,BH]:[],xRt,...r==="video"||r==="audio"?[]:[Mg]];case"path":return[...o,LH,FH,BH,...r==="video"||r==="audio"?[]:[Mg]];case"data":return[...o,Mg];case"blob":return[Mg];case"http":return[...PRt(n)?[Mg]:[],QRt,kRt];case"other":return[]}}const Xxe=(e,t)=>Rxe(e,t).length>0;function PRt(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 _U=e=>e.startsWith("file://")?e.slice(7):e;function _Rt(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 HH(e,t,n){if(e==="data")return _Rt(t);if(e==="blob"){const o=ife(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=_U(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Mz(i)})}const TRt=e=>e.trim().toLowerCase()!=="image/png";async function RRt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!TRt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await XRt(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 XRt(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 ERt=6e4;function qRt(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),ERt)}const F1=new Map;function jRt(e,t){const n=F1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await su(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=Lz(i.data,i.mimeType);return r.holders<=0?($v(a),null):(afe(t,a),a)}catch{return null}finally{F1.delete(t)}})(),F1.set(t,r),r.promise}class TU extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function Exe(e,t){const n=Fz(t),r=n?ife(n):null;if(r)return r;const i=await su(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 TU:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function CRt(e){const t=F1.get(e);t&&(t.holders-=1)}function Dv(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?Fz(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=_S(u);if(d)return i(d),o(!1),()=>{O=!1,TS(u)};i(null),o(!1);let f=!0;return jRt({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(_S(u))}}),()=>{O=!1,f&&CRt(u),TS(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 RU(e,t){return Dv(e,t)}const YOn=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:TU,fetchAttachmentBlob:Exe,useAttachmentSource:Dv,useAttachmentUrl:RU},Symbol.toStringTag,{value:"Module"})),ARt={"expand-image":h.jsx(Eue,{"aria-hidden":"true"}),"open-file":h.jsx(dv,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(Xue,{"aria-hidden":"true"}),"save-as":h.jsx(Ov,{"aria-hidden":"true"}),"open-folder":h.jsx(Rp,{"aria-hidden":"true"}),"copy-file-path":h.jsx(Que,{"aria-hidden":"true"}),"copy-image":h.jsx(hk,{"aria-hidden":"true"}),"copy-image-url":h.jsx(Gze,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Pue,{"aria-hidden":"true"})},KH=(e,t)=>t instanceof TU?`${e}: it is no longer in the session`:e,qxe=({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=Txe(e),y=Rxe(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(x=>(x.id!=="save-as"||!!d)&&(!l||x.id==="copy-file-path"));if(y.length===0)return null;const v=async(x,k,T)=>{try{await navigator.clipboard.writeText(x),Of(k)}catch(_){console.error(`${T}: `,_),mi(T)}},S=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const x=f?await f():await HH(g,e,t),k=await RRt(x);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),Of("Image copied to clipboard")}catch(x){console.error("Failed to copy image: ",x),mi(KH("Failed to copy image",x))}},Q=async()=>{try{const x=f?await f():await HH(g,e,t);qRt(x,d??"download")}catch(x){console.error("Failed to save file: ",x),mi(KH("Failed to save file",x))}},b=async x=>{let k=_U(e);if(s&&["open-file","open-folder","copy-file-path"].includes(x.id))try{k=await s()}catch{mi(J("ui.canvas.files.prepareError"));return}switch(x.id){case"expand-image":O?.();return;case"open-file":AO(k);return;case"open-folder":xU(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":Q();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":QU(t??e);return}},w=m??`Actions for ${n??"this image"}`;return h.jsxs(bA,{open:r,onOpenChange:i,children:[h.jsx(Yt,{content:p,children:h.jsx(wA,{asChild:!0,children:h.jsx(Xe,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:x=>x.stopPropagation(),children:h.jsx(yj,{"aria-hidden":"true"})})})}),h.jsxs(SA,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:x=>x.stopPropagation(),children:[s&&h.jsx("div",{role:"note",className:q("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:J("ui.canvas.files.pathCopyNote")}),y.map(x=>h.jsxs(jl,{onSelect:()=>b(x),children:[ARt[x.id],h.jsx("span",{children:x.label})]},x.id))]})]})},zRt=({src:e,alt:t,title:n,className:r})=>{const i=SP(),a=e??"",o=_xe(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=Xxe(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(qxe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||AO(_U(a))})}:void 0})})]})};function URt(){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 WRt={tokenize:NRt,concrete:!0,name:"mathFlow"},JH={tokenize:YRt,partial:!0};function NRt(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"),ln(e,c,"whitespace")(v))}function c(v){return v===null||bt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||bt(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(JH,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,f)(v)}function f(v){return(a?ln(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):bt(v)?e.attempt(JH,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||bt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,S,Q){let b=0;return ln(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(T){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),x(T)}function x(T){return T===36?(b++,v.consume(T),x):b<o?Q(T):(v.exit("mathFlowFenceSequence"),ln(v,k,"whitespace")(T))}function k(T){return T===null||bt(T)?(v.exit("mathFlowFence"),S(T)):Q(T)}}}function YRt(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 GRt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:IRt,previous:ZRt,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):bt(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||bt(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 IRt(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 ZRt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function DRt(e){return{flow:{36:WRt},text:{36:GRt()}}}const ep=36,eK=e=>e!==null&&e<-2,tK=e=>e===null||e===32||e<0,nK=e=>e!==null&&e>=48&&e<=57,jxe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:MRt,previous:VRt,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===ep?(r.consume(g),s++,d):s<2&&!t||s===1&&(tK(g)||nK(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===ep?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):eK(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===ep||eK(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===ep?(r.consume(g),c++,m):c===s?s===1&&(tK(l)||nK(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function MRt(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 VRt(e){return e!==ep||this.events[this.events.length-1][1].type==="characterEscape"}const LRt=DRt().flow,FRt=jxe();function TP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?FRt:jxe(e);n.push({flow:LRt,text:{[ep]:i}}),r.push(URt())}const BRt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),HRt=/\$(?!\d)(.+?)\$/,KRt=/\$\$([\s\S]+?)\$\$/,JRt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,eXt=/\\[a-zA-Z]+(\{[^}]*\})?/,rK=e=>HRt.test(e)||KRt.test(e)||JRt.test(e)?!0:eXt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),tXt=e=>{const t=PP(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},nXt=e=>PP(e).filter(t=>t.kind!=="text").length,rXt=e=>{if(!rK(e))return!1;const t=tXt(e);return t===null?!0:rK(t)||t.includes("$")?!1:nXt(e)<2},Kt="var(--color-ink)",bc="var(--color-ink-muted)",Sl="var(--color-surface)",Du="var(--color-elevated)",wc="var(--color-sunken)",oa="var(--color-hairline)",Mu="var(--color-control)",Xh="var(--color-accent)",Q0="var(--color-accent-wash)",iXt="var(--color-accent-alt-wash)",aXt="var(--color-on-accent)",oXt="var(--color-info)",Cxe="var(--color-info-wash)",sXt="var(--color-success)",Axe="var(--color-success-wash)",lXt="var(--color-warning)",s7="var(--color-warning-wash)",cXt="var(--color-warning-border)",lR="var(--color-danger)",l7="var(--color-danger-wash)",iK=[Q0,iXt,Cxe,Axe,s7,l7],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),uXt=()=>{const e={primaryColor:Vu("--color-accent"),secondaryColor:Vu("--color-success"),tertiaryColor:Vu("--color-info"),mainBkg:Vu("--color-elevated"),clusterBkg:Vu("--color-sunken"),clusterBorder:Vu("--color-hairline"),edgeLabelBackground:Vu("--color-surface"),quadrant1Fill:Vu("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:Sl,primaryTextColor:Kt,primaryBorderColor:Mu,secondaryTextColor:Kt,secondaryBorderColor:oa,tertiaryTextColor:Kt,tertiaryBorderColor:oa,lineColor:bc,arrowheadColor:bc,textColor:Kt,secondBkg:wc,border1:Mu,border2:oa,labelColor:Kt,nodeBkg:Du,nodeBorder:Mu,nodeTextColor:Kt,defaultLinkColor:bc,titleColor:Kt,noteBkgColor:s7,noteBorderColor:cXt,noteTextColor:Kt,actorBkg:Du,actorBorder:Mu,actorTextColor:Kt,actorLineColor:oa,signalColor:bc,signalTextColor:Kt,labelBoxBkgColor:Du,labelBoxBorderColor:oa,labelTextColor:Kt,loopTextColor:Kt,activationBkgColor:Q0,activationBorderColor:Xh,sequenceNumberColor:Sl,sectionBkgColor:wc,sectionBkgColor2:Sl,altSectionBkgColor:wc,excludeBkgColor:wc,taskBkgColor:Q0,taskBorderColor:Mu,taskTextColor:Kt,taskTextLightColor:Kt,taskTextDarkColor:Kt,taskTextOutsideColor:Kt,taskTextClickableColor:Xh,activeTaskBkgColor:Q0,activeTaskBorderColor:Xh,gridColor:oa,doneTaskBkgColor:wc,doneTaskBorderColor:oa,critBkgColor:l7,critBorderColor:lR,todayLineColor:Xh,transitionColor:bc,transitionLabelColor:Kt,stateLabelColor:Kt,stateBkg:Du,labelBackgroundColor:Sl,compositeBackground:wc,altBackground:wc,compositeTitleBackground:Du,compositeBorder:oa,innerEndBackground:Kt,specialStateColor:Kt,classText:Kt,attributeBackgroundColorOdd:Sl,attributeBackgroundColorEven:wc,rowOdd:Sl,rowEven:wc,errorBkgColor:l7,errorTextColor:lR,pieTitleTextColor:Kt,pieSectionTextColor:Kt,pieLegendTextColor:Kt,pieStrokeColor:Sl,pieOuterStrokeColor:oa,requirementBackground:Du,requirementBorderColor:Mu,requirementTextColor:Kt,relationColor:bc,relationLabelBackground:Sl,relationLabelColor:Kt,branchLabelColor:aXt,commitLabelColor:Kt,commitLabelBackground:Sl,tagLabelColor:Kt,tagLabelBackground:Q0,tagLabelBorder:Mu,quadrant2Fill:Cxe,quadrant3Fill:Axe,quadrant4Fill:s7,quadrant2TextFill:Kt,quadrant3TextFill:Kt,quadrant4TextFill:Kt,quadrantPointFill:Xh,archEdgeColor:bc,archEdgeArrowColor:bc,archGroupBorderColor:oa,scaleLabelColor:Kt,packet:{startByteColor:Kt,endByteColor:Kt,labelColor:Kt,titleColor:Kt,blockStrokeColor:Mu,blockFillColor:Du},radar:{axisColor:bc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:oa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Sl,titleColor:Kt,xAxisTitleColor:Kt,xAxisLabelColor:Kt,xAxisTickColor:oa,xAxisLineColor:oa,yAxisTitleColor:Kt,yAxisLabelColor:Kt,yAxisTickColor:oa,yAxisLineColor:oa,plotColorPalette:[Xh,oXt,sXt,lXt,lR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Du,t[`surfacePeer${n}`]=oa;for(let n=0;n<8;n++)t[`fillType${n}`]=iK[n%iK.length];return{...t,...e}};let cR=null,aK=null;const OXt=async e=>{cR||(cR=ve(async()=>{const{default:n}=await import("./mermaid.core-DXWoCulQ.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,1,2]),import.meta.url).then(({default:n})=>n));const t=await cR;return aK!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:uXt()}),aK=e),t},oK=({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(Yt,{content:"Zoom in",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(Iue,{})})}),h.jsx(Yt,{content:"Zoom out",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(Zue,{})})}),h.jsx(Yt,{content:"Drag the diagram to pan",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(o9e,{})})}),h.jsx(Yt,{content:"Reset view",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(mk,{})})}),h.jsx(Yt,{content:"Save as SVG",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(Ov,{})})}),h.jsx(Yt,{content:t?"Copied":"Copy mermaid text",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(hk,{className:q(t&&"text-success")})})}),s]}),c7=({title:e,children:t})=>h.jsxs(Ll,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(E0,{children:e}),h.jsx(q0,{children:t})]});class dXt 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(c7,{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 fXt=$.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}),[Q,b]=$.useState("idle"),[w,x]=$.useState("idle"),k=Jn(U=>U.themeName),T=$.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 OXt(k),H=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:D}=await U.render(H,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 H=U instanceof Error?U.message:"Failed to render mermaid diagram";a(H),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{T().catch(U=>{console.error("Error in renderDiagram effect:",U),a("Failed to initialize diagram rendering"),s(!1)})},[T]);const _=$.useCallback(()=>{try{if(!l||!r.current)return 1;const H=r.current.getBoundingClientRect(),D=document.createElement("div");D.innerHTML=l;const V=D.querySelector("svg");if(!V)return 1;const se=V.getBoundingClientRect?.()?.width||Number.parseFloat(V.getAttribute("width")||"0")||V.viewBox?.baseVal?.width||800,B=V.getBoundingClientRect?.()?.height||Number.parseFloat(V.getAttribute("height")||"0")||V.viewBox?.baseVal?.height||600,K=H.width*.9/se,ne=H.height*.9/B;return Math.min(K,ne,1)}catch(U){return console.error("Error calculating fullscreen scale:",U),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const U=_();m({scale:U,x:0,y:0})}catch(U){console.error("Error setting fullscreen transform:",U)}},100)},[u,l,_]);const E=$.useCallback((U=!1)=>{try{(U?m:f)(D=>({...D,scale:Math.min(D.scale*1.2,10)}))}catch(H){console.error("Error in zoom in:",H)}},[]),R=$.useCallback((U=!1)=>{try{(U?m:f)(D=>({...D,scale:Math.max(D.scale/1.2,.1)}))}catch(H){console.error("Error in zoom out:",H)}},[]),j=$.useCallback((U=!1)=>{try{const H=U?m:f;if(U){const D=_();H({scale:D,x:0,y:0})}else H({scale:1,x:0,y:0})}catch(H){console.error("Error in reset:",H)}},[_]),C=$.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),H=URL.createObjectURL(U),D=document.createElement("a");D.href=H,D.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(H)}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),x("copied"),setTimeout(()=>x("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(H){console.error("Error in mouse down:",H)}},[]),Z=$.useCallback((U,H=!1)=>{try{if(!g)return;const D=U.clientX-v.x,V=U.clientY-v.y;(H?m:f)(B=>({...B,x:B.x+D,y:B.y+V})),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,H=!1)=>{try{U.preventDefault();const D=U.deltaY>0?.9:1.1;(H?m:f)(se=>({...se,scale:Math.min(Math.max(se.scale*D,.1),5)}))}catch(D){console.error("Error in wheel:",D)}},[]),M=$.useCallback(U=>{try{O(U)}catch(H){console.error("Error toggling fullscreen:",H)}},[]);if(i)return h.jsxs(c7,{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 te=(U=!1)=>{try{const H=U?r:n,D=U?p:d;return h.jsx("div",{ref:H,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:V=>Z(V,U),onMouseUp:F,onMouseLeave:F,onWheel:V=>z(V,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(H){return console.error("Error rendering diagram content:",H),h.jsx(c7,{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:[te(!1),h.jsx(oK,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>R(!1),onReset:()=>j(!1),onSave:C,onCopy:W,children:h.jsx(Yt,{content:"Fullscreen",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>M(!0),children:h.jsx(Eue,{})})})})]}),h.jsx(R$,{open:u,onClose:()=>M(!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:[te(!0),h.jsx(oK,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>R(!0),onReset:()=>j(!0),onSave:C,onCopy:G,children:h.jsx(Yt,{content:"Close fullscreen",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>M(!1),children:h.jsx(ea,{})})})})]})})]})}),hXt=$.memo(e=>h.jsx(dXt,{children:h.jsx(fXt,{...e})}));let zxe=!1,uR=null;const pXt=()=>(uR||(uR=ve(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(zxe=!0,e))),uR),mXt=/language-(\w+)/,gXt=JQ,$Xt=new RegExp(`^[^${ba}\\d*+-]`),yXt=/\n$/,Uxe=({href:e,children:t})=>{const n=GSe(e),r=SP();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=>wXt(i,r):void 0,children:t})},vXt=e=>GSe(e)?.kind==="file",bXt=VSe,wXt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(MSe)??"file",i=n.getAttribute(bXt),a=rTt({kind:r,hasHighlight:$Tt(n),canOpenInCanvas:SU(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||AO(i)});return}AO(i)}},u7=(e,t)=>t==="href"&&vXt(e)?e:uhe(e),my={a:Uxe,table:BRt,img:zRt,code:({node:e,className:t,children:n,...r})=>mXt.exec(t??"")?.[1]==="mermaid"?h.jsx(hXt,{chart:String(n).replace(yXt,"")}):h.jsx("code",{className:t,...r,children:n})},SXt={...my,a:wRt(Uxe)},xXt=[IO],QXt=[IO,TP],kXt=[IO,xP],PXt=[IO,TP,xP],_Xt=[IO,_P,QP],TXt=[IO,TP,_P,QP],RXt=[IO,xP,_P,QP],XXt=[IO,TP,xP,_P,QP],EXt={"000":xXt,"001":_Xt,"010":kXt,"011":RXt,100:QXt,101:TXt,110:PXt,111:XXt},qXt=[],jXt=[tJe],Wxe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Nxe=(e,t,n)=>{const r=$.useMemo(()=>rXt(e),[e]),[i,a]=$.useState(zxe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return pXt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:EXt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?jXt:qXt}},Yxe=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=Utt(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=aTt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return DSe(r,window.api?.probeFiles,rle).then(()=>{i&&r.some(s=>ZSe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},gy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=Nxe(a,r,i),l=Wxe(t);return Yxe(a,r),h.jsx("div",{className:q("lo-markdown",n),style:l,children:h.jsx(Kj,{remarkPlugins:o,rehypePlugins:s,urlTransform:u7,components:i?SXt:my,children:a})})});gy.displayName="MarkdownRenderer";const sK={...my,a:({children:e})=>h.jsx(h.Fragment,{children:e})},Gxe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:EH(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=oxe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=Nxe(n,t,!1);if(Yxe(e,t),r!==null){const o=EH(r.before);return h.jsxs(h.Fragment,{children:[o.trim()!==""&&h.jsx(Kj,{remarkPlugins:i,rehypePlugins:a,urlTransform:u7,components:t?my:sK,children:o}),h.jsx(CXt,{info:r.info,body:r.body})]})}return h.jsx(Kj,{remarkPlugins:i,rehypePlugins:a,urlTransform:u7,components:t?my:sK,children:n})});Gxe.displayName="ParsedBlock";const CXt=({info:e,body:t})=>{const n=e.split(gXt)[0];return h.jsx("pre",{children:h.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
|
|
866
|
+
`)&&(s={capture:Ex(e),buffer:n,caret:r})}return{...s,capture:Jh(s.capture,s.buffer,s.caret,i)}}function h2t(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Jf(t);if(o===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const s=t.arm===null?o.start:t.arm.start,l=yxe(i,t.value),c=l+kP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:eo,buffer:u,caret:s+c.length,payload:{index:i,key:Sxe(a,e.draw),value:t.value,marker:l}}}function p2t(e,t){const n=Jf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=wxe(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:eo,buffer:i,caret:n.start+r.length,restored:a7(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:a7(r),restoredText:r}}}function WH(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function m2t(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Jf(e);return o===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=o.start?{kind:"passthrough",capture:{...e,typingAt:o.start+r.length},buffer:i,caret:a,payload:null}:n.start>=o.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:Ex(e),buffer:i,caret:a,payload:null}}function g2t(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=PU(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=on(i);if(!a)return i===""?null:m2t(t,n,e.selection,i);const o=t.arm,s=yxe(e.index,a),l=s+kP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:eo,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:Sxe(e.taken,e.draw),value:a,marker:s}}}const $xe=e=>`${a7(e)} chars`,yxe=(e,t)=>`[Credential #${e}, ${$xe(t)}]`;function $2t(e){Dl.lastIndex=0;const t=Dl.exec(e);return Dl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function y2t(e){Dl.lastIndex=0;const t=Dl.exec(e);if(Dl.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($2t(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const aR=/\[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,oR=/\[credential NOT stored \u2014 [^\]\n]*\]/y,sR=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,v2t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&i7.test(t[1])?t[1]:""};function b2t(e,t){if(e.charCodeAt(t)!==91)return null;aR.lastIndex=t;const n=aR.exec(e);if(aR.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};oR.lastIndex=t;const r=oR.exec(e);if(oR.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};sR.lastIndex=t;const i=sR.exec(e);return sR.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:v2t(i[0])}:null}function PP(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=b2t(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 NH(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 w2t(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 S2t=e=>`[credential ${e.key} (${$xe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function x2t(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 hxe(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?w2t(l??"lost",s?.key):S2t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const Q2t=(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.`,k2t=e=>`Remove credential #${e}`,P2t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,_2t=(e,t,n)=>Q2t(e,t,n),T2t="Undo",R2t=e=>`Credential #${e} removed`,X2t=e=>e.unredacted!==null?e.unredacted:e.armed?U2t:e.cleared!==null?_2t(e.cleared.key,e.cleared.index,e.undoCap):null;function E2t(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]===kP?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 q2t(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 YH=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function GH(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 j2t="store unconfirmed",C2t="Credential store unconfirmed",A2t=e=>e===""?C2t:`${e} · ${j2t}`,vxe="Paste the value again after /credential to store it again.",z2t=e=>`${e} ${vxe}`;function IH(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. ${vxe}`}const U2t="armed — add a space, then type or paste the secret",W2t="masked as you type — Enter turns it into a pill, Esc cancels",N2t="masked — Enter opens the credential picker; type or paste the secret into this span",Y2t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",bxe="\0held",G2t=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===bxe?`${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 wxe(e,t){const n=Jf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const ZH=(e,t)=>e&&e.over===t?e.chars:null,I2t=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},Z2t=16,D2t=16;function Sxe(e=[],t=I2t){const n=new Set(e);for(let r=0;r<Z2t;r++){const i=AH+DH(8,t);if(!n.has(i))return i}return AH+DH(D2t,t)}const DH=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=CH[t(CH.length)];return n},M2t=8,V2t=256,L2t=/^[/@$#]/,F2t=/^\w+:\/\//,B2t=/^[A-Za-z]+$/,H2t=/^\d+$/,K2t=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],J2t=3,eRt=20,tRt=/^[A-Za-z0-9_\-+/=.]+$/,nRt=new RegExp(`^[^${ba}@]+@[^${ba}@]+\\.[A-Za-z]{2,}$`),rRt=/^[\w.-]+(?:\/[\w.-]+)+$/,iRt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,aRt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,oRt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,sRt=/^[\w.-]+:\d{2,5}$/,lRt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,cRt=/^[a-z]+(?:_[a-z]+)+$/,uRt=/^[a-z]+(?:-[a-z]+)+$/,ORt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,dRt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,fRt=/\d{4,}/,hRt=e=>{const t=e.trim();return t.length<M2t||t.length>V2t||Zo.test(t)||L2t.test(t)||F2t.test(t)||oOe(t)!==null||nRt.test(t)||rRt.test(t)||iRt.test(t)||aRt.test(t)||oRt.test(t)||sRt.test(t)||lRt.test(t)||cRt.test(t)||uRt.test(t)||ORt.test(t)||dRt.test(t)&&fRt.test(t)||B2t.test(t)||H2t.test(t)?!1:K2t.filter(r=>r.test(t)).length>=J2t?!0:t.length>=eRt&&tRt.test(t)},xxe=q("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),Qxe=q("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),kxe=({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"?Qxe:xxe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(sle,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(Uze,{"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(ea,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),py="#lo-credential/",pRt=`${py}unstored`,MH=`${py}unconfirmed`,mRt=/^\d+$/,Pxe=e=>e.kind==="stored"?`${py}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${MH}/${e.key}`:MH:pRt;function gRt(e){if(!e||!e.startsWith(py))return null;const t=e.slice(py.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return i7.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!i7.test(r)||!mRt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function VH(e,t){const n=gRt(e);if(n===null)return null;const r=PP(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return Pxe(i)!==e?null:n}const _P=()=>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=PP(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:Pxe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},$Rt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?A2t(e.key):"Credential not stored",yRt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?z2t(t):t,vRt=({citation:e,title:t})=>h.jsx(kxe,{tone:e.kind==="stored"?"live":"warning",label:$Rt(e),chars:e.kind==="stored"?e.chars:null,title:yRt(e,t),className:"align-middle"}),bRt=(e,t)=>typeof t=="string"?VH(e,t):t==null?VH(e,""):null,wRt=e=>({href:t,title:n,children:r})=>{const i=bRt(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(vRt,{citation:i,title:n})},_xe=e=>ptt(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",Txe=e=>{const t=_xe(e);return t==="other"?"path":t},LH={id:"open-file",label:"Open file"},SRt={id:"show-in-canvas",label:"Show in canvas"},xRt={id:"save-as",label:"Save as…"},FH={id:"open-folder",label:"Open folder"},BH={id:"copy-file-path",label:"Copy file path"},Mg={id:"copy-image",label:"Copy image"},QRt={id:"copy-image-url",label:"Copy image URL"},kRt={id:"open-in-browser",label:"Open in browser"};function Rxe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[SRt]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[LH,FH,BH]:[],xRt,...r==="video"||r==="audio"?[]:[Mg]];case"path":return[...o,LH,FH,BH,...r==="video"||r==="audio"?[]:[Mg]];case"data":return[...o,Mg];case"blob":return[Mg];case"http":return[...PRt(n)?[Mg]:[],QRt,kRt];case"other":return[]}}const Xxe=(e,t)=>Rxe(e,t).length>0;function PRt(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 _U=e=>e.startsWith("file://")?e.slice(7):e;function _Rt(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 HH(e,t,n){if(e==="data")return _Rt(t);if(e==="blob"){const o=ife(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=_U(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Mz(i)})}const TRt=e=>e.trim().toLowerCase()!=="image/png";async function RRt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!TRt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await XRt(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 XRt(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 ERt=6e4;function qRt(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),ERt)}const F1=new Map;function jRt(e,t){const n=F1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await su(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=Lz(i.data,i.mimeType);return r.holders<=0?($v(a),null):(afe(t,a),a)}catch{return null}finally{F1.delete(t)}})(),F1.set(t,r),r.promise}class TU extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function Exe(e,t){const n=Fz(t),r=n?ife(n):null;if(r)return r;const i=await su(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 TU:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function CRt(e){const t=F1.get(e);t&&(t.holders-=1)}function Dv(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?Fz(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=_S(u);if(d)return i(d),o(!1),()=>{O=!1,TS(u)};i(null),o(!1);let f=!0;return jRt({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(_S(u))}}),()=>{O=!1,f&&CRt(u),TS(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 RU(e,t){return Dv(e,t)}const YOn=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:TU,fetchAttachmentBlob:Exe,useAttachmentSource:Dv,useAttachmentUrl:RU},Symbol.toStringTag,{value:"Module"})),ARt={"expand-image":h.jsx(Eue,{"aria-hidden":"true"}),"open-file":h.jsx(dv,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(Xue,{"aria-hidden":"true"}),"save-as":h.jsx(Ov,{"aria-hidden":"true"}),"open-folder":h.jsx(Rp,{"aria-hidden":"true"}),"copy-file-path":h.jsx(Que,{"aria-hidden":"true"}),"copy-image":h.jsx(hk,{"aria-hidden":"true"}),"copy-image-url":h.jsx(Gze,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Pue,{"aria-hidden":"true"})},KH=(e,t)=>t instanceof TU?`${e}: it is no longer in the session`:e,qxe=({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=Txe(e),y=Rxe(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(x=>(x.id!=="save-as"||!!d)&&(!l||x.id==="copy-file-path"));if(y.length===0)return null;const v=async(x,k,T)=>{try{await navigator.clipboard.writeText(x),Of(k)}catch(_){console.error(`${T}: `,_),mi(T)}},S=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const x=f?await f():await HH(g,e,t),k=await RRt(x);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),Of("Image copied to clipboard")}catch(x){console.error("Failed to copy image: ",x),mi(KH("Failed to copy image",x))}},Q=async()=>{try{const x=f?await f():await HH(g,e,t);qRt(x,d??"download")}catch(x){console.error("Failed to save file: ",x),mi(KH("Failed to save file",x))}},b=async x=>{let k=_U(e);if(s&&["open-file","open-folder","copy-file-path"].includes(x.id))try{k=await s()}catch{mi(J("ui.canvas.files.prepareError"));return}switch(x.id){case"expand-image":O?.();return;case"open-file":AO(k);return;case"open-folder":xU(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":Q();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":QU(t??e);return}},w=m??`Actions for ${n??"this image"}`;return h.jsxs(bA,{open:r,onOpenChange:i,children:[h.jsx(Yt,{content:p,children:h.jsx(wA,{asChild:!0,children:h.jsx(Xe,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:x=>x.stopPropagation(),children:h.jsx(yj,{"aria-hidden":"true"})})})}),h.jsxs(SA,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:x=>x.stopPropagation(),children:[s&&h.jsx("div",{role:"note",className:q("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:J("ui.canvas.files.pathCopyNote")}),y.map(x=>h.jsxs(jl,{onSelect:()=>b(x),children:[ARt[x.id],h.jsx("span",{children:x.label})]},x.id))]})]})},zRt=({src:e,alt:t,title:n,className:r})=>{const i=SP(),a=e??"",o=_xe(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=Xxe(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(qxe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||AO(_U(a))})}:void 0})})]})};function URt(){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 WRt={tokenize:NRt,concrete:!0,name:"mathFlow"},JH={tokenize:YRt,partial:!0};function NRt(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"),ln(e,c,"whitespace")(v))}function c(v){return v===null||bt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||bt(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(JH,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,f)(v)}function f(v){return(a?ln(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):bt(v)?e.attempt(JH,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||bt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,S,Q){let b=0;return ln(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(T){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),x(T)}function x(T){return T===36?(b++,v.consume(T),x):b<o?Q(T):(v.exit("mathFlowFenceSequence"),ln(v,k,"whitespace")(T))}function k(T){return T===null||bt(T)?(v.exit("mathFlowFence"),S(T)):Q(T)}}}function YRt(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 GRt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:IRt,previous:ZRt,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):bt(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||bt(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 IRt(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 ZRt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function DRt(e){return{flow:{36:WRt},text:{36:GRt()}}}const ep=36,eK=e=>e!==null&&e<-2,tK=e=>e===null||e===32||e<0,nK=e=>e!==null&&e>=48&&e<=57,jxe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:MRt,previous:VRt,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===ep?(r.consume(g),s++,d):s<2&&!t||s===1&&(tK(g)||nK(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===ep?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):eK(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===ep||eK(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===ep?(r.consume(g),c++,m):c===s?s===1&&(tK(l)||nK(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function MRt(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 VRt(e){return e!==ep||this.events[this.events.length-1][1].type==="characterEscape"}const LRt=DRt().flow,FRt=jxe();function TP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?FRt:jxe(e);n.push({flow:LRt,text:{[ep]:i}}),r.push(URt())}const BRt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),HRt=/\$(?!\d)(.+?)\$/,KRt=/\$\$([\s\S]+?)\$\$/,JRt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,eXt=/\\[a-zA-Z]+(\{[^}]*\})?/,rK=e=>HRt.test(e)||KRt.test(e)||JRt.test(e)?!0:eXt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),tXt=e=>{const t=PP(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},nXt=e=>PP(e).filter(t=>t.kind!=="text").length,rXt=e=>{if(!rK(e))return!1;const t=tXt(e);return t===null?!0:rK(t)||t.includes("$")?!1:nXt(e)<2},Kt="var(--color-ink)",bc="var(--color-ink-muted)",Sl="var(--color-surface)",Du="var(--color-elevated)",wc="var(--color-sunken)",oa="var(--color-hairline)",Mu="var(--color-control)",Xh="var(--color-accent)",Q0="var(--color-accent-wash)",iXt="var(--color-accent-alt-wash)",aXt="var(--color-on-accent)",oXt="var(--color-info)",Cxe="var(--color-info-wash)",sXt="var(--color-success)",Axe="var(--color-success-wash)",lXt="var(--color-warning)",s7="var(--color-warning-wash)",cXt="var(--color-warning-border)",lR="var(--color-danger)",l7="var(--color-danger-wash)",iK=[Q0,iXt,Cxe,Axe,s7,l7],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),uXt=()=>{const e={primaryColor:Vu("--color-accent"),secondaryColor:Vu("--color-success"),tertiaryColor:Vu("--color-info"),mainBkg:Vu("--color-elevated"),clusterBkg:Vu("--color-sunken"),clusterBorder:Vu("--color-hairline"),edgeLabelBackground:Vu("--color-surface"),quadrant1Fill:Vu("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:Sl,primaryTextColor:Kt,primaryBorderColor:Mu,secondaryTextColor:Kt,secondaryBorderColor:oa,tertiaryTextColor:Kt,tertiaryBorderColor:oa,lineColor:bc,arrowheadColor:bc,textColor:Kt,secondBkg:wc,border1:Mu,border2:oa,labelColor:Kt,nodeBkg:Du,nodeBorder:Mu,nodeTextColor:Kt,defaultLinkColor:bc,titleColor:Kt,noteBkgColor:s7,noteBorderColor:cXt,noteTextColor:Kt,actorBkg:Du,actorBorder:Mu,actorTextColor:Kt,actorLineColor:oa,signalColor:bc,signalTextColor:Kt,labelBoxBkgColor:Du,labelBoxBorderColor:oa,labelTextColor:Kt,loopTextColor:Kt,activationBkgColor:Q0,activationBorderColor:Xh,sequenceNumberColor:Sl,sectionBkgColor:wc,sectionBkgColor2:Sl,altSectionBkgColor:wc,excludeBkgColor:wc,taskBkgColor:Q0,taskBorderColor:Mu,taskTextColor:Kt,taskTextLightColor:Kt,taskTextDarkColor:Kt,taskTextOutsideColor:Kt,taskTextClickableColor:Xh,activeTaskBkgColor:Q0,activeTaskBorderColor:Xh,gridColor:oa,doneTaskBkgColor:wc,doneTaskBorderColor:oa,critBkgColor:l7,critBorderColor:lR,todayLineColor:Xh,transitionColor:bc,transitionLabelColor:Kt,stateLabelColor:Kt,stateBkg:Du,labelBackgroundColor:Sl,compositeBackground:wc,altBackground:wc,compositeTitleBackground:Du,compositeBorder:oa,innerEndBackground:Kt,specialStateColor:Kt,classText:Kt,attributeBackgroundColorOdd:Sl,attributeBackgroundColorEven:wc,rowOdd:Sl,rowEven:wc,errorBkgColor:l7,errorTextColor:lR,pieTitleTextColor:Kt,pieSectionTextColor:Kt,pieLegendTextColor:Kt,pieStrokeColor:Sl,pieOuterStrokeColor:oa,requirementBackground:Du,requirementBorderColor:Mu,requirementTextColor:Kt,relationColor:bc,relationLabelBackground:Sl,relationLabelColor:Kt,branchLabelColor:aXt,commitLabelColor:Kt,commitLabelBackground:Sl,tagLabelColor:Kt,tagLabelBackground:Q0,tagLabelBorder:Mu,quadrant2Fill:Cxe,quadrant3Fill:Axe,quadrant4Fill:s7,quadrant2TextFill:Kt,quadrant3TextFill:Kt,quadrant4TextFill:Kt,quadrantPointFill:Xh,archEdgeColor:bc,archEdgeArrowColor:bc,archGroupBorderColor:oa,scaleLabelColor:Kt,packet:{startByteColor:Kt,endByteColor:Kt,labelColor:Kt,titleColor:Kt,blockStrokeColor:Mu,blockFillColor:Du},radar:{axisColor:bc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:oa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Sl,titleColor:Kt,xAxisTitleColor:Kt,xAxisLabelColor:Kt,xAxisTickColor:oa,xAxisLineColor:oa,yAxisTitleColor:Kt,yAxisLabelColor:Kt,yAxisTickColor:oa,yAxisLineColor:oa,plotColorPalette:[Xh,oXt,sXt,lXt,lR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Du,t[`surfacePeer${n}`]=oa;for(let n=0;n<8;n++)t[`fillType${n}`]=iK[n%iK.length];return{...t,...e}};let cR=null,aK=null;const OXt=async e=>{cR||(cR=ve(async()=>{const{default:n}=await import("./mermaid.core-CWiad1OO.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,1,2]),import.meta.url).then(({default:n})=>n));const t=await cR;return aK!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:uXt()}),aK=e),t},oK=({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(Yt,{content:"Zoom in",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(Iue,{})})}),h.jsx(Yt,{content:"Zoom out",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(Zue,{})})}),h.jsx(Yt,{content:"Drag the diagram to pan",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(o9e,{})})}),h.jsx(Yt,{content:"Reset view",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(mk,{})})}),h.jsx(Yt,{content:"Save as SVG",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(Ov,{})})}),h.jsx(Yt,{content:t?"Copied":"Copy mermaid text",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(hk,{className:q(t&&"text-success")})})}),s]}),c7=({title:e,children:t})=>h.jsxs(Ll,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(E0,{children:e}),h.jsx(q0,{children:t})]});class dXt 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(c7,{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 fXt=$.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}),[Q,b]=$.useState("idle"),[w,x]=$.useState("idle"),k=Jn(U=>U.themeName),T=$.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 OXt(k),H=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:D}=await U.render(H,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 H=U instanceof Error?U.message:"Failed to render mermaid diagram";a(H),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{T().catch(U=>{console.error("Error in renderDiagram effect:",U),a("Failed to initialize diagram rendering"),s(!1)})},[T]);const _=$.useCallback(()=>{try{if(!l||!r.current)return 1;const H=r.current.getBoundingClientRect(),D=document.createElement("div");D.innerHTML=l;const V=D.querySelector("svg");if(!V)return 1;const se=V.getBoundingClientRect?.()?.width||Number.parseFloat(V.getAttribute("width")||"0")||V.viewBox?.baseVal?.width||800,B=V.getBoundingClientRect?.()?.height||Number.parseFloat(V.getAttribute("height")||"0")||V.viewBox?.baseVal?.height||600,K=H.width*.9/se,ne=H.height*.9/B;return Math.min(K,ne,1)}catch(U){return console.error("Error calculating fullscreen scale:",U),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const U=_();m({scale:U,x:0,y:0})}catch(U){console.error("Error setting fullscreen transform:",U)}},100)},[u,l,_]);const E=$.useCallback((U=!1)=>{try{(U?m:f)(D=>({...D,scale:Math.min(D.scale*1.2,10)}))}catch(H){console.error("Error in zoom in:",H)}},[]),R=$.useCallback((U=!1)=>{try{(U?m:f)(D=>({...D,scale:Math.max(D.scale/1.2,.1)}))}catch(H){console.error("Error in zoom out:",H)}},[]),j=$.useCallback((U=!1)=>{try{const H=U?m:f;if(U){const D=_();H({scale:D,x:0,y:0})}else H({scale:1,x:0,y:0})}catch(H){console.error("Error in reset:",H)}},[_]),C=$.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),H=URL.createObjectURL(U),D=document.createElement("a");D.href=H,D.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(H)}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),x("copied"),setTimeout(()=>x("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(H){console.error("Error in mouse down:",H)}},[]),Z=$.useCallback((U,H=!1)=>{try{if(!g)return;const D=U.clientX-v.x,V=U.clientY-v.y;(H?m:f)(B=>({...B,x:B.x+D,y:B.y+V})),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,H=!1)=>{try{U.preventDefault();const D=U.deltaY>0?.9:1.1;(H?m:f)(se=>({...se,scale:Math.min(Math.max(se.scale*D,.1),5)}))}catch(D){console.error("Error in wheel:",D)}},[]),M=$.useCallback(U=>{try{O(U)}catch(H){console.error("Error toggling fullscreen:",H)}},[]);if(i)return h.jsxs(c7,{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 te=(U=!1)=>{try{const H=U?r:n,D=U?p:d;return h.jsx("div",{ref:H,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:V=>Z(V,U),onMouseUp:F,onMouseLeave:F,onWheel:V=>z(V,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(H){return console.error("Error rendering diagram content:",H),h.jsx(c7,{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:[te(!1),h.jsx(oK,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>R(!1),onReset:()=>j(!1),onSave:C,onCopy:W,children:h.jsx(Yt,{content:"Fullscreen",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>M(!0),children:h.jsx(Eue,{})})})})]}),h.jsx(R$,{open:u,onClose:()=>M(!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:[te(!0),h.jsx(oK,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>R(!0),onReset:()=>j(!0),onSave:C,onCopy:G,children:h.jsx(Yt,{content:"Close fullscreen",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>M(!1),children:h.jsx(ea,{})})})})]})})]})}),hXt=$.memo(e=>h.jsx(dXt,{children:h.jsx(fXt,{...e})}));let zxe=!1,uR=null;const pXt=()=>(uR||(uR=ve(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(zxe=!0,e))),uR),mXt=/language-(\w+)/,gXt=JQ,$Xt=new RegExp(`^[^${ba}\\d*+-]`),yXt=/\n$/,Uxe=({href:e,children:t})=>{const n=GSe(e),r=SP();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=>wXt(i,r):void 0,children:t})},vXt=e=>GSe(e)?.kind==="file",bXt=VSe,wXt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(MSe)??"file",i=n.getAttribute(bXt),a=rTt({kind:r,hasHighlight:$Tt(n),canOpenInCanvas:SU(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||AO(i)});return}AO(i)}},u7=(e,t)=>t==="href"&&vXt(e)?e:uhe(e),my={a:Uxe,table:BRt,img:zRt,code:({node:e,className:t,children:n,...r})=>mXt.exec(t??"")?.[1]==="mermaid"?h.jsx(hXt,{chart:String(n).replace(yXt,"")}):h.jsx("code",{className:t,...r,children:n})},SXt={...my,a:wRt(Uxe)},xXt=[IO],QXt=[IO,TP],kXt=[IO,xP],PXt=[IO,TP,xP],_Xt=[IO,_P,QP],TXt=[IO,TP,_P,QP],RXt=[IO,xP,_P,QP],XXt=[IO,TP,xP,_P,QP],EXt={"000":xXt,"001":_Xt,"010":kXt,"011":RXt,100:QXt,101:TXt,110:PXt,111:XXt},qXt=[],jXt=[tJe],Wxe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Nxe=(e,t,n)=>{const r=$.useMemo(()=>rXt(e),[e]),[i,a]=$.useState(zxe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return pXt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:EXt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?jXt:qXt}},Yxe=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=Utt(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=aTt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return DSe(r,window.api?.probeFiles,rle).then(()=>{i&&r.some(s=>ZSe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},gy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=Nxe(a,r,i),l=Wxe(t);return Yxe(a,r),h.jsx("div",{className:q("lo-markdown",n),style:l,children:h.jsx(Kj,{remarkPlugins:o,rehypePlugins:s,urlTransform:u7,components:i?SXt:my,children:a})})});gy.displayName="MarkdownRenderer";const sK={...my,a:({children:e})=>h.jsx(h.Fragment,{children:e})},Gxe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:EH(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=oxe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=Nxe(n,t,!1);if(Yxe(e,t),r!==null){const o=EH(r.before);return h.jsxs(h.Fragment,{children:[o.trim()!==""&&h.jsx(Kj,{remarkPlugins:i,rehypePlugins:a,urlTransform:u7,components:t?my:sK,children:o}),h.jsx(CXt,{info:r.info,body:r.body})]})}return h.jsx(Kj,{remarkPlugins:i,rehypePlugins:a,urlTransform:u7,components:t?my:sK,children:n})});Gxe.displayName="ParsedBlock";const CXt=({info:e,body:t})=>{const n=e.split(gXt)[0];return h.jsx("pre",{children:h.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
|
|
867
867
|
`)?"":`
|
|
868
868
|
`}`})})},Ixe=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=wTt());const i=r.current;kTt(i,e);const{blockStart:a}=i,o=a+PTt(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&$Xt.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=Wxe(t);return h.jsx("div",{className:q("lo-markdown",n),style:O,children:u.map(d=>h.jsx(Gxe,{source:d.source,closed:d.closed},d.key))})};Ixe.displayName="StreamingMarkdown";const No=({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}),XU=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},AXt=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 EU=XU(Date.now()),aO=null;const B1=new Set,Zxe=()=>{aO!==null&&clearTimeout(aO),aO=setTimeout(()=>{aO=null,EU=XU(Date.now());for(const e of B1)e();Zxe()},AXt(Date.now())),aO.unref?.()},zXt=e=>(B1.add(e),EU=XU(Date.now()),Zxe(),()=>{B1.delete(e),B1.size===0&&aO!==null&&(clearTimeout(aO),aO=null)}),lK=()=>EU,UXt=()=>$.useSyncExternalStore(zXt,lK,lK),WXt=e=>new Date(e+1e3),NXt=()=>WXt(UXt()),GOn=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":yde(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},YXt=(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=BGe(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=yde(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),""}},GXt=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":HGe(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},IXt={turn:"Sent",answer:"Answered",tool:"Ran"},Dxe=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=NXt();if(Number.isNaN(r.getTime()))return null;const a=GXt(r,{hour12:!0});return h.jsx(Yt,{content:a,side:"bottom",delayDuration:1200,children:h.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${IXt[t]} ${a}`,className:q("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:YXt(r,i)})})},qU=({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(Jze,{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(Xe,{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(ea,{"aria-hidden":"true"})})]},n.id))]}),ZXt=({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}),DXt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},MXt=({line:e})=>h.jsx("span",{className:q(DXt[e.kind],"block"),children:e.text}),VXt=({diff:e,className:t})=>{const n=fEe(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(MXt,{line:r},i)),n.hidden>0&&h.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:hEe(n.hidden)})]})},LXt=(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()},cK=e=>e.startsWith("file://")?e.slice(7):e,FXt={READ:{verb:"Read",runningVerb:"Reading",icon:hz},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:zue},EDIT:{verb:"Edited",runningVerb:"Editing",icon:$9e},CODE:{verb:"Ran code",runningVerb:"Running code",icon:kue},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:q9e},DONE:{verb:"Finished",runningVerb:"Finishing",icon:xA},ASK:{verb:"Asked",runningVerb:"Asking",icon:dk},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:Oze}},BXt={verb:"Worked on the request",runningVerb:"Working on the request",icon:kue},HXt=(e,t,n,r)=>{const i=e?FXt[e]:BXt;let a;if(t)a=cK(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=cK(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?LXt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},uK="min-h-5 py-0",KXt=({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(ZXt,{className:q(a?"text-danger":"text-ink-dim",o&&KOe),children:e}),h.jsxs("span",{className:q(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[h.jsxs("span",{...x5,className:q("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?h.jsxs("span",{...x5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?h.jsxs("span",{...x5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),OK=({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=HXt(e,t,n,r),m=c??(i?p.runningVerb:p.verb),g=a?kp:p.icon,y=a||!c||!O?h.jsx(g,{}):O,v=h.jsx(KXt,{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($a,{summary:v,chevron:"leading",summaryAlign:S,defaultOpen:o,className:l,rowClassName:f?uK:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):h.jsx($a,{disabled:!0,summary:v,summaryAlign:S,className:l,rowClassName:f?uK:void 0})},Mxe=8,JXt="… deeper values not shown",e4t="(empty)";function t4t(e){return`… ${e} more line${e===1?"":"s"}`}const dK=.5;function n4t(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 Vxe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function jU(e){return typeof e=="object"&&e!==null}function Lxe(e,t,n,r){if(n>Mxe){r.push({key:t,value:JXt,depth:n});return}if(jU(e)){for(const[a,o]of Object.entries(e))Lxe(o,t?`${t}.${a}`:a,n+1,r);return}const i=Vxe(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))Lxe(r,n,1,t);return t}const r4t=512;function i4t(e,t){if(t)return!0;if(!e)return!1;let n=r4t;const r=(i,a)=>{if(n--<=0||a>Mxe)return!0;if(!jU(i))return Vxe(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 a4t(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(!jU(n))return null;const r=Fxe(n);return r.length>0?r:[{key:"",value:e4t,depth:1}]}const o4t=8,O7="max-h-[min(320px,40vh)]",Bxe=O7,s4t=({line:e})=>h.jsxs("div",{className:q("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*o4t},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})]}),fK=({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(s4t,{line:n},r))});function hK(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+dK);const f=c.children.length>0?Array.from(c.children):[c];n(n4t(f.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,dK))};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 pK=({lines:e,overflowing:t})=>t?h.jsx("span",{className:q("mt-1 block text-ink-dim"),children:e>0?t4t(e):" "}):null,l4t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=Fxe(e),o=a4t(t),s=$.useRef(null),l=$.useRef(null),c=hK(s),u=hK(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(O7,"overflow-auto"),children:h.jsx(fK,{lines:a,label:"input"})}),h.jsx(pK,{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(O7,"overflow-auto"),children:o?h.jsx(fK,{lines:o,label:"result-json"}):h.jsx("pre",{className:q("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),h.jsx(pK,{lines:u.lines,overflowing:u.overflowing})]})]})},c4t="mcp__",u4t={bash:z9e,read:pk,write:bG,edit:bG,glob:Rp,grep:fv,todo:Zze,wake:fk,list_variables:xG,read_variable:xG,browser:wG,console:mz,project:aze,project_delete:W9e,web_search:wG,web_fetch:Ov,task:Bd,agent:Bd,send:Nue,peer:Aze,sessions:b9e};function O4t(e){const t=e.trim().toLowerCase(),n=u4t[t];return n||(t.startsWith(c4t)?Uue:V9e)}const d4t=pz,f4t=Bze,h4t=Lze,mK="min-h-5 py-0",gK={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},p4t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?gK.plain:gK[tEe(t)],m4t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",g4t=({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]})]}),OR={running:"",success:"succeeded",error:"failed",interrupted:"interrupted","not-run":"never ran",partial:"",receipt:""},$4t=1e3;function y4t(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,$4t);return()=>window.clearInterval(i)},[e]),t}const v4t=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=y4t(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?I4e[t]:void 0,c=s?l??null:o?l??OR[e]:null,O=q("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?M4e[t]??null:null,f=s&&t?Z4e[t]:void 0,p=s?t==="mailbox"?f4t:t==="unconfirmed"?h4t:null:e==="interrupted"?d4t:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":ec(a??0):jA(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&&OR[e]?h.jsx("span",{className:q("sr-only"),children:OR[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})]})},xO=({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=O4t(e),S=uf(e),{verb:Q,object:b}=Ale(e,r,i,g,t,L4e(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",p4t(o,e)),children:h.jsx(v,{})}),n?null:h.jsx("span",{"data-trace-verb":"",className:q("shrink-0 whitespace-nowrap text-body-sm",m4t(o)),title:S,children:Q}),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(g4t,{added:u,removed:O}),h.jsx(v4t,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),x=g?{"data-glass-state":"running"}:void 0,k=g?"bg-elevated":y?"bg-danger-wash":"hover:bg-row-hover",T=d?h.jsx($a,{summary:w,chevron:"leading",defaultOpen:f,className:q("@container/toolrow",p),triggerData:x,rowClassName:mK,triggerClassName:q("-mx-2 rounded-sm px-2",k),children:d}):h.jsx($a,{disabled:!0,summary:w,triggerData:x,rowClassName:mK,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:[T,m]}):T},b4t=3,Hxe=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},d7=e=>{const t=new Map;let n=0;for(const a of e){const o=Hxe(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=x4t(Q4t(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}},w4t=e=>d7(e).units;function S4t(e){return w4t(e).join(" · ")}const $K={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"}},dR=5,x4t=e=>{if(e.length<=dR)return e.map(r=>r.label);const t=e.slice(0,dR),n=e.slice(dR).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},Q4t=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=Hxe(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",$K.todo);else{const u=$K[l];if(u)n(`kind:${l}`,u);else{const O=uf(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 k4t(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 P4t(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=k4t(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 _4t(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return Ale(n.name,n.summary??"",null,!0,n.op)}return null}function T4t(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>=b4t)n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:o,summary:{...d7(o),units:[...d7(o).units,...t.receiptSummaryOf?.(a)??[]]},failedCount:o.filter(s=>s.failed).length,span:P4t(o),live:_4t(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 yK=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??[])x$(r)&&t.push(r);return t},H1=5,R4t=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<H1?{shown:Math.max(e,0),more:0}:{shown:H1-1,more:e-(H1-1)},X4t=e=>{const t=H1-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},qx=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function jx(e){return e.record.kind==="tool"?e.record.durationS:null}function Kxe(e){let t=null;for(const n of e){const r=jx(n);typeof r=="number"&&(t=(t??0)+r)}return t}function E4t(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 q4t="min-h-5 py-0",j4t=1e3;function C4t(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,j4t);return()=>window.clearInterval(i)},[e]),t}const A4t=({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=C4t(n?.running===!0),d=n===null?null:Math.max(0,((n.running?O:n.endedAtMs??O)-n.startedAtMs)/1e3),f=d===null?"":jA(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($a,{animate:i||!s,open:i,onOpenChange:a,rowClassName:q4t,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))}),qx(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:qx(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)]})},vK=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],z4t=80,U4t=1e3,Jxe=({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=Ez("(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,Q=y.current===t;g.current=v,y.current=t,!S&&v&&Q&&l(Math.floor((Date.now()-f.current)/1e3))},[r,t]),$.useEffect(()=>{const v=O?window.setInterval(()=>l(Math.floor((Date.now()-f.current)/1e3)),U4t):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const S=window.setInterval(()=>o(Q=>(Q+1)%vK.length),z4t);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:vK[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?ec(s):""})]})},W4t="min-h-5 py-0",Lu=()=>h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),N4t=({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`,Q=y?.receipts??g?.count,b=Q===void 0?null:`At least ${Q} messages — earlier rows are not loaded`,w=$.useRef(null),x=()=>{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($a,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:W4t,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(xA,{"aria-hidden":!0,className:q("size-3.5 shrink-0 text-success")})}),y?.active?h.jsxs(h.Fragment,{children:[c!==null&&h.jsx(Lu,{}),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(Lu,{}),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(Lu,{}),h.jsx(Jxe,{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(Lu,{}),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(Lu,{}),h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:ec(g.spanS)})]})]}):h.jsxs(h.Fragment,{children:[c!==null&&(i!==null||a>0)&&h.jsx(Lu,{}),i!==null&&h.jsxs("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:["Took ",ec(i)]}),i!==null&&a>0&&h.jsx(Lu,{}),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})]}),qx(m)!==null&&h.jsxs(h.Fragment,{children:[h.jsx(Lu,{}),h.jsx("span",{className:q("shrink-0 text-body-sm text-ink-muted"),children:qx(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(Dxe,{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(x)})]})},eQe="lo-missing-session-notice",zO=({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}),Y4t="could not be displayed. It may have been moved, renamed, or deleted.",CU="could not be displayed. Its stored copy is not available to this reader.",tQe="could not be played. Its stored copy is not available to this reader.",nQe=tQe,_f=({name:e,detail:t=Y4t,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(SG,{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(SG,{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}`]})]}),Uw=(e,t,n)=>Math.min(n,Math.max(t,e)),Fi=ta((e,t)=>{const n=new Map,r=o=>{o.onended=()=>{const{ownerId:l,handlers:c}=t();l!==null&&(e({status:"ended",currentTime:o.currentTime}),c?.onEnded?.())},o.onerror=()=>{const{ownerId:l,handlers:c}=t();l!==null&&(e({status:"error"}),c?.onError?.())};const s=()=>{e({duration:Number.isFinite(o.duration)?o.duration:0,currentTime:o.currentTime})};o.onloadedmetadata=s,o.ondurationchange=s,o.ontimeupdate=()=>{e({currentTime:o.currentTime})}},i=()=>{const o=t().element;if(o)return o;const s=new Audio;return s.preload="metadata",r(s),rQe?.(s),e({element:s}),s},a=o=>{o.pause(),o.removeAttribute("src"),o.load?.()};return{element:null,ownerId:null,url:null,status:"idle",currentTime:0,duration:0,volume:1,playbackRate:1,generation:0,handlers:null,play:async(o,s,l)=>{const c=t().generation+1,u=i();a(u),u.volume=t().volume,u.playbackRate=t().playbackRate,u.src=s,e({ownerId:o,url:s,status:"loading",currentTime:0,duration:Number.isFinite(u.duration)?u.duration:0,generation:c,handlers:l??null});try{await u.play()}catch{return t().generation!==c||(e({status:"error"}),t().handlers?.onError?.()),!1}if(t().generation!==c)return!1;const O=n.get(o);return O!==void 0&&(t().seek(o,O),n.delete(o)),e({status:"playing"}),!0},resume:async o=>{const{element:s,ownerId:l,status:c}=t();if(!s||l!==o||c!=="paused"&&c!=="ended")return!1;const u=t().generation+1;e({generation:u,status:"loading"}),c==="ended"&&(s.currentTime=0);try{await s.play()}catch{return t().generation!==u||(e({status:"error"}),t().handlers?.onError?.()),!1}return t().generation!==u?!1:(e({status:"playing"}),!0)},pause:o=>{const{element:s,ownerId:l}=t();!s||l!==o||(s.pause(),e({generation:t().generation+1,status:"paused",currentTime:s.currentTime}))},toggle:async(o,s,l)=>{const{ownerId:c,status:u}=t();return c===o&&u==="playing"?(t().pause(o),!1):c===o&&(u==="paused"||u==="ended")?t().resume(o):t().play(o,s,l)},seek:(o,s)=>{const{element:l,ownerId:c,duration:u}=t();if(!l||c!==o){n.set(o,Math.max(0,s));return}const O=Uw(s,0,u>0?u:s);l.currentTime=O,e({currentTime:O})},scrub:(o,s)=>{const{element:l,ownerId:c,duration:u}=t();if(!l||c!==o){n.set(o,Math.max(0,s));return}const O=Uw(s,0,u>0?u:s);typeof l.fastSeek=="function"?l.fastSeek(O):l.currentTime=O},stop:o=>{const{element:s,ownerId:l}=t();s&&(o!==void 0&&l!==o||(a(s),e({generation:t().generation+1,ownerId:null,url:null,status:"idle",currentTime:0,duration:0,handlers:null})))},setVolume:o=>{const s=Uw(o,0,1),l=t().element;l&&(l.volume=s),e({volume:s})},setPlaybackRate:o=>{const s=Uw(o,.5,4),l=t().element;l&&(l.playbackRate=s),e({playbackRate:s})}}});let rQe=null;function IOn(e){rQe=e}function fR(){return Fi.getState().element}const f7=4,iQe=2,G4t=2,I4t=4,aQe=f7+iQe,Z4t=.8,D4t=24,bK=.3,wK=1;function M4t(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+iQe)/aQe))}function V4t(e,t){const n=Math.min(e,t-e);return Number.isFinite(n)?Math.max(0,Math.min(1,n/D4t)):0}function L4t(e,t){if(t<=0)return[];if(e.length===0)return new Array(t).fill(0);const n=new Array(t),r=e.length/t;for(let i=0;i<t;i+=1){const a=Math.floor(i*r),o=Math.max(a+1,Math.floor((i+1)*r));let s=0;for(let l=a;l<o&&l<e.length;l+=1){const c=e[l];Number.isFinite(c)&&c>s&&(s=c)}n[i]=Math.max(0,Math.min(1,s))}return n}function F4t(e,t,n){const r=M4t(t),i=e===null?null:L4t(e,r),a=[],o=Math.max(1,r-1);for(let s=0;s<r;s+=1){const l=s*aQe,c=l+f7/2,O=(i===null?0:i[s])*n*Z4t,d=Math.max(I4t,Math.round(O)),f=bK+(wK-bK)*(s/o);a.push({x:l,width:f7,height:d,alpha:Math.min(wK,f)*V4t(c,t)})}return a}function s$(e){if(!Number.isFinite(e)||e<=0)return"0:00";const t=Math.floor(e),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}function B4t(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return 0;const r=Math.max(0,Math.min(1,e/t));return!Number.isFinite(n)||n<=0?0:r*n}function H4t(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}function SK(e,t){return`${s$(e)} of ${s$(t)}`}const K4t=4,xK=1,J4t="flex min-h-11 min-w-11 shrink-0 items-center justify-center text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink disabled:pointer-events-none disabled:text-ink-disabled",oQe=({ownerId:e,src:t,label:n,peaks:r,durationHint:i=null,variant:a="full",className:o})=>{const s=Fi(H=>H.ownerId===e),l=Fi(H=>H.ownerId===e?H.status:"idle"),c=Fi(H=>H.ownerId===e?H.duration:0),[u,O]=$.useState(!1),[d,f]=$.useState(!1);$.useEffect(()=>{(l==="loading"||l==="playing")&&f(!1)},[l]);const p=c>0?c:i??0,m=s&&l==="playing",g=s&&l==="loading",y=d||s&&l==="error",v=$.useRef(null),S=$.useRef(null),Q=$.useRef(null),b=$.useRef(null),w=$.useRef(null),[x,k]=$.useState({width:0,height:0,dpr:1});$.useEffect(()=>{const H=v.current;if(!H)return;const D=()=>{const se=H.getBoundingClientRect();k({width:se.width,height:se.height,dpr:window.devicePixelRatio||1})};D();const V=new ResizeObserver(D);return V.observe(H),()=>V.disconnect()},[]);const T=$.useCallback(H=>{if(!H||x.width<=0)return;const D=H.getContext("2d");if(!D)return;H.width=Math.max(1,Math.round(x.width*x.dpr)),H.height=Math.max(1,Math.round(x.height*x.dpr)),D.setTransform(x.dpr,0,0,x.dpr,0,0),D.clearRect(0,0,x.width,x.height);const V=getComputedStyle(H).color,se=F4t(r,x.width,x.height);D.fillStyle=V;for(const B of se)D.globalAlpha=B.alpha,D.beginPath(),D.roundRect(B.x,(x.height-B.height)/2,B.width,B.height,G4t),D.fill();D.globalAlpha=1},[x.width,x.height,x.dpr,r]);$.useEffect(()=>{T(S.current),T(Q.current)},[T]);const _=$.useRef(null),E=$.useCallback(H=>{const D=H4t(H,p),V=Q.current;v.current?.style.setProperty("--sound-progress",`${D*100}%`),V&&(V.style.clipPath=`inset(0 ${(1-D)*100}% 0 0)`);const se=s$(H);w.current&&w.current.textContent!==se&&(w.current.textContent=se);const B=b.current;B&&(B.setAttribute("aria-valuenow",String(Math.floor(H))),B.setAttribute("aria-valuetext",SK(H,p)))},[p]);$.useEffect(()=>{const H=m||u,D=()=>E(s?fR()?.currentTime??0:W.current);if(!H){D();return}let V=0;const se=()=>{const B=_.current??fR()?.currentTime??0;E(B),V=requestAnimationFrame(se)};return V=requestAnimationFrame(se),()=>cancelAnimationFrame(V)},[m,u,s,E]);const R=$.useCallback(async()=>(f(!1),Fi.getState().play(e,t,{onError:()=>f(!0)})),[e,t]),j=$.useCallback(H=>{const D=Fi.getState();if(m){D.seek(e,H),E(H);return}R().then(V=>{V!==!1&&(Fi.getState().seek(e,H),E(H))})},[e,m,R,E]),C=$.useCallback(async()=>{if(m){Fi.getState().pause(e);return}f(!1),await Fi.getState().toggle(e,t,{onError:()=>f(!0)})},[e,t,m]),W=$.useRef(0),G=$.useRef(null),N=$.useCallback(H=>{const D=v.current;if(!D)return 0;const V=D.getBoundingClientRect();return B4t(H-V.left,V.width,p)},[p]),Z=H=>{if(g)return;H.currentTarget.setPointerCapture?.(H.pointerId),G.current={pointerId:H.pointerId,startX:H.clientX,moved:!1,pendingX:H.clientX,raf:0}},F=H=>{const D=G.current;!D||D.pointerId!==H.pointerId||(Math.abs(H.clientX-D.startX)>K4t&&(D.moved||O(!0),D.moved=!0),D.pendingX=H.clientX,D.moved&&D.raf===0&&(D.raf=requestAnimationFrame(()=>{const V=G.current;if(!V)return;V.raf=0;const se=N(V.pendingX);_.current=se,Fi.getState().scrub(e,se),E(se)})))},z=H=>{const D=G.current;if(!D||D.pointerId!==H.pointerId)return;D.raf!==0&&cancelAnimationFrame(D.raf),G.current=null,_.current=null,H.currentTarget.releasePointerCapture?.(H.pointerId);const V=N(H.clientX);if(D.moved){W.current=V,O(!1),Fi.getState().seek(e,V),E(V);return}j(V)},M=H=>{const D=fR(),V=s&&D?D.currentTime:0;if(H.key===" "||H.key==="Enter"){H.preventDefault(),C();return}let se=null;if(H.key==="ArrowLeft"?se=V-xK:H.key==="ArrowRight"?se=V+xK:H.key==="Home"?se=0:H.key==="End"&&(se=p),se===null)return;H.preventDefault();const B=Math.max(0,Math.min(p,se));j(B)},te=a==="compact",U=`${n} position`;return h.jsxs("div",{"data-sound-player":a,"data-sound-status":y?"error":u?"scrubbing":s?l:"idle",className:q("flex w-full min-w-0 items-center gap-2",te?"gap-1.5":"gap-2",o),children:[h.jsx("button",{type:"button",className:J4t,disabled:g,onClick:()=>void C(),"aria-label":`${m?"Pause":"Play"} ${n}`,children:g?h.jsx(Go,{size:"sm"}):m?h.jsx(xue,{size:22,"aria-hidden":"true"}):h.jsx(JAe,{size:22,"aria-hidden":"true"})}),h.jsx("div",{ref:b,role:"slider",tabIndex:0,"aria-label":U,"aria-valuemin":0,"aria-valuemax":Math.max(0,Math.round(p)),"aria-valuenow":0,"aria-valuetext":SK(0,p),"data-sound-slider":"",className:q("group relative min-h-11 min-w-0 flex-1 cursor-pointer touch-none select-none","rounded-sm outline-offset-2 focus-visible:outline-2 focus-visible:outline-accent",y&&"cursor-default"),onPointerDown:Z,onPointerMove:F,onPointerUp:z,onPointerCancel:z,onKeyDown:M,children:h.jsxs("div",{ref:v,className:"absolute inset-0",children:[h.jsx("canvas",{ref:S,className:"absolute inset-0 h-full w-full text-ink-dim"}),h.jsx("canvas",{ref:Q,style:{clipPath:"inset(0 100% 0 0)"},className:"absolute inset-0 h-full w-full text-ink-muted"}),h.jsx("span",{"data-sound-thumb":"",className:q("pointer-events-none absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-ink-muted group-hover:bg-ink group-focus-visible:bg-accent",u&&"bg-accent"),style:{left:"var(--sound-progress, 0%)"}})]})}),h.jsx("span",{ref:w,"data-sound-time":"",className:q("min-w-10 shrink-0 text-center text-meta text-ink-muted tabular-nums"),children:s$(0)}),h.jsx("span",{className:q("min-w-10 shrink-0 text-center text-meta text-ink-dim tabular-nums"),children:s$(p)}),y?h.jsx("span",{"data-sound-error":"",className:q("shrink-0 text-meta text-ink-muted"),children:"This sound could not be played"}):null]})};function QK(e){const t=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.peaks)?e.peaks:null;if(!t||t.length===0)return null;const n=[];for(const r of t){if(typeof r!="number"||!Number.isFinite(r))return null;n.push(Math.max(0,Math.min(1,r)))}return n}const kK=new Map;async function eEt(e,t){try{const n=await su({op:"sessions.attachment.waveform",sessionId:e.sessionId,digest:t},null);if(n.kind==="json")return QK(n.body);if(n.kind==="bytes"){const r=new TextDecoder().decode(n.data);try{return QK(JSON.parse(r))}catch{return null}}return null}catch{return null}}function sQe(e,t){const n=t?.sessionId??null,r=t?.childId??null,[i,a]=$.useState(()=>e?tEt(e):null);return $.useEffect(()=>{if(!e||!n){a(null);return}let o=!0;return nEt({sessionId:n,childId:r},e).then(s=>{o&&a(s)}),()=>{o=!1}},[e,n,r]),i}function tEt(e){return h7.get(e)??null}const h7=new Map;function nEt(e,t){const n=kK.get(t);if(n)return n;const r=eEt(e,t).then(i=>(h7.set(t,i),i)).catch(()=>(h7.set(t,null),null));return kK.set(t,r),r}function lQe(e){return`sound:${e.attachment??e.id}`}const AU=({audio:e,scope:t,label:n,ownerId:r})=>{const i=Dv(e,t),a=sQe(e.attachment,t);return i.state==="missing"?h.jsx(_f,{name:n,detail:nQe}):i.state==="resolving"?h.jsx("div",{className:q("inline-block max-w-full self-start"),"aria-hidden":!0,children:h.jsx(zO,{"data-attachment-reserved":""})}):h.jsx("div",{className:q("w-full max-w-[560px] self-start"),children:h.jsx(oQe,{ownerId:r??lQe(e),src:i.url,label:n,peaks:a,durationHint:e.durationS??null})})},Qd=1,cQe=4,PK=(e,t)=>Math.min(cQe,Math.max(Qd,e+t)),Vg=Object.freeze({x:0,y:0}),hR=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),pR=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,rEt=(e,t)=>`Image ${e+1} of ${t}`,_K=(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))}},iEt="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",aEt="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",TK=e=>q(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),oEt="opacity-45",zU=({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(Qd),[p,m]=$.useState(Vg),g=$.useRef(e);$.useLayoutEffect(()=>{g.current!==e&&(g.current=e,f(Qd),m(Vg))},[e]);const[y,v]=$.useState(!0),S=$.useRef(null);$.useEffect(()=>{if(!n)return;let U;const H=()=>{clearTimeout(U),U=setTimeout(()=>{const V=S.current;if(V&&(V.matches(":hover")||V.contains(document.activeElement))){H();return}v(!1)},$de)},D=()=>{v(!0),H()};return v(!0),H(),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 Q=s?.onPrev,b=s?.onNext,w=s!==void 0&&s.count>1,x=w?aEt:iEt,k=$.useRef(null),T=l??k;$.useEffect(()=>{if(!n||!w)return;const U=H=>{H.defaultPrevented||H.metaKey||H.ctrlKey||H.altKey||(H.key==="ArrowLeft"?(H.preventDefault(),Q?.()):H.key==="ArrowRight"&&(H.preventDefault(),b?.()))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[n,w,Q,b]),gA(n,"image-lightbox");const _=$.useRef(null),E=e!==void 0&&!O,R=d===Qd&&p.x===Vg.x&&p.y===Vg.y,j=U=>{if(!E)return;f(U);const H=_.current;H&&m(D=>_K(D,{width:H.clientWidth,height:H.clientHeight},U))},C=()=>{E&&(f(Qd),m(Vg))},W=$.useRef(null),[G,N]=$.useState(!1),Z=E&&d>Qd,F=U=>{!Z||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 H=W.current,D=_.current;!H||H.pointerId!==U.pointerId||!D||m(_K({x:H.pan.x+(U.clientX-H.startX),y:H.pan.y+(U.clientY-H.startY)},{width:D.clientWidth,height:D.clientHeight},d))},M=U=>{W.current?.pointerId===U.pointerId&&(W.current=null,N(!1))},te=e!==void 0&&!O?h.jsx("div",{ref:_,"data-image-viewport":"",tabIndex:-1,className:q(x,"relative h-fit w-fit overflow-hidden leading-none outline-none",Z&&(G?"cursor-grabbing":"cursor-grab"),Z&&"touch-none"),onPointerDown:F,onPointerMove:z,onPointerUp:M,onPointerCancel:M,children:h.jsx("img",{src:e,alt:t,draggable:!1,className:q(x,"block select-none object-contain"),style:R?void 0:{transform:`translate(${p.x}px, ${p.y}px) scale(${d})`},onError:()=>u(e)})}):e===void 0&&o?h.jsx("div",{className:TK(x),"aria-hidden":"true"}):h.jsx("div",{className:TK(x),children:a});return h.jsx($A,{open:n,onOpenChange:r,children:h.jsxs(yA,{ref:T,tabIndex:-1,onOpenAutoFocus:U=>{U.preventDefault(),(_.current??T.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:U=>{const H=i?.current;H&&(U.preventDefault(),H.focus())},className:q("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",x,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[h.jsx(vA,{className:"sr-only",children:t}),w&&s?h.jsx("div",{"aria-live":"polite",className:"sr-only",children:rEt(s.index,s.count)}):null,te,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":`${oEt} 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(Xe,{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(YAe,{"aria-hidden":"true"})}),h.jsx(Xe,{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(ole,{"aria-hidden":"true"})})]}):null,h.jsxs("div",{className:"pointer-events-auto fixed right-4 bottom-4 flex items-center gap-1",children:[h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",title:"Zoom out",disabled:!E||d===Qd,onClick:()=>j(PK(d,-1)),children:h.jsx(Zue,{"aria-hidden":"true"})}),h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",title:"Zoom in",disabled:!E||d===cQe,onClick:()=>j(PK(d,1)),children:h.jsx(Iue,{"aria-hidden":"true"})}),h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",title:"Reset view",disabled:!E||R,onClick:C,children:h.jsx(mk,{"aria-hidden":"true"})})]}),h.jsx(FRe,{asChild:!0,children:h.jsx(Xe,{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(ea,{"aria-hidden":"true"})})})]})]})})};zU.displayName="ImageLightbox";const sEt={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(" ")},lEt=/[/\\]/,RK=e=>{const t=e.split(lEt);return t[t.length-1]},uQe=$.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=Jn(T=>T.setCanvasOpen),{setViewMode:m}=zd(),g=$.useCallback(async()=>{const T=RK(e),_=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:R,setSelectedTab:j}=zd.getState();if(e.startsWith("data:"))if(t7(T)){const C=e,W={id:C,title:T,path:C,content:e,type:NS(e)},N=zd.getState().conversations?.[n],Z=N?.files??[],F=N?.openTabs??[],z=(()=>{const U=Z.findIndex(H=>H.id===C);return U!==-1?[...Z.slice(0,U),W,...Z.slice(U+1)]:[...Z,W]})();E(n,z);const te=F.some(U=>U.id===C)?F:[...F,{id:C,title:T}];R(n,te),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&&t7(T)){const G=C,N={id:G,title:T,path:C,content:W.data,type:NS(e)},F=zd.getState().conversations?.[n],z=F?.files??[],M=F?.openTabs??[],te=(()=>{const D=z.findIndex(V=>V.id===G);return D!==-1?[...z.slice(0,D),N,...z.slice(D+1)]:[...z,N]})();E(n,te);const H=M.some(D=>D.id===G)?M:[...M,{id:G,title:T}];R(n,H),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 _(G)}}},[e,p,m,n]),y=()=>{l(!0)},v=Txe(e),Q=(v==="path"||v==="data")&&n!=="",b=Xxe(v,{canShowInCanvas:Q,source:t}),w=v==="path",x=r??RK(e);if(s)return h.jsx(_f,{name:x,compact:i==="thumbnail"});const k=h.jsx(zO,{boundary:i==="thumbnail"?"control":"hairline",children:h.jsx("img",{className:q(sEt[i],c?"opacity-100":"opacity-0"),src:t,alt:x,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 ${x}`,title:o?o.title:`Click to expand ${x}`,"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:T=>{T.stopPropagation()},onKeyDown:T=>T.stopPropagation(),children:h.jsx(qxe,{file:e,src:t,label:x,onShowInCanvas:Q?g:void 0})}),o?null:a?a({open:O,onOpenChange:d,restoreFocusTo:f}):h.jsx(zU,{src:t,label:x,open:O,onOpenChange:d,restoreFocusTo:f,fallback:h.jsx(_f,{name:x,detail:w?void 0:CU})})]})});uQe.displayName="ImageAttachment";const cEt=(e,t,n)=>e.name??(n===1?"Image":`Image ${t+1}`),uEt={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},OEt=({cold:e,children:t})=>e?h.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,dEt=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=cEt})=>{const s=e.length,[l,c]=$.useState(()=>hR(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(hR(t,s)));const d=hR(l,s),f=e[d]??uEt,p=o(f,d,s),m=RU(f,n),g=$.useRef(null),y=$.useRef(null),[v,S]=$.useState(!1),Q=$.useCallback(N=>{g.current=N,S(N!==null)},[]),b=N=>{const Z=g.current?.querySelector(`button[aria-label="Show image ${N+1} of ${s}"]`);Z?Z.focus():y.current?.focus()},w=N=>{const Z=pR(d,s,N),F=g.current?.contains(document.activeElement)??!1;c(Z),F&&b(Z)},x=()=>w(-1),k=()=>w(1),T=JSON.stringify([n?.sessionId,n?.childId,e.map(N=>[N.id,N.attachment,N.mimeType])]),[_,E]=$.useState(()=>({identity:T,open:r,indices:new Set}));(_.identity!==T||_.open!==r)&&E({identity:T,open:r,indices:new Set});const R=$.useCallback(N=>{E(Z=>{if(!r||Z.identity!==T||!Z.open||N.every(z=>Z.indices.has(z)))return Z;const F=new Set(Z.indices);for(const z of N)F.add(z);return{...Z,indices:F}})},[T,r]),j=pR(d,s,-1),C=pR(d,s,1);$.useEffect(()=>{r&&R([d,j,C])},[r,d,j,C,R]),$.useEffect(()=>{const N=g.current;if(!r||!v||!N||typeof IntersectionObserver>"u")return;let Z=!0;const F=new IntersectionObserver(z=>{Z&&R(z.filter(M=>M.isIntersecting).map(M=>Number(M.target.dataset.imageSlot)-1))},{root:N});for(const z of N.querySelectorAll("[data-image-slot]"))F.observe(z);return()=>{Z=!1,F.disconnect()}},[r,v,R]);const W=(N,Z)=>!!N.data||!N.attachment||Z===d||Z===j||Z===C||_.identity===T&&_.open&&_.indices.has(Z);$.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:Q,"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,Z)=>h.jsx("li",{"data-image-slot":Z+1,className:q("flex shrink-0 scroll-mx-px rounded-sm leading-none",Z===d&&"ring-1 ring-ink"),children:h.jsx(OEt,{cold:!!N.attachment&&!N.data,children:W(N,Z)?h.jsx(Dm,{image:N,scope:n,size:"thumbnail",label:o(N,Z,s),press:{onPress:()=>c(Z),label:`Show image ${Z+1} of ${s}`,title:`Show image ${Z+1} of ${s}`,current:Z===d}}):h.jsx("button",{type:"button","aria-label":`Show image ${Z+1} of ${s}`,title:`Show image ${Z+1} of ${s}`,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{R([Z]),c(Z)},children:h.jsx(zO,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},N.id))}):void 0;return h.jsx(zU,{src:m.state==="ready"?m.url:void 0,pending:m.state==="resolving",label:p,open:r,onOpenChange:i,restoreFocusTo:a,fallback:h.jsx(_f,{name:p,detail:CU}),layerRef:y,group:{index:d,count:s,onPrev:x,onNext:k,filmstrip:G}})},Dm=({image:e,scope:t,label:n,size:r,group:i,press:a})=>{const o=RU(e,t);if(o.state==="resolving"){const l=h.jsx(zO,{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(_f,{name:n,compact:r==="thumbnail",detail:CU});const s=o.url;return h.jsx("div",{className:q("inline-block max-w-full"),children:h.jsx(uQe,{file:s,src:s,label:n,size:r,conversationId:t?.sessionId??"",press:a,overlay:i?l=>h.jsx(dEt,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:l.open,onOpenChange:l.onOpenChange,restoreFocusTo:l.restoreFocusTo}):void 0})})},fEt="Generating name…",hEt={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 pEt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function UU(e,t){return`Turn ${e} of ${t}`}const mEt=e=>e.charAt(0).toLowerCase()+e.slice(1);function gEt(e,t){const n=UU(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function $Et(e){return e.kind==="completion"&&e.naming?.state==="pending"}function yEt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function vEt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const bEt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function wEt(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 SEt(e,t){const n=mEt(UU(e.turn,t));if(e.kind==="user"){const i=wEt(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 xEt(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 mR(e,t){const n=[];for(const r of t)xEt(e,r)==="pending"&&n.push(r);return n}const QEt=120,XK=80,kEt="Turn checkpoints",PEt={complete:xu,error:kp,interrupted:pz,open:FAe},_Et={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},TEt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?PEt[n]:null,i=yEt(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:[UU(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})]})]}),$Et(e)&&h.jsx("p",{className:q("text-ink-dim text-meta"),children:fEt}),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",_Et[n]),children:[h.jsx(r,{"aria-hidden":"true",className:q("size-3.5 shrink-0")}),bEt[n]]})})]})},REt=$.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",hEt[n])})})}),XEt=({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)},[]),Q=$.useCallback((B,K)=>{S();const ne=()=>{O(B),f(p.current.find(le=>le.id===B)??null)};if(K<=0){ne();return}y.current=setTimeout(()=>{y.current=null,ne()},K)},[S]),b=$.useCallback(B=>{if(S(),B<=0){O(null);return}v.current=setTimeout(()=>{v.current=null,O(null)},B)},[S]),w=$.useRef(e);$.useEffect(()=>{w.current!==e&&(w.current=e,S(),M.current=null,c(null),O(null),f(null))},[e,S]);const x=$.useRef(null);$.useLayoutEffect(()=>{const B=g.current;if(!(t.length===0||B===null)){if(o!==null&&k.current===e){x.current=e;return}x.current!==e&&(x.current=e,B.scrollTop=B.scrollHeight)}},[o,t.length,e]);const k=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const B=g.current,K=m.current.get(o);if(B===null||K===void 0)return;k.current=e;const ne=B.getBoundingClientRect(),le=K.getBoundingClientRect(),Oe=le.top-ne.top+B.scrollTop,Qe=Oe+le.height,we=24;Oe<B.scrollTop+we?B.scrollTop=Math.max(0,Oe-we):Qe>B.scrollTop+B.clientHeight-we&&(B.scrollTop=Qe-B.clientHeight+we)},[o,e]),$.useEffect(()=>()=>S(),[S]);const T=$.useRef(r);$.useEffect(()=>{T.current=r});const _=$.useMemo(()=>vEt(t),[t]),E=$.useMemo(()=>new Map(t.map(B=>[B.id,SEt(B,_)])),[t,_]),R=u&&d?.id===u?d:null,j=u&&m.current.get(u)||null,C=$.useMemo(()=>({current:j}),[j]),W=R!==null&&j!==null;$.useEffect(()=>{T.current(W&&u?u:null)},[W,u]);const G=$.useCallback((B,K)=>{K?m.current.set(B,K):m.current.delete(B)},[]),[N,Z]=$.useState(null),F=N&&t.some(B=>B.id===N)?N:t[0]?.id??null,z=$.useCallback(B=>{const K=Math.max(0,Math.min(t.length-1,B)),ne=t[K];ne&&(Z(ne.id),m.current.get(ne.id)?.focus())},[t]),M=$.useRef(null),te=$.useCallback(B=>{M.current!==B&&(M.current=B,c(B),Q(B,QEt))},[Q]),U=$.useCallback(()=>{M.current=null,c(B=>B===null?B:null),b(XK)},[b]),H=$.useCallback(B=>{M.current=B,Z(B),c(K=>K===B?K:B),Q(B,0)},[Q]),D=$.useCallback(()=>{M.current=null,c(B=>B===null?B:null),b(XK)},[b]),V=$.useCallback(B=>{b(0),M.current=null,c(null),n(B)},[b,n]),se=$.useCallback((B,K)=>{if(B.key==="Escape"){b(0);return}const ne=t.findIndex(le=>le.id===K);if(!(ne<0)){if(B.key==="ArrowDown"){B.preventDefault(),B.stopPropagation(),z(ne+1);return}if(B.key==="ArrowUp"){B.preventDefault(),B.stopPropagation(),z(ne-1);return}if(B.key==="Home"){B.preventDefault(),B.stopPropagation(),z(0);return}B.key==="End"&&(B.preventDefault(),B.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":kEt,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(B=>h.jsx(REt,{checkpoint:B,state:pEt({id:B.id,previewId:l,activeId:o,loaded:a?a.has(B.id):!0}),label:E.get(B.id)??"",roving:B.id===F,registerTick:G,onPreview:te,onPreviewEnd:U,onFocusMark:H,onBlurMark:D,onActivate:V,onKeyMark:se,describedBy:W&&u===B.id?s:void 0},B.id))})]}),h.jsxs(BRe,{open:W,onOpenChange:B=>{B||b(0)},children:[h.jsx(HRe,{virtualRef:C}),R&&h.jsx(KRe,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":R.kind==="user"?"Your message":gEt(R,_),onOpenAutoFocus:B=>B.preventDefault(),onCloseAutoFocus:B=>B.preventDefault(),onFocusOutside:B=>{const K=B.detail?.originalEvent?.target;K instanceof Element&&K.closest("[data-lo-checkpoint-rail]")&&B.preventDefault()},className:q("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:R.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:R.text}):h.jsx(TEt,{checkpoint:R,turnCount:_})})]})]})},EEt=$.memo(XEt);function qEt(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 jEt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function CEt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function OQe(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):!jEt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function AEt(e,t){return CEt(e,t)||OQe(e,t)!==null}const zEt=3;function UEt(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>=zEt){n.onMissing();return}const s=OQe(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}`,qK=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=R4t(e.length,{uncapped:r}),s=X4t(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(Dm,{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(Xe,{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 jK(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 WEt(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 NEt=({video:e,scope:t,label:n})=>{const r=Dv(e,t),[i,a]=$.useState(!1);return r.state==="missing"||i?h.jsx(_f,{name:n,detail:tQe}):r.state==="resolving"?h.jsx("div",{className:q("inline-block max-w-full self-start"),"aria-hidden":!0,children:h.jsx(zO,{"data-attachment-reserved":""})}):h.jsx("div",{className:q("inline-block max-w-full self-start"),children:h.jsx(zO,{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)})})})};function YEt({items:e,summary:t,scope:n}){return h.jsxs("div",{"data-sound-batch":"",className:q("flex w-full min-w-0 max-w-[560px] flex-col gap-4"),children:[h.jsx("p",{className:q("text-meta text-ink-muted break-words [overflow-wrap:anywhere]"),children:t}),h.jsx("ul",{className:"flex min-w-0 flex-col gap-4",children:e.map(r=>h.jsxs("li",{"data-sound-batch-item":"",className:q("min-w-0"),children:[h.jsxs("p",{className:q("text-body text-ink break-words [overflow-wrap:anywhere]"),children:[r.label,r.status!=="completed"?` · ${r.status==="unknown"?"Status unknown":r.status==="cancelled"?"Stopped":"Failed"}`:""]}),r.error?h.jsx("p",{className:q("text-body-sm text-ink break-words [overflow-wrap:anywhere]"),children:r.error}):r.audio?h.jsx(AU,{audio:r.audio,ownerId:`${lQe(r.audio)}:batch:${r.audio.id}:${r.id}`,scope:n,label:r.label}):h.jsx("p",{className:q("text-meta text-ink-muted"),children:"Audio attachment unavailable."}),h.jsx("p",{className:q("text-meta text-ink-dim"),children:r.costCaption??"Cost not yet known."})]},r.id))})]})}function ZOn({sessionId:e,runningSound:t,available:n,onInterrupt:r,onRestoreFocus:i}){const[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(e);$.useEffect(()=>{const f=l.current!==e;l.current=e,!(!f&&t)&&a&&(o(!1),i())},[e,t,a,i]);const c=$.useCallback(()=>{o(!1),i()},[i]),u=$.useCallback(()=>{if(!e||!n)return;const f=s.current?.querySelector("[data-sound-stop-confirmation] button");if(f){f.focus();return}if(t){o(!0);return}r()},[e,n,t,r]),O=$.useCallback(()=>{o(!1),i(),r()},[r,i]),d=$.useMemo(()=>a&&t?h.jsx(dQe,{onKeepWaiting:c,onRequestStop:O}):null,[a,t,c,O]);return{paneRef:s,stop:u,confirmation:d}}function dQe({onKeepWaiting:e,onRequestStop:t}){const n=$.useRef(null),r=$.useId();return $.useEffect(()=>{n.current?.focus();const i=a=>{a.key!=="Escape"||a.isComposing||a.defaultPrevented||(a.preventDefault(),a.stopPropagation(),e())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[e]),h.jsxs("fieldset",{"data-sound-stop-confirmation":"","aria-label":"Confirm stop request",className:"flex flex-col items-start gap-2",children:[h.jsx("p",{className:"text-meta text-ink","aria-live":"polite",children:"Stop this generation?"}),h.jsx("p",{id:r,className:"text-body-sm text-ink-dim",children:"The provider has no cancellation endpoint. The generation continues and will be charged if it produces audio. Stopping is best-effort; it does not guarantee cancellation or no charge."}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(Xe,{ref:n,"aria-describedby":r,variant:"ghost",size:"sm",onClick:e,children:"Keep waiting"}),h.jsx(Xe,{variant:"secondary",size:"sm",onClick:t,children:"Request stop"})]})]})}const GEt=1e3;function IEt(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,GEt);return()=>window.clearInterval(i)},[e]),t}function ZEt(){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 DEt({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?O1(e.argumentBytes):null;break;case"running":n=e.batchProgress?`Generating ${e.batchProgress.total} ${Dh(e.material)}${e.batchProgress.total===1?"":"s"}…`:`Generating ${Dh(e.material)}…`,r=t===null?null:ec(t);break;case"cancelling":n=e.generating?cY:lY;break;case"done":n=e.receipt==="already-finished"?"Already finished.":e.batch?`${gR(e.material)} batch`:`Generated ${Dh(e.material)}`,r=e.receipt==="already-finished"||e.durationS===null?null:jA(e.durationS);break;case"failed":n=e.batch?`${gR(e.material)} batch failed.`:e.message??`The ${Dh(e.material)} could not be generated.`,i=!0;break;case"cancelled":{const a=e.message??(e.generating?cY:lY);n=e.batch?`${gR(e.material??"sound-effect")} batch stopped.`:e.settlementCaption||e.settled?AEe(a):a;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 MEt({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 gR(e){const t=Dh(e);return t.charAt(0).toUpperCase()+t.slice(1)}function Lg({line:e,prominent:t=!1}){return h.jsx("p",{"data-imagegen-note":"",className:q("min-w-0 text-body-sm",t?"text-ink-muted":"text-ink-dim"),children:e})}function VEt(e,t){return e==="cancel"?"Stop":e==="restart"?t==="failed"?"Retry":"Restart":"Edit and restart"}const LEt=({view:e,scope:t,actions:n})=>{const[r,i]=$.useState(!1),a=$.useCallback(()=>i(!1),[]),o=$.useRef(null),s=$.useRef(!1);$.useLayoutEffect(()=>{s.current&&!r&&(o.current?.querySelector("[data-imagegen-controls] button")??o.current)?.focus(),s.current=r},[r]),$.useLayoutEffect(()=>{const g=o.current;return()=>{g?.contains(document.activeElement)&&g.closest("[data-chat-pane]")?.querySelector("textarea")?.focus()}},[]);const l=e.state==="running"&&(e.material==="voiceover"||e.material==="sound-effect");$.useEffect(()=>{l||i(!1)},[l]);const c=e.state==="running"||e.state==="cancelling"?e.startedAtMs:null,u=IEt(c),O=UEe(e,n),d={cancel:n?.onCancel,restart:n?.onRestart,editRestart:n?.onEditRestart},f=e.state==="running"||e.state==="cancelling",p=f&&(e.state==="running"||e.generating),m=f&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return h.jsxs("div",{ref:o,tabIndex:-1,"data-imagegen-card":e.state,className:q("flex w-full flex-col gap-2"),children:[p?h.jsx(ZEt,{}):null,e.state==="failed"&&(e.material==="voiceover"||e.material==="sound-effect")&&e.errorType?h.jsx("p",{className:q("text-meta text-ink-dim"),children:e.errorType}):null,h.jsx(DEt,{view:e,elapsed:u}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.costCaption?h.jsx(Lg,{line:e.costCaption,prominent:!!e.batch}):null,(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batchNote?h.jsx(Lg,{line:e.batchNote,prominent:!0}):null,e.state==="running"&&e.batchProgress?.note?h.jsx(Lg,{line:e.batchProgress.note}):null,e.state==="cancelled"&&e.settlementCaption?h.jsx(Lg,{line:e.settlementCaption}):null,l&&r?h.jsx(dQe,{onKeepWaiting:a,onRequestStop:()=>{i(!1),n?.onCancel?.()}}):null,e.state==="running"&&typeof e.note=="string"?h.jsx(Lg,{line:e.note}):null,p&&e.progress.fraction!==null?h.jsx(JRe,{"aria-label":"Image generation progress",className:q("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,m===null?null:h.jsx(MEt,{line:m}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batch?h.jsx(YEt,{items:e.batch,summary:e.batchSummary??`${e.batch.length} items`,scope:t}):e.state==="done"&&e.images.length>0?h.jsx("div",{className:q("flex flex-col gap-2"),children:e.images.map((g,y)=>{const v=`Generated ${Dh(g.kind==="audio"?e.material:g.kind??"image")}`,S=e.images.length===1?v:`${v} ${y+1}`;return g.kind==="video"?h.jsx(NEt,{video:g,scope:t,label:S},g.id):g.kind==="audio"?h.jsx(AU,{audio:g,scope:t,label:S},g.id):h.jsx(Dm,{image:g,scope:t,label:S},g.id)})}):null,O.length>0&&!(l&&r)?h.jsx("div",{"data-imagegen-controls":"",className:q("flex items-center gap-2"),children:O.map(g=>h.jsx(Xe,{variant:"secondary",size:"sm",disabled:g.disabled,title:g.kind==="cancel"?e.state==="queued"||e.state==="cancelling"&&!e.generating?"Stops before the provider is called.":"Requests a stop; the provider may finish anyway.":void 0,onClick:g.kind==="cancel"&&l?()=>{const y=o.current?.closest("[data-chat-pane]")?.querySelector("[data-sound-stop-confirmation] button");if(y){y.focus();return}i(!0)}:d[g.kind],children:VEt(g.kind,e.state)},g.kind))}):null]})},l$=1e4,fQe=/\s/,FEt=e=>{for(let t=e.length;t>0;t-=1){const n=e[t-1];if(n===`
|
|
869
869
|
`)return t;if(n==="."||n==="!"||n==="?"){const r=e[t];if(r===void 0||fQe.test(r))return t}}return-1},BEt=e=>{for(let t=e.length;t>0;t-=1)if(fQe.test(e[t-1]))return t;return-1},HEt=/[\uD800-\uDBFF]/,KEt=e=>HEt.test(e[l$-1])?l$-1:l$;function WU(e){if(e.length<=l$)return{text:e,clipped:!1};const t=e.slice(0,l$),n=FEt(t),r=BEt(t),i=n>0?n:r>0?r:KEt(t),a=e.slice(0,i).trimEnd();return{text:a.length>0?a:t,clipped:!0}}const hQe="[speech]",JEt="Couldn't speak this aloud. Try again.",eqt="Couldn't speak this aloud. Try again.",pQe="This conversation's agent is no longer available.",tqt=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.",pQe,"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 nqt(e){const t=e instanceof Error?e.message:String(e);return tqt.has(t)?t:(console.error(`${hQe} ${t}`),JEt)}function rqt(e){return(e instanceof Error?e.message:String(e))===pQe}function iqt(e){const t=e?.binding?.agent;return typeof t=="string"&&t.length>0?t:null}function aqt(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 oqt=100;function sqt(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 $R(e){try{return await e()}catch{return null}}async function lqt(e){if(!e)return null;const t=hv(Nf.baseUrl),n=await $R(async()=>{const{profiles:a}=await Re({op:"profiles.list"});return aqt(e,a)});if(n?.state==="agent")return n.agentId;if(n?.state==="role-without-agent")return null;const r=await $R(async()=>{const a=await t.agents.listAgents(1,oqt,e);return a.status<400?sqt(e,a.result??null):null});return r||await $R(async()=>{const a=await t.agents.getAgent(e);return a.status<400?a.result?.id??null:null})}function NU(e){return ar(t=>e?iqt(t.sessions.find(n=>n.session_id===e)):null)}const cqt=20,mQe=e=>`msg:${e}`,CK=e=>`speech:${e}`,uqt="speech:",Oqt=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")},Cx=(e,t)=>`sel:${e}:${Oqt(t)}`,YU=(e,t)=>async()=>{const n=()=>AK.speech.create({input:t}),r=await lqt(e);return r===null?n():AK.speech.createForAgent(r,{input_text:t}).catch(i=>{if(!rqt(i))throw i;return n()})},AK=hv(Nf.baseUrl),dqt=e=>{for(;e.size>cqt;){const t=e.keys().next().value;if(t===void 0)return;e.delete(t)}},yR=new Map,fqt=(e,t)=>{let n=yR.get(e);return n===void 0&&(n=t().finally(()=>{yR.delete(e)}),yR.set(e,n)),n},Mv=ta((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 fqt(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),dqt(u),e({audioCache:u}),t().generation!==i)return}if(t().generation!==i)return;const o=URL.createObjectURL(a);if(!await Fi.getState().play(CK(n),o,{onEnded:()=>{URL.revokeObjectURL(o),e(c=>c.audioElement===Fi.getState().element?{playingKey:null,audioElement:null,currentUrl:null}:{})},onError:()=>{URL.revokeObjectURL(o),e(c=>c.audioElement===Fi.getState().element?{error:"Error playing audio.",playingKey:null,audioElement:null,currentUrl:null}:{}),console.error(`${hQe} playback failed for ${n}`),mi(eqt)}})||t().generation!==i){Fi.getState().stop(CK(n)),URL.revokeObjectURL(o);return}const l=new Set(t().heardKeys);l.add(n),e({playingKey:n,loadingKey:null,audioElement:Fi.getState().element,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(nqt(a))}},stopSpeech:()=>{const n=Fi.getState();n.ownerId?.startsWith(uqt)&&n.stop();const{currentUrl:r}=t();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(mQe(n),YU(r,i))}}));function GU({key:e,getText:t,play:n,available:r=!0}){const{dismiss:i,stopSpeech:a,loadingKey:o,playingKey:s,audioCache:l,heardKeys:c}=Mv(),{canUseRadientSpeech:u,speechBlock:O}=uGe(),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:ode("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:x}=WU(b);x&&!p&&Tp(`Reading the first ${w.length.toLocaleString("en-US")} characters. The rest is not read aloud.`),n({text:w})}}}function gQe(e){$.useEffect(()=>{if(e!==null)return()=>{Mv.getState().dismiss(e)}},[e])}const IU=({control:e,side:t="top"})=>{const n=$.useId(),r=e.disabled&&e.reason!==null;return h.jsx(Yt,{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(Xe,{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(m1,{"aria-hidden":"true"}):e.isLoading?h.jsx(Go,{size:"xs"}):h.jsx(D9e,{"aria-hidden":"true"})}),r&&h.jsx("span",{id:n,className:"sr-only",children:e.reason})]})})},Mm="data-lo-quote-toolkit";function p7(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const zK=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${Mm}]`)??null,hqt=e=>e.nodeType===Node.ELEMENT_NODE,pqt=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>hqt(r)&&r.hasAttribute(Mm));return n===-1?t.length:n},mqt=(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,gqt=e=>{const t=Array.from(document.querySelectorAll(`[${Mm}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>mqt(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function $y(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(zK(n.startContainer)||zK(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,pqt(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:gqt(n)}}const $Qe=8,$qt=.5;function yqt(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 UK=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function vqt({lines:e,container:t,viewport:n,size:r,gap:i=$Qe,row:a,belowWhenOffFirstLine:o=!1}){if(e.length===0)return null;const s=yqt(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*$qt,d=l.top-i-r.height>=s.top,f=c.bottom+i+r.height<=s.bottom,m=d&&!(o&&O&&f);return{top:UK(m?l.top-i-r.height:c.bottom+i,s.top,s.bottom-r.height),left:UK(l.left,s.left,s.right-r.width),placement:m?"above":"below"}}const WK="[data-lo-canonical-transcript]",bqt="[data-lo-transcript-content]",NK=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),wqt=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function yQe(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=vqt({lines:f,container:NK((O.closest(WK)??O).getBoundingClientRect()),viewport:wqt(),size:{width:d.offsetWidth,height:d.offsetHeight},row:NK(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(WK),p=f?.querySelector(bqt),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 vQe(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n($y(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 Ih="data-lo-link-toolbar",Sqt=120,xqt=2;function bQe(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=lTt(u);if(O){n(f=>f===O?f:O),i(f=>f===!0?f:!0);return}if(i(f=>f===!1?f:!1),FSe()){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=x=>{O&&(clearTimeout(O),O=0),o.current=x,l()},f=x=>{if(O&&clearTimeout(O),!x){O=0,o.current=null,l();return}o.current!==x&&(s.current=null,O=setTimeout(()=>{O=0,o.current=x,l()},Sqt))},p=(x,k)=>{const T=o.current;if(!T||!u.contains(T))return!1;const _=u.querySelector(`[${Ih}]`),E=$Qe+xqt;for(const R of[T,_]){if(!R)continue;const j=R.getBoundingClientRect();if(!(j.width<=0||j.height<=0)&&x>=j.left-E&&x<=j.right+E&&k>=j.top-E&&k<=j.bottom+E)return!0}return!1},m=x=>{const k=x.target;if(k?.closest(`[${Mm}]`))return;const T=k?.closest(Gh)??null;!T&&p(x.clientX,x.clientY)||f(T)},g=x=>{const k=x.relatedTarget;k&&u.contains(k)||p(x.clientX,x.clientY)||d(null)},y=x=>{const k=x.target?.closest(Gh);if(k){if(k===s.current){s.current=null;return}d(k)}},v=x=>{const k=x.relatedTarget;k&&u.contains(k)||d(null)},S=()=>Array.from(u.querySelectorAll(`[${Ih}] button:not([disabled])`)),Q=x=>{const k=x.target;if(!k)return!1;if(k.closest(`[${Ih}]`)){const R=S(),j=R.indexOf(k);if(j===-1)return!1;if(x.shiftKey&&j===0){const C=o.current;return C instanceof HTMLElement?(C.focus(),!0):!1}if(!x.shiftKey&&j===R.length-1){const C=Array.from(u.querySelectorAll(Gh)),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(x.shiftKey)return!1;const _=k.closest(Gh);if(!_||!u.contains(_))return!1;o.current!==_&&d(_);const[E]=S();return E?(E.focus(),!0):!1},b=x=>{if(x.key==="Tab"&&Q(x)){x.preventDefault();return}if(!(x.key==="ContextMenu"||x.shiftKey&&x.key==="F10"))return;const T=x.target?.closest(Gh);!T||!u.contains(T)||(x.preventDefault(),d(T),requestAnimationFrame(()=>{u.querySelector(`[${Ih}] button`)?.focus()}))},w=x=>{const k=x.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(`[${Ih}]`))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 wQe(e,t,n){const r=an(i=>i.addReply);return $.useCallback(()=>{const a=$y(t.current)?.text??(FSe()?null:n?.()??null);a&&(r(e,{id:fs(),text:a}),window.getSelection()?.removeAllRanges(),_z())},[r,e,t,n])}const SQe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(VSe)??"",o=n.getAttribute("data-lo-kind")??"file",s=SP(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=wQe(e,t,l),{text:u}=vQe(t),{speak:O}=Mv(),d=NU(e),f=u??l(),p=f===null?null:Cx(e,WU(f).text);gQe(p);const m=GU({key:p,getText:()=>$y(t.current)?.text??l(),play:({text:W})=>O(Cx(e,W),YU(d,W))}),[g,y]=$.useState(!1),[v,S]=$.useState(()=>L1(a)??null),{controlRef:Q,placement:b}=yQe({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=L1(a);if(S(W??null),y(!1),W!==void 0)return;let G=!0;return iTt(a,window.api?.probeFiles).then(()=>{G&&S(L1(a)??null)}),()=>{G=!1}},[a]);const w=o==="file"&&SU(s,a),x=KSe({target:a,isDirectory:v?.exists===!0&&!v.isFile,probe:v,canOpenInCanvas:w}),k=OTt({kind:o,target:a,probe:v,quotable:r,canOpenInCanvas:w});if(!k||!a)return null;const T=async()=>{await txe(a)&&y(!0)},_=async()=>{if(o==="url"){await TH(o,a);return}s&&x&&await s.openInCanvas(a)||await TH(o,a)||S(null)},E=async()=>{await AO(a)||S(null)},R=async()=>{await xU(a)||S(null)},j={quote:h.jsx(Wue,{}),copy:g?h.jsx(xu,{}):h.jsx(hk,{}),open:x?h.jsx(h9e,{}):o==="url"?h.jsx(Pue,{}):h.jsx(dv,{}),"open-default":h.jsx(qAe,{}),"open-folder":h.jsx(Rp,{})},C={quote:c,copy:()=>{T()},open:()=>{_()},"open-default":()=>{E()},"open-folder":()=>{R()}};return h.jsxs("div",{[Mm]:"",[Ih]:"",ref:Q,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(Yt,{content:W.id==="copy"&&g?"Copied":W.label,side:b?.placement==="below"?"bottom":"top",children:h.jsx(Xe,{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(IU,{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 Qqt({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:e==="response"?["copy"]:["copy","speak",...n]}function xQe(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const YK=96;function kqt(e){const t=e.replace(/\s+/g," ").trim();return t.length<=YK?t:`${t.slice(0,YK-1).trimEnd()}…`}const Pqt="Answer actions",_qt="Your message actions",Tqt="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 Rqt(e){return e?"opacity-100":Tqt}const Xqt=2e3,Eqt=1e4;function DOn(e){const{request:t}=e;return t?e.now-t.requestedAt>Eqt?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let GK=0,Ww=0;const qqt=ta(e=>({request:null,requestPanel:(t,n,r,i)=>{GK+=1,e({request:{destination:t,nonce:GK,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:()=>{Ww+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,Ww=Math.max(0,Ww-1),Ww===0&&e({presenterClaimed:!1}))}}})),jqt=(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)},Cqt=9e4,IK=new Set,Aqt=2600,m7=$.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}=Mv(),v=NU(r??null),S=GU({key:i?mQe(i):null,getText:()=>t,play:({text:E})=>{i&&y(i,v,E)}}),Q=qqt(E=>E.requestPanel),b=!!(s&&l);br();const w=Qqt({role:n,forkable:b}),x=c||S.active;$.useEffect(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]),$.useEffect(()=>{if(!a||o===void 0||IK.has(a)||(IK.add(a),Date.now()-o>Cqt))return;const E=p.current;if(E===null)return;const R=E.closest(".group")??E;if(jqt(E,R))return;d(!0);const j=()=>{d(!1),R.removeEventListener("pointerenter",j),R.removeEventListener("focusin",j)};return R.addEventListener("pointerenter",j),R.addEventListener("focusin",j),()=>{R.removeEventListener("pointerenter",j),R.removeEventListener("focusin",j)}},[a,o]),$.useEffect(()=>{if(O)return g.current=setTimeout(()=>{g.current=null,d(!1)},Aqt),()=>{g.current!==null&&clearTimeout(g.current)}},[O]);const k=async()=>{await txe(t)&&(u(!0),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,u(!1)},Xqt))},T=()=>{!s||!l||Q("session.fork",m.current,s,{id:l,excerpt:kqt(t)})},_={copy:h.jsx(Yt,{content:c?"Copied":"Copy",side:"bottom",children:h.jsx(Xe,{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(xu,{"aria-hidden":"true"}):h.jsx(hk,{"aria-hidden":"true"})})}),speak:h.jsx(IU,{control:S,side:"bottom"}),fork:h.jsx(Yt,{content:"Fork from this message",side:"bottom",children:h.jsx(Xe,{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:T,children:h.jsx(Pze,{"aria-hidden":"true"})})})};return h.jsx("div",{role:"toolbar","aria-label":n==="user"?_qt:n==="response"?J("ui.chat.response_actions.label"):Pqt,ref:p,onAnimationEnd:E=>{E.target===E.currentTarget&&d(!1)},...O?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:n==="response"?{"data-lo-response-actions":""}:{"data-lo-answer-actions":""},className:q("flex shrink-0 items-center gap-1",Rqt(x)),children:w.map(E=>h.jsx($.Fragment,{children:_[E]},E))})}),zqt="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",Nw="@min-[260px]/olderhistory:hidden",Yw="@max-[260px]/olderhistory:hidden",QQe="lo-older-history-hint",Uqt=({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:zqt,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:Nw,children:"Not loaded"}),h.jsx("span",{className:Yw,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:Nw,children:"Did not load"}),h.jsx("span",{className:Yw,children:"Could not load earlier messages"})]}),h.jsx(Xe,{variant:"ghost",size:"sm",className:"shrink-0",onClick:n,children:"Try again"})]}):a?h.jsxs(Xe,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"text-ink-muted",children:[h.jsx(Go,{size:"sm"}),"Loading earlier messages"]}):e==="idle"?h.jsx(Xe,{variant:"ghost",size:"sm",onClick:n,children:"Load earlier messages"}):e==="windowed"?h.jsxs("span",{id:QQe,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:Nw,children:t?"Earlier history above":"Scroll up for earlier"}),h.jsxs("span",{className:Yw,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:Nw,children:"Earlier not loaded"}),h.jsx("span",{className:Yw,children:"Earlier history not loaded"})]}),!t&&r&&h.jsx(Xe,{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"})]})},Wqt="/settings?section=providers",ZK="/settings?section=providers&provider=radient",Nqt="/settings?section=radient",DK=/sign in to radient/i,Yqt=[/insufficient credits/i,/credit balance is too low/i],Gqt=[/rate limit or quota/i],Iqt=[/insufficient credits/i,/\bHTTP 402\b/i];function kQe(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function ZU(e){return kQe(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&Iqt.some(n=>n.test(e.text)):!1}function Zqt(e){if(!ZU(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 Dqt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function MK(e){const t=kQe(e.provider)||DK.test(e.text);let n=Dqt(e.category);return ZU(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(DK.test(e.text)?n="sign-in":Yqt.some(r=>r.test(e.text))?n="billing":Gqt.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:"Sign in to Radient",to:ZK}:n==="billing"&&t?{label:"Open Radient account",to:Nqt}:{label:"Open provider settings",to:t?ZK:Wqt}}const PQe=({conversationId:e,turnRef:t})=>{const{text:n,clear:r}=vQe(t),i=n!==null,a=wQe(e,t),{controlRef:o,placement:s}=yQe({turnRef:t,visible:i,lines:()=>$y(t.current)?.lines??null}),{speak:l}=Mv(),c=NU(e),u=n===null?null:Cx(e,WU(n).text);gQe(u);const O=GU({key:u,getText:()=>$y(t.current)?.text??null,play:({text:d})=>l(Cx(e,d),YU(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",{[Mm]:"",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(Yt,{content:"Quote",side:s?.placement==="below"?"bottom":"top",children:h.jsx(Xe,{variant:"ghost",size:"icon-sm","aria-label":"Quote",className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:a,children:h.jsx(Wue,{})})}),h.jsx(IU,{control:O,side:s?.placement==="below"?"bottom":"top"})]}):null},_Qe={all:["radient-prices"],prices:()=>[..._Qe.all,"prices"]},Mqt=()=>{const e=jt({queryKey:_Qe.prices(),queryFn:()=>Az({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}},VK="https://console.radienthq.com/dashboard/verification",LK="https://console.radienthq.com/dashboard/billing",FK="Top up in Radient console";function Vqt(e){return!e.email_verified&&e.signup_grant!=="claimed"}const MOn=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`$${e.toFixed(2)} in free credits`,g7=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,Lqt=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`${g7(e)} in free credits`;function BK(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function Fqt(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const Bqt=(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 Hqt(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:VK},{label:FK,url:LK}]};if(Vqt(e)){const i=BK(e.claim_url,VK),{action:a}=Bqt(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 ${Lqt(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 ${g7(n.bonus_amount)} free on your first top-up of ${g7(n.minimum_purchase)} or more.`),{state:"verified",lines:r,links:[{label:FK,url:BK(n?.topup_url,LK)}]}}const Kqt=5*1e3,Jqt=({action:e})=>{const{user:t,accountRead:n}=cde({staleTime:Kqt,retryOnMount:!1}),r=Ri(),{prices:i}=Mqt(),o=r.isPending||n==="checking"?null:Hqt(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(KQ,{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(Xe,{variant:"secondary",size:"sm",onClick:()=>Fqt(s.url),children:s.label},s.url)),h.jsx(Xe,{variant:"ghost",size:"sm",asChild:!0,children:h.jsx(wue,{to:e.to,children:e.label})})]})]})},vR=(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)},K1=24,TQe=6,$7=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),HK=async e=>{for(let t=0;t<TQe;t+=1){if(e())return;await $7()}},RQe=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},ejt=e=>{const t=RQe(e.loadOlder),n=()=>HK(()=>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 HK(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},k0="data-jump-highlight",tjt=1400,njt=12,rjt=1200,ijt=TQe,ajt=ijt+2,ojt=2,sjt=30,KK=1,Fg=K1;let Eh=0;async function ljt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await ejt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:njt,maxRows:rjt})==="landed"}async function cjt(e,t,n){if(!n()||!t.isConnected)return;Eh+=1;const r=Eh;vR(e,t,"reversed",Fg);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<ajt&&(await $7(),!(!n()||!t.isConnected||a||r!==Eh));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-Fg;if(Math.abs(O)<=KK){if(l+=1,l>=ojt){c=!0;break}continue}l=0,vR(e,t,"reversed",Fg)}if(c&&!a&&r===Eh){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<sjt;f+=1){if(await $7(),!n()||a||r!==Eh||!u.isConnected||!O.isConnected)return;const p=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-Fg;if(Math.abs(p)<=KK)continue;vR(u,O,"reversed",Fg);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===Eh){const l=e.ownerDocument?.defaultView;l!=null&&e.dispatchEvent(new l.Event("scroll"))}}function XQe(e,t,n,r=()=>!0){return r()?new Promise(i=>{UEt(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}JK(a),cjt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(k0)&&JK(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const bR=new WeakMap;function JK(e){const t=bR.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(k0);e.removeAttribute(k0),n&&e.offsetHeight,e.setAttribute(k0,""),bR.set(e,window.setTimeout(()=>{bR.delete(e),e.removeAttribute(k0)},tjt))}const mO=120,Gw=400,ujt=.5,Ojt=320,djt=900,Iw=64,RP=2,wR=24,SR=3,fjt=4,yy=12,y7=yy,hjt=120,pjt=.35,eJ=12,mjt=8,gjt=yy,$jt=.5,tJ=()=>({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}),EQe=e=>Math.min(djt,Math.max(Ojt,Math.round(e*ujt))),yjt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=Gw?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=Gw?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=Gw?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,actTravelled:e.actTravelled||t.travelledPx>=Iw,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=Gw,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>=Iw:e.actTravelled||t.travelledPx>=Iw,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>=Iw&&!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}},Bg=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=RP,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}}),vjt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!qQe(t).inZone?!1:t.distanceFromTopPx<=RP?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=y7?!1:n-e.lastInputAt>=mO:!0;function qQe(e,t=EQe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const bjt=(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=EQe(t.clientHeight),{inZone:a}=qQe(t,i),o=n-e.lastInputAt>=mO||t.distanceFromTopPx<=RP,s=e.revealsThisAct<gjt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<eJ&&s)return o?Bg({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed){if(e.deliberate)return Bg(e,r,t);if(r==="fetch"&&e.failures>=SR)return{action:"none",state:{...e,armed:!1}};if(!o)return{action:"none",state:e};if(!a)return{action:"none",state:{...e,armed:!1}};if(r==="fetch"&&e.actFetchSpent){const l=n-e.lastInputAt>=mO;return l&&e.clampLatched&&!e.actTravelled&&e.pressDemand&&e.actAsks<y7?Bg(e,r,t):l?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e}}return Bg(e,r,t)}if(e.continuation){const l=e.actAsks<y7,c=l&&e.chainInvisible>0&&e.chainInvisible<yy;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<eJ:(c||l&&e.chainFetch<fjt)&&e.failures<SR)?Bg({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},nJ=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<mjt,l=r===null&&t&&i!==null&&i<Math.max(hjt,pjt*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,yy):0,continuation:t&&n>0||c&&e.chainInvisible+1<yy||!e.retained&&!e.turnedAround}},wjt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),Sjt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),xjt=(e,t,n,r)=>n===r?jQe(e,t):null,jQe=(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)<$jt?0:n};function CQe({path:e}){switch(Dz(e)){case"image":return h.jsx(mze,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return h.jsx(yze,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return h.jsx(pk,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return h.jsx(dv,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}function Qjt(e,t){try{return SU(e,t)}catch{return!1}}function DU(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(J("ui.chat.highlights.file_resolution_failed"))}},[e,t]),i=Qjt(n??null,e),a=$.useCallback(()=>{r(async o=>{i&&n&&await n.openInCanvas(o)||await AO(o)})},[r,i,n]);return{canOpenInCanvas:i,press:a,withTarget:r}}const AQe=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1}){const{canOpenInCanvas:o,withTarget:s}=DU(t,r,i),[l,c]=$.useState(!1),u=`Actions for ${n||"this file"}`;return h.jsxs(bA,{children:[h.jsx(Yt,{content:"File actions",children:h.jsx(wA,{asChild:!0,children:a?h.jsx(Xe,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":u,children:h.jsx(yj,{"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(yj,{"aria-hidden":"true",className:"size-3.5"})})})}),h.jsxs(SA,{align:"end",className:"min-w-45",children:[o&&h.jsxs(jl,{onSelect:()=>{s(O=>i?.openInCanvas(O))},children:[h.jsx(Xue,{"aria-hidden":"true"}),h.jsx("span",{children:"Open in canvas"})]}),h.jsxs(jl,{onSelect:()=>{s(AO)},children:[h.jsx(dv,{"aria-hidden":"true"}),h.jsx("span",{children:"Open in default app"})]}),h.jsxs(jl,{onSelect:()=>{s(xU)},children:[h.jsx(Rp,{"aria-hidden":"true"}),h.jsx("span",{children:"Reveal in Finder"})]}),h.jsxs(jl,{onSelect:()=>{navigator.clipboard.writeText(t).then(()=>c(!0)).catch(()=>mi("Failed to copy file path"))},children:[h.jsx(Que,{"aria-hidden":"true"}),h.jsx("span",{children:l?"Copied":"Copy file path"})]})]})]})}),kjt="lo-supplement",Pjt="s";function _jt(e,t){return`${kjt}://${Pjt}/${e}/${t}`}const Tjt="[supplement] frame torn down after a second load (hostile navigation or a blocked attempt)";function Rjt(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 Xjt({component:e,sessionId:t,documentHtml:n,documentFailed:r=!1,onRetry:i,onHeightChange:a,className:o}){const s=Ble(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(()=>{}),Q=$.useRef(0),b=$.useRef(s),w=$.useRef(null),x=$.useRef(()=>{}),k=$.useRef(a),T=$.useRef(()=>{}),_=$.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=$qe();const R=window.api?.desktop?.armSupplementFrame,j=t!==null&&S$(e.attachment);let C;if(R===void 0)C=wqe(n);else if(j)C=_jt(t,e.attachment);else{_("no-address");return}let W=!1,G=!1,N=null,Z=null,F=null;const z={resize:null,error:!1},M=window.setTimeout(()=>{W||_("no-ready")},dY),te=ne=>{E.contentWindow?.postMessage(ne,"*")},U=()=>{y.current||Z===null&&(te({lo:"supplement-host",t:"ping"}),Z=window.setTimeout(()=>{Z=null,_("no-pong")},dY))};S.current=()=>{G||y.current||(G=!0,U(),N=window.setInterval(U,mqe))};const H=ne=>{const le=p.current;if(le){const Oe=Rjt(le);if(Oe&&le.getBoundingClientRect().top<Oe.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:le}=z;if(z.resize=null,z.error=!1,le){_("frame-error");return}ne!==null&&H(ne)}))},V=ne=>{if(y.current||ne.source!==E.contentWindow||ne.origin!=="null")return;const le=gqe(ne.data,g.current);if(le){if(le.t==="ready"){W||(W=!0,window.clearTimeout(M));return}if(le.t==="pong"){Z!==null&&(window.clearTimeout(Z),Z=null);return}if(le.t==="resize"){z.resize=Hle(le.h),f(!1),D();return}z.error=!0,D()}},se=()=>{const ne=w.current;ne!==null&&H(ne)};window.addEventListener("message",V),window.addEventListener("scroll",se,!0);let B=!1;return(async()=>{if(R)try{await R(C)}catch{}B||(E.src=C)})(),()=>{B=!0,window.clearTimeout(M),N!==null&&window.clearInterval(N),Z!==null&&window.clearTimeout(Z),F!==null&&window.cancelAnimationFrame(F),window.removeEventListener("message",V),window.removeEventListener("scroll",se,!0),S.current=()=>{}}},[n,_,t,e.attachment]),k.current=a,T.current=E=>{y.current||Q.current!==1||m.current?.contentWindow?.postMessage({lo:"supplement-host",t:"theme",mode:E.mode,vars:E.vars,nonce:g.current},"*")},$.useEffect(()=>bqe(E=>T.current(E)),[]),x.current=()=>{const E=Q.current+1;if(Q.current=E,E>1){console.debug(Tjt),_("second-load");return}T.current(Fle()),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:()=>x.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: ",Ld(e.source)]})]})}function Ejt(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 qjt=150,v7=16*1024*1024,Js=new Map,$p=[];let P0=0,zQe=0,UQe=0,b7=0;const VOn=()=>({entries:Js.size,queued:$p.length,active:P0,reads:zQe,decodes:UQe,peakActive:b7}),jjt=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 Cjt(e){if(e.artifact)return Exe({sessionId:e.artifact.sessionId,childId:e.artifact.childId??null},e.artifact.digest);const t=await window.api.readFileBytes(e.path,v7);if(!t.success)throw new Error(t.error??"Could not be read");return new Blob([t.data],{type:Mz(e.path)})}function WQe(){for(const[e,t]of Js){if(Js.size<=qjt)return;t.listeners.size||t.started||(t.state.url&&$v(t.state.url),Js.delete(e))}}function rJ(e,t){e.state=t;for(const n of e.listeners)n(t)}function NQe(){for(;P0<4&&$p.length;){const e=$p.shift();if(!e||!e.listeners.size){e&&Js.delete(e.key);continue}e.started=!0,P0++,zQe++,b7=Math.max(b7,P0),(async()=>{try{if((e.document.sizeBytes??0)>v7)throw new Error("Too large to preview");const t=await Cjt(e.document);if(t.size>v7)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);UQe++;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"});rJ(e,{state:"ready",url:Lz(await O.arrayBuffer(),"image/png")})}finally{"close"in o&&o.close(),s&&URL.revokeObjectURL(s)}}catch(t){rJ(e,{state:"unavailable",reason:t instanceof Error?t.message:"Could not be read"})}finally{e.started=!1,P0--,WQe(),NQe()}})()}}function Ajt(e,t){const n=jjt(e),[r,i]=$.useState({state:"loading"});return $.useEffect(()=>{if(!t)return;let a=Js.get(n);a?.state.state==="unavailable"&&!a.listeners.size&&(Js.delete(n),a=void 0),a?(Js.delete(n),Js.set(n,a)):(a={key:n,document:e,state:{state:"loading"},listeners:new Set,started:!1},Js.set(n,a),$p.push(a)),a.listeners.add(i),i(a.state),NQe();const o=a;return()=>{if(o.listeners.delete(i),!o.started&&o.state.state==="loading"&&!o.listeners.size){const s=$p.indexOf(o);s>=0&&$p.splice(s,1),Js.delete(n)}WQe()}},[n,t,e]),r}const zjt="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",Ujt=$.memo(function({file:t,cwd:n,pane:r}){const{name:i,path:a}=Lle(t),o=i||a||t.path,[s,l]=Ejt(),[c,u]=$.useState(null),[O,d]=$.useState(!1);$.useEffect(()=>{let S=!1;const Q=window.api?.probeFiles;if(typeof Q!="function"){u(null),d(!0);return}return u(null),d(!1),(async()=>{try{const[b]=await Q([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=Ajt(f,l&&c!==null),{press:m}=DU(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(zO,{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(CQe,{path:t.path})}):h.jsx(zO,{boundary:"control",className:"h-[78px] w-[117px]"})}),h.jsx("div",{className:zjt,children:h.jsx(AQe,{overlay:!0,actionPath:t.path,label:o,cwd:n,pane:r})})]})})}),Wjt=({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(Ujt,{file:i,cwd:t,pane:n},i.path))}),Njt=2*1024*1024,tp=new Map,xR=new Map,Yjt=64,iJ={html:null,failed:!1};async function Gjt(e,t){const n=`${e}:${t}`,r=xR.get(n);if(r)return r;const i=(async()=>{try{const a=await su({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>Njt)return null;for(tp.set(n,s);tp.size>Yjt;){const l=tp.keys().next().value;if(l===void 0)break;tp.delete(l)}return s}catch{return null}finally{xR.delete(n)}})();return xR.set(n,i),i}function Ijt(e,t,n){const[r,i]=$.useState(()=>{if(!e||!S$(t))return iJ;const a=tp.get(`${e}:${t}`);return a!==void 0?{html:a,failed:!1}:iJ});return $.useEffect(()=>{if(!n||!e||!S$(t))return;const a=tp.get(`${e}:${t}`);if(a!==void 0){i({html:a,failed:!1});return}let o=!1;return Gjt(e,t).then(s=>{o||i(s!==null?{html:s,failed:!1}:{html:null,failed:!0})}),()=>{o=!0}},[n,e,t]),r}const aJ=$.memo(function({actionPath:t,cwd:n,label:r,suffix:i,size:a,pane:o}){const{press:s}=DU(t,n,o);return h.jsxs("div",{className:"group flex w-full items-center gap-2 text-meta",children:[h.jsx(CQe,{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:[Ld(r),i&&i!==r&&h.jsx("span",{className:"ml-2 text-ink-muted",children:Ld(i)})]}),a&&h.jsx("span",{className:"shrink-0 text-ink-dim",children:a}),h.jsx(AQe,{actionPath:t,label:r,cwd:n,pane:o})]})}),Zjt=$.memo(function({sound:t,sessionId:n}){const r=$.useMemo(()=>n?{sessionId:n,childId:null}:null,[n]),i=Dv({data:null,attachment:t.attachment,mimeType:t.mime},r),a=sQe(t.attachment,r),o=t.title||"Generated sound";return h.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[t.title&&h.jsx("span",{"data-supplement-sound-title":"",title:t.title,className:"truncate text-meta text-ink-muted",children:Ld(t.title)}),i.state==="missing"?h.jsx(_f,{name:o,detail:nQe}):i.state==="resolving"?h.jsx("div",{className:"h-11","aria-hidden":!0}):h.jsx(oQe,{variant:"compact",ownerId:`sound:${t.attachment}`,src:i.url,label:o,peaks:a,durationHint:t.durationS})]})}),oJ=$.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=Ijt(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(Xjt,{component:t,sessionId:n,documentHtml:l.html,documentFailed:l.failed,onRetry:r,onHeightChange:i?c:void 0})})}),Djt=$.memo(function({record:t,sessionId:n,cwd:r,condensed:i=!1}){const a=SP(),[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),[Q,b]=$.useState(0),w=HEe(t,t.live),x=oqe(t.cause),k=t.files,T=t.filesMore,_=t.components,E=t.sounds??[],R=k.length+T,j=async se=>{if(n){y(!0);try{await Re({...se,sessionId:n,job:t.job,anchor:t.anchor})}catch(B){mi(pv("Highlights could not be updated.",B))}finally{y(!1)}}},C=()=>{j({op:"supplements.cancel"})},W=()=>{j({op:"supplements.restart"})},G=()=>{const se=p.trim();se&&(f(!1),m(""),j({op:"supplements.steer",text:se}))},N=$.useCallback((se,B)=>{S(K=>{if(K.get(se)===B)return K;const ne=new Map(K);return ne.set(se,B),ne})},[]),Z=Qqe(typeof window>"u"?900:window.innerHeight),{visible:F}=kqe(_,Z,v);$.useEffect(()=>{b(se=>Math.max(se,F.length))},[F.length]);const z=Math.min(_.length,Math.max(Q,F.length)),M=_.slice(0,z),te=_.slice(z),U=()=>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:KEe})]}),(w==="cancelled_retry"||w==="files_cancelled_retry")&&h.jsx("span",{className:"text-ink-muted",children:JEe}),(w==="failed_retry"||w==="files_failed_retry")&&h.jsxs("span",{className:"text-ink-muted",children:[eqe,x?` — ${x}`:""]}),(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:tqe}),h.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60","data-supplement-cancel":"",disabled:g||t.state==="cancelling",onClick:C,children:nqe})]}),(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:W,children:rqe})]})]}):null,H=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:GEe,placeholder:"Adjust the graphic…",value:p,onChange:se=>m(se.target.value),onKeyDown:se=>{se.key==="Enter"&&G(),se.key==="Escape"&&(f(!1),m(""))}}),h.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60",disabled:g||!p.trim(),onClick:G,children:"Send"})]}):null;if(w==="nothing")return null;let D=null;if(k.length>0||T>0){const se=[],B=[];for(const ne of k)Dz(ne.path)==="image"?se.push(ne):B.push(ne);const K=R<=2&&_.length===0&&T===0;D=h.jsxs("div",{className:"flex flex-col gap-1","data-supplement-files-summary":K?"":void 0,"data-supplement-files":K?void 0:"",children:[se.length>0&&h.jsx(Wjt,{files:se,cwd:r,pane:a,className:B.length>0||T>0?"mb-1":void 0}),B.map(ne=>{const{name:le,path:Oe,size:Qe}=Lle(ne);return h.jsx(aJ,{actionPath:ne.path,cwd:r,label:le||Oe,suffix:Oe,size:Qe,pane:a},`${ne.path}:${ne.name}`)}),T>0&&h.jsx($a,{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":sqe(T)}),children:t.more.slice(0,20).map(ne=>h.jsx(aJ,{actionPath:ne,cwd:r,label:ne,suffix:"",size:"",pane:a},ne))})]})}const V=E.length>0?h.jsx("div",{className:"flex flex-col gap-1","data-supplement-sounds":"",children:E.map(se=>h.jsx(Zjt,{sound:se,sessionId:n},se.attachment))}):null;return h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,"data-supplement-condensed":i?"":void 0,children:[D,V,U(),i&&w==="block"&&D===null&&_.length>0&&h.jsx("div",{className:"text-ink-muted text-meta",children:cqe(_.length,"graphic")}),!i&&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."}),!i&&(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:Xqe(t)}),((t.attempts?.length??0)>0||(t.detail?.length??0)>0)&&h.jsx($a,{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(se=>h.jsx("p",{children:Rqe(se)},se))]})})]}),(w==="preparing"||w==="files_preparing")&&H,!i&&w==="block"&&_.length>0&&h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-components":"",children:[M.map(se=>h.jsx(oJ,{component:se,sessionId:n,onRetry:n?W:void 0,onHeight:N},se.attachment)),te.length>0&&h.jsx($a,{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":uqe(te.length)}),children:te.map(se=>h.jsx(oJ,{component:se,sessionId:n,onRetry:n?W:void 0,onHeight:N},se.attachment))})]})]})});function Mjt(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="f"}const Vjt=e=>e?"⌘F":"Ctrl+F";function Ljt(e){switch(e){case"ready":case"building":case"unsupported":case"error":return e;default:return"error"}}function Fjt(e,t,n){return n<=0?-1:(((e<0||e>=n?t>0?-1:0:e)+t)%n+n)%n}function Bjt(e,t){return t>=0&&t<e.length?e[t]:null}function Hjt(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 Kjt={user:"You",agent:"Agent"},Jjt="related match",sJ="Search this conversation",e3t="Search results",t3t="Close search";function n3t(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 r3t="No messages match this search.",i3t="Still indexing this conversation.",a3t="Results appear as the index catches up.",o3t="Newer messages may be missing while the index catches up.",s3t="This conversation lives on another device, so it cannot be searched here.",l3t="This conversation could not be searched.",c3t="Try again",u3t="Check again",O3t="Could not reach that message. It is further back than the loaded history — scroll up in the transcript to load more.",d3t="Updating — the list below is the previous search's.",f3t="Going to that message…";function h3t(e){return e===1?"(the first match shown)":`(first ${e} shown)`}function p3t(e){return e.state==="building"}async function m3t(e,t){if(e===null)return"not-mounted";const n=e.querySelector("[data-lo-transcript-content]")??e;return await XQe(n,e,t)==="landed"?"revealed":"not-mounted"}async function g3t(e){const t=e.query.trim().slice(0,ile);if(t.length===0)return{query:"",state:"ready",partial:!1,hits:[],truncated:!1};const n=Math.min(Math.max(e.limit??CRe,1),ARe);return Re({op:"sessions.find",sessionId:e.sessionId,q:t,limit:n})}const $3t=200,y3t=1500;function v3t({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),Q=$.useRef(new Set),b=$.useRef(e);b.current=e;const w=$.useCallback(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null)},[]),x=$.useCallback((C,W)=>{Q.current.has(C)||(Q.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]),T=$.useRef(()=>{}),_=$.useCallback((C,W)=>{const G=Ljt(W.state);a(G);const N=G==="ready"||G==="building",Z=N?W.hits:[];if(g.current=Z.length,s(Z),c(N&&W.truncated),O(G==="building"&&W.partial),f(Z.length>0?0:-1),G==="building"&&p3t(W)){if(v.current!==C){v.current=C;const F=p.current;S.current=setTimeout(()=>{S.current=null,p.current===F&&T.current(C,"follow-up")},y3t)}}else w()},[w]),E=$.useCallback((C,W)=>{const G=b.current;if(!G)return;const N=p.current,Z=++m.current;W==="fresh"&&(w(),v.current=null,a("loading")),g3t({sessionId:G,query:C}).then(F=>{Z!==m.current||p.current!==N||_(C,F)}).catch(F=>{Z!==m.current||p.current!==N||(x("thread search could not be answered:",F),w(),v.current=null,g.current=0,s([]),c(!1),O(!1),f(-1),a("error"))})},[_,w,x]);T.current=E,$.useEffect(()=>{const C=`${t?"1":"0"}:${e??""}`;if(y.current!==C&&(y.current=C,Q.current=new Set,k(),r(Z=>Z===""?Z:""),!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&&T.current(W,"fresh")},$3t);return()=>clearTimeout(N)},[n,t,e,k]),$.useEffect(()=>()=>w(),[w]);const R=$.useCallback(C=>{f(W=>Fjt(W,C,g.current))},[]),j=$.useCallback(()=>{const C=n.trim();!t||!e||C.length===0||T.current(C,"fresh")},[t,e,n]);return{query:n,setQuery:r,state:i,hits:o,truncated:l,partial:u,cursor:d,moveCursor:R,activeHit:Bjt(o,d),refresh:j}}const b3t=q("bg-accent-wash","before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent"),w3t="bg-accent-wash font-medium text-ink underline decoration-accent decoration-2 underline-offset-2",S3t=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0,x3t=({hit:e,active:t,optionId:n,onNavigate:r})=>{const i=Hjt(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?b3t:"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:Kjt[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:Jjt})]})]}),h.jsx("span",{className:"line-clamp-2 text-body-sm text-ink",children:i.map((a,o)=>a.matched?h.jsx("mark",{className:w3t,children:a.text},o):h.jsx("span",{children:a.text},o))})]})},Q3t=({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 Q=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(fv,{"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:Q,maxLength:ile,placeholder:sJ,"aria-label":sJ,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(Xe,{type:"button",variant:"ghost",size:"icon-sm","aria-label":t3t,onClick:u,children:h.jsx(ea,{"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?d3t:"Searching…"),n==="ready"&&(r.length>0?n3t(r):r3t),n==="building"&&(o?o3t:i3t),n==="unsupported"&&s3t,n==="error"&&l3t,n==="ready"&&a&&v&&h.jsxs("span",{className:"text-ink-dim",children:[" ",h3t(r.length)]}),n==="building"&&!o&&h.jsxs("span",{className:"text-ink-dim",children:[" ",a3t]})]}),S&&h.jsx(Xe,{type:"button",variant:"ghost",size:"sm",onClick:c,className:"shrink-0",children:n==="building"?u3t:c3t})]}),v&&h.jsx("ul",{id:p,role:"listbox","aria-label":e3t,"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(x3t,{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:f3t}),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(Ad,{shortcut:"↑"}),h.jsx(Ad,{shortcut:"↓"}),h.jsx("span",{children:"browse"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(Ad,{shortcut:"↵"}),h.jsx("span",{children:"jump"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(Ad,{shortcut:"esc"}),h.jsx("span",{children:"close"})]}),h.jsx("span",{className:"ml-auto text-ink-dim text-meta",children:Vjt(O)})]})]})},k3t=({sessionId:e,containerRef:t,onReveal:n})=>{const[r,i]=$.useState(!1),[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(null),c=v3t({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||!Mjt(p))return;const m=p.target;if(!(!(s.current!==null&&m!==null&&s.current.contains(m))&&(X$(p.target)||nOe(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 m3t(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(Q3t,{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:S3t(),jumping:a})}):null};function P3t(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 _3t(e,t){for(const[n,r]of e)t.set(n,{...r});e.clear()}function lJ(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 T3t(e,t,n,r,i){const a=e.length-1,o=new Set(i.filter(O=>O>=0&&O<a)),s=Math.max(0,lJ(e,t-r)-1),l=Math.min(a,lJ(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 R3t(e,t,n,r){return!e||!t||e.id!==t.id||n!==r?null:t.viewportOffset-e.viewportOffset}function X3t(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 E3t(e,t){return e==="inline"&&t}function YQe(e,t,n,r){const i=Math.max(24,Math.floor((r||810)/7.2)),a=t.split(`
|
|
@@ -972,4 +972,4 @@ ${m}`,te=j.current;j.current=M,!(te===null||te===M)&&(Oin(te.split(`
|
|
|
972
972
|
}`,A2e=()=>h.jsxs("div",{className:"flex h-6 items-center gap-0.5 [&>span]:animate-[waveform-bar_1.2s_infinite_ease-in-out]","aria-hidden":"true",children:[h.jsx("style",{children:ysn}),h.jsx("span",{className:"size-[3px] rounded-[1px] bg-accent"}),h.jsx("span",{className:"h-2 size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.2s"}}),h.jsx("span",{className:"size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.4s"}}),h.jsx("span",{className:"h-3 size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.6s"}}),h.jsx("span",{className:"size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.8s"}})]});A2e.displayName="WaveformAnimation";const vsn=120;function bsn({text:e,cwd:t,enabled:n=!1}){const r=$.useMemo(()=>n?Kin(e):[],[e,n]),i=$.useRef(new Map),a=$.useRef(t),[o,s]=$.useState(new Map),l=Ri(),c=oi(l.data,"projects",1),u=$.useRef(new Set),O=$.useMemo(()=>{const g=new Set;for(const y of r)if(y.path&&g.add(y.path),g.size>=rle)break;return[...g]},[r]),d=O.join(`
|
|
973
973
|
`),f=$.useMemo(()=>{const g=new Set;for(const y of O){const v=Sse(y);v&&g.add(v.toLowerCase())}return[...g]},[O]),p=()=>{const g=new Map(i.current);if(u.current.size===0)return g;for(const y of O){const v=Sse(y);v&&u.current.has(v.toLowerCase())&&g.set(y,{exists:!0,outside:!1})}return g};$.useEffect(()=>{const g=window.api;if(a.current!==t&&(a.current=t,i.current.clear(),s(p())),!n||O.length===0){s(b=>b.size>0?new Map:b);return}if(typeof g?.probeFiles!="function"&&f.length===0){s(b=>b.size>0?p():b);return}const y=O.filter(b=>!i.current.has(b)),v=c?f.filter(b=>!u.current.has(b)):[];if(y.length===0&&v.length===0){s(p());return}let S=!1;const Q=setTimeout(()=>{const b=y.length>0&&typeof g?.probeFiles=="function"?g.probeFiles(y,t).then(x=>{if(!S)for(const k of x)k.exists&&i.current.set(k.input,{exists:!0,outside:k.outsideWorkspace===!0})}).catch(()=>{}):Promise.resolve(),w=v.length>0?Re({op:"projects.list"}).then(x=>{if(!S)for(const k of x.projects){const T=k.name.toLowerCase();v.includes(T)&&u.current.add(T)}}).catch(()=>{}):Promise.resolve();Promise.allSettled([b,w]).then(()=>{S||s(p())})},vsn);return()=>{S=!0,clearTimeout(Q)}},[d,t,c]);const m=$.useMemo(()=>Din(r,o),[r,o]);return{spans:r,resolved:m}}const Use=""+new URL("brand-mark-Bv0Hu-Cz.png",import.meta.url).href,wsn={ink:"bg-ink","ink-muted":"bg-ink-muted"},Ssn={maskImage:`linear-gradient(#000, #000), url(${Use})`,WebkitMaskImage:`linear-gradient(#000, #000), url(${Use})`,maskSize:"100% 100%, auto 50%",WebkitMaskSize:"100% 100%, auto 50%",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",maskPosition:"center",WebkitMaskPosition:"center",maskComposite:"exclude",WebkitMaskComposite:"xor"},xsn=({className:e,tone:t="ink",label:n})=>h.jsx("span",{role:n?"img":void 0,"aria-label":n,"aria-hidden":n?void 0:!0,"data-brand-mark":"",className:q("inline-block shrink-0 rounded-full",wsn[t],e),style:Ssn}),Qsn=new Set(Oxe),zq=navigator.platform.toUpperCase().indexOf("MAC")>=0,Wse="composer-credential-notice",Nse="composer-secret-closure-notice",ksn="Answer the secret request in the asks panel — this box is paused until it is answered, and your draft is kept.",Yse="composer-secret-ask-notice",Psn="composer-secret-ask-refusal",_sn="composer-secret-confirm",Gse="composer-secret-confirm-message",Ise="composer-mention-outside-notice",Zse="composer-host-blocked-reason",Dse="composer-delivery-remedies-hint",Tsn={canUseRadientSpeech:!1,speechBlock:"could-not-check"},Rsn=1500;function z2e(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>r(new Error("credential store timed out")),t);e.then(a=>{clearTimeout(i),n(a)},a=>{clearTimeout(i),r(a)})})}const Xsn=fA("sessions.credential"),Mse=5e3;async function Vse(e,t,n){try{const r=await z2e(Re({op:"sessions.credential",sessionId:e,action:"store",key:t.key,value:t.value}),n);return r?.data?.ok===!1?{kind:"fate",fate:r.data.reason==="empty-key"?"rejected-key":"lost"}:{kind:"stored"}}catch(r){const i=r instanceof Ut?r.status:null;return i!==null&&i>=400&&i<500?{kind:"fate",fate:"lost"}:null}}async function Esn(e,t,n){try{const r=await z2e(Re({op:"sessions.credential",sessionId:e,action:"list"}),n),i=r?.data;return i?.ok===!1||!Array.isArray(i?.credentials)?null:kU(r).includes(t)}catch{return null}}async function qsn(e,t){const n=await Vse(e,t,Xsn);if(n?.kind==="stored")return n;const r=n===null;let i=n;if(i===null&&(i=await Vse(e,t,Mse)),i?.kind==="stored")return i;const a=await Esn(e,t.key,Mse);return a===!0?{kind:"stored"}:a===!1&&i!==null&&!r?i:null}const Lse=[],Fse=[],jsn=e=>new Promise(t=>{const n=new FileReader;n.onload=r=>t(typeof r.target?.result=="string"?r.target.result:null),n.onerror=()=>t(null),n.readAsDataURL(e)}),Csn=()=>document.querySelector('[aria-label="Answer options"] button:not([disabled])'),Asn=()=>document.querySelector(ROe),zsn='[aria-label="Remove reply"]';let OA=!1;const lfn=()=>yUe(Asn(),document.activeElement,OA),Usn=q("mx-auto flex w-full flex-col bg-elevated","box-border transition-colors duration-fast ease-out-quart"),Wsn=q("has-[textarea:focus-visible]:outline-solid has-[textarea:focus-visible]:outline-2","has-[textarea:focus-visible]:outline-accent has-[textarea:focus-visible]:outline-offset-2"),Nsn=$.forwardRef(({onSendMessage:e,isLoading:t,awaitingReply:n=!1,awaitingAnswer:r=!1,deliveryRemediesReachable:i=!1,deviceHold:a,hostNotice:o,secretAnswer:s=!1,secretAsk:l=null,asideSessionId:c,asideStreaming:u=!1,asideAdoptQueue:O=!1,conversationId:d,messages:f,currentJobId:p,onCancelJob:m,onComposerInput:g,isFarFromBottom:y=!1,hasNewActivity:v=!1,scrollToBottom:S=()=>{},canonicalStop:Q,canonicalStopAvailable:b=!1,interruptNotice:w,sendError:x,stopConfirmation:k,initialSuggestions:T,noProvider:_=!1,noModel:E=!1,agentData:R,cwd:j,cwdWritePath:C,cwdReadOnlyReason:W,cwdPending:G,cwdPendingAccepted:N,isSmallView:Z=!1,askExpanded:F,onAskToggle:z,askOutcomes:M,ownGutter:te=!1,isHydrating:U=!1,transcriptless:H=!1,autoFocus:D=!0,unavailable:V=!1,mentionsEnabled:se=!1,mentionsUnsupported:B=!1,sessionStatus:K,onSlashCommand:ne,onSlashNote:le,paneHasSession:Oe,runDetails:Qe,recordingProbe:we=Tsn,onCredentialsStored:He,onDictationStateChange:Ne,placeholderOverride:Ke},Fe)=>{br();const ze=j??(C?.kind==="move"?void 0:R?.current_working_directory),ye=Pr(I=>c?I.attached[c]??null:null),_e=$.useRef(null);$.useEffect(()=>{if(O||!u||_e.current===null)return;_e.current=null;const I=Pr.getState(),he=c??"";I.attached[he]?.notice===CI(zq)&&I.setAsideNotice(he,null)},[u,c,O]);const et=an(I=>I.removeReply),ae=an(I=>I.addAttachment),ue=an(I=>I.removeAttachment),be=an($.useCallback(I=>d?I.inputByConversation[d]?.replies??Lse:Lse,[d])),oe=an($.useCallback(I=>d?I.inputByConversation[d]?.attachments??Fse:Fse,[d])),pe=$.useRef(He);$.useEffect(()=>{pe.current=He});const[me,Se]=$.useState(!1),[Ve,gt]=$.useState(!1),[Rt,pt]=$.useState(null),[Ee,xt]=$.useState(!1),[en,Sn]=$.useState(!1);$.useEffect(()=>{if(!en)return;const I=window.setTimeout(()=>Sn(!1),5e3);return()=>window.clearTimeout(I)},[en]);const hr=$.useRef(null),Gr=$.useRef([]),[Ia,xa]=$.useState(""),Ii=$.useRef(0);$.useEffect(()=>{const I=x?.message;Ii.current=I?Date.now():0},[x?.message]);const{canUseRadientSpeech:Xs,speechBlock:At}=we,En=Xs,tr=ode("recording",At),pr=!H&&f.length===0&&!U,St=pr,nt=$.useMemo(()=>{const I=K?.frontend?.effective_model??K?.frontend?.selected_model??null;return I?{provider:I.provider,model_id:I.model_id}:null},[K]),mt=$.useRef(null),_t=$.useRef(null),De=$.useMemo(()=>!T||T.length===0?[]:St?(mt.current===null&&(mt.current=Rrn(T)),mt.current):[],[T,St]),[ut,Wt]=$.useState(null),[tn,gn]=$.useState(null),[zn,nr]=$.useState(null),[Zn,Za]=$.useState(eo),qn=$.useRef(eo),Ar=$.useCallback(I=>{qn.current=I,Za(I)},[]),or=$.useRef(new Map),qi=$.useRef(1),[pc,Qa]=$.useState(null),Zi=$.useRef(null),mr=$.useCallback(I=>{Zi.current=I,Qa(I)},[]),[mc,qe]=$.useState(null),ke=$.useRef(null),$n=$.useCallback(I=>{ke.current=I,qe(I)},[]),Hn=$.useCallback(I=>ZH(Zi.current,I)??0,[]),gr=$.useRef(null),Qt=$.useRef(null),Da=$.useRef(null),yt=$.useRef(null),Kn=$.useRef(null),xn=$.useRef(!1),[Es,fo]=$.useState(0),Fr=$.useRef([]),Ol=$.useRef(void 0),Ft=K&&!K.draft?d:void 0,na=$.useCallback(async(I,he=Ft)=>{const je=[...or.current.values()],Je=NH(I,je);if(Je.length===0&&hxe(I,je).length===0)return{text:I,stored:[],refused:[],unconfirmed:[]};const On=new Map,Mt=[],rr=await Promise.all(Je.map(async Di=>({payload:Di,attempt:he?await qsn(he,Di):{kind:"fate",fate:"unreachable"}})));for(const{payload:Di,attempt:mo}of rr){if(mo===null){On.set(Di.index,"unconfirmed");continue}if(mo.kind==="stored"){Mt.push(Di.key);continue}On.set(Di.index,mo.fate)}Mt.length>0&&he&&await pe.current?.(he);const Zr=Di=>[...On.entries()].filter(([,mo])=>Di(mo)).map(([mo])=>je.find(ml=>ml.index===mo)?.key??`#${mo}`);return{text:x2t(I,je,On),stored:Mt,refused:Zr(Di=>Di!=="unconfirmed"),unconfirmed:Zr(Di=>Di==="unconfirmed")}},[Ft]),qs=K?.draft===!0&&K?.draftResolved===!1,ho=$.useCallback(()=>{xn.current=!0,fo(I=>I+1),mr(null),Kn.current=null},[mr]),dl=$.useRef(!1),oh=$.useRef(!1),ig=$.useCallback(()=>oh.current?dl.current?"mixed":"dictated":"typed",[]),ag=$.useRef([]),{client:tb,provided:nb}=oo(),sh=$.useMemo(()=>async(I,he)=>{if(qs)return K?.onOpenDraftPicker?.("session.model"),!1;if(me||Ee)return!1;let je;const Je=Ft?await na(I):{text:I,stored:[],refused:[],unconfirmed:[]};Je.stored.length>0&&Of(YH(Je.stored)),Je.refused.length>0&&pg(GH(Je.refused)),Je.unconfirmed.length>0&&pg(IH(Je.unconfirmed));const On=ag.current,Mt=HN(I,On);let rr=null;if(Mt&&nb){const Cs=await von(tb,j??"",Mt.name);Cs!==null&&MXe(Cs)?rr=Cs:le?.(Cs!==null?`skill \`${Mt.name}\` has an empty body — sending your message as written`:`could not load skill \`${Mt.name}\` — sending your message as written`)}const Zr=Cs=>{if(Mt!==null&&rr!==null){const U_=HN(Cs,On),dRe=U_&&U_.name===Mt.name?U_.request:Mt.request;return r5(VXe({...Mt,request:dRe},rr),be)}return r5(Cs,be)},Di=Ft?void 0:async Cs=>(je=await na(I,Cs),Zr(je.text)),mo=Zr(Je.text),ml=await e(mo,oe.map(Cs=>Cs.path),he,I,Di,ig());return ml!==!1&&(dl.current=!1,oh.current=!1),ml!==!1&&je&&(je.stored.length>0&&Of(YH(je.stored)),je.refused.length>0&&pg(GH(je.refused)),je.unconfirmed.length>0&&pg(IH(je.unconfirmed))),ml===!1?ml:Wz(ml)?(ude(ml,ho),ml):(ho(),ml)},[e,oe,be,ho,na,Ft,qs,K?.onOpenDraftPicker,ig,me,Ee,tb,nb,j,le]),lh=ar(I=>JIe(I.drafts,d)),{inputValue:Te,setInputValue:sr,handleKeyDown:rb,handleSubmit:ch,textareaRef:It,sendInFlight:og,appendTranscriptText:ra}=_Ge({conversationId:d,onSubmit:sh,scrollToBottom:S,draftHeld:ql(Zn),transcriptless:H,draftUnredacted:Hn});$.useEffect(()=>{Te===""&&!og&&!lh&&(dl.current=!1,oh.current=!1)},[Te,og,lh]);const uh=ZH(pc,Te),[Br,ji]=$.useState(0),[Oh,ib]=$.useState(!1),Q_=kon(d),fl=Oe??!1,ot=Osn({inputValue:Te,selectionStart:Br,sessionId:Q_,paneHasSession:fl,activeProfile:{team:K?.frontend?.active_team,agent:K?.frontend?.active_agent},activeModel:Ax(K?.frontend?.effective_model??K?.frontend?.selected_model),activeSpec:K?.frontend?.effective_model??K?.frontend?.selected_model,cwd:j}),dh=St&&!(ot.open&&ot.phase==="argument"),Hr=yon({text:Te,caret:Br,cwd:j,attached:fl,commandNames:ot.commandNames,argumentWords:ot.argumentWords,enabled:!ql(Zn)});$.useEffect(()=>{ag.current=Hr.vocabulary.map(I=>I.name)},[Hr.vocabulary]);const ka=Tan({text:Te,caret:Br,cwd:j,enabled:se,unsupported:B}),Vo=bsn({text:Te,cwd:j,enabled:se}),ia=$.useMemo(()=>[...Vo.resolved.values()].filter(I=>I.outside).length,[Vo.resolved]),si=$.useRef(null),sg=$.useRef(null),ed=$.useRef(null);$.useLayoutEffect(()=>{d!==void 0&&ed.current!==d&&Te&&(ed.current=d,si.current=Te.length,ji(Te.length))},[Te,d]);const lg=$.useRef(Te);$.useLayoutEffect(()=>{lg.current=Te;const I=It.current,he=si.current;!I||he===null||(si.current=null,I.setSelectionRange(he,he))},[Te,It,mr]);const cg=$.useCallback(()=>[...Fr.current,...[...or.current.values()].map(I=>I.key)],[]),de=$.useCallback((I,he)=>{d&&(ql(I)||an.getState().setCurrentInput(d,he,Hn(he)))},[d,Hn]),ce=$.useCallback(I=>{const he=I.payload??null;he&&(or.current.set(he.index,he),qi.current=Math.max(qi.current,he.index+1)),I.buffer!==lg.current&&(si.current=I.caret,ji(I.caret)),gr.current=I.buffer,Da.current!==null&&!I.buffer.includes(Da.current.trim())&&(Da.current=null),Qt.current!==null&&!I.buffer.includes(Qt.current.text.trim())&&(Qt.current=null),Ar(I.capture),sr(I.buffer),de(I.capture,I.buffer)},[de,Ar,sr]);$.useLayoutEffect(()=>{gr.current!==Te&&(gr.current=Te,O2t(qn.current)&&(Ar(eo),mr(null)))},[Te,Ar,mr]),$.useEffect(()=>{qn.current=eo,Ar(eo),or.current.clear(),qi.current=1,xn.current=!1,Qt.current=null,Da.current=null,Kn.current=null,mr(null)},[d,Ar,mr]);const Ge=an(I=>d?I.getUnredactedChars(d):0),rt=an(I=>d?I.getCurrentInput(d):"");$.useEffect(()=>{Ge<=0||!rt||Te!==rt||Zi.current?.over!==rt&&mr({chars:Ge,over:rt})},[Ge,rt,Te,mr]),$.useLayoutEffect(()=>{const I=Zi.current;I&&I.over!==Te&&mr(null)},[Te,mr]),$.useLayoutEffect(()=>{const I=ke.current;I&&I.over!==Te&&$n(null)},[Te,$n]),$.useEffect(()=>{xn.current&&(NH(Te,or.current.values()).length>0||(or.current.clear(),qi.current=1,xn.current=!1))},[Te,Es]),$.useEffect(()=>{Zn.arm===null||!Ft||Ol.current!==Ft&&(Ol.current=Ft,Re({op:"sessions.credential",sessionId:Ft,action:"list"}).then(I=>{Fr.current=kU(I)}).catch(()=>{}))},[Zn.arm,Ft]);const ft=$.useCallback(()=>{const I=qn.current;if(!ql(I))return!1;const he=h2t({capture:I,buffer:Te,caret:It.current?.selectionEnd??Te.length,index:qi.current,taken:cg()});return he.minted?(ce(he),mr(null),!0):!1},[ce,Te,cg,mr]),kt=$.useCallback(I=>{const he=qn.current;if(!ql(he))return!1;const je=I.currentTarget,Je={start:je.selectionStart??Te.length,end:je.selectionEnd??Te.length};if(I.key==="Enter"&&!I.shiftKey&&!I.nativeEvent.isComposing)return ft();if(I.key==="Escape"){const Mt=p2t(he,Te);return Mt.cancelled?(Qt.current=Mt.token,mr(Mt.restored>0?{chars:Mt.restored,over:Mt.buffer}:null),ce(Mt),!0):!1}return I.key==="Enter"?(ce(UH(he,Te,Je,`
|
|
974
974
|
`)),!0):I.key==="Tab"?!0:Array.from(I.key).length===1&&!I.ctrlKey&&!I.metaKey&&!I.altKey&&!I.nativeEvent.isComposing?(ce(UH(he,Te,Je,I.key)),!0):!1},[Te,ce,ft,mr]),Dn=$.useCallback((I,he,je="typed")=>asn({gesture:je,draft:I,caret:he,commandNames:ot.commandNames,promptCommands:ot.promptCommands,armedOnlyCommands:ot.armedOnlyCommands,valueArgumentCommands:ot.valueArgumentCommands,argumentCommands:ot.argumentCommands,argumentShapes:ot.argumentShapes,prefixingCommands:ot.prefixingCommands,commandLockedWords:Qsn,unmaskedRunWord:Ir(I)?Qt.current?.text.trim().replace(/^\//,""):aa(I)?yt.current?.word:void 0,nameListCommands:ot.nameListCommands,enabled:ot.available&&!!ne}),[ot.commandNames,ot.promptCommands,ot.armedOnlyCommands,ot.valueArgumentCommands,ot.argumentCommands,ot.argumentShapes,ot.prefixingCommands,ot.nameListCommands,ot.available,ne]),vn=$.useCallback((I,he,je)=>{si.current=he,sr(I),ji(he),le?.(je)},[le,sr]),Sr=$.useCallback(I=>{const he=Qt.current;if(he!==null&&he.text.trim().length>0&&I.includes(he.text.trim()))return he.text.trim();const je=Da.current;return je!==null&&je.trim().length>0&&I.includes(je.trim())?je.trim():null},[]),sn=$.useCallback(I=>WH(I,Qt.current)?"send":Sr(I)===null?"typed":"pick",[Sr]),Ir=$.useCallback(I=>{const he=Qt.current;return he===null||he.restored===0?!1:zH(I,he.restoredText)},[]),aa=$.useCallback(I=>{const he=yt.current;return he!==null&&zH(I,he.run)},[]),Qn=$.useCallback(I=>{const he=Qt.current;return he!==null&&he.restored>0&&WH(I,he)},[]),li=$.useCallback((I,he)=>{const je=sn(I);if(je==="send"&&Qn(I))return{kind:"held",notice:"These characters are still the credentials you cancelled — clear the box to release your words and send your sentence."};if(je==="send")return{kind:"send"};const Je=je==="pick"?Dn(I,he,"pick"):Dn(I,he);if(je!=="pick"||Je.kind!=="send")return Je;const On=Sr(I);if(On===null)return Je;const Mt=I.indexOf(On);return Mt<0?Je:Dn(I,Mt+On.length,"pick")},[sn,Qn,Dn,Sr]),pn=$.useMemo(()=>{if(Oh)return[];const I=jan({draft:Te,commandNames:ot.commandNames,nameListCommands:ot.nameListCommands,nameChoices:ot.nameChoices,picking:ot.open&&ot.matches.length>0});if(I.length===0)return I;const he=Dn(Te,Br,"typed");return Can(I,Te,{sendsAsWritten:he.kind==="send"})},[Te,Br,Oh,Dn,ot.commandNames,ot.nameListCommands,ot.nameChoices,ot.open,ot.matches.length]),ju=$.useMemo(()=>Oh?[]:oon({draft:Te,vocabulary:Hr.vocabulary,settled:Hr.settled,picking:Hr.open}),[Te,Oh,Hr.vocabulary,Hr.settled,Hr.open]),ab=$.useMemo(()=>[...pn,...ju],[pn,ju]),Kr=b2e(ab),ug=$.useCallback(async(I,he,je)=>{const Je=ne;if(I.kind==="held"){const Mt=Qt.current;Mt!==null&&(_t.current?.token!==Mt||_t.current?.notice!==I.notice)&&(_t.current={token:Mt,notice:I.notice},le?.(I.notice));return}if(!Je)return;if(I.kind==="whole"||I.kind==="splice"){const Mt=ot.commands.find(Zr=>Zr.name===I.command.name||Zr.aliases.includes(I.command.name)),rr=on(I.command.args??"");if(Mt?.destination==="session.model"&&rr){const Zr=hke(ot.argumentList.rows,rr);if(Zr){SO.getState().openConnect({providerId:Zr});return}}}if(I.kind==="list-open"){if(ot.open&&ot.matches.length>0)return;le?.(`Type a name after /${I.command.name}, or choose one from the list.`);return}if(I.kind==="unrecognised"){await Je(I.command),si.current=je,sr(he),ji(je);return}if(I.kind==="reassemble"){vn(I.text,I.caret,Yon(I.text.trim(),fl));return}if(await Je(I.command)==="consumed"){const Mt=I.kind==="whole"?"":I.text,rr=I.kind==="whole"?0:I.caret;if(si.current=rr,sr(Mt),ji(rr),I.locked===!0){const Zr=wxe(he,qn.current),mo=!(I.kind==="whole"?Zr:Zr.slice(I.start,I.end)).includes(uxe);Kn.current=mo?{text:Zr,caret:je,plain:Kp(I.command.args).length}:null,le?.(Gon(I.command.name,{dialog:fl&&ot.commandNames.has(I.command.name),undo:mo},zq))}return}si.current=je,sr(he),ji(je)},[ne,le,sr,ot.commandNames,ot.open,ot.matches.length,ot.commands,ot.argumentList.rows,vn,fl]),W2e=!!(t&&p),k_=!!s,un=V||W2e||k_||!!o?.blocksInput,[ci,Cu]=$.useState(null),[mN,fh]=$.useState(null),[po,gN]=$.useState(!1),$N=$.useRef(null),ob=$.useRef(null),yN=$.useRef(Te);$.useEffect(()=>{yN.current=Te},[Te]),$.useEffect(()=>{Cu(null),fh(null)},[d]),$.useEffect(()=>{ci!==null&&$N.current?.focus()},[ci]),$.useEffect(()=>{if(!po)return;const I=document.activeElement;I!==null&&I!==document.body&&!ob.current?.contains(I)||ob.current?.focus()},[po]),$.useEffect(()=>{if(ci===null||l!==null&&l.key===ci.key)return;Cu(null),fh(l===null?J("ui.chat.composer.secret_fill_gone"):J("ui.chat.composer.secret_fill_changed"));const I=document.activeElement;I!==null&&I!==document.body&&I!==It.current&&!ob.current?.contains(I)||It.current?.focus()},[l,ci,It]),$.useEffect(()=>{fh(null)},[Te]),$.useEffect(()=>{ci!==null&&Te.trim()!==ci.value&&Cu(null)},[Te,ci]);const sb=$.useCallback(I=>!l||!hRt(I)?!1:(Cu({value:I.trim(),key:l.key}),!0),[l]),lb=$.useCallback(()=>{Cu(null),fh(null),It.current?.focus()},[It]),vN=$.useCallback(I=>{switch(I){case"locked":return J("ui.chat.composer.secret_fill_locked");case"stale":return J("ui.chat.composer.secret_fill_changed");case"multi":return J("ui.chat.composer.secret_fill_multi");case"refused":return J("ui.chat.composer.secret_fill_refused");case"unavailable":return J("ui.chat.composer.secret_fill_unavailable")}},[]),N2e=$.useCallback(async()=>{if(ci===null||l===null||po)return;if(!l.fillable){Cu(null),fh(J("ui.chat.composer.secret_fill_multi")),l.onOpen({focus:!1}),It.current?.focus();return}gN(!0);let I;try{I=await l.onFill(ci.value,ci.key)}catch{I="unavailable"}finally{gN(!1)}if(Cu(null),I==="sent"){yN.current.trim()===ci.value&&sr(""),It.current?.focus();return}fh(vN(I)),I!=="unavailable"&&l.onOpen({focus:!1}),It.current?.focus()},[l,ci,po,vN,sr,It]),Y2e=$.useCallback(()=>{Cu(null),ch(),It.current?.focus()},[ch,It]),Og=_||E,cb=$.useCallback(()=>{Sn(!0)},[]),P_=$.useCallback(async I=>{const he=Ax(I.model);if(!(un||!Ake(I)||I.id!=="model-default"||!he)){ot.close();try{await Cke(he,(je,Je)=>Re({op:"settings.edit",key:je,value:Je})),sr(""),le?.(`Default for new sessions: ${he.provider}/${he.model_id}`)}catch(je){le?.(`The default was not saved: ${je instanceof Error?je.message:"the backend refused it"}`)}}},[un,ot.close,sr,le]),__=$.useCallback(async(I,he)=>{if(I.kind==="action"){he.run&&await P_(I.row);return}if(un)return;const je=$sn(Te,Br,I,ot.commandNames,ot.argumentWords,ot.inline?.nameThenMessage??!1);if(!je)return;if(ot.close(),he.run&&I.kind==="argument"&&!fl&&ne){const rr=grn(ot.inline?.source);if(rr){const Zr=b$(Te,Br,ot.commandNames),Di=Zr?on(vO(Te,Zr.start,Zr.end,"").text):"";ar.getState().restageDraft({kind:rr,name:I.row.value},Di);return}}Kh.lastIndex=0;const Je=Kh.exec(je.text);if(Da.current=Je?Je[0].trim():null,I.kind==="command"&&he.run&&uA(I,ot.armedOnlyCommands)){const rr=osn({draft:je.text,caret:je.caret,commandNames:ot.commandNames,armedOnlyCommands:ot.armedOnlyCommands});if(rr.kind==="armed"){vn(rr.text,rr.caret,Non(rr.text.trim(),I.command.destination,e2e(I.command.destination)?fl:!0));return}}if(ce({capture:Jh(qn.current,je.text,je.caret,"completion"),buffer:je.text,caret:je.caret}),!(he.run&&(I.kind==="command"?T2e(I.command.destination,ot.effectiveEntry(I.command.destination)):ot.inline?.runs??!1)&&!!ne))return;const Mt=Dn(je.text,je.caret,"pick");Mt.kind!=="send"&&await ug(Mt,Te,Br)},[Te,Br,ot,ce,ne,Dn,ug,vn,fl,un,P_]),bN=$.useCallback(I=>{const he=Pon(Te,Br,I,ot.commandNames);he&&(si.current=he.caret,sr(he.text),ji(he.caret))},[Te,Br,ot.commandNames,sr]),wN=$.useCallback(I=>{if(un)return;const he=m2e(Te,Br);if(!he)return;const je=ean(I),Je=Te.slice(he.end,he.end+1),On=he.start>0&&(Je===" "||Je===`
|
|
975
|
-
`)?1:0,Mt=vO(Te,he.start,he.end+On,je),rr=je.endsWith('"')?Mt.caret-1:Mt.caret;si.current=rr,sr(Mt.text),ji(rr),ka.remember(I.path),ka.close()},[Te,Br,ka,sr,un]),T_=$.useCallback(I=>{if(un||!Hr.token)return;const he=eon(Te,Hr.token,I.name);Hr.close(),si.current=he.caret,sr(he.text),ji(he.caret)},[Te,Hr,sr,un]),G2e=$.useCallback(I=>{const he=Kn.current;return he===null||!(I.metaKey||I.ctrlKey)||I.altKey||I.shiftKey||I.key.toLowerCase()!=="z"?!1:(Kn.current=null,si.current=he.caret,he.plain>0&&mr({chars:he.plain,over:he.text}),sr(he.text),ji(he.caret),!0)},[mr,sr]),I2e=$.useCallback(I=>{if(un)return;if(kt(I)){I.preventDefault();return}if(I.key==="Escape"&&ci!==null){if(I.preventDefault(),po)return;lb();return}if(D2e(I)){I.preventDefault();return}if(G2e(I)){I.preventDefault();return}if(Ran(I,ka,wN)){I.preventDefault();return}if(gsn(I,ot,__,bN)){I.preventDefault();return}if(won(I,Hr,T_)){I.preventDefault();return}if(ye!==null&&I.key==="Escape"){I.preventDefault(),zj(c??"");return}if(ye!==null&&_Ie(I)){const Je=ye.turns.at(-1),On=Je?Pr.getState().streams[Je.asideId]:void 0;if(!Je||ye.queued!==void 0||!_de(On,u,O))return;I.preventDefault();const Mt=c??"",rr=Date.now(),Zr=RIe(_e.current,Je.asideId,rr);if(Zr==="arm"){_e.current={turnId:Je.asideId,at:rr},Pr.getState().setAsideNotice(Mt,CI(zq));return}if(Zr==="ignore")return;_e.current=null,kde(Mt).catch(()=>{});return}if(I.key==="Backspace"||I.key==="Delete"){const Je=Zin(Br,I.key==="Backspace"?"back":"forward",Vo.spans,Vo.resolved);if(Je&&!I.nativeEvent.isComposing){const On=vO(Te,Je.start,Je.end,"");si.current=On.caret,ji(On.caret),sr(On.text),I.preventDefault();return}}const he=It.current,je=Csn();if(je&&$Ue(I,{value:Te,selectionStart:he?.selectionStart??null,selectionEnd:he?.selectionEnd??null})){je.focus(),I.preventDefault();return}if(Og&&I.key==="Enter"&&!I.shiftKey&&!I.nativeEvent.isComposing){I.preventDefault(),cb();return}if(I.key==="Enter"&&!I.shiftKey&&!I.nativeEvent.isComposing){const Je=li(Te,Br);if(Je.kind!=="send"){I.preventDefault(),ug(Je,Te,Br);return}if(sb(Te)){I.preventDefault();return}}rb(I)},[ot,__,bN,Hr,T_,sb,rb,kt,ci,lb,li,ug,Te,Br,un,ye,c,u,O]),SN=$.useRef(null),hl=$.useCallback(I=>{OA=!1,It.current?.focus({preventScroll:I?.preventScroll===!0})},[It]),Z2e=$.useCallback(()=>{oOe(Te)!==null&&sr("")},[Te,sr]);$.useImperativeHandle(Fe,()=>({focusInput:hl,openWorkingDirectoryMenu:()=>{SN.current?.openMenu()},submitNow:()=>{sb(Te)||ch()},consumeApprovalAnswerDraft:Z2e}));const xN=$.useCallback(()=>It.current,[It]);$.useEffect(()=>YWe(hl,xN),[hl,xN]);const pl=$.useRef(null),QN=$.useRef(Te);$.useLayoutEffect(()=>{QN.current=Te},[Te]);const kN=$.useCallback(I=>{pl.current===I&&(pl.current=null,or.current.delete(I.index))},[]),ub=$.useCallback(I=>{if(pl.current!==I)return!1;const he=q2t({buffer:QN.current,cleared:I.cleared});return he?(or.current.set(I.index,I.payload),pl.current===I&&(pl.current=null),I.toastId!==null&&U0(I.toastId),ce({capture:Jh(qn.current,he.buffer,he.caret,"arrival"),buffer:he.buffer,caret:he.caret}),$n(null),!0):!1},[ce,$n]);$.useLayoutEffect(()=>{const I=pl.current;I!==null&&I.cleared.buffer!==Te&&(I.toastId!==null&&U0(I.toastId),kN(I))},[Te,kN]);const D2e=$.useCallback(I=>{const he=pl.current;return he===null||!(I.metaKey||I.ctrlKey)||I.altKey||I.shiftKey||I.key.toLowerCase()!=="z"?!1:(ub(he),!0)},[ub]),PN=$.useCallback(I=>{ub(I)&&hl()},[hl,ub]),M2e=$.useCallback(I=>{if(un)return;const he=or.current.get(I);if(!he)return;const je=E2t({buffer:Te,payload:he});if(!je.cleared)return;const Je=pl.current;Je&&(pl.current=null,or.current.delete(Je.index),Je.toastId!==null&&U0(Je.toastId));const On={index:I,payload:he,cleared:je,toastId:null};pl.current=On,ce({capture:Jh(qn.current,je.buffer,je.caret,"arrival"),buffer:je.buffer,caret:je.caret}),$n({key:he.key,index:I,over:je.buffer}),On.toastId=pg(R2t(I),{action:{label:T2t,onClick:()=>PN(On)}}),hl()},[ce,hl,un,Te,$n,PN]),V2e=Hnn(!!Q?.active),_N=b&&!Q?.active&&(V2e.held||me)&&!(t&&p),L2e=!!Q?.active||_N,F2e=un||me||Ee||Te.trim().length>0;$.useEffect(()=>{const I=It.current;I&&(I.style.height="auto",I.style.height=`${I.scrollHeight}px`)},[Te,It,me,Ee]);const TN=$.useRef(!1);$.useEffect(()=>{const I=me||Ee,he=TN.current&&!I;if(TN.current=I,!D&&!he||un||I)return;const je=document.activeElement;!(je&&(je.tagName==="INPUT"||je.tagName==="TEXTAREA"))&&!_&&It.current?.focus({preventScroll:!0})},[D,un,me,Ee,It,_]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(I=>{xa(I.platform)}).catch(I=>{console.error("Failed to get platform info:",I)})},[]);const js=$.useRef(null),B2e=250,RN=$.useRef(Ne);$.useEffect(()=>{RN.current=Ne}),$.useEffect(()=>(hse("message-input",me||Ve),()=>hse("message-input",!1)),[me,Ve]),$.useEffect(()=>{RN.current?.(me)},[me]);const Au=$.useCallback(I=>{gt(!1);const he=hr.current;if(!he)return;const je=js.current?.startedAt??null,Je=je===null?Number.POSITIVE_INFINITY:performance.now()-je;if(js.current=null,he.state==="inactive"){Se(!1);return}(I==="abort"||Je<B2e)&&(he.onstop=()=>{if(he.stream)for(const On of he.stream.getTracks())On.stop();pt(null),Gr.current=[]}),he.stop(),Se(!1)},[]);$.useEffect(()=>()=>{const I=js.current!==null;js.current=null;const he=hr.current;if(he&&he.state!=="inactive"){Au("abort");return}I&>(!1)},[Au]);const R_=$.useCallback((I="release")=>{const he=js.current;if(he){if(he.startedAt===null){js.current=null,gt(!1);return}Au(I)}},[Au]),XN=$.useCallback(async()=>{if(!(un||!En)&&!js.current)if(navigator?.mediaDevices?.getUserMedia){const I={startedAt:null};js.current=I,gt(!0);try{const he=await navigator.mediaDevices.getUserMedia({audio:!0});if(js.current!==I){for(const je of he.getTracks())je.stop();return}hr.current=new MediaRecorder(he),Gr.current=[],hr.current.ondataavailable=je=>{Gr.current.push(je.data)},hr.current.onstop=()=>{const je=new Blob(Gr.current,{type:"audio/webm"});pt(je);for(const Je of he.getTracks())Je.stop()},hr.current.start(),I.startedAt=performance.now(),gt(!1),Se(!0),pt(null)}catch(he){if(js.current!==I)return;js.current=null,gt(!1),console.error("Error accessing microphone:",he),mi("Error accessing microphone. Please ensure microphone permissions are granted.")}}else console.error("This runtime exposes no MediaRecorder"),mi("Dictation is not available on this device.")},[En,un]),X_=$.useCallback(()=>{me&&Au("release")},[me,Au]),E_=$.useCallback(()=>{me&&Au("abort")},[me,Au]);$.useEffect(()=>{if(!me&&!Ve)return;const I=he=>{if(me){he.key==="Enter"?(he.preventDefault(),X_()):he.key==="Escape"&&(he.preventDefault(),E_());return}he.key==="Escape"&&(he.preventDefault(),R_("abort"),gt(!1))};return window.addEventListener("keydown",I),()=>{window.removeEventListener("keydown",I)}},[me,Ve,X_,E_,R_]);const EN=$.useCallback(async()=>{if(Rt)try{xt(!0);const I=await Hue.createTranscription(Nf.baseUrl,{file:new File([Rt],"recording.webm",{type:"audio/webm"})});if(I.result?.text){const he=I.result?.text||"";oh.current=!0,ra(he)}else Tp(Y8e);pt(null)}catch(I){console.error("Error transcribing audio:",I),mi($8e(I))}finally{xt(!1)}},[Rt,ra]);$.useEffect(()=>{Rt&&EN()},[Rt,EN]);const qN=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const I=It.current;if(I===null)return;const he=new IntersectionObserver(je=>{const Je=je[je.length-1];Je!==void 0&&(qN.current=Je.isIntersecting)});return he.observe(I),()=>he.disconnect()},[It]),krn("message-input",t2e.MESSAGE_INPUT,{start:XN,stop:R_},()=>!!(!un&&!me&&!Ee&&En&&qN.current));const H2e=I=>{if(I.preventDefault(),un||_)return;if(E){cb();return}if(!Te.trim()&&oe.length===0||ft())return;const he=li(Te,Br);if(he.kind!=="send"){ug(he,Te,Br);return}sb(Te)||ch()},q_=$.useCallback(I=>{un&&I.preventDefault()},[un]),K2e=$.useCallback(I=>{!un&&!Og||(I.preventDefault(),Og&&!un&&cb())},[un,Og,cb]),J2e=I=>{d&&ue(d,I)},eRe=async()=>{const I=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!I.canceled&&I.filePaths.length>0&&d)for(const he of I.filePaths)ae(d,{id:fs(),path:q$(he)})},tRe=I=>{if(un)return;const he=I.clipboardData?.getData("text/plain")??"";if(he&&qn.current.arm!==null){const Je=I.currentTarget,On=g2t({capture:qn.current,buffer:Te,caret:Je.selectionEnd??Te.length,selection:{start:Je.selectionStart??Te.length,end:Je.selectionEnd??Te.length},pasted:he,index:qi.current,taken:cg()});if(On){I.preventDefault(),ce(On),mr(null);return}}he&&(yt.current=l2t(he));const je=I.clipboardData?.items;if(je){for(let Je=0;Je<je.length;Je++)if(je[Je].type.indexOf("image")!==-1||je[Je].kind==="file"){const On=je[Je].getAsFile();if(On){const Mt=new FileReader;Mt.onload=rr=>{rr.target?.result&&d&&ae(d,{id:fs(),path:rr.target.result})},Mt.readAsDataURL(On)}}}},nRe=I=>{un||I.dataTransfer?.types.includes("Files")&&(I.preventDefault(),I.stopPropagation(),I.dataTransfer.dropEffect="copy",j_(!0))},rRe=I=>{I.currentTarget.contains(I.relatedTarget)||j_(!1)},iRe=I=>{if(j_(!1),un)return;const he=I.dataTransfer?.files;!he||he.length===0||(I.preventDefault(),I.stopPropagation(),d&&aRe(d,Array.from(he)))},aRe=async(I,he)=>{for(const je of he){const Je=window.api?.getPathForFile?window.api.getPathForFile(je):"";if(Je){ae(I,{id:fs(),path:q$(Je)});continue}const On=await jsn(je);On&&ae(I,{id:fs(),path:On})}},[jN,j_]=$.useState(!1),oRe=I=>{un||(Te||g?.(),si.current=I.length,sr(I),ji(I.length),It.current?.focus())},C_=ql(Zn)?Zn.value!==""?W2t:Ft?N2t:Y2t:X2t({unredacted:uh!==null?G2t(uh,Qn(Te)?bxe:void 0):null,armed:Zn.arm!==null&&mxe(Te,Te.length)!==null,cleared:mc===null?null:{key:mc.key,index:mc.index},undoCap:q2e(Ia==="darwin")}),sRe=$.useMemo(()=>Ia==="darwin"?"Cmd+Shift+S":"Ctrl+Shift+S",[Ia]),A_=$.useRef(null),lRe=I=>{d&&(A_.current=be.findIndex(he=>he.id===I),et(d,I))};$.useEffect(()=>{const I=A_.current;if(I===null)return;A_.current=null;const he=document.querySelectorAll(zsn),je=he[Math.min(I,he.length-1)];je?je.focus():hl()},[be,hl]);const Lo=$.useMemo(()=>{const he=r5(Te,be)!==""||oe.length>0,je=_||x?.message&&Sfe.test(x.message)?[{label:"Connect a provider",onClick:()=>SO.getState().openConnect()}]:[];return{message:x?.message,muted:x?.muted===!0,polite:x?.polite===!0,actions:[...x?.actions??[],...je],retry:x?.retry===!0,clear:x?.muted!==!0&&(x?.onClear!==void 0||he)}},[x,Te,be,oe,_]),hh=u7t(),CN=q("block text-body-sm",Z?"px-2 pb-1":"px-4 pb-2",uh!==null?"text-warning":"text-ink-muted"),z_=q("flex flex-wrap items-center gap-2 text-body-sm text-ink-muted",Z?"px-2 pb-1":"px-4 pb-2"),AN=k_&&Te.length>0,cRe=h.jsx("output",{className:q(Rr,"block pb-2",hh.issue.kind==="hidden"&&"hidden"),children:h.jsx(Han,{issue:hh.issue,onSignIn:hh.start,onCancel:hh.cancel,onDismiss:hh.dismiss,isSmallView:Z,onFocusComposer:()=>It.current?.focus()})}),dg=t3e(K),uRe=dg&&!a3e(dg,r3e(hh.issue))?h.jsx("output",{className:q(Rr,"block pb-2"),children:h.jsx($rn,{access:dg,isSmallView:Z,onSwitchModel:K?.onCommand?()=>K.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>SO.getState().openConnect({providerId:dg.provider})})}):null,zN=Ve||!me&&!Ee&&!(t&&p),ORe=h.jsxs("form",{onSubmit:H2e,"data-chat-region":"composer","aria-label":tOe.composer,tabIndex:-1,className:"w-full",children:[h.jsx(VN,{fallback:null,children:h.jsx(Lnn,{frontend:K?.frontend,askFrontend:K?.asks,runDetails:Qe,isSmallView:Z,askExpanded:F,onAskToggle:z,askOutcomes:M,onNote:le,onFocusComposer:()=>It.current?.focus()},d)}),!i3e(dg)&&cRe,uRe,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Te.trim().length>0?h.jsx("p",{id:Zse,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,Lo.message!==void 0&&h.jsxs("div",{role:Lo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":x?.message===Ta.queuedSend?!0:void 0,className:q(Rr,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",Z?"px-2 pb-1":"px-4 pb-2"),children:[h.jsxs("p",{className:q("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",Lo.muted?"text-ink-muted":"text-danger"),children:[!Lo.muted&&h.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:h.jsx(kp,{size:14,"aria-hidden":"true"})}),h.jsx("span",{className:q("min-w-0 break-words",!Lo.muted&&"font-medium"),children:Lo.message})]}),(Lo.retry||Lo.clear||Lo.actions.length>0)&&h.jsxs(h.Fragment,{children:[Lo.actions.map(I=>h.jsx(Xe,{type:"button",variant:"link",size:"sm",className:q("min-h-6 cursor-pointer text-body-sm underline"),onClick:I.onClick,children:I.label},I.label)),Lo.retry&&x?.onRetry&&h.jsx(Xe,{type:"button",variant:"link",size:"sm",className:q("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>x.onRetry?.(),children:mCe}),Lo.clear&&x?.onClear&&h.jsx(Xe,{type:"button",variant:"link",size:"sm","aria-label":J("ui.chat.composer.clear_message"),className:q("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>x.onClear?.(),children:gCe})]})]}),w&&h.jsx("output",{className:q(Rr,"block text-body-sm text-ink-muted",Z?"px-2 pb-1":"px-4 pb-2"),children:w}),c&&ye!==null&&h.jsx(Rin,{sessionId:c,sessionStreaming:u,adoptQueueSupported:O,isSmallView:Z,onReturnFocus:()=>It.current?.focus()}),k?h.jsx("div",{className:q(Rr,Z?"px-2 pb-2":"px-4 pb-2"),children:k}):null,h.jsxs("div",{className:q(Rr,"relative w-full"),children:[h.jsx(fsn,{state:ot,onPick:__,onActionPick:P_}),h.jsx(Ean,{state:ka,onPick:wN}),h.jsx(bon,{state:Hr,onPick:T_}),!H&&!ot.open&&!ka.open&&!Hr.open&&h.jsx(C6t,{visible:y,onClick:S,hasNewActivity:v}),h.jsx("output",{id:Wse,className:q(Rr,C_?CN:"hidden"),children:C_}),AN&&h.jsx("output",{id:Nse,className:q(Rr,CN),children:ksn}),l&&ci===null&&h.jsxs("output",{id:Yse,className:q(z_,Rr),children:[h.jsx("span",{className:"min-w-0",children:J("ui.chat.composer.secret_ask_notice")}),h.jsx(Xe,{type:"button",size:"sm",variant:"secondary","data-lo-ask-item-toggle":"",onClick:()=>l.onOpen(),children:J("ui.chat.composer.secret_ask_open")})]}),mN!==null&&ci===null&&h.jsx("output",{id:Psn,className:q(z_,Rr),children:h.jsx("span",{className:"min-w-0",children:mN})}),ci!==null&&h.jsxs("fieldset",{ref:ob,tabIndex:-1,id:_sn,"aria-labelledby":Gse,"aria-busy":po,onKeyDown:I=>{I.key==="Escape"&&(I.preventDefault(),!po&&lb())},className:q("m-0 min-w-0 border-0 p-0",z_,Rr),children:[h.jsxs("span",{id:Gse,className:"min-w-0",children:[po?J("ui.chat.composer.secret_confirm_sending"):J("ui.chat.composer.secret_confirm_message"),h.jsx("span",{className:q("whitespace-nowrap",po&&"invisible"),"aria-hidden":po||void 0,children:` ${J("ui.chat.composer.secret_confirm_chars",{count:ci.value.length})}`})]}),h.jsx(Xe,{ref:$N,type:"button",size:"sm",disabled:po,onClick:N2e,children:l?.fillable?J("ui.chat.composer.secret_confirm_put"):J("ui.chat.composer.secret_confirm_put_multi")}),h.jsx(Xe,{type:"button",size:"sm",variant:"secondary",disabled:po,onClick:Y2e,children:J("ui.chat.composer.secret_confirm_send")}),h.jsx(Xe,{type:"button",size:"sm",variant:"ghost",disabled:po,onClick:lb,children:J("ui.chat.composer.secret_confirm_cancel")})]}),ia>0&&h.jsx("span",{id:Ise,className:"sr-only",children:ia===1?"1 reference points outside this session's working directory; the agent will ask you to approve it before reading.":`${ia} references point outside this session's working directory; the agent will ask you to approve them before reading.`}),i&&h.jsx("span",{id:Dse,className:"sr-only",children:J("ui.chat.composer.delivery_remedies_hint")}),h.jsxs("div",{"data-glass-region":"composer",className:q(Usn,jN?void 0:Wsn,Z?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",Rr,jN&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(be.length>0||oe.length>0)&&h.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[be.length>0&&h.jsx(qU,{replies:be,onRemoveReply:lRe}),oe.length>0&&h.jsx(kZe,{attachments:oe.map(I=>I.path),onRemoveAttachment:I=>J2e(oe[I].id),disabled:un||me||Ee})]}),h.jsxs("div",{className:"relative isolate w-full",children:[h.jsx(Irn,{text:Te,payloads:or.current,capture:Zn,fieldRef:It,mirrorRef:sg,isSmallView:Z}),h.jsx(san,{text:Te,spans:Vo.spans,resolved:Vo.resolved,fieldRef:It,isSmallView:Z}),h.jsx(Wan,{draft:Te,runs:ab,textareaRef:It,fieldClassName:GQ(Z),refused:un,children:h.jsx("textarea",{ref:It,"data-region-entry":!0,className:q(GQ(Z),"block",Z?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",Kr?"text-transparent caret-ink":"text-ink","outline-none placeholder:text-ink-dim",o?.blocksInput?"read-only:text-ink-muted read-only:placeholder:text-ink-muted disabled:text-ink-disabled disabled:placeholder:text-ink-disabled":"read-only:text-ink-disabled read-only:placeholder:text-ink-disabled disabled:text-ink-disabled disabled:placeholder:text-ink-disabled"),placeholder:me?Ys.recording:wGe({unavailable:V,secretAnswer:k_,inputDisabled:un,awaitingAnswer:r,asideAttached:ye!==null,sendingUnsettled:lh||og,awaitingReply:n,stopping:Q?.stopping===!0,noProvider:_,idle:Ke,hostLine:o?.placeholder??null}),value:Te,onCompositionStart:()=>ib(!0),onCompositionEnd:()=>ib(!1),onChange:I=>{dl.current=!0;const he=I.target.value,je=I.target.selectionStart??he.length;Kn.current=null;const Je=f2t(qn.current,Te,he,je,"typing");Je.buffer!==he?(si.current=Je.caret,ji(Je.caret)):ji(je),Je.capture!==qn.current&&Ar(Je.capture),!Te&&Je.buffer&&g?.(),gr.current=Je.buffer,de(Je.capture,Je.buffer),sr(Je.buffer),Date.now()-Ii.current>=Rsn&&x?.onDismiss?.()},onSelect:I=>{const he=I.target,je=si.current;if(je!==null){he.selectionStart===je&&(si.current=null);return}ji(he.selectionStart),Ar(Jh(qn.current,Te,he.selectionStart,"caret"))},onKeyDown:I2e,onPointerDown:()=>{OA=!0},onPaste:tRe,rows:1,readOnly:un,"aria-disabled":un||void 0,"aria-label":J("ui.chat.composer.message"),role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Te.trim().length>0?Zse:null,C_?Wse:null,AN?Nse:null,l&&ci===null?Yse:null,ia>0?Ise:null,V?eQe:null,i?Dse:null].filter(Boolean).join(" ")||void 0,"aria-expanded":ot.open||ka.open,"aria-controls":ot.open?ot.listId:ka.open?ka.listId:void 0,"aria-activedescendant":(ot.open?ot.activeDescendantId:ka.activeDescendantId)??void 0})}),h.jsx(Nrn,{small:Z,text:Te,payloads:or.current,capture:Zn,mirrorRef:sg,fieldRef:It,onClear:un?null:M2e,onControlUnmounted:hl})]}),me&&h.jsx(sfe,{isRecording:me}),Ee&&h.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[h.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:J("ui.chat.composer.processing_audio")}),h.jsx(A2e,{})]}),h.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[K&&h.jsx(VN,{fallback:null,children:h.jsx(dMe,{frontend:K.frontend,onCommand:K.onCommand,effortEntities:K.effortEntities,draft:K.draft,onOpenDraftPicker:K.onOpenDraftPicker,draftResolution:K.draftResolution,held:K.held,contextHeld:K.contextHeld,readingsDropped:K.readingsDropped,pendingModel:K.pendingModel,costChannels:K.costChannels,controlsThirdBox:L2e})}),h.jsxs("div",{className:"contents",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[h.jsx(Yt,{content:J("ui.chat.composer.attach_file"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"ghost",size:Z?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:q_,onClick:eRe,"aria-label":J("ui.chat.composer.attach_file"),"data-tour-tag":"chat-input-attach-file-button",disabled:un||me||Ee,children:h.jsx(m9e,{"aria-hidden":"true"})})})}),ze!==void 0&&h.jsx(Man,{ref:SN,currentWorkingDirectory:ze,writePath:C,pending:G,pendingAccepted:N,readOnlyReason:C?void 0:W??KTe})]}),h.jsxs("div",{className:"ml-auto flex order-3 items-center gap-1",children:[Ve&&zN&&h.jsx("output",{"data-preparing-indicator":"",className:"shrink-0 font-medium text-body-sm text-ink-muted",children:Z?J("ui.chat.composer.starting"):J("ui.chat.composer.starting_recording")}),zN&&h.jsx(Yt,{content:Ve?J("ui.chat.composer.starting_recording"):En?J("ui.chat.composer.start_recording_hint",{shortcut:sRe,pushToTalk:oA().label}):tr,children:h.jsx("span",{children:h.jsx(Xe,{variant:"ghost",size:Z?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:q_,onClick:XN,"aria-label":J("ui.chat.composer.start_recording"),"aria-busy":Ve||void 0,disabled:un||!En,children:Ve?h.jsx(Go,{size:"sm"}):h.jsx(r9e,{"aria-hidden":"true"})})})}),me&&h.jsxs(h.Fragment,{children:[h.jsx(Yt,{content:J("ui.chat.composer.confirm_recording_hint"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"ghost",size:Z?"icon-sm":"icon",className:"text-success hover:bg-success-wash hover:text-success",onClick:X_,"aria-label":J("ui.chat.composer.confirm_recording"),children:h.jsx(xu,{"aria-hidden":"true"})})})}),h.jsx(Yt,{content:J("ui.chat.composer.cancel_recording_hint"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"ghost",size:Z?"icon-sm":"icon",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:E_,"aria-label":J("ui.chat.composer.cancel_recording"),children:h.jsx(ea,{"aria-hidden":"true"})})})})]}),_N&&h.jsx("span",{"aria-hidden":"true","data-interrupt-slot":"",className:q("pointer-events-none invisible flex items-center"),children:h.jsx(Xe,{variant:"danger",size:Z?"icon-sm":"icon",type:"button",tabIndex:-1,children:h.jsx(m1,{"aria-hidden":"true"})})}),Q?.active&&h.jsx(Yt,{content:J("ui.chat.composer.stop_work_hint"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"danger",size:Z?"icon-sm":"icon",type:"button",onClick:Q.onStop,"aria-label":J("ui.chat.composer.stop"),"aria-keyshortcuts":"Escape","data-stopping":Q.stopping===!0?"true":void 0,"aria-busy":Q.stopping===!0?!0:void 0,className:q("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]"),children:h.jsx(m1,{"aria-hidden":"true"})})})}),t&&p?h.jsx(Yt,{content:J("ui.chat.composer.stop_agent"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"danger",size:Z?"icon-sm":"icon",type:"button",onClick:()=>m?.(p),"aria-label":J("ui.chat.composer.stop_agent"),children:h.jsx(m1,{"aria-hidden":"true"})})})}):!me&&!Ee&&h.jsx(Yt,{content:ye!==null&&!r?J("ui.chat.composer.ask_aside"):J("ui.chat.composer.send_message"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"primary",size:Z?"icon-sm":"icon",type:"submit",onPointerDown:K2e,disabled:un||Og||!Te.trim()&&oe.length===0,className:"rounded-full disabled:bg-surface","aria-label":ye!==null&&!r?J("ui.chat.composer.ask_aside"):J("ui.chat.composer.send_message"),children:h.jsx(Nue,{"aria-hidden":"true"})})})})]})]})]})]})]}),_&&!St?h.jsx("div",{className:q("mt-2",Rr),children:h.jsx(yin,{})}):null,(_||E)&&en?h.jsx("div",{className:q("mt-2",Rr),children:h.jsx("output",{className:"block text-body-sm text-ink-muted",children:E?"Choose a model for this conversation before sending.":"Connect a provider to send."})}):null]});return h.jsxs("div",{className:q(zde,"flex w-full flex-col items-center",pr?"grow":"shrink-0",te?void 0:iZe,Z?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:Wt,onDragOver:nRe,onDragLeave:rRe,onDrop:iRe,children:[h.jsx("div",{"data-lo-composer-splash":"",className:q("flex w-full flex-col items-center justify-center",pr?"grow":null),children:h.jsx("div",{ref:gn,className:q(dh?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:dh?h.jsxs(h.Fragment,{children:[h.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:h.jsx(xsn,{className:"size-8",tone:"ink-muted"})}),_?null:h.jsx("h2",{className:"text-center text-ink text-title",children:J("ui.chat.composer.welcome")}),_?h.jsx("div",{className:q("w-full",Rr),children:h.jsx($in,{})}):h.jsxs("div",{className:q("flex flex-col gap-3",Rr),children:[h.jsx(Lan,{band:ut,splash:tn,foot:zn,suggestions:De,disabled:F2e,onRefusedPress:q_,onSelect:oRe,focusComposer:()=>It.current?.focus()}),h.jsx(Urn,{suspended:Te.trim().length>0,mentionsEnabled:se})]})]}):null})}),St?h.jsx("div",{className:q("mb-2 mt-2",Rr),children:h.jsx(gin,{selection:nt})}):null,h.jsx("div",{ref:nr,"data-lo-composer-foot":"",className:"w-full",children:ORe})]})}),Ysn=$.memo(Nsn);Ysn.displayName="MessageInput";const U2e=1024,aS=1024*1024,pN=.85,Gsn=new Set(["image/png","image/jpeg","image/webp"]),Isn=[{maxEdge:U2e,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function Zsn(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function Dsn(e){const t=Uint8Array.fromBase64;if(typeof t=="function")return t.call(Uint8Array,e);const n=atob(e),r=new Uint8Array(n.length);for(let i=0;i<n.length;i+=1)r[i]=n.charCodeAt(i);return r}function Msn(e){const t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";const r=32768;for(let i=0;i<e.length;i+=r)n+=String.fromCharCode(...e.subarray(i,i+r));return btoa(n)}async function Vsn(e,t,n,r,i){const a=Math.max(e.width,e.height),o=a>r?r/a:1,s=Math.max(1,Math.round(e.width*o)),l=Math.max(1,Math.round(e.height*o)),c=new OffscreenCanvas(s,l),u=c.getContext("2d");if(!u)return null;u.drawImage(e,0,0,s,l);const O=[],d=await c.convertToBlob({type:"image/png"}),f=new Uint8Array(await d.arrayBuffer());if(f.byteLength<=aS&&O.push({bytes:f,mime_type:"image/png"}),f.byteLength>aS||i<pN){const g=new OffscreenCanvas(s,l),y=g.getContext("2d");if(!y)return null;y.fillStyle="#ffffff",y.fillRect(0,0,s,l),y.drawImage(e,0,0,s,l);const v=await g.convertToBlob({type:"image/jpeg",quality:i}),S=new Uint8Array(await v.arrayBuffer());O.push({bytes:S,mime_type:"image/jpeg"}),f.byteLength>aS&&S.byteLength>f.byteLength&&O.push({bytes:f,mime_type:"image/png"})}let p=null,m=Number.POSITIVE_INFINITY;for(const g of O)g.bytes.byteLength<m&&(p=g,m=g.bytes.byteLength);return p?m>=n?t:{data_b64:Msn(p.bytes),mime_type:p.mime_type}:null}async function Lsn(e){if(!Gsn.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([Dsn(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function Fsn(e,t,n,r){const i=Zsn(e.data_b64);try{return Math.max(t.width,t.height)<=n&&i<=aS&&r>=pN?e:await Vsn(t,e,i,n,r)??e}catch{return e}}async function Bsn(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>Lsn(i)));try{return await Hsn(e,r,t,n)}finally{for(const i of r)i?.close()}}async function Hsn(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,d)=>{const f=t[d];return f?Fsn(O,f,c,u):Promise.resolve(O)})),a=await i(U2e,pN);if(r(a)<=n)return a;let o=e,s=r(e);const l=c=>{const u=r(c);return u<s&&(o=c,s=u),u};l(a);for(const c of Isn){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const Ksn=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,Jsn=/^file:\/\//,eln={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"};async function cfn(e,t){const n=[],r=[];for(const a of e){const o=Ksn.exec(a);if(o){n.push({data_b64:o[3],mime_type:o[1]});continue}const s=a.split(".").pop()?.toLowerCase()??"",l=eln[s];if(!l||!window.api?.readFile)continue;const c=await window.api.readFile(a.replace(Jsn,""),"base64");c.success?n.push({data_b64:c.data,mime_type:l}):r.push(a)}const i=Math.max(0,n.length-Wq);return{images:await Bsn(n.slice(0,Wq),HQ,a=>Xj(t,a)),unreadable:r,overflow:i}}function ufn(e){if(e.length===0)return null;const t=e.map(Ck);return t.length===1?`${t[0]} could not be read (it may have been moved or deleted), so this message was not sent. Attach it again, or remove it from the draft.`:`${t.join(", ")} could not be read (they may have been moved or deleted), so this message was not sent. Attach them again, or remove them from the draft.`}function Ofn(e){if(e<=0)return null;const t=Wq,n=t+e;return e===1?`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove the extra image, or send it in a second message.`:`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove ${e} of them, or send them in a second message.`}function dfn(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function ffn(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function hfn(e,t){return e==="pause"?{text:"Aida is paused. She will not check in until you resume her.",kind:"success"}:e==="resume"?{text:"Aida is resumed. She will check in on her usual schedule.",kind:"success"}:{kind:"info",text:t.paused?"Aida is paused.":"Aida is active."}}function tln(e){return Io(e,"Aida's controls could not reach the backend.")}const pfn="The chief of staff is switched off on this install.",nln="aida_no_provider",rln="aida_disabled";function mfn(e,t){const n=e instanceof Ut?e.code:void 0;return n===rln?null:n===nln?{kind:"info",text:`${t} will say hello once an AI account is connected. Connect one from the chat to start.`}:{kind:"error",text:`${t}'s conversation could not be opened, so you are in a new chat instead. ${tln(e)}`}}function gfn(e,t){if(e.held===!0)return`${t} is already open in another window, so she will say hello there.`;const n=e.greeting_state==="delivered"||e.greeting_state==="skipped"||e.greeting_state==null&&e.greeted===!0;return e.paused&&!n?`${t} is paused, so she will say hello when you resume her: type /aida resume.`:null}function $fn(e){const t=e?.greeting_state;return t==null||t==="owed"}function iln(e){return e.eventKey===e.storeKey&&!e.focused}let Bse=!1;function yfn(){if(Bse)return;Bse=!0;const e=an.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{iln({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&an.persist?.rehydrate?.()?.catch?.(()=>{})};window.addEventListener("storage",t)}export{Fln as $,eGe as A,sGe as B,jt as C,Ua as D,lt as E,El as F,An as G,Df as H,P as I,Rn as J,Qr as K,Xn as L,wn as M,Mk as N,Ev as O,Yr as P,Cr as Q,Lr as R,bs as S,d8 as T,wa as U,Bn as V,L9 as W,cr as X,_s as Y,Ut as Z,pv as _,Ri as a,kW as a$,Io as a0,Sln as a1,Bln as a2,R$ as a3,mi as a4,dW as a5,QW as a6,Rc as a7,Nr as a8,pDe as a9,Ad as aA,Ysn as aB,gUe as aC,Ycn as aD,Aln as aE,Uln as aF,yfn as aG,gun as aH,pun as aI,zln as aJ,hj as aK,Of as aL,W9e as aM,uv as aN,Zln as aO,Ov as aP,GOn as aQ,Tl as aR,Mh as aS,$a as aT,jue as aU,mz as aV,yj as aW,ade as aX,Dln as aY,ro as aZ,ZNt as a_,j$ as aa,rdn as ab,idn as ac,xke as ad,V8e as ae,Az as af,qj as ag,hv as ah,Nf as ai,FYe as aj,pfn as ak,cfn as al,ufn as am,Uce as an,Ofn as ao,aun as ap,$ln as aq,ar,wln as as,Ta as at,wtt as au,zd as av,bCe as aw,$Ce as ax,an as ay,Pm as az,ecn as b,Rp as b$,t_e as b0,Bv as b1,i_e as b2,Kdn as b3,IGt as b4,Lre as b5,Vre as b6,w_e as b7,NW as b8,FP as b9,Sde as bA,Qun as bB,kun as bC,Bd as bD,fv as bE,ve as bF,YAe as bG,ri as bH,pg as bI,n8e as bJ,x5 as bK,ake as bL,wG as bM,xG as bN,kue as bO,acn as bP,yz as bQ,iun as bR,qm as bS,eUe as bT,d6e as bU,sG as bV,Yln as bW,Nln as bX,k6e as bY,icn as bZ,su as b_,XYt as ba,RYt as bb,sm as bc,TYt as bd,_Yt as be,iQ as bf,Kv as bg,UW as bh,AW as bi,Id as bj,rQ as bk,uGe as bl,zx as bm,Rr as bn,iZe as bo,zde as bp,m1 as bq,mln as br,_un as bs,Lln as bt,HGe as bu,L8e as bv,Pun as bw,Gz as bx,eun as by,nIe as bz,oi as c,ok as c$,zue as c0,Que as c1,dv as c2,pk as c3,Gue as c4,que as c5,Rue as c6,Mze as c7,Pue as c8,Zue as c9,BRt as cA,mZe as cB,Mz as cC,uQe as cD,zO as cE,_f as cF,rIe as cG,IAe as cH,AAe as cI,QKt as cJ,nd as cK,Hcn as cL,GYe as cM,Zc as cN,xKt as cO,d_ as cP,f_ as cQ,VLt as cR,u_ as cS,cde as cT,Cln as cU,vYe as cV,Lue as cW,sO as cX,dGe as cY,oke as cZ,LAt as c_,Iue as ca,Kj as cb,IO as cc,Eue as cd,Xue as ce,Xm as cf,Si as cg,tue as ch,m6e as ci,y6e as cj,S6e as ck,v6e as cl,b6e as cm,fj as cn,Q6e as co,uG as cp,x6e as cq,w6e as cr,vde as cs,yde as ct,BGe as cu,xln as cv,Tp as cw,Qln as cx,U0 as cy,oUe as cz,Re as d,NP as d$,kce as d0,Hje as d1,sk as d2,_ke as d3,GXt as d4,hk as d5,tdn as d6,X7t as d7,bke as d8,ndn as d9,K8e as dA,uun as dB,e6t as dC,kd as dD,e7t as dE,F9e as dF,Wln as dG,afn as dH,cGe as dI,pGe as dJ,ACt as dK,JAe as dL,sdn as dM,sf as dN,uPe as dO,Yx as dP,Jx as dQ,rie as dR,nYt as dS,qy as dT,F9t as dU,B9t as dV,L9t as dW,V9t as dX,M9t as dY,D9t as dZ,Z9t as d_,W6t as da,T7 as db,Xle as dc,RCe as dd,Son as de,ofn as df,Uc as dg,sfn as dh,Qon as di,Eke as dj,Uue as dk,QU as dl,frn as dm,AO as dn,sde as dp,Oun as dq,Mqt as dr,Bqt as ds,MOn as dt,BK as du,VK as dv,Fqt as dw,bJt as dx,Wi as dy,Sc as dz,Cz as e,Ls as e$,_9t as e0,P9t as e1,I9t as e2,G9t as e3,u8e as e4,Mn as e5,fk as e6,bdn as e7,Sdn as e8,$dn as e9,PYe as eA,mun as eB,k5 as eC,ZJe as eD,HJe as eE,aFe as eF,Y$ as eG,GJe as eH,Ape as eI,rYe as eJ,iYe as eK,GWe as eL,Sj as eM,gy as eN,_z as eO,Ucn as eP,udn as eQ,cdn as eR,RWe as eS,Xcn as eT,Tcn as eU,Rcn as eV,Acn as eW,zcn as eX,sWe as eY,vcn as eZ,$cn as e_,mdn as ea,rA as eb,ddn as ec,fdn as ed,hdn as ee,wdn as ef,xdn as eg,ydn as eh,Odn as ei,vdn as ej,gdn as ek,pdn as el,jln as em,WCe as en,UCe as eo,Fce as ep,Lce as eq,oun as er,sun as es,a8e as et,lun as eu,cun as ev,dun as ew,hun as ex,J8e as ey,lGe as ez,tPe as f,zun as f$,z0 as f0,wcn as f1,hcn as f2,wR as f3,Scn as f4,_7 as f5,U6t as f6,C6t as f7,ldn as f8,xcn as f9,Pcn as fA,QWe as fB,Ccn as fC,cWe as fD,_cn as fE,rAt as fF,xj as fG,mWe as fH,jce as fI,ou as fJ,Qdn as fK,UTe as fL,kdn as fM,LOn as fN,o6t as fO,Sun as fP,UAe as fQ,ROe as fR,LWe as fS,xsn as fT,D9e as fU,Tue as fV,MZe as fW,FZe as fX,Wun as fY,Nun as fZ,Aun as f_,mle as fa,SS as fb,wWe as fc,kcn as fd,I6t as fe,VAe as ff,dk as fg,wue as fh,JU as fi,NJ as fj,d0 as fk,mcn as fl,$Oe as fm,_9e as fn,jcn as fo,Ecn as fp,XAe as fq,pcn as fr,gOe as fs,bcn as ft,vR as fu,Wcn as fv,d9e as fw,UUe as fx,ycn as fy,qcn as fz,yr as g,Zl as g$,Uun as g0,Gun as g1,tDe as g2,lfe as g3,Dun as g4,Tze as g5,iDe as g6,Yun as g7,uDe as g8,Mun as g9,Lpe as gA,iOn as gB,CCe as gC,QA as gD,Tz as gE,AOe as gF,oNe as gG,Dv as gH,sQe as gI,oQe as gJ,co as gK,_n as gL,ZO as gM,Pt as gN,Ie as gO,ht as gP,yOn as gQ,Ti as gR,UM as gS,Nm as gT,Ro as gU,Yc as gV,dme as gW,cn as gX,Nn as gY,gf as gZ,ms as g_,Iun as ga,LZe as gb,Gn as gc,Zun as gd,Sue as ge,nUe as gf,B8e as gg,rcn as gh,ncn as gi,tcn as gj,Icn as gk,Qj as gl,eAt as gm,lln as gn,UCt as go,Z9 as gp,aOn as gq,eOn as gr,htt as gs,Jun as gt,G9 as gu,Hpe as gv,Y9 as gw,Kpe as gx,Fpe as gy,Vpe as gz,yte as h,Nue as h$,uOn as h0,Mv as h1,NU as h2,GU as h3,Cx as h4,WU as h5,YU as h6,IU as h7,Jze as h8,fs as h9,POn as hA,TOn as hB,XOn as hC,qOn as hD,mOn as hE,gOn as hF,hOn as hG,Nk as hH,_On as hI,Dk as hJ,pOn as hK,YSe as hL,wU as hM,hse as hN,Hue as hO,oI as hP,Y8e as hQ,$8e as hR,krn as hS,t2e as hT,kZe as hU,sfe as hV,A2e as hW,m9e as hX,ode as hY,oA as hZ,r9e as h_,jge as ha,eat as hb,XO as hc,Jit as hd,Fn as he,Gt as hf,Zf as hg,Ki as hh,Er as hi,zi as hj,tu as hk,rw as hl,KS as hm,Ik as hn,$On as ho,Tu as hp,EOn as hq,QOn as hr,_ot as hs,vOn as ht,bOn as hu,fOn as hv,kOn as hw,OOn as hx,dOn as hy,xOn as hz,Fdn as i,_ln as i$,q$ as i0,NOn as i1,p8e as i2,m8e as i3,qxe as i4,Exe as i5,tOn as i6,NS as i7,Sk as i8,Cfe as i9,rBe as iA,Gze as iB,Wue as iC,Ck as iD,Mpe as iE,ptt as iF,btt as iG,gle as iH,uk as iI,fXe as iJ,VY as iK,kXe as iL,TCe as iM,qYe as iN,Ez as iO,DAe as iP,Vcn as iQ,qqt as iR,wde as iS,ZNe as iT,Lcn as iU,Dce as iV,qln as iW,Pln as iX,kln as iY,BY as iZ,sUe as i_,K5 as ia,UBe as ib,zBe as ic,jfe as id,Vun as ie,che as ig,Sa as ih,YO as ii,wv as ij,Fun as ik,RMe as il,KBe as im,det as io,qS as ip,p9 as iq,s9 as ir,Lj as is,lhe as it,GMe as iu,QMe as iv,WMe as iw,bD as ix,bBe as iy,uFe as iz,ul as j,Tln as j$,scn as j0,Pze as j1,ocn as j2,lcn as j3,pUe as j4,Cjt as j5,Lz as j6,$v as j7,xU as j8,zU as j9,yk as jA,Zcn as jB,iNe as jC,Dcn as jD,Gcn as jE,JZe as jF,ifn as jG,Cun as jH,rZe as jI,nI as jJ,nde as jK,ple as jL,hle as jM,mYe as jN,Jcn as jO,G3t as jP,IQe as jQ,Knn as jR,KTe as jS,Jdn as jT,rg as jU,dfn as jV,hfn as jW,tln as jX,ffn as jY,uln as jZ,Oln as j_,Ejt as ja,Ajt as jb,nOn as jc,YXt as jd,rOn as je,_ue as jf,Man as jg,Ncn as jh,X$ as ji,azt as jj,Dke as jk,j5 as jl,_m as jm,ja as jn,TGe as jo,fun as jp,hGe as jq,KOn as jr,JOn as js,edn as jt,Yue as ju,Kln as jv,iUe as jw,Pr as jx,qun as jy,cln as jz,Ddn as k,h9e as k$,W7e as k0,Rln as k1,Eln as k2,Xln as k3,e2e as k4,JQ as k5,Tun as k6,Eun as k7,Run as k8,Xun as k9,pln as kA,fln as kB,nfn as kC,Mcn as kD,CUe as kE,aCe as kF,AUe as kG,zUe as kH,fcn as kI,dcn as kJ,ANe as kK,CNe as kL,VOe as kM,Ocn as kN,Yce as kO,oOe as kP,ccn as kQ,Gce as kR,fCe as kS,MY as kT,ucn as kU,gln as kV,rfn as kW,DWe as kX,DOn as kY,tfn as kZ,tS as k_,run as ka,Wke as kb,Eqt as kc,cv as kd,vCe as ke,Jue as kf,Jln as kg,nz as kh,vUe as ki,hln as kj,eZe as kk,tZe as kl,jun as km,gcn as kn,Qcn as ko,iAt as kp,efn as kq,dln as kr,Ice as ks,lfn as kt,ZOn as ku,xCe as kv,ck as kw,vln as kx,bln as ky,i4e as kz,Mdn as l,Fi as l$,SO as l0,Bcn as l1,eYe as l2,yln as l3,Fcn as l4,VYe as l5,u7t as l6,pke as l7,Ydn as l8,FOn as l9,EP as lA,Adn as lB,Cdn as lC,qdn as lD,$z as lE,a2e as lF,jke as lG,Ej as lH,$fn as lI,gfn as lJ,mfn as lK,H7t as lL,kke as lM,Qke as lN,eIe as lO,SJ as lP,adn as lQ,odn as lR,xun as lS,_Ye as lT,TYe as lU,Kcn as lV,tun as lW,RGe as lX,nun as lY,Mln as lZ,$Ae as l_,HOn as la,yke as lb,yu as lc,BOn as ld,oGe as le,mke as lf,Xdn as lg,Gdn as lh,Idn as li,Edn as lj,Zdn as lk,mk as ll,c7t as lm,TXe as ln,Zrn as lo,zdn as lp,Udn as lq,g7t as lr,Tdn as ls,pAt as lt,_dn as lu,Rdn as lv,dAt as lw,jdn as lx,Ndn as ly,Wdn as lz,Ldn as m,IOn as m0,Pdn as m1,VOn as m2,s6e as m3,W7t as m4,vun as m5,$un as m6,yun as m7,bg as m8,bun as m9,Iln as ma,Hln as mb,g1 as mc,wun as md,Vln as me,Kun as mf,YOn as mg,Hdn as n,Vdn as o,em as p,Bdn as q,Kd as r,Nx as s,WP as t,cc as u,nQ as v,OW as w,Ry as x,oPe as y,Y9t as z};
|
|
975
|
+
`)?1:0,Mt=vO(Te,he.start,he.end+On,je),rr=je.endsWith('"')?Mt.caret-1:Mt.caret;si.current=rr,sr(Mt.text),ji(rr),ka.remember(I.path),ka.close()},[Te,Br,ka,sr,un]),T_=$.useCallback(I=>{if(un||!Hr.token)return;const he=eon(Te,Hr.token,I.name);Hr.close(),si.current=he.caret,sr(he.text),ji(he.caret)},[Te,Hr,sr,un]),G2e=$.useCallback(I=>{const he=Kn.current;return he===null||!(I.metaKey||I.ctrlKey)||I.altKey||I.shiftKey||I.key.toLowerCase()!=="z"?!1:(Kn.current=null,si.current=he.caret,he.plain>0&&mr({chars:he.plain,over:he.text}),sr(he.text),ji(he.caret),!0)},[mr,sr]),I2e=$.useCallback(I=>{if(un)return;if(kt(I)){I.preventDefault();return}if(I.key==="Escape"&&ci!==null){if(I.preventDefault(),po)return;lb();return}if(D2e(I)){I.preventDefault();return}if(G2e(I)){I.preventDefault();return}if(Ran(I,ka,wN)){I.preventDefault();return}if(gsn(I,ot,__,bN)){I.preventDefault();return}if(won(I,Hr,T_)){I.preventDefault();return}if(ye!==null&&I.key==="Escape"){I.preventDefault(),zj(c??"");return}if(ye!==null&&_Ie(I)){const Je=ye.turns.at(-1),On=Je?Pr.getState().streams[Je.asideId]:void 0;if(!Je||ye.queued!==void 0||!_de(On,u,O))return;I.preventDefault();const Mt=c??"",rr=Date.now(),Zr=RIe(_e.current,Je.asideId,rr);if(Zr==="arm"){_e.current={turnId:Je.asideId,at:rr},Pr.getState().setAsideNotice(Mt,CI(zq));return}if(Zr==="ignore")return;_e.current=null,kde(Mt).catch(()=>{});return}if(I.key==="Backspace"||I.key==="Delete"){const Je=Zin(Br,I.key==="Backspace"?"back":"forward",Vo.spans,Vo.resolved);if(Je&&!I.nativeEvent.isComposing){const On=vO(Te,Je.start,Je.end,"");si.current=On.caret,ji(On.caret),sr(On.text),I.preventDefault();return}}const he=It.current,je=Csn();if(je&&$Ue(I,{value:Te,selectionStart:he?.selectionStart??null,selectionEnd:he?.selectionEnd??null})){je.focus(),I.preventDefault();return}if(Og&&I.key==="Enter"&&!I.shiftKey&&!I.nativeEvent.isComposing){I.preventDefault(),cb();return}if(I.key==="Enter"&&!I.shiftKey&&!I.nativeEvent.isComposing){const Je=li(Te,Br);if(Je.kind!=="send"){I.preventDefault(),ug(Je,Te,Br);return}if(sb(Te)){I.preventDefault();return}}rb(I)},[ot,__,bN,Hr,T_,sb,rb,kt,ci,lb,li,ug,Te,Br,un,ye,c,u,O]),SN=$.useRef(null),hl=$.useCallback(I=>{OA=!1,It.current?.focus({preventScroll:I?.preventScroll===!0})},[It]),Z2e=$.useCallback(()=>{oOe(Te)!==null&&sr("")},[Te,sr]);$.useImperativeHandle(Fe,()=>({focusInput:hl,openWorkingDirectoryMenu:()=>{SN.current?.openMenu()},submitNow:()=>{sb(Te)||ch()},consumeApprovalAnswerDraft:Z2e}));const xN=$.useCallback(()=>It.current,[It]);$.useEffect(()=>YWe(hl,xN),[hl,xN]);const pl=$.useRef(null),QN=$.useRef(Te);$.useLayoutEffect(()=>{QN.current=Te},[Te]);const kN=$.useCallback(I=>{pl.current===I&&(pl.current=null,or.current.delete(I.index))},[]),ub=$.useCallback(I=>{if(pl.current!==I)return!1;const he=q2t({buffer:QN.current,cleared:I.cleared});return he?(or.current.set(I.index,I.payload),pl.current===I&&(pl.current=null),I.toastId!==null&&U0(I.toastId),ce({capture:Jh(qn.current,he.buffer,he.caret,"arrival"),buffer:he.buffer,caret:he.caret}),$n(null),!0):!1},[ce,$n]);$.useLayoutEffect(()=>{const I=pl.current;I!==null&&I.cleared.buffer!==Te&&(I.toastId!==null&&U0(I.toastId),kN(I))},[Te,kN]);const D2e=$.useCallback(I=>{const he=pl.current;return he===null||!(I.metaKey||I.ctrlKey)||I.altKey||I.shiftKey||I.key.toLowerCase()!=="z"?!1:(ub(he),!0)},[ub]),PN=$.useCallback(I=>{ub(I)&&hl()},[hl,ub]),M2e=$.useCallback(I=>{if(un)return;const he=or.current.get(I);if(!he)return;const je=E2t({buffer:Te,payload:he});if(!je.cleared)return;const Je=pl.current;Je&&(pl.current=null,or.current.delete(Je.index),Je.toastId!==null&&U0(Je.toastId));const On={index:I,payload:he,cleared:je,toastId:null};pl.current=On,ce({capture:Jh(qn.current,je.buffer,je.caret,"arrival"),buffer:je.buffer,caret:je.caret}),$n({key:he.key,index:I,over:je.buffer}),On.toastId=pg(R2t(I),{action:{label:T2t,onClick:()=>PN(On)}}),hl()},[ce,hl,un,Te,$n,PN]),V2e=Hnn(!!Q?.active),_N=b&&!Q?.active&&(V2e.held||me)&&!(t&&p),L2e=!!Q?.active||_N,F2e=un||me||Ee||Te.trim().length>0;$.useEffect(()=>{const I=It.current;I&&(I.style.height="auto",I.style.height=`${I.scrollHeight}px`)},[Te,It,me,Ee]);const TN=$.useRef(!1);$.useEffect(()=>{const I=me||Ee,he=TN.current&&!I;if(TN.current=I,!D&&!he||un||I)return;const je=document.activeElement;!(je&&(je.tagName==="INPUT"||je.tagName==="TEXTAREA"))&&!_&&It.current?.focus({preventScroll:!0})},[D,un,me,Ee,It,_]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(I=>{xa(I.platform)}).catch(I=>{console.error("Failed to get platform info:",I)})},[]);const js=$.useRef(null),B2e=250,RN=$.useRef(Ne);$.useEffect(()=>{RN.current=Ne}),$.useEffect(()=>(hse("message-input",me||Ve),()=>hse("message-input",!1)),[me,Ve]),$.useEffect(()=>{RN.current?.(me)},[me]);const Au=$.useCallback(I=>{gt(!1);const he=hr.current;if(!he)return;const je=js.current?.startedAt??null,Je=je===null?Number.POSITIVE_INFINITY:performance.now()-je;if(js.current=null,he.state==="inactive"){Se(!1);return}(I==="abort"||Je<B2e)&&(he.onstop=()=>{if(he.stream)for(const On of he.stream.getTracks())On.stop();pt(null),Gr.current=[]}),he.stop(),Se(!1)},[]);$.useEffect(()=>()=>{const I=js.current!==null;js.current=null;const he=hr.current;if(he&&he.state!=="inactive"){Au("abort");return}I&>(!1)},[Au]);const R_=$.useCallback((I="release")=>{const he=js.current;if(he){if(he.startedAt===null){js.current=null,gt(!1);return}Au(I)}},[Au]),XN=$.useCallback(async()=>{if(!(un||!En)&&!js.current)if(navigator?.mediaDevices?.getUserMedia){const I={startedAt:null};js.current=I,gt(!0);try{const he=await navigator.mediaDevices.getUserMedia({audio:!0});if(js.current!==I){for(const je of he.getTracks())je.stop();return}hr.current=new MediaRecorder(he),Gr.current=[],hr.current.ondataavailable=je=>{Gr.current.push(je.data)},hr.current.onstop=()=>{const je=new Blob(Gr.current,{type:"audio/webm"});pt(je);for(const Je of he.getTracks())Je.stop()},hr.current.start(),I.startedAt=performance.now(),gt(!1),Se(!0),pt(null)}catch(he){if(js.current!==I)return;js.current=null,gt(!1),console.error("Error accessing microphone:",he),mi("Error accessing microphone. Please ensure microphone permissions are granted.")}}else console.error("This runtime exposes no MediaRecorder"),mi("Dictation is not available on this device.")},[En,un]),X_=$.useCallback(()=>{me&&Au("release")},[me,Au]),E_=$.useCallback(()=>{me&&Au("abort")},[me,Au]);$.useEffect(()=>{if(!me&&!Ve)return;const I=he=>{if(me){he.key==="Enter"?(he.preventDefault(),X_()):he.key==="Escape"&&(he.preventDefault(),E_());return}he.key==="Escape"&&(he.preventDefault(),R_("abort"),gt(!1))};return window.addEventListener("keydown",I),()=>{window.removeEventListener("keydown",I)}},[me,Ve,X_,E_,R_]);const EN=$.useCallback(async()=>{if(Rt)try{xt(!0);const I=await Hue.createTranscription(Nf.baseUrl,{file:new File([Rt],"recording.webm",{type:"audio/webm"})});if(I.result?.text){const he=I.result?.text||"";oh.current=!0,ra(he)}else Tp(Y8e);pt(null)}catch(I){console.error("Error transcribing audio:",I),mi($8e(I))}finally{xt(!1)}},[Rt,ra]);$.useEffect(()=>{Rt&&EN()},[Rt,EN]);const qN=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const I=It.current;if(I===null)return;const he=new IntersectionObserver(je=>{const Je=je[je.length-1];Je!==void 0&&(qN.current=Je.isIntersecting)});return he.observe(I),()=>he.disconnect()},[It]),krn("message-input",t2e.MESSAGE_INPUT,{start:XN,stop:R_},()=>!!(!un&&!me&&!Ee&&En&&qN.current));const H2e=I=>{if(I.preventDefault(),un||_)return;if(E){cb();return}if(!Te.trim()&&oe.length===0||ft())return;const he=li(Te,Br);if(he.kind!=="send"){ug(he,Te,Br);return}sb(Te)||ch()},q_=$.useCallback(I=>{un&&I.preventDefault()},[un]),K2e=$.useCallback(I=>{!un&&!Og||(I.preventDefault(),Og&&!un&&cb())},[un,Og,cb]),J2e=I=>{d&&ue(d,I)},eRe=async()=>{const I=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!I.canceled&&I.filePaths.length>0&&d)for(const he of I.filePaths)ae(d,{id:fs(),path:q$(he)})},tRe=I=>{if(un)return;const he=I.clipboardData?.getData("text/plain")??"";if(he&&qn.current.arm!==null){const Je=I.currentTarget,On=g2t({capture:qn.current,buffer:Te,caret:Je.selectionEnd??Te.length,selection:{start:Je.selectionStart??Te.length,end:Je.selectionEnd??Te.length},pasted:he,index:qi.current,taken:cg()});if(On){I.preventDefault(),ce(On),mr(null);return}}he&&(yt.current=l2t(he));const je=I.clipboardData?.items;if(je){for(let Je=0;Je<je.length;Je++)if(je[Je].type.indexOf("image")!==-1||je[Je].kind==="file"){const On=je[Je].getAsFile();if(On){const Mt=new FileReader;Mt.onload=rr=>{rr.target?.result&&d&&ae(d,{id:fs(),path:rr.target.result})},Mt.readAsDataURL(On)}}}},nRe=I=>{un||I.dataTransfer?.types.includes("Files")&&(I.preventDefault(),I.stopPropagation(),I.dataTransfer.dropEffect="copy",j_(!0))},rRe=I=>{I.currentTarget.contains(I.relatedTarget)||j_(!1)},iRe=I=>{if(j_(!1),un)return;const he=I.dataTransfer?.files;!he||he.length===0||(I.preventDefault(),I.stopPropagation(),d&&aRe(d,Array.from(he)))},aRe=async(I,he)=>{for(const je of he){const Je=window.api?.getPathForFile?window.api.getPathForFile(je):"";if(Je){ae(I,{id:fs(),path:q$(Je)});continue}const On=await jsn(je);On&&ae(I,{id:fs(),path:On})}},[jN,j_]=$.useState(!1),oRe=I=>{un||(Te||g?.(),si.current=I.length,sr(I),ji(I.length),It.current?.focus())},C_=ql(Zn)?Zn.value!==""?W2t:Ft?N2t:Y2t:X2t({unredacted:uh!==null?G2t(uh,Qn(Te)?bxe:void 0):null,armed:Zn.arm!==null&&mxe(Te,Te.length)!==null,cleared:mc===null?null:{key:mc.key,index:mc.index},undoCap:q2e(Ia==="darwin")}),sRe=$.useMemo(()=>Ia==="darwin"?"Cmd+Shift+S":"Ctrl+Shift+S",[Ia]),A_=$.useRef(null),lRe=I=>{d&&(A_.current=be.findIndex(he=>he.id===I),et(d,I))};$.useEffect(()=>{const I=A_.current;if(I===null)return;A_.current=null;const he=document.querySelectorAll(zsn),je=he[Math.min(I,he.length-1)];je?je.focus():hl()},[be,hl]);const Lo=$.useMemo(()=>{const he=r5(Te,be)!==""||oe.length>0,je=_||x?.message&&Sfe.test(x.message)?[{label:"Connect a provider",onClick:()=>SO.getState().openConnect()}]:[];return{message:x?.message,muted:x?.muted===!0,polite:x?.polite===!0,actions:[...x?.actions??[],...je],retry:x?.retry===!0,clear:x?.muted!==!0&&(x?.onClear!==void 0||he)}},[x,Te,be,oe,_]),hh=u7t(),CN=q("block text-body-sm",Z?"px-2 pb-1":"px-4 pb-2",uh!==null?"text-warning":"text-ink-muted"),z_=q("flex flex-wrap items-center gap-2 text-body-sm text-ink-muted",Z?"px-2 pb-1":"px-4 pb-2"),AN=k_&&Te.length>0,cRe=h.jsx("output",{className:q(Rr,"block pb-2",hh.issue.kind==="hidden"&&"hidden"),children:h.jsx(Han,{issue:hh.issue,onSignIn:hh.start,onCancel:hh.cancel,onDismiss:hh.dismiss,isSmallView:Z,onFocusComposer:()=>It.current?.focus()})}),dg=t3e(K),uRe=dg&&!a3e(dg,r3e(hh.issue))?h.jsx("output",{className:q(Rr,"block pb-2"),children:h.jsx($rn,{access:dg,isSmallView:Z,onSwitchModel:K?.onCommand?()=>K.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>SO.getState().openConnect({providerId:dg.provider})})}):null,zN=Ve||!me&&!Ee&&!(t&&p),ORe=h.jsxs("form",{onSubmit:H2e,"data-chat-region":"composer","aria-label":tOe.composer,tabIndex:-1,className:"w-full",children:[h.jsx(VN,{fallback:null,children:h.jsx(Lnn,{frontend:K?.frontend,askFrontend:K?.asks,runDetails:Qe,isSmallView:Z,askExpanded:F,onAskToggle:z,askOutcomes:M,onNote:le,onFocusComposer:()=>It.current?.focus()},d)}),!i3e(dg)&&cRe,uRe,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Te.trim().length>0?h.jsx("p",{id:Zse,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,Lo.message!==void 0&&h.jsxs("div",{role:Lo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":x?.message===Ta.queuedSend?!0:void 0,className:q(Rr,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",Z?"px-2 pb-1":"px-4 pb-2"),children:[h.jsxs("p",{className:q("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",Lo.muted?"text-ink-muted":"text-danger"),children:[!Lo.muted&&h.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:h.jsx(kp,{size:14,"aria-hidden":"true"})}),h.jsx("span",{className:q("min-w-0 break-words",!Lo.muted&&"font-medium"),children:Lo.message})]}),(Lo.retry||Lo.clear||Lo.actions.length>0)&&h.jsxs(h.Fragment,{children:[Lo.actions.map(I=>h.jsx(Xe,{type:"button",variant:"link",size:"sm",className:q("min-h-6 cursor-pointer text-body-sm underline"),onClick:I.onClick,children:I.label},I.label)),Lo.retry&&x?.onRetry&&h.jsx(Xe,{type:"button",variant:"link",size:"sm",className:q("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>x.onRetry?.(),children:mCe}),Lo.clear&&x?.onClear&&h.jsx(Xe,{type:"button",variant:"link",size:"sm","aria-label":J("ui.chat.composer.clear_message"),className:q("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>x.onClear?.(),children:gCe})]})]}),w&&h.jsx("output",{className:q(Rr,"block text-body-sm text-ink-muted",Z?"px-2 pb-1":"px-4 pb-2"),children:w}),c&&ye!==null&&h.jsx(Rin,{sessionId:c,sessionStreaming:u,adoptQueueSupported:O,isSmallView:Z,onReturnFocus:()=>It.current?.focus()}),k?h.jsx("div",{className:q(Rr,Z?"px-2 pb-2":"px-4 pb-2"),children:k}):null,h.jsxs("div",{className:q(Rr,"relative w-full"),children:[h.jsx(fsn,{state:ot,onPick:__,onActionPick:P_}),h.jsx(Ean,{state:ka,onPick:wN}),h.jsx(bon,{state:Hr,onPick:T_}),!H&&!ot.open&&!ka.open&&!Hr.open&&h.jsx(C6t,{visible:y,onClick:S,hasNewActivity:v}),h.jsx("output",{id:Wse,className:q(Rr,C_?CN:"hidden"),children:C_}),AN&&h.jsx("output",{id:Nse,className:q(Rr,CN),children:ksn}),l&&ci===null&&h.jsxs("output",{id:Yse,className:q(z_,Rr),children:[h.jsx("span",{className:"min-w-0",children:J("ui.chat.composer.secret_ask_notice")}),h.jsx(Xe,{type:"button",size:"sm",variant:"secondary","data-lo-ask-item-toggle":"",onClick:()=>l.onOpen(),children:J("ui.chat.composer.secret_ask_open")})]}),mN!==null&&ci===null&&h.jsx("output",{id:Psn,className:q(z_,Rr),children:h.jsx("span",{className:"min-w-0",children:mN})}),ci!==null&&h.jsxs("fieldset",{ref:ob,tabIndex:-1,id:_sn,"aria-labelledby":Gse,"aria-busy":po,onKeyDown:I=>{I.key==="Escape"&&(I.preventDefault(),!po&&lb())},className:q("m-0 min-w-0 border-0 p-0",z_,Rr),children:[h.jsxs("span",{id:Gse,className:"min-w-0",children:[po?J("ui.chat.composer.secret_confirm_sending"):J("ui.chat.composer.secret_confirm_message"),h.jsx("span",{className:q("whitespace-nowrap",po&&"invisible"),"aria-hidden":po||void 0,children:` ${J("ui.chat.composer.secret_confirm_chars",{count:ci.value.length})}`})]}),h.jsx(Xe,{ref:$N,type:"button",size:"sm",disabled:po,onClick:N2e,children:l?.fillable?J("ui.chat.composer.secret_confirm_put"):J("ui.chat.composer.secret_confirm_put_multi")}),h.jsx(Xe,{type:"button",size:"sm",variant:"secondary",disabled:po,onClick:Y2e,children:J("ui.chat.composer.secret_confirm_send")}),h.jsx(Xe,{type:"button",size:"sm",variant:"ghost",disabled:po,onClick:lb,children:J("ui.chat.composer.secret_confirm_cancel")})]}),ia>0&&h.jsx("span",{id:Ise,className:"sr-only",children:ia===1?"1 reference points outside this session's working directory; the agent will ask you to approve it before reading.":`${ia} references point outside this session's working directory; the agent will ask you to approve them before reading.`}),i&&h.jsx("span",{id:Dse,className:"sr-only",children:J("ui.chat.composer.delivery_remedies_hint")}),h.jsxs("div",{"data-glass-region":"composer",className:q(Usn,jN?void 0:Wsn,Z?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",Rr,jN&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(be.length>0||oe.length>0)&&h.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[be.length>0&&h.jsx(qU,{replies:be,onRemoveReply:lRe}),oe.length>0&&h.jsx(kZe,{attachments:oe.map(I=>I.path),onRemoveAttachment:I=>J2e(oe[I].id),disabled:un||me||Ee})]}),h.jsxs("div",{className:"relative isolate w-full",children:[h.jsx(Irn,{text:Te,payloads:or.current,capture:Zn,fieldRef:It,mirrorRef:sg,isSmallView:Z}),h.jsx(san,{text:Te,spans:Vo.spans,resolved:Vo.resolved,fieldRef:It,isSmallView:Z}),h.jsx(Wan,{draft:Te,runs:ab,textareaRef:It,fieldClassName:GQ(Z),refused:un,children:h.jsx("textarea",{ref:It,"data-region-entry":!0,className:q(GQ(Z),"block",Z?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",Kr?"text-transparent caret-ink":"text-ink","outline-none placeholder:text-ink-dim",o?.blocksInput?"read-only:text-ink-muted read-only:placeholder:text-ink-muted disabled:text-ink-disabled disabled:placeholder:text-ink-disabled":"read-only:text-ink-disabled read-only:placeholder:text-ink-disabled disabled:text-ink-disabled disabled:placeholder:text-ink-disabled"),placeholder:me?Ys.recording:wGe({unavailable:V,secretAnswer:k_,inputDisabled:un,awaitingAnswer:r,asideAttached:ye!==null,sendingUnsettled:lh||og,awaitingReply:n,stopping:Q?.stopping===!0,noProvider:_,idle:Ke,hostLine:o?.placeholder??null}),value:Te,onCompositionStart:()=>ib(!0),onCompositionEnd:()=>ib(!1),onChange:I=>{dl.current=!0;const he=I.target.value,je=I.target.selectionStart??he.length;Kn.current=null;const Je=f2t(qn.current,Te,he,je,"typing");Je.buffer!==he?(si.current=Je.caret,ji(Je.caret)):ji(je),Je.capture!==qn.current&&Ar(Je.capture),!Te&&Je.buffer&&g?.(),gr.current=Je.buffer,de(Je.capture,Je.buffer),sr(Je.buffer),Date.now()-Ii.current>=Rsn&&x?.onDismiss?.()},onSelect:I=>{const he=I.target,je=si.current;if(je!==null){he.selectionStart===je&&(si.current=null);return}ji(he.selectionStart),Ar(Jh(qn.current,Te,he.selectionStart,"caret"))},onKeyDown:I2e,onPointerDown:()=>{OA=!0},onPaste:tRe,rows:1,readOnly:un,"aria-disabled":un||void 0,"aria-label":J("ui.chat.composer.message"),role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Te.trim().length>0?Zse:null,C_?Wse:null,AN?Nse:null,l&&ci===null?Yse:null,ia>0?Ise:null,V?eQe:null,i?Dse:null].filter(Boolean).join(" ")||void 0,"aria-expanded":ot.open||ka.open,"aria-controls":ot.open?ot.listId:ka.open?ka.listId:void 0,"aria-activedescendant":(ot.open?ot.activeDescendantId:ka.activeDescendantId)??void 0})}),h.jsx(Nrn,{small:Z,text:Te,payloads:or.current,capture:Zn,mirrorRef:sg,fieldRef:It,onClear:un?null:M2e,onControlUnmounted:hl})]}),me&&h.jsx(sfe,{isRecording:me}),Ee&&h.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[h.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:J("ui.chat.composer.processing_audio")}),h.jsx(A2e,{})]}),h.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[K&&h.jsx(VN,{fallback:null,children:h.jsx(dMe,{frontend:K.frontend,onCommand:K.onCommand,effortEntities:K.effortEntities,draft:K.draft,onOpenDraftPicker:K.onOpenDraftPicker,draftResolution:K.draftResolution,held:K.held,contextHeld:K.contextHeld,readingsDropped:K.readingsDropped,pendingModel:K.pendingModel,costChannels:K.costChannels,controlsThirdBox:L2e})}),h.jsxs("div",{className:"contents",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[h.jsx(Yt,{content:J("ui.chat.composer.attach_file"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"ghost",size:Z?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:q_,onClick:eRe,"aria-label":J("ui.chat.composer.attach_file"),"data-tour-tag":"chat-input-attach-file-button",disabled:un||me||Ee,children:h.jsx(m9e,{"aria-hidden":"true"})})})}),ze!==void 0&&h.jsx(Man,{ref:SN,currentWorkingDirectory:ze,writePath:C,pending:G,pendingAccepted:N,readOnlyReason:C?void 0:W??KTe})]}),h.jsxs("div",{className:"ml-auto flex order-3 items-center gap-1",children:[Ve&&zN&&h.jsx("output",{"data-preparing-indicator":"",className:"shrink-0 font-medium text-body-sm text-ink-muted",children:Z?J("ui.chat.composer.starting"):J("ui.chat.composer.starting_recording")}),zN&&h.jsx(Yt,{content:Ve?J("ui.chat.composer.starting_recording"):En?J("ui.chat.composer.start_recording_hint",{shortcut:sRe,pushToTalk:oA().label}):tr,children:h.jsx("span",{children:h.jsx(Xe,{variant:"ghost",size:Z?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:q_,onClick:XN,"aria-label":J("ui.chat.composer.start_recording"),"aria-busy":Ve||void 0,disabled:un||!En,children:Ve?h.jsx(Go,{size:"sm"}):h.jsx(r9e,{"aria-hidden":"true"})})})}),me&&h.jsxs(h.Fragment,{children:[h.jsx(Yt,{content:J("ui.chat.composer.confirm_recording_hint"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"ghost",size:Z?"icon-sm":"icon",className:"text-success hover:bg-success-wash hover:text-success",onClick:X_,"aria-label":J("ui.chat.composer.confirm_recording"),children:h.jsx(xu,{"aria-hidden":"true"})})})}),h.jsx(Yt,{content:J("ui.chat.composer.cancel_recording_hint"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"ghost",size:Z?"icon-sm":"icon",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:E_,"aria-label":J("ui.chat.composer.cancel_recording"),children:h.jsx(ea,{"aria-hidden":"true"})})})})]}),_N&&h.jsx("span",{"aria-hidden":"true","data-interrupt-slot":"",className:q("pointer-events-none invisible flex items-center"),children:h.jsx(Xe,{variant:"danger",size:Z?"icon-sm":"icon",type:"button",tabIndex:-1,children:h.jsx(m1,{"aria-hidden":"true"})})}),Q?.active&&h.jsx(Yt,{content:J("ui.chat.composer.stop_work_hint"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"danger",size:Z?"icon-sm":"icon",type:"button",onClick:Q.onStop,"aria-label":J("ui.chat.composer.stop"),"aria-keyshortcuts":"Escape","data-stopping":Q.stopping===!0?"true":void 0,"aria-busy":Q.stopping===!0?!0:void 0,className:q("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]"),children:h.jsx(m1,{"aria-hidden":"true"})})})}),t&&p?h.jsx(Yt,{content:J("ui.chat.composer.stop_agent"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"danger",size:Z?"icon-sm":"icon",type:"button",onClick:()=>m?.(p),"aria-label":J("ui.chat.composer.stop_agent"),children:h.jsx(m1,{"aria-hidden":"true"})})})}):!me&&!Ee&&h.jsx(Yt,{content:ye!==null&&!r?J("ui.chat.composer.ask_aside"):J("ui.chat.composer.send_message"),children:h.jsx("span",{children:h.jsx(Xe,{variant:"primary",size:Z?"icon-sm":"icon",type:"submit",onPointerDown:K2e,disabled:un||Og||!Te.trim()&&oe.length===0,className:"rounded-full disabled:bg-surface","aria-label":ye!==null&&!r?J("ui.chat.composer.ask_aside"):J("ui.chat.composer.send_message"),children:h.jsx(Nue,{"aria-hidden":"true"})})})})]})]})]})]})]}),_&&!St?h.jsx("div",{className:q("mt-2",Rr),children:h.jsx(yin,{})}):null,(_||E)&&en?h.jsx("div",{className:q("mt-2",Rr),children:h.jsx("output",{className:"block text-body-sm text-ink-muted",children:E?"Choose a model for this conversation before sending.":"Connect a provider to send."})}):null]});return h.jsxs("div",{className:q(zde,"flex w-full flex-col items-center",pr?"grow":"shrink-0",te?void 0:iZe,Z?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:Wt,onDragOver:nRe,onDragLeave:rRe,onDrop:iRe,children:[h.jsx("div",{"data-lo-composer-splash":"",className:q("flex w-full flex-col items-center justify-center",pr?"grow":null),children:h.jsx("div",{ref:gn,className:q(dh?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:dh?h.jsxs(h.Fragment,{children:[h.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:h.jsx(xsn,{className:"size-8",tone:"ink-muted"})}),_?null:h.jsx("h2",{className:"text-center text-ink text-title",children:J("ui.chat.composer.welcome")}),_?h.jsx("div",{className:q("w-full",Rr),children:h.jsx($in,{})}):h.jsxs("div",{className:q("flex flex-col gap-3",Rr),children:[h.jsx(Lan,{band:ut,splash:tn,foot:zn,suggestions:De,disabled:F2e,onRefusedPress:q_,onSelect:oRe,focusComposer:()=>It.current?.focus()}),h.jsx(Urn,{suspended:Te.trim().length>0,mentionsEnabled:se})]})]}):null})}),St?h.jsx("div",{className:q("mb-2 mt-2",Rr),children:h.jsx(gin,{selection:nt})}):null,h.jsx("div",{ref:nr,"data-lo-composer-foot":"",className:"w-full",children:ORe})]})}),Ysn=$.memo(Nsn);Ysn.displayName="MessageInput";const U2e=1024,aS=1024*1024,pN=.85,Gsn=new Set(["image/png","image/jpeg","image/webp"]),Isn=[{maxEdge:U2e,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function Zsn(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function Dsn(e){const t=Uint8Array.fromBase64;if(typeof t=="function")return t.call(Uint8Array,e);const n=atob(e),r=new Uint8Array(n.length);for(let i=0;i<n.length;i+=1)r[i]=n.charCodeAt(i);return r}function Msn(e){const t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";const r=32768;for(let i=0;i<e.length;i+=r)n+=String.fromCharCode(...e.subarray(i,i+r));return btoa(n)}async function Vsn(e,t,n,r,i){const a=Math.max(e.width,e.height),o=a>r?r/a:1,s=Math.max(1,Math.round(e.width*o)),l=Math.max(1,Math.round(e.height*o)),c=new OffscreenCanvas(s,l),u=c.getContext("2d");if(!u)return null;u.drawImage(e,0,0,s,l);const O=[],d=await c.convertToBlob({type:"image/png"}),f=new Uint8Array(await d.arrayBuffer());if(f.byteLength<=aS&&O.push({bytes:f,mime_type:"image/png"}),f.byteLength>aS||i<pN){const g=new OffscreenCanvas(s,l),y=g.getContext("2d");if(!y)return null;y.fillStyle="#ffffff",y.fillRect(0,0,s,l),y.drawImage(e,0,0,s,l);const v=await g.convertToBlob({type:"image/jpeg",quality:i}),S=new Uint8Array(await v.arrayBuffer());O.push({bytes:S,mime_type:"image/jpeg"}),f.byteLength>aS&&S.byteLength>f.byteLength&&O.push({bytes:f,mime_type:"image/png"})}let p=null,m=Number.POSITIVE_INFINITY;for(const g of O)g.bytes.byteLength<m&&(p=g,m=g.bytes.byteLength);return p?m>=n?t:{data_b64:Msn(p.bytes),mime_type:p.mime_type}:null}async function Lsn(e){if(!Gsn.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([Dsn(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function Fsn(e,t,n,r){const i=Zsn(e.data_b64);try{return Math.max(t.width,t.height)<=n&&i<=aS&&r>=pN?e:await Vsn(t,e,i,n,r)??e}catch{return e}}async function Bsn(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>Lsn(i)));try{return await Hsn(e,r,t,n)}finally{for(const i of r)i?.close()}}async function Hsn(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,d)=>{const f=t[d];return f?Fsn(O,f,c,u):Promise.resolve(O)})),a=await i(U2e,pN);if(r(a)<=n)return a;let o=e,s=r(e);const l=c=>{const u=r(c);return u<s&&(o=c,s=u),u};l(a);for(const c of Isn){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const Ksn=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,Jsn=/^file:\/\//,eln={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"};async function cfn(e,t){const n=[],r=[];for(const a of e){const o=Ksn.exec(a);if(o){n.push({data_b64:o[3],mime_type:o[1]});continue}const s=a.split(".").pop()?.toLowerCase()??"",l=eln[s];if(!l||!window.api?.readFile)continue;const c=await window.api.readFile(a.replace(Jsn,""),"base64");c.success?n.push({data_b64:c.data,mime_type:l}):r.push(a)}const i=Math.max(0,n.length-Wq);return{images:await Bsn(n.slice(0,Wq),HQ,a=>Xj(t,a)),unreadable:r,overflow:i}}function ufn(e){if(e.length===0)return null;const t=e.map(Ck);return t.length===1?`${t[0]} could not be read (it may have been moved or deleted), so this message was not sent. Attach it again, or remove it from the draft.`:`${t.join(", ")} could not be read (they may have been moved or deleted), so this message was not sent. Attach them again, or remove them from the draft.`}function Ofn(e){if(e<=0)return null;const t=Wq,n=t+e;return e===1?`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove the extra image, or send it in a second message.`:`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove ${e} of them, or send them in a second message.`}function dfn(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function ffn(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function hfn(e,t){return e==="pause"?{text:"Aida is paused. She will not check in until you resume her.",kind:"success"}:e==="resume"?{text:"Aida is resumed. She will check in on her usual schedule.",kind:"success"}:{kind:"info",text:t.paused?"Aida is paused.":"Aida is active."}}function tln(e){return Io(e,"Aida's controls could not reach the backend.")}const pfn="The chief of staff is switched off on this install.",nln="aida_no_provider",rln="aida_disabled";function mfn(e,t){const n=e instanceof Ut?e.code:void 0;return n===rln?null:n===nln?{kind:"info",text:`${t} will say hello once an AI account is connected. Connect one from the chat to start.`}:{kind:"error",text:`${t}'s conversation could not be opened, so you are in a new chat instead. ${tln(e)}`}}function gfn(e,t){if(e.held===!0)return`${t} is already open in another window, so she will say hello there.`;const n=e.greeting_state==="delivered"||e.greeting_state==="skipped"||e.greeting_state==null&&e.greeted===!0;return e.paused&&!n?`${t} is paused, so she will say hello when you resume her: type /aida resume.`:null}function $fn(e){const t=e?.greeting_state;return t==null||t==="owed"}function iln(e){return e.eventKey===e.storeKey&&!e.focused}let Bse=!1;function yfn(){if(Bse)return;Bse=!0;const e=an.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{iln({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&an.persist?.rehydrate?.()?.catch?.(()=>{})};window.addEventListener("storage",t)}export{Fln as $,eGe as A,sGe as B,jt as C,Ua as D,lt as E,El as F,An as G,Df as H,P as I,Rn as J,Qr as K,Xn as L,wn as M,Mk as N,Ev as O,Yr as P,Cr as Q,Lr as R,bs as S,d8 as T,wa as U,Bn as V,L9 as W,cr as X,_s as Y,Ut as Z,pv as _,Ri as a,kW as a$,Io as a0,Sln as a1,Bln as a2,R$ as a3,mi as a4,dW as a5,QW as a6,Rc as a7,Nr as a8,pDe as a9,Ad as aA,Ysn as aB,gUe as aC,Ycn as aD,Aln as aE,Uln as aF,yfn as aG,gun as aH,pun as aI,zln as aJ,hj as aK,Of as aL,W9e as aM,uv as aN,Zln as aO,Ov as aP,GOn as aQ,Tl as aR,Mh as aS,$a as aT,jue as aU,mz as aV,yj as aW,ade as aX,Dln as aY,ro as aZ,ZNt as a_,j$ as aa,rdn as ab,idn as ac,xke as ad,V8e as ae,Az as af,qj as ag,hv as ah,Nf as ai,FYe as aj,pfn as ak,cfn as al,ufn as am,Uce as an,Ofn as ao,aun as ap,$ln as aq,ar,wln as as,Ta as at,wtt as au,zd as av,bCe as aw,$Ce as ax,an as ay,Pm as az,ecn as b,Rp as b$,t_e as b0,Bv as b1,i_e as b2,Kdn as b3,IGt as b4,Lre as b5,Vre as b6,w_e as b7,NW as b8,FP as b9,Sde as bA,Qun as bB,kun as bC,Bd as bD,fv as bE,ve as bF,YAe as bG,ri as bH,pg as bI,n8e as bJ,x5 as bK,ake as bL,wG as bM,xG as bN,kue as bO,acn as bP,yz as bQ,iun as bR,qm as bS,eUe as bT,d6e as bU,sG as bV,Yln as bW,Nln as bX,k6e as bY,icn as bZ,su as b_,XYt as ba,RYt as bb,sm as bc,TYt as bd,_Yt as be,iQ as bf,Kv as bg,UW as bh,AW as bi,Id as bj,rQ as bk,uGe as bl,zx as bm,Rr as bn,iZe as bo,zde as bp,m1 as bq,mln as br,_un as bs,Lln as bt,HGe as bu,L8e as bv,Pun as bw,Gz as bx,eun as by,nIe as bz,oi as c,LAt as c$,zue as c0,Que as c1,dv as c2,pk as c3,Gue as c4,que as c5,Rue as c6,Mze as c7,Ejt as c8,Pue as c9,oUe as cA,BRt as cB,mZe as cC,Mz as cD,uQe as cE,zO as cF,_f as cG,rIe as cH,IAe as cI,AAe as cJ,QKt as cK,nd as cL,Hcn as cM,GYe as cN,Zc as cO,xKt as cP,d_ as cQ,f_ as cR,VLt as cS,u_ as cT,cde as cU,Cln as cV,vYe as cW,Lue as cX,sO as cY,dGe as cZ,oke as c_,Zue as ca,Iue as cb,Kj as cc,IO as cd,Eue as ce,Xue as cf,Xm as cg,Si as ch,tue as ci,m6e as cj,y6e as ck,S6e as cl,v6e as cm,b6e as cn,fj as co,Q6e as cp,uG as cq,x6e as cr,w6e as cs,vde as ct,yde as cu,BGe as cv,xln as cw,Tp as cx,Qln as cy,U0 as cz,Re as d,Z9t as d$,ok as d0,kce as d1,Hje as d2,sk as d3,_ke as d4,GXt as d5,hk as d6,tdn as d7,X7t as d8,bke as d9,Sc as dA,K8e as dB,uun as dC,e6t as dD,kd as dE,e7t as dF,F9e as dG,Wln as dH,afn as dI,cGe as dJ,pGe as dK,ACt as dL,JAe as dM,sdn as dN,sf as dO,uPe as dP,Yx as dQ,Jx as dR,rie as dS,nYt as dT,qy as dU,F9t as dV,B9t as dW,L9t as dX,V9t as dY,M9t as dZ,D9t as d_,ndn as da,W6t as db,T7 as dc,Xle as dd,RCe as de,Son as df,ofn as dg,Uc as dh,sfn as di,Qon as dj,Eke as dk,Uue as dl,QU as dm,frn as dn,AO as dp,sde as dq,Oun as dr,Mqt as ds,Bqt as dt,MOn as du,BK as dv,VK as dw,Fqt as dx,bJt as dy,Wi as dz,Cz as e,$cn as e$,NP as e0,_9t as e1,P9t as e2,I9t as e3,G9t as e4,u8e as e5,Mn as e6,fk as e7,bdn as e8,Sdn as e9,lGe as eA,PYe as eB,mun as eC,k5 as eD,ZJe as eE,HJe as eF,aFe as eG,Y$ as eH,GJe as eI,Ape as eJ,rYe as eK,iYe as eL,GWe as eM,Sj as eN,gy as eO,_z as eP,Ucn as eQ,udn as eR,cdn as eS,RWe as eT,Xcn as eU,Tcn as eV,Rcn as eW,Acn as eX,zcn as eY,sWe as eZ,vcn as e_,$dn as ea,mdn as eb,rA as ec,ddn as ed,fdn as ee,hdn as ef,wdn as eg,xdn as eh,ydn as ei,Odn as ej,vdn as ek,gdn as el,pdn as em,jln as en,WCe as eo,UCe as ep,Fce as eq,Lce as er,oun as es,sun as et,a8e as eu,lun as ev,cun as ew,dun as ex,hun as ey,J8e as ez,tPe as f,Aun as f$,Ls as f0,z0 as f1,wcn as f2,hcn as f3,wR as f4,Scn as f5,_7 as f6,U6t as f7,C6t as f8,ldn as f9,qcn as fA,Pcn as fB,QWe as fC,Ccn as fD,cWe as fE,_cn as fF,rAt as fG,xj as fH,mWe as fI,jce as fJ,ou as fK,Qdn as fL,UTe as fM,kdn as fN,LOn as fO,o6t as fP,Sun as fQ,UAe as fR,ROe as fS,LWe as fT,xsn as fU,D9e as fV,Tue as fW,MZe as fX,FZe as fY,Wun as fZ,Nun as f_,xcn as fa,mle as fb,SS as fc,wWe as fd,kcn as fe,I6t as ff,VAe as fg,dk as fh,wue as fi,JU as fj,NJ as fk,d0 as fl,mcn as fm,$Oe as fn,_9e as fo,jcn as fp,Ecn as fq,XAe as fr,pcn as fs,gOe as ft,bcn as fu,vR as fv,Wcn as fw,d9e as fx,UUe as fy,ycn as fz,yr as g,ms as g$,zun as g0,Uun as g1,Gun as g2,tDe as g3,lfe as g4,Dun as g5,Tze as g6,iDe as g7,Yun as g8,uDe as g9,Vpe as gA,Lpe as gB,iOn as gC,CCe as gD,QA as gE,Tz as gF,AOe as gG,oNe as gH,Dv as gI,sQe as gJ,oQe as gK,co as gL,_n as gM,ZO as gN,Pt as gO,Ie as gP,ht as gQ,yOn as gR,Ti as gS,UM as gT,Nm as gU,Ro as gV,Yc as gW,dme as gX,cn as gY,Nn as gZ,gf as g_,Mun as ga,Iun as gb,LZe as gc,Gn as gd,Zun as ge,Sue as gf,nUe as gg,B8e as gh,rcn as gi,ncn as gj,tcn as gk,Icn as gl,Qj as gm,eAt as gn,lln as go,UCt as gp,Z9 as gq,aOn as gr,eOn as gs,htt as gt,Jun as gu,G9 as gv,Hpe as gw,Y9 as gx,Kpe as gy,Fpe as gz,yte as h,r9e as h$,Zl as h0,uOn as h1,Mv as h2,NU as h3,GU as h4,Cx as h5,WU as h6,YU as h7,IU as h8,Jze as h9,xOn as hA,POn as hB,TOn as hC,XOn as hD,qOn as hE,mOn as hF,gOn as hG,hOn as hH,Nk as hI,_On as hJ,Dk as hK,pOn as hL,YSe as hM,wU as hN,hse as hO,Hue as hP,oI as hQ,Y8e as hR,$8e as hS,krn as hT,t2e as hU,kZe as hV,sfe as hW,A2e as hX,m9e as hY,ode as hZ,oA as h_,fs as ha,jge as hb,eat as hc,XO as hd,Jit as he,Fn as hf,Gt as hg,Zf as hh,Ki as hi,Er as hj,zi as hk,tu as hl,rw as hm,KS as hn,Ik as ho,$On as hp,Tu as hq,EOn as hr,QOn as hs,_ot as ht,vOn as hu,bOn as hv,fOn as hw,kOn as hx,OOn as hy,dOn as hz,Fdn as i,sUe as i$,Nue as i0,q$ as i1,NOn as i2,p8e as i3,m8e as i4,qxe as i5,Exe as i6,tOn as i7,NS as i8,Sk as i9,uFe as iA,rBe as iB,Gze as iC,Wue as iD,Ck as iE,Mpe as iF,ptt as iG,btt as iH,gle as iI,uk as iJ,fXe as iK,VY as iL,kXe as iM,TCe as iN,qYe as iO,Ez as iP,DAe as iQ,Vcn as iR,qqt as iS,wde as iT,ZNe as iU,Lcn as iV,Dce as iW,qln as iX,Pln as iY,kln as iZ,BY as i_,Cfe as ia,K5 as ib,UBe as ic,zBe as id,jfe as ie,Vun as ig,che as ih,Sa as ii,YO as ij,wv as ik,Fun as il,RMe as im,KBe as io,det as ip,qS as iq,p9 as ir,s9 as is,Lj as it,lhe as iu,GMe as iv,QMe as iw,WMe as ix,bD as iy,bBe as iz,ul as j,Tln as j$,_ln as j0,scn as j1,Pze as j2,ocn as j3,lcn as j4,pUe as j5,Cjt as j6,Lz as j7,$v as j8,xU as j9,yk as jA,Zcn as jB,iNe as jC,Dcn as jD,Gcn as jE,JZe as jF,ifn as jG,Cun as jH,rZe as jI,nI as jJ,nde as jK,ple as jL,hle as jM,mYe as jN,Jcn as jO,G3t as jP,IQe as jQ,Knn as jR,KTe as jS,Jdn as jT,rg as jU,dfn as jV,hfn as jW,tln as jX,ffn as jY,uln as jZ,Oln as j_,zU as ja,Ajt as jb,nOn as jc,YXt as jd,rOn as je,_ue as jf,Man as jg,Ncn as jh,X$ as ji,azt as jj,Dke as jk,j5 as jl,_m as jm,ja as jn,TGe as jo,fun as jp,hGe as jq,KOn as jr,JOn as js,edn as jt,Yue as ju,Kln as jv,iUe as jw,Pr as jx,qun as jy,cln as jz,Ddn as k,h9e as k$,W7e as k0,Rln as k1,Eln as k2,Xln as k3,e2e as k4,JQ as k5,Tun as k6,Eun as k7,Run as k8,Xun as k9,pln as kA,fln as kB,nfn as kC,Mcn as kD,CUe as kE,aCe as kF,AUe as kG,zUe as kH,fcn as kI,dcn as kJ,ANe as kK,CNe as kL,VOe as kM,Ocn as kN,Yce as kO,oOe as kP,ccn as kQ,Gce as kR,fCe as kS,MY as kT,ucn as kU,gln as kV,rfn as kW,DWe as kX,DOn as kY,tfn as kZ,tS as k_,run as ka,Wke as kb,Eqt as kc,cv as kd,vCe as ke,Jue as kf,Jln as kg,nz as kh,vUe as ki,hln as kj,eZe as kk,tZe as kl,jun as km,gcn as kn,Qcn as ko,iAt as kp,efn as kq,dln as kr,Ice as ks,lfn as kt,ZOn as ku,xCe as kv,ck as kw,vln as kx,bln as ky,i4e as kz,Mdn as l,Fi as l$,SO as l0,Bcn as l1,eYe as l2,yln as l3,Fcn as l4,VYe as l5,u7t as l6,pke as l7,Ydn as l8,FOn as l9,EP as lA,Adn as lB,Cdn as lC,qdn as lD,$z as lE,a2e as lF,jke as lG,Ej as lH,$fn as lI,gfn as lJ,mfn as lK,H7t as lL,kke as lM,Qke as lN,eIe as lO,SJ as lP,adn as lQ,odn as lR,xun as lS,_Ye as lT,TYe as lU,Kcn as lV,tun as lW,RGe as lX,nun as lY,Mln as lZ,$Ae as l_,HOn as la,yke as lb,yu as lc,BOn as ld,oGe as le,mke as lf,Xdn as lg,Gdn as lh,Idn as li,Edn as lj,Zdn as lk,mk as ll,c7t as lm,TXe as ln,Zrn as lo,zdn as lp,Udn as lq,g7t as lr,Tdn as ls,pAt as lt,_dn as lu,Rdn as lv,dAt as lw,jdn as lx,Ndn as ly,Wdn as lz,Ldn as m,IOn as m0,Pdn as m1,VOn as m2,s6e as m3,W7t as m4,vun as m5,$un as m6,yun as m7,bg as m8,bun as m9,Iln as ma,Hln as mb,g1 as mc,wun as md,Vln as me,Kun as mf,YOn as mg,Hdn as n,Vdn as o,em as p,Bdn as q,Kd as r,Nx as s,WP as t,cc as u,nQ as v,OW as w,Ry as x,oPe as y,Y9t as z};
|