local-operator-ui 0.35.2 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/out/main/index.js +8112 -154
  2. package/out/preload/index.js +16 -0
  3. package/out/renderer/assets/{_basePickBy-NBZVf3x_.js → _basePickBy-SGLOphwb.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-BpOXfy9b.js → _baseUniq-BEXNc7x-.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-CI5V0mco.js → agent-details-page-DV2yIuv2.js} +1 -1
  6. package/out/renderer/assets/{agent-hub-page-C7UV5Z02.js → agent-hub-page-CUbsvyOV.js} +1 -1
  7. package/out/renderer/assets/{agents-page-BHUCzpZE.js → agents-page-HlZ3bxUE.js} +3 -3
  8. package/out/renderer/assets/{arc-DTlm2-sN.js → arc-C8xiXz_s.js} +1 -1
  9. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-uA5hYBWO.js → architectureDiagram-IEHRJDOE-DPp-Txy7.js} +1 -1
  10. package/out/renderer/assets/{blockDiagram-JOT3LUYC-Awo08lrR.js → blockDiagram-JOT3LUYC-D_d0BHII.js} +1 -1
  11. package/out/renderer/assets/{book-open-DBUibLWP.js → book-open-DTOZBzFE.js} +1 -1
  12. package/out/renderer/assets/browser-page-CeOP0TxL.js +1 -0
  13. package/out/renderer/assets/{browser-webauthn-prompt-egKdqzbk.js → browser-webauthn-prompt-BK-iloiA.js} +1 -1
  14. package/out/renderer/assets/{c4Diagram-VJAJSXHY-DAHoIxNf.js → c4Diagram-VJAJSXHY-C6MJyQ4X.js} +1 -1
  15. package/out/renderer/assets/channel-FnsvGBvN.js +1 -0
  16. package/out/renderer/assets/{chunk-4BMEZGHF-QvFtu74J.js → chunk-4BMEZGHF-DaoR7E6u.js} +1 -1
  17. package/out/renderer/assets/{chunk-A2AXSNBT-EcRDJZN6.js → chunk-A2AXSNBT-kSoJEGtH.js} +1 -1
  18. package/out/renderer/assets/{chunk-AEK57VVT-CKf_yBAg.js → chunk-AEK57VVT-CbuETRiF.js} +1 -1
  19. package/out/renderer/assets/{chunk-D6G4REZN-CoixV4aq.js → chunk-D6G4REZN-VgQyUEwk.js} +1 -1
  20. package/out/renderer/assets/{chunk-RZ5BOZE2-CtEEDTp-.js → chunk-RZ5BOZE2-CC9D19Ws.js} +1 -1
  21. package/out/renderer/assets/{chunk-XZIHB7SX-BOgT03N8.js → chunk-XZIHB7SX-rHyhcY1z.js} +1 -1
  22. package/out/renderer/assets/classDiagram-GIVACNV2-B1qeThzW.js +1 -0
  23. package/out/renderer/assets/classDiagram-v2-COTLJTTW-B1qeThzW.js +1 -0
  24. package/out/renderer/assets/clone-CEyxkG_K.js +1 -0
  25. package/out/renderer/assets/{console-mirror-D7dfGxrD.js → console-mirror-C_vErGtg.js} +1 -1
  26. package/out/renderer/assets/{consoleCapture-DczATgZh.js → consoleCapture-BSMsAadm.js} +1 -1
  27. package/out/renderer/assets/{conversation-input-sync-GlFEQKuo.js → conversation-input-sync-D8m_0i2P.js} +4 -4
  28. package/out/renderer/assets/{dagre-OKDRZEBW-CijtV3o0.js → dagre-OKDRZEBW-dnMavWL5.js} +1 -1
  29. package/out/renderer/assets/{diagram-SSKATNLV-Dxx1RpmY.js → diagram-SSKATNLV-CbEqpT5c.js} +1 -1
  30. package/out/renderer/assets/{diagram-VNBRO52H-DZg2hjvO.js → diagram-VNBRO52H-CVFcaRWG.js} +1 -1
  31. package/out/renderer/assets/{erDiagram-Q7BY3M3F-CjvMMGLo.js → erDiagram-Q7BY3M3F-c4T4ZMVa.js} +1 -1
  32. package/out/renderer/assets/{error-boundary-CLT6U8jT.js → error-boundary-5hn9OWCr.js} +1 -1
  33. package/out/renderer/assets/{flowDiagram-4HSFHLVR-EjagIE01.js → flowDiagram-4HSFHLVR-DONfRBhn.js} +1 -1
  34. package/out/renderer/assets/{ganttDiagram-APWFNJXF-OfsWfUyW.js → ganttDiagram-APWFNJXF-Cp9mKyj3.js} +1 -1
  35. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-nYTyKs0s.js → gitGraphDiagram-7IBYFJ6S-qDIZQ2Xn.js} +1 -1
  36. package/out/renderer/assets/{graph-BnL8m22f.js → graph-DxzSxuLT.js} +1 -1
  37. package/out/renderer/assets/{index-C866kR_k.js → index-BUDP0pmc.js} +1 -1
  38. package/out/renderer/assets/index-By5U6kgU.js +824 -0
  39. package/out/renderer/assets/{index-CO7sxKWb.js → index-CSR2j15s.js} +1 -1
  40. package/out/renderer/assets/index-DlJQQpdf.css +1 -0
  41. package/out/renderer/assets/index-Dom8jp4B.js +57 -0
  42. package/out/renderer/assets/{infoDiagram-PH2N3AL5-LE2dCnxc.js → infoDiagram-PH2N3AL5-DMwjGTFV.js} +1 -1
  43. package/out/renderer/assets/{installer-Wpfa8xHM.js → installer-C6aKiv4n.js} +1 -1
  44. package/out/renderer/assets/{journeyDiagram-U35MCT3I-BhpegMd0.js → journeyDiagram-U35MCT3I-D1rmFkrM.js} +1 -1
  45. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-OoMW68Bt.js → kanban-definition-NDS4AKOZ-CqK-A_YR.js} +1 -1
  46. package/out/renderer/assets/{layout-BdaXfJXz.js → layout-D4krH14D.js} +1 -1
  47. package/out/renderer/assets/{legacy-agents-page-lVj0d18U.js → legacy-agents-page-kqMeTGcp.js} +1 -1
  48. package/out/renderer/assets/{mermaid.core-DmdT5IgP.js → mermaid.core-CrL8DoR1.js} +5 -5
  49. package/out/renderer/assets/{mesh-page-D0-4HVNk.js → mesh-page-CM48PCe9.js} +1 -1
  50. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BCXX8n68.js → mindmap-definition-ALO5MXBD-C-gUOB1I.js} +1 -1
  51. package/out/renderer/assets/{mini-DsJCW_H3.js → mini-onfDilHt.js} +1 -1
  52. package/out/renderer/assets/{notebook-pen-CAZF-xgd.js → notebook-pen-Btzx7ygD.js} +1 -1
  53. package/out/renderer/assets/{org-access-DCQGHh2Y.js → org-access-BEUGBi3r.js} +1 -1
  54. package/out/renderer/assets/{org-surface-gate-Cq3kOR7u.js → org-surface-gate-D09m9wPe.js} +1 -1
  55. package/out/renderer/assets/{page-header-CQ6qN4O4.js → page-header-CKQX5mld.js} +1 -1
  56. package/out/renderer/assets/{pieDiagram-IB7DONF6-BRK1MBQO.js → pieDiagram-IB7DONF6-Drlcy994.js} +1 -1
  57. package/out/renderer/assets/{projects-page-DpAhuoA7.js → projects-page-B6hrFCYu.js} +1 -1
  58. package/out/renderer/assets/{publication-validation-CZn6wbD0.js → publication-validation-CcRMJVIV.js} +1 -1
  59. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-CtQwUI4m.js → quadrantDiagram-7GDLP6J5-BiVOkk5-.js} +1 -1
  60. package/out/renderer/assets/{radar-MK3ICKWK-o9_lRR0v.js → radar-MK3ICKWK-DJQQ5bto.js} +1 -1
  61. package/out/renderer/assets/{radient-auth-buttons-BWhD8ldO.js → radient-auth-buttons-BXlyZYxA.js} +1 -1
  62. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-aEEiUjHx.js → requirementDiagram-KVF5MWMF-BuTsJfL4.js} +1 -1
  63. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-CtjAQQYG.js → sankeyDiagram-QLVOVGJD-D-tl8j-V.js} +1 -1
  64. package/out/renderer/assets/{schedules-page-C4-FWwsb.js → schedules-page-DrwIsOtA.js} +1 -1
  65. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-QOpgwrwA.js → sequenceDiagram-X6HHIX6F-NqOQh-1X.js} +1 -1
  66. package/out/renderer/assets/{settings-page-BJZ7ozTY.js → settings-page-D35Ls2IS.js} +1 -1
  67. package/out/renderer/assets/{stateDiagram-DGXRK772-D99A_n2H.js → stateDiagram-DGXRK772-CbnDiKHd.js} +1 -1
  68. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CAGVkdpP.js +1 -0
  69. package/out/renderer/assets/{timeline-definition-BDJGKUSR-C_Op_i7D.js → timeline-definition-BDJGKUSR-C8_-K0jE.js} +1 -1
  70. package/out/renderer/assets/ui-preferences-store-Dz1d9H9b.js +1 -0
  71. package/out/renderer/assets/{use-download-agent-mutation-PP3ZbZ7V.js → use-download-agent-mutation-C2YV-ZqZ.js} +1 -1
  72. package/out/renderer/assets/{use-memberships-query-TOFQHH-q.js → use-memberships-query-CE1RS6l9.js} +1 -1
  73. package/out/renderer/assets/{use-session-snapshot-BOMni_bJ.js → use-session-snapshot-tK5pFJpN.js} +1 -1
  74. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-Bq2H6JYU.js → xychartDiagram-VJFVF3MP-DxygsIwk.js} +1 -1
  75. package/out/renderer/console-capture.html +5 -5
  76. package/out/renderer/index.html +7 -7
  77. package/out/renderer/installer.html +4 -4
  78. package/out/renderer/mini.html +7 -7
  79. package/package.json +2 -2
  80. package/out/renderer/assets/browser-page-DuKCLrh5.js +0 -1
  81. package/out/renderer/assets/channel-BZ9uCAQo.js +0 -1
  82. package/out/renderer/assets/classDiagram-GIVACNV2-D6kkk-4_.js +0 -1
  83. package/out/renderer/assets/classDiagram-v2-COTLJTTW-D6kkk-4_.js +0 -1
  84. package/out/renderer/assets/clone-BgCd73kI.js +0 -1
  85. package/out/renderer/assets/index-CGcU9-Py.css +0 -1
  86. package/out/renderer/assets/index-Cj2bZws8.js +0 -57
  87. package/out/renderer/assets/index-p3NO0LL-.js +0 -824
  88. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D0CTAsLQ.js +0 -1
  89. package/out/renderer/assets/ui-preferences-store-Dz1Kg_SA.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-C866kR_k.js","./index-Cj2bZws8.js","./index-CGcU9-Py.css","./ui-preferences-store-Dz1Kg_SA.js","./error-boundary-CLT6U8jT.js","./index-CO7sxKWb.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-DmdT5IgP.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
- import{r as $,b as ee,j as h,i as lRe,c as q,g as Jn,t as J,B as Lse,k as ov,L as qd,d as uA,C as Ob,h as yn,e as Uq}from"./index-Cj2bZws8.js";import{aQ as xp,aR as FQ,aS as Fse,aT as Bse,aU as y$,A as lf,aV as cRe,aW as BQ,aX as uRe,J as Hse,aY as OA,aZ as ORe,B as dA,a_ as dRe,a$ as fRe,e as ta,g as lc,R as Rm,E as Kse,C as fA,b0 as zu,b1 as hRe,u as Kn,b2 as pRe,b3 as mRe,b4 as gRe,b5 as $Re,b6 as AN,b7 as yRe,ax as vRe,aF as bRe,b8 as wRe,aL as SRe,b9 as xRe,ba as QRe,az as zN,aA as kRe,bb as HQ,bc as Qp,bd as PRe,be as UN,bf as _Re,bg as TRe,bh as Jse,bi as WN,M as ele,bj as tle,bk as RRe,bl as XRe,bm as ERe,bn as qRe,aN as hA,bo as jRe,D as CRe,r as NN,bp as W_,y as ARe,bq as zRe,x as nle,br as Wq}from"./ui-preferences-store-Dz1Kg_SA.js";import{ae as URe,c as De,B as Ee,aq as pA,D as mA,a as gA,b as WRe,d as $A,f as NRe,l as Yt,x as oS,y as rle,T as cf,z as Md,g as xu,X as ea,u as kr,af as Nq,aF as YRe,aG as GRe,aH as IRe,A as Ll,S as Go,p as ile,q as yA,r as vA,s as bA,w as jl,m as E0,n as q0,aE as wA,o as kp,aK as ZRe,a1 as DRe,a2 as MRe,a3 as VRe,ab as LRe,a0 as KQ,N as FRe,Y as BRe,Z as HRe,_ as KRe,I as io,F as ale,G as ole,H as sle,J as lle,K as Yq,M as JRe,e as Gq,L as cle,C as eXe,k as _o,P as tXe,Q as nXe,R as YN,U as GN,V as rXe,W as IN,ar as iXe,aL as aXe,h as oXe,t as N_,v as ZN,E as DN}from"./error-boundary-CLT6U8jT.js";const sXe="superseded_completion_token",lXe="store_busy",cXe="session_is_remote",uXe="owner_build_behind";function OXe(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 ule(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const Ole=e=>typeof e?.goal_status=="string",dle=e=>(e?.goal??"").trim().length>0;function dXe(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."},MN={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},fXe={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},hXe={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},pXe={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},mXe={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function VN(e){return e?e===j0.notPaired?hXe:e===j0.serverDown?fXe:e===j0.frameBudget?mXe:MN:MN}async function SA(e){if(window.api?.desktop)try{return await gXe(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ut?n:SXe(n)?new ou(Fse,Bse):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 gXe(e,t){const n=OA(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=ORe(t.op,n);a(new Ut(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const fle="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 $Xe(e,t,n,r){return typeof r=="string"?r:n===y$.noCredential?lf.noCredential:n===y$.transportFailed?lf.transportFailed:cRe(BQ(e).path,t)}async function Re(e){const t=await SA(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??fle,void 0,$Xe(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"&&yXe(n?.result),n?.result}function yXe(e){if(typeof e!="object"||e===null)return;const t=uRe(e.delegated_cleanup_notice);t&&Hse.getState().receive(t)}async function vXe(){try{await Re({op:"delegated_cleanup_notice.ack"})}catch{}}async function iln(){Hse.getState().dismiss(),await vXe()}function hle(e){return e instanceof Ut&&e.code===dA}function bXe(e){if(!(e instanceof Ut))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===uXe:e.code===cXe}function wXe(e){return e instanceof ou&&e.code===Bse}function SXe(e){return e instanceof Error&&e.message.includes(Fse)}async function Cn(e){const t=await SA(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function xXe(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 QXe(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"),dRe(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 xA(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 ple(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 mle(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 gle(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 $le(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return kXe(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,...x}=y;y=x}return y});ple(a,f=>f.journalGeneration===n&&Vd(f.journalSeq))&&(i=!0);const s=new Map,l=new Map(a.map(f=>[f.id,f])),c=gle(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?mle(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 kXe(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();ple(s,m=>m.journalGeneration===n&&Vd(m.journalSeq))&&(o=!0);const c=new Map,u=new Map(s.map(m=>[m.id,m])),O=gle(u,m=>a(m)?.seq),d=m=>O(m)!==void 0,f=(m,g)=>{const y=O(m);if(m.kind==="user"&&m.provisional===!0&&y===void 0)return[1,0,0,0,g];const v=m.kind==="supplement"?m.anchor:m.kind==="tool"?e.journalCallOwners?.get(m.toolCallId)??e.argsByCall.get(m.toolCallId)?.anchorId:void 0,S=typeof v=="string"?O(u.get(v)):void 0,x=y===void 0?mle(m,u,d,O,c):void 0,b=S??y??x;return b===void 0?[1,0,0,0,g]:[0,b,S!==void 0?1:y!==void 0?0:2,y??Number.MAX_SAFE_INTEGER,g]},p=s.map((m,g)=>({record:m,index:g,rank:f(m,g)}));return p.sort((m,g)=>{for(let y=0;y<m.rank.length;y++){const v=m.rank[y]-g.rank[y];if(v)return v}return 0}),!o&&p.every((m,g)=>m.index===g)?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(...QA(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 QA(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 yle(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 PXe(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"?QA(s):l==="lookup"?yle(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=fRe(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 LN(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function aln(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:LN(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:LN(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 _Xe(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 TXe(e,t,n){const r=_Xe(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 kA=new Set,wa="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",Zo=new RegExp(`[${wa}]`),JQ=new RegExp(`[${wa}]+`),RXe=new RegExp(`[${wa}]+`,"g"),XXe=new RegExp(`^[${wa}]+|[${wa}]+$`,"g"),EXe=new RegExp(`^[${wa}]+`),qXe=new RegExp(`[^${wa}]`);function on(e){return e.replace(XXe,"")}function lu(e){return e.replace(EXe,"")}function jXe(e,t){return t===0||Zo.test(e[t-1])}function vle(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&jXe(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-BUDP0pmc.js","./index-Dom8jp4B.js","./index-DlJQQpdf.css","./ui-preferences-store-Dz1d9H9b.js","./error-boundary-5hn9OWCr.js","./index-CSR2j15s.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-CrL8DoR1.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
+ import{r as $,b as ee,j as h,i as lRe,c as q,g as Jn,t as J,B as Lse,k as ov,L as qd,d as uA,C as Ob,h as yn,e as Uq}from"./index-Dom8jp4B.js";import{aQ as xp,aR as FQ,aS as Fse,aT as Bse,aU as y$,A as lf,aV as cRe,aW as BQ,aX as uRe,J as Hse,aY as OA,aZ as ORe,B as dA,a_ as dRe,a$ as fRe,e as ta,g as lc,R as Rm,E as Kse,C as fA,b0 as zu,b1 as hRe,u as Kn,b2 as pRe,b3 as mRe,b4 as gRe,b5 as $Re,b6 as AN,b7 as yRe,ax as vRe,aF as bRe,b8 as wRe,aL as SRe,b9 as xRe,ba as QRe,az as zN,aA as kRe,bb as HQ,bc as Qp,bd as PRe,be as UN,bf as _Re,bg as TRe,bh as Jse,bi as WN,M as ele,bj as tle,bk as RRe,bl as XRe,bm as ERe,bn as qRe,aN as hA,bo as jRe,D as CRe,r as NN,bp as W_,y as ARe,bq as zRe,x as nle,br as Wq}from"./ui-preferences-store-Dz1d9H9b.js";import{ae as URe,c as De,B as Ee,aq as pA,D as mA,a as gA,b as WRe,d as $A,f as NRe,l as Yt,x as oS,y as rle,T as cf,z as Md,g as xu,X as ea,u as kr,af as Nq,aF as YRe,aG as GRe,aH as IRe,A as Ll,S as Go,p as ile,q as yA,r as vA,s as bA,w as jl,m as E0,n as q0,aE as wA,o as kp,aK as ZRe,a1 as DRe,a2 as MRe,a3 as VRe,ab as LRe,a0 as KQ,N as FRe,Y as BRe,Z as HRe,_ as KRe,I as io,F as ale,G as ole,H as sle,J as lle,K as Yq,M as JRe,e as Gq,L as cle,C as eXe,k as _o,P as tXe,Q as nXe,R as YN,U as GN,V as rXe,W as IN,ar as iXe,aL as aXe,h as oXe,t as N_,v as ZN,E as DN}from"./error-boundary-5hn9OWCr.js";const sXe="superseded_completion_token",lXe="store_busy",cXe="session_is_remote",uXe="owner_build_behind";function OXe(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 ule(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const Ole=e=>typeof e?.goal_status=="string",dle=e=>(e?.goal??"").trim().length>0;function dXe(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."},MN={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},fXe={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},hXe={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},pXe={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},mXe={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function VN(e){return e?e===j0.notPaired?hXe:e===j0.serverDown?fXe:e===j0.frameBudget?mXe:MN:MN}async function SA(e){if(window.api?.desktop)try{return await gXe(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ut?n:SXe(n)?new ou(Fse,Bse):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 gXe(e,t){const n=OA(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=ORe(t.op,n);a(new Ut(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const fle="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 $Xe(e,t,n,r){return typeof r=="string"?r:n===y$.noCredential?lf.noCredential:n===y$.transportFailed?lf.transportFailed:cRe(BQ(e).path,t)}async function Re(e){const t=await SA(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??fle,void 0,$Xe(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"&&yXe(n?.result),n?.result}function yXe(e){if(typeof e!="object"||e===null)return;const t=uRe(e.delegated_cleanup_notice);t&&Hse.getState().receive(t)}async function vXe(){try{await Re({op:"delegated_cleanup_notice.ack"})}catch{}}async function iln(){Hse.getState().dismiss(),await vXe()}function hle(e){return e instanceof Ut&&e.code===dA}function bXe(e){if(!(e instanceof Ut))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===uXe:e.code===cXe}function wXe(e){return e instanceof ou&&e.code===Bse}function SXe(e){return e instanceof Error&&e.message.includes(Fse)}async function Cn(e){const t=await SA(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function xXe(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 QXe(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"),dRe(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 xA(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 ple(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 mle(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 gle(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 $le(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return kXe(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,...x}=y;y=x}return y});ple(a,f=>f.journalGeneration===n&&Vd(f.journalSeq))&&(i=!0);const s=new Map,l=new Map(a.map(f=>[f.id,f])),c=gle(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?mle(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 kXe(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();ple(s,m=>m.journalGeneration===n&&Vd(m.journalSeq))&&(o=!0);const c=new Map,u=new Map(s.map(m=>[m.id,m])),O=gle(u,m=>a(m)?.seq),d=m=>O(m)!==void 0,f=(m,g)=>{const y=O(m);if(m.kind==="user"&&m.provisional===!0&&y===void 0)return[1,0,0,0,g];const v=m.kind==="supplement"?m.anchor:m.kind==="tool"?e.journalCallOwners?.get(m.toolCallId)??e.argsByCall.get(m.toolCallId)?.anchorId:void 0,S=typeof v=="string"?O(u.get(v)):void 0,x=y===void 0?mle(m,u,d,O,c):void 0,b=S??y??x;return b===void 0?[1,0,0,0,g]:[0,b,S!==void 0?1:y!==void 0?0:2,y??Number.MAX_SAFE_INTEGER,g]},p=s.map((m,g)=>({record:m,index:g,rank:f(m,g)}));return p.sort((m,g)=>{for(let y=0;y<m.rank.length;y++){const v=m.rank[y]-g.rank[y];if(v)return v}return 0}),!o&&p.every((m,g)=>m.index===g)?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(...QA(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 QA(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 yle(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 PXe(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"?QA(s):l==="lookup"?yle(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=fRe(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 LN(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function aln(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:LN(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:LN(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 _Xe(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 TXe(e,t,n){const r=_Xe(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 kA=new Set,wa="\\t\\n\\v\\f\\r\\u001C-\\u001F \\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000",Zo=new RegExp(`[${wa}]`),JQ=new RegExp(`[${wa}]+`),RXe=new RegExp(`[${wa}]+`,"g"),XXe=new RegExp(`^[${wa}]+|[${wa}]+$`,"g"),EXe=new RegExp(`^[${wa}]+`),qXe=new RegExp(`[^${wa}]`);function on(e){return e.replace(XXe,"")}function lu(e){return e.replace(EXe,"")}function jXe(e,t){return t===0||Zo.test(e[t-1])}function vle(e){const t=[];for(let n=0;n<e.length;n++)e[n]==="/"&&jXe(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 CXe(e,t){if(t.size===0)return null;for(const n of vle(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 PA(e,t,n){const r=CXe(e,n);let i=null;for(const a of vle(e)){if(a===r)return t>a?a:i;a<=t&&(i=a)}return i}function sv(e,t=null,n=kA){const{line:r,lineStart:i,column:a}=ek(e,t),o=PA(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=kA){const{line:r,lineStart:i,column:a}=ek(e,t),o=PA(r,a,n);return o===null?null:{start:i+o,end:i+r.length}}function tk(e,t,n=null,r=kA){const{line:i,lineStart:a,column:o}=ek(e,n),s=r.size>0?r:new Set(t.map(f=>f.toLowerCase())),l=PA(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 AXe(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 zXe=/^\$([A-Za-z0-9][A-Za-z0-9._-]*)/,UXe=/<skill name="([^"]*)" invocation="([^"]*)">/;function FN(e,t){const n=lu(e),r=zXe.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 WXe(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"&#10;")}function NXe(e){return e.replace(/&#10;/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=Ze.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:Ln.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);r8(t,c,Ze.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:Bme.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 _t{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||bnt(t.parent)||document,this.viewState=new vM(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 Wrt(this),this.inputState=new lrt(this),this.inputState.ensureHandlers(this.plugins),this.docView=new tM(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(cge))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=uge(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:Ze.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(N3))try{d(i)}catch(f){to(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!rge(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 vM(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 tM(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){to(this.state,r,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:a,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let s=0;;s++){if(o<0)if(xme(r))a=-1,o=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(i);a=f.from,o=f.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(s>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(f=>{try{return f.read(this)}catch(p){return to(this.state,p),xM}}),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]!=xM)try{let p=c[f];p.write&&p.write(u[f],this)}catch(p){to(this.state,p)}if(d&&this.docView.updateSelection(!0),!O.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(a<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(a).top)-o;if(p>1||p<-1){i=i+p,r.scrollTop=i/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let s of this.state.facet(N3))s(n)}get themeClasses(){return D3+" "+(this.state.facet(Z3)?hge:fge)+" "+this.state.facet(Bb)}updateAttrs(){let t=QM(this,Hme,{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"),QM(this,e8,n);let r=this.observer.ignore(()=>{let i=C3(this.contentDOM,this.contentAttrs,n),a=C3(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(_t.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(_t.cspNonce);EO.mount(this.root,this.styleModules.concat(zrt).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,oM(this,t,n,r))}moveByGroup(t,n){return xT(this,t,oM(this,t,n,r=>Jnt(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 Ze.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return Knt(this,t,n,r)}moveVertically(t,n,r){return xT(this,t,ert(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(),nge(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==Xr.LTR==n>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Vme)||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>Grt)return Wme(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||Ume(a.isolates,r=eM(this,t))))return a.order;r||(r=eM(this,t));let i=Ant(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(()=>{wme(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"?Ze.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(Ze.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(M3(`.${r}`,t))];return n&&n.dark&&i.push(Z3.of(!0)),i}static baseTheme(t){return ZO.lowest(m0.of(M3("."+D3,t,pge)))}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}}_t.styleModule=m0;_t.inputHandler=Dme;_t.clipboardInputFilter=K9;_t.clipboardOutputFilter=J9;_t.scrollHandler=Fme;_t.focusChangeEffect=Mme;_t.perLineTextDirection=Vme;_t.exceptionSink=Zme;_t.updateListener=N3;_t.editable=Gc;_t.mouseSelectionStyle=Ime;_t.dragMovesSelection=Gme;_t.clickAddsSelectionRange=Yme;_t.decorations=F$;_t.outerDecorations=Kme;_t.atomicRanges=t8;_t.bidiIsolatedRanges=Jme;_t.scrollMargins=ege;_t.darkTheme=Z3;_t.cspNonce=ht.define({combine:e=>e.length?e[0]:""});_t.contentAttributes=e8;_t.editorAttributes=Hme;_t.lineWrapping=_t.contentAttributes.of({class:"cm-lineWrapping"});_t.announce=Tn.define();const Grt=4096,xM={};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:Xr.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new LS(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function QM(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&&j3(o,n)}return n}const Irt=ct.mac?"mac":ct.windows?"win":ct.linux?"linux":"key";function Zrt(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 Drt=ZO.default(_t.domEventHandlers({keydown(e,t){return gge(mge(t.state),e,t,"editor")}})),Nk=ht.define({enables:Drt}),kM=new WeakMap;function mge(e){let t=e.facet(Nk),n=kM.get(t);return n||kM.set(t,n=Vrt(t.reduce((r,i)=>r.concat(i),[]))),n}function iOn(e,t,n){return gge(mge(e.state),t,e,n)}let iO=null;const Mrt=4e3;function Vrt(e,t=Irt){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=>Zrt(y,t));for(let y=1;y<p.length;y++){let v=p.slice(0,y).join(" ");i(v,!0),f[v]||(f[v]={preventDefault:!0,stopPropagation:!1,run:[S=>{let x=iO={view:S,prefix:v,scope:o};return setTimeout(()=>{iO==x&&(iO=null)},Mrt),!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,V3))}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 V3=null;function gge(e,t,n,r){V3=t;let i=mnt(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+" ",age.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(),V3=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=$ge(t);return[new Rv(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return Lrt(t,n,r)}}function $ge(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Xr.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function PM(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 Lrt(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==Xr.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=$ge(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=G3(e,r,1),p=G3(e,i,-1),m=f.type==Na.Text?f:null,g=p.type==Na.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=PM(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=PM(e,i,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(S(n.from,n.to,m));{let b=m?S(n.from,null,m):x(f,!1),w=g?S(null,n.to,g):x(p,!0),Q=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&b.bottom+e.defaultLineHeight/2<w.top?Q.push(y(O,b.bottom,d,w.top)):b.bottom<w.top&&e.elementAtHeight((b.bottom+w.top)/2).type==Na.Text&&(b.bottom=w.top=(b.bottom+w.top)/2),v(b).concat(Q).concat(v(w))}function y(b,w,Q,k){return new Rv(t,b-l.left,w-l.top,Q-b,k-w)}function v({top:b,bottom:w,horizontal:Q}){let k=[];for(let T=0;T<Q.length;T+=2)k.push(y(Q[T],b,Q[T+1],w));return k}function S(b,w,Q){let k=1e9,T=-1e9,_=[];function E(C,W,N,G,D){let F=e.coordsAtPos(C,C==Q.to?-2:2),z=e.coordsAtPos(N,N==Q.from?2:-2);!F||!z||(k=Math.min(F.top,z.top,k),T=Math.max(F.bottom,z.bottom,T),D==Xr.LTR?_.push(a&&W?O:F.left,a&&G?d:z.right):_.push(!a&&G?O:z.left,!a&&W?d:F.right))}let R=b??Q.from,j=w??Q.to;for(let C of e.visibleRanges)if(C.to>R&&C.from<j)for(let W=Math.max(C.from,R),N=Math.min(C.to,j);;){let G=e.state.doc.lineAt(W);for(let D of e.bidiSpans(G)){let F=D.from+G.from,z=D.to+G.from;if(F>=N)break;z>W&&E(Math.max(F,W),b==null&&F<=R,Math.min(z,N),w==null&&z>=j,D.dir)}if(W=G.to+1,W>=N)break}return _.length==0&&E(R,b==null,j,w==null,e.textDirection),{top:k,bottom:T,horizontal:_}}function x(b,w){let Q=s.top+(w?b.top:b.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function Frt(e,t){return e.constructor==t.constructor&&e.eq(t)}class Brt{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)=>!Frt(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 yge(e){return[Ti.define(t=>new Brt(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 aOn(e={}){return[B$.of(e),Hrt,Krt,Jrt,Lme.of(!0)]}function vge(e){return e.startState.facet(B$)!=e.state.facet(B$)}const Hrt=yge({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:Ze.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=vge(e);return n&&_M(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){_M(t.state,e)},class:"cm-cursorLayer"});function _M(e,t){t.style.animationDuration=e.facet(B$).cursorBlinkRate+"ms"}const Krt=yge({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||vge(e)},class:"cm-selectionLayer"}),Jrt=ZO.highest(_t.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"}}}})),bge=Tn.define({map(e,t){return e==null?null:t.mapPos(e)}}),y0=lo.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(bge)?r.value:n,e)}}),eit=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:bge.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 oOn(){return[y0,eit]}function TM(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 tit(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 nit{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 tit(t,this.maxLength))TM(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 TM(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 L3=/x/.unicode!=null?"gu":"g",rit=new RegExp(`[\0-\b
830
830
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,L3),iit={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 ait(){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:rit,addSpecialChars:null});return(t.replaceTabs=!ait())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,L3)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,L3)),t}});function sOn(e={}){return[X1.of(e),oit()]}let RM=null;function oit(){return RM||(RM=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 nit({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 uit((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=cn.replace({widget:new cit(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 sit="•";function lit(e){return e>=32?sit:e==10?"␤":String.fromCharCode(9216+e)}class cit extends Tu{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=lit(this.code),r=t.state.phrase("Control character")+" "+(iit[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 uit 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 lOn(){return dit}const Oit=cn.line({class:"cm-activeLine"}),dit=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(Oit.range(i.from)),t=i.from)}return cn.set(n)}},{decorations:e=>e.decorations});class fit 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 cOn(e){let t=Ti.fromClass(class{constructor(n){this.view=n,this.placeholder=e?cn.set([cn.widget({widget:new fit(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,_t.contentAttributes.of({"aria-placeholder":e})]:t}const F3=2e3;function hit(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>F3||n.off>F3||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(Ze.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=P3(c.text,o,e.tabSize,!0);if(u<0)a.push(Ze.cursor(c.to));else{let O=P3(c.text,s,e.tabSize);a.push(Ze.range(c.from+u,c.from+O))}}}return a}function pit(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function XM(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>F3?-1:i==r.length?pit(e,t.clientX):XO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function mit(e,t){let n=XM(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=XM(e,i);if(!s)return r;let l=hit(e.state,n,s);return l.length?o?Ze.create(l.concat(r.ranges)):Ze.create(l):r}}:null}function uOn(e){let t=n=>n.altKey&&n.button==0;return _t.mouseSelectionStyle.of((n,r)=>t(r)?mit(n,r):null)}const git={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},$it={style:"cursor: crosshair"};function OOn(e={}){let[t,n]=git[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,_t.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?$it:null})]}const kg="-10000px";class wge{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 yit(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)||yit}}}),EM=new WeakMap,o8=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 wge(e,s8,(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=n8(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=EM.get(c))!==null&&t!==void 0?t:d.bottom-d.top,y=c.offset||bit,v=this.view.textDirection==Xr.LTR,S=d.width>r.right-r.left?v?r.left:r.right-d.width:v?Math.max(r.left,Math.min(O.left-(f?14:0)+y.x,r.right-m)):Math.min(Math.max(r.left,O.left-m+(f?14:0)-y.x),r.right-m),x=this.above[s];!l.strictSide&&(x?O.top-g-p-y.y<r.top:O.bottom+g+p+y.y>r.bottom)&&x==r.bottom-O.bottom>O.top-r.top&&(x=this.above[s]=!x);let b=(x?O.top-r.top:r.bottom-O.bottom)-p;if(b<g&&c.resize!==!1){if(b<this.view.defaultLineHeight){u.style.top=kg;continue}EM.set(c,g),u.style.height=(g=b)/a+"px"}else u.style.height&&(u.style.height="");let w=x?O.top-g-p-y.y:O.bottom+p+y.y,Q=S+m;if(c.overlap!==!0)for(let k of o)k.left<Q&&k.right>S&&k.top<w+g&&k.bottom>w&&(w=x?k.top-g-2-p:k.bottom+p+2);if(this.position=="absolute"?(u.style.top=(w-e.parent.top)/a+"px",qM(u,(S-e.parent.left)/i)):(u.style.top=w/a+"px",qM(u,S/i)),f){let k=O.left+(v?y.x:-y.x)-(S+14-7);f.style.left=k/i+"px"}c.overlap!==!0&&o.push({left:S,top:w,right:Q,bottom:w+g}),u.classList.toggle("cm-tooltip-above",x),u.classList.toggle("cm-tooltip-below",!x),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=kg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function qM(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const vit=_t.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"}}}),bit={x:0,y:0},s8=ht.define({enables:[o8,vit]}),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 wge(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 wit=s8.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 Sit{constructor(t,n,r,i,a){this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:n}=this,r=t.docView.nearest(n.target);if(!r)return;let i,a=1;if(r instanceof OO)i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let s=t.coordsAtPos(i);if(!s||n.y<s.top||n.y>s.bottom||n.x<s.left-t.defaultCharacterWidth||n.x>s.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==Xr.RTL?-1:1;a=n.x<s.left?-c:c}let o=this.source(t,i,a);if(o?.then){let s=this.pending={pos:i};o.then(l=>{this.pending==s&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>to(t.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let t=this.view.plugin(o8),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&&!xit(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:!Qit(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 xit(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 Qit(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 dOn(e,t={}){let n=Tn.define(),r=lo.define({create(){return[]},update(i,a){if(i.length&&(t.hideOnChange&&(a.docChanged||a.selection)?i=[]:t.hideOn&&(i=i.filter(o=>!t.hideOn(a,o))),a.docChanged)){let o=[];for(let s of i){let l=a.changes.mapPos(s.pos,-1,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(kit)&&(i=[]);return i},provide:i=>FS.from(i)});return{active:r,extension:[r,Ti.define(i=>new Sit(i,e,r,n,t.hoverTime||300)),wit]}}function Sge(e,t){let n=e.plugin(o8);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const kit=Tn.define(),jM=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 fOn(e,t){let n=e.plugin(xge),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const xge=Ti.fromClass(class{constructor(e){this.input=e.state.facet(AM),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(jM);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(jM);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(AM);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=>_t.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=CM(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=CM(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 CM(e){let t=e.nextSibling;return e.remove(),t}const AM=ht.define({enables:xge});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(),Pit=ht.define(),_it={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>_n.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},F0=ht.define();function Tit(e){return[Qge(),F0.of({..._it,...e})]}const zM=ht.define({combine:e=>e.some(t=>t)});function Qge(e){return[Rit]}const Rit=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 WM(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(zM),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(zM)!=!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=_n.iter(this.view.state.facet(E1),this.view.viewport.from),r=[],i=this.gutters.map(a=>new Xit(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){B3(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){B3(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||!_n.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 WM(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=>_t.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==Xr.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function UM(e){return Array.isArray(e)?e:[e]}function B3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Xit{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=_n.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 kge(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=[];B3(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(Pit)){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 WM{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=UM(n.markers(t)),n.initialSpacer&&(this.spacer=new kge(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=UM(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!_n.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 kge{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":""),Eit(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 Eit(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 qit=ht.define(),jit=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 Cit=F0.compute([Fh],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(qit)},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(jit)){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,NM(t.state.doc.lines)))},updateSpacer(t,n){let r=RT(n.view,NM(n.view.state.doc.lines));return r==t.number?t:new TT(r)},domEventHandlers:e.facet(Fh).domEventHandlers}));function hOn(e={}){return[Fh.of(e),Qge(),Cit]}function NM(e){let t=9;for(;t<e;)t=t*10+9;return t}const Ait=new class extends hu{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},zit=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(Ait.range(i)))}return _n.of(t)});function pOn(){return zit}let Uit=0;class it{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=Uit++}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 Wit=0;class BS{constructor(t){this.name=t,this.instances=[],this.id=Wit++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&Nit(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=Yit(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 Nit(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function Yit(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 zn(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 Pge.add(t)}const Pge=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 _ge(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 Git(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Iit(e,t,n,r=0,i=e.length){let a=new Zit(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class Zit{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=Dit(t)||HS.empty,O=Git(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,x=Math.max(n,y),b=Math.min(r,S);if(x<b&&m)for(;t.from<b&&(this.highlightRange(t,x,b,i,a),this.startSpan(Math.min(b,t.to),c),!(t.to>=S||!t.nextSibling())););if(!v||S>r)break;y=v.to+s,y>n&&(this.highlightRange(f.cursor(),Math.max(n,v.from+s),Math.min(r,y),"",p),this.startSpan(Math.min(r,y),c))}m&&t.parent()}else if(t.firstChild()){d&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,a),this.startSpan(Math.min(r,t.to),c)}while(t.nextSibling());t.parent()}}}function Dit(e){let t=e.type.prop(Pge);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const tt=it.define,ew=tt(),Hu=tt(),YM=tt(Hu),GM=tt(Hu),Ku=tt(),tw=tt(Ku),XT=tt(Ku),Ql=tt(),Od=tt(Ql),yl=tt(),vl=tt(),H3=tt(),Pg=tt(H3),nw=tt(),P={comment:ew,lineComment:tt(ew),blockComment:tt(ew),docComment:tt(ew),name:Hu,variableName:tt(Hu),typeName:YM,tagName:tt(YM),propertyName:GM,attributeName:tt(GM),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:H3,separator:tt(H3),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)}_ge([{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 l8=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 Fn(this)}}),this.parser=n,this.extension=[CO.of(this),Nn.languageData.of((a,o,s)=>{let l=IM(a,o,s),c=l.type.prop(fO);if(!c)return[];let u=a.facet(c),O=l.type.prop(l8);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 IM(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(Fn(t),0),r}get allowsNesting(){return!0}}Ao.setState=Tn.define();function IM(e,t,n){let r=e.facet(CO),i=Fn(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 Xn extends Ao{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=Gk(t.languageData);return new Xn(n,t.parser.configure({props:[fO.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Xn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Fn(e){let t=e.field(Ao.state,!1);return t?t.tree:hn.empty}class Mit{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 Mit(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=ZM(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=ZM(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($i.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 ZM(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=lo.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 Tge=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Tge=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,Vit=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=Tge(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=>to(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),CO=ht.define({combine(e){return e.length?e[0]:null},enables:e=>[Ao.state,Vit,_t.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 Lit=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 Fit(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 Bit(e,t){e instanceof Nn&&(e=new Rge(e));for(let r of e.state.facet(Lit)){let i=r(e,t);if(i!==void 0)return i}let n=Fn(e.state);return n.length>=t?Hit(e,n,t):null}class Rge{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 Nr=new Gt;function Hit(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 Xge(r,e,n)}function Xge(e,t,n){for(let r=e;r;r=r.next){let i=Jit(r.node);if(i)return i(c8.create(t,n,r))}return 0}function Kit(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Jit(e){let t=e.type.prop(Nr);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=>Ege(o,!0,1,void 0,a&&!Kit(o)?i.from:void 0)}return e.parent==null?eat:null}function eat(){return 0}class c8 extends Rge{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 c8(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(tat(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Xge(this.context.next,this.base,this.pos)}}function tat(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function nat(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=>Ege(r,t,n,e)}function Ege(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?nat(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const u8=e=>e.baseIndent;function Mr({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const rat=200;function $On(){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+rat)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=Bit(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],f=Fit(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 qge=ht.define(),jr=new Gt;function Sa(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 iat(e,t,n){let r=Fn(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(a&&s.from<t)break;let l=s.type.prop(jr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!aat(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function aat(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(qge)){let i=r(e,t,n);if(i)return i}return iat(e,t,n)}function jge(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=Tn.define({map:jge}),Xv=Tn.define({map:jge});function Cge(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=lo.define({create(){return cn.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Zk)&&!oat(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Uge),i=r?cn.replace({widget:new dat(r(t.state,n.value))}):DM;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=>_t.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(DM.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 oat(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function Age(e,t){return e.field(wf,!1)?t:t.concat(Tn.appendConfig.of(Wge()))}const sat=e=>{for(let t of Cge(e)){let n=JS(e.state,t.from,t.to);if(n)return e.dispatch({effects:Age(e.state,[Zk.of(n),zge(e,n)])}),!0}return!1},lat=e=>{if(!e.state.field(wf,!1))return!1;let t=[];for(let n of Cge(e)){let r=ex(e.state,n.from,n.to);r&&t.push(Xv.of(r),zge(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function zge(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return _t.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const cat=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:Age(e.state,n)}),!!n.length},uat=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},yOn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:sat},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:lat},{key:"Ctrl-Alt-[",run:cat},{key:"Ctrl-Alt-]",run:uat}],Oat={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Uge=ht.define({combine(e){return Nm(e,Oat)}});function Wge(e){return[wf,hat]}function Nge(e,t){let{state:n}=e,r=n.facet(Uge),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 DM=cn.replace({widget:new class extends Tu{toDOM(e){return Nge(e,null)}}});class dat extends Tu{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Nge(t,this.value)}}const fat={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 vOn(e={}){let t={...fat,...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)||Fn(o.startState)!=Fn(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,Tit({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||_n.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}}}),Wge()]}const hat=_t.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=_ge(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 K3=ht.define(),Yge=ht.define({combine(e){return e.length?[e[0]]:null}});function CT(e){let t=e.facet(K3);return t.length?t:e.facet(Yge)}function bOn(e,t){let n=[mat],r;return e instanceof Dk&&(e.module&&n.push(_t.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Yge.of(e)):r?n.push(K3.computeN([_t.darkTheme],i=>i.facet(_t.darkTheme)==(r=="dark")?[e]:[])):n.push(K3.of(e)),n}class pat{constructor(t){this.markCache=Object.create(null),this.tree=Fn(t.state),this.decorations=this.buildDeco(t,CT(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Fn(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)Iit(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 mat=ZO.high(Ti.fromClass(pat,{decorations:e=>e.decorations})),wOn=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"}]),gat=_t.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Gge=1e4,Ige="()[]{}",Zge=ht.define({combine(e){return Nm(e,{afterCursor:!0,brackets:Ige,maxScanDistance:Gge,renderMatch:vat})}}),$at=cn.mark({class:"cm-matchingBracket"}),yat=cn.mark({class:"cm-nonmatchingBracket"});function vat(e){let t=[],n=e.matched?$at:yat;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 bat=lo.define({create(){return cn.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Zge);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=>_t.decorations.from(e)}),wat=[bat,gat];function SOn(e={}){return[Zge.of(e),wat]}const O8=new Gt;function J3(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 eC(e){let t=e.type.prop(O8);return t?t(e.node):e}function rw(e,t,n,r={}){let i=r.maxScanDistance||Gge,a=r.brackets||Ige,o=Fn(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=J3(l.type,n,a);if(c&&l.from<l.to){let u=eC(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return Sat(e,t,n,l,u,c,a)}}return xat(e,t,n,o,s.type,i,a)}function Sat(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=eC(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(J3(u.type,n,o))c++;else if(J3(u.type,-n,o)){if(c==0){let O=eC(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 xat(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 MM(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 Dge{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=MM(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:MM(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 Qat(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||kat,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||f8,mergeTokens:e.mergeTokens!==!1}}function kat(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 VM=new WeakMap;class ze extends Ao{constructor(t){let n=Gk(t.languageData),r=Qat(t),i,a=new class extends Ak{createParse(o,s,l){return new _at(i,o,s,l)}};super(n,a,[],t.name),this.topNode=Xat(n,this),i=this,this.streamParser=r,this.stateAfter=new Gt({perNode:!0}),this.tokenTable=t.tokenTable?new Fge(r.tokenTable):Rat}static define(t){return new ze(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=VM.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=d8(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 Dge(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)Vge(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&&VM.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function d8(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&&d8(e,s,l,r,i);if(c)return c}return null}function Mge(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=Mge(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 Pat(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&&d8(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=Mge(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 _at=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}=Pat(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 Dge(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=Vge(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:Tat,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 Vge(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 f8=Object.create(null),H$=[$i.none],Tat=new Wm(H$),LM=[],FM=Object.create(null),Lge=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"]])Lge[e]=Bge(f8,t);class Fge{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Lge)}resolve(t){return t?this.table[t]||(this.table[t]=Bge(this.extra,t)):0}}const Rat=new Fge(f8);function AT(e,t){LM.indexOf(e)>-1||(LM.push(e),console.warn(t))}function Bge(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=FM[i];if(a)return a.id;let o=FM[i]=$i.define({id:H$.length,name:r,props:[zn({[r]:n})]});return H$.push(o),o.id}function Xat(e,t){let n=$i.define({id:H$.length,name:"Document",props:[fO.add(()=>e),Nr.add(()=>r=>t.getIndent(r))],top:!0});return H$.push(n),n}Xr.RTL,Xr.LTR;function _e(e){return new wn(ze.define(e))}function Yu(e){return ve(()=>Promise.resolve().then(()=>tpt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Eat=[$e.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>NL),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(()=>NL),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(()=>mlt),void 0,import.meta.url).then(e=>e.css())}}),$e.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-C866kR_k.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(()=>sct),void 0,import.meta.url).then(e=>e.html())}}),$e.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>apt),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(()=>dut),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(()=>_ct),void 0,import.meta.url).then(e=>e.less())}}),$e.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>Zgt),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(()=>gct),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(()=>bgt),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(()=>Zft),void 0,import.meta.url).then(e=>e.python())}}),$e.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>Qpt),void 0,import.meta.url).then(e=>e.rust())}}),$e.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>tL),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),$e.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>tL),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(()=>Vgt),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(()=>dht),void 0,import.meta.url).then(e=>e.xml())}}),$e.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-CO7sxKWb.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(()=>wyt),void 0,import.meta.url).then(e=>_e(e.apl))}}),$e.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ve(()=>Promise.resolve().then(()=>Syt),void 0,import.meta.url).then(e=>_e(e.asciiArmor))}}),$e.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ve(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>_e(e.asn1({})))}}),$e.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>_yt),void 0,import.meta.url).then(e=>_e(e.asterisk))}}),$e.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>Ryt),void 0,import.meta.url).then(e=>_e(e.brainfuck))}}),$e.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>ivt),void 0,import.meta.url).then(e=>_e(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=>_e(e.csharp))}}),$e.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>_e(e.clojure))}}),$e.of({name:"ClojureScript",extensions:["cljs"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>_e(e.clojure))}}),$e.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ve(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>_e(e.gss))}}),$e.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ve(()=>Promise.resolve().then(()=>Fyt),void 0,import.meta.url).then(e=>_e(e.cmake))}}),$e.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ve(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>_e(e.coffeeScript))}}),$e.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ve(()=>Promise.resolve().then(()=>Svt),void 0,import.meta.url).then(e=>_e(e.commonLisp))}}),$e.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>Yvt),void 0,import.meta.url).then(e=>_e(e.cypher))}}),$e.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ve(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>_e(e.cython))}}),$e.of({name:"Crystal",extensions:["cr"],load(){return ve(()=>Promise.resolve().then(()=>Cvt),void 0,import.meta.url).then(e=>_e(e.crystal))}}),$e.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>Lvt),void 0,import.meta.url).then(e=>_e(e.d))}}),$e.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>_e(e.dart))}}),$e.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>Fvt),void 0,import.meta.url).then(e=>_e(e.diff))}}),$e.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>lbt),void 0,import.meta.url).then(e=>_e(e.dockerFile))}}),$e.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>Obt),void 0,import.meta.url).then(e=>_e(e.dtd))}}),$e.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>mbt),void 0,import.meta.url).then(e=>_e(e.dylan))}}),$e.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>gbt),void 0,import.meta.url).then(e=>_e(e.ebnf))}}),$e.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>Qbt),void 0,import.meta.url).then(e=>_e(e.ecl))}}),$e.of({name:"edn",extensions:["edn"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>_e(e.clojure))}}),$e.of({name:"Eiffel",extensions:["e"],load(){return ve(()=>Promise.resolve().then(()=>Xbt),void 0,import.meta.url).then(e=>_e(e.eiffel))}}),$e.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>Gbt),void 0,import.meta.url).then(e=>_e(e.elm))}}),$e.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>dwt),void 0,import.meta.url).then(e=>_e(e.erlang))}}),$e.of({name:"Esper",load(){return ve(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>_e(e.esper))}}),$e.of({name:"Factor",extensions:["factor"],load(){return ve(()=>Promise.resolve().then(()=>fwt),void 0,import.meta.url).then(e=>_e(e.factor))}}),$e.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>$wt),void 0,import.meta.url).then(e=>_e(e.fcl))}}),$e.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>bwt),void 0,import.meta.url).then(e=>_e(e.forth))}}),$e.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ve(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>_e(e.fortran))}}),$e.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>_e(e.fSharp))}}),$e.of({name:"Gas",extensions:["s"],load(){return ve(()=>Promise.resolve().then(()=>Rwt),void 0,import.meta.url).then(e=>_e(e.gas))}}),$e.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Xwt),void 0,import.meta.url).then(e=>_e(e.gherkin))}}),$e.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ve(()=>Promise.resolve().then(()=>Gwt),void 0,import.meta.url).then(e=>_e(e.groovy))}}),$e.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>Fwt),void 0,import.meta.url).then(e=>_e(e.haskell))}}),$e.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>cB),void 0,import.meta.url).then(e=>_e(e.haxe))}}),$e.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>cB),void 0,import.meta.url).then(e=>_e(e.hxml))}}),$e.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>$1t),void 0,import.meta.url).then(e=>_e(e.http))}}),$e.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>Q1t),void 0,import.meta.url).then(e=>_e(e.idl))}}),$e.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ve(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>_e(e.jsonld))}}),$e.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ve(()=>Promise.resolve().then(()=>T1t),void 0,import.meta.url).then(e=>_e(e.jinja2))}}),$e.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>eSt),void 0,import.meta.url).then(e=>_e(e.julia))}}),$e.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>_e(e.kotlin))}}),$e.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>iSt),void 0,import.meta.url).then(e=>_e(e.liveScript))}}),$e.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>dSt),void 0,import.meta.url).then(e=>_e(e.lua))}}),$e.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>CSt),void 0,import.meta.url).then(e=>_e(e.mirc))}}),$e.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ve(()=>Promise.resolve().then(()=>vSt),void 0,import.meta.url).then(e=>_e(e.mathematica))}}),$e.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>DSt),void 0,import.meta.url).then(e=>_e(e.modelica))}}),$e.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>sxt),void 0,import.meta.url).then(e=>_e(e.mumps))}}),$e.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>ESt),void 0,import.meta.url).then(e=>_e(e.mbox))}}),$e.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>dxt),void 0,import.meta.url).then(e=>_e(e.nginx))}}),$e.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>fxt),void 0,import.meta.url).then(e=>_e(e.nsis))}}),$e.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>hxt),void 0,import.meta.url).then(e=>_e(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=>_e(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=>_e(e.objectiveCpp))}}),$e.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>_e(e.oCaml))}}),$e.of({name:"Octave",extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>Qxt),void 0,import.meta.url).then(e=>_e(e.octave))}}),$e.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>zxt),void 0,import.meta.url).then(e=>_e(e.oz))}}),$e.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>Ixt),void 0,import.meta.url).then(e=>_e(e.pascal))}}),$e.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>Zxt),void 0,import.meta.url).then(e=>_e(e.perl))}}),$e.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>Vxt),void 0,import.meta.url).then(e=>_e(e.pig))}}),$e.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>cQt),void 0,import.meta.url).then(e=>_e(e.powerShell))}}),$e.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ve(()=>Promise.resolve().then(()=>uQt),void 0,import.meta.url).then(e=>_e(e.properties))}}),$e.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>pQt),void 0,import.meta.url).then(e=>_e(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=>_e(e.pug))}}),$e.of({name:"Puppet",extensions:["pp"],load(){return ve(()=>Promise.resolve().then(()=>$Qt),void 0,import.meta.url).then(e=>_e(e.puppet))}}),$e.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>kQt),void 0,import.meta.url).then(e=>_e(e.q))}}),$e.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ve(()=>Promise.resolve().then(()=>qQt),void 0,import.meta.url).then(e=>_e(e.r))}}),$e.of({name:"RPM Changes",load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>_e(e.rpmChanges))}}),$e.of({name:"RPM Spec",extensions:["spec"],load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>_e(e.rpmSpec))}}),$e.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ve(()=>Promise.resolve().then(()=>GQt),void 0,import.meta.url).then(e=>_e(e.ruby))}}),$e.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>MQt),void 0,import.meta.url).then(e=>_e(e.sas))}}),$e.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>_e(e.scala))}}),$e.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>akt),void 0,import.meta.url).then(e=>_e(e.scheme))}}),$e.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ve(()=>Promise.resolve().then(()=>ckt),void 0,import.meta.url).then(e=>_e(e.shell))}}),$e.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>hkt),void 0,import.meta.url).then(e=>_e(e.sieve))}}),$e.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>gkt),void 0,import.meta.url).then(e=>_e(e.smalltalk))}}),$e.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>xkt),void 0,import.meta.url).then(e=>_e(e.solr))}}),$e.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>_e(e.sml))}}),$e.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ve(()=>Promise.resolve().then(()=>Xkt),void 0,import.meta.url).then(e=>_e(e.sparql))}}),$e.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>Ekt),void 0,import.meta.url).then(e=>_e(e.spreadsheet))}}),$e.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>_e(e.squirrel))}}),$e.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>ePt),void 0,import.meta.url).then(e=>_e(e.stylus))}}),$e.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>vPt),void 0,import.meta.url).then(e=>_e(e.swift))}}),$e.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>eH),void 0,import.meta.url).then(e=>_e(e.stex))}}),$e.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ve(()=>Promise.resolve().then(()=>eH),void 0,import.meta.url).then(e=>_e(e.stex))}}),$e.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>vH),void 0,import.meta.url).then(e=>_e(e.verilog))}}),$e.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>xPt),void 0,import.meta.url).then(e=>_e(e.tcl))}}),$e.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>_Pt),void 0,import.meta.url).then(e=>_e(e.textile))}}),$e.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>FPt),void 0,import.meta.url).then(e=>_e(e.tiddlyWiki))}}),$e.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>n_t),void 0,import.meta.url).then(e=>_e(e.tiki))}}),$e.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>r_t),void 0,import.meta.url).then(e=>_e(e.toml))}}),$e.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ve(()=>Promise.resolve().then(()=>o_t),void 0,import.meta.url).then(e=>_e(e.troff))}}),$e.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>x_t),void 0,import.meta.url).then(e=>_e(e.ttcn))}}),$e.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ve(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>_e(e.ttcnCfg))}}),$e.of({name:"Turtle",extensions:["ttl"],load(){return ve(()=>Promise.resolve().then(()=>P_t),void 0,import.meta.url).then(e=>_e(e.turtle))}}),$e.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>v5t),void 0,import.meta.url).then(e=>_e(e.webIDL))}}),$e.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>G_t),void 0,import.meta.url).then(e=>_e(e.vb))}}),$e.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>Z_t),void 0,import.meta.url).then(e=>_e(e.vbScript))}}),$e.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>V_t),void 0,import.meta.url).then(e=>_e(e.velocity))}}),$e.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>vH),void 0,import.meta.url).then(e=>_e(e.verilog))}}),$e.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>n5t),void 0,import.meta.url).then(e=>_e(e.vhdl))}}),$e.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>R5t),void 0,import.meta.url).then(e=>_e(e.xQuery))}}),$e.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>N5t),void 0,import.meta.url).then(e=>_e(e.yacas))}}),$e.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>D5t),void 0,import.meta.url).then(e=>_e(e.z80))}}),$e.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>_e(e.mscgen))}}),$e.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>_e(e.xu))}}),$e.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>_e(e.msgenny))}}),$e.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>t0t),void 0,import.meta.url).then(e=>e.vue())}}),$e.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>v0t),void 0,import.meta.url).then(e=>e.angular())}})];class h8{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=Fn(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(Hge(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 BM(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 qat(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=BM(t)+BM(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+$/]:qat(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=Fn(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 HM{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 Hge(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 p8=Zf.define();function jat(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:Ze.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const KM=new WeakMap;function Cat(e){if(!Array.isArray(e))return e;let t=KM.get(e);return t||KM.set(e,t=Ev(e)),t}const tx=Tn.define(),K$=Tn.define();class Aat{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),x=S==t.length?0:-100;if(v!=n[0])if(v==r[0])x+=-200;else return null;return this.ret(x,[0,S])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let v=0,S=Math.min(t.length,200);v<S&&c<l;){let x=Ro(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=Yc(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,S=Math.min(t.length,200),x=0;v<S&&O<l;){let b=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,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=lme(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||Q==1&&g||x==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),x=Q,v+=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 zat{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:Uat,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=>JM(t(r),n(r)),optionClass:(t,n)=>r=>JM(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function JM(e,t){return e?t?e+" "+t:e:t}function Uat(e,t,n,r,i,a){let o=e.textDirection==Xr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,f)?s=!1:!s&&f<Math.min(p,d)&&(s=!0),p<=(s?d:f))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:f);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Wat(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 Nat{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=Wat(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=>to(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&Gat(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 Yat(e,t){return n=>new Nat(n,e,t)}function Gat(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 eV(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Iat(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 HM(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new zat(O):new Aat(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 HM(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):eV(c.completion)>eV(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,tV(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=Iat(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,tV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Fat,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(Vat,"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(Cat)).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(m8));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Zat(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(Jge)&&(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?Dat:Mat}}function Zat(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 Dat={"aria-autocomplete":"list"},Mat={};function tV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Vat=[];function Kge(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(p8);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=Kge(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(m8))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 Lat(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 h8(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 Lat(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Hge(e,!0).test(i)}const m8=Tn.define({map(e,t){return e.map(n=>n.map(t))}}),Jge=Tn.define(),Ka=lo.define({create(){return nx.start()},update(e,t){return e.update(t)},provide:e=>[s8.from(e,t=>t.tooltip),_t.contentAttributes.from(e,t=>t.attrs)]});function g8(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ka).active.find(i=>i.source==t.source);return r instanceof hp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},jat(e.state,n,r.from,r.to)),{annotations:p8.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Fat=Yat(Ka,g8);function iw(e,t="option"){return n=>{let r=n.state.field(Ka,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ni).interactionDelay)return!1;let i=1,a;t=="page"&&(a=Sge(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:Jge.of(s)}),!0}}const Bat=e=>{let t=e.state.field(Ka,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ni).interactionDelay?!1:g8(e,t.open.options[t.open.selected])},nV=e=>e.state.field(Ka,!1)?(e.dispatch({effects:tx.of(!0)}),!0):!1,Hat=e=>{let t=e.state.field(Ka,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:K$.of(null)}),!0)};class Kat{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Jat=50,eot=1e3,tot=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(Ka).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ka),n=e.state.facet(Ni);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ka)==t)return;let r=e.transactions.some(a=>{let o=Kge(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>Jat&&Date.now()-o.time>eot){for(let s of o.context.abortListeners)try{s()}catch(l){to(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(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(Ka);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ni).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=ef(t),r=new h8(t,n,e.explicit,this.view),i=new Kat(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)}),to(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(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(Ka);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=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:m8.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ka,!1);if(t&&t.tooltip&&this.view.state.facet(Ni).closeOnBlur){let n=t.open&&Sge(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}}}),not=typeof navigator=="object"&&/Win/.test(navigator.platform),rot=ZO.highest(_t.domEventHandlers({keydown(e,t){let n=t.state.field(Ka,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(not&&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&&g8(t,r),!1}})),e0e=_t.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 iot{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class $8{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 $8(this.field,n,r)}}class y8{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 $8(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 iot(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 y8(r,i)}}let aot=cn.widget({widget:new class extends Tu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),oot=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?aot:oot).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=Tn.define({map(e,t){return e&&e.map(t)}}),sot=Tn.define(),J$=lo.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(qv))return n.value;if(n.is(sot)&&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=>_t.decorations.from(e,t=>t?t.deco:cn.none)});function v8(e,t){return Ze.create(e.filter(n=>n.field==t).map(n=>Ze.range(n.from,n.to)))}function lot(e){let t=y8.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:Ln.of(o)},scrollIntoView:!0,annotations:r?[p8.of(r),Ki.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=v8(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(Tn.appendConfig.of([J$,fot,hot,e0e]))}n.dispatch(n.state.update(c))}}function t0e(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:v8(r.ranges,i),effects:qv.of(a?null:new Ym(r.ranges,i)),scrollIntoView:!0})),!0}}const cot=({state:e,dispatch:t})=>e.field(J$,!1)?(t(e.update({effects:qv.of(null)})),!0):!1,uot=t0e(1),Oot=t0e(-1),dot=[{key:"Tab",run:uot,shift:Oot},{key:"Escape",run:cot}],rV=ht.define({combine(e){return e.length?e[0]:dot}}),fot=ZO.highest(Nk.compute([rV],e=>e.facet(rV)));function Sr(e,t){return Object.assign(Object.assign({},t),{apply:lot(e)})}const hot=_t.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:v8(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=Tn.define({map(e,t){let n=t.mapPos(e,-1,Hi.TrackAfter);return n??void 0}}),b8=new class extends mf{};b8.startSide=1;b8.endSide=-1;const n0e=lo.define({create(){return _n.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:[b8.range(n.value,n.value+1)]}));return e}});function QOn(){return[mot,n0e]}const UT="()[]{}<>«»»«[]{}";function r0e(e){for(let t=0;t<UT.length;t+=2)if(UT.charCodeAt(t)==e)return UT.charAt(t+1);return lme(e<128?e:e+1)}function i0e(e,t){return e.languageDataAt("closeBrackets",t)[0]||ey}const pot=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),mot=_t.inputHandler.of((e,t,n,r)=>{if((pot?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=$ot(e.state,r);return a?(e.dispatch(a),!0):!1}),got=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=i0e(e,e.selection.main.head).brackets||ey.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=yot(e.doc,o.head);for(let l of r)if(l==s&&Vk(e.doc,o.head)==r0e(Ro(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ze.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},kOn=[{key:"Backspace",run:got}];function $ot(e,t){let n=i0e(e,e.selection.main.head),r=n.brackets||ey.brackets;for(let i of r){let a=r0e(Ro(i,0));if(t==i)return a==i?wot(e,i,r.indexOf(i+i+i)>-1,n):vot(e,i,a,n.before||ey.before);if(t==a&&a0e(e,e.selection.main.from))return bot(e,i,a)}return null}function a0e(e,t){let n=!1;return e.field(n0e).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 yot(e,t){let n=e.sliceString(t-2,t);return Yc(Ro(n,0))==n.length?n:n.slice(1)}function vot(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:Ze.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:Ze.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function bot(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:Ze.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function wot(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:Ze.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=Vk(e.doc,l),u;if(c==t){if(iV(e,l))return{changes:{insert:t+t,from:l},effects:Wd.of(l+t.length),range:Ze.cursor(l+t.length)};if(a0e(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:Ze.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=aV(e,l-2*t.length,i))>-1&&iV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Wd.of(l+t.length),range:Ze.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ms.Word&&aV(e,l,i)>-1&&!Sot(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Wd.of(l+t.length),range:Ze.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function iV(e,t){let n=Fn(e).resolveInner(t+1);return n.parent&&n.from==t}function Sot(e,t,n,r){let i=Fn(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 aV(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 POn(e={}){return[rot,Ka,Ni.of(e),tot,Qot,e0e]}const xot=[{key:"Ctrl-Space",run:nV},{mac:"Alt-`",run:nV},{key:"Escape",run:Hat},{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:Bat}],Qot=ZO.highest(Nk.computeN([Ni],e=>e.facet(Ni).defaultKeymap?[xot]:[]));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($i.none,i,a,o,this.hashProp)})}}var Ve;(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"})(Ve||(Ve={}));class kot{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Pot=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 oV(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==Ve.OrderedList?x8:S8)(n,t,!1);return r>0&&(e.type!=Ve.BulletList||w8(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const o0e={[Ve.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(bn(Ve.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)},[Ve.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ve.OrderedList]:oV,[Ve.BulletList]:oV,[Ve.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 sV(e,t,n){for(;t>n&&Ts(e.charCodeAt(t-1));)t--;return t}function s0e(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 l0e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function w8(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&&O0e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(p0e.SetextHeading)>-1||r<3?-1:1}function c0e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function S8(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||c0e(t,Ve.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function x8(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&&!c0e(t,Ve.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function u0e(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 O0e(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 tC=/^[ \t]*$/,d0e=/-->/,f0e=/\?>/,nC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,d0e],[/^\s*<\?/,f0e],[/^\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,tC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,tC]];function h0e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=nC.length-(n?1:0);i<a;i++)if(nC[i][0].test(r))return i;return-1}function lV(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==Ve.CodeText?e[r].to=n:e.push(bn(Ve.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==Ve.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!=Ve.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ve.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=s0e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=sV(t.text,t.text.length,o),l=[bn(Ve.CodeMark,r,r+a)];o<s&&l.push(bn(Ve.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(Ve.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(Ve.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=l0e(t);return n<0?!1:(e.startContext(Ve.Blockquote,t.pos),e.addNode(Ve.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(w8(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ve.HorizontalRule,n),!0},BulletList(e,t){let n=S8(t,e,!1);if(n<0)return!1;e.block.type!=Ve.BulletList&&e.startContext(Ve.BulletList,t.basePos,t.next);let r=lV(t,t.pos+1);return e.startContext(Ve.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ve.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=x8(t,e,!1);if(n<0)return!1;e.block.type!=Ve.OrderedList&&e.startContext(Ve.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=lV(t,t.pos+n);return e.startContext(Ve.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ve.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=u0e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=sV(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(Ve.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ve.HeaderMark,o-r,a-r);let l=s.finish(Ve.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=h0e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=nC[n][1],a=[],o=i!=tC;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==d0e?Ve.CommentBlock:i==f0e?Ve.ProcessingInstructionBlock:Ve.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class _ot{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 Dge(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=Vge(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:Tat,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 Vge(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 f8=Object.create(null),H$=[$i.none],Tat=new Wm(H$),LM=[],FM=Object.create(null),Lge=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"]])Lge[e]=Bge(f8,t);class Fge{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Lge)}resolve(t){return t?this.table[t]||(this.table[t]=Bge(this.extra,t)):0}}const Rat=new Fge(f8);function AT(e,t){LM.indexOf(e)>-1||(LM.push(e),console.warn(t))}function Bge(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=FM[i];if(a)return a.id;let o=FM[i]=$i.define({id:H$.length,name:r,props:[zn({[r]:n})]});return H$.push(o),o.id}function Xat(e,t){let n=$i.define({id:H$.length,name:"Document",props:[fO.add(()=>e),Nr.add(()=>r=>t.getIndent(r))],top:!0});return H$.push(n),n}Xr.RTL,Xr.LTR;function _e(e){return new wn(ze.define(e))}function Yu(e){return ve(()=>Promise.resolve().then(()=>tpt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Eat=[$e.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>NL),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(()=>NL),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(()=>mlt),void 0,import.meta.url).then(e=>e.css())}}),$e.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-BUDP0pmc.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(()=>sct),void 0,import.meta.url).then(e=>e.html())}}),$e.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>apt),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(()=>dut),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(()=>_ct),void 0,import.meta.url).then(e=>e.less())}}),$e.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>Zgt),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(()=>gct),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(()=>bgt),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(()=>Zft),void 0,import.meta.url).then(e=>e.python())}}),$e.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>Qpt),void 0,import.meta.url).then(e=>e.rust())}}),$e.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>tL),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),$e.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>tL),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(()=>Vgt),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(()=>dht),void 0,import.meta.url).then(e=>e.xml())}}),$e.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-CSR2j15s.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(()=>wyt),void 0,import.meta.url).then(e=>_e(e.apl))}}),$e.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ve(()=>Promise.resolve().then(()=>Syt),void 0,import.meta.url).then(e=>_e(e.asciiArmor))}}),$e.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ve(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>_e(e.asn1({})))}}),$e.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>_yt),void 0,import.meta.url).then(e=>_e(e.asterisk))}}),$e.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>Ryt),void 0,import.meta.url).then(e=>_e(e.brainfuck))}}),$e.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>ivt),void 0,import.meta.url).then(e=>_e(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=>_e(e.csharp))}}),$e.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>_e(e.clojure))}}),$e.of({name:"ClojureScript",extensions:["cljs"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>_e(e.clojure))}}),$e.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ve(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>_e(e.gss))}}),$e.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ve(()=>Promise.resolve().then(()=>Fyt),void 0,import.meta.url).then(e=>_e(e.cmake))}}),$e.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ve(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>_e(e.coffeeScript))}}),$e.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ve(()=>Promise.resolve().then(()=>Svt),void 0,import.meta.url).then(e=>_e(e.commonLisp))}}),$e.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>Yvt),void 0,import.meta.url).then(e=>_e(e.cypher))}}),$e.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ve(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>_e(e.cython))}}),$e.of({name:"Crystal",extensions:["cr"],load(){return ve(()=>Promise.resolve().then(()=>Cvt),void 0,import.meta.url).then(e=>_e(e.crystal))}}),$e.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>Lvt),void 0,import.meta.url).then(e=>_e(e.d))}}),$e.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>_e(e.dart))}}),$e.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>Fvt),void 0,import.meta.url).then(e=>_e(e.diff))}}),$e.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>lbt),void 0,import.meta.url).then(e=>_e(e.dockerFile))}}),$e.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>Obt),void 0,import.meta.url).then(e=>_e(e.dtd))}}),$e.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>mbt),void 0,import.meta.url).then(e=>_e(e.dylan))}}),$e.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>gbt),void 0,import.meta.url).then(e=>_e(e.ebnf))}}),$e.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>Qbt),void 0,import.meta.url).then(e=>_e(e.ecl))}}),$e.of({name:"edn",extensions:["edn"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>_e(e.clojure))}}),$e.of({name:"Eiffel",extensions:["e"],load(){return ve(()=>Promise.resolve().then(()=>Xbt),void 0,import.meta.url).then(e=>_e(e.eiffel))}}),$e.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>Gbt),void 0,import.meta.url).then(e=>_e(e.elm))}}),$e.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>dwt),void 0,import.meta.url).then(e=>_e(e.erlang))}}),$e.of({name:"Esper",load(){return ve(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>_e(e.esper))}}),$e.of({name:"Factor",extensions:["factor"],load(){return ve(()=>Promise.resolve().then(()=>fwt),void 0,import.meta.url).then(e=>_e(e.factor))}}),$e.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>$wt),void 0,import.meta.url).then(e=>_e(e.fcl))}}),$e.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>bwt),void 0,import.meta.url).then(e=>_e(e.forth))}}),$e.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ve(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>_e(e.fortran))}}),$e.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>_e(e.fSharp))}}),$e.of({name:"Gas",extensions:["s"],load(){return ve(()=>Promise.resolve().then(()=>Rwt),void 0,import.meta.url).then(e=>_e(e.gas))}}),$e.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Xwt),void 0,import.meta.url).then(e=>_e(e.gherkin))}}),$e.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ve(()=>Promise.resolve().then(()=>Gwt),void 0,import.meta.url).then(e=>_e(e.groovy))}}),$e.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>Fwt),void 0,import.meta.url).then(e=>_e(e.haskell))}}),$e.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>cB),void 0,import.meta.url).then(e=>_e(e.haxe))}}),$e.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>cB),void 0,import.meta.url).then(e=>_e(e.hxml))}}),$e.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>$1t),void 0,import.meta.url).then(e=>_e(e.http))}}),$e.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>Q1t),void 0,import.meta.url).then(e=>_e(e.idl))}}),$e.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ve(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>_e(e.jsonld))}}),$e.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ve(()=>Promise.resolve().then(()=>T1t),void 0,import.meta.url).then(e=>_e(e.jinja2))}}),$e.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>eSt),void 0,import.meta.url).then(e=>_e(e.julia))}}),$e.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>_e(e.kotlin))}}),$e.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>iSt),void 0,import.meta.url).then(e=>_e(e.liveScript))}}),$e.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>dSt),void 0,import.meta.url).then(e=>_e(e.lua))}}),$e.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>CSt),void 0,import.meta.url).then(e=>_e(e.mirc))}}),$e.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ve(()=>Promise.resolve().then(()=>vSt),void 0,import.meta.url).then(e=>_e(e.mathematica))}}),$e.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>DSt),void 0,import.meta.url).then(e=>_e(e.modelica))}}),$e.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>sxt),void 0,import.meta.url).then(e=>_e(e.mumps))}}),$e.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>ESt),void 0,import.meta.url).then(e=>_e(e.mbox))}}),$e.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>dxt),void 0,import.meta.url).then(e=>_e(e.nginx))}}),$e.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>fxt),void 0,import.meta.url).then(e=>_e(e.nsis))}}),$e.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>hxt),void 0,import.meta.url).then(e=>_e(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=>_e(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=>_e(e.objectiveCpp))}}),$e.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>_e(e.oCaml))}}),$e.of({name:"Octave",extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>Qxt),void 0,import.meta.url).then(e=>_e(e.octave))}}),$e.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>zxt),void 0,import.meta.url).then(e=>_e(e.oz))}}),$e.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>Ixt),void 0,import.meta.url).then(e=>_e(e.pascal))}}),$e.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>Zxt),void 0,import.meta.url).then(e=>_e(e.perl))}}),$e.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>Vxt),void 0,import.meta.url).then(e=>_e(e.pig))}}),$e.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>cQt),void 0,import.meta.url).then(e=>_e(e.powerShell))}}),$e.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ve(()=>Promise.resolve().then(()=>uQt),void 0,import.meta.url).then(e=>_e(e.properties))}}),$e.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>pQt),void 0,import.meta.url).then(e=>_e(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=>_e(e.pug))}}),$e.of({name:"Puppet",extensions:["pp"],load(){return ve(()=>Promise.resolve().then(()=>$Qt),void 0,import.meta.url).then(e=>_e(e.puppet))}}),$e.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>kQt),void 0,import.meta.url).then(e=>_e(e.q))}}),$e.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ve(()=>Promise.resolve().then(()=>qQt),void 0,import.meta.url).then(e=>_e(e.r))}}),$e.of({name:"RPM Changes",load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>_e(e.rpmChanges))}}),$e.of({name:"RPM Spec",extensions:["spec"],load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>_e(e.rpmSpec))}}),$e.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ve(()=>Promise.resolve().then(()=>GQt),void 0,import.meta.url).then(e=>_e(e.ruby))}}),$e.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>MQt),void 0,import.meta.url).then(e=>_e(e.sas))}}),$e.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>_e(e.scala))}}),$e.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>akt),void 0,import.meta.url).then(e=>_e(e.scheme))}}),$e.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ve(()=>Promise.resolve().then(()=>ckt),void 0,import.meta.url).then(e=>_e(e.shell))}}),$e.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>hkt),void 0,import.meta.url).then(e=>_e(e.sieve))}}),$e.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>gkt),void 0,import.meta.url).then(e=>_e(e.smalltalk))}}),$e.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>xkt),void 0,import.meta.url).then(e=>_e(e.solr))}}),$e.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>_e(e.sml))}}),$e.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ve(()=>Promise.resolve().then(()=>Xkt),void 0,import.meta.url).then(e=>_e(e.sparql))}}),$e.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>Ekt),void 0,import.meta.url).then(e=>_e(e.spreadsheet))}}),$e.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>pd),void 0,import.meta.url).then(e=>_e(e.squirrel))}}),$e.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>ePt),void 0,import.meta.url).then(e=>_e(e.stylus))}}),$e.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>vPt),void 0,import.meta.url).then(e=>_e(e.swift))}}),$e.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>eH),void 0,import.meta.url).then(e=>_e(e.stex))}}),$e.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ve(()=>Promise.resolve().then(()=>eH),void 0,import.meta.url).then(e=>_e(e.stex))}}),$e.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>vH),void 0,import.meta.url).then(e=>_e(e.verilog))}}),$e.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>xPt),void 0,import.meta.url).then(e=>_e(e.tcl))}}),$e.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>_Pt),void 0,import.meta.url).then(e=>_e(e.textile))}}),$e.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>FPt),void 0,import.meta.url).then(e=>_e(e.tiddlyWiki))}}),$e.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>n_t),void 0,import.meta.url).then(e=>_e(e.tiki))}}),$e.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>r_t),void 0,import.meta.url).then(e=>_e(e.toml))}}),$e.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ve(()=>Promise.resolve().then(()=>o_t),void 0,import.meta.url).then(e=>_e(e.troff))}}),$e.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>x_t),void 0,import.meta.url).then(e=>_e(e.ttcn))}}),$e.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ve(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>_e(e.ttcnCfg))}}),$e.of({name:"Turtle",extensions:["ttl"],load(){return ve(()=>Promise.resolve().then(()=>P_t),void 0,import.meta.url).then(e=>_e(e.turtle))}}),$e.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>v5t),void 0,import.meta.url).then(e=>_e(e.webIDL))}}),$e.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>G_t),void 0,import.meta.url).then(e=>_e(e.vb))}}),$e.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>Z_t),void 0,import.meta.url).then(e=>_e(e.vbScript))}}),$e.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>V_t),void 0,import.meta.url).then(e=>_e(e.velocity))}}),$e.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>vH),void 0,import.meta.url).then(e=>_e(e.verilog))}}),$e.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>n5t),void 0,import.meta.url).then(e=>_e(e.vhdl))}}),$e.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>R5t),void 0,import.meta.url).then(e=>_e(e.xQuery))}}),$e.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>N5t),void 0,import.meta.url).then(e=>_e(e.yacas))}}),$e.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>D5t),void 0,import.meta.url).then(e=>_e(e.z80))}}),$e.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>_e(e.mscgen))}}),$e.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>_e(e.xu))}}),$e.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>G2),void 0,import.meta.url).then(e=>_e(e.msgenny))}}),$e.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>t0t),void 0,import.meta.url).then(e=>e.vue())}}),$e.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>v0t),void 0,import.meta.url).then(e=>e.angular())}})];class h8{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=Fn(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(Hge(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 BM(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 qat(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=BM(t)+BM(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+$/]:qat(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=Fn(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 HM{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 Hge(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 p8=Zf.define();function jat(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:Ze.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const KM=new WeakMap;function Cat(e){if(!Array.isArray(e))return e;let t=KM.get(e);return t||KM.set(e,t=Ev(e)),t}const tx=Tn.define(),K$=Tn.define();class Aat{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),x=S==t.length?0:-100;if(v!=n[0])if(v==r[0])x+=-200;else return null;return this.ret(x,[0,S])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let v=0,S=Math.min(t.length,200);v<S&&c<l;){let x=Ro(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=Yc(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,S=Math.min(t.length,200),x=0;v<S&&O<l;){let b=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,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=lme(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||Q==1&&g||x==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),x=Q,v+=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 zat{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:Uat,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=>JM(t(r),n(r)),optionClass:(t,n)=>r=>JM(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function JM(e,t){return e?t?e+" "+t:e:t}function Uat(e,t,n,r,i,a){let o=e.textDirection==Xr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,f)?s=!1:!s&&f<Math.min(p,d)&&(s=!0),p<=(s?d:f))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:f);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Wat(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 Nat{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=Wat(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=>to(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&Gat(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 Yat(e,t){return n=>new Nat(n,e,t)}function Gat(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 eV(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Iat(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 HM(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new zat(O):new Aat(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 HM(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):eV(c.completion)>eV(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,tV(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=Iat(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,tV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Fat,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(Vat,"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(Cat)).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(m8));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Zat(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(Jge)&&(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?Dat:Mat}}function Zat(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 Dat={"aria-autocomplete":"list"},Mat={};function tV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Vat=[];function Kge(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(p8);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=Kge(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(m8))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 Lat(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 h8(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 Lat(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Hge(e,!0).test(i)}const m8=Tn.define({map(e,t){return e.map(n=>n.map(t))}}),Jge=Tn.define(),Ka=lo.define({create(){return nx.start()},update(e,t){return e.update(t)},provide:e=>[s8.from(e,t=>t.tooltip),_t.contentAttributes.from(e,t=>t.attrs)]});function g8(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ka).active.find(i=>i.source==t.source);return r instanceof hp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},jat(e.state,n,r.from,r.to)),{annotations:p8.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Fat=Yat(Ka,g8);function iw(e,t="option"){return n=>{let r=n.state.field(Ka,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ni).interactionDelay)return!1;let i=1,a;t=="page"&&(a=Sge(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:Jge.of(s)}),!0}}const Bat=e=>{let t=e.state.field(Ka,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ni).interactionDelay?!1:g8(e,t.open.options[t.open.selected])},nV=e=>e.state.field(Ka,!1)?(e.dispatch({effects:tx.of(!0)}),!0):!1,Hat=e=>{let t=e.state.field(Ka,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:K$.of(null)}),!0)};class Kat{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Jat=50,eot=1e3,tot=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(Ka).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ka),n=e.state.facet(Ni);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ka)==t)return;let r=e.transactions.some(a=>{let o=Kge(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>Jat&&Date.now()-o.time>eot){for(let s of o.context.abortListeners)try{s()}catch(l){to(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(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(Ka);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ni).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=ef(t),r=new h8(t,n,e.explicit,this.view),i=new Kat(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)}),to(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(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(Ka);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=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:m8.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ka,!1);if(t&&t.tooltip&&this.view.state.facet(Ni).closeOnBlur){let n=t.open&&Sge(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}}}),not=typeof navigator=="object"&&/Win/.test(navigator.platform),rot=ZO.highest(_t.domEventHandlers({keydown(e,t){let n=t.state.field(Ka,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(not&&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&&g8(t,r),!1}})),e0e=_t.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 iot{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class $8{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 $8(this.field,n,r)}}class y8{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 $8(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 iot(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 y8(r,i)}}let aot=cn.widget({widget:new class extends Tu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),oot=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?aot:oot).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=Tn.define({map(e,t){return e&&e.map(t)}}),sot=Tn.define(),J$=lo.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(qv))return n.value;if(n.is(sot)&&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=>_t.decorations.from(e,t=>t?t.deco:cn.none)});function v8(e,t){return Ze.create(e.filter(n=>n.field==t).map(n=>Ze.range(n.from,n.to)))}function lot(e){let t=y8.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:Ln.of(o)},scrollIntoView:!0,annotations:r?[p8.of(r),Ki.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=v8(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(Tn.appendConfig.of([J$,fot,hot,e0e]))}n.dispatch(n.state.update(c))}}function t0e(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:v8(r.ranges,i),effects:qv.of(a?null:new Ym(r.ranges,i)),scrollIntoView:!0})),!0}}const cot=({state:e,dispatch:t})=>e.field(J$,!1)?(t(e.update({effects:qv.of(null)})),!0):!1,uot=t0e(1),Oot=t0e(-1),dot=[{key:"Tab",run:uot,shift:Oot},{key:"Escape",run:cot}],rV=ht.define({combine(e){return e.length?e[0]:dot}}),fot=ZO.highest(Nk.compute([rV],e=>e.facet(rV)));function Sr(e,t){return Object.assign(Object.assign({},t),{apply:lot(e)})}const hot=_t.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:v8(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=Tn.define({map(e,t){let n=t.mapPos(e,-1,Hi.TrackAfter);return n??void 0}}),b8=new class extends mf{};b8.startSide=1;b8.endSide=-1;const n0e=lo.define({create(){return _n.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:[b8.range(n.value,n.value+1)]}));return e}});function QOn(){return[mot,n0e]}const UT="()[]{}<>«»»«[]{}";function r0e(e){for(let t=0;t<UT.length;t+=2)if(UT.charCodeAt(t)==e)return UT.charAt(t+1);return lme(e<128?e:e+1)}function i0e(e,t){return e.languageDataAt("closeBrackets",t)[0]||ey}const pot=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),mot=_t.inputHandler.of((e,t,n,r)=>{if((pot?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=$ot(e.state,r);return a?(e.dispatch(a),!0):!1}),got=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=i0e(e,e.selection.main.head).brackets||ey.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=yot(e.doc,o.head);for(let l of r)if(l==s&&Vk(e.doc,o.head)==r0e(Ro(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ze.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},kOn=[{key:"Backspace",run:got}];function $ot(e,t){let n=i0e(e,e.selection.main.head),r=n.brackets||ey.brackets;for(let i of r){let a=r0e(Ro(i,0));if(t==i)return a==i?wot(e,i,r.indexOf(i+i+i)>-1,n):vot(e,i,a,n.before||ey.before);if(t==a&&a0e(e,e.selection.main.from))return bot(e,i,a)}return null}function a0e(e,t){let n=!1;return e.field(n0e).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 yot(e,t){let n=e.sliceString(t-2,t);return Yc(Ro(n,0))==n.length?n:n.slice(1)}function vot(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:Ze.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:Ze.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function bot(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:Ze.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function wot(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:Ze.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=Vk(e.doc,l),u;if(c==t){if(iV(e,l))return{changes:{insert:t+t,from:l},effects:Wd.of(l+t.length),range:Ze.cursor(l+t.length)};if(a0e(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:Ze.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=aV(e,l-2*t.length,i))>-1&&iV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Wd.of(l+t.length),range:Ze.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ms.Word&&aV(e,l,i)>-1&&!Sot(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Wd.of(l+t.length),range:Ze.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function iV(e,t){let n=Fn(e).resolveInner(t+1);return n.parent&&n.from==t}function Sot(e,t,n,r){let i=Fn(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 aV(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 POn(e={}){return[rot,Ka,Ni.of(e),tot,Qot,e0e]}const xot=[{key:"Ctrl-Space",run:nV},{mac:"Alt-`",run:nV},{key:"Escape",run:Hat},{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:Bat}],Qot=ZO.highest(Nk.computeN([Ni],e=>e.facet(Ni).defaultKeymap?[xot]:[]));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($i.none,i,a,o,this.hashProp)})}}var Ve;(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"})(Ve||(Ve={}));class kot{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Pot=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 oV(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==Ve.OrderedList?x8:S8)(n,t,!1);return r>0&&(e.type!=Ve.BulletList||w8(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const o0e={[Ve.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(bn(Ve.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)},[Ve.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ve.OrderedList]:oV,[Ve.BulletList]:oV,[Ve.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 sV(e,t,n){for(;t>n&&Ts(e.charCodeAt(t-1));)t--;return t}function s0e(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 l0e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function w8(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&&O0e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(p0e.SetextHeading)>-1||r<3?-1:1}function c0e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function S8(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||c0e(t,Ve.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function x8(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&&!c0e(t,Ve.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function u0e(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 O0e(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 tC=/^[ \t]*$/,d0e=/-->/,f0e=/\?>/,nC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,d0e],[/^\s*<\?/,f0e],[/^\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,tC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,tC]];function h0e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=nC.length-(n?1:0);i<a;i++)if(nC[i][0].test(r))return i;return-1}function lV(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==Ve.CodeText?e[r].to=n:e.push(bn(Ve.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==Ve.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!=Ve.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ve.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=s0e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=sV(t.text,t.text.length,o),l=[bn(Ve.CodeMark,r,r+a)];o<s&&l.push(bn(Ve.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(Ve.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(Ve.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=l0e(t);return n<0?!1:(e.startContext(Ve.Blockquote,t.pos),e.addNode(Ve.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(w8(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ve.HorizontalRule,n),!0},BulletList(e,t){let n=S8(t,e,!1);if(n<0)return!1;e.block.type!=Ve.BulletList&&e.startContext(Ve.BulletList,t.basePos,t.next);let r=lV(t,t.pos+1);return e.startContext(Ve.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ve.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=x8(t,e,!1);if(n<0)return!1;e.block.type!=Ve.OrderedList&&e.startContext(Ve.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=lV(t,t.pos+n);return e.startContext(Ve.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ve.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=u0e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=sV(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(Ve.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ve.HeaderMark,o-r,a-r);let l=s.finish(Ve.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=h0e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=nC[n][1],a=[],o=i!=tC;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==d0e?Ve.CommentBlock:i==f0e?Ve.ProcessingInstructionBlock:Ve.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class _ot{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(Ve.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(x0e(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(bn(Ve.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(w0e(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=S0e(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 Tot{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:O0e(n),a=n.next;if(i<0)return!1;let o=bn(Ve.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,bn(a==61?Ve.SetextHeading1:Ve.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const p0e={LinkReference(e,t){return t.content.charCodeAt(0)==91?new _ot(t):null},SetextHeading(){return new Tot}},Rot=[(e,t)=>u0e(t)>=0,(e,t)=>s0e(t)>=0,(e,t)=>l0e(t)>=0,(e,t)=>S8(t,e,!0)>=0,(e,t)=>x8(t,e,!0)>=0,(e,t)=>w8(t,e,!0)>=0,(e,t)=>h0e(t,e,!0)>=0],Xot={text:"",end:0};class Eot{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new Pot,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(Ve.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new Aot(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 kot(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=Q0e(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=Xot;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 "+Ve[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(t2t.test(l))return Ja;const c=l.length-l.replace(n2t,"").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,s2t=e=>e.arm!==null;function Jf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+Kp(e.value).length}}function QU(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=a7(a-i.start,0,l.length),u=a7(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)+oxe.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 AH(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 QU(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 l2t(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 c2t(e,t,n,r,i){const a=l2t(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=QU(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 u2t(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=pxe(i,t.value),c=l+kP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ja,buffer:u,caret:s+c.length,payload:{index:i,key:yxe(a,e.draw),value:t.value,marker:l}}}function O2t(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=$xe(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ja,buffer:i,caret:n.start+r.length,restored:i7(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:i7(r),restoredText:r}}}function zH(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function d2t(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 f2t(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=QU(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:d2t(t,n,e.selection,i);const o=t.arm,s=pxe(e.index,a),l=s+kP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ja,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:yxe(e.taken,e.draw),value:a,marker:s}}}const hxe=e=>`${i7(e)} chars`,pxe=(e,t)=>`[Credential #${e}, ${hxe(t)}]`;function h2t(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 p2t(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(h2t(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,m2t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&r7.test(t[1])?t[1]:""};function g2t(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:m2t(i[0])}:null}function PP(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=g2t(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 UH(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 $2t(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 y2t=e=>`[credential ${e.key} (${hxe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function v2t(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 uxe(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?$2t(l??"lost",s?.key):y2t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const b2t=(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.`,w2t=e=>`Remove credential #${e}`,S2t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,x2t=(e,t,n)=>b2t(e,t,n),Q2t="Undo",k2t=e=>`Credential #${e} removed`,P2t=e=>e.unredacted!==null?e.unredacted:e.armed?j2t:e.cleared!==null?x2t(e.cleared.key,e.cleared.index,e.undoCap):null;function _2t(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 T2t(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 WH=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function NH(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 R2t="store unconfirmed",X2t="Credential store unconfirmed",E2t=e=>e===""?X2t:`${e} · ${R2t}`,mxe="Paste the value again after /credential to store it again.",q2t=e=>`${e} ${mxe}`;function YH(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. ${mxe}`}const j2t="armed — add a space, then type or paste the secret",C2t="masked as you type — Enter turns it into a pill, Esc cancels",A2t="masked — Enter opens the credential picker; type or paste the secret into this span",z2t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",gxe="\0held",U2t=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===gxe?`${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 $xe(e,t){const n=Jf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const GH=(e,t)=>e&&e.over===t?e.chars:null,W2t=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},N2t=16,Y2t=16;function yxe(e=[],t=W2t){const n=new Set(e);for(let r=0;r<N2t;r++){const i=jH+IH(8,t);if(!n.has(i))return i}return jH+IH(Y2t,t)}const IH=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=qH[t(qH.length)];return n},G2t=8,I2t=256,Z2t=/^[/@$#]/,D2t=/^\w+:\/\//,M2t=/^[A-Za-z]+$/,V2t=/^\d+$/,L2t=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],F2t=3,B2t=20,H2t=/^[A-Za-z0-9_\-+/=.]+$/,K2t=new RegExp(`^[^${wa}@]+@[^${wa}@]+\\.[A-Za-z]{2,}$`),J2t=/^[\w.-]+(?:\/[\w.-]+)+$/,eRt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,tRt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,nRt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,rRt=/^[\w.-]+:\d{2,5}$/,iRt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,aRt=/^[a-z]+(?:_[a-z]+)+$/,oRt=/^[a-z]+(?:-[a-z]+)+$/,sRt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,lRt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,cRt=/\d{4,}/,uRt=e=>{const t=e.trim();return t.length<G2t||t.length>I2t||Zo.test(t)||Z2t.test(t)||D2t.test(t)||nOe(t)!==null||K2t.test(t)||J2t.test(t)||eRt.test(t)||tRt.test(t)||nRt.test(t)||rRt.test(t)||iRt.test(t)||aRt.test(t)||oRt.test(t)||sRt.test(t)||lRt.test(t)&&cRt.test(t)||M2t.test(t)||V2t.test(t)?!1:L2t.filter(r=>r.test(t)).length>=F2t?!0:t.length>=B2t&&H2t.test(t)},vxe=q("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),bxe=q("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),wxe=({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"?bxe:vxe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(ile,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(jze,{"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/",ORt=`${py}unstored`,ZH=`${py}unconfirmed`,dRt=/^\d+$/,Sxe=e=>e.kind==="stored"?`${py}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${ZH}/${e.key}`:ZH:ORt;function fRt(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 r7.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!r7.test(r)||!dRt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function DH(e,t){const n=fRt(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 Sxe(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:Sxe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},hRt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?E2t(e.key):"Credential not stored",pRt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?q2t(t):t,mRt=({citation:e,title:t})=>h.jsx(wxe,{tone:e.kind==="stored"?"live":"warning",label:hRt(e),chars:e.kind==="stored"?e.chars:null,title:pRt(e,t),className:"align-middle"}),gRt=(e,t)=>typeof t=="string"?DH(e,t):t==null?DH(e,""):null,$Rt=e=>({href:t,title:n,children:r})=>{const i=gRt(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(mRt,{citation:i,title:n})},xxe=e=>Ott(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",Qxe=e=>{const t=xxe(e);return t==="other"?"path":t},MH={id:"open-file",label:"Open file"},yRt={id:"show-in-canvas",label:"Show in canvas"},vRt={id:"save-as",label:"Save as…"},VH={id:"open-folder",label:"Open folder"},LH={id:"copy-file-path",label:"Copy file path"},Mg={id:"copy-image",label:"Copy image"},bRt={id:"copy-image-url",label:"Copy image URL"},wRt={id:"open-in-browser",label:"Open in browser"};function kxe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[yRt]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[MH,VH,LH]:[],vRt,...r==="video"||r==="audio"?[]:[Mg]];case"path":return[...o,MH,VH,LH,...r==="video"||r==="audio"?[]:[Mg]];case"data":return[...o,Mg];case"blob":return[Mg];case"http":return[...SRt(n)?[Mg]:[],bRt,wRt];case"other":return[]}}const Pxe=(e,t)=>kxe(e,t).length>0;function SRt(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 kU=e=>e.startsWith("file://")?e.slice(7):e;function xRt(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 FH(e,t,n){if(e==="data")return xRt(t);if(e==="blob"){const o=efe(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=kU(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Zz(i)})}const QRt=e=>e.trim().toLowerCase()!=="image/png";async function kRt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!QRt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await PRt(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 PRt(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 _Rt=6e4;function TRt(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),_Rt)}const F1=new Map;function RRt(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=Mz(i.data,i.mimeType);return r.holders<=0?($v(a),null):(tfe(t,a),a)}catch{return null}finally{F1.delete(t)}})(),F1.set(t,r),r.promise}class PU extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function _xe(e,t){const n=Vz(t),r=n?efe(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 PU:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function XRt(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?Vz(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 RRt({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(_S(u))}}),()=>{O=!1,f&&XRt(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 _U(e,t){return Dv(e,t)}const COn=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:PU,fetchAttachmentBlob:_xe,useAttachmentSource:Dv,useAttachmentUrl:_U},Symbol.toStringTag,{value:"Module"})),ERt={"expand-image":h.jsx(_ue,{"aria-hidden":"true"}),"open-file":h.jsx(dv,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(Pue,{"aria-hidden":"true"}),"save-as":h.jsx(Ov,{"aria-hidden":"true"}),"open-folder":h.jsx(Rp,{"aria-hidden":"true"}),"copy-file-path":h.jsx(bue,{"aria-hidden":"true"}),"copy-image":h.jsx(hk,{"aria-hidden":"true"}),"copy-image-url":h.jsx(Uze,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Sue,{"aria-hidden":"true"})},BH=(e,t)=>t instanceof PU?`${e}: it is no longer in the session`:e,Txe=({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=Qxe(e),y=kxe(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(Q=>(Q.id!=="save-as"||!!d)&&(!l||Q.id==="copy-file-path"));if(y.length===0)return null;const v=async(Q,k,T)=>{try{await navigator.clipboard.writeText(Q),Of(k)}catch(_){console.error(`${T}: `,_),pi(T)}},S=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const Q=f?await f():await FH(g,e,t),k=await kRt(Q);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),Of("Image copied to clipboard")}catch(Q){console.error("Failed to copy image: ",Q),pi(BH("Failed to copy image",Q))}},x=async()=>{try{const Q=f?await f():await FH(g,e,t);TRt(Q,d??"download")}catch(Q){console.error("Failed to save file: ",Q),pi(BH("Failed to save file",Q))}},b=async Q=>{let k=kU(e);if(s&&["open-file","open-folder","copy-file-path"].includes(Q.id))try{k=await s()}catch{pi(J("ui.canvas.files.prepareError"));return}switch(Q.id){case"expand-image":O?.();return;case"open-file":AO(k);return;case"open-folder":wU(k);return;case"show-in-canvas":c?.();return;case"copy-file-path":v(k,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":S();return;case"save-as":x();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":SU(t??e);return}},w=m??`Actions for ${n??"this image"}`;return h.jsxs(yA,{open:r,onOpenChange:i,children:[h.jsx(Yt,{content:p,children:h.jsx(vA,{asChild:!0,children:h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:Q=>Q.stopPropagation(),children:h.jsx($j,{"aria-hidden":"true"})})})}),h.jsxs(bA,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:Q=>Q.stopPropagation(),children:[s&&h.jsx("div",{role:"note",className:q("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:J("ui.canvas.files.pathCopyNote")}),y.map(Q=>h.jsxs(jl,{onSelect:()=>b(Q),children:[ERt[Q.id],h.jsx("span",{children:Q.label})]},Q.id))]})]})},qRt=({src:e,alt:t,title:n,className:r})=>{const i=SP(),a=e??"",o=xxe(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=Pxe(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(Txe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||AO(kU(a))})}:void 0})})]})};function jRt(){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 CRt={tokenize:ARt,concrete:!0,name:"mathFlow"},HH={tokenize:zRt,partial:!0};function ARt(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||wt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||wt(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(HH,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):wt(v)?e.attempt(HH,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||wt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,S,x){let b=0;return ln(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(T){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(T)}function Q(T){return T===36?(b++,v.consume(T),Q):b<o?x(T):(v.exit("mathFlowFenceSequence"),ln(v,k,"whitespace")(T))}function k(T){return T===null||wt(T)?(v.exit("mathFlowFence"),S(T)):x(T)}}}function zRt(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 URt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:WRt,previous:NRt,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):wt(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||wt(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 WRt(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 NRt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function YRt(e){return{flow:{36:CRt},text:{36:URt()}}}const ep=36,KH=e=>e!==null&&e<-2,JH=e=>e===null||e===32||e<0,eK=e=>e!==null&&e>=48&&e<=57,Rxe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:GRt,previous:IRt,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&&(JH(g)||eK(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):KH(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||KH(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&&(JH(l)||eK(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function GRt(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 IRt(e){return e!==ep||this.events[this.events.length-1][1].type==="characterEscape"}const ZRt=YRt().flow,DRt=Rxe();function TP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?DRt:Rxe(e);n.push({flow:ZRt,text:{[ep]:i}}),r.push(jRt())}const MRt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),VRt=/\$(?!\d)(.+?)\$/,LRt=/\$\$([\s\S]+?)\$\$/,FRt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,BRt=/\\[a-zA-Z]+(\{[^}]*\})?/,tK=e=>VRt.test(e)||LRt.test(e)||FRt.test(e)?!0:BRt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),HRt=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},KRt=e=>PP(e).filter(t=>t.kind!=="text").length,JRt=e=>{if(!tK(e))return!1;const t=HRt(e);return t===null?!0:tK(t)||t.includes("$")?!1:KRt(e)<2},Kt="var(--color-ink)",bc="var(--color-ink-muted)",Sl="var(--color-surface)",Du="var(--color-elevated)",wc="var(--color-sunken)",sa="var(--color-hairline)",Mu="var(--color-control)",Xh="var(--color-accent)",Q0="var(--color-accent-wash)",eXt="var(--color-accent-alt-wash)",tXt="var(--color-on-accent)",nXt="var(--color-info)",Xxe="var(--color-info-wash)",rXt="var(--color-success)",Exe="var(--color-success-wash)",iXt="var(--color-warning)",o7="var(--color-warning-wash)",aXt="var(--color-warning-border)",lR="var(--color-danger)",s7="var(--color-danger-wash)",nK=[Q0,eXt,Xxe,Exe,o7,s7],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),oXt=()=>{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:sa,tertiaryTextColor:Kt,tertiaryBorderColor:sa,lineColor:bc,arrowheadColor:bc,textColor:Kt,secondBkg:wc,border1:Mu,border2:sa,labelColor:Kt,nodeBkg:Du,nodeBorder:Mu,nodeTextColor:Kt,defaultLinkColor:bc,titleColor:Kt,noteBkgColor:o7,noteBorderColor:aXt,noteTextColor:Kt,actorBkg:Du,actorBorder:Mu,actorTextColor:Kt,actorLineColor:sa,signalColor:bc,signalTextColor:Kt,labelBoxBkgColor:Du,labelBoxBorderColor:sa,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:sa,doneTaskBkgColor:wc,doneTaskBorderColor:sa,critBkgColor:s7,critBorderColor:lR,todayLineColor:Xh,transitionColor:bc,transitionLabelColor:Kt,stateLabelColor:Kt,stateBkg:Du,labelBackgroundColor:Sl,compositeBackground:wc,altBackground:wc,compositeTitleBackground:Du,compositeBorder:sa,innerEndBackground:Kt,specialStateColor:Kt,classText:Kt,attributeBackgroundColorOdd:Sl,attributeBackgroundColorEven:wc,rowOdd:Sl,rowEven:wc,errorBkgColor:s7,errorTextColor:lR,pieTitleTextColor:Kt,pieSectionTextColor:Kt,pieLegendTextColor:Kt,pieStrokeColor:Sl,pieOuterStrokeColor:sa,requirementBackground:Du,requirementBorderColor:Mu,requirementTextColor:Kt,relationColor:bc,relationLabelBackground:Sl,relationLabelColor:Kt,branchLabelColor:tXt,commitLabelColor:Kt,commitLabelBackground:Sl,tagLabelColor:Kt,tagLabelBackground:Q0,tagLabelBorder:Mu,quadrant2Fill:Xxe,quadrant3Fill:Exe,quadrant4Fill:o7,quadrant2TextFill:Kt,quadrant3TextFill:Kt,quadrant4TextFill:Kt,quadrantPointFill:Xh,archEdgeColor:bc,archEdgeArrowColor:bc,archGroupBorderColor:sa,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:sa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Sl,titleColor:Kt,xAxisTitleColor:Kt,xAxisLabelColor:Kt,xAxisTickColor:sa,xAxisLineColor:sa,yAxisTitleColor:Kt,yAxisLabelColor:Kt,yAxisTickColor:sa,yAxisLineColor:sa,plotColorPalette:[Xh,nXt,rXt,iXt,lR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Du,t[`surfacePeer${n}`]=sa;for(let n=0;n<8;n++)t[`fillType${n}`]=nK[n%nK.length];return{...t,...e}};let cR=null,rK=null;const sXt=async e=>{cR||(cR=ve(async()=>{const{default:n}=await import("./mermaid.core-DmdT5IgP.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 rK!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:oXt()}),rK=e),t},iK=({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(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(Wue,{})})}),h.jsx(Yt,{content:"Zoom out",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(Nue,{})})}),h.jsx(Yt,{content:"Drag the diagram to pan",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(n9e,{})})}),h.jsx(Yt,{content:"Reset view",children:h.jsx(Ee,{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(Ee,{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(Ee,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(hk,{className:q(t&&"text-success")})})}),s]}),l7=({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 lXt 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(l7,{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 cXt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,f]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,S]=$.useState({x:0,y:0}),[x,b]=$.useState("idle"),[w,Q]=$.useState("idle"),k=Kn(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 sXt(k),B=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:I}=await U.render(B,e);if(!I||typeof I!="string"||I.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(I)}catch(U){console.error("Mermaid rendering error:",U);const B=U instanceof Error?U.message:"Failed to render mermaid diagram";a(B),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 B=r.current.getBoundingClientRect(),I=document.createElement("div");I.innerHTML=l;const L=I.querySelector("svg");if(!L)return 1;const ie=L.getBoundingClientRect?.()?.width||Number.parseFloat(L.getAttribute("width")||"0")||L.viewBox?.baseVal?.width||800,H=L.getBoundingClientRect?.()?.height||Number.parseFloat(L.getAttribute("height")||"0")||L.viewBox?.baseVal?.height||600,K=B.width*.9/ie,ne=B.height*.9/H;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)(I=>({...I,scale:Math.min(I.scale*1.2,10)}))}catch(B){console.error("Error in zoom in:",B)}},[]),R=$.useCallback((U=!1)=>{try{(U?m:f)(I=>({...I,scale:Math.max(I.scale/1.2,.1)}))}catch(B){console.error("Error in zoom out:",B)}},[]),j=$.useCallback((U=!1)=>{try{const B=U?m:f;if(U){const I=_();B({scale:I,x:0,y:0})}else B({scale:1,x:0,y:0})}catch(B){console.error("Error in reset:",B)}},[_]),C=$.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),B=URL.createObjectURL(U),I=document.createElement("a");I.href=B,I.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(B)}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]),N=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),G=$.useCallback(U=>{try{y(!0),S({x:U.clientX,y:U.clientY}),U.preventDefault()}catch(B){console.error("Error in mouse down:",B)}},[]),D=$.useCallback((U,B=!1)=>{try{if(!g)return;const I=U.clientX-v.x,L=U.clientY-v.y;(B?m:f)(H=>({...H,x:H.x+I,y:H.y+L})),S({x:U.clientX,y:U.clientY})}catch(I){console.error("Error in mouse move:",I)}},[g,v]),F=$.useCallback(()=>{try{y(!1)}catch(U){console.error("Error in mouse up:",U)}},[]),z=$.useCallback((U,B=!1)=>{try{U.preventDefault();const I=U.deltaY>0?.9:1.1;(B?m:f)(ie=>({...ie,scale:Math.min(Math.max(ie.scale*I,.1),5)}))}catch(I){console.error("Error in wheel:",I)}},[]),M=$.useCallback(U=>{try{O(U)}catch(B){console.error("Error toggling fullscreen:",B)}},[]);if(i)return h.jsxs(l7,{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 B=U?r:n,I=U?p:d;return h.jsx("div",{ref:B,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:G,onMouseMove:L=>D(L,U),onMouseUp:F,onMouseLeave:F,onWheel:L=>z(L,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(${I.x}px, ${I.y}px) scale(${I.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(B){return console.error("Error rendering diagram content:",B),h.jsx(l7,{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(iK,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>R(!1),onReset:()=>j(!1),onSave:C,onCopy:W,children:h.jsx(Yt,{content:"Fullscreen",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>M(!0),children:h.jsx(_ue,{})})})})]}),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(iK,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>R(!0),onReset:()=>j(!0),onSave:C,onCopy:N,children:h.jsx(Yt,{content:"Close fullscreen",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>M(!1),children:h.jsx(ea,{})})})})]})})]})}),uXt=$.memo(e=>h.jsx(lXt,{children:h.jsx(cXt,{...e})}));let qxe=!1,uR=null;const OXt=()=>(uR||(uR=ve(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(qxe=!0,e))),uR),dXt=/language-(\w+)/,fXt=JQ,hXt=new RegExp(`^[^${wa}\\d*+-]`),pXt=/\n$/,jxe=({href:e,children:t})=>{const n=USe(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=>$Xt(i,r):void 0,children:t})},mXt=e=>USe(e)?.kind==="file",gXt=ISe,$Xt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(GSe)??"file",i=n.getAttribute(gXt),a=J5t({kind:r,hasHighlight:hTt(n),canOpenInCanvas:bU(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)}},c7=(e,t)=>t==="href"&&mXt(e)?e:ohe(e),my={a:jxe,table:MRt,img:qRt,code:({node:e,className:t,children:n,...r})=>dXt.exec(t??"")?.[1]==="mermaid"?h.jsx(uXt,{chart:String(n).replace(pXt,"")}):h.jsx("code",{className:t,...r,children:n})},yXt={...my,a:$Rt(jxe)},vXt=[IO],bXt=[IO,TP],wXt=[IO,xP],SXt=[IO,TP,xP],xXt=[IO,_P,QP],QXt=[IO,TP,_P,QP],kXt=[IO,xP,_P,QP],PXt=[IO,TP,xP,_P,QP],_Xt={"000":vXt,"001":xXt,"010":wXt,"011":kXt,100:bXt,101:QXt,110:SXt,111:PXt},TXt=[],RXt=[HKe],Cxe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Axe=(e,t,n)=>{const r=$.useMemo(()=>JRt(e),[e]),[i,a]=$.useState(qxe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return OXt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:_Xt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?RXt:TXt}},zxe=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=jtt(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=tTt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return YSe(r,window.api?.probeFiles,ele).then(()=>{i&&r.some(s=>NSe(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}=Axe(a,r,i),l=Cxe(t);return zxe(a,r),h.jsx("div",{className:q("lo-markdown",n),style:l,children:h.jsx(Hj,{remarkPlugins:o,rehypePlugins:s,urlTransform:c7,components:i?yXt:my,children:a})})});gy.displayName="MarkdownRenderer";const aK={...my,a:({children:e})=>h.jsx(h.Fragment,{children:e})},Uxe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:RH(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=nxe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=Axe(n,t,!1);if(zxe(e,t),r!==null){const o=RH(r.before);return h.jsxs(h.Fragment,{children:[o.trim()!==""&&h.jsx(Hj,{remarkPlugins:i,rehypePlugins:a,urlTransform:c7,components:t?my:aK,children:o}),h.jsx(XXt,{info:r.info,body:r.body})]})}return h.jsx(Hj,{remarkPlugins:i,rehypePlugins:a,urlTransform:c7,components:t?my:aK,children:n})});Uxe.displayName="ParsedBlock";const XXt=({info:e,body:t})=>{const n=e.split(fXt)[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 u2t(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=pxe(i,t.value),c=l+kP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ja,buffer:u,caret:s+c.length,payload:{index:i,key:yxe(a,e.draw),value:t.value,marker:l}}}function O2t(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=$xe(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ja,buffer:i,caret:n.start+r.length,restored:i7(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:i7(r),restoredText:r}}}function zH(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function d2t(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 f2t(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=QU(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:d2t(t,n,e.selection,i);const o=t.arm,s=pxe(e.index,a),l=s+kP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ja,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:yxe(e.taken,e.draw),value:a,marker:s}}}const hxe=e=>`${i7(e)} chars`,pxe=(e,t)=>`[Credential #${e}, ${hxe(t)}]`;function h2t(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 p2t(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(h2t(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,m2t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&r7.test(t[1])?t[1]:""};function g2t(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:m2t(i[0])}:null}function PP(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=g2t(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 UH(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 $2t(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 y2t=e=>`[credential ${e.key} (${hxe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function v2t(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 uxe(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?$2t(l??"lost",s?.key):y2t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const b2t=(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.`,w2t=e=>`Remove credential #${e}`,S2t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,x2t=(e,t,n)=>b2t(e,t,n),Q2t="Undo",k2t=e=>`Credential #${e} removed`,P2t=e=>e.unredacted!==null?e.unredacted:e.armed?j2t:e.cleared!==null?x2t(e.cleared.key,e.cleared.index,e.undoCap):null;function _2t(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 T2t(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 WH=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function NH(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 R2t="store unconfirmed",X2t="Credential store unconfirmed",E2t=e=>e===""?X2t:`${e} · ${R2t}`,mxe="Paste the value again after /credential to store it again.",q2t=e=>`${e} ${mxe}`;function YH(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. ${mxe}`}const j2t="armed — add a space, then type or paste the secret",C2t="masked as you type — Enter turns it into a pill, Esc cancels",A2t="masked — Enter opens the credential picker; type or paste the secret into this span",z2t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",gxe="\0held",U2t=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===gxe?`${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 $xe(e,t){const n=Jf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const GH=(e,t)=>e&&e.over===t?e.chars:null,W2t=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},N2t=16,Y2t=16;function yxe(e=[],t=W2t){const n=new Set(e);for(let r=0;r<N2t;r++){const i=jH+IH(8,t);if(!n.has(i))return i}return jH+IH(Y2t,t)}const IH=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=qH[t(qH.length)];return n},G2t=8,I2t=256,Z2t=/^[/@$#]/,D2t=/^\w+:\/\//,M2t=/^[A-Za-z]+$/,V2t=/^\d+$/,L2t=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],F2t=3,B2t=20,H2t=/^[A-Za-z0-9_\-+/=.]+$/,K2t=new RegExp(`^[^${wa}@]+@[^${wa}@]+\\.[A-Za-z]{2,}$`),J2t=/^[\w.-]+(?:\/[\w.-]+)+$/,eRt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,tRt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,nRt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,rRt=/^[\w.-]+:\d{2,5}$/,iRt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,aRt=/^[a-z]+(?:_[a-z]+)+$/,oRt=/^[a-z]+(?:-[a-z]+)+$/,sRt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,lRt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,cRt=/\d{4,}/,uRt=e=>{const t=e.trim();return t.length<G2t||t.length>I2t||Zo.test(t)||Z2t.test(t)||D2t.test(t)||nOe(t)!==null||K2t.test(t)||J2t.test(t)||eRt.test(t)||tRt.test(t)||nRt.test(t)||rRt.test(t)||iRt.test(t)||aRt.test(t)||oRt.test(t)||sRt.test(t)||lRt.test(t)&&cRt.test(t)||M2t.test(t)||V2t.test(t)?!1:L2t.filter(r=>r.test(t)).length>=F2t?!0:t.length>=B2t&&H2t.test(t)},vxe=q("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),bxe=q("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),wxe=({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"?bxe:vxe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(ile,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(jze,{"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/",ORt=`${py}unstored`,ZH=`${py}unconfirmed`,dRt=/^\d+$/,Sxe=e=>e.kind==="stored"?`${py}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${ZH}/${e.key}`:ZH:ORt;function fRt(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 r7.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!r7.test(r)||!dRt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function DH(e,t){const n=fRt(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 Sxe(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:Sxe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},hRt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?E2t(e.key):"Credential not stored",pRt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?q2t(t):t,mRt=({citation:e,title:t})=>h.jsx(wxe,{tone:e.kind==="stored"?"live":"warning",label:hRt(e),chars:e.kind==="stored"?e.chars:null,title:pRt(e,t),className:"align-middle"}),gRt=(e,t)=>typeof t=="string"?DH(e,t):t==null?DH(e,""):null,$Rt=e=>({href:t,title:n,children:r})=>{const i=gRt(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(mRt,{citation:i,title:n})},xxe=e=>Ott(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",Qxe=e=>{const t=xxe(e);return t==="other"?"path":t},MH={id:"open-file",label:"Open file"},yRt={id:"show-in-canvas",label:"Show in canvas"},vRt={id:"save-as",label:"Save as…"},VH={id:"open-folder",label:"Open folder"},LH={id:"copy-file-path",label:"Copy file path"},Mg={id:"copy-image",label:"Copy image"},bRt={id:"copy-image-url",label:"Copy image URL"},wRt={id:"open-in-browser",label:"Open in browser"};function kxe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[yRt]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[MH,VH,LH]:[],vRt,...r==="video"||r==="audio"?[]:[Mg]];case"path":return[...o,MH,VH,LH,...r==="video"||r==="audio"?[]:[Mg]];case"data":return[...o,Mg];case"blob":return[Mg];case"http":return[...SRt(n)?[Mg]:[],bRt,wRt];case"other":return[]}}const Pxe=(e,t)=>kxe(e,t).length>0;function SRt(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 kU=e=>e.startsWith("file://")?e.slice(7):e;function xRt(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 FH(e,t,n){if(e==="data")return xRt(t);if(e==="blob"){const o=efe(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=kU(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Zz(i)})}const QRt=e=>e.trim().toLowerCase()!=="image/png";async function kRt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!QRt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await PRt(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 PRt(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 _Rt=6e4;function TRt(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),_Rt)}const F1=new Map;function RRt(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=Mz(i.data,i.mimeType);return r.holders<=0?($v(a),null):(tfe(t,a),a)}catch{return null}finally{F1.delete(t)}})(),F1.set(t,r),r.promise}class PU extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function _xe(e,t){const n=Vz(t),r=n?efe(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 PU:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function XRt(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?Vz(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 RRt({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(_S(u))}}),()=>{O=!1,f&&XRt(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 _U(e,t){return Dv(e,t)}const COn=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:PU,fetchAttachmentBlob:_xe,useAttachmentSource:Dv,useAttachmentUrl:_U},Symbol.toStringTag,{value:"Module"})),ERt={"expand-image":h.jsx(_ue,{"aria-hidden":"true"}),"open-file":h.jsx(dv,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(Pue,{"aria-hidden":"true"}),"save-as":h.jsx(Ov,{"aria-hidden":"true"}),"open-folder":h.jsx(Rp,{"aria-hidden":"true"}),"copy-file-path":h.jsx(bue,{"aria-hidden":"true"}),"copy-image":h.jsx(hk,{"aria-hidden":"true"}),"copy-image-url":h.jsx(Uze,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Sue,{"aria-hidden":"true"})},BH=(e,t)=>t instanceof PU?`${e}: it is no longer in the session`:e,Txe=({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=Qxe(e),y=kxe(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(Q=>(Q.id!=="save-as"||!!d)&&(!l||Q.id==="copy-file-path"));if(y.length===0)return null;const v=async(Q,k,T)=>{try{await navigator.clipboard.writeText(Q),Of(k)}catch(_){console.error(`${T}: `,_),pi(T)}},S=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const Q=f?await f():await FH(g,e,t),k=await kRt(Q);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),Of("Image copied to clipboard")}catch(Q){console.error("Failed to copy image: ",Q),pi(BH("Failed to copy image",Q))}},x=async()=>{try{const Q=f?await f():await FH(g,e,t);TRt(Q,d??"download")}catch(Q){console.error("Failed to save file: ",Q),pi(BH("Failed to save file",Q))}},b=async Q=>{let k=kU(e);if(s&&["open-file","open-folder","copy-file-path"].includes(Q.id))try{k=await s()}catch{pi(J("ui.canvas.files.prepareError"));return}switch(Q.id){case"expand-image":O?.();return;case"open-file":AO(k);return;case"open-folder":wU(k);return;case"show-in-canvas":c?.();return;case"copy-file-path":v(k,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":S();return;case"save-as":x();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":SU(t??e);return}},w=m??`Actions for ${n??"this image"}`;return h.jsxs(yA,{open:r,onOpenChange:i,children:[h.jsx(Yt,{content:p,children:h.jsx(vA,{asChild:!0,children:h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:Q=>Q.stopPropagation(),children:h.jsx($j,{"aria-hidden":"true"})})})}),h.jsxs(bA,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:Q=>Q.stopPropagation(),children:[s&&h.jsx("div",{role:"note",className:q("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:J("ui.canvas.files.pathCopyNote")}),y.map(Q=>h.jsxs(jl,{onSelect:()=>b(Q),children:[ERt[Q.id],h.jsx("span",{children:Q.label})]},Q.id))]})]})},qRt=({src:e,alt:t,title:n,className:r})=>{const i=SP(),a=e??"",o=xxe(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=Pxe(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(Txe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||AO(kU(a))})}:void 0})})]})};function jRt(){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 CRt={tokenize:ARt,concrete:!0,name:"mathFlow"},HH={tokenize:zRt,partial:!0};function ARt(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||wt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||wt(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(HH,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):wt(v)?e.attempt(HH,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||wt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,S,x){let b=0;return ln(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(T){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(T)}function Q(T){return T===36?(b++,v.consume(T),Q):b<o?x(T):(v.exit("mathFlowFenceSequence"),ln(v,k,"whitespace")(T))}function k(T){return T===null||wt(T)?(v.exit("mathFlowFence"),S(T)):x(T)}}}function zRt(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 URt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:WRt,previous:NRt,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):wt(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||wt(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 WRt(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 NRt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function YRt(e){return{flow:{36:CRt},text:{36:URt()}}}const ep=36,KH=e=>e!==null&&e<-2,JH=e=>e===null||e===32||e<0,eK=e=>e!==null&&e>=48&&e<=57,Rxe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:GRt,previous:IRt,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&&(JH(g)||eK(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):KH(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||KH(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&&(JH(l)||eK(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function GRt(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 IRt(e){return e!==ep||this.events[this.events.length-1][1].type==="characterEscape"}const ZRt=YRt().flow,DRt=Rxe();function TP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?DRt:Rxe(e);n.push({flow:ZRt,text:{[ep]:i}}),r.push(jRt())}const MRt=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),VRt=/\$(?!\d)(.+?)\$/,LRt=/\$\$([\s\S]+?)\$\$/,FRt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,BRt=/\\[a-zA-Z]+(\{[^}]*\})?/,tK=e=>VRt.test(e)||LRt.test(e)||FRt.test(e)?!0:BRt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),HRt=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},KRt=e=>PP(e).filter(t=>t.kind!=="text").length,JRt=e=>{if(!tK(e))return!1;const t=HRt(e);return t===null?!0:tK(t)||t.includes("$")?!1:KRt(e)<2},Kt="var(--color-ink)",bc="var(--color-ink-muted)",Sl="var(--color-surface)",Du="var(--color-elevated)",wc="var(--color-sunken)",sa="var(--color-hairline)",Mu="var(--color-control)",Xh="var(--color-accent)",Q0="var(--color-accent-wash)",eXt="var(--color-accent-alt-wash)",tXt="var(--color-on-accent)",nXt="var(--color-info)",Xxe="var(--color-info-wash)",rXt="var(--color-success)",Exe="var(--color-success-wash)",iXt="var(--color-warning)",o7="var(--color-warning-wash)",aXt="var(--color-warning-border)",lR="var(--color-danger)",s7="var(--color-danger-wash)",nK=[Q0,eXt,Xxe,Exe,o7,s7],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),oXt=()=>{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:sa,tertiaryTextColor:Kt,tertiaryBorderColor:sa,lineColor:bc,arrowheadColor:bc,textColor:Kt,secondBkg:wc,border1:Mu,border2:sa,labelColor:Kt,nodeBkg:Du,nodeBorder:Mu,nodeTextColor:Kt,defaultLinkColor:bc,titleColor:Kt,noteBkgColor:o7,noteBorderColor:aXt,noteTextColor:Kt,actorBkg:Du,actorBorder:Mu,actorTextColor:Kt,actorLineColor:sa,signalColor:bc,signalTextColor:Kt,labelBoxBkgColor:Du,labelBoxBorderColor:sa,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:sa,doneTaskBkgColor:wc,doneTaskBorderColor:sa,critBkgColor:s7,critBorderColor:lR,todayLineColor:Xh,transitionColor:bc,transitionLabelColor:Kt,stateLabelColor:Kt,stateBkg:Du,labelBackgroundColor:Sl,compositeBackground:wc,altBackground:wc,compositeTitleBackground:Du,compositeBorder:sa,innerEndBackground:Kt,specialStateColor:Kt,classText:Kt,attributeBackgroundColorOdd:Sl,attributeBackgroundColorEven:wc,rowOdd:Sl,rowEven:wc,errorBkgColor:s7,errorTextColor:lR,pieTitleTextColor:Kt,pieSectionTextColor:Kt,pieLegendTextColor:Kt,pieStrokeColor:Sl,pieOuterStrokeColor:sa,requirementBackground:Du,requirementBorderColor:Mu,requirementTextColor:Kt,relationColor:bc,relationLabelBackground:Sl,relationLabelColor:Kt,branchLabelColor:tXt,commitLabelColor:Kt,commitLabelBackground:Sl,tagLabelColor:Kt,tagLabelBackground:Q0,tagLabelBorder:Mu,quadrant2Fill:Xxe,quadrant3Fill:Exe,quadrant4Fill:o7,quadrant2TextFill:Kt,quadrant3TextFill:Kt,quadrant4TextFill:Kt,quadrantPointFill:Xh,archEdgeColor:bc,archEdgeArrowColor:bc,archGroupBorderColor:sa,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:sa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Sl,titleColor:Kt,xAxisTitleColor:Kt,xAxisLabelColor:Kt,xAxisTickColor:sa,xAxisLineColor:sa,yAxisTitleColor:Kt,yAxisLabelColor:Kt,yAxisTickColor:sa,yAxisLineColor:sa,plotColorPalette:[Xh,nXt,rXt,iXt,lR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Du,t[`surfacePeer${n}`]=sa;for(let n=0;n<8;n++)t[`fillType${n}`]=nK[n%nK.length];return{...t,...e}};let cR=null,rK=null;const sXt=async e=>{cR||(cR=ve(async()=>{const{default:n}=await import("./mermaid.core-CrL8DoR1.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 rK!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:oXt()}),rK=e),t},iK=({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(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(Wue,{})})}),h.jsx(Yt,{content:"Zoom out",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(Nue,{})})}),h.jsx(Yt,{content:"Drag the diagram to pan",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(n9e,{})})}),h.jsx(Yt,{content:"Reset view",children:h.jsx(Ee,{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(Ee,{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(Ee,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx(hk,{className:q(t&&"text-success")})})}),s]}),l7=({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 lXt 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(l7,{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 cXt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,f]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,S]=$.useState({x:0,y:0}),[x,b]=$.useState("idle"),[w,Q]=$.useState("idle"),k=Kn(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 sXt(k),B=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:I}=await U.render(B,e);if(!I||typeof I!="string"||I.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(I)}catch(U){console.error("Mermaid rendering error:",U);const B=U instanceof Error?U.message:"Failed to render mermaid diagram";a(B),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 B=r.current.getBoundingClientRect(),I=document.createElement("div");I.innerHTML=l;const L=I.querySelector("svg");if(!L)return 1;const ie=L.getBoundingClientRect?.()?.width||Number.parseFloat(L.getAttribute("width")||"0")||L.viewBox?.baseVal?.width||800,H=L.getBoundingClientRect?.()?.height||Number.parseFloat(L.getAttribute("height")||"0")||L.viewBox?.baseVal?.height||600,K=B.width*.9/ie,ne=B.height*.9/H;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)(I=>({...I,scale:Math.min(I.scale*1.2,10)}))}catch(B){console.error("Error in zoom in:",B)}},[]),R=$.useCallback((U=!1)=>{try{(U?m:f)(I=>({...I,scale:Math.max(I.scale/1.2,.1)}))}catch(B){console.error("Error in zoom out:",B)}},[]),j=$.useCallback((U=!1)=>{try{const B=U?m:f;if(U){const I=_();B({scale:I,x:0,y:0})}else B({scale:1,x:0,y:0})}catch(B){console.error("Error in reset:",B)}},[_]),C=$.useCallback(()=>{if(l)try{const U=new Blob([l],{type:"image/svg+xml"}),B=URL.createObjectURL(U),I=document.createElement("a");I.href=B,I.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(B)}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]),N=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(U){console.error("Failed to copy Mermaid chart text:",U)}},[e]),G=$.useCallback(U=>{try{y(!0),S({x:U.clientX,y:U.clientY}),U.preventDefault()}catch(B){console.error("Error in mouse down:",B)}},[]),D=$.useCallback((U,B=!1)=>{try{if(!g)return;const I=U.clientX-v.x,L=U.clientY-v.y;(B?m:f)(H=>({...H,x:H.x+I,y:H.y+L})),S({x:U.clientX,y:U.clientY})}catch(I){console.error("Error in mouse move:",I)}},[g,v]),F=$.useCallback(()=>{try{y(!1)}catch(U){console.error("Error in mouse up:",U)}},[]),z=$.useCallback((U,B=!1)=>{try{U.preventDefault();const I=U.deltaY>0?.9:1.1;(B?m:f)(ie=>({...ie,scale:Math.min(Math.max(ie.scale*I,.1),5)}))}catch(I){console.error("Error in wheel:",I)}},[]),M=$.useCallback(U=>{try{O(U)}catch(B){console.error("Error toggling fullscreen:",B)}},[]);if(i)return h.jsxs(l7,{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 B=U?r:n,I=U?p:d;return h.jsx("div",{ref:B,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:G,onMouseMove:L=>D(L,U),onMouseUp:F,onMouseLeave:F,onWheel:L=>z(L,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(${I.x}px, ${I.y}px) scale(${I.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(B){return console.error("Error rendering diagram content:",B),h.jsx(l7,{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(iK,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>R(!1),onReset:()=>j(!1),onSave:C,onCopy:W,children:h.jsx(Yt,{content:"Fullscreen",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>M(!0),children:h.jsx(_ue,{})})})})]}),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(iK,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>R(!0),onReset:()=>j(!0),onSave:C,onCopy:N,children:h.jsx(Yt,{content:"Close fullscreen",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>M(!1),children:h.jsx(ea,{})})})})]})})]})}),uXt=$.memo(e=>h.jsx(lXt,{children:h.jsx(cXt,{...e})}));let qxe=!1,uR=null;const OXt=()=>(uR||(uR=ve(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(qxe=!0,e))),uR),dXt=/language-(\w+)/,fXt=JQ,hXt=new RegExp(`^[^${wa}\\d*+-]`),pXt=/\n$/,jxe=({href:e,children:t})=>{const n=USe(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=>$Xt(i,r):void 0,children:t})},mXt=e=>USe(e)?.kind==="file",gXt=ISe,$Xt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(GSe)??"file",i=n.getAttribute(gXt),a=J5t({kind:r,hasHighlight:hTt(n),canOpenInCanvas:bU(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)}},c7=(e,t)=>t==="href"&&mXt(e)?e:ohe(e),my={a:jxe,table:MRt,img:qRt,code:({node:e,className:t,children:n,...r})=>dXt.exec(t??"")?.[1]==="mermaid"?h.jsx(uXt,{chart:String(n).replace(pXt,"")}):h.jsx("code",{className:t,...r,children:n})},yXt={...my,a:$Rt(jxe)},vXt=[IO],bXt=[IO,TP],wXt=[IO,xP],SXt=[IO,TP,xP],xXt=[IO,_P,QP],QXt=[IO,TP,_P,QP],kXt=[IO,xP,_P,QP],PXt=[IO,TP,xP,_P,QP],_Xt={"000":vXt,"001":xXt,"010":wXt,"011":kXt,100:bXt,101:QXt,110:SXt,111:PXt},TXt=[],RXt=[HKe],Cxe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Axe=(e,t,n)=>{const r=$.useMemo(()=>JRt(e),[e]),[i,a]=$.useState(qxe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return OXt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:_Xt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?RXt:TXt}},zxe=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=jtt(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=tTt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return YSe(r,window.api?.probeFiles,ele).then(()=>{i&&r.some(s=>NSe(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}=Axe(a,r,i),l=Cxe(t);return zxe(a,r),h.jsx("div",{className:q("lo-markdown",n),style:l,children:h.jsx(Hj,{remarkPlugins:o,rehypePlugins:s,urlTransform:c7,components:i?yXt:my,children:a})})});gy.displayName="MarkdownRenderer";const aK={...my,a:({children:e})=>h.jsx(h.Fragment,{children:e})},Uxe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:RH(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=nxe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=Axe(n,t,!1);if(zxe(e,t),r!==null){const o=RH(r.before);return h.jsxs(h.Fragment,{children:[o.trim()!==""&&h.jsx(Hj,{remarkPlugins:i,rehypePlugins:a,urlTransform:c7,components:t?my:aK,children:o}),h.jsx(XXt,{info:r.info,body:r.body})]})}return h.jsx(Hj,{remarkPlugins:i,rehypePlugins:a,urlTransform:c7,components:t?my:aK,children:n})});Uxe.displayName="ParsedBlock";const XXt=({info:e,body:t})=>{const n=e.split(fXt)[0];return h.jsx("pre",{children:h.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
867
867
  `)?"":`
868
868
  `}`})})},Wxe=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=$Tt());const i=r.current;wTt(i,e);const{blockStart:a}=i,o=a+STt(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&hXt.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=Cxe(t);return h.jsx("div",{className:q("lo-markdown",n),style:O,children:u.map(d=>h.jsx(Uxe,{source:d.source,closed:d.closed},d.key))})};Wxe.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}),TU=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},EXt=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 RU=TU(Date.now()),aO=null;const B1=new Set,Nxe=()=>{aO!==null&&clearTimeout(aO),aO=setTimeout(()=>{aO=null,RU=TU(Date.now());for(const e of B1)e();Nxe()},EXt(Date.now())),aO.unref?.()},qXt=e=>(B1.add(e),RU=TU(Date.now()),Nxe(),()=>{B1.delete(e),B1.size===0&&aO!==null&&(clearTimeout(aO),aO=null)}),oK=()=>RU,jXt=()=>$.useSyncExternalStore(qXt,oK,oK),CXt=e=>new Date(e+1e3),AXt=()=>CXt(jXt()),AOn=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":pde(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},zXt=(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=MGe(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=pde(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),""}},UXt=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":VGe(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},WXt={turn:"Sent",answer:"Answered",tool:"Ran"},Yxe=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=AXt();if(Number.isNaN(r.getTime()))return null;const a=UXt(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":`${WXt[t]} ${a}`,className:q("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:zXt(r,i)})})},XU=({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(Fze,{size:12,"aria-hidden":"true"}),h.jsx("span",{className:"text-meta",children:"Replying to"})]}),e.map(n=>h.jsxs("div",{className:"flex items-center gap-2 border-hairline border-l-2 py-0.5 pl-2",children:[h.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"aria-label":"Remove reply",children:h.jsx(ea,{"aria-hidden":"true"})})]},n.id))]}),NXt=({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}),YXt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},GXt=({line:e})=>h.jsx("span",{className:q(YXt[e.kind],"block"),children:e.text}),IXt=({diff:e,className:t})=>{const n=lEe(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(GXt,{line:r},i)),n.hidden>0&&h.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:cEe(n.hidden)})]})},ZXt=(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()},sK=e=>e.startsWith("file://")?e.slice(7):e,DXt={READ:{verb:"Read",runningVerb:"Reading",icon:dz},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:que},EDIT:{verb:"Edited",runningVerb:"Editing",icon:h9e},CODE:{verb:"Ran code",runningVerb:"Running code",icon:wue},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:T9e},DONE:{verb:"Finished",runningVerb:"Finishing",icon:wA},ASK:{verb:"Asked",runningVerb:"Asking",icon:dk},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:sze}},MXt={verb:"Worked on the request",runningVerb:"Working on the request",icon:wue},VXt=(e,t,n,r)=>{const i=e?DXt[e]:MXt;let a;if(t)a=sK(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=sK(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?ZXt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},lK="min-h-5 py-0",LXt=({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(NXt,{className:q(a?"text-danger":"text-ink-dim",o&&LOe),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]})]}),cK=({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=VXt(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(LXt,{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(ya,{summary:v,chevron:"leading",summaryAlign:S,defaultOpen:o,className:l,rowClassName:f?lK:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):h.jsx(ya,{disabled:!0,summary:v,summaryAlign:S,className:l,rowClassName:f?lK:void 0})},Gxe=8,FXt="… deeper values not shown",BXt="(empty)";function HXt(e){return`… ${e} more line${e===1?"":"s"}`}const uK=.5;function KXt(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 Ixe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function EU(e){return typeof e=="object"&&e!==null}function Zxe(e,t,n,r){if(n>Gxe){r.push({key:t,value:FXt,depth:n});return}if(EU(e)){for(const[a,o]of Object.entries(e))Zxe(o,t?`${t}.${a}`:a,n+1,r);return}const i=Ixe(e);i!==null&&r.push({key:t,value:i,depth:n})}function Dxe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))Zxe(r,n,1,t);return t}const JXt=512;function e4t(e,t){if(t)return!0;if(!e)return!1;let n=JXt;const r=(i,a)=>{if(n--<=0||a>Gxe)return!0;if(!EU(i))return Ixe(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 t4t(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(!EU(n))return null;const r=Dxe(n);return r.length>0?r:[{key:"",value:BXt,depth:1}]}const n4t=8,u7="max-h-[min(320px,40vh)]",Mxe=u7,r4t=({line:e})=>h.jsxs("div",{className:q("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*n4t},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})]}),OK=({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(r4t,{line:n},r))});function dK(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+uK);const f=c.children.length>0?Array.from(c.children):[c];n(KXt(f.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,uK))};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 fK=({lines:e,overflowing:t})=>t?h.jsx("span",{className:q("mt-1 block text-ink-dim"),children:e>0?HXt(e):" "}):null,i4t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=Dxe(e),o=t4t(t),s=$.useRef(null),l=$.useRef(null),c=dK(s),u=dK(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(u7,"overflow-auto"),children:h.jsx(OK,{lines:a,label:"input"})}),h.jsx(fK,{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(u7,"overflow-auto"),children:o?h.jsx(OK,{lines:o,label:"result-json"}):h.jsx("pre",{className:q("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),h.jsx(fK,{lines:u.lines,overflowing:u.overflowing})]})]})},a4t="mcp__",o4t={bash:q9e,read:pk,write:vG,edit:vG,glob:Rp,grep:fv,todo:Nze,wake:fk,list_variables:SG,read_variable:SG,browser:bG,console:hz,project:tze,project_delete:C9e,web_search:bG,web_fetch:Ov,task:Bd,agent:Bd,send:Aue,peer:Eze,sessions:g9e};function s4t(e){const t=e.trim().toLowerCase(),n=o4t[t];return n||(t.startsWith(a4t)?jue:I9e)}const l4t=fz,c4t=Mze,u4t=Zze,hK="min-h-5 py-0",pK={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},O4t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?pK.plain:pK[B4e(t)],d4t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",f4t=({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:""},h4t=1e3;function p4t(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,h4t);return()=>window.clearInterval(i)},[e]),t}const m4t=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=p4t(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?U4e[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?Y4e[t]??null:null,f=s&&t?W4e[t]:void 0,p=s?t==="mailbox"?c4t:t==="unconfirmed"?u4t:null:e==="interrupted"?l4t:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":ec(a??0):EA(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=s4t(e),S=uf(e),{verb:x,object:b}=qle(e,r,i,g,t,I4e(s)),w=h.jsxs("span",{className:q("flex min-w-0 flex-1 items-center gap-2"),children:[h.jsx("span",{"aria-hidden":!0,className:q("flex size-3.5 shrink-0 [&_svg]:size-3.5",O4t(o,e)),children:h.jsx(v,{})}),n?null:h.jsx("span",{"data-trace-verb":"",className:q("shrink-0 whitespace-nowrap text-body-sm",d4t(o)),title:S,children:x}),h.jsx("span",{className:q("min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:b,children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),h.jsx("span",{className:q("sr-only"),children:"pending"})]}):b}),h.jsx(f4t,{added:u,removed:O}),h.jsx(m4t,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),Q=g?{"data-glass-state":"running"}:void 0,k=g?"bg-elevated":y?"bg-danger-wash":"hover:bg-row-hover",T=d?h.jsx(ya,{summary:w,chevron:"leading",defaultOpen:f,className:q("@container/toolrow",p),triggerData:Q,rowClassName:hK,triggerClassName:q("-mx-2 rounded-sm px-2",k),children:d}):h.jsx(ya,{disabled:!0,summary:w,triggerData:Q,rowClassName:hK,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},g4t=3,Vxe=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},O7=e=>{const t=new Map;let n=0;for(const a of e){const o=Vxe(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=v4t(b4t(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}},$4t=e=>O7(e).units;function y4t(e){return $4t(e).join(" · ")}const mK={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,v4t=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"}`]},b4t=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=Vxe(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",mK.todo);else{const u=mK[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 w4t(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 S4t(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=w4t(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 x4t(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return qle(n.name,n.summary??"",null,!0,n.op)}return null}function Q4t(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>=g4t)n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:o,summary:{...O7(o),units:[...O7(o).units,...t.receiptSummaryOf?.(a)??[]]},failedCount:o.filter(s=>s.failed).length,span:S4t(o),live:x4t(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 gK=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,k4t=(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)},P4t=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 Lxe(e){let t=null;for(const n of e){const r=jx(n);typeof r=="number"&&(t=(t??0)+r)}return t}function _4t(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 T4t="min-h-5 py-0",R4t=1e3;function X4t(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,R4t);return()=>window.clearInterval(i)},[e]),t}const E4t=({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=X4t(n?.running===!0),d=n===null?null:Math.max(0,((n.running?O:n.endedAtMs??O)-n.startedAtMs)/1e3),f=d===null?"":EA(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(ya,{animate:i||!s,open:i,onOpenChange:a,rowClassName:T4t,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)]})},$K=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],q4t=80,j4t=1e3,Fxe=({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=Rz("(prefers-reduced-motion: reduce)"),f=$.useRef(n??Date.now()),p=$.useRef(t),m=$.useRef(n);if(p.current!==t)p.current=t,m.current=n,f.current=n??Date.now(),c&&u(!1),l(0);else if(m.current!==n){const v=m.current!==void 0&&n===void 0;m.current=n,u(v),v||(f.current=n,l(Math.floor((Date.now()-n)/1e3)))}const g=$.useRef(r!==!1),y=$.useRef(t);return $.useEffect(()=>{const v=r!==!1,S=g.current,x=y.current===t;g.current=v,y.current=t,!S&&v&&x&&l(Math.floor((Date.now()-f.current)/1e3))},[r,t]),$.useEffect(()=>{const v=O?window.setInterval(()=>l(Math.floor((Date.now()-f.current)/1e3)),j4t):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const S=window.setInterval(()=>o(x=>(x+1)%$K.length),q4t);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:$K[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):""})]})},C4t="min-h-5 py-0",Lu=()=>h.jsx("span",{"aria-hidden":!0,className:q("text-ink-dim text-meta"),children:"·"}),A4t=({recordIds:e,segmentIds:t,anchorRecordId:n,className:r,durationS:i,actionCount:a,partial:o=!1,title:s,stampTs:l,label:c=null,completed:u=!1,open:O,onOpenChange:d,children:f,condensedMedia:p,mediaCount:m=0,group:g=null,episode:y=null})=>{const v=o?`${a}+ actions`:a===1?"1 action":`${a} actions`,S=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,x=y?.receipts??g?.count,b=x===void 0?null:`At least ${x} messages — earlier rows are not loaded`,w=$.useRef(null),Q=()=>{w.current?.querySelector("button[aria-expanded]")?.focus(),d(!0)};return h.jsxs("div",{ref:w,className:q("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u&&!y?.active?"true":void 0,"data-segment-active":y?.active?"true":void 0,"data-record-id":n,children:[h.jsx(ya,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:C4t,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(wA,{"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(Fxe,{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(Yxe,{timestamp:l,scope:"answer"})})]}),children:h.jsx("div",{className:q("flex flex-col"),children:f})}),!O&&p&&h.jsx("div",{className:q("pb-2"),children:p(Q)})]})},Bxe="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}),z4t="could not be displayed. It may have been moved, renamed, or deleted.",qU="could not be displayed. Its stored copy is not available to this reader.",Hxe="could not be played. Its stored copy is not available to this reader.",Kxe=Hxe,_f=({name:e,detail:t=z4t,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(wG,{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(wG,{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),Jxe?.(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 Jxe=null;function zOn(e){Jxe=e}function fR(){return Fi.getState().element}const d7=4,eQe=2,U4t=2,W4t=4,tQe=d7+eQe,N4t=.8,Y4t=24,yK=.3,vK=1;function G4t(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+eQe)/tQe))}function I4t(e,t){const n=Math.min(e,t-e);return Number.isFinite(n)?Math.max(0,Math.min(1,n/Y4t)):0}function Z4t(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 D4t(e,t,n){const r=G4t(t),i=e===null?null:Z4t(e,r),a=[],o=Math.max(1,r-1);for(let s=0;s<r;s+=1){const l=s*tQe,c=l+d7/2,O=(i===null?0:i[s])*n*N4t,d=Math.max(W4t,Math.round(O)),f=yK+(vK-yK)*(s/o);a.push({x:l,width:d7,height:d,alpha:Math.min(vK,f)*I4t(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 M4t(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 V4t(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}function bK(e,t){return`${s$(e)} of ${s$(t)}`}const L4t=4,wK=1,F4t="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",nQe=({ownerId:e,src:t,label:n,peaks:r,durationHint:i=null,variant:a="full",className:o})=>{const s=Fi(B=>B.ownerId===e),l=Fi(B=>B.ownerId===e?B.status:"idle"),c=Fi(B=>B.ownerId===e?B.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),x=$.useRef(null),b=$.useRef(null),w=$.useRef(null),[Q,k]=$.useState({width:0,height:0,dpr:1});$.useEffect(()=>{const B=v.current;if(!B)return;const I=()=>{const ie=B.getBoundingClientRect();k({width:ie.width,height:ie.height,dpr:window.devicePixelRatio||1})};I();const L=new ResizeObserver(I);return L.observe(B),()=>L.disconnect()},[]);const T=$.useCallback(B=>{if(!B||Q.width<=0)return;const I=B.getContext("2d");if(!I)return;B.width=Math.max(1,Math.round(Q.width*Q.dpr)),B.height=Math.max(1,Math.round(Q.height*Q.dpr)),I.setTransform(Q.dpr,0,0,Q.dpr,0,0),I.clearRect(0,0,Q.width,Q.height);const L=getComputedStyle(B).color,ie=D4t(r,Q.width,Q.height);I.fillStyle=L;for(const H of ie)I.globalAlpha=H.alpha,I.beginPath(),I.roundRect(H.x,(Q.height-H.height)/2,H.width,H.height,U4t),I.fill();I.globalAlpha=1},[Q.width,Q.height,Q.dpr,r]);$.useEffect(()=>{T(S.current),T(x.current)},[T]);const _=$.useRef(null),E=$.useCallback(B=>{const I=V4t(B,p),L=x.current;v.current?.style.setProperty("--sound-progress",`${I*100}%`),L&&(L.style.clipPath=`inset(0 ${(1-I)*100}% 0 0)`);const ie=s$(B);w.current&&w.current.textContent!==ie&&(w.current.textContent=ie);const H=b.current;H&&(H.setAttribute("aria-valuenow",String(Math.floor(B))),H.setAttribute("aria-valuetext",bK(B,p)))},[p]);$.useEffect(()=>{const B=m||u,I=()=>E(s?fR()?.currentTime??0:W.current);if(!B){I();return}let L=0;const ie=()=>{const H=_.current??fR()?.currentTime??0;E(H),L=requestAnimationFrame(ie)};return L=requestAnimationFrame(ie),()=>cancelAnimationFrame(L)},[m,u,s,E]);const R=$.useCallback(async()=>(f(!1),Fi.getState().play(e,t,{onError:()=>f(!0)})),[e,t]),j=$.useCallback(B=>{const I=Fi.getState();if(m){I.seek(e,B),E(B);return}R().then(L=>{L!==!1&&(Fi.getState().seek(e,B),E(B))})},[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),N=$.useRef(null),G=$.useCallback(B=>{const I=v.current;if(!I)return 0;const L=I.getBoundingClientRect();return M4t(B-L.left,L.width,p)},[p]),D=B=>{if(g)return;B.currentTarget.setPointerCapture?.(B.pointerId),N.current={pointerId:B.pointerId,startX:B.clientX,moved:!1,pendingX:B.clientX,raf:0}},F=B=>{const I=N.current;!I||I.pointerId!==B.pointerId||(Math.abs(B.clientX-I.startX)>L4t&&(I.moved||O(!0),I.moved=!0),I.pendingX=B.clientX,I.moved&&I.raf===0&&(I.raf=requestAnimationFrame(()=>{const L=N.current;if(!L)return;L.raf=0;const ie=G(L.pendingX);_.current=ie,Fi.getState().scrub(e,ie),E(ie)})))},z=B=>{const I=N.current;if(!I||I.pointerId!==B.pointerId)return;I.raf!==0&&cancelAnimationFrame(I.raf),N.current=null,_.current=null,B.currentTarget.releasePointerCapture?.(B.pointerId);const L=G(B.clientX);if(I.moved){W.current=L,O(!1),Fi.getState().seek(e,L),E(L);return}j(L)},M=B=>{const I=fR(),L=s&&I?I.currentTime:0;if(B.key===" "||B.key==="Enter"){B.preventDefault(),C();return}let ie=null;if(B.key==="ArrowLeft"?ie=L-wK:B.key==="ArrowRight"?ie=L+wK:B.key==="Home"?ie=0:B.key==="End"&&(ie=p),ie===null)return;B.preventDefault();const H=Math.max(0,Math.min(p,ie));j(H)},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:F4t,disabled:g,onClick:()=>void C(),"aria-label":`${m?"Pause":"Play"} ${n}`,children:g?h.jsx(Go,{size:"sm"}):m?h.jsx(vue,{size:22,"aria-hidden":"true"}):h.jsx(FAe,{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":bK(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:D,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:x,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 SK(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 xK=new Map;async function B4t(e,t){try{const n=await su({op:"sessions.attachment.waveform",sessionId:e.sessionId,digest:t},null);if(n.kind==="json")return SK(n.body);if(n.kind==="bytes"){const r=new TextDecoder().decode(n.data);try{return SK(JSON.parse(r))}catch{return null}}return null}catch{return null}}function rQe(e,t){const n=t?.sessionId??null,r=t?.childId??null,[i,a]=$.useState(()=>e?H4t(e):null);return $.useEffect(()=>{if(!e||!n){a(null);return}let o=!0;return K4t({sessionId:n,childId:r},e).then(s=>{o&&a(s)}),()=>{o=!1}},[e,n,r]),i}function H4t(e){return f7.get(e)??null}const f7=new Map;function K4t(e,t){const n=xK.get(t);if(n)return n;const r=B4t(e,t).then(i=>(f7.set(t,i),i)).catch(()=>(f7.set(t,null),null));return xK.set(t,r),r}function iQe(e){return`sound:${e.attachment??e.id}`}const jU=({audio:e,scope:t,label:n,ownerId:r})=>{const i=Dv(e,t),a=rQe(e.attachment,t);return i.state==="missing"?h.jsx(_f,{name:n,detail:Kxe}):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(nQe,{ownerId:r??iQe(e),src:i.url,label:n,peaks:a,durationHint:e.durationS??null})})},Qd=1,aQe=4,QK=(e,t)=>Math.min(aQe,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,J4t=(e,t)=>`Image ${e+1} of ${t}`,kK=(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))}},eEt="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",tEt="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",PK=e=>q(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),nEt="opacity-45",CU=({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 B=()=>{clearTimeout(U),U=setTimeout(()=>{const L=S.current;if(L&&(L.matches(":hover")||L.contains(document.activeElement))){B();return}v(!1)},hde)},I=()=>{v(!0),B()};return v(!0),B(),document.addEventListener("pointermove",I,{passive:!0}),document.addEventListener("pointerdown",I,{passive:!0}),document.addEventListener("keydown",I),document.addEventListener("focusin",I),()=>{clearTimeout(U),document.removeEventListener("pointermove",I),document.removeEventListener("pointerdown",I),document.removeEventListener("keydown",I),document.removeEventListener("focusin",I)}},[n]);const x=s?.onPrev,b=s?.onNext,w=s!==void 0&&s.count>1,Q=w?tEt:eEt,k=$.useRef(null),T=l??k;$.useEffect(()=>{if(!n||!w)return;const U=B=>{B.defaultPrevented||B.metaKey||B.ctrlKey||B.altKey||(B.key==="ArrowLeft"?(B.preventDefault(),x?.()):B.key==="ArrowRight"&&(B.preventDefault(),b?.()))};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[n,w,x,b]),pA(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 B=_.current;B&&m(I=>kK(I,{width:B.clientWidth,height:B.clientHeight},U))},C=()=>{E&&(f(Qd),m(Vg))},W=$.useRef(null),[N,G]=$.useState(!1),D=E&&d>Qd,F=U=>{!D||U.button!==0||(U.currentTarget.setPointerCapture(U.pointerId),W.current={pointerId:U.pointerId,startX:U.clientX,startY:U.clientY,pan:p},G(!0))},z=U=>{const B=W.current,I=_.current;!B||B.pointerId!==U.pointerId||!I||m(kK({x:B.pan.x+(U.clientX-B.startX),y:B.pan.y+(U.clientY-B.startY)},{width:I.clientWidth,height:I.clientHeight},d))},M=U=>{W.current?.pointerId===U.pointerId&&(W.current=null,G(!1))},te=e!==void 0&&!O?h.jsx("div",{ref:_,"data-image-viewport":"",tabIndex:-1,className:q(Q,"relative h-fit w-fit overflow-hidden leading-none outline-none",D&&(N?"cursor-grabbing":"cursor-grab"),D&&"touch-none"),onPointerDown:F,onPointerMove:z,onPointerUp:M,onPointerCancel:M,children:h.jsx("img",{src:e,alt:t,draggable:!1,className:q(Q,"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:PK(Q),"aria-hidden":"true"}):h.jsx("div",{className:PK(Q),children:a});return h.jsx(mA,{open:n,onOpenChange:r,children:h.jsxs(gA,{ref:T,tabIndex:-1,onOpenAutoFocus:U=>{U.preventDefault(),(_.current??T.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:U=>{const B=i?.current;B&&(U.preventDefault(),B.focus())},className:q("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",Q,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[h.jsx($A,{className:"sr-only",children:t}),w&&s?h.jsx("div",{"aria-live":"polite",className:"sr-only",children:J4t(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":`${nEt} duration-base`),children:[w&&s?.filmstrip?h.jsx("div",{className:"pointer-events-auto fixed inset-x-0 bottom-4 mx-auto w-fit max-w-[calc(100vw-256px)]",children:s.filmstrip}):null,w?h.jsxs(h.Fragment,{children:[h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Previous image",title:"Previous image",onClick:s?.onPrev,className:"pointer-events-auto fixed top-0 bottom-0 left-4 my-auto","data-image-viewer-prev":"",children:h.jsx(zAe,{"aria-hidden":"true"})}),h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Next image",title:"Next image",onClick:s?.onNext,className:"pointer-events-auto fixed top-0 right-4 bottom-0 my-auto","data-image-viewer-next":"",children:h.jsx(rle,{"aria-hidden":"true"})})]}):null,h.jsxs("div",{className:"pointer-events-auto fixed right-4 bottom-4 flex items-center gap-1",children:[h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",title:"Zoom out",disabled:!E||d===Qd,onClick:()=>j(QK(d,-1)),children:h.jsx(Nue,{"aria-hidden":"true"})}),h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",title:"Zoom in",disabled:!E||d===aQe,onClick:()=>j(QK(d,1)),children:h.jsx(Wue,{"aria-hidden":"true"})}),h.jsx(Ee,{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(ZRe,{asChild:!0,children:h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:q("pointer-events-auto fixed top-4 right-4"),"aria-label":"Close image",title:"Close image",children:h.jsx(ea,{"aria-hidden":"true"})})})]})]})})};CU.displayName="ImageLightbox";const rEt={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(" ")},iEt=/[/\\]/,_K=e=>{const t=e.split(iEt);return t[t.length-1]},oQe=$.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=Kn(T=>T.setCanvasOpen),{setViewMode:m}=zd(),g=$.useCallback(async()=>{const T=_K(e),_=C=>{C&&console.error("Error processing file:",C);const W=e.startsWith("file://")?e.substring(7):e;window.api.openFile(W).catch(N=>{console.error("Error opening file:",N)})},{setFiles:E,setOpenTabs:R,setSelectedTab:j}=zd.getState();if(e.startsWith("data:"))if(e7(T)){const C=e,W={id:C,title:T,path:C,content:e,type:NS(e)},G=zd.getState().conversations?.[n],D=G?.files??[],F=G?.openTabs??[],z=(()=>{const U=D.findIndex(B=>B.id===C);return U!==-1?[...D.slice(0,U),W,...D.slice(U+1)]:[...D,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&&e7(T)){const N=C,G={id:N,title:T,path:C,content:W.data,type:NS(e)},F=zd.getState().conversations?.[n],z=F?.files??[],M=F?.openTabs??[],te=(()=>{const I=z.findIndex(L=>L.id===N);return I!==-1?[...z.slice(0,I),G,...z.slice(I+1)]:[...z,G]})();E(n,te);const B=M.some(I=>I.id===N)?M:[...M,{id:N,title:T}];R(n,B),j(n,N),p(!0),m(n,"documents");return}p(!0),m(n,"files")}catch(W){const N=W instanceof Error?W.message:String(W??"Unknown error reading file");return _(N)}}},[e,p,m,n]),y=()=>{l(!0)},v=Qxe(e),x=(v==="path"||v==="data")&&n!=="",b=Pxe(v,{canShowInCanvas:x,source:t}),w=v==="path",Q=r??_K(e);if(s)return h.jsx(_f,{name:Q,compact:i==="thumbnail"});const k=h.jsx(zO,{boundary:i==="thumbnail"?"control":"hairline",children:h.jsx("img",{className:q(rEt[i],c?"opacity-100":"opacity-0"),src:t,alt:Q,onLoad:()=>u(!0),onError:y})});return h.jsxs("div",{className:"group relative inline-block",children:[h.jsx("button",{ref:f,type:"button",className:q("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>d(!0),"aria-label":o?o.label:`Expand ${Q}`,title:o?o.title:`Click to expand ${Q}`,"aria-current":o?.current?"true":void 0,children:k}),b&&h.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 right-1 z-[2] opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",onClick:T=>{T.stopPropagation()},onKeyDown:T=>T.stopPropagation(),children:h.jsx(Txe,{file:e,src:t,label:Q,onShowInCanvas:x?g:void 0})}),o?null:a?a({open:O,onOpenChange:d,restoreFocusTo:f}):h.jsx(CU,{src:t,label:Q,open:O,onOpenChange:d,restoreFocusTo:f,fallback:h.jsx(_f,{name:Q,detail:w?void 0:qU})})]})});oQe.displayName="ImageAttachment";const aEt=(e,t,n)=>e.name??(n===1?"Image":`Image ${t+1}`),oEt={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},sEt=({cold:e,children:t})=>e?h.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,lEt=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=aEt})=>{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]??oEt,p=o(f,d,s),m=_U(f,n),g=$.useRef(null),y=$.useRef(null),[v,S]=$.useState(!1),x=$.useCallback(G=>{g.current=G,S(G!==null)},[]),b=G=>{const D=g.current?.querySelector(`button[aria-label="Show image ${G+1} of ${s}"]`);D?D.focus():y.current?.focus()},w=G=>{const D=pR(d,s,G),F=g.current?.contains(document.activeElement)??!1;c(D),F&&b(D)},Q=()=>w(-1),k=()=>w(1),T=JSON.stringify([n?.sessionId,n?.childId,e.map(G=>[G.id,G.attachment,G.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(G=>{E(D=>{if(!r||D.identity!==T||!D.open||G.every(z=>D.indices.has(z)))return D;const F=new Set(D.indices);for(const z of G)F.add(z);return{...D,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 G=g.current;if(!r||!v||!G||typeof IntersectionObserver>"u")return;let D=!0;const F=new IntersectionObserver(z=>{D&&R(z.filter(M=>M.isIntersecting).map(M=>Number(M.target.dataset.imageSlot)-1))},{root:G});for(const z of G.querySelectorAll("[data-image-slot]"))F.observe(z);return()=>{D=!1,F.disconnect()}},[r,v,R]);const W=(G,D)=>!!G.data||!G.attachment||D===d||D===j||D===C||_.identity===T&&_.open&&_.indices.has(D);$.useEffect(()=>{(g.current?.querySelector(`[data-image-slot="${d+1}"]`)??g.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[v,d]);const N=s>1?h.jsx("ul",{role:"list",ref:x,"aria-label":`${s} images`,"data-image-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((G,D)=>h.jsx("li",{"data-image-slot":D+1,className:q("flex shrink-0 scroll-mx-px rounded-sm leading-none",D===d&&"ring-1 ring-ink"),children:h.jsx(sEt,{cold:!!G.attachment&&!G.data,children:W(G,D)?h.jsx(Dm,{image:G,scope:n,size:"thumbnail",label:o(G,D,s),press:{onPress:()=>c(D),label:`Show image ${D+1} of ${s}`,title:`Show image ${D+1} of ${s}`,current:D===d}}):h.jsx("button",{type:"button","aria-label":`Show image ${D+1} of ${s}`,title:`Show image ${D+1} of ${s}`,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{R([D]),c(D)},children:h.jsx(zO,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},G.id))}):void 0;return h.jsx(CU,{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:qU}),layerRef:y,group:{index:d,count:s,onPrev:Q,onNext:k,filmstrip:N}})},Dm=({image:e,scope:t,label:n,size:r,group:i,press:a})=>{const o=_U(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:qU});const s=o.url;return h.jsx("div",{className:q("inline-block max-w-full"),children:h.jsx(oQe,{file:s,src:s,label:n,size:r,conversationId:t?.sessionId??"",press:a,overlay:i?l=>h.jsx(lEt,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:l.open,onOpenChange:l.onOpenChange,restoreFocusTo:l.restoreFocusTo}):void 0})})},cEt="Generating name…",uEt={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 OEt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function AU(e,t){return`Turn ${e} of ${t}`}const dEt=e=>e.charAt(0).toLowerCase()+e.slice(1);function fEt(e,t){const n=AU(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function hEt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function pEt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function mEt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const gEt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function $Et(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 yEt(e,t){const n=dEt(AU(e.turn,t));if(e.kind==="user"){const i=$Et(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 vEt(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)vEt(e,r)==="pending"&&n.push(r);return n}const bEt=120,TK=80,wEt="Turn checkpoints",SEt={complete:xu,error:kp,interrupted:fz,open:DAe},xEt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},QEt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?SEt[n]:null,i=pEt(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:[AU(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})]})]}),hEt(e)&&h.jsx("p",{className:q("text-ink-dim text-meta"),children:cEt}),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",xEt[n]),children:[h.jsx(r,{"aria-hidden":"true",className:q("size-3.5 shrink-0")}),gEt[n]]})})]})},kEt=$.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",uEt[n])})})}),PEt=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{const s=$.useId(),[l,c]=$.useState(null),[u,O]=$.useState(null),[d,f]=$.useState(null),p=$.useRef(t);p.current=t;const m=$.useRef(new Map),g=$.useRef(null),y=$.useRef(null),v=$.useRef(null),S=$.useCallback(()=>{y.current!==null&&(clearTimeout(y.current),y.current=null),v.current!==null&&(clearTimeout(v.current),v.current=null)},[]),x=$.useCallback((H,K)=>{S();const ne=()=>{O(H),f(p.current.find(ae=>ae.id===H)??null)};if(K<=0){ne();return}y.current=setTimeout(()=>{y.current=null,ne()},K)},[S]),b=$.useCallback(H=>{if(S(),H<=0){O(null);return}v.current=setTimeout(()=>{v.current=null,O(null)},H)},[S]),w=$.useRef(e);$.useEffect(()=>{w.current!==e&&(w.current=e,S(),M.current=null,c(null),O(null),f(null))},[e,S]);const Q=$.useRef(null);$.useLayoutEffect(()=>{const H=g.current;if(!(t.length===0||H===null)){if(o!==null&&k.current===e){Q.current=e;return}Q.current!==e&&(Q.current=e,H.scrollTop=H.scrollHeight)}},[o,t.length,e]);const k=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const H=g.current,K=m.current.get(o);if(H===null||K===void 0)return;k.current=e;const ne=H.getBoundingClientRect(),ae=K.getBoundingClientRect(),ce=ae.top-ne.top+H.scrollTop,Pe=ce+ae.height,we=24;ce<H.scrollTop+we?H.scrollTop=Math.max(0,ce-we):Pe>H.scrollTop+H.clientHeight-we&&(H.scrollTop=Pe-H.clientHeight+we)},[o,e]),$.useEffect(()=>()=>S(),[S]);const T=$.useRef(r);$.useEffect(()=>{T.current=r});const _=$.useMemo(()=>mEt(t),[t]),E=$.useMemo(()=>new Map(t.map(H=>[H.id,yEt(H,_)])),[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 N=$.useCallback((H,K)=>{K?m.current.set(H,K):m.current.delete(H)},[]),[G,D]=$.useState(null),F=G&&t.some(H=>H.id===G)?G:t[0]?.id??null,z=$.useCallback(H=>{const K=Math.max(0,Math.min(t.length-1,H)),ne=t[K];ne&&(D(ne.id),m.current.get(ne.id)?.focus())},[t]),M=$.useRef(null),te=$.useCallback(H=>{M.current!==H&&(M.current=H,c(H),x(H,bEt))},[x]),U=$.useCallback(()=>{M.current=null,c(H=>H===null?H:null),b(TK)},[b]),B=$.useCallback(H=>{M.current=H,D(H),c(K=>K===H?K:H),x(H,0)},[x]),I=$.useCallback(()=>{M.current=null,c(H=>H===null?H:null),b(TK)},[b]),L=$.useCallback(H=>{b(0),M.current=null,c(null),n(H)},[b,n]),ie=$.useCallback((H,K)=>{if(H.key==="Escape"){b(0);return}const ne=t.findIndex(ae=>ae.id===K);if(!(ne<0)){if(H.key==="ArrowDown"){H.preventDefault(),H.stopPropagation(),z(ne+1);return}if(H.key==="ArrowUp"){H.preventDefault(),H.stopPropagation(),z(ne-1);return}if(H.key==="Home"){H.preventDefault(),H.stopPropagation(),z(0);return}H.key==="End"&&(H.preventDefault(),H.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":wEt,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(H=>h.jsx(kEt,{checkpoint:H,state:OEt({id:H.id,previewId:l,activeId:o,loaded:a?a.has(H.id):!0}),label:E.get(H.id)??"",roving:H.id===F,registerTick:N,onPreview:te,onPreviewEnd:U,onFocusMark:B,onBlurMark:I,onActivate:L,onKeyMark:ie,describedBy:W&&u===H.id?s:void 0},H.id))})]}),h.jsxs(DRe,{open:W,onOpenChange:H=>{H||b(0)},children:[h.jsx(MRe,{virtualRef:C}),R&&h.jsx(VRe,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":R.kind==="user"?"Your message":fEt(R,_),onOpenAutoFocus:H=>H.preventDefault(),onCloseAutoFocus:H=>H.preventDefault(),onFocusOutside:H=>{const K=H.detail?.originalEvent?.target;K instanceof Element&&K.closest("[data-lo-checkpoint-rail]")&&H.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(QEt,{checkpoint:R,turnCount:_})})]})]})},_Et=$.memo(PEt);function TEt(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 REt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function XEt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function sQe(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):!REt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function EEt(e,t){return XEt(e,t)||sQe(e,t)!==null}const qEt=3;function jEt(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>=qEt){n.onMissing();return}const s=sQe(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const RK=(e,t,n)=>n===1?"Image":`Image ${t+1}`,XK=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=k4t(e.length,{uncapped:r}),s=P4t(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:RK(O,d,e.length),group:{images:e,index:d,labelFor:RK}})},O.id));return h.jsxs("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-fold-media":"",className:q("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ml-5":"ml-0"),children:[u,o>0&&h.jsx("li",{className:q("flex h-[78px] items-center leading-none"),children:h.jsx(Ee,{variant:"outline",size:"sm",onClick:n,"aria-label":`+${o} more image${o===1?"":"s"}`,title:`+${o} more image${o===1?"":"s"}`,children:`+${o}`})},"fold-media-more")]})};function EK(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 CEt(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 AEt=({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:Hxe}):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 zEt({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(jU,{audio:r.audio,ownerId:`${iQe(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 UOn({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(lQe,{onKeepWaiting:c,onRequestStop:O}):null,[a,t,c,O]);return{paneRef:s,stop:u,confirmation:d}}function lQe({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(Ee,{ref:n,"aria-describedby":r,variant:"ghost",size:"sm",onClick:e,children:"Keep waiting"}),h.jsx(Ee,{variant:"secondary",size:"sm",onClick:t,children:"Request stop"})]})]})}const UEt=1e3;function WEt(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,UEt);return()=>window.clearInterval(i)},[e]),t}function NEt(){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 YEt({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?sY:oY;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:EA(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?sY:oY);n=e.batch?`${gR(e.material??"sound-effect")} batch stopped.`:e.settlementCaption||e.settled?XEe(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 GEt({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 IEt(e,t){return e==="cancel"?"Stop":e==="restart"?t==="failed"?"Retry":"Restart":"Edit and restart"}const ZEt=({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=WEt(c),O=qEe(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(NEt,{}):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(YEt,{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(lQe,{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(LRe,{"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(GEt,{line:m}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batch?h.jsx(zEt,{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(AEt,{video:g,scope:t,label:S},g.id):g.kind==="audio"?h.jsx(jU,{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(Ee,{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:IEt(g.kind,e.state)},g.kind))}):null]})},l$=1e4,cQe=/\s/,DEt=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||cQe.test(r))return t}}return-1},MEt=e=>{for(let t=e.length;t>0;t-=1)if(cQe.test(e[t-1]))return t;return-1},VEt=/[\uD800-\uDBFF]/,LEt=e=>VEt.test(e[l$-1])?l$-1:l$;function zU(e){if(e.length<=l$)return{text:e,clipped:!1};const t=e.slice(0,l$),n=DEt(t),r=MEt(t),i=n>0?n:r>0?r:LEt(t),a=e.slice(0,i).trimEnd();return{text:a.length>0?a:t,clipped:!0}}const uQe="[speech]",FEt="Couldn't speak this aloud. Try again.",BEt="Couldn't speak this aloud. Try again.",OQe="This conversation's agent is no longer available.",HEt=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.",OQe,"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 KEt(e){const t=e instanceof Error?e.message:String(e);return HEt.has(t)?t:(console.error(`${uQe} ${t}`),FEt)}function JEt(e){return(e instanceof Error?e.message:String(e))===OQe}function eqt(e){const t=e?.binding?.agent;return typeof t=="string"&&t.length>0?t:null}function tqt(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 nqt=100;function rqt(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 iqt(e){if(!e)return null;const t=hv(Nf.baseUrl),n=await $R(async()=>{const{profiles:a}=await Re({op:"profiles.list"});return tqt(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,nqt,e);return a.status<400?rqt(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 UU(e){return ar(t=>e?eqt(t.sessions.find(n=>n.session_id===e)):null)}const aqt=20,dQe=e=>`msg:${e}`,qK=e=>`speech:${e}`,oqt="speech:",sqt=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}:${sqt(t)}`,WU=(e,t)=>async()=>{const n=()=>jK.speech.create({input:t}),r=await iqt(e);return r===null?n():jK.speech.createForAgent(r,{input_text:t}).catch(i=>{if(!JEt(i))throw i;return n()})},jK=hv(Nf.baseUrl),lqt=e=>{for(;e.size>aqt;){const t=e.keys().next().value;if(t===void 0)return;e.delete(t)}},yR=new Map,cqt=(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 cqt(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),lqt(u),e({audioCache:u}),t().generation!==i)return}if(t().generation!==i)return;const o=URL.createObjectURL(a);if(!await Fi.getState().play(qK(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(`${uQe} playback failed for ${n}`),pi(BEt)}})||t().generation!==i){Fi.getState().stop(qK(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}),pi(KEt(a))}},stopSpeech:()=>{const n=Fi.getState();n.ownerId?.startsWith(oqt)&&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(dQe(n),WU(r,i))}}));function NU({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}=oGe(),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:nde("speaking-aloud",O),y=!d&&!f&&(!u||!r);return{label:d?"Stop":f?"Loading speech. Press again to cancel.":m?"Replay speech":"Speak aloud",tooltip:d?"Stop":f?"Loading speech. Press again to cancel.":g??(m?"Replay speech":"Speak aloud"),isPlaying:d,isLoading:f,disabled:y,reason:g,active:d||f,press:()=>{if(d){a();return}if(f){e!==null&&i(e);return}if(y)return;const b=t();if(b===null||b.trim().length===0)return;const{text:w,clipped:Q}=zU(b);Q&&!p&&Tp(`Reading the first ${w.length.toLocaleString("en-US")} characters. The rest is not read aloud.`),n({text:w})}}}function fQe(e){$.useEffect(()=>{if(e!==null)return()=>{Mv.getState().dismiss(e)}},[e])}const YU=({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(Ee,{variant:"ghost",size:"icon-sm","aria-label":e.label,className:q("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:e.press,disabled:e.disabled,children:e.isPlaying?h.jsx(m1,{"aria-hidden":"true"}):e.isLoading?h.jsx(Go,{size:"xs"}):h.jsx(Y9e,{"aria-hidden":"true"})}),r&&h.jsx("span",{id:n,className:"sr-only",children:e.reason})]})})},Mm="data-lo-quote-toolkit";function h7(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const CK=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${Mm}]`)??null,uqt=e=>e.nodeType===Node.ELEMENT_NODE,Oqt=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>uqt(r)&&r.hasAttribute(Mm));return n===-1?t.length:n},dqt=(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,fqt=e=>{const t=Array.from(document.querySelectorAll(`[${Mm}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>dqt(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(CK(n.startContainer)||CK(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,Oqt(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:fqt(n)}}const hQe=8,hqt=.5;function pqt(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 AK=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function mqt({lines:e,container:t,viewport:n,size:r,gap:i=hQe,row:a,belowWhenOffFirstLine:o=!1}){if(e.length===0)return null;const s=pqt(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*hqt,d=l.top-i-r.height>=s.top,f=c.bottom+i+r.height<=s.bottom,m=d&&!(o&&O&&f);return{top:AK(m?l.top-i-r.height:c.bottom+i,s.top,s.bottom-r.height),left:AK(l.left,s.left,s.right-r.width),placement:m?"above":"below"}}const zK="[data-lo-canonical-transcript]",gqt="[data-lo-transcript-content]",UK=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),$qt=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function pQe(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=mqt({lines:f,container:UK((O.closest(zK)??O).getBoundingClientRect()),viewport:$qt(),size:{width:d.offsetWidth,height:d.offsetHeight},row:UK(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(zK),p=f?.querySelector(gqt),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 mQe(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",yqt=120,vqt=2;function gQe(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=iTt(u);if(O){n(f=>f===O?f:O),i(f=>f===!0?f:!0);return}if(i(f=>f===!1?f:!1),DSe()){n(f=>f===null?f:null);return}const d=o.current&&u.contains(o.current)?o.current:null;n(f=>f===d?f:d)},[e]);$.useEffect(()=>{const u=e.current;if(!u)return;let O=0;const d=Q=>{O&&(clearTimeout(O),O=0),o.current=Q,l()},f=Q=>{if(O&&clearTimeout(O),!Q){O=0,o.current=null,l();return}o.current!==Q&&(s.current=null,O=setTimeout(()=>{O=0,o.current=Q,l()},yqt))},p=(Q,k)=>{const T=o.current;if(!T||!u.contains(T))return!1;const _=u.querySelector(`[${Ih}]`),E=hQe+vqt;for(const R of[T,_]){if(!R)continue;const j=R.getBoundingClientRect();if(!(j.width<=0||j.height<=0)&&Q>=j.left-E&&Q<=j.right+E&&k>=j.top-E&&k<=j.bottom+E)return!0}return!1},m=Q=>{const k=Q.target;if(k?.closest(`[${Mm}]`))return;const T=k?.closest(Gh)??null;!T&&p(Q.clientX,Q.clientY)||f(T)},g=Q=>{const k=Q.relatedTarget;k&&u.contains(k)||p(Q.clientX,Q.clientY)||d(null)},y=Q=>{const k=Q.target?.closest(Gh);if(k){if(k===s.current){s.current=null;return}d(k)}},v=Q=>{const k=Q.relatedTarget;k&&u.contains(k)||d(null)},S=()=>Array.from(u.querySelectorAll(`[${Ih}] button:not([disabled])`)),x=Q=>{const k=Q.target;if(!k)return!1;if(k.closest(`[${Ih}]`)){const R=S(),j=R.indexOf(k);if(j===-1)return!1;if(Q.shiftKey&&j===0){const C=o.current;return C instanceof HTMLElement?(C.focus(),!0):!1}if(!Q.shiftKey&&j===R.length-1){const C=Array.from(u.querySelectorAll(Gh)),W=o.current,N=W?C.indexOf(W)+1:-1,G=N>0?C[N]:void 0;return G?(G.focus(),!0):!1}return!1}if(Q.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=Q=>{if(Q.key==="Tab"&&x(Q)){Q.preventDefault();return}if(!(Q.key==="ContextMenu"||Q.shiftKey&&Q.key==="F10"))return;const T=Q.target?.closest(Gh);!T||!u.contains(T)||(Q.preventDefault(),d(T),requestAnimationFrame(()=>{u.querySelector(`[${Ih}] button`)?.focus()}))},w=Q=>{const k=Q.target;k&&u.contains(k)||d(null)};return u.addEventListener("pointerover",m),u.addEventListener("pointerout",g),u.addEventListener("focusin",y),u.addEventListener("focusout",v),u.addEventListener("keydown",b),document.addEventListener("pointerdown",w,!0),document.addEventListener("selectionchange",l),l(),()=>{O&&clearTimeout(O),u.removeEventListener("pointerover",m),u.removeEventListener("pointerout",g),u.removeEventListener("focusin",y),u.removeEventListener("focusout",v),u.removeEventListener("keydown",b),document.removeEventListener("pointerdown",w,!0),document.removeEventListener("selectionchange",l)}},[e,l]);const c=$.useCallback(()=>{s.current=a.current,o.current=null,l()},[l]);return $.useEffect(()=>{if(!t)return;const u=O=>{if(O.key!=="Escape"||O.target?.closest(`[${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 $Qe(e,t,n){const r=an(i=>i.addReply);return $.useCallback(()=>{const a=$y(t.current)?.text??(DSe()?null:n?.()??null);a&&(r(e,{id:fs(),text:a}),window.getSelection()?.removeAllRanges(),kz())},[r,e,t,n])}const yQe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(ISe)??"",o=n.getAttribute("data-lo-kind")??"file",s=SP(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=$Qe(e,t,l),{text:u}=mQe(t),{speak:O}=Mv(),d=UU(e),f=u??l(),p=f===null?null:Cx(e,zU(f).text);fQe(p);const m=NU({key:p,getText:()=>$y(t.current)?.text??l(),play:({text:W})=>O(Cx(e,W),WU(d,W))}),[g,y]=$.useState(!1),[v,S]=$.useState(()=>L1(a)??null),{controlRef:x,placement:b}=pQe({turnRef:t,visible:!0,lines:()=>{const W=n.getClientRects();return Array.from(W,N=>({top:N.top,left:N.left,right:N.right,bottom:N.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const W=L1(a);if(S(W??null),y(!1),W!==void 0)return;let N=!0;return eTt(a,window.api?.probeFiles).then(()=>{N&&S(L1(a)??null)}),()=>{N=!1}},[a]);const w=o==="file"&&bU(s,a),Q=LSe({target:a,isDirectory:v?.exists===!0&&!v.isFile,probe:v,canOpenInCanvas:w}),k=sTt({kind:o,target:a,probe:v,quotable:r,canOpenInCanvas:w});if(!k||!a)return null;const T=async()=>{await HSe(a)&&y(!0)},_=async()=>{if(o==="url"){await PH(o,a);return}s&&Q&&await s.openInCanvas(a)||await PH(o,a)||S(null)},E=async()=>{await AO(a)||S(null)},R=async()=>{await wU(a)||S(null)},j={quote:h.jsx(Cue,{}),copy:g?h.jsx(xu,{}):h.jsx(hk,{}),open:Q?h.jsx(u9e,{}):o==="url"?h.jsx(Sue,{}):h.jsx(dv,{}),"open-default":h.jsx(TAe,{}),"open-folder":h.jsx(Rp,{})},C={quote:c,copy:()=>{T()},open:()=>{_()},"open-default":()=>{E()},"open-folder":()=>{R()}};return h.jsxs("div",{[Mm]:"",[Ih]:"",ref:x,role:"toolbar","aria-label":k.label,className:q("absolute z-10 flex h-8 items-center gap-0.5 rounded-md border border-hairline bg-elevated px-1",!b&&"invisible"),style:b?{top:b.top,left:b.left}:void 0,onMouseDown:W=>W.preventDefault(),onKeyDown:W=>{if(W.key!=="Escape")return;window.getSelection()?.removeAllRanges();const N=n;W.preventDefault(),i(),N.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(Ee,{variant:"ghost",size:"icon-sm","aria-label":W.id==="copy"&&g?"Copied":W.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:C[W.id],children:j[W.id]})}),W.id==="quote"&&h.jsx(YU,{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 bqt({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:["copy","speak",...n]}function vQe(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const WK=96;function wqt(e){const t=e.replace(/\s+/g," ").trim();return t.length<=WK?t:`${t.slice(0,WK-1).trimEnd()}…`}const Sqt="Answer actions",xqt="Your message actions",Qqt="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 kqt(e){return e?"opacity-100":Qqt}const Pqt=2e3,_qt=1e4;function WOn(e){const{request:t}=e;return t?e.now-t.requestedAt>_qt?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let NK=0,Ww=0;const Tqt=ta(e=>({request:null,requestPanel:(t,n,r,i)=>{NK+=1,e({request:{destination:t,nonce:NK,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}))}}})),Rqt=(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)},Xqt=9e4,YK=new Set,Eqt=2600,bQe=$.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=UU(r??null),S=NU({key:i?dQe(i):null,getText:()=>t,play:({text:E})=>{i&&y(i,v,E)}}),x=Tqt(E=>E.requestPanel),w=bqt({role:n,forkable:!!(s&&l)}),Q=c||S.active;$.useEffect(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]),$.useEffect(()=>{if(!a||o===void 0||YK.has(a)||(YK.add(a),Date.now()-o>Xqt))return;const E=p.current;if(E===null)return;const R=E.closest(".group")??E;if(Rqt(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)},Eqt),()=>{g.current!==null&&clearTimeout(g.current)}},[O]);const k=async()=>{await HSe(t)&&(u(!0),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,u(!1)},Pqt))},T=()=>{!s||!l||x("session.fork",m.current,s,{id:l,excerpt:wqt(t)})},_={copy:h.jsx(Yt,{content:c?"Copied":"Copy",side:"bottom",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":c?"Copied":"Copy",className:q("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:k,children:c?h.jsx(xu,{"aria-hidden":"true"}):h.jsx(hk,{"aria-hidden":"true"})})}),speak:h.jsx(YU,{control:S,side:"bottom"}),fork:h.jsx(Yt,{content:"Fork from this message",side:"bottom",children:h.jsx(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Fork from this message",ref:m,className:q("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:T,children:h.jsx(Sze,{"aria-hidden":"true"})})})};return h.jsx("div",{role:"toolbar","aria-label":n==="user"?xqt:Sqt,ref:p,onAnimationEnd:E=>{E.target===E.currentTarget&&d(!1)},...O?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:{"data-lo-answer-actions":""},className:q("flex shrink-0 items-center gap-1",kqt(Q)),children:w.map(E=>h.jsx($.Fragment,{children:_[E]},E))})}),qqt="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",Nw="@min-[260px]/olderhistory:hidden",Yw="@max-[260px]/olderhistory:hidden",wQe="lo-older-history-hint",jqt=({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:qqt,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(Ee,{variant:"ghost",size:"sm",className:"shrink-0",onClick:n,children:"Try again"})]}):a?h.jsxs(Ee,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"text-ink-muted",children:[h.jsx(Go,{size:"sm"}),"Loading earlier messages"]}):e==="idle"?h.jsx(Ee,{variant:"ghost",size:"sm",onClick:n,children:"Load earlier messages"}):e==="windowed"?h.jsxs("span",{id:wQe,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(Ee,{variant:"ghost",size:"sm",className:"shrink-0",onClick:r,children:"Try again"})]}):h.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:"Start of conversation"})]})},Cqt="/settings?section=providers",GK="/settings?section=providers&provider=radient",Aqt="/settings?section=radient",IK=/sign in to radient/i,zqt=[/insufficient credits/i,/credit balance is too low/i],Uqt=[/rate limit or quota/i],Wqt=[/insufficient credits/i,/\bHTTP 402\b/i];function SQe(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function GU(e){return SQe(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&Wqt.some(n=>n.test(e.text)):!1}function Nqt(e){if(!GU(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 Yqt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function ZK(e){const t=SQe(e.provider)||IK.test(e.text);let n=Yqt(e.category);return GU(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(IK.test(e.text)?n="sign-in":zqt.some(r=>r.test(e.text))?n="billing":Uqt.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:"Sign in to Radient",to:GK}:n==="billing"&&t?{label:"Open Radient account",to:Aqt}:{label:"Open provider settings",to:t?GK:Cqt}}const xQe=({conversationId:e,turnRef:t})=>{const{text:n,clear:r}=mQe(t),i=n!==null,a=$Qe(e,t),{controlRef:o,placement:s}=pQe({turnRef:t,visible:i,lines:()=>$y(t.current)?.lines??null}),{speak:l}=Mv(),c=UU(e),u=n===null?null:Cx(e,zU(n).text);fQe(u);const O=NU({key:u,getText:()=>$y(t.current)?.text??null,play:({text:d})=>l(Cx(e,d),WU(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(Ee,{variant:"ghost",size:"icon-sm","aria-label":"Quote",className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:a,children:h.jsx(Cue,{})})}),h.jsx(YU,{control:O,side:s?.placement==="below"?"bottom":"top"})]}):null},QQe={all:["radient-prices"],prices:()=>[...QQe.all,"prices"]},Gqt=()=>{const e=jt({queryKey:QQe.prices(),queryFn:()=>jz({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}},DK="https://console.radienthq.com/dashboard/verification",MK="https://console.radienthq.com/dashboard/billing",VK="Top up in Radient console";function Iqt(e){return!e.email_verified&&e.signup_grant!=="claimed"}const NOn=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`$${e.toFixed(2)} in free credits`,p7=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,Zqt=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`${p7(e)} in free credits`;function LK(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function Dqt(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const Mqt=(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 Vqt(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:DK},{label:VK,url:MK}]};if(Iqt(e)){const i=LK(e.claim_url,DK),{action:a}=Mqt(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 ${Zqt(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 ${p7(n.bonus_amount)} free on your first top-up of ${p7(n.minimum_purchase)} or more.`),{state:"verified",lines:r,links:[{label:VK,url:LK(n?.topup_url,MK)}]}}const Lqt=5*1e3,Fqt=({action:e})=>{const{user:t,accountRead:n}=ade({staleTime:Lqt,retryOnMount:!1}),r=Ri(),{prices:i}=Gqt(),o=r.isPending||n==="checking"?null:Vqt(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(Ee,{variant:"secondary",size:"sm",onClick:()=>Dqt(s.url),children:s.label},s.url)),h.jsx(Ee,{variant:"ghost",size:"sm",asChild:!0,children:h.jsx($ue,{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,kQe=6,m7=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),FK=async e=>{for(let t=0;t<kQe;t+=1){if(e())return;await m7()}},PQe=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},Bqt=e=>{const t=PQe(e.loadOlder),n=()=>FK(()=>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 FK(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},k0="data-jump-highlight",Hqt=1400,Kqt=12,Jqt=1200,ejt=kQe,tjt=ejt+2,njt=2,rjt=30,BK=1,Fg=K1;let Eh=0;async function ijt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await Bqt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:Kqt,maxRows:Jqt})==="landed"}async function ajt(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<tjt&&(await m7(),!(!n()||!t.isConnected||a||r!==Eh));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-Fg;if(Math.abs(O)<=BK){if(l+=1,l>=njt){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<rjt;f+=1){if(await m7(),!n()||a||r!==Eh||!u.isConnected||!O.isConnected)return;const p=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-Fg;if(Math.abs(p)<=BK)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 _Qe(e,t,n,r=()=>!0){return r()?new Promise(i=>{jEt(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}HK(a),ajt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(k0)&&HK(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const bR=new WeakMap;function HK(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)},Hqt))}const mO=120,Gw=400,ojt=.5,sjt=320,ljt=900,Iw=64,RP=2,wR=24,SR=3,cjt=4,yy=12,g7=yy,ujt=120,Ojt=.35,KK=12,djt=8,fjt=yy,hjt=.5,JK=()=>({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}),TQe=e=>Math.min(ljt,Math.max(sjt,Math.round(e*ojt))),pjt=(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}}),mjt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!RQe(t).inZone?!1:t.distanceFromTopPx<=RP?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=g7?!1:n-e.lastInputAt>=mO:!0;function RQe(e,t=TQe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const gjt=(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=TQe(t.clientHeight),{inZone:a}=RQe(t,i),o=n-e.lastInputAt>=mO||t.distanceFromTopPx<=RP,s=e.revealsThisAct<fjt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<KK&&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<g7?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<g7,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<KK:(c||l&&e.chainFetch<cjt)&&e.failures<SR)?Bg({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},eJ=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<djt,l=r===null&&t&&i!==null&&i<Math.max(ujt,Ojt*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}},$jt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),yjt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),vjt=(e,t,n,r)=>n===r?XQe(e,t):null,XQe=(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)<hjt?0:n};function EQe({path:e}){switch(Iz(e)){case"image":return h.jsx(dze,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return h.jsx(pze,{"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 bjt(e,t){try{return bU(e,t)}catch{return!1}}function IU(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{pi(J("ui.chat.highlights.file_resolution_failed"))}},[e,t]),i=bjt(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 qQe=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1}){const{canOpenInCanvas:o,withTarget:s}=IU(t,r,i),[l,c]=$.useState(!1),u=`Actions for ${n||"this file"}`;return h.jsxs(yA,{children:[h.jsx(Yt,{content:"File actions",children:h.jsx(vA,{asChild:!0,children:a?h.jsx(Ee,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":u,children:h.jsx($j,{"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($j,{"aria-hidden":"true",className:"size-3.5"})})})}),h.jsxs(bA,{align:"end",className:"min-w-45",children:[o&&h.jsxs(jl,{onSelect:()=>{s(O=>i?.openInCanvas(O))},children:[h.jsx(Pue,{"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(wU)},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(()=>pi("Failed to copy file path"))},children:[h.jsx(bue,{"aria-hidden":"true"}),h.jsx("span",{children:l?"Copied":"Copy file path"})]})]})]})}),wjt="lo-supplement",Sjt="s";function xjt(e,t){return`${wjt}://${Sjt}/${e}/${t}`}const Qjt="[supplement] frame torn down after a second load (hostile navigation or a blocked attempt)";function kjt(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 Pjt({component:e,sessionId:t,documentHtml:n,documentFailed:r=!1,onRetry:i,onHeightChange:a,className:o}){const s=Vle(e),[l,c]=$.useState(s),[u,O]=$.useState(!1),[d,f]=$.useState(!0),p=$.useRef(null),m=$.useRef(null),g=$.useRef(""),y=$.useRef(!1),v=$.useRef(""),S=$.useRef(()=>{}),x=$.useRef(0),b=$.useRef(s),w=$.useRef(null),Q=$.useRef(()=>{}),k=$.useRef(a),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=fqe();const R=window.api?.desktop?.armSupplementFrame,j=t!==null&&S$(e.attachment);let C;if(R===void 0)C=gqe(n);else if(j)C=xjt(t,e.attachment);else{_("no-address");return}let W=!1,N=!1,G=null,D=null,F=null;const z={resize:null,error:!1},M=window.setTimeout(()=>{W||_("no-ready")},uY),te=ne=>{E.contentWindow?.postMessage(ne,"*")},U=()=>{y.current||D===null&&(te({lo:"supplement-host",t:"ping"}),D=window.setTimeout(()=>{D=null,_("no-pong")},uY))};S.current=()=>{N||y.current||(N=!0,U(),G=window.setInterval(U,Oqe))};const B=ne=>{const ae=p.current;if(ae){const ce=kjt(ae);if(ce&&ae.getBoundingClientRect().top<ce.getBoundingClientRect().top){w.current=ne,k.current?.(ne);return}}w.current=null,k.current?.(ne),ne!==b.current&&(b.current=ne,c(ne))},I=()=>{F===null&&(F=window.requestAnimationFrame(()=>{F=null;const{resize:ne,error:ae}=z;if(z.resize=null,z.error=!1,ae){_("frame-error");return}ne!==null&&B(ne)}))},L=ne=>{if(y.current||ne.source!==E.contentWindow||ne.origin!=="null")return;const ae=dqe(ne.data,g.current);if(ae){if(ae.t==="ready"){W||(W=!0,window.clearTimeout(M));return}if(ae.t==="pong"){D!==null&&(window.clearTimeout(D),D=null);return}if(ae.t==="resize"){z.resize=Lle(ae.h),f(!1),I();return}z.error=!0,I()}},ie=()=>{const ne=w.current;ne!==null&&B(ne)};window.addEventListener("message",L),window.addEventListener("scroll",ie,!0);let H=!1;return(async()=>{if(R)try{await R(C)}catch{}H||(E.src=C)})(),()=>{H=!0,window.clearTimeout(M),G!==null&&window.clearInterval(G),D!==null&&window.clearTimeout(D),F!==null&&window.cancelAnimationFrame(F),window.removeEventListener("message",L),window.removeEventListener("scroll",ie,!0),S.current=()=>{}}},[n,_,t,e.attachment]),k.current=a,T.current=E=>{y.current||x.current!==1||m.current?.contentWindow?.postMessage({lo:"supplement-host",t:"theme",mode:E.mode,vars:E.vars,nonce:g.current},"*")},$.useEffect(()=>mqe(E=>T.current(E)),[]),Q.current=()=>{const E=x.current+1;if(x.current=E,E>1){console.debug(Qjt),_("second-load");return}T.current(Mle()),S.current()},u||r?h.jsxs("div",{className:"text-ink-dim text-meta","data-supplement-frame-fallback":r?"document":v.current,children:["Couldn't render this graphic",i&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"px-1 text-ink-dim",children:"·"}),h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-frame-retry":"",onClick:()=>i(),children:"Retry"})]})]}):h.jsxs("div",{className:o,"data-supplement-frame-box":"",children:[h.jsxs("div",{ref:p,"data-supplement-frame":"",className:"relative overflow-hidden",style:{height:l,width:"100%"},children:[n!==null&&h.jsx("iframe",{ref:m,title:e.title,sandbox:"allow-scripts",onLoad:()=>Q.current(),className:"block h-full w-full border-0"}),d&&h.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 animate-shimmer bg-elevated/40 bg-gradient-to-r from-transparent via-elevated/60 to-transparent bg-[length:200%_100%] bg-[position:-200%_50%] bg-no-repeat"})]}),h.jsxs("span",{className:"block truncate text-ink-muted text-meta",title:`Source: ${e.source}`,"data-supplement-source":"",children:["Source: ",Ld(e.source)]})]})}function _jt(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 Tjt=150,$7=16*1024*1024,Js=new Map,$p=[];let P0=0,jQe=0,CQe=0,y7=0;const YOn=()=>({entries:Js.size,queued:$p.length,active:P0,reads:jQe,decodes:CQe,peakActive:y7}),Rjt=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 Xjt(e){if(e.artifact)return _xe({sessionId:e.artifact.sessionId,childId:e.artifact.childId??null},e.artifact.digest);const t=await window.api.readFileBytes(e.path,$7);if(!t.success)throw new Error(t.error??"Could not be read");return new Blob([t.data],{type:Zz(e.path)})}function AQe(){for(const[e,t]of Js){if(Js.size<=Tjt)return;t.listeners.size||t.started||(t.state.url&&$v(t.state.url),Js.delete(e))}}function tJ(e,t){e.state=t;for(const n of e.listeners)n(t)}function zQe(){for(;P0<4&&$p.length;){const e=$p.shift();if(!e||!e.listeners.size){e&&Js.delete(e.key);continue}e.started=!0,P0++,jQe++,y7=Math.max(y7,P0),(async()=>{try{if((e.document.sizeBytes??0)>$7)throw new Error("Too large to preview");const t=await Xjt(e.document);if(t.size>$7)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);CQe++;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"});tJ(e,{state:"ready",url:Mz(await O.arrayBuffer(),"image/png")})}finally{"close"in o&&o.close(),s&&URL.revokeObjectURL(s)}}catch(t){tJ(e,{state:"unavailable",reason:t instanceof Error?t.message:"Could not be read"})}finally{e.started=!1,P0--,AQe(),zQe()}})()}}function Ejt(e,t){const n=Rjt(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),zQe();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)}AQe()}},[n,t,e]),r}const qjt="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",jjt=$.memo(function({file:t,cwd:n,pane:r}){const{name:i,path:a}=Dle(t),o=i||a||t.path,[s,l]=_jt(),[c,u]=$.useState(null),[O,d]=$.useState(!1);$.useEffect(()=>{let S=!1;const x=window.api?.probeFiles;if(typeof x!="function"){u(null),d(!0);return}return u(null),d(!1),(async()=>{try{const[b]=await x([t.path],n??void 0),w=b?.resolved??"";S||u(w.startsWith("/")?w:null)}catch{S||u(null)}finally{S||d(!0)}})(),()=>{S=!0}},[t.path,n]);const f=$.useMemo(()=>({id:`supplement:${t.path}`,title:o,path:c??t.path,content:"",type:"image",sizeBytes:t.sizeBytes,lastAgentModified:t.mtime?t.mtime*1e3:void 0}),[t.path,o,t.sizeBytes,t.mtime,c]),p=Ejt(f,l&&c!==null),{press:m}=IU(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(EQe,{path:t.path})}):h.jsx(zO,{boundary:"control",className:"h-[78px] w-[117px]"})}),h.jsx("div",{className:qjt,children:h.jsx(qQe,{overlay:!0,actionPath:t.path,label:o,cwd:n,pane:r})})]})})}),Cjt=({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(jjt,{file:i,cwd:t,pane:n},i.path))}),Ajt=2*1024*1024,tp=new Map,xR=new Map,zjt=64,nJ={html:null,failed:!1};async function Ujt(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>Ajt)return null;for(tp.set(n,s);tp.size>zjt;){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 Wjt(e,t,n){const[r,i]=$.useState(()=>{if(!e||!S$(t))return nJ;const a=tp.get(`${e}:${t}`);return a!==void 0?{html:a,failed:!1}:nJ});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 Ujt(e,t).then(s=>{o||i(s!==null?{html:s,failed:!1}:{html:null,failed:!0})}),()=>{o=!0}},[n,e,t]),r}const rJ=$.memo(function({actionPath:t,cwd:n,label:r,suffix:i,size:a,pane:o}){const{press:s}=IU(t,n,o);return h.jsxs("div",{className:"group flex w-full items-center gap-2 text-meta",children:[h.jsx(EQe,{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(qQe,{actionPath:t,label:r,cwd:n,pane:o})]})}),Njt=$.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=rQe(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:Kxe}):i.state==="resolving"?h.jsx("div",{className:"h-11","aria-hidden":!0}):h.jsx(nQe,{variant:"compact",ownerId:`sound:${t.attachment}`,src:i.url,label:o,peaks:a,durationHint:t.durationS})]})}),iJ=$.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=Wjt(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(Pjt,{component:t,sessionId:n,documentHtml:l.html,documentFailed:l.failed,onRetry:r,onHeightChange:i?c:void 0})})}),Yjt=$.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),[x,b]=$.useState(0),w=MEe(t,t.live),Q=tqe(t.cause),k=t.files,T=t.filesMore,_=t.components,E=t.sounds??[],R=k.length+T,j=async ie=>{if(n){y(!0);try{await Re({...ie,sessionId:n,job:t.job,anchor:t.anchor})}catch(H){pi(pv("Highlights could not be updated.",H))}finally{y(!1)}}},C=()=>{j({op:"supplements.cancel"})},W=()=>{j({op:"supplements.restart"})},N=()=>{const ie=p.trim();ie&&(f(!1),m(""),j({op:"supplements.steer",text:ie}))},G=$.useCallback((ie,H)=>{S(K=>{if(K.get(ie)===H)return K;const ne=new Map(K);return ne.set(ie,H),ne})},[]),D=vqe(typeof window>"u"?900:window.innerHeight),{visible:F}=bqe(_,D,v);$.useEffect(()=>{b(ie=>Math.max(ie,F.length))},[F.length]);const z=Math.min(_.length,Math.max(x,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:VEe})]}),(w==="cancelled_retry"||w==="files_cancelled_retry")&&h.jsx("span",{className:"text-ink-muted",children:LEe}),(w==="failed_retry"||w==="files_failed_retry")&&h.jsxs("span",{className:"text-ink-muted",children:[FEe,Q?` — ${Q}`:""]}),(w==="preparing"||w==="files_preparing")&&n&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),!d&&h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-adjust":"",onClick:()=>f(!0),children:BEe}),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:HEe})]}),(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:KEe})]})]}):null,B=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:zEe,placeholder:"Adjust the graphic…",value:p,onChange:ie=>m(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&N(),ie.key==="Escape"&&(f(!1),m(""))}}),h.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60",disabled:g||!p.trim(),onClick:N,children:"Send"})]}):null;if(w==="nothing")return null;let I=null;if(k.length>0||T>0){const ie=[],H=[];for(const ne of k)Iz(ne.path)==="image"?ie.push(ne):H.push(ne);const K=R<=2&&_.length===0&&T===0;I=h.jsxs("div",{className:"flex flex-col gap-1","data-supplement-files-summary":K?"":void 0,"data-supplement-files":K?void 0:"",children:[ie.length>0&&h.jsx(Cjt,{files:ie,cwd:r,pane:a,className:H.length>0||T>0?"mb-1":void 0}),H.map(ne=>{const{name:ae,path:ce,size:Pe}=Dle(ne);return h.jsx(rJ,{actionPath:ne.path,cwd:r,label:ae||ce,suffix:ce,size:Pe,pane:a},`${ne.path}:${ne.name}`)}),T>0&&h.jsx(ya,{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":nqe(T)}),children:t.more.slice(0,20).map(ne=>h.jsx(rJ,{actionPath:ne,cwd:r,label:ne,suffix:"",size:"",pane:a},ne))})]})}const L=E.length>0?h.jsx("div",{className:"flex flex-col gap-1","data-supplement-sounds":"",children:E.map(ie=>h.jsx(Njt,{sound:ie,sessionId:n},ie.attachment))}):null;return i?w==="block"?I===null&&_.length===0?null:h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,"data-supplement-condensed":"",children:[I,L,I===null&&_.length>0&&h.jsx("div",{className:"text-ink-muted text-meta",children:iqe(_.length,"graphic")})]}):h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,"data-supplement-condensed":"",children:[I,L,U(),B]}):h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,children:[I,L,U(),t.detail?.includes("prepared:unsupported")&&h.jsx("p",{className:"text-meta text-ink-muted","data-supplement-refusal":"",children:"Inline preview unavailable. This HTML needs unsupported resources or document content. Open the file to view it."}),(w==="failed_retry"||w==="files_failed_retry")&&h.jsxs("div",{className:"flex flex-col gap-1 text-meta text-ink-muted","data-supplement-diagnostic":"",children:[h.jsx("p",{children:kqe(t)}),((t.attempts?.length??0)>0||(t.detail?.length??0)>0)&&h.jsx(ya,{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(ie=>h.jsx("p",{children:Qqe(ie)},ie))]})})]}),B,w==="block"&&_.length>0&&h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-components":"",children:[M.map(ie=>h.jsx(iJ,{component:ie,sessionId:n,onRetry:n?W:void 0,onHeight:G},ie.attachment)),te.length>0&&h.jsx(ya,{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":aqe(te.length)}),children:te.map(ie=>h.jsx(iJ,{component:ie,sessionId:n,onRetry:n?W:void 0,onHeight:G},ie.attachment))})]})]})});function Gjt(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="f"}const Ijt=e=>e?"⌘F":"Ctrl+F";function Zjt(e){switch(e){case"ready":case"building":case"unsupported":case"error":return e;default:return"error"}}function Djt(e,t,n){return n<=0?-1:(((e<0||e>=n?t>0?-1:0:e)+t)%n+n)%n}function Mjt(e,t){return t>=0&&t<e.length?e[t]:null}function Vjt(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 Ljt={user:"You",agent:"Agent"},Fjt="related match",aJ="Search this conversation",Bjt="Search results",Hjt="Close search";function Kjt(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 Jjt="No messages match this search.",e3t="Still indexing this conversation.",t3t="Results appear as the index catches up.",n3t="Newer messages may be missing while the index catches up.",r3t="This conversation lives on another device, so it cannot be searched here.",i3t="This conversation could not be searched.",a3t="Try again",o3t="Check again",s3t="Could not reach that message. It is further back than the loaded history — scroll up in the transcript to load more.",l3t="Updating — the list below is the previous search's.",c3t="Going to that message…";function u3t(e){return e===1?"(the first match shown)":`(first ${e} shown)`}function O3t(e){return e.state==="building"}async function d3t(e,t){if(e===null)return"not-mounted";const n=e.querySelector("[data-lo-transcript-content]")??e;return await _Qe(n,e,t)==="landed"?"revealed":"not-mounted"}async function f3t(e){const t=e.query.trim().slice(0,tle);if(t.length===0)return{query:"",state:"ready",partial:!1,hits:[],truncated:!1};const n=Math.min(Math.max(e.limit??RRe,1),XRe);return Re({op:"sessions.find",sessionId:e.sessionId,q:t,limit:n})}const h3t=200,p3t=1500;function m3t({sessionId:e,enabled:t}){const[n,r]=$.useState(""),[i,a]=$.useState("idle"),[o,s]=$.useState([]),[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,f]=$.useState(-1),p=$.useRef(0),m=$.useRef(0),g=$.useRef(0),y=$.useRef(""),v=$.useRef(null),S=$.useRef(null),x=$.useRef(new Set),b=$.useRef(e);b.current=e;const w=$.useCallback(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null)},[]),Q=$.useCallback((C,W)=>{x.current.has(C)||(x.current.add(C),console.warn(C,W))},[]),k=$.useCallback(()=>{p.current+=1,w(),v.current=null,g.current=0,a("idle"),s(C=>C.length===0?C:[]),c(!1),O(!1),f(-1)},[w]),T=$.useRef(()=>{}),_=$.useCallback((C,W)=>{const N=Zjt(W.state);a(N);const G=N==="ready"||N==="building",D=G?W.hits:[];if(g.current=D.length,s(D),c(G&&W.truncated),O(N==="building"&&W.partial),f(D.length>0?0:-1),N==="building"&&O3t(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")},p3t)}}else w()},[w]),E=$.useCallback((C,W)=>{const N=b.current;if(!N)return;const G=p.current,D=++m.current;W==="fresh"&&(w(),v.current=null,a("loading")),f3t({sessionId:N,query:C}).then(F=>{D!==m.current||p.current!==G||_(C,F)}).catch(F=>{D!==m.current||p.current!==G||(Q("thread search could not be answered:",F),w(),v.current=null,g.current=0,s([]),c(!1),O(!1),f(-1),a("error"))})},[_,w,Q]);T.current=E,$.useEffect(()=>{const C=`${t?"1":"0"}:${e??""}`;if(y.current!==C&&(y.current=C,x.current=new Set,k(),r(D=>D===""?D:""),!t||!e))return;if(!t||!e){k();return}const W=n.trim();if(W.length===0){k();return}const N=p.current,G=setTimeout(()=>{p.current===N&&T.current(W,"fresh")},h3t);return()=>clearTimeout(G)},[n,t,e,k]),$.useEffect(()=>()=>w(),[w]);const R=$.useCallback(C=>{f(W=>Djt(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:Mjt(o,d),refresh:j}}const g3t=q("bg-accent-wash","before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent"),$3t="bg-accent-wash font-medium text-ink underline decoration-accent decoration-2 underline-offset-2",y3t=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0,v3t=({hit:e,active:t,optionId:n,onNavigate:r})=>{const i=Vjt(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?g3t:"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:Ljt[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:Fjt})]})]}),h.jsx("span",{className:"line-clamp-2 text-body-sm text-ink",children:i.map((a,o)=>a.matched?h.jsx("mark",{className:$3t,children:a.text},o):h.jsx("span",{children:a.text},o))})]})},b3t=({query:e,onQueryChange:t,state:n,hits:r,cursor:i,truncated:a,partial:o,onMoveCursor:s,onNavigate:l,onRetry:c,onClose:u,isMac:O,jumping:d=!1})=>{const f=$.useId(),p=`${f}-list`,m=$.useCallback(b=>`${f}-opt-${b}`,[f]),g=$.useRef(null),y=i>=0&&i<r.length?r[i]:null,v=r.length>0,S=n==="error"||n==="building";$.useEffect(()=>{g.current?.focus(),g.current?.select()},[]),$.useEffect(()=>{i<0||document.getElementById(m(i))?.scrollIntoView({block:"nearest"})},[i,m]);const x=b=>{if(b.key==="ArrowDown"){b.preventDefault(),s(1);return}if(b.key==="ArrowUp"){b.preventDefault(),s(-1);return}if(b.key==="Enter"){b.preventDefault(),y!==null?l(y):S&&c();return}};return h.jsxs("div",{"data-lo-thread-search":"",role:"presentation",onKeyDown:b=>{b.defaultPrevented||b.key==="Escape"&&(b.preventDefault(),u())},className:"pointer-events-auto w-[26rem] max-w-full rounded-md border border-hairline bg-elevated text-body-sm text-ink shadow-overlay",children:[h.jsx("div",{className:"p-2",children:h.jsxs("div",{className:q("flex items-center gap-2 rounded-sm border border-control bg-surface px-2","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[h.jsx(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:x,maxLength:tle,placeholder:aJ,"aria-label":aJ,role:"combobox","aria-expanded":v,"aria-controls":v?p:void 0,"aria-activedescendant":y!==null?m(i):void 0,"aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 border-0 bg-transparent text-body-sm text-ink outline-none placeholder:text-ink-dim"}),h.jsx(Ee,{type:"button",variant:"ghost",size:"icon-sm","aria-label":Hjt,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?l3t:"Searching…"),n==="ready"&&(r.length>0?Kjt(r):Jjt),n==="building"&&(o?n3t:e3t),n==="unsupported"&&r3t,n==="error"&&i3t,n==="ready"&&a&&v&&h.jsxs("span",{className:"text-ink-dim",children:[" ",u3t(r.length)]}),n==="building"&&!o&&h.jsxs("span",{className:"text-ink-dim",children:[" ",t3t]})]}),S&&h.jsx(Ee,{type:"button",variant:"ghost",size:"sm",onClick:c,className:"shrink-0",children:n==="building"?o3t:a3t})]}),v&&h.jsx("ul",{id:p,role:"listbox","aria-label":Bjt,"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(v3t,{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:c3t}),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:Ijt(O)})]})]})},w3t=({sessionId:e,containerRef:t,onReveal:n})=>{const[r,i]=$.useState(!1),[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(null),c=m3t({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||!Gjt(p))return;const m=p.target;if(!(!(s.current!==null&&m!==null&&s.current.contains(m))&&(X$(p.target)||Kue(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 d3t(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(b3t,{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:y3t(),jumping:a})}):null};function S3t(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 x3t(e,t){for(const[n,r]of e)t.set(n,{...r});e.clear()}function oJ(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 Q3t(e,t,n,r,i){const a=e.length-1,o=new Set(i.filter(O=>O>=0&&O<a)),s=Math.max(0,oJ(e,t-r)-1),l=Math.min(a,oJ(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 k3t(e,t,n,r){return!e||!t||e.id!==t.id||n!==r?null:t.viewportOffset-e.viewportOffset}function P3t(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 _3t(e,t){return e==="inline"&&t}function UQe(e,t,n,r){const i=Math.max(24,Math.floor((r||810)/7.2)),a=t.split(`