@rubytech/create-realagent 1.0.663 → 1.0.665
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -1
- package/package.json +1 -1
- package/payload/platform/neo4j/schema.cypher +34 -1
- package/payload/platform/plugins/docs/references/memory-guide.md +2 -2
- package/payload/platform/plugins/docs/references/platform.md +1 -1
- package/payload/platform/plugins/docs/references/troubleshooting.md +24 -6
- package/payload/platform/scripts/vnc.sh +174 -2
- package/payload/server/public/assets/{admin-C9qoVb2l.js → admin-Brug36E-.js} +5 -5
- package/payload/server/public/assets/data-woLf2Tmp.js +1 -0
- package/payload/server/public/assets/{file-lmzx24EO.js → file-rN5uuyaV.js} +1 -1
- package/payload/server/public/assets/{graph-DkjvCb8B.js → graph-BYaOEZUg.js} +16 -16
- package/payload/server/public/assets/{house-ClhI06TA.js → house-DnFgpCt2.js} +1 -1
- package/payload/server/public/assets/jsx-runtime-CSCPZpLN.css +1 -0
- package/payload/server/public/assets/{public-Dz33-dIE.js → public-BRrqpeVH.js} +1 -1
- package/payload/server/public/assets/{share-2-MZ4MqbjS.js → share-2-DLjRUEiG.js} +1 -1
- package/payload/server/public/assets/{useVoiceRecorder-Cm0G51D_.js → useVoiceRecorder-D_efR3Nx.js} +1 -1
- package/payload/server/public/assets/{x-CLhtM_Mh.js → x-L6KPMfIN.js} +1 -1
- package/payload/server/public/data.html +6 -6
- package/payload/server/public/graph.html +6 -6
- package/payload/server/public/index.html +7 -7
- package/payload/server/public/public.html +4 -4
- package/payload/server/server.js +360 -126
- package/payload/platform/plugins/admin/mcp/dist/lib/onboarding.test.d.ts +0 -2
- package/payload/platform/plugins/admin/mcp/dist/lib/onboarding.test.d.ts.map +0 -1
- package/payload/platform/plugins/admin/mcp/dist/lib/onboarding.test.js +0 -224
- package/payload/platform/plugins/admin/mcp/dist/lib/onboarding.test.js.map +0 -1
- package/payload/platform/plugins/documents/mcp/dist/index.d.ts +0 -2
- package/payload/platform/plugins/documents/mcp/dist/index.d.ts.map +0 -1
- package/payload/platform/plugins/documents/mcp/dist/index.js +0 -98
- package/payload/platform/plugins/documents/mcp/dist/index.js.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/semantic-chunker.test.d.ts +0 -2
- package/payload/platform/plugins/memory/mcp/dist/lib/semantic-chunker.test.d.ts.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/semantic-chunker.test.js +0 -233
- package/payload/platform/plugins/memory/mcp/dist/lib/semantic-chunker.test.js.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/scripts/graph-prune.d.ts +0 -18
- package/payload/platform/plugins/memory/mcp/dist/scripts/graph-prune.d.ts.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/scripts/graph-prune.js +0 -80
- package/payload/platform/plugins/memory/mcp/dist/scripts/graph-prune.js.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/graph-prune-run.d.ts +0 -7
- package/payload/platform/plugins/memory/mcp/dist/tools/graph-prune-run.d.ts.map +0 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/graph-prune-run.js +0 -10
- package/payload/platform/plugins/memory/mcp/dist/tools/graph-prune-run.js.map +0 -1
- package/payload/platform/plugins/waitlist/mcp/dist/lib/anthropic.d.ts +0 -23
- package/payload/platform/plugins/waitlist/mcp/dist/lib/anthropic.d.ts.map +0 -1
- package/payload/platform/plugins/waitlist/mcp/dist/lib/anthropic.js +0 -115
- package/payload/platform/plugins/waitlist/mcp/dist/lib/anthropic.js.map +0 -1
- package/payload/platform/plugins/waitlist/mcp/dist/tools/waitlist-extract.d.ts +0 -12
- package/payload/platform/plugins/waitlist/mcp/dist/tools/waitlist-extract.d.ts.map +0 -1
- package/payload/platform/plugins/waitlist/mcp/dist/tools/waitlist-extract.js +0 -197
- package/payload/platform/plugins/waitlist/mcp/dist/tools/waitlist-extract.js.map +0 -1
- package/payload/server/public/assets/data-C-WE3FGr.js +0 -1
- package/payload/server/public/assets/jsx-runtime-CLCFnMYD.css +0 -1
- /package/payload/server/public/assets/{jsx-runtime-ImbU973I.js → jsx-runtime-XWiDQoTG.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,t}from"./chunk-DD-I1_y5.js";import{a as n,i as r,n as i,o as a,r as o,t as s}from"./jsx-runtime-ImbU973I.js";import{A as c,C as l,D as u,E as d,M as f,N as p,O as m,P as h,S as g,T as _,_ as v,a as y,b,c as x,d as S,f as C,g as w,h as T,i as E,j as D,k as O,l as k,m as A,n as j,o as M,p as N,r as P,s as ee,t as F,u as te,w as I,x as ne,y as re}from"./useVoiceRecorder-Cm0G51D_.js";import{a as ie,i as L,n as ae,o as oe,r as se,t as ce}from"./share-2-MZ4MqbjS.js";import{n as le,t as ue}from"./file-lmzx24EO.js";import{n as de,t as fe}from"./x-CLhtM_Mh.js";var pe=o(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),me=o(`asterisk`,[[`path`,{d:`M12 6v12`,key:`1vza4d`}],[`path`,{d:`M17.196 9 6.804 15`,key:`1ah31z`}],[`path`,{d:`m6.804 9 10.392 6`,key:`1b6pxd`}]]),he=o(`bold`,[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]),ge=o(`bot-off`,[[`path`,{d:`M13.67 8H18a2 2 0 0 1 2 2v4.33`,key:`7az073`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M22 22 2 2`,key:`1r8tn9`}],[`path`,{d:`M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586`,key:`s09a7a`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}],[`path`,{d:`M9.67 4H12v2.33`,key:`110xot`}]]),_e=o(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ve=o(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),ye=o(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),R=o(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),be=o(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),z=o(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),xe=o(`clipboard-plus`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M9 14h6`,key:`159ibu`}],[`path`,{d:`M12 17v-6`,key:`1y8rbf`}]]),Se=o(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Ce=o(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),we=o(`database-zap`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`,key:`14ibmq`}],[`path`,{d:`M21 5V8`,key:`1marbg`}],[`path`,{d:`M21 12L18 17H22L19 22`,key:`zafso`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`,key:`1y4wr8`}]]),Te=o(`database-search`,[[`path`,{d:`M21 11.693V5`,key:`175m1t`}],[`path`,{d:`m22 22-1.875-1.875`,key:`13zax7`}],[`path`,{d:`M3 12a9 3 0 0 0 8.697 2.998`,key:`151u9p`}],[`path`,{d:`M3 5v14a9 3 0 0 0 9.28 2.999`,key:`q2rs2p`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}]]),Ee=o(`dot`,[[`circle`,{cx:`12.1`,cy:`12.1`,r:`1`,key:`18d7e5`}]]),De=o(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Oe=o(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),ke=o(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Ae=o(`file-pen-line`,[[`path`,{d:`m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351`,key:`1k2beg`}],[`path`,{d:`M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`2t3380`}],[`path`,{d:`M8 18h1`,key:`13wk12`}]]),je=o(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Me=o(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Ne=o(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Pe=o(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Fe=o(`italic`,[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]),Ie=o(`lightbulb-off`,[[`path`,{d:`M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5`,key:`1fkcox`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5`,key:`10m8kw`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Le=o(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Re=o(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),ze=o(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),Be=o(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),Ve=o(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),He=o(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),Ue=o(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),We=o(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Ge=o(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Ke=o(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),qe=o(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Je=o(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ye=o(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),Xe=o(`sparkle`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}]]),Ze=o(`square-arrow-down-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`m16 8-8 8`,key:`166keh`}],[`path`,{d:`M16 16H8V8`,key:`1w2ppm`}]]),Qe=o(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),$e=o(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),et=o(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),tt=o(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),nt=o(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),rt=o(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),it=o(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),at=r(),B=e(a(),1);function ot(){(0,B.useEffect)(()=>{function e(e){e.data?.type===`vnc-clipboard`&&typeof e.data.text==`string`&&g(e.data.text)}window.addEventListener(`message`,e);let t=null;return typeof BroadcastChannel<`u`&&(t=new BroadcastChannel(`maxy-vnc-clipboard`),t.onmessage=e=>{typeof e.data==`string`&&g(e.data)}),()=>{window.removeEventListener(`message`,e),t?.close()}},[])}function st(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function ct(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function lt(){let[e,t]=(0,B.useState)(0),n=(0,B.useRef)(0),r=(0,B.useRef)(0),i=(0,B.useRef)(null),[a,o]=(0,B.useState)(0),s=(0,B.useRef)(0),c=(0,B.useRef)(null),l=(0,B.useRef)(null);return{elapsedSeconds:e,sessionElapsed:a,sessionTurnStart:l,pausedElapsedRef:r,startElapsedTimer:(0,B.useCallback)((e=0)=>{l.current=Date.now(),c.current=setInterval(()=>{let e=s.current+(Date.now()-(l.current??Date.now()));o(Math.floor(e/1e3))},1e3),n.current=e,t(e),i.current=setInterval(()=>{n.current+=1,t(n.current)},1e3)},[]),stopElapsedTimer:(0,B.useCallback)(e=>{i.current&&=(clearInterval(i.current),null),c.current&&=(clearInterval(c.current),null),l.current&&(s.current+=Date.now()-l.current,l.current=null,o(Math.floor(s.current/1e3))),r.current=n.current;let t=n.current;e(e=>{let n=[...e].map((e,t)=>({m:e,i:t})).reverse().find(({m:e})=>e.role===`maxy`)?.i;if(n===void 0)return e;let r=[...e];return r[n]={...r[n],elapsedSeconds:t},r})},[]),resetTimerState:(0,B.useCallback)(()=>{s.current=0,o(0)},[])}}var ut=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar`,dt=new Set(ut.split(`,`)),ft=20*1024*1024,pt=new Set([`action-list`,`document-editor`,`rich-content-editor`,`grid-editor`]);function mt(e){switch(e){case`expanded`:return!0;case`collapsed`:return!1;default:return}}function ht(){let[e,t]=(0,B.useState)(`loading`),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(null),[S,C]=(0,B.useState)(!1),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)(void 0),[O,k]=(0,B.useState)(void 0),[A,j]=(0,B.useState)(null),[M,N]=(0,B.useState)([]),[P,ee]=(0,B.useState)(!1),[F,te]=(0,B.useState)(void 0),I=(0,B.useRef)(void 0),ne=(0,B.useRef)(null),re=(0,B.useRef)(null),ie=(0,B.useRef)(null);(0,B.useEffect)(()=>{async function e(n=2){try{let r=await fetch(`/api/health`);if(!r.ok){if(n>0)return await new Promise(e=>setTimeout(e,1500)),e(n-1);console.error(`[admin] health check returned ${r.status} after retries`),t(`set-pin`);return}let i=await r.json();i.pin_configured?i.claude_authenticated?t(`enter-pin`):t(i.onboarding_complete?`connect-claude`:`onboarding-choice`):t(`set-pin`)}catch(r){if(n>0)return await new Promise(e=>setTimeout(e,1500)),e(n-1);console.error(`[admin] health check failed:`,r),t(`set-pin`)}}e()},[]),(0,B.useEffect)(()=>{e===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&x(e)}).catch(()=>{})},[e]),(0,B.useEffect)(()=>{if(e!==`chat`)return;let n=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(!e.ok)return;let n=await e.json();(n.auth_status===`dead`||n.auth_status===`missing`)&&t(`connect-claude`)}catch{}},300*1e3);return()=>clearInterval(n)},[e]),(0,B.useEffect)(()=>{e===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&t(`enter-pin`)}).catch(()=>{})},[e]);async function L(e,n){d(!0);try{let i=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...n?{accountId:n}:{}})});if(!i.ok){s((await i.json().catch(()=>({}))).error||`Invalid PIN`);return}let o=await i.json();if(o.accounts&&!o.session_key){console.log(`[admin] account picker shown: userId=${o.userId} accountCount=${o.accounts.length}`),N(o.accounts),t(`account-picker`);return}y(o.session_key),j(o.conversationId??null),D(o.onboardingComplete??!0),k(o.businessName);let c=mt(o.thinkingView);if(I.current=c,te(c),n)try{sessionStorage.setItem(`maxy-account-id`,n)}catch{}try{sessionStorage.setItem(`maxy-admin-session-key`,o.session_key)}catch{}r(``),a(``),t(`chat`)}catch(e){console.error(`[admin] connection error:`,e),s(`Could not connect.`)}finally{d(!1),ee(!1)}}let ae=(0,B.useCallback)(async e=>{if(e.preventDefault(),u)return;if(s(``),n.length<4){s(`PIN must be at least 4 characters.`);return}if(n!==i){s(`PINs do not match.`);return}let o=n;d(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:o})});if(!e.ok){let n=await e.json().catch(()=>({}));if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?t(`enter-pin`):r.pin_configured?t(`connect-claude`):s(n.error||`Failed to set PIN.`)}else t(`enter-pin`)}catch{t(`enter-pin`)}return}s(n.error||`Failed to set PIN.`);return}let n=await fetch(`/api/health`);if((n.ok?await n.json():null)?.claude_authenticated){await L(o);return}r(``),a(``),t(`onboarding-choice`)}catch(e){console.error(`[admin] connection error:`,e),s(`Could not connect.`)}finally{d(!1)}},[n,i,u]),oe=(0,B.useCallback)(async e=>{e.preventDefault(),s(``),await L(n)},[n]),se=(0,B.useCallback)(async()=>{if(!v||!b?.contextMode||S)return;let e=b.contextMode,t=e===`claude-code`?`managed`:`claude-code`;C(!0),x({...b,contextMode:t}),T(!0);let n=setTimeout(()=>T(!1),3e3);try{let r=await fetch(`/api/admin/account`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:v,contextMode:t})});r.ok||(console.error(`[context-mode-toggle] failed: ${r.status}`),x({...b,contextMode:e}),clearTimeout(n),T(!1))}catch(t){console.error(`[context-mode-toggle] error:`,t),x({...b,contextMode:e}),clearTimeout(n),T(!1)}finally{C(!1)}},[v,b,S]),ce=(0,B.useCallback)(async()=>{_(!0),await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})}),y(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}t(`connect-claude`)},[]),le=(0,B.useCallback)(()=>{y(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}r(``),a(``),s(``),t(`enter-pin`)},[]);return{appState:e,setAppState:t,pin:n,setPin:r,confirmPin:i,setConfirmPin:a,pinError:o,setPinError:s,showPin:c,setShowPin:l,pinLoading:u,authPolling:f,setAuthPolling:p,authLoading:m,setAuthLoading:h,disconnecting:g,sessionKey:v,setSessionKey:y,claudeInfo:b,setClaudeInfo:x,togglingContextMode:S,contextModeHint:w,onboardingComplete:E,setOnboardingComplete:D,businessName:O,conversationId:A,setConversationId:j,accounts:M,accountPickerLoading:P,expandAll:F,setExpandAll:te,expandAllDefaultRef:I,pinInputRef:ne,confirmPinInputRef:re,setPinFormRef:ie,handleSetPin:ae,handleLogin:oe,handleAccountSelect:(0,B.useCallback)(async e=>{ee(!0),s(``),await L(n,e)},[n]),handleContextModeToggle:se,handleDisconnect:ce,handleLogout:le,handleChangePin:(0,B.useCallback)(async()=>{if(!n){s(`Enter your current PIN first.`);return}d(!0),s(``);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({currentPin:n})});if(!e.ok){s((await e.json().catch(()=>({error:`Incorrect PIN.`}))).error||`Incorrect PIN.`);return}r(``),a(``),s(``),t(`set-pin`)}catch(e){console.error(`[admin-auth] change pin failed:`,e),s(e instanceof Error?e.message:String(e))}finally{d(!1)}},[n])}}var gt={active:!1,heldMessage:null,existingTopic:null,confidence:0};function _t(){let[e,t]=(0,B.useState)(gt),n=(0,B.useRef)(!1);return{offer:e,handleOfferEvent:(0,B.useCallback)((e,n,r)=>{t({active:!0,heldMessage:e,existingTopic:n,confidence:r})},[]),consumeOffer:(0,B.useCallback)(r=>{if(!e.active||!e.heldMessage||n.current)return null;n.current=!0;let i={heldMessage:e.heldMessage,action:r};return t(gt),setTimeout(()=>{n.current=!1},0),i},[e]),dismissAndGetHeldMessage:(0,B.useCallback)(()=>{if(!e.active||!e.heldMessage)return null;let n=e.heldMessage;return t(gt),n},[e])}}var vt=`maxy-admin-draft`,yt=[500,1e3,2e3,4e3,8e3,1e4,1e4],bt=3e4;function xt(e){if(e instanceof TypeError){let t=e.message||``;return/network|failed to fetch|load failed/i.test(t)}return!1}async function St(){let e=Date.now()+bt;for(let t=0;t<yt.length;t++){let n=yt[t];if(await new Promise(e=>setTimeout(e,n)),Date.now()>e)return!1;try{if((await fetch(`/api/health`,{cache:`no-store`,signal:AbortSignal.timeout(3e3)})).ok)return!0}catch{}}return!1}function Ct(e){let{sessionKey:t,setSessionKey:n,setAppState:r,setConversationId:i,startElapsedTimer:a,stopElapsedTimer:o,resetTimerState:s,pausedElapsedRef:c,expandAllDefaultRef:l,setExpandAll:u,getPendingFiles:d,clearPendingFiles:f,inputRef:p}=e,[m,h]=(0,B.useState)([]),[g,_]=(0,B.useState)(()=>{try{return localStorage.getItem(vt)??``}catch{return``}}),v=(0,B.useRef)(null),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)([]),C=(0,B.useRef)([]),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)(!1),O=(0,B.useRef)(!1),[k,A]=(0,B.useState)(0),[j,M]=(0,B.useState)(!1),N=(0,B.useRef)(null),P=(0,B.useRef)(()=>{}),[ee,F]=(0,B.useState)(new Set),te=_t();function I(e){C.current=e,S(e)}(0,B.useEffect)(()=>(v.current=setTimeout(()=>{try{g?localStorage.setItem(vt,g):localStorage.removeItem(vt)}catch{}},300),()=>{v.current&&clearTimeout(v.current)}),[g]);function re(){v.current&&clearTimeout(v.current);try{localStorage.removeItem(vt)}catch{}}function ie(e){N.current?.abort(),M(e)}async function L(e){if(y||!t)return;M(!1),a(),b(!0);let i=new AbortController;N.current=i,h([{role:`maxy`,events:[],timestamp:Date.now()}]);try{let a=await fetch(`/api/admin/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:e,session_key:t}),signal:i.signal});if(!a.ok){if(a.status===401){(await a.json().catch(()=>({}))).error===`auth_expired`?r(`connect-claude`):(n(null),r(`enter-pin`));return}let e=await a.json().catch(()=>({}));throw Error(typeof e.error==`string`?e.error:`Request failed (${a.status})`)}let o=!1;for await(let e of ne(a)){if(e.type===`session_reset`){O.current=!0,N.current?.abort();break}if(e.type===`server_shutdown`){o=!0,h(e=>{let t=[...e];return t[0]?.role===`maxy`&&(t[0]={...t[0],events:[...t[0].events??[],{type:`text`,content:`Server is restarting — reconnect will happen automatically.`}]}),t});continue}if(e.type===`done`||e.type===`session_init`)continue;let t=e;h(e=>{let n=[...e];return n[0]?.role===`maxy`&&(n[0]={...n[0],events:[...n[0].events??[],t]}),n})}o&&St()}catch(e){if(!(e instanceof DOMException&&e.name===`AbortError`)){console.error(`[chat] admin sendMessage failed:`,e);let t=e instanceof Error?e.message:String(e),n=xt(e);h(e=>{let r=[...e],i=r[0];if(i?.role===`maxy`){let e=n?`Server is restarting — reconnect will happen automatically.`:`Error: ${t}`;r[0]={...i,events:[...i.events??[],{type:`text`,content:e}]}}else r.push({role:`maxy`,events:[{type:`text`,content:`Error: ${t}`}],timestamp:Date.now()});return r}),n&&St()}}finally{o(h),b(!1),O.current?(O.current=!1,ae()):p.current?.focus()}}function ae(){h([]),D(!1),s(),F(new Set),u(l.current),I([]),_(``),re(),f(),M(!1),A(e=>e+1)}async function oe(){if(y||w||!t){console.warn(`[chat] startNewConversation blocked: streaming=${y} compacting=${w} sessionKey=${!!t}`);return}ae();try{let e=await fetch(`/api/admin/sessions/new?session_key=${encodeURIComponent(t)}`,{method:`POST`});if(e.ok){let t=await e.json();t.session_key&&n(t.session_key),t.conversationId&&i(t.conversationId)}else console.error(`[chat] new conversation failed: ${e.status}`),h([{role:`maxy`,events:[{type:`text`,content:`Could not start a new conversation. Please try again.`}],timestamp:Date.now()}])}catch(e){console.error(`[chat] new conversation failed:`,e),h([{role:`maxy`,events:[{type:`text`,content:`Could not start a new conversation. Please try again.`}],timestamp:Date.now()}])}}function se(e,n,r,i){try{let e=JSON.parse(r);if(e._lifecycle&&t){fetch(`/api/admin/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:r,session_key:t})}).catch(()=>{});return}if(e.action===`save`)return}catch{}pt.has(i??``)||F(t=>new Set(t).add(`${e}_${n}`)),le(i?JSON.stringify({_componentDone:!0,component:i,payload:r}):r,void 0,void 0,!0)}let ce=(0,B.useMemo)(()=>{let e=new Set(ee),t=[];for(let e=0;e<m.length;e++){let n=m[e];if(!(n.role!==`maxy`||!n.events))for(let e=0;e<n.events.length;e++){let r=n.events[e];r.type===`component`&&r.name===`browser-viewer`&&t.push({key:`${n.timestamp}_${e}`})}}for(let n=0;n<t.length-1;n++)e.add(t[n].key);return e},[m,ee]);async function le(e,i,s,l,u){if(!e&&(i??d()).length===0&&!j||y||!t)return;if(te.offer.active&&!u){let t=te.dismissAndGetHeldMessage();if(t)return I([...C.current,{text:e,files:i??[],timestamp:s??Date.now()}]),le(t,void 0,void 0,!0,{topicChangeAction:`continue`,heldMessage:t})}let g=j;M(!1),D(!1);let v=i??[...d()],x=v.map(e=>({attachmentId:``,filename:e.name,mimeType:e.type})),S={role:`admin`,content:e,attachments:x.length>0?x:void 0,timestamp:s??Date.now(),hidden:l||void 0},w=m.length;h(e=>[...e,S]),_(``),re(),i||f(),a(g?c.current:0),b(!0);let T=new AbortController;N.current=T;let E={role:`maxy`,events:[],timestamp:Date.now()};h(e=>[...e,E]);let k=w+1;try{let i,a={},o=s?new Date(s).toISOString():void 0;if(v.length>0){let n=new FormData;n.append(`message`,e),n.append(`session_key`,t),o&&n.append(`timestamp`,o);for(let e of v)n.append(`attachments`,e);i=n}else i=JSON.stringify({message:e,session_key:t,...o&&{timestamp:o},...u&&{topicChangeAction:u.topicChangeAction,heldMessage:u.heldMessage}}),a={"Content-Type":`application/json`};let c=await fetch(`/api/admin/chat`,{method:`POST`,headers:a,body:i,signal:T.signal});if(!c.ok){if(c.status===401){(await c.json().catch(()=>({}))).error===`auth_expired`?r(`connect-claude`):(n(null),r(`enter-pin`));return}let e=await c.json().catch(()=>({}));throw Error(typeof e.error==`string`?e.error:`Request failed (${c.status})`)}let l=!1;for await(let e of ne(c)){if(e.type===`session_reset`){O.current=!0;continue}if(e.type===`topic_change_offer`){te.handleOfferEvent(e.heldMessage,e.existingTopic,e.confidence);continue}if(e.type===`server_shutdown`){l=!0,h(e=>{let t=[...e],n=t[k];return n&&n.role===`maxy`&&(t[k]={...n,events:[...n.events??[],{type:`text`,content:`Server is restarting — reconnect will happen automatically.`}]}),t});continue}if(e.type===`done`||e.type===`session_init`)continue;let t=e;h(e=>{let n=[...e],r=n[k];if(r&&r.role===`maxy`){let i=r.events??[];if(t.type===`component`&&i.some(e=>e.type===`component`&&e.name===t.name&&JSON.stringify(e.data)===JSON.stringify(t.data)))return e;n[k]={...r,events:[...i,t]}}return n})}l&&St()}catch(e){if(!(e instanceof DOMException&&e.name===`AbortError`)){console.error(`[chat] admin sendMessage failed:`,e);let t=e instanceof Error?e.message:String(e),n=xt(e);h(e=>{let r=[...e],i=r[k];if(i&&i.role===`maxy`){let e=n?`Server is restarting — reconnect will happen automatically.`:`Error: ${t}`;r[k]={...i,events:[...i.events??[],{type:`text`,content:e}]}}return r}),n&&St()}}finally{if(o(h),b(!1),O.current)O.current=!1,ae();else{let e=C.current;if(e.length>0){let[t,...n]=e;I(n),P.current(t.text,t.files,t.timestamp)}else p.current?.focus()}}}P.current=le;let ue=(0,B.useCallback)(async()=>{if(!(!t||y||w)){T(!0);try{let e=await fetch(`/api/admin/compact`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:t})});for await(let t of ne(e))if(t.type===`status`&&t.message){let e=t.message;h(t=>{let n=[...t],r=n[n.length-1];return r?.role===`maxy`&&(n[n.length-1]={...r,events:[...r.events??[],{type:`status`,message:e}]}),n})}else t.type===`done`&&t.ok&&D(!0)}finally{T(!1)}}},[t,y,w]);async function de(){let e=te.consumeOffer(`fresh`);e&&(await oe(),P.current(e.heldMessage))}function fe(){let e=te.consumeOffer(`continue`);e&&le(e.heldMessage,void 0,void 0,!0,{topicChangeAction:`continue`,heldMessage:e.heldMessage})}return{messages:m,setMessages:h,input:g,setInput:_,isStreaming:y,messageQueue:x,messageQueueRef:C,setQueue:I,isCompacting:w,conversationCompacted:E,greetingGeneration:k,wasPaused:j,sendMessageRef:P,submittedComponents:ee,effectiveSubmitted:ce,stopStreaming:ie,sendSystemPrompt:L,sendMessage:le,resetConversation:ae,startNewConversation:oe,handleComponentSubmit:se,handleCompactNow:ue,topicChangeOffer:te.offer,handleTopicFreshStart:de,handleTopicContinue:fe}}function wt(){let[e,t]=(0,B.useState)([]),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(null),o=(0,B.useRef)(null),s=(0,B.useCallback)(e=>{a(null);let n=e.find(e=>!dt.has(e.type));if(n){a(`Unsupported file type: "${n.type}". Supported: images, PDF, plain text, markdown, CSV, calendar.`);return}let r=e.find(e=>e.size>ft);if(r){a(`"${r.name}" exceeds the 20 MB limit.`);return}t(t=>[...t,...e].slice(0,5))},[]);return{pendingFiles:e,setPendingFiles:t,isDragOver:n,attachError:i,setAttachError:a,fileInputRef:o,addFiles:s,clearFiles:(0,B.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,B.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,B.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,B.useCallback)(()=>{r(!1)},[]),onDrop:(0,B.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var V=s();function Tt({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,B.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,V.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,V.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function Et(e){let{pin:t,setPin:n,confirmPin:r,setConfirmPin:i,showPin:a,setShowPin:o,pinLoading:s,pinError:c,pinInputRef:l,confirmPinInputRef:u,setPinFormRef:d,onSubmit:f}=e;return(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,v.productName]}),(0,V.jsx)(`p`,{className:`connect-subtitle`,children:`Choose a PIN to secure your admin access.`}),(0,V.jsxs)(`form`,{ref:d,onSubmit:f,className:`connect-pin-form`,children:[(0,V.jsxs)(`div`,{className:`pin-input-row`,children:[(0,V.jsx)(Tt,{inputRef:l,value:t,onChange:n,onComplete:()=>u.current?.focus(),showPin:a,autoFocus:!0}),(0,V.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,V.jsxs)(`div`,{className:`pin-input-row`,children:[(0,V.jsx)(Tt,{inputRef:u,value:r,onChange:i,onComplete:()=>{},showPin:a}),(0,V.jsx)(T,{variant:`send`,type:`submit`,disabled:!t||!r,loading:s,"aria-label":`Set PIN`,children:(0,V.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,V.jsx)(w,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})]}),c&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function Dt(e){let{pin:t,setPin:n,showPin:r,setShowPin:i,pinLoading:a,pinError:o,pinInputRef:s,onSubmit:c,onChangePin:l}=e;return(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsx)(`h1`,{className:`connect-title`,children:v.productName}),(0,V.jsxs)(`form`,{onSubmit:c,className:`connect-pin-form`,children:[(0,V.jsxs)(`div`,{className:`pin-input-row`,children:[(0,V.jsx)(Tt,{inputRef:s,value:t,onChange:n,onComplete:()=>{},showPin:r,autoFocus:!0}),(0,V.jsx)(T,{variant:`send`,type:`submit`,disabled:!t,loading:a,children:(0,V.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,V.jsxs)(`div`,{className:`pin-options`,children:[(0,V.jsx)(w,{checked:r,onChange:()=>i(e=>!e),label:`Show PIN`}),(0,V.jsx)(T,{type:`button`,variant:`ghost`,onClick:l,children:`Change PIN`})]})]}),o&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:o})]})})}function Ot(e){let{accounts:t,loading:n,error:r,onSelect:i}=e;return(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsx)(`h1`,{className:`connect-title`,children:v.productName}),(0,V.jsx)(`p`,{className:`connect-subtitle`,children:`Select an account`}),(0,V.jsx)(`div`,{className:`account-picker-list`,children:t.map(e=>(0,V.jsxs)(`button`,{className:`account-picker-card`,onClick:()=>i(e.accountId),disabled:n,type:`button`,children:[(0,V.jsx)(`span`,{className:`account-picker-name`,children:e.businessName||e.accountId}),(0,V.jsx)(`span`,{className:`account-picker-role`,children:e.role}),n&&(0,V.jsx)(ie,{className:`account-picker-spinner`,size:16})]},e.accountId))}),r&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:r})]})})}function kt(e){let{authPolling:t,setAuthPolling:n,authLoading:r,setAuthLoading:i,pinError:a,setPinError:o,setAppState:s}=e,[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1);async function f(){d(!0),o(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?l(!0):e.error&&o(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),o(`Could not launch browser.`)}d(!1)}async function p(){i(!0),o(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),l(!0),i(!1);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),s(`enter-pin`);return}o(`Timed out waiting for sign-in. Try again.`),n(!1)}else e.error&&o(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),o(`Could not start auth flow.`)}i(!1)}async function m(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),o(``)}return t||c?(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,V.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,V.jsx)(`button`,{onClick:m,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,V.jsx)(`button`,{onClick:()=>l(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,V.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,V.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,V.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,V.jsx)(`div`,{style:{marginTop:`12px`},children:(0,V.jsx)(T,{variant:`primary`,onClick:p,disabled:r,children:r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})})]}),(0,V.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,V.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),a&&(0,V.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:a})]}):(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsxs)(`div`,{className:`connect-logos`,children:[(0,V.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,V.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,V.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,V.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,V.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsx)(`span`,{className:`connect-logo-label`,children:v.productName})]})]}),(0,V.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,v.productName]}),(0,V.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,V.jsx)(T,{variant:`primary`,onClick:p,disabled:r,children:r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,V.jsx)(`button`,{onClick:f,disabled:u,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:u?`Launching…`:`Open browser first`}),(0,V.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),a&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:a})]})})}function At({setAppState:e,setOnboardingComplete:t}){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(``);async function o(){r(!0),a(``);try{let n=await fetch(`/api/onboarding/skip`,{method:`POST`});if(!n.ok){a((await n.json().catch(()=>({}))).error||`Failed to apply defaults.`);return}t(!0),e(`connect-claude`)}catch(e){console.error(`[admin] skip onboarding error:`,e),a(`Could not apply defaults.`)}finally{r(!1)}}function s(){e(`connect-claude`)}return(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsx)(`span`,{className:`connect-logo-label`,children:v.productName})]}),(0,V.jsx)(`h1`,{className:`connect-title`,children:`How would you like to get started?`}),(0,V.jsx)(`p`,{className:`connect-subtitle`,style:{fontSize:`0.8rem`,maxWidth:`320px`},children:`Defaults: core plugins only, auto-detected timezone, concise output style, and a minimal personality. No WiFi or optional plugins.`}),(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`10px`,width:`100%`,maxWidth:`320px`,alignItems:`center`},children:[(0,V.jsx)(T,{variant:`primary`,onClick:o,disabled:n,children:n?`Applying defaults…`:`Use defaults`}),(0,V.jsx)(`button`,{onClick:s,style:{background:`none`,border:`none`,padding:`8px`,cursor:`pointer`,fontSize:`0.95rem`,color:`var(--text-secondary, #666)`,textDecoration:`none`},children:`Guided setup`})]}),(0,V.jsx)(`p`,{className:`connect-subtitle`,style:{marginTop:`12px`},children:`You can change any setting later through conversation.`}),i&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:i})]})})}function jt({data:e,onSubmit:t,submitted:n}){let r=e,[i,a]=(0,B.useState)(`Submitted`);return r?.title?(0,V.jsx)(k,{submitted:n,submittedLabel:i,actions:[{label:r.rejectLabel??`Reject`,variant:`ghost`,onClick:()=>{n||(a(`Rejected`),t(r.rejectMessage??`Rejected: ${r.title}`))}},{label:r.confirmLabel??`Approve`,variant:`primary`,onClick:()=>{n||(a(`Approved`),t(r.confirmMessage??`Approved: ${r.title}`))}}],children:(0,V.jsxs)(`div`,{className:`confirm`,children:[(0,V.jsx)(`div`,{className:`confirm__title`,children:r.title}),r.description&&(0,V.jsx)(`div`,{className:`confirm__desc`,children:r.description}),r.items&&r.items.length>0&&(0,V.jsx)(`div`,{className:`confirm__items`,children:r.items.map((e,t)=>(0,V.jsxs)(`div`,{className:`confirm__item`,children:[(0,V.jsx)(`span`,{className:`confirm__item-label`,children:e.label}),(0,V.jsx)(`span`,{className:`confirm__item-value`,children:e.value})]},t))})]})}):null}function Mt({data:e,onSubmit:t,submitted:n}){let r=e,i=(0,B.useRef)(!1),a=!!(r?.title&&Array.isArray(r?.fields)&&r.fields.length>0),o=r?.actions&&r.actions.length>0;return(0,B.useEffect)(()=>{a&&!o&&!n&&!i.current&&(i.current=!0,t(``))},[a,o,n,t]),a?(0,V.jsx)(k,{submitted:n,submittedLabel:`Done`,actions:o?r.actions.map(e=>({label:e.label,variant:e.variant,onClick:()=>{n||t(e.message)}})):[],children:(0,V.jsxs)(`div`,{className:`info-card`,children:[(0,V.jsxs)(`div`,{className:`info-card__header`,children:[(0,V.jsx)(`div`,{className:`info-card__title`,children:r.title}),r.subtitle&&(0,V.jsx)(`div`,{className:`info-card__subtitle`,children:r.subtitle})]}),(0,V.jsx)(`div`,{className:`info-card__fields`,children:r.fields.map((e,t)=>(0,V.jsxs)(`div`,{className:`info-card__field`,children:[(0,V.jsx)(`span`,{className:`info-card__field-label`,children:e.label}),(0,V.jsx)(`span`,{className:`info-card__field-value${e.type===`status`?` info-card__field-value--status`:``}`,children:e.type===`link`?(0,V.jsx)(`a`,{href:e.value,target:`_blank`,rel:`noopener noreferrer`,children:e.value}):e.value})]},t))})]})}):null}function Nt({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.items)?r.items:[],[a,o]=(0,B.useState)(new Set),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(`Done`);if(i.length===0)return null;let d=n||s,f=(e,n)=>{d||a.has(e)||(o(t=>new Set(t).add(e)),t(n))};return(0,V.jsx)(k,{submitted:d,submittedLabel:l,actions:[{label:`Done`,variant:`primary`,onClick:()=>{d||(c(!0),u(`Done`),t(r?.doneMessage??`Done`))}}],children:(0,V.jsxs)(`div`,{className:`action-list`,children:[r?.title&&(0,V.jsx)(`div`,{className:`action-list__title`,children:r.title}),(0,V.jsx)(`div`,{className:`action-list__items`,children:i.map(e=>(0,V.jsxs)(`div`,{className:`action-list__item${a.has(e.id)?` action-list__item--acted`:``}`,children:[(0,V.jsxs)(`div`,{className:`action-list__item-info`,children:[(0,V.jsx)(`span`,{className:`action-list__item-label`,children:e.label}),e.description&&(0,V.jsx)(`span`,{className:`action-list__item-desc`,children:e.description})]}),(0,V.jsxs)(`div`,{className:`action-list__item-right`,children:[e.status&&(0,V.jsx)(`span`,{className:`action-list__item-status`,children:e.status}),(0,V.jsx)(`div`,{className:`action-list__item-actions`,children:e.actions.map((t,n)=>(0,V.jsx)(T,{variant:t.variant===`danger`?`danger`:t.variant===`ghost`?`ghost`:`primary`,size:`sm`,disabled:d||a.has(e.id),onClick:n=>{n.stopPropagation(),f(e.id,t.message)},children:t.label},n))})]})]},e.id))})]})})}function Pt({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.fields)?r.fields:[],[a,o]=(0,B.useState)({}),[s,c]=(0,B.useState)({}),[l,u]=(0,B.useState)({}),[d,f]=(0,B.useState)(`Submitted`);if((0,B.useEffect)(()=>{i.length!==0&&(o(e=>{let t={...e};return i.forEach(e=>{e.type!==`list`&&(e.name in t||(t[e.name]=e.defaultValue??(e.type===`checkbox`?!1:``)))}),t}),c(e=>{let t={...e};return i.forEach(e=>{e.type===`list`&&(e.name in t||(t[e.name]=Array.isArray(e.defaultValue)?e.defaultValue:[]))}),t}))},[i]),i.length===0)return null;let p=(e,t)=>{n||o(n=>({...n,[e]:t}))},m=i.filter(e=>e.required&&e.type!==`list`).every(e=>{let t=a[e.name];return e.type===`checkbox`?t===!0:typeof t==`string`&&t.trim()!==``}),h=()=>{if(!m||n)return;f(`Submitted`);let e=r?.submitMessage??`Form submitted: {{json}}`,i=JSON.stringify(a),o=e;for(let[e,t]of Object.entries(a))o=o.replace(`{{${e}}}`,()=>String(t));o=o.replace(`{{json}}`,()=>i),o=o.replace(`{{values}}`,()=>i),t(o)},g=e=>e.description?`${e.label} — ${e.description}`:e.label,_=e=>{let r=(l[e.name]??``).trim();!r||n||(c(t=>({...t,[e.name]:[...t[e.name]??[],r]})),u(t=>({...t,[e.name]:``})),e.addMessage&&t(e.addMessage.replace(`{{value}}`,r)))},v=(e,r)=>{n||(c(t=>({...t,[e.name]:(t[e.name]??[]).filter(e=>e!==r)})),e.removeMessage&&t(e.removeMessage.replace(`{{value}}`,r)))};return(0,V.jsx)(k,{submitted:n,submittedLabel:d,actions:[{label:r?.submitLabel??`Submit`,variant:`primary`,disabled:!m,onClick:h}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[r?.title&&(0,V.jsx)(`div`,{className:`form-input__title`,children:r.title}),r?.description&&(0,V.jsx)(`div`,{className:`form-input__desc`,children:r.description}),(0,V.jsx)(`div`,{className:`form-input__fields`,children:i.map(e=>(0,V.jsx)(`div`,{className:`form-input__field`,children:e.type===`checkbox`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(w,{checked:a[e.name]===!0,onChange:t=>p(e.name,t),label:e.label,disabled:n}),e.description&&(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:e.description})]}):e.type===`list`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`label`,{className:`form-input__label`,children:e.label}),e.description&&(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:e.description}),(0,V.jsxs)(`div`,{className:`form-input__list`,children:[(s[e.name]??[]).map(t=>(0,V.jsxs)(`div`,{className:`form-input__list-item`,children:[(0,V.jsx)(`span`,{className:`form-input__list-item-text`,children:t}),(0,V.jsx)(`button`,{type:`button`,className:`form-input__list-item-remove`,onClick:()=>v(e,t),disabled:n,"aria-label":`Remove ${t}`,children:`×`})]},t)),(0,V.jsxs)(`div`,{className:`form-input__list-add`,children:[(0,V.jsx)(`input`,{className:`form-input__input`,type:`text`,placeholder:e.addPlaceholder??``,value:l[e.name]??``,onChange:t=>u(n=>({...n,[e.name]:t.target.value})),onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),_(e))},disabled:n}),(0,V.jsx)(`button`,{type:`button`,className:`form-input__list-add-btn`,onClick:()=>_(e),disabled:n||!(l[e.name]??``).trim(),children:`Add`})]})]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`form-${e.name}`,children:[e.label,e.required&&(0,V.jsx)(`span`,{className:`form-input__required`,children:`*`})]}),e.description&&(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:e.description}),e.type===`textarea`?(0,V.jsx)(`textarea`,{id:`form-${e.name}`,className:`form-input__textarea`,placeholder:e.placeholder,value:a[e.name]??``,onChange:t=>p(e.name,t.target.value),disabled:n,rows:3}):e.type===`select`?(0,V.jsxs)(`select`,{id:`form-${e.name}`,className:`form-input__select`,value:a[e.name]??``,onChange:t=>p(e.name,t.target.value),disabled:n,children:[(0,V.jsx)(`option`,{value:``,children:e.placeholder??`Select...`}),e.options?.map(e=>(0,V.jsx)(`option`,{value:e.value,children:g(e)},e.value))]}):(0,V.jsx)(`input`,{id:`form-${e.name}`,className:`form-input__input`,type:e.type,placeholder:e.placeholder,value:a[e.name]??``,onChange:t=>p(e.name,t.target.value),disabled:n})]})},e.name))})]})})}var Ft={pending:`○`,active:`◉`,completed:`✓`,failed:`✗`,skipped:`–`};function It({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.steps)?r.steps:[],a=(0,B.useRef)(!1),o=i.length>0&&i.every(e=>e.status===`completed`||e.status===`failed`||e.status===`skipped`);return(0,B.useEffect)(()=>{o&&!n&&!a.current&&(a.current=!0,t(r?.completedMessage??`All steps completed`))},[o,n,t,r?.completedMessage]),i.length===0?null:(0,V.jsxs)(`div`,{className:`progress-tracker${n?` progress-tracker--submitted`:``}`,children:[r?.title&&(0,V.jsx)(`div`,{className:`progress-tracker__title`,children:r.title}),(0,V.jsx)(`div`,{className:`progress-tracker__steps`,children:i.map((e,t)=>(0,V.jsxs)(`div`,{className:`progress-tracker__step progress-tracker__step--${e.status}`,children:[(0,V.jsx)(`span`,{className:`progress-tracker__icon`,children:Ft[e.status]??`○`}),(0,V.jsxs)(`div`,{className:`progress-tracker__step-info`,children:[(0,V.jsx)(`span`,{className:`progress-tracker__step-label`,children:e.label}),e.description&&(0,V.jsx)(`span`,{className:`progress-tracker__step-desc`,children:e.description})]})]},t))})]})}function Lt({handlePopout:e,disabled:t=!1}){let n=(0,B.useCallback)(()=>{delete document.body.dataset.dragPopoutActive},[]);(0,B.useEffect)(()=>()=>n(),[n]);let r=(0,B.useCallback)(e=>{if(t){e.preventDefault();return}let n=e.target;if(n.closest(`.editor-base__actions`)||n.closest(`.browser-viewer__actions`)){e.preventDefault();return}if(!document.querySelector(`.chat-messages`)){e.preventDefault();return}e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,``),document.body.dataset.dragPopoutActive=`true`},[t,n]),i=(0,B.useCallback)(t=>{if(n(),t.clientX===0&&t.clientY===0)return;let r=document.querySelector(`.chat-messages`);if(!r)return;let i=r.getBoundingClientRect();(t.clientX<i.left||t.clientX>i.right||t.clientY<i.top||t.clientY>i.bottom)&&e()},[e,n]);return t?{draggable:!1,onDragStart:()=>{},onDragEnd:()=>{}}:{draggable:!0,onDragStart:r,onDragEnd:i}}function Rt({data:e,onSubmit:t,submitted:n,isStreaming:r}){ot();let{title:i}=e??{},[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),d=(0,B.useRef)(null),f=(0,B.useRef)(null),p=i??v.productName,m=(0,B.useCallback)(()=>{f.current&&=(clearInterval(f.current),null),d.current&&!d.current.closed&&d.current.close(),d.current=null,c(!1)},[]),h=(0,B.useCallback)(()=>{o(!1),u(!1);let e=`/vnc-popout.html?title=${encodeURIComponent(p)}`,t=window.open(e,`maxy-vnc-popout`,`width=1024,height=768`);t&&(d.current=t,c(!0),f.current=setInterval(()=>{d.current?.closed&&(m(),u(!0))},500))},[p,m]),g=(0,B.useCallback)(()=>{m(),o(!1),u(!0)},[m]),_=(0,B.useCallback)(()=>{m(),u(!1)},[m]),y=(0,B.useCallback)(()=>{u(!1)},[]),b=(0,B.useCallback)(()=>{m(),u(!1),o(!0)},[m]),x=(0,B.useCallback)(()=>o(!1),[]);(0,B.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&x()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,x]),(0,B.useEffect)(()=>()=>m(),[m]);let S=Lt({handlePopout:h,disabled:s||a});if(n)return null;let C=`/vnc-viewer.html`;return a?(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...S,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:p}),(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:h,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:We,onClick:x,"aria-label":`Exit full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ge,onClick:g,"aria-label":`Minimise`})]})]}),(0,V.jsx)(`iframe`,{src:C,className:`browser-viewer-fullscreen__iframe`,title:p})]}):s?(0,V.jsx)(`div`,{className:`browser-viewer browser-viewer--popout`,children:(0,V.jsxs)(`div`,{className:`browser-viewer__bar`,...S,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer__title`,children:p}),(0,V.jsxs)(`div`,{className:`browser-viewer__actions`,children:[(0,V.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ze,onClick:_,"aria-label":`Pop back in`})]})]})}):l?(0,V.jsxs)(`div`,{className:`browser-viewer browser-viewer--minimised`,onClick:y,role:`button`,tabIndex:0,onKeyDown:e=>e.key===`Enter`&&y(),children:[(0,V.jsxs)(`div`,{className:`browser-viewer__bar`,...S,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer__title`,children:p}),(0,V.jsxs)(`div`,{className:`browser-viewer__actions`,onClick:e=>e.stopPropagation(),children:[(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:h,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ve,onClick:b,"aria-label":`Full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Je,onClick:y,"aria-label":`Expand`})]})]}),(0,V.jsx)(`iframe`,{src:C,className:`browser-viewer__iframe`,title:p,"aria-hidden":`true`})]}):(0,V.jsxs)(`div`,{className:`browser-viewer`,children:[(0,V.jsxs)(`div`,{className:`browser-viewer__bar`,...S,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),i&&(0,V.jsx)(`span`,{className:`browser-viewer__title`,children:i}),(0,V.jsxs)(`div`,{className:`browser-viewer__actions`,children:[(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:h,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ve,onClick:b,"aria-label":`Full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ge,onClick:g,"aria-label":`Minimise`})]})]}),(0,V.jsx)(`iframe`,{src:C,className:`browser-viewer__iframe`,title:p})]})}var zt=t((e=>{var t=a();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),a=r[0].inst,l=r[1];return s(function(){a.value=n,a.getSnapshot=t,u(a)&&l({inst:a})},[e,n,t]),o(function(){return u(a)&&l({inst:a}),e(function(){u(a)&&l({inst:a})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Bt=t(((e,t)=>{t.exports=zt()})),Vt=Bt(),Ht=e(n(),1);function Ut(e){this.content=e}Ut.prototype={constructor:Ut,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new Ut(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new Ut(n)},addToStart:function(e,t){return new Ut([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Ut(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new Ut(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=Ut.from(e),e.size?new Ut(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=Ut.from(e),e.size?new Ut(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Ut.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},Ut.from=function(e){if(e instanceof Ut)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Ut(t)};function Wt(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=Wt(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Gt(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=Gt(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var H=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Wt(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Gt(this,e,t,n)}findIndex(e){if(e==0)return qt(0,e);if(e==this.size)return qt(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?qt(t+1,i):qt(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};H.empty=new H([],0);var Kt={index:0,offset:0};function qt(e,t){return Kt.index=e,Kt.offset=t,Kt}function Jt(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Jt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Jt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var U=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Jt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};U.none=[];var Yt=class extends Error{},W=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Zt(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Xt(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(H.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};W.empty=new W(H.empty,0,0);function Xt(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Xt(a.content,t-i-1,n-i-1)))}function Zt(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=Zt(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function Qt(e,t,n){if(n.openStart>e.depth)throw new Yt(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Yt(`Inconsistent open depths`);return $t(e,t,n,0)}function $t(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=$t(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return an(a,sn(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return an(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=cn(n,e);return an(a,on(e,i,o,t,r))}}function en(e,t){if(!t.type.compatibleContent(e.type))throw new Yt(`Cannot join `+t.type.name+` onto `+e.type.name)}function tn(e,t,n){let r=e.node(n);return en(r,t.node(n)),r}function nn(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function rn(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(nn(e.nodeAfter,r),a++));for(let e=a;e<o;e++)nn(i.child(e),r);t&&t.depth==n&&t.textOffset&&nn(t.nodeBefore,r)}function an(e,t){return e.type.checkContent(t),e.copy(t)}function on(e,t,n,r,i){let a=e.depth>i&&tn(e,t,i+1),o=r.depth>i&&tn(n,r,i+1),s=[];return rn(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(en(a,o),nn(an(a,on(e,t,n,r,i+1)),s)):(a&&nn(an(a,sn(e,t,i+1)),s),rn(t,n,i,s),o&&nn(an(o,sn(n,r,i+1)),s)),rn(r,null,i,s),new H(s)}function sn(e,t,n){let r=[];return rn(null,e,n,r),e.depth>n&&nn(an(tn(e,t,n+1),sn(e,t,n+1)),r),rn(t,null,n,r),new H(r)}function cn(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(H.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var ln=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return U.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new pn(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=fn.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else fn.set(t,r=new un);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%dn,i}},un=class{constructor(){this.elts=[],this.i=0}},dn=12,fn=new WeakMap,pn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},mn=Object.create(null),hn=class e{constructor(e,t,n,r=U.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||H.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Jt(this.attrs,t||e.defaultAttrs||mn)&&U.sameSet(this.marks,n||U.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return W.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new W(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Qt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return ln.resolveCached(this,e)}resolveNoCache(e){return ln.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),_n(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=H.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=U.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!U.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=H.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};hn.prototype.text=void 0;var gn=class e extends hn{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):_n(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function _n(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var vn=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new yn(t,n);if(r.next==null)return e.empty;let i=bn(r);r.next&&r.err(`Unexpected trailing text`);let a=An(Dn(i));return jn(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return H.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
1
|
+
import{o as e,t}from"./chunk-DD-I1_y5.js";import{a as n,i as r,n as i,o as a,r as o,t as s}from"./jsx-runtime-XWiDQoTG.js";import{A as c,C as l,D as u,E as d,M as f,N as p,O as m,P as h,S as g,T as _,_ as v,a as y,b,c as x,d as S,f as C,g as w,h as T,i as E,j as D,k as O,l as k,m as A,n as j,o as M,p as N,r as P,s as ee,t as F,u as te,w as I,x as ne,y as re}from"./useVoiceRecorder-D_efR3Nx.js";import{a as ie,i as L,n as ae,o as oe,r as se,t as ce}from"./share-2-DLjRUEiG.js";import{n as le,t as ue}from"./file-rN5uuyaV.js";import{n as de,t as fe}from"./x-L6KPMfIN.js";var pe=o(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),me=o(`asterisk`,[[`path`,{d:`M12 6v12`,key:`1vza4d`}],[`path`,{d:`M17.196 9 6.804 15`,key:`1ah31z`}],[`path`,{d:`m6.804 9 10.392 6`,key:`1b6pxd`}]]),he=o(`bold`,[[`path`,{d:`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`,key:`mg9rjx`}]]),ge=o(`bot-off`,[[`path`,{d:`M13.67 8H18a2 2 0 0 1 2 2v4.33`,key:`7az073`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M22 22 2 2`,key:`1r8tn9`}],[`path`,{d:`M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586`,key:`s09a7a`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}],[`path`,{d:`M9.67 4H12v2.33`,key:`110xot`}]]),_e=o(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ve=o(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),ye=o(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),be=o(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),xe=o(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),R=o(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),Se=o(`clipboard-plus`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M9 14h6`,key:`159ibu`}],[`path`,{d:`M12 17v-6`,key:`1y8rbf`}]]),z=o(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Ce=o(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),we=o(`database-zap`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`,key:`14ibmq`}],[`path`,{d:`M21 5V8`,key:`1marbg`}],[`path`,{d:`M21 12L18 17H22L19 22`,key:`zafso`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`,key:`1y4wr8`}]]),Te=o(`database-search`,[[`path`,{d:`M21 11.693V5`,key:`175m1t`}],[`path`,{d:`m22 22-1.875-1.875`,key:`13zax7`}],[`path`,{d:`M3 12a9 3 0 0 0 8.697 2.998`,key:`151u9p`}],[`path`,{d:`M3 5v14a9 3 0 0 0 9.28 2.999`,key:`q2rs2p`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}]]),Ee=o(`dot`,[[`circle`,{cx:`12.1`,cy:`12.1`,r:`1`,key:`18d7e5`}]]),De=o(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Oe=o(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),ke=o(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),Ae=o(`file-pen-line`,[[`path`,{d:`m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351`,key:`1k2beg`}],[`path`,{d:`M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`2t3380`}],[`path`,{d:`M8 18h1`,key:`13wk12`}]]),je=o(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Me=o(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Ne=o(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Pe=o(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Fe=o(`italic`,[[`line`,{x1:`19`,x2:`10`,y1:`4`,y2:`4`,key:`15jd3p`}],[`line`,{x1:`14`,x2:`5`,y1:`20`,y2:`20`,key:`bu0au3`}],[`line`,{x1:`15`,x2:`9`,y1:`4`,y2:`20`,key:`uljnxc`}]]),Ie=o(`lightbulb-off`,[[`path`,{d:`M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5`,key:`1fkcox`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5`,key:`10m8kw`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Le=o(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Re=o(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),ze=o(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),Be=o(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),Ve=o(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),He=o(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),Ue=o(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),We=o(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Ge=o(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Ke=o(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),qe=o(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Je=o(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ye=o(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),Xe=o(`sparkle`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}]]),Ze=o(`square-arrow-down-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`m16 8-8 8`,key:`166keh`}],[`path`,{d:`M16 16H8V8`,key:`1w2ppm`}]]),Qe=o(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),$e=o(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),et=o(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),tt=o(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),nt=o(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),rt=o(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),it=o(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),at=r(),B=e(a(),1);function ot(){(0,B.useEffect)(()=>{function e(e){e.data?.type===`vnc-clipboard`&&typeof e.data.text==`string`&&g(e.data.text)}window.addEventListener(`message`,e);let t=null;return typeof BroadcastChannel<`u`&&(t=new BroadcastChannel(`maxy-vnc-clipboard`),t.onmessage=e=>{typeof e.data==`string`&&g(e.data)}),()=>{window.removeEventListener(`message`,e),t?.close()}},[])}function st(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function ct(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function lt(){let[e,t]=(0,B.useState)(0),n=(0,B.useRef)(0),r=(0,B.useRef)(0),i=(0,B.useRef)(null),[a,o]=(0,B.useState)(0),s=(0,B.useRef)(0),c=(0,B.useRef)(null),l=(0,B.useRef)(null);return{elapsedSeconds:e,sessionElapsed:a,sessionTurnStart:l,pausedElapsedRef:r,startElapsedTimer:(0,B.useCallback)((e=0)=>{l.current=Date.now(),c.current=setInterval(()=>{let e=s.current+(Date.now()-(l.current??Date.now()));o(Math.floor(e/1e3))},1e3),n.current=e,t(e),i.current=setInterval(()=>{n.current+=1,t(n.current)},1e3)},[]),stopElapsedTimer:(0,B.useCallback)(e=>{i.current&&=(clearInterval(i.current),null),c.current&&=(clearInterval(c.current),null),l.current&&(s.current+=Date.now()-l.current,l.current=null,o(Math.floor(s.current/1e3))),r.current=n.current;let t=n.current;e(e=>{let n=[...e].map((e,t)=>({m:e,i:t})).reverse().find(({m:e})=>e.role===`maxy`)?.i;if(n===void 0)return e;let r=[...e];return r[n]={...r[n],elapsedSeconds:t},r})},[]),resetTimerState:(0,B.useCallback)(()=>{s.current=0,o(0)},[])}}var ut=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar`,dt=new Set(ut.split(`,`)),ft=20*1024*1024,pt=new Set([`action-list`,`document-editor`,`rich-content-editor`,`grid-editor`]);function mt(e){switch(e){case`expanded`:return!0;case`collapsed`:return!1;default:return}}function ht(){let[e,t]=(0,B.useState)(`loading`),[n,r]=(0,B.useState)(``),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(null),[S,C]=(0,B.useState)(!1),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)(void 0),[O,k]=(0,B.useState)(void 0),[A,j]=(0,B.useState)(null),[M,N]=(0,B.useState)([]),[P,ee]=(0,B.useState)(!1),[F,te]=(0,B.useState)(void 0),I=(0,B.useRef)(void 0),ne=(0,B.useRef)(null),re=(0,B.useRef)(null),ie=(0,B.useRef)(null);(0,B.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let n=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(n.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!n.ok)return!1;let r=await n.json();y(r.session_key),j(r.conversationId??null),D(r.onboardingComplete),k(r.businessName);let i=mt(r.thinkingView);return I.current=i,te(i),t(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function n(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),n(r-1);console.error(`[admin] health check returned ${i.status} after retries`),t(`set-pin`);return}let a=await i.json();if(!a.pin_configured)t(`set-pin`);else if(!a.claude_authenticated)t(a.onboarding_complete?`connect-claude`:`onboarding-choice`);else{if(await e())return;t(`enter-pin`)}}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),n(r-1);console.error(`[admin] health check failed:`,e),t(`set-pin`)}}n()},[]),(0,B.useEffect)(()=>{e===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&x(e)}).catch(()=>{})},[e]),(0,B.useEffect)(()=>{if(e!==`chat`)return;let n=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(!e.ok)return;let n=await e.json();(n.auth_status===`dead`||n.auth_status===`missing`)&&t(`connect-claude`)}catch{}},300*1e3);return()=>clearInterval(n)},[e]),(0,B.useEffect)(()=>{e===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&t(`enter-pin`)}).catch(()=>{})},[e]);async function L(e,n){d(!0);try{let i=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...n?{accountId:n}:{}})});if(!i.ok){s((await i.json().catch(()=>({}))).error||`Invalid PIN`);return}let o=await i.json();if(o.accounts&&!o.session_key){console.log(`[admin] account picker shown: userId=${o.userId} accountCount=${o.accounts.length}`),N(o.accounts),t(`account-picker`);return}y(o.session_key),j(o.conversationId??null),D(o.onboardingComplete??!0),k(o.businessName);let c=mt(o.thinkingView);if(I.current=c,te(c),n)try{sessionStorage.setItem(`maxy-account-id`,n)}catch{}try{sessionStorage.setItem(`maxy-admin-session-key`,o.session_key)}catch{}r(``),a(``),t(`chat`)}catch(e){console.error(`[admin] connection error:`,e),s(`Could not connect.`)}finally{d(!1),ee(!1)}}let ae=(0,B.useCallback)(async e=>{if(e.preventDefault(),u)return;if(s(``),n.length<4){s(`PIN must be at least 4 characters.`);return}if(n!==i){s(`PINs do not match.`);return}let o=n;d(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:o})});if(!e.ok){let n=await e.json().catch(()=>({}));if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?t(`enter-pin`):r.pin_configured?t(`connect-claude`):s(n.error||`Failed to set PIN.`)}else t(`enter-pin`)}catch{t(`enter-pin`)}return}s(n.error||`Failed to set PIN.`);return}let n=await fetch(`/api/health`);if((n.ok?await n.json():null)?.claude_authenticated){await L(o);return}r(``),a(``),t(`onboarding-choice`)}catch(e){console.error(`[admin] connection error:`,e),s(`Could not connect.`)}finally{d(!1)}},[n,i,u]),oe=(0,B.useCallback)(async e=>{e.preventDefault(),s(``),await L(n)},[n]),se=(0,B.useCallback)(async()=>{if(!v||!b?.contextMode||S)return;let e=b.contextMode,t=e===`claude-code`?`managed`:`claude-code`;C(!0),x({...b,contextMode:t}),T(!0);let n=setTimeout(()=>T(!1),3e3);try{let r=await fetch(`/api/admin/account`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:v,contextMode:t})});r.ok||(console.error(`[context-mode-toggle] failed: ${r.status}`),x({...b,contextMode:e}),clearTimeout(n),T(!1))}catch(t){console.error(`[context-mode-toggle] error:`,t),x({...b,contextMode:e}),clearTimeout(n),T(!1)}finally{C(!1)}},[v,b,S]),ce=(0,B.useCallback)(async()=>{_(!0),await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})}),y(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}t(`connect-claude`)},[]),le=(0,B.useCallback)(()=>{y(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}r(``),a(``),s(``),t(`enter-pin`)},[]);return{appState:e,setAppState:t,pin:n,setPin:r,confirmPin:i,setConfirmPin:a,pinError:o,setPinError:s,showPin:c,setShowPin:l,pinLoading:u,authPolling:f,setAuthPolling:p,authLoading:m,setAuthLoading:h,disconnecting:g,sessionKey:v,setSessionKey:y,claudeInfo:b,setClaudeInfo:x,togglingContextMode:S,contextModeHint:w,onboardingComplete:E,setOnboardingComplete:D,businessName:O,conversationId:A,setConversationId:j,accounts:M,accountPickerLoading:P,expandAll:F,setExpandAll:te,expandAllDefaultRef:I,pinInputRef:ne,confirmPinInputRef:re,setPinFormRef:ie,handleSetPin:ae,handleLogin:oe,handleAccountSelect:(0,B.useCallback)(async e=>{ee(!0),s(``),await L(n,e)},[n]),handleContextModeToggle:se,handleDisconnect:ce,handleLogout:le,handleChangePin:(0,B.useCallback)(async()=>{if(!n){s(`Enter your current PIN first.`);return}d(!0),s(``);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({currentPin:n})});if(!e.ok){s((await e.json().catch(()=>({error:`Incorrect PIN.`}))).error||`Incorrect PIN.`);return}r(``),a(``),s(``),t(`set-pin`)}catch(e){console.error(`[admin-auth] change pin failed:`,e),s(e instanceof Error?e.message:String(e))}finally{d(!1)}},[n])}}var gt={active:!1,heldMessage:null,existingTopic:null,confidence:0};function _t(){let[e,t]=(0,B.useState)(gt),n=(0,B.useRef)(!1);return{offer:e,handleOfferEvent:(0,B.useCallback)((e,n,r)=>{t({active:!0,heldMessage:e,existingTopic:n,confidence:r})},[]),consumeOffer:(0,B.useCallback)(r=>{if(!e.active||!e.heldMessage||n.current)return null;n.current=!0;let i={heldMessage:e.heldMessage,action:r};return t(gt),setTimeout(()=>{n.current=!1},0),i},[e]),dismissAndGetHeldMessage:(0,B.useCallback)(()=>{if(!e.active||!e.heldMessage)return null;let n=e.heldMessage;return t(gt),n},[e])}}var vt=`maxy-admin-draft`,yt=[500,1e3,2e3,4e3,8e3,1e4,1e4],bt=3e4;function xt(e){if(e instanceof TypeError){let t=e.message||``;return/network|failed to fetch|load failed/i.test(t)}return!1}async function St(){let e=Date.now()+bt;for(let t=0;t<yt.length;t++){let n=yt[t];if(await new Promise(e=>setTimeout(e,n)),Date.now()>e)return!1;try{if((await fetch(`/api/health`,{cache:`no-store`,signal:AbortSignal.timeout(3e3)})).ok)return!0}catch{}}return!1}function Ct(e){let{sessionKey:t,setSessionKey:n,setAppState:r,setConversationId:i,startElapsedTimer:a,stopElapsedTimer:o,resetTimerState:s,pausedElapsedRef:c,expandAllDefaultRef:l,setExpandAll:u,getPendingFiles:d,clearPendingFiles:f,inputRef:p}=e,[m,h]=(0,B.useState)([]),[g,_]=(0,B.useState)(()=>{try{return localStorage.getItem(vt)??``}catch{return``}}),v=(0,B.useRef)(null),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)([]),C=(0,B.useRef)([]),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)(!1),O=(0,B.useRef)(!1),[k,A]=(0,B.useState)(0),[j,M]=(0,B.useState)(!1),N=(0,B.useRef)(null),P=(0,B.useRef)(()=>{}),[ee,F]=(0,B.useState)(new Set),te=_t();function I(e){C.current=e,S(e)}(0,B.useEffect)(()=>(v.current=setTimeout(()=>{try{g?localStorage.setItem(vt,g):localStorage.removeItem(vt)}catch{}},300),()=>{v.current&&clearTimeout(v.current)}),[g]);function re(){v.current&&clearTimeout(v.current);try{localStorage.removeItem(vt)}catch{}}function ie(e){N.current?.abort(),M(e)}async function L(e){if(y||!t)return;M(!1),a(),b(!0);let i=new AbortController;N.current=i,h([{role:`maxy`,events:[],timestamp:Date.now()}]);try{let a=await fetch(`/api/admin/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:e,session_key:t}),signal:i.signal});if(!a.ok){if(a.status===401){(await a.json().catch(()=>({}))).error===`auth_expired`?r(`connect-claude`):(n(null),r(`enter-pin`));return}let e=await a.json().catch(()=>({}));throw Error(typeof e.error==`string`?e.error:`Request failed (${a.status})`)}let o=!1;for await(let e of ne(a)){if(e.type===`session_reset`){O.current=!0,N.current?.abort();break}if(e.type===`server_shutdown`){o=!0,h(e=>{let t=[...e];return t[0]?.role===`maxy`&&(t[0]={...t[0],events:[...t[0].events??[],{type:`text`,content:`Server is restarting — reconnect will happen automatically.`}]}),t});continue}if(e.type===`done`||e.type===`session_init`)continue;let t=e;h(e=>{let n=[...e];return n[0]?.role===`maxy`&&(n[0]={...n[0],events:[...n[0].events??[],t]}),n})}o&&St()}catch(e){if(!(e instanceof DOMException&&e.name===`AbortError`)){console.error(`[chat] admin sendMessage failed:`,e);let t=e instanceof Error?e.message:String(e),n=xt(e);h(e=>{let r=[...e],i=r[0];if(i?.role===`maxy`){let e=n?`Server is restarting — reconnect will happen automatically.`:`Error: ${t}`;r[0]={...i,events:[...i.events??[],{type:`text`,content:e}]}}else r.push({role:`maxy`,events:[{type:`text`,content:`Error: ${t}`}],timestamp:Date.now()});return r}),n&&St()}}finally{o(h),b(!1),O.current?(O.current=!1,ae()):p.current?.focus()}}function ae(){h([]),D(!1),s(),F(new Set),u(l.current),I([]),_(``),re(),f(),M(!1),A(e=>e+1)}async function oe(){if(y||w||!t){console.warn(`[chat] startNewConversation blocked: streaming=${y} compacting=${w} sessionKey=${!!t}`);return}ae();try{let e=await fetch(`/api/admin/sessions/new?session_key=${encodeURIComponent(t)}`,{method:`POST`});if(e.ok){let t=await e.json();t.session_key&&n(t.session_key),t.conversationId&&i(t.conversationId)}else console.error(`[chat] new conversation failed: ${e.status}`),h([{role:`maxy`,events:[{type:`text`,content:`Could not start a new conversation. Please try again.`}],timestamp:Date.now()}])}catch(e){console.error(`[chat] new conversation failed:`,e),h([{role:`maxy`,events:[{type:`text`,content:`Could not start a new conversation. Please try again.`}],timestamp:Date.now()}])}}function se(e,n,r,i){try{let e=JSON.parse(r);if(e._lifecycle&&t){fetch(`/api/admin/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:r,session_key:t})}).catch(()=>{});return}if(e.action===`save`)return}catch{}pt.has(i??``)||F(t=>new Set(t).add(`${e}_${n}`)),le(i?JSON.stringify({_componentDone:!0,component:i,payload:r}):r,void 0,void 0,!0)}let ce=(0,B.useMemo)(()=>{let e=new Set(ee),t=[];for(let e=0;e<m.length;e++){let n=m[e];if(!(n.role!==`maxy`||!n.events))for(let e=0;e<n.events.length;e++){let r=n.events[e];r.type===`component`&&r.name===`browser-viewer`&&t.push({key:`${n.timestamp}_${e}`})}}for(let n=0;n<t.length-1;n++)e.add(t[n].key);return e},[m,ee]);async function le(e,i,s,l,u){if(!e&&(i??d()).length===0&&!j||y||!t)return;if(te.offer.active&&!u){let t=te.dismissAndGetHeldMessage();if(t)return I([...C.current,{text:e,files:i??[],timestamp:s??Date.now()}]),le(t,void 0,void 0,!0,{topicChangeAction:`continue`,heldMessage:t})}let g=j;M(!1),D(!1);let v=i??[...d()],x=v.map(e=>({attachmentId:``,filename:e.name,mimeType:e.type})),S={role:`admin`,content:e,attachments:x.length>0?x:void 0,timestamp:s??Date.now(),hidden:l||void 0},w=m.length;h(e=>[...e,S]),_(``),re(),i||f(),a(g?c.current:0),b(!0);let T=new AbortController;N.current=T;let E={role:`maxy`,events:[],timestamp:Date.now()};h(e=>[...e,E]);let k=w+1;try{let i,a={},o=s?new Date(s).toISOString():void 0;if(v.length>0){let n=new FormData;n.append(`message`,e),n.append(`session_key`,t),o&&n.append(`timestamp`,o);for(let e of v)n.append(`attachments`,e);i=n}else i=JSON.stringify({message:e,session_key:t,...o&&{timestamp:o},...u&&{topicChangeAction:u.topicChangeAction,heldMessage:u.heldMessage}}),a={"Content-Type":`application/json`};let c=await fetch(`/api/admin/chat`,{method:`POST`,headers:a,body:i,signal:T.signal});if(!c.ok){if(c.status===401){(await c.json().catch(()=>({}))).error===`auth_expired`?r(`connect-claude`):(n(null),r(`enter-pin`));return}let e=await c.json().catch(()=>({}));throw Error(typeof e.error==`string`?e.error:`Request failed (${c.status})`)}let l=!1;for await(let e of ne(c)){if(e.type===`session_reset`){O.current=!0;continue}if(e.type===`topic_change_offer`){te.handleOfferEvent(e.heldMessage,e.existingTopic,e.confidence);continue}if(e.type===`server_shutdown`){l=!0,h(e=>{let t=[...e],n=t[k];return n&&n.role===`maxy`&&(t[k]={...n,events:[...n.events??[],{type:`text`,content:`Server is restarting — reconnect will happen automatically.`}]}),t});continue}if(e.type===`done`||e.type===`session_init`)continue;let t=e;h(e=>{let n=[...e],r=n[k];if(r&&r.role===`maxy`){let i=r.events??[];if(t.type===`component`&&i.some(e=>e.type===`component`&&e.name===t.name&&JSON.stringify(e.data)===JSON.stringify(t.data)))return e;n[k]={...r,events:[...i,t]}}return n})}l&&St()}catch(e){if(!(e instanceof DOMException&&e.name===`AbortError`)){console.error(`[chat] admin sendMessage failed:`,e);let t=e instanceof Error?e.message:String(e),n=xt(e);h(e=>{let r=[...e],i=r[k];if(i&&i.role===`maxy`){let e=n?`Server is restarting — reconnect will happen automatically.`:`Error: ${t}`;r[k]={...i,events:[...i.events??[],{type:`text`,content:e}]}}return r}),n&&St()}}finally{if(o(h),b(!1),O.current)O.current=!1,ae();else{let e=C.current;if(e.length>0){let[t,...n]=e;I(n),P.current(t.text,t.files,t.timestamp)}else p.current?.focus()}}}P.current=le;let ue=(0,B.useCallback)(async()=>{if(!(!t||y||w)){T(!0);try{let e=await fetch(`/api/admin/compact`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:t})});for await(let t of ne(e))if(t.type===`status`&&t.message){let e=t.message;h(t=>{let n=[...t],r=n[n.length-1];return r?.role===`maxy`&&(n[n.length-1]={...r,events:[...r.events??[],{type:`status`,message:e}]}),n})}else t.type===`done`&&t.ok&&D(!0)}finally{T(!1)}}},[t,y,w]);async function de(){let e=te.consumeOffer(`fresh`);e&&(await oe(),P.current(e.heldMessage))}function fe(){let e=te.consumeOffer(`continue`);e&&le(e.heldMessage,void 0,void 0,!0,{topicChangeAction:`continue`,heldMessage:e.heldMessage})}return{messages:m,setMessages:h,input:g,setInput:_,isStreaming:y,messageQueue:x,messageQueueRef:C,setQueue:I,isCompacting:w,conversationCompacted:E,greetingGeneration:k,wasPaused:j,sendMessageRef:P,submittedComponents:ee,effectiveSubmitted:ce,stopStreaming:ie,sendSystemPrompt:L,sendMessage:le,resetConversation:ae,startNewConversation:oe,handleComponentSubmit:se,handleCompactNow:ue,topicChangeOffer:te.offer,handleTopicFreshStart:de,handleTopicContinue:fe}}function wt(){let[e,t]=(0,B.useState)([]),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(null),o=(0,B.useRef)(null),s=(0,B.useCallback)(e=>{a(null);let n=e.find(e=>!dt.has(e.type));if(n){a(`Unsupported file type: "${n.type}". Supported: images, PDF, plain text, markdown, CSV, calendar.`);return}let r=e.find(e=>e.size>ft);if(r){a(`"${r.name}" exceeds the 20 MB limit.`);return}t(t=>[...t,...e].slice(0,5))},[]);return{pendingFiles:e,setPendingFiles:t,isDragOver:n,attachError:i,setAttachError:a,fileInputRef:o,addFiles:s,clearFiles:(0,B.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,B.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,B.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,B.useCallback)(()=>{r(!1)},[]),onDrop:(0,B.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var V=s();function Tt({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,B.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,V.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,V.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function Et(e){let{pin:t,setPin:n,confirmPin:r,setConfirmPin:i,showPin:a,setShowPin:o,pinLoading:s,pinError:c,pinInputRef:l,confirmPinInputRef:u,setPinFormRef:d,onSubmit:f}=e;return(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,v.productName]}),(0,V.jsx)(`p`,{className:`connect-subtitle`,children:`Choose a PIN to secure your admin access.`}),(0,V.jsxs)(`form`,{ref:d,onSubmit:f,className:`connect-pin-form`,children:[(0,V.jsxs)(`div`,{className:`pin-input-row`,children:[(0,V.jsx)(Tt,{inputRef:l,value:t,onChange:n,onComplete:()=>u.current?.focus(),showPin:a,autoFocus:!0}),(0,V.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,V.jsxs)(`div`,{className:`pin-input-row`,children:[(0,V.jsx)(Tt,{inputRef:u,value:r,onChange:i,onComplete:()=>{},showPin:a}),(0,V.jsx)(T,{variant:`send`,type:`submit`,disabled:!t||!r,loading:s,"aria-label":`Set PIN`,children:(0,V.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,V.jsx)(w,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})]}),c&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function Dt(e){let{pin:t,setPin:n,showPin:r,setShowPin:i,pinLoading:a,pinError:o,pinInputRef:s,onSubmit:c,onChangePin:l}=e;return(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsx)(`h1`,{className:`connect-title`,children:v.productName}),(0,V.jsxs)(`form`,{onSubmit:c,className:`connect-pin-form`,children:[(0,V.jsxs)(`div`,{className:`pin-input-row`,children:[(0,V.jsx)(Tt,{inputRef:s,value:t,onChange:n,onComplete:()=>{},showPin:r,autoFocus:!0}),(0,V.jsx)(T,{variant:`send`,type:`submit`,disabled:!t,loading:a,children:(0,V.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,V.jsxs)(`div`,{className:`pin-options`,children:[(0,V.jsx)(w,{checked:r,onChange:()=>i(e=>!e),label:`Show PIN`}),(0,V.jsx)(T,{type:`button`,variant:`ghost`,onClick:l,children:`Change PIN`})]})]}),o&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:o})]})})}function Ot(e){let{accounts:t,loading:n,error:r,onSelect:i}=e;return(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsx)(`h1`,{className:`connect-title`,children:v.productName}),(0,V.jsx)(`p`,{className:`connect-subtitle`,children:`Select an account`}),(0,V.jsx)(`div`,{className:`account-picker-list`,children:t.map(e=>(0,V.jsxs)(`button`,{className:`account-picker-card`,onClick:()=>i(e.accountId),disabled:n,type:`button`,children:[(0,V.jsx)(`span`,{className:`account-picker-name`,children:e.businessName||e.accountId}),(0,V.jsx)(`span`,{className:`account-picker-role`,children:e.role}),n&&(0,V.jsx)(ie,{className:`account-picker-spinner`,size:16})]},e.accountId))}),r&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:r})]})})}function kt(e){let{authPolling:t,setAuthPolling:n,authLoading:r,setAuthLoading:i,pinError:a,setPinError:o,setAppState:s}=e,[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1);async function f(){d(!0),o(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?l(!0):e.error&&o(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),o(`Could not launch browser.`)}d(!1)}async function p(){i(!0),o(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),l(!0),i(!1);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),s(`enter-pin`);return}o(`Timed out waiting for sign-in. Try again.`),n(!1)}else e.error&&o(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),o(`Could not start auth flow.`)}i(!1)}async function m(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),o(``)}return t||c?(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,V.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,V.jsx)(`button`,{onClick:m,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,V.jsx)(`button`,{onClick:()=>l(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,V.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,V.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,V.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,V.jsx)(`div`,{style:{marginTop:`12px`},children:(0,V.jsx)(T,{variant:`primary`,onClick:p,disabled:r,children:r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})})]}),(0,V.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,V.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),a&&(0,V.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:a})]}):(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsxs)(`div`,{className:`connect-logos`,children:[(0,V.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,V.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,V.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,V.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,V.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsx)(`span`,{className:`connect-logo-label`,children:v.productName})]})]}),(0,V.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,v.productName]}),(0,V.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,V.jsx)(T,{variant:`primary`,onClick:p,disabled:r,children:r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,V.jsx)(`button`,{onClick:f,disabled:u,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:u?`Launching…`:`Open browser first`}),(0,V.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),a&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:a})]})})}function At({setAppState:e,setOnboardingComplete:t}){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(``);async function o(){r(!0),a(``);try{let n=await fetch(`/api/onboarding/skip`,{method:`POST`});if(!n.ok){a((await n.json().catch(()=>({}))).error||`Failed to apply defaults.`);return}t(!0),e(`connect-claude`)}catch(e){console.error(`[admin] skip onboarding error:`,e),a(`Could not apply defaults.`)}finally{r(!1)}}function s(){e(`connect-claude`)}return(0,V.jsx)(`div`,{className:`connect-page`,children:(0,V.jsxs)(`div`,{className:`connect-content`,children:[(0,V.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,V.jsx)(`img`,{src:b,alt:v.productName,className:`connect-logo connect-logo--maxy`}),!v.logoContainsName&&(0,V.jsx)(`span`,{className:`connect-logo-label`,children:v.productName})]}),(0,V.jsx)(`h1`,{className:`connect-title`,children:`How would you like to get started?`}),(0,V.jsx)(`p`,{className:`connect-subtitle`,style:{fontSize:`0.8rem`,maxWidth:`320px`},children:`Defaults: core plugins only, auto-detected timezone, concise output style, and a minimal personality. No WiFi or optional plugins.`}),(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`10px`,width:`100%`,maxWidth:`320px`,alignItems:`center`},children:[(0,V.jsx)(T,{variant:`primary`,onClick:o,disabled:n,children:n?`Applying defaults…`:`Use defaults`}),(0,V.jsx)(`button`,{onClick:s,style:{background:`none`,border:`none`,padding:`8px`,cursor:`pointer`,fontSize:`0.95rem`,color:`var(--text-secondary, #666)`,textDecoration:`none`},children:`Guided setup`})]}),(0,V.jsx)(`p`,{className:`connect-subtitle`,style:{marginTop:`12px`},children:`You can change any setting later through conversation.`}),i&&(0,V.jsx)(`p`,{className:`admin-pin-error`,children:i})]})})}function jt({data:e,onSubmit:t,submitted:n}){let r=e,[i,a]=(0,B.useState)(`Submitted`);return r?.title?(0,V.jsx)(k,{submitted:n,submittedLabel:i,actions:[{label:r.rejectLabel??`Reject`,variant:`ghost`,onClick:()=>{n||(a(`Rejected`),t(r.rejectMessage??`Rejected: ${r.title}`))}},{label:r.confirmLabel??`Approve`,variant:`primary`,onClick:()=>{n||(a(`Approved`),t(r.confirmMessage??`Approved: ${r.title}`))}}],children:(0,V.jsxs)(`div`,{className:`confirm`,children:[(0,V.jsx)(`div`,{className:`confirm__title`,children:r.title}),r.description&&(0,V.jsx)(`div`,{className:`confirm__desc`,children:r.description}),r.items&&r.items.length>0&&(0,V.jsx)(`div`,{className:`confirm__items`,children:r.items.map((e,t)=>(0,V.jsxs)(`div`,{className:`confirm__item`,children:[(0,V.jsx)(`span`,{className:`confirm__item-label`,children:e.label}),(0,V.jsx)(`span`,{className:`confirm__item-value`,children:e.value})]},t))})]})}):null}function Mt({data:e,onSubmit:t,submitted:n}){let r=e,i=(0,B.useRef)(!1),a=!!(r?.title&&Array.isArray(r?.fields)&&r.fields.length>0),o=r?.actions&&r.actions.length>0;return(0,B.useEffect)(()=>{a&&!o&&!n&&!i.current&&(i.current=!0,t(``))},[a,o,n,t]),a?(0,V.jsx)(k,{submitted:n,submittedLabel:`Done`,actions:o?r.actions.map(e=>({label:e.label,variant:e.variant,onClick:()=>{n||t(e.message)}})):[],children:(0,V.jsxs)(`div`,{className:`info-card`,children:[(0,V.jsxs)(`div`,{className:`info-card__header`,children:[(0,V.jsx)(`div`,{className:`info-card__title`,children:r.title}),r.subtitle&&(0,V.jsx)(`div`,{className:`info-card__subtitle`,children:r.subtitle})]}),(0,V.jsx)(`div`,{className:`info-card__fields`,children:r.fields.map((e,t)=>(0,V.jsxs)(`div`,{className:`info-card__field`,children:[(0,V.jsx)(`span`,{className:`info-card__field-label`,children:e.label}),(0,V.jsx)(`span`,{className:`info-card__field-value${e.type===`status`?` info-card__field-value--status`:``}`,children:e.type===`link`?(0,V.jsx)(`a`,{href:e.value,target:`_blank`,rel:`noopener noreferrer`,children:e.value}):e.value})]},t))})]})}):null}function Nt({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.items)?r.items:[],[a,o]=(0,B.useState)(new Set),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(`Done`);if(i.length===0)return null;let d=n||s,f=(e,n)=>{d||a.has(e)||(o(t=>new Set(t).add(e)),t(n))};return(0,V.jsx)(k,{submitted:d,submittedLabel:l,actions:[{label:`Done`,variant:`primary`,onClick:()=>{d||(c(!0),u(`Done`),t(r?.doneMessage??`Done`))}}],children:(0,V.jsxs)(`div`,{className:`action-list`,children:[r?.title&&(0,V.jsx)(`div`,{className:`action-list__title`,children:r.title}),(0,V.jsx)(`div`,{className:`action-list__items`,children:i.map(e=>(0,V.jsxs)(`div`,{className:`action-list__item${a.has(e.id)?` action-list__item--acted`:``}`,children:[(0,V.jsxs)(`div`,{className:`action-list__item-info`,children:[(0,V.jsx)(`span`,{className:`action-list__item-label`,children:e.label}),e.description&&(0,V.jsx)(`span`,{className:`action-list__item-desc`,children:e.description})]}),(0,V.jsxs)(`div`,{className:`action-list__item-right`,children:[e.status&&(0,V.jsx)(`span`,{className:`action-list__item-status`,children:e.status}),(0,V.jsx)(`div`,{className:`action-list__item-actions`,children:e.actions.map((t,n)=>(0,V.jsx)(T,{variant:t.variant===`danger`?`danger`:t.variant===`ghost`?`ghost`:`primary`,size:`sm`,disabled:d||a.has(e.id),onClick:n=>{n.stopPropagation(),f(e.id,t.message)},children:t.label},n))})]})]},e.id))})]})})}function Pt({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.fields)?r.fields:[],[a,o]=(0,B.useState)({}),[s,c]=(0,B.useState)({}),[l,u]=(0,B.useState)({}),[d,f]=(0,B.useState)(`Submitted`);if((0,B.useEffect)(()=>{i.length!==0&&(o(e=>{let t={...e};return i.forEach(e=>{e.type!==`list`&&(e.name in t||(t[e.name]=e.defaultValue??(e.type===`checkbox`?!1:``)))}),t}),c(e=>{let t={...e};return i.forEach(e=>{e.type===`list`&&(e.name in t||(t[e.name]=Array.isArray(e.defaultValue)?e.defaultValue:[]))}),t}))},[i]),i.length===0)return null;let p=(e,t)=>{n||o(n=>({...n,[e]:t}))},m=i.filter(e=>e.required&&e.type!==`list`).every(e=>{let t=a[e.name];return e.type===`checkbox`?t===!0:typeof t==`string`&&t.trim()!==``}),h=()=>{if(!m||n)return;f(`Submitted`);let e=r?.submitMessage??`Form submitted: {{json}}`,i=JSON.stringify(a),o=e;for(let[e,t]of Object.entries(a))o=o.replace(`{{${e}}}`,()=>String(t));o=o.replace(`{{json}}`,()=>i),o=o.replace(`{{values}}`,()=>i),t(o)},g=e=>e.description?`${e.label} — ${e.description}`:e.label,_=e=>{let r=(l[e.name]??``).trim();!r||n||(c(t=>({...t,[e.name]:[...t[e.name]??[],r]})),u(t=>({...t,[e.name]:``})),e.addMessage&&t(e.addMessage.replace(`{{value}}`,r)))},v=(e,r)=>{n||(c(t=>({...t,[e.name]:(t[e.name]??[]).filter(e=>e!==r)})),e.removeMessage&&t(e.removeMessage.replace(`{{value}}`,r)))};return(0,V.jsx)(k,{submitted:n,submittedLabel:d,actions:[{label:r?.submitLabel??`Submit`,variant:`primary`,disabled:!m,onClick:h}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[r?.title&&(0,V.jsx)(`div`,{className:`form-input__title`,children:r.title}),r?.description&&(0,V.jsx)(`div`,{className:`form-input__desc`,children:r.description}),(0,V.jsx)(`div`,{className:`form-input__fields`,children:i.map(e=>(0,V.jsx)(`div`,{className:`form-input__field`,children:e.type===`checkbox`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(w,{checked:a[e.name]===!0,onChange:t=>p(e.name,t),label:e.label,disabled:n}),e.description&&(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:e.description})]}):e.type===`list`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`label`,{className:`form-input__label`,children:e.label}),e.description&&(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:e.description}),(0,V.jsxs)(`div`,{className:`form-input__list`,children:[(s[e.name]??[]).map(t=>(0,V.jsxs)(`div`,{className:`form-input__list-item`,children:[(0,V.jsx)(`span`,{className:`form-input__list-item-text`,children:t}),(0,V.jsx)(`button`,{type:`button`,className:`form-input__list-item-remove`,onClick:()=>v(e,t),disabled:n,"aria-label":`Remove ${t}`,children:`×`})]},t)),(0,V.jsxs)(`div`,{className:`form-input__list-add`,children:[(0,V.jsx)(`input`,{className:`form-input__input`,type:`text`,placeholder:e.addPlaceholder??``,value:l[e.name]??``,onChange:t=>u(n=>({...n,[e.name]:t.target.value})),onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),_(e))},disabled:n}),(0,V.jsx)(`button`,{type:`button`,className:`form-input__list-add-btn`,onClick:()=>_(e),disabled:n||!(l[e.name]??``).trim(),children:`Add`})]})]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`form-${e.name}`,children:[e.label,e.required&&(0,V.jsx)(`span`,{className:`form-input__required`,children:`*`})]}),e.description&&(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:e.description}),e.type===`textarea`?(0,V.jsx)(`textarea`,{id:`form-${e.name}`,className:`form-input__textarea`,placeholder:e.placeholder,value:a[e.name]??``,onChange:t=>p(e.name,t.target.value),disabled:n,rows:3}):e.type===`select`?(0,V.jsxs)(`select`,{id:`form-${e.name}`,className:`form-input__select`,value:a[e.name]??``,onChange:t=>p(e.name,t.target.value),disabled:n,children:[(0,V.jsx)(`option`,{value:``,children:e.placeholder??`Select...`}),e.options?.map(e=>(0,V.jsx)(`option`,{value:e.value,children:g(e)},e.value))]}):(0,V.jsx)(`input`,{id:`form-${e.name}`,className:`form-input__input`,type:e.type,placeholder:e.placeholder,value:a[e.name]??``,onChange:t=>p(e.name,t.target.value),disabled:n})]})},e.name))})]})})}var Ft={pending:`○`,active:`◉`,completed:`✓`,failed:`✗`,skipped:`–`};function It({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.steps)?r.steps:[],a=(0,B.useRef)(!1),o=i.length>0&&i.every(e=>e.status===`completed`||e.status===`failed`||e.status===`skipped`);return(0,B.useEffect)(()=>{o&&!n&&!a.current&&(a.current=!0,t(r?.completedMessage??`All steps completed`))},[o,n,t,r?.completedMessage]),i.length===0?null:(0,V.jsxs)(`div`,{className:`progress-tracker${n?` progress-tracker--submitted`:``}`,children:[r?.title&&(0,V.jsx)(`div`,{className:`progress-tracker__title`,children:r.title}),(0,V.jsx)(`div`,{className:`progress-tracker__steps`,children:i.map((e,t)=>(0,V.jsxs)(`div`,{className:`progress-tracker__step progress-tracker__step--${e.status}`,children:[(0,V.jsx)(`span`,{className:`progress-tracker__icon`,children:Ft[e.status]??`○`}),(0,V.jsxs)(`div`,{className:`progress-tracker__step-info`,children:[(0,V.jsx)(`span`,{className:`progress-tracker__step-label`,children:e.label}),e.description&&(0,V.jsx)(`span`,{className:`progress-tracker__step-desc`,children:e.description})]})]},t))})]})}function Lt({handlePopout:e,disabled:t=!1}){let n=(0,B.useCallback)(()=>{delete document.body.dataset.dragPopoutActive},[]);(0,B.useEffect)(()=>()=>n(),[n]);let r=(0,B.useCallback)(e=>{if(t){e.preventDefault();return}let n=e.target;if(n.closest(`.editor-base__actions`)||n.closest(`.browser-viewer__actions`)){e.preventDefault();return}if(!document.querySelector(`.chat-messages`)){e.preventDefault();return}e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,``),document.body.dataset.dragPopoutActive=`true`},[t,n]),i=(0,B.useCallback)(t=>{if(n(),t.clientX===0&&t.clientY===0)return;let r=document.querySelector(`.chat-messages`);if(!r)return;let i=r.getBoundingClientRect();(t.clientX<i.left||t.clientX>i.right||t.clientY<i.top||t.clientY>i.bottom)&&e()},[e,n]);return t?{draggable:!1,onDragStart:()=>{},onDragEnd:()=>{}}:{draggable:!0,onDragStart:r,onDragEnd:i}}function Rt({data:e,onSubmit:t,submitted:n,isStreaming:r}){ot();let{title:i}=e??{},[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),d=(0,B.useRef)(null),f=(0,B.useRef)(null),p=i??v.productName,m=(0,B.useCallback)(()=>{f.current&&=(clearInterval(f.current),null),d.current&&!d.current.closed&&d.current.close(),d.current=null,c(!1)},[]),h=(0,B.useCallback)(()=>{o(!1),u(!1);let e=`/vnc-popout.html?title=${encodeURIComponent(p)}`,t=window.open(e,`maxy-vnc-popout`,`width=1024,height=768`);t&&(d.current=t,c(!0),f.current=setInterval(()=>{d.current?.closed&&(m(),u(!0))},500))},[p,m]),g=(0,B.useCallback)(()=>{m(),o(!1),u(!0)},[m]),_=(0,B.useCallback)(()=>{m(),u(!1)},[m]),y=(0,B.useCallback)(()=>{u(!1)},[]),b=(0,B.useCallback)(()=>{m(),u(!1),o(!0)},[m]),x=(0,B.useCallback)(()=>o(!1),[]);(0,B.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&x()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,x]),(0,B.useEffect)(()=>()=>m(),[m]);let S=Lt({handlePopout:h,disabled:s||a});if(n)return null;let C=`/vnc-viewer.html`;return a?(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...S,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:p}),(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:h,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:We,onClick:x,"aria-label":`Exit full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ge,onClick:g,"aria-label":`Minimise`})]})]}),(0,V.jsx)(`iframe`,{src:C,className:`browser-viewer-fullscreen__iframe`,title:p})]}):s?(0,V.jsx)(`div`,{className:`browser-viewer browser-viewer--popout`,children:(0,V.jsxs)(`div`,{className:`browser-viewer__bar`,...S,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer__title`,children:p}),(0,V.jsxs)(`div`,{className:`browser-viewer__actions`,children:[(0,V.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ze,onClick:_,"aria-label":`Pop back in`})]})]})}):l?(0,V.jsxs)(`div`,{className:`browser-viewer browser-viewer--minimised`,onClick:y,role:`button`,tabIndex:0,onKeyDown:e=>e.key===`Enter`&&y(),children:[(0,V.jsxs)(`div`,{className:`browser-viewer__bar`,...S,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer__title`,children:p}),(0,V.jsxs)(`div`,{className:`browser-viewer__actions`,onClick:e=>e.stopPropagation(),children:[(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:h,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ve,onClick:b,"aria-label":`Full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Je,onClick:y,"aria-label":`Expand`})]})]}),(0,V.jsx)(`iframe`,{src:C,className:`browser-viewer__iframe`,title:p,"aria-hidden":`true`})]}):(0,V.jsxs)(`div`,{className:`browser-viewer`,children:[(0,V.jsxs)(`div`,{className:`browser-viewer__bar`,...S,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),i&&(0,V.jsx)(`span`,{className:`browser-viewer__title`,children:i}),(0,V.jsxs)(`div`,{className:`browser-viewer__actions`,children:[(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:h,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ve,onClick:b,"aria-label":`Full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ge,onClick:g,"aria-label":`Minimise`})]})]}),(0,V.jsx)(`iframe`,{src:C,className:`browser-viewer__iframe`,title:p})]})}var zt=t((e=>{var t=a();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),a=r[0].inst,l=r[1];return s(function(){a.value=n,a.getSnapshot=t,u(a)&&l({inst:a})},[e,n,t]),o(function(){return u(a)&&l({inst:a}),e(function(){u(a)&&l({inst:a})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Bt=t(((e,t)=>{t.exports=zt()})),Vt=Bt(),Ht=e(n(),1);function Ut(e){this.content=e}Ut.prototype={constructor:Ut,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new Ut(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new Ut(n)},addToStart:function(e,t){return new Ut([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Ut(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new Ut(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=Ut.from(e),e.size?new Ut(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=Ut.from(e),e.size?new Ut(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Ut.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},Ut.from=function(e){if(e instanceof Ut)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Ut(t)};function Wt(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=Wt(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Gt(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=Gt(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var H=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Wt(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Gt(this,e,t,n)}findIndex(e){if(e==0)return qt(0,e);if(e==this.size)return qt(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?qt(t+1,i):qt(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};H.empty=new H([],0);var Kt={index:0,offset:0};function qt(e,t){return Kt.index=e,Kt.offset=t,Kt}function Jt(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Jt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Jt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var U=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Jt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};U.none=[];var Yt=class extends Error{},W=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Zt(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Xt(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(H.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};W.empty=new W(H.empty,0,0);function Xt(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Xt(a.content,t-i-1,n-i-1)))}function Zt(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=Zt(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function Qt(e,t,n){if(n.openStart>e.depth)throw new Yt(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Yt(`Inconsistent open depths`);return $t(e,t,n,0)}function $t(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=$t(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return an(a,sn(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return an(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=cn(n,e);return an(a,on(e,i,o,t,r))}}function en(e,t){if(!t.type.compatibleContent(e.type))throw new Yt(`Cannot join `+t.type.name+` onto `+e.type.name)}function tn(e,t,n){let r=e.node(n);return en(r,t.node(n)),r}function nn(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function rn(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(nn(e.nodeAfter,r),a++));for(let e=a;e<o;e++)nn(i.child(e),r);t&&t.depth==n&&t.textOffset&&nn(t.nodeBefore,r)}function an(e,t){return e.type.checkContent(t),e.copy(t)}function on(e,t,n,r,i){let a=e.depth>i&&tn(e,t,i+1),o=r.depth>i&&tn(n,r,i+1),s=[];return rn(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(en(a,o),nn(an(a,on(e,t,n,r,i+1)),s)):(a&&nn(an(a,sn(e,t,i+1)),s),rn(t,n,i,s),o&&nn(an(o,sn(n,r,i+1)),s)),rn(r,null,i,s),new H(s)}function sn(e,t,n){let r=[];return rn(null,e,n,r),e.depth>n&&nn(an(tn(e,t,n+1),sn(e,t,n+1)),r),rn(t,null,n,r),new H(r)}function cn(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(H.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var ln=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return U.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new pn(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=fn.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else fn.set(t,r=new un);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%dn,i}},un=class{constructor(){this.elts=[],this.i=0}},dn=12,fn=new WeakMap,pn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},mn=Object.create(null),hn=class e{constructor(e,t,n,r=U.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||H.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Jt(this.attrs,t||e.defaultAttrs||mn)&&U.sameSet(this.marks,n||U.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return W.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new W(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Qt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return ln.resolveCached(this,e)}resolveNoCache(e){return ln.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),_n(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=H.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=U.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!U.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=H.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};hn.prototype.text=void 0;var gn=class e extends hn{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):_n(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function _n(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var vn=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new yn(t,n);if(r.next==null)return e.empty;let i=bn(r);r.next&&r.err(`Unexpected trailing text`);let a=An(Dn(i));return jn(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return H.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
2
2
|
`)}};vn.empty=new vn(!0);var yn=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function bn(e){let t=[];do t.push(xn(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function xn(e){let t=[];do t.push(Sn(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Sn(e){let t=En(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=wn(e,t);else break;return t}function Cn(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function wn(e,t){let n=Cn(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Cn(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Tn(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function En(e){if(e.eat(`(`)){let t=bn(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Tn(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Dn(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function On(e,t){return t-e}function kn(e,t){let n=[];return r(t),n.sort(On);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function An(e){let t=Object.create(null);return n(kn(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);kn(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new vn(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(On);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function jn(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Mn(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Nn(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function Pn(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function Fn(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Rn(e,r,t[r]);return n}var In=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Fn(e,n.attrs),this.defaultAttrs=Mn(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==vn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Nn(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new hn(this,this.computeAttrs(e),H.from(t),U.setFrom(n))}createChecked(e=null,t,n){return t=H.from(t),this.checkContent(t),new hn(this,this.computeAttrs(e),t,U.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=H.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(H.empty,!0);return i?new hn(this,e,t.append(i),U.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Pn(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:U.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Ln(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Rn=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Ln(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},zn=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Fn(e,r.attrs),this.excluded=null;let i=Mn(this.attrs);this.instance=i?new U(this,i):null}create(e=null){return!e&&this.instance?this.instance:new U(this,Nn(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Pn(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Bn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=Ut.from(e.nodes),t.marks=Ut.from(e.marks||{}),this.nodes=In.compile(this.spec.nodes,this),this.marks=zn.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=vn.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Vn(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Vn(this,n.split(` `))}this.nodeFromJSON=e=>hn.fromJSON(this,e),this.markFromJSON=e=>U.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof In))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new gn(n,n.defaultAttrs,e,U.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function Vn(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Hn(e){return e.tag!=null}function Un(e){return e.style!=null}var Wn=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Hn(e))this.tags.push(e);else if(Un(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new $n(this,t,!1);return n.addAll(e,U.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new $n(this,t,!0);return n.addAll(e,U.none,t.from,t.to),W.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(tr(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=nr(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=nr(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Gn={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Kn={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qn={ol:!0,ul:!0},Jn=1,Yn=2,Xn=4;function Zn(e,t,n){return t==null?e&&e.whitespace==`pre`?Jn|Yn:n&~Xn:(t?Jn:0)|(t===`full`?Yn:0)}var Qn=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=U.none,this.match=i||(a&Xn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(H.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Jn)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=H.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(H.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Gn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},$n=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Zn(null,t.preserveWhitespace,0)|(n?Xn:0);i=r?new Qn(r.type,r.attrs,U.none,!0,t.topMatch||r.type.contentMatch,a):n?new Qn(null,null,U.none,!0,null,a):new Qn(e.schema.topNodeType,null,U.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Yn?`full`:this.localPreserveWS||(r.options&Jn)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
3
3
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;qn.hasOwnProperty(a)&&this.parser.normalizeLists&&er(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:Kn.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Gn.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
4
|
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=U.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):rr(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=Zn(e,i,a.options);a.options&Xn&&a.content.length==0&&(o|=Xn);let s=U.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):rr(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new Qn(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Jn);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(r?0:1),a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function er(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&qn.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function tr(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function nr(e){let t={};for(let n in e)t[n]=e[n];return t}function rr(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var ir=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=or(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=ur(or(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&ur(or(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return ur(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=ar(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return ar(e.marks)}};function ar(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function or(e){return e.document||window.document}var sr=new WeakMap;function cr(e){let t=sr.get(e);return t===void 0&&sr.set(e,t=lr(e)),t}function lr(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function ur(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=cr(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=ur(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var dr=65535,fr=2**16;function pr(e,t){return e+t*fr}function mr(e){return e&dr}function hr(e){return(e-(e&dr))/fr}var gr=1,_r=2,vr=4,yr=8,br=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&yr)>0}get deletedBefore(){return(this.delInfo&(gr|vr))>0}get deletedAfter(){return(this.delInfo&(_r|vr))>0}get deletedAcross(){return(this.delInfo&vr)>0}},xr=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=mr(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+hr(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:pr(o/3,e-s),f=e==s?_r:e==u?gr:vr;return(t<0?e!=s:e!=u)&&(f|=yr),new br(a,f,d)}r+=l-c}return n?e+r:new br(e+r,0,null)}touches(e,t){let n=0,r=mr(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};xr.empty=new xr([]);var Sr=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new br(e,r,null)}},Cr=Object.create(null),wr=class{getMap(){return xr.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Cr[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Cr)throw RangeError(`Duplicate use of step JSON ID `+e);return Cr[e]=t,t.prototype.jsonID=e,t}},Tr=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Yt)return e.fail(t.message);throw t}}};function Er(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Er(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return H.fromArray(r)}var Dr=class e extends wr{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new W(Er(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return Tr.fromReplace(e,this.from,this.to,i)}invert(){return new Or(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};wr.jsonID(`addMark`,Dr);var Or=class e extends wr{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new W(Er(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Tr.fromReplace(e,this.from,this.to,n)}invert(){return new Dr(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};wr.jsonID(`removeMark`,Or);var kr=class e extends wr{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Tr.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Tr.fromReplace(e,this.pos,this.pos+1,new W(H.from(n),0,t.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Ar(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};wr.jsonID(`addNodeMark`,kr);var Ar=class e extends wr{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Tr.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Tr.fromReplace(e,this.pos,this.pos+1,new W(H.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new kr(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};wr.jsonID(`removeNodeMark`,Ar);var jr=class e extends wr{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Nr(e,this.from,this.to)?Tr.fail(`Structure replace would overwrite content`):Tr.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xr([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?W.empty:new W(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?W.empty:new W(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,W.fromJSON(t,n.slice),!!n.structure)}};wr.jsonID(`replace`,jr);var Mr=class e extends wr{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Nr(e,this.from,this.gapFrom)||Nr(e,this.gapTo,this.to)))return Tr.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Tr.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Tr.fromReplace(e,this.from,this.to,n):Tr.fail(`Content does not fit in gap`)}getMap(){return new xr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,W.fromJSON(t,n.slice),n.insert,!!n.structure)}};wr.jsonID(`replaceAround`,Mr);function Nr(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Pr(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Or(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Dr(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Fr(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof zn){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Or(t.from,t.to,t.style)))}function Ir(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new jr(s,l,W.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Or(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new W(H.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new jr(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(H.empty,!0);e.replace(s,s,new W(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Lr(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Rr(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Lr(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function zr(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=H.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=H.from(r.node(e).copy(u)),d++):c--;let f=H.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=H.from(i.node(e).copy(f)),p++):l++;e.step(new Mr(c,l,o,s,new W(u.append(f),d,p),u.size-d,!0))}function Br(e,t,n=null,r=e){let i=Hr(e,t),a=i&&Ur(r,t);return a?i.map(Vr).concat({type:t,attrs:n}).concat(a.map(Vr)):null}function Vr(e){return{type:e,attrs:null}}function Hr(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function Ur(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function Wr(e,t,n){let r=H.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=H.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Mr(i,a,i,a,new W(r,0,0),n.length,!0))}function Gr(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Jr(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&qr(e,t,n,a),Ir(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Mr(c,l,c+1,l-1,new W(H.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Kr(e,t,n,a),!1}})}function Kr(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function qr(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
@@ -340,16 +340,16 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
340
340
|
border: 1px solid rgba(0,0,0,0.1); }
|
|
341
341
|
td { padding: 6px 10px; border: 1px solid rgba(0,0,0,0.1); }
|
|
342
342
|
`;function rT({data:e,onSubmit:t,submitted:n,isStreaming:r}){let{title:a,columns:o,rows:s,filePath:c,brandName:l,brandLogo:u}=e??{},d=a??`Grid`,[f,p]=(0,B.useState)(o??[`Column 1`]),[m,h]=(0,B.useState)(()=>{let e=s??[[``]];return e.length>0?e:[[``]]}),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(``),b=(0,B.useRef)(null),[x,S]=(0,B.useState)(()=>(o??[`Column 1`]).map(()=>$w)),C=(0,B.useRef)(null),[w,E]=(0,B.useState)(`idle`),D=(0,B.useRef)(null),O=(0,B.useRef)(null),k=(0,B.useRef)(JSON.stringify({columns:o,rows:s}));(0,B.useEffect)(()=>{let e=JSON.stringify({columns:o,rows:s});e!==k.current&&(k.current=e,o&&p(o),s&&(h(s.length>0?s:[[``]]),S(e=>{let t=o?.length??e.length;return t>e.length?[...e,...Array(t-e.length).fill($w)]:e.slice(0,t)})))},[o,s]);let A=(0,B.useCallback)(()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{E(`saving`),t(JSON.stringify({action:`save`,columns:f,rows:m,...c?{filePath:c}:{}})),O.current&&clearTimeout(O.current),E(`saved`),O.current=setTimeout(()=>E(`idle`),2e3)},500)},[f,m,c,t]);(0,B.useEffect)(()=>()=>{D.current&&clearTimeout(D.current),O.current&&clearTimeout(O.current)},[]);let j=kw({title:d,isStreaming:r,channelName:`maxy-grid-editor`,renderPopout:(0,B.useCallback)((e,t)=>{let n=e.document;n.open(),n.close(),n.title=t;let r=n.createElement(`style`);r.textContent=nT,n.head.appendChild(r);let i=n.createElement(`div`);i.className=`title`,i.textContent=t,n.body.appendChild(i);let a=n.createElement(`table`),o=n.createElement(`thead`),s=n.createElement(`tr`);for(let e of f){let t=n.createElement(`th`);t.textContent=e,s.appendChild(t)}o.appendChild(s),a.appendChild(o);let c=n.createElement(`tbody`);for(let e of m){let t=n.createElement(`tr`);for(let r of e){let e=n.createElement(`td`);e.textContent=r,t.appendChild(e)}c.appendChild(t)}a.appendChild(c),n.body.appendChild(a)},[f,m])}),M=Aw({onSubmit:t}),N=(0,B.useCallback)((e,t)=>{_({row:e,col:t}),y(m[e]?.[t]??``),setTimeout(()=>b.current?.focus(),0)},[m]),P=(0,B.useCallback)(()=>{if(!g)return;let{row:e,col:t}=g;h(n=>{let r=n.map(e=>[...e]);return r[e]&&(r[e][t]=v),r}),_(null),A()},[g,v,A]),ee=(0,B.useCallback)(()=>{_(null)},[]),F=(0,B.useCallback)(e=>{if(g)if(e.key===`Tab`){e.preventDefault(),P();let{row:t,col:n}=g,r=n+1;if(r<f.length)N(t,r);else{let e=t+1;e>=m.length&&h(e=>[...e,Array(f.length).fill(``)]),N(Math.min(e,m.length),0)}}else if(e.key===`Enter`){e.preventDefault(),P();let{row:t,col:n}=g,r=t+1;r>=m.length&&h(e=>[...e,Array(f.length).fill(``)]),N(Math.min(r,m.length),n)}else e.key===`Escape`&&ee()},[g,f.length,m.length,P,N,ee]),te=(0,B.useCallback)(()=>{h(e=>[...e,Array(f.length).fill(``)]),A()},[f.length,A]),I=(0,B.useCallback)(e=>{h(t=>t.length<=1?[Array(f.length).fill(``)]:t.filter((t,n)=>n!==e)),g?.row===e&&_(null),A()},[f.length,g,A]),ne=(0,B.useCallback)(e=>{let t=e.clipboardData.getData(`text/plain`);if(!t||!g)return;let n=t.split(`
|
|
343
|
-
`).filter(e=>e.trim());if(n.length<=1&&!n[0]?.includes(` `)&&!n[0]?.includes(`,`))return;e.preventDefault();let r=n.slice(0,Zw).map(eT);n.length>Zw&&console.warn(`Grid editor: paste truncated from ${n.length} to ${Zw} rows`);let{row:i,col:a}=g;h(e=>{let t=e.map(e=>[...e]);for(let e=0;e<r.length;e++){let n=i+e;for(;n>=t.length;)t.push(Array(f.length).fill(``));for(let i=0;i<r[e].length;i++){let o=a+i;o<f.length&&(t[n][o]=r[e][i])}}return t}),A()},[g,f.length,A]),re=(0,B.useCallback)(()=>{let e=tT(f,m),t=new Blob([e],{type:`text/csv;charset=utf-8;`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${d.replace(/[^a-zA-Z0-9]/g,`_`)}.csv`,r.click(),URL.revokeObjectURL(n)},[f,m,d]),ie=(0,B.useCallback)(()=>{zw({title:d,content:Bw(f,m),brandName:l,brandLogo:u})},[d,f,m,l,u]),L=(0,B.useCallback)((e,t)=>{t.preventDefault(),C.current={colIndex:e,startX:t.clientX,startWidth:x[e]};let n=null,r=e=>{C.current&&(n&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{if(!C.current)return;let t=e.clientX-C.current.startX,n=Math.max(Qw,C.current.startWidth+t);S(e=>{let t=[...e];return t[C.current.colIndex]=n,t})}))},i=()=>{C.current=null,n&&cancelAnimationFrame(n),window.removeEventListener(`mousemove`,r),window.removeEventListener(`mouseup`,i)};window.addEventListener(`mousemove`,r),window.addEventListener(`mouseup`,i)},[x]),ae=(0,B.useCallback)(()=>{g&&M.openCommentInput()},[g,M]),oe=(0,B.useCallback)(()=>{if(!g)return;let e=m[g.row]?.[g.col]??``;M.submitComment(e,{row:g.row,column:g.col})},[g,m,M]);if(n)return null;let se=typeof window<`u`&&window.innerWidth<640,ce=typeof BroadcastChannel<`u`,ue=(0,V.jsxs)(`div`,{className:`editor-base__actions`,children:[w===`saving`&&(0,V.jsx)(`span`,{className:`editor-base__status`,children:`Saving...`}),w===`saved`&&(0,V.jsx)(`span`,{className:`editor-base__status`,children:`Saved`}),M.pendingComments.length>0&&(0,V.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:M.sendComments,children:[`Send `,M.pendingComments.length,` comment`,M.pendingComments.length>1?`s`:``]}),g&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:He,onClick:ae,"aria-label":`Comment on cell`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:le,onClick:re,"aria-label":`Download CSV`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Oe,onClick:ie,"aria-label":`Export PDF`}),!se&&ce&&!j.poppedOut&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:j.handlePopout,"aria-label":`Pop out`}),!j.fullscreen&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ve,onClick:j.handleFullscreen,"aria-label":`Full screen`}),j.fullscreen&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:We,onClick:j.exitFullscreen,"aria-label":`Exit full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ge,onClick:j.handleMinimise,"aria-label":`Minimise`})]}),de=(0,V.jsxs)(`div`,{className:`grid-editor__table-wrap`,onPaste:ne,children:[M.showCommentInput?(0,V.jsxs)(`div`,{className:`grid-editor__comment-popover`,children:[(0,V.jsx)(`input`,{ref:M.commentInputRef,type:`text`,value:M.commentText,onChange:e=>M.setCommentText(e.target.value),onKeyDown:e=>{e.key===`Enter`&&oe(),e.key===`Escape`&&M.cancelComment()},placeholder:`Add a comment...`,className:`doc-editor__comment-input`,"aria-label":`Add comment on cell`}),(0,V.jsxs)(`div`,{className:`doc-editor__comment-actions`,children:[(0,V.jsx)(T,{variant:`primary`,size:`sm`,onClick:oe,disabled:!M.commentText.trim(),children:`Add`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:fe,onClick:M.cancelComment,"aria-label":`Cancel`})]})]}):null,(0,V.jsxs)(`table`,{className:`grid-editor__table`,role:`grid`,"aria-label":d,children:[(0,V.jsx)(`thead`,{children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`grid-editor__row-header`}),f.map((e,t)=>(0,V.jsxs)(`th`,{className:`grid-editor__col-header`,style:{width:x[t]},children:[e,(0,V.jsx)(`div`,{className:`grid-editor__resize-handle`,onMouseDown:e=>L(t,e),role:`separator`,"aria-orientation":`vertical`})]},t))]})}),(0,V.jsx)(`tbody`,{children:m.map((e,t)=>(0,V.jsxs)(`tr`,{children:[(0,V.jsxs)(`td`,{className:`grid-editor__row-header`,children:[(0,V.jsx)(`span`,{className:`grid-editor__row-num`,children:t+1}),m.length>1&&(0,V.jsx)(`button`,{className:`grid-editor__row-delete`,onClick:()=>I(t),"aria-label":`Delete row ${t+1}`,children:(0,V.jsx)(i,{size:12})})]}),e.map((e,n)=>{let r=g?.row===t&&g?.col===n;return(0,V.jsx)(`td`,{className:`grid-editor__cell ${r?`grid-editor__cell--active`:``}`,onClick:()=>!r&&N(t,n),role:`gridcell`,"aria-selected":r,style:{width:x[n]},children:r?(0,V.jsx)(`input`,{ref:b,type:`text`,className:`grid-editor__cell-input`,value:v,onChange:e=>y(e.target.value),onKeyDown:F,onBlur:P,"aria-label":`${f[n]} row ${t+1}`}):(0,V.jsx)(`span`,{className:`grid-editor__cell-text`,children:e})},n)})]},t))})]}),(0,V.jsxs)(`button`,{className:`grid-editor__add-row`,onClick:te,"aria-label":`Add row`,children:[(0,V.jsx)(be,{size:14}),(0,V.jsx)(`span`,{children:`Add row`})]})]});return j.fullscreen?(0,V.jsxs)(`div`,{className:`editor-base-fullscreen`,children:[(0,V.jsxs)(`div`,{className:`editor-base-fullscreen__bar`,...j.dragBarProps,children:[(0,V.jsx)(`span`,{className:`editor-base-fullscreen__title`,children:d}),ue]}),(0,V.jsx)(`div`,{className:`editor-base-fullscreen__body`,style:{maxWidth:`none`},children:de})]}):j.poppedOut?(0,V.jsx)(`div`,{className:`editor-base editor-base--popout`,children:(0,V.jsxs)(`div`,{className:`editor-base__bar`,...j.dragBarProps,children:[(0,V.jsx)(`span`,{className:`editor-base__title`,children:d}),(0,V.jsxs)(`div`,{className:`editor-base__actions`,children:[(0,V.jsx)(`span`,{className:`editor-base__status`,children:`Popped out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ze,onClick:j.handlePopIn,"aria-label":`Pop back in`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ge,onClick:j.handleMinimise,"aria-label":`Close`})]})]})}):j.minimised?(0,V.jsx)(`div`,{className:`editor-base editor-base--minimised`,onClick:j.handleExpand,role:`button`,tabIndex:0,onKeyDown:e=>e.key===`Enter`&&j.handleExpand(),children:(0,V.jsxs)(`div`,{className:`editor-base__bar`,...j.dragBarProps,children:[(0,V.jsx)(`span`,{className:`editor-base__title`,children:d}),(0,V.jsxs)(`div`,{className:`editor-base__actions`,onClick:e=>e.stopPropagation(),children:[!se&&ce&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:j.handlePopout,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ve,onClick:j.handleFullscreen,"aria-label":`Full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Je,onClick:j.handleExpand,"aria-label":`Expand`})]})]})}):(0,V.jsxs)(`div`,{className:`editor-base grid-editor`,children:[(0,V.jsxs)(`div`,{className:`editor-base__bar`,...j.dragBarProps,children:[(0,V.jsx)(`span`,{className:`editor-base__title`,children:d}),ue]}),(0,V.jsx)(`div`,{className:`grid-editor__body`,children:de})]})}var iT=Object.defineProperty,aT=Object.getOwnPropertySymbols,oT=Object.prototype.hasOwnProperty,sT=Object.prototype.propertyIsEnumerable,cT=(e,t,n)=>t in e?iT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lT=(e,t)=>{for(var n in t||={})oT.call(t,n)&&cT(e,n,t[n]);if(aT)for(var n of aT(t))sT.call(t,n)&&cT(e,n,t[n]);return e},uT=(e,t)=>{var n={};for(var r in e)oT.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&aT)for(var r of aT(e))t.indexOf(r)<0&&sT.call(e,r)&&(n[r]=e[r]);return n},dT;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+(t?1:0),n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(dT||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(dT||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(dT||={});var fT=dT,pT={L:fT.QrCode.Ecc.LOW,M:fT.QrCode.Ecc.MEDIUM,Q:fT.QrCode.Ecc.QUARTILE,H:fT.QrCode.Ecc.HIGH},mT=128,hT=`L`,gT=`#FFFFFF`,_T=`#000000`,vT=!1,yT=1,bT=4,xT=0,ST=.1;function CT(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function wT(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function TT(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*ST),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function ET(e,t){return t==null?e?bT:xT:Math.max(Math.floor(t),0)}function DT({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=B.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...fT.QrSegment.makeSegments(t)),e),[]);return fT.QrCode.encodeSegments(r,pT[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=B.useMemo(()=>{let e=c.getModules(),t=ET(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:TT(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var OT=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),kT=B.forwardRef(function(e,t){let n=e,{value:r,size:i=mT,level:a=hT,bgColor:o=gT,fgColor:s=_T,includeMargin:c=vT,minVersion:l=yT,boostLevel:u,marginSize:d,imageSettings:f}=n,p=uT(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=uT(p,[`style`]),g=f?.src,_=B.useRef(null),v=B.useRef(null),y=B.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=B.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=DT({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});B.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=wT(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,OT?t.fill(new Path2D(CT(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),B.useEffect(()=>{x(!1)},[g]);let E=lT({height:i,width:i},m),D=null;return g!=null&&(D=B.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),B.createElement(B.Fragment,null,B.createElement(`canvas`,lT({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});kT.displayName=`QRCodeCanvas`;var AT=B.forwardRef(function(e,t){let n=e,{value:r,size:i=mT,level:a=hT,bgColor:o=gT,fgColor:s=_T,includeMargin:c=vT,minVersion:l=yT,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=uT(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=DT({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=wT(g,v.excavation)),b=B.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=CT(y,h);return B.createElement(`svg`,lT({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&B.createElement(`title`,null,d),B.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),B.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});AT.displayName=`QRCodeSVG`;function jT({data:e,onSubmit:t,submitted:n}){let r=e,i=(0,B.useRef)(!1),a=r?.value?.trim()??``;return(0,B.useEffect)(()=>{a&&!n&&!i.current&&(i.current=!0,t(``))},[a,n,t]),a?(0,V.jsxs)(`div`,{className:`qr-code`,children:[(0,V.jsx)(`div`,{className:`qr-code__canvas`,children:(0,V.jsx)(AT,{value:a,size:240,level:`M`,bgColor:`#ffffff`,fgColor:`#000000`})}),r?.label&&(0,V.jsx)(`div`,{className:`qr-code__label`,children:r.label})]}):(0,V.jsx)(`div`,{className:`qr-code qr-code--error`,children:`No QR data provided. Try again or ask the agent to generate a new QR code.`})}function MT(e){return e===0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function NT(e){return e.startsWith(`image/`)?(0,V.jsx)(ke,{size:18}):e===`application/pdf`?(0,V.jsx)(c,{size:18}):e===`text/calendar`?(0,V.jsx)(ve,{size:18}):e.startsWith(`text/`)?(0,V.jsx)(D,{size:18}):(0,V.jsx)(ue,{size:18})}function PT({data:e,onSubmit:t,submitted:n,sessionKey:r}){let i=e,a=(0,B.useRef)(!1),o=!!(i?.attachmentId&&i?.filename);(0,B.useEffect)(()=>{o&&!n&&!a.current&&(a.current=!0,t(JSON.stringify({_lifecycle:!0,component:`file-attachment`,event:`rendered`,attachmentId:i.attachmentId,filename:i.filename})))},[o,n,t,i]);let s=(0,B.useCallback)(()=>{if(!i?.attachmentId||!r)return;let e=`/api/admin/attachment/${i.attachmentId}?session_key=${encodeURIComponent(r)}`,t=document.createElement(`a`);t.href=e,t.download=i.filename,t.click()},[i,r]);return o?(0,V.jsx)(k,{submitted:!1,submittedLabel:`Downloaded`,actions:[{label:`Download`,variant:`primary`,onClick:s,disabled:!r}],children:(0,V.jsxs)(`div`,{className:`file-attachment`,children:[(0,V.jsx)(`div`,{className:`file-attachment__icon`,children:NT(i.mimeType)}),(0,V.jsxs)(`div`,{className:`file-attachment__info`,children:[(0,V.jsx)(`div`,{className:`file-attachment__name`,title:i.filename,children:i.filename}),(0,V.jsxs)(`div`,{className:`file-attachment__meta`,children:[MT(i.sizeBytes),` · `,i.mimeType]})]}),(0,V.jsx)(`button`,{className:`file-attachment__download`,onClick:s,disabled:!r,title:`Download file`,children:(0,V.jsx)(le,{size:16})})]})}):null}var FT=/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/,IT=/^[a-z0-9-]$/;function LT(e){return e?FT.test(e):!1}function RT(e){let t=e.toLowerCase(),n=``;for(let e of t)IT.test(e)&&(n+=e);for(;n.startsWith(`-`);)n=n.slice(1);return n}function zT(e){return[{key:`length`,label:`At least 8 characters`,met:e.length>=8},{key:`number`,label:`Contains a number`,met:/\d/.test(e)},{key:`special`,label:`Contains a special character`,met:/[^A-Za-z0-9]/.test(e)},{key:`whitespace`,label:`No spaces`,met:e.length>0&&!/\s/.test(e)}]}var BT=18e4,VT=4096;function HT(e){let t=new TextEncoder().encode(e);return t.length<=VT?e:`${new TextDecoder(`utf-8`,{fatal:!1}).decode(t.slice(0,VT))}\n… ${t.length-VT} bytes truncated (total ${t.length} bytes)`}function UT({data:e,onSubmit:t,submitted:n,sessionKey:r}){let i=e,[a,o]=(0,B.useState)({status:`loading`}),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(``),[_,v]=(0,B.useState)(``),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(!1),[T,E]=(0,B.useState)(null),D=(0,B.useRef)(null),O=(0,B.useCallback)(async()=>{if(!r){o({status:`error`,field:`session`,message:`No session key available — refresh the page.`});return}o({status:`loading`});try{let e=await(await fetch(`/api/admin/cloudflare/domains?session_key=${encodeURIComponent(r)}`,{method:`GET`,headers:{Accept:`application/json`}})).json();if(!e.ok){o({status:`error`,field:e.field,message:e.message,output:e.output,correlationId:e.correlationId,streamLogPath:e.streamLogPath});return}if(e.domains.length===0){o({status:`empty`});return}o({status:`populated`,domains:e.domains}),u(t=>t||e.domains[0]),m(t=>t||e.domains[0])}catch(e){o({status:`error`,field:`script`,message:e instanceof Error?e.message:`Network error loading domains.`})}},[r]);(0,B.useEffect)(()=>{O()},[O]),(0,B.useEffect)(()=>()=>{D.current&&clearTimeout(D.current)},[]);let A=a.status===`populated`?a.domains:[],j=e=>{n||x||(c(RT(e)),E(null))},M=e=>{n||x||(f(RT(e)),E(null))},N=LT(s)&&l.length>0,P=d!==``,ee=!P||LT(d)&&p.length>0,F=N?`${s.replace(/-+$/,``)}.${l}`:``,te=P&&ee?`${d.replace(/-+$/,``)}.${p}`:``,I=!(te&&te===F),ne=zT(_),re=ne.every(e=>e.met),ie=a.status===`populated`&&N&&ee&&I&&re&&!x,L=s!==``&&!LT(s)?`Use lowercase letters, numbers, and hyphens. Start and end with a letter or number.`:null,ae=P&&!LT(d)?`Use lowercase letters, numbers, and hyphens. Start and end with a letter or number.`:I?null:`Public address must differ from the admin address.`,oe=T?.field===`admin`?T.message:null,se=T?.field===`public`?T.message:null,ce=T?.field===`password`?T.message:null,le=T?.field===`script`||T?.field===`request`?T.message:null,ue=()=>{w(!1),E(null),S(!1)},de=async()=>{if(!ie)return;if(!r){E({field:`request`,message:`No session key available — refresh the page.`});return}S(!0),E(null),w(!1);let e=new AbortController;D.current=setTimeout(()=>{e.abort(),w(!0)},BT);let n={session_key:r,adminLabel:s.replace(/-+$/,``),adminDomain:l,password:_};P&&(n.publicLabel=d.replace(/-+$/,``),n.publicDomain=p),h&&(n.apex=h);try{let r=await fetch(`/api/admin/cloudflare/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n),signal:e.signal});D.current&&clearTimeout(D.current),D.current=null;let i=await r.json();if(!i.ok){E({field:i.field,message:i.message,output:i.output,correlationId:i.correlationId,streamLogPath:i.streamLogPath});let e=i.streamLogPath?`\n\nstream log: ${i.streamLogPath}`:``;t(i.output&&i.output.length>0?`Cloudflare setup failed: ${i.message}\n\n${i.output}${e}`:`Cloudflare setup failed: ${i.message}${e}`),S(!1);return}t(i.output)}catch(t){if(D.current&&clearTimeout(D.current),D.current=null,e.signal.aborted)return;E({field:`script`,message:t instanceof Error?t.message:`Network error — try again.`}),S(!1)}},fe=(0,B.useMemo)(()=>s?`${s}.${l||`your-domain`}`:`your-name.${l||`your-domain`}`,[s,l]);if(a.status===`loading`)return(0,V.jsx)(k,{submitted:!1,actions:[],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[i?.title&&(0,V.jsx)(`div`,{className:`form-input__title`,children:i.title}),(0,V.jsx)(`div`,{className:`form-input__desc`,children:`Reading the domains on your Cloudflare account…`})]})});if(a.status===`empty`)return(0,V.jsx)(k,{submitted:!1,actions:[{label:`Retry`,variant:`primary`,onClick:O}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[(0,V.jsx)(`div`,{className:`form-input__title`,children:`No domains on this Cloudflare account`}),(0,V.jsx)(`div`,{className:`form-input__desc`,children:`Add a domain in the Cloudflare dashboard first, then click Retry.`}),(0,V.jsxs)(`ol`,{className:`form-input__field-desc`,style:{margin:0,paddingLeft:20},children:[(0,V.jsxs)(`li`,{children:[`With the correct account active (top-left), click `,(0,V.jsx)(`strong`,{children:`Websites`}),` in the left-hand sidebar.`]}),(0,V.jsxs)(`li`,{children:[`Click the `,(0,V.jsx)(`strong`,{children:`Add a site`}),` button.`]}),(0,V.jsxs)(`li`,{children:[`Enter the bare domain (e.g. `,(0,V.jsx)(`code`,{children:`example.com`}),`) and click `,(0,V.jsx)(`strong`,{children:`Continue`}),`.`]}),(0,V.jsxs)(`li`,{children:[`Review Cloudflare's imported DNS records — preserve website (`,(0,V.jsx)(`code`,{children:`A`}),`), email (`,(0,V.jsx)(`code`,{children:`MX`}),`), and verification (`,(0,V.jsx)(`code`,{children:`TXT`}),`) entries.`]}),(0,V.jsx)(`li`,{children:`Copy Cloudflare's two nameservers and set them on your domain registrar.`}),(0,V.jsxs)(`li`,{children:[`Return to Cloudflare and click `,(0,V.jsx)(`strong`,{children:`Check nameservers`}),`. Wait for the zone to show `,(0,V.jsx)(`strong`,{children:`Active`}),`.`]})]})]})});if(a.status===`error`){let e=a.field===`dashboard`,t=e?`Not signed into Cloudflare on this device`:`Could not read domains from Cloudflare`,n=e?`Sign in again at the Cloudflare dashboard in the VNC browser, then click Retry. If the VNC browser is not open, ask me to run vnc.sh restart.`:a.message;return(0,V.jsx)(k,{submitted:!1,actions:[{label:`Retry`,variant:`primary`,onClick:O}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[(0,V.jsx)(`div`,{className:`form-input__title`,children:t}),(0,V.jsx)(`div`,{className:`form-input__desc`,children:n}),a.output&&a.output.length>0&&(0,V.jsx)(`pre`,{style:{marginTop:8,padding:8,maxHeight:280,overflow:`auto`,fontFamily:`var(--font-mono, ui-monospace, monospace)`,fontSize:12,lineHeight:1.4,whiteSpace:`pre-wrap`,wordBreak:`break-word`,background:`var(--surface-2, rgba(0,0,0,0.04))`,borderRadius:4},children:HT(a.output)}),(a.correlationId||a.streamLogPath)&&(0,V.jsxs)(`div`,{style:{marginTop:8,fontFamily:`var(--font-mono, ui-monospace, monospace)`,fontSize:11,color:`var(--text-secondary)`,wordBreak:`break-all`},children:[a.correlationId&&(0,V.jsxs)(`div`,{children:[`conversationId: `,a.correlationId]}),a.streamLogPath&&(0,V.jsxs)(`div`,{children:[`stream log: `,a.streamLogPath]})]})]})})}return C?(0,V.jsx)(k,{submitted:!1,actions:[{label:`Reset form`,variant:`ghost`,onClick:ue}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[(0,V.jsx)(`div`,{className:`form-input__title`,children:`Setup is taking longer than expected`}),(0,V.jsx)(`div`,{className:`form-input__desc`,children:`The request is still running on the device — check the chat for live progress. Do not resubmit. If the script fails, the error will appear in chat and you can retry from there.`})]})}):(0,V.jsx)(k,{submitted:n,submittedLabel:`Submitting…`,actions:[{label:x?`Setting up…`:i?.submitLabel??`Set up Cloudflare`,variant:`primary`,disabled:!ie,onClick:de}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[i?.title&&(0,V.jsx)(`div`,{className:`form-input__title`,children:i.title}),i?.description&&(0,V.jsx)(`div`,{className:`form-input__desc`,children:i.description}),(0,V.jsxs)(`div`,{className:`form-input__fields`,children:[(0,V.jsxs)(`div`,{className:`form-input__field`,children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`cf-admin-label`,children:[`Admin address`,(0,V.jsx)(`span`,{className:`form-input__required`,children:`*`})]}),(0,V.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,V.jsx)(`input`,{id:`cf-admin-label`,className:`form-input__input tunnel-route__input`,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`your-name`,value:s,onChange:e=>j(e.target.value),disabled:n||x}),(0,V.jsx)(WT,{id:`cf-admin-domain`,value:l,options:A,onChange:u,disabled:n||x})]}),(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:`Where you access your platform remotely, via your main domain.`}),(0,V.jsxs)(`div`,{className:`form-input__field-desc`,children:[`Preview: `,(0,V.jsx)(`span`,{className:`tunnel-route__preview`,children:fe})]}),(oe||L)&&(0,V.jsx)(`div`,{className:`tunnel-route__error`,children:oe??L})]}),(0,V.jsxs)(`div`,{className:`form-input__field`,children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`cf-public-label`,children:[`Public address`,(0,V.jsx)(`span`,{className:`tunnel-route__optional`,children:`Optional`})]}),(0,V.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,V.jsx)(`input`,{id:`cf-public-label`,className:`form-input__input tunnel-route__input`,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`leave empty to skip`,value:d,onChange:e=>M(e.target.value),disabled:n||x}),(0,V.jsx)(WT,{id:`cf-public-domain`,value:p,options:A,onChange:m,disabled:n||x||!P})]}),(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:`Where visitors engage with your public agents, via your main domain. Leave empty for admin-only access.`}),(se||ae)&&(0,V.jsx)(`div`,{className:`tunnel-route__error`,children:se??ae})]}),(0,V.jsxs)(`div`,{className:`form-input__field`,children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`cf-apex`,children:[`Proxy apex`,(0,V.jsx)(`span`,{className:`tunnel-route__optional`,children:`Optional`})]}),(0,V.jsxs)(`select`,{id:`cf-apex`,className:`form-input__input`,value:h,onChange:e=>g(e.target.value),disabled:n||x,children:[(0,V.jsx)(`option`,{value:``,children:`None`}),A.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]}),(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:`Alternative domain for public agent visitors.`})]}),(0,V.jsxs)(`div`,{className:`form-input__field`,children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`cf-password`,children:[`Admin password`,(0,V.jsx)(`span`,{className:`form-input__required`,children:`*`})]}),(0,V.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,V.jsx)(`input`,{id:`cf-password`,className:`form-input__input tunnel-route__input`,type:y?`text`:`password`,autoCapitalize:`none`,autoComplete:`new-password`,autoCorrect:`off`,spellCheck:!1,value:_,onChange:e=>{v(e.target.value),E(null)},disabled:n||x}),(0,V.jsx)(`button`,{type:`button`,className:`tunnel-route__suffix`,onClick:()=>b(e=>!e),disabled:n||x,style:{cursor:`pointer`,border:`none`,background:`inherit`},"aria-label":y?`Hide password`:`Show password`,children:y?`Hide`:`Show`})]}),(0,V.jsx)(`ul`,{className:`form-input__field-desc`,style:{margin:0,paddingLeft:16},children:ne.map(e=>(0,V.jsxs)(`li`,{style:{color:e.met?`var(--text)`:`var(--text-secondary)`},children:[e.met?`✓`:`○`,` `,e.label]},e.key))}),ce&&(0,V.jsx)(`div`,{className:`tunnel-route__error`,children:ce})]}),le&&(0,V.jsxs)(`div`,{className:`tunnel-route__error`,role:`alert`,children:[(0,V.jsx)(`div`,{children:le}),T?.output&&T.output.length>0&&(0,V.jsx)(`pre`,{style:{marginTop:8,padding:8,maxHeight:280,overflow:`auto`,fontFamily:`var(--font-mono, ui-monospace, monospace)`,fontSize:12,lineHeight:1.4,whiteSpace:`pre-wrap`,wordBreak:`break-word`,background:`var(--surface-2, rgba(0,0,0,0.04))`,borderRadius:4},children:HT(T.output)}),(T?.correlationId||T?.streamLogPath)&&(0,V.jsxs)(`div`,{style:{marginTop:8,fontFamily:`var(--font-mono, ui-monospace, monospace)`,fontSize:11,color:`var(--text-secondary)`,wordBreak:`break-all`},children:[T.correlationId&&(0,V.jsxs)(`div`,{children:[`conversationId: `,T.correlationId]}),T.streamLogPath&&(0,V.jsxs)(`div`,{children:[`stream log: `,T.streamLogPath]})]})]})]})]})})}function WT({id:e,value:t,options:n,onChange:r,disabled:i}){return(0,V.jsx)(`select`,{id:e,className:`tunnel-route__suffix`,value:t,onChange:e=>r(e.target.value),disabled:i,style:{cursor:i?`default`:`pointer`,border:`none`},children:n.map(e=>(0,V.jsxs)(`option`,{value:e,children:[`.`,e]},e))})}var GT={"single-select":x,"multi-select":ee,confirm:jt,"info-card":Mt,"action-list":Nt,form:Pt,progress:It,"browser-viewer":Rt,"document-editor":Pw,"rich-content-editor":Xw,"grid-editor":rT,"qr-code":jT,"file-attachment":PT,"action-buttons":M,"cloudflare-setup-form":UT,"output-style":x,"thinking-view":x,"plugin-selector":ee};function KT({name:e,data:t,onSubmit:n,submitted:r,isStreaming:i,sessionKey:a}){let o=GT[e];return o?(0,V.jsx)(o,{data:t,onSubmit:n,submitted:r,isStreaming:i,sessionKey:a}):(console.warn(`[ComponentRenderer] Unknown component: "${e}". Registered: ${Object.keys(GT).join(`, `)}`),(0,V.jsx)(`div`,{className:`component-card component-card--error`,children:(0,V.jsxs)(`p`,{style:{fontFamily:`var(--font-body)`,fontSize:12,color:`var(--text-secondary)`},children:[`Component “`,e,`” is not available. This may require a platform update.`]})}))}var qT=/\b(?:fail|error|unable|could not|cannot|CAPTCHA|SIGN_IN_REQUIRED)\b/i;function JT(e){let t=new Date(e),n=new Date,r=String(t.getHours()).padStart(2,`0`),i=String(t.getMinutes()).padStart(2,`0`);return t.toDateString()===n.toDateString()?`${r}:${i}`:`${String(t.getDate()).padStart(2,`0`)}-${String(t.getMonth()+1).padStart(2,`0`)}-${t.getFullYear()} ${r}:${i}`}var YT=[et,Xe,me,Je,Ee];function XT({size:e=13}){let[t,n]=(0,B.useState)(0);(0,B.useEffect)(()=>{let e=setInterval(()=>n(e=>(e+1)%8),300);return()=>clearInterval(e)},[]);let r=t<=4?t:8-t,i=YT[r];return(0,V.jsx)(i,{size:e,className:`star-loader star-frame-${r}`})}var ZT=[`Thinking`,`Reasoning`,`Analyzing`,`Considering`,`Reflecting`,`Evaluating`,`Weighing`,`Synthesizing`,`Processing`,`Exploring`,`Examining`,`Assessing`,`Reviewing`,`Contemplating`,`Deliberating`],QT=60,$T=1500;function eE(){let e=(0,B.useRef)(-1),t=(0,B.useRef)(void 0),[n,r]=(0,B.useState)(()=>{let t=Math.floor(Math.random()*ZT.length);return e.current=t,ZT[t]+`…`});return(0,B.useEffect)(()=>{let n=!1;function i(){let t;do t=Math.floor(Math.random()*ZT.length);while(t===e.current&&ZT.length>1);return e.current=t,t}function a(){if(n)return;let e=ZT[i()]+`…`,o=0;function s(){n||(o++,r(e.slice(0,o)),o<e.length?t.current=setTimeout(s,QT):t.current=setTimeout(a,$T))}t.current=setTimeout(s,QT)}return t.current=setTimeout(a,$T),()=>{n=!0,clearTimeout(t.current)}},[]),(0,V.jsx)(`span`,{className:`tl-thinking-typewriter`,children:n})}function tE(e,t){let n=e=>String(e??``);switch(e){case`Read`:return`Read ${n(t.file_path??t.path)}`;case`Write`:return`Write ${n(t.file_path??t.path)}`;case`Edit`:return`Edit ${n(t.file_path??t.path)}`;case`Bash`:return n(t.description??String(t.command??``).slice(0,70));case`Glob`:return`Glob ${n(t.pattern)}`;case`Grep`:return`Grep "${n(t.pattern)}" in ${n(t.path??`.`)}`;case`WebFetch`:return`Fetch ${n(t.url)}`;case`Agent`:return n(t.description??t.task??`Subagent`);case`Skill`:return n(t.skill??`Skill`);default:{let r=e.match(/^mcp__[^_]+__(.+)$/),i=r?r[1]:e,a=Object.keys(t)[0];return a?`${i}: ${n(t[a]).slice(0,50)}`:i}}}function nE({name:e,size:t=12}){let n=e.match(/^mcp__[^_]+__(.+)$/);switch(n?n[1]:e){case`Read`:return(0,V.jsx)(c,{size:t});case`Write`:return(0,V.jsx)(je,{size:t});case`Edit`:return(0,V.jsx)(Ae,{size:t});case`Bash`:return(0,V.jsx)(tt,{size:t});case`Glob`:case`Grep`:return(0,V.jsx)(ae,{size:t});case`WebFetch`:return(0,V.jsx)(O,{size:t});case`Agent`:return(0,V.jsx)(_e,{size:t});case`Skill`:return(0,V.jsx)(Xe,{size:t});case`memory-search`:return(0,V.jsx)(Te,{size:t});case`memory-write`:return(0,V.jsx)(we,{size:t});case`task-list`:return(0,V.jsx)(z,{size:t});case`task-create`:return(0,V.jsx)(xe,{size:t});case`contact-create`:return(0,V.jsx)(nt,{size:t});default:return(0,V.jsx)(rt,{size:t})}}function rE(e){let t=new Map,n=new Map;return e.forEach((e,r)=>{if(e.type===`tool_use`){let t=n.get(e.name)??[];t.push(r),n.set(e.name,t)}else if(e.type===`tool_result`){let i=n.get(e.name);i?.length&&t.set(i.shift(),r)}}),t}function iE(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function aE(e){let t=``;switch(e.type){case`text`:case`thinking`:t=e.content??``;break;case`tool_use`:t=JSON.stringify(e.input??{});break;case`tool_result`:t=e.output??``;break;case`subagent_start`:t=e.task??``;break;case`subagent_end`:t=e.result??``;break;case`component`:t=JSON.stringify(e.data??{});break;case`status`:t=e.message??``;break;default:return 0}return Math.ceil(t.length/4)}function oE(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function sE(e){if(e<60)return`${e.toFixed(1)}s`;let t=Math.floor(e/60),n=e%60;return n>=.1?`${t}m ${Math.floor(n)}s`:`${t}m`}function cE({icon:e,isPending:t,isError:n,doneClass:r=`tl-done`,summary:i,detail:a,tokens:o,elapsed:s,isLast:c,expanded:l,onToggle:u,selectCheck:d}){let f=!!a;return(0,V.jsxs)(`div`,{className:`tl-step`,children:[d,(0,V.jsxs)(`div`,{className:`tl-col`,children:[(0,V.jsx)(`div`,{className:`tl-icon${t?` tl-pending`:n?` tl-error`:` ${r}`}`,children:e}),!c&&(0,V.jsx)(`div`,{className:`tl-line tl-line-grow`})]}),(0,V.jsxs)(`div`,{className:`tl-body`,children:[(0,V.jsxs)(`div`,{className:`tl-row`,onClick:f?()=>{window.getSelection()?.toString()||u()}:void 0,style:{cursor:f?`pointer`:`default`},children:[(0,V.jsx)(`span`,{className:`tl-summary`,children:i}),o>0&&(0,V.jsxs)(`span`,{className:`tl-step-tokens`,children:[(0,V.jsx)(it,{size:9}),iE(o)]}),(0,V.jsx)(`span`,{className:`tl-step-elapsed`,children:sE(s)}),f&&(0,V.jsx)(`span`,{className:`tl-chevron`,children:l?(0,V.jsx)(p,{size:10}):(0,V.jsx)(ye,{size:10})})]}),f&&l&&(0,V.jsx)(`pre`,{className:`tl-detail`,children:a})]})]})}function lE({events:e,isStreaming:t,elapsedSeconds:n,streamStartMs:r,expandAll:i,onCompactNow:a,isCompacting:o,sessionCompacted:s,onComponentSubmit:c,submittedComponents:l,timestamp:u,selectionMode:d,selectedItems:f,onToggleItem:m,sessionKey:g}){let[_,v]=(0,B.useState)(new Set),[y,b]=(0,B.useState)(!t),x=(0,B.useRef)(t);(0,B.useEffect)(()=>{x.current&&!t&&b(!0),!x.current&&t&&b(!1),x.current=t},[t]);let C=(0,B.useRef)(new Map),E=(0,B.useRef)(0),[D,O]=(0,B.useState)(Date.now());(0,B.useEffect)(()=>{let t=Date.now();for(let n=E.current;n<e.length;n++)C.current.has(n)||C.current.set(n,t);E.current=e.length},[e]),(0,B.useEffect)(()=>{if(!t)return;let e=setInterval(()=>O(Date.now()),100);return()=>clearInterval(e)},[t]);let k=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},A=(e,t)=>{let n=e===L[0]?.i&&r?r:C.current.get(e)??D,i=t===void 0?D:C.current.get(t)??D;return Math.max(0,(i-n)/1e3)},j=rE(e),M=new Set(j.values()),N=e.map((e,t)=>({e,i:t})).filter(({e})=>e.type===`text`),P=new Set(t?[]:e.map((e,t)=>({e,i:t})).filter(({e})=>e.type===`component`).map(({i:e})=>e)),ee=e=>e.type===`component`&&[`browser-viewer`,`qr-code`].includes(e.name);function F(e){if(!d||t||!u)return null;let n=`${u}_${e}`;return(0,V.jsx)(`div`,{className:`tl-select-check`,onClick:e=>e.stopPropagation(),children:(0,V.jsx)(w,{checked:f?.has(n)??!1,onChange:()=>m?.(n)})})}let I=e.findLast(e=>e.type===`usage`),ne=e.findLast(e=>e.type===`history_usage`),re=e.findLast(e=>e.type===`status`),ie=e.some(e=>e.type===`subagent_start`),L=e.map((e,t)=>({e,i:t})).filter(({e,i:n})=>e.type!==`text`&&e.type!==`usage`&&e.type!==`rate_limit`&&e.type!==`history_usage`&&e.type!==`status`&&e.type!==`done`&&e.type!==`subagent_progress`&&!M.has(n)&&!P.has(n)&&!(t&&e.type===`component`&&!ee(e))&&!(e.type===`tool_use`&&e.name===`Agent`&&ie)),ae=new Map;for(let e=0;e<L.length-1;e++)ae.set(L[e].i,L[e+1].i);let oe=(()=>{let e=[],t=!1,n=0;for(let{e:r}of L)if(n+=aE(r),r.type===`thinking`)t=!0;else if(r.type===`tool_use`){let t=r.name;e.includes(t)||e.push(t)}let r=[`${L.length} step${L.length===1?``:`s`}`];if(e.length>0){let t=e.slice(0,3),n=e.length-t.length;r.push(t.join(`, `)+(n>0?` +${n}`:``))}return{text:r.join(` · `),hasThinking:t,tokenSum:n}})(),se=I?.peak_request_pct==null?I?.context_window?Math.round((I.input_tokens+I.cache_creation_tokens+I.cache_read_tokens)/I.context_window*100):null:Math.round(I.peak_request_pct*100),ce=L.length>0,le=N.length>0,ue=new Set(L.map(e=>e.i)),de=new Set(N.map(e=>e.i)),me=[];for(let t=0;t<e.length;t++){let n=e[t],r=null;if(ue.has(t)?r=`steps`:de.has(t)&&(r=`text`),!r)continue;let i=me[me.length-1];i&&i.role===r?i.items.push({e:n,i:t}):me.push({role:r,items:[{e:n,i:t}]})}let he=N.length>0?N[N.length-1].i:-1;function ge(n,r,a,o){let s=o===a.length-1;if(n.type===`thinking`){let e=i===void 0?!_.has(r):i,t=ae.get(r);return(0,V.jsxs)(`div`,{className:`tl-step`,children:[F(r),(0,V.jsxs)(`div`,{className:`tl-col`,children:[(0,V.jsx)(`div`,{className:`tl-icon tl-dim`,children:(0,V.jsx)(Le,{size:11})}),!s&&(0,V.jsx)(`div`,{className:`tl-line tl-line-grow`})]}),(0,V.jsx)(`div`,{className:`tl-body`,children:(0,V.jsxs)(`div`,{className:`tl-row tl-row-top`,onClick:()=>{window.getSelection()?.toString()||k(r)},style:{cursor:`pointer`},children:[(0,V.jsx)(`div`,{className:`tl-thinking-col`,children:e?(0,V.jsx)(`div`,{className:`tl-thinking-body`,children:n.content}):(0,V.jsxs)(`span`,{className:`tl-summary tl-thinking-label`,children:[n.content.slice(0,80),n.content.length>80?`…`:``]})}),aE(n)>0&&(0,V.jsxs)(`span`,{className:`tl-step-tokens`,children:[(0,V.jsx)(it,{size:9}),iE(aE(n))]}),(0,V.jsx)(`span`,{className:`tl-step-elapsed`,children:sE(A(r,t))}),(0,V.jsx)(`span`,{className:`tl-chevron`,children:e?(0,V.jsx)(p,{size:10}):(0,V.jsx)(ye,{size:10})})]})})]},r)}if(n.type===`status`)return(0,V.jsx)(`div`,{className:`tl-status`,children:n.message},r);if(n.type===`tool_use`){let t=j.get(r),a=t===void 0?void 0:e[t],o=a===void 0,c=a?.type===`tool_result`&&!!a.error,l=o?(0,V.jsx)(Be,{size:11,className:`tl-spinner`}):c?(0,V.jsx)(fe,{size:11}):(0,V.jsx)(nE,{name:n.name,size:11}),u=n,d=a?.type===`tool_result`?`Input:
|
|
343
|
+
`).filter(e=>e.trim());if(n.length<=1&&!n[0]?.includes(` `)&&!n[0]?.includes(`,`))return;e.preventDefault();let r=n.slice(0,Zw).map(eT);n.length>Zw&&console.warn(`Grid editor: paste truncated from ${n.length} to ${Zw} rows`);let{row:i,col:a}=g;h(e=>{let t=e.map(e=>[...e]);for(let e=0;e<r.length;e++){let n=i+e;for(;n>=t.length;)t.push(Array(f.length).fill(``));for(let i=0;i<r[e].length;i++){let o=a+i;o<f.length&&(t[n][o]=r[e][i])}}return t}),A()},[g,f.length,A]),re=(0,B.useCallback)(()=>{let e=tT(f,m),t=new Blob([e],{type:`text/csv;charset=utf-8;`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${d.replace(/[^a-zA-Z0-9]/g,`_`)}.csv`,r.click(),URL.revokeObjectURL(n)},[f,m,d]),ie=(0,B.useCallback)(()=>{zw({title:d,content:Bw(f,m),brandName:l,brandLogo:u})},[d,f,m,l,u]),L=(0,B.useCallback)((e,t)=>{t.preventDefault(),C.current={colIndex:e,startX:t.clientX,startWidth:x[e]};let n=null,r=e=>{C.current&&(n&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{if(!C.current)return;let t=e.clientX-C.current.startX,n=Math.max(Qw,C.current.startWidth+t);S(e=>{let t=[...e];return t[C.current.colIndex]=n,t})}))},i=()=>{C.current=null,n&&cancelAnimationFrame(n),window.removeEventListener(`mousemove`,r),window.removeEventListener(`mouseup`,i)};window.addEventListener(`mousemove`,r),window.addEventListener(`mouseup`,i)},[x]),ae=(0,B.useCallback)(()=>{g&&M.openCommentInput()},[g,M]),oe=(0,B.useCallback)(()=>{if(!g)return;let e=m[g.row]?.[g.col]??``;M.submitComment(e,{row:g.row,column:g.col})},[g,m,M]);if(n)return null;let se=typeof window<`u`&&window.innerWidth<640,ce=typeof BroadcastChannel<`u`,ue=(0,V.jsxs)(`div`,{className:`editor-base__actions`,children:[w===`saving`&&(0,V.jsx)(`span`,{className:`editor-base__status`,children:`Saving...`}),w===`saved`&&(0,V.jsx)(`span`,{className:`editor-base__status`,children:`Saved`}),M.pendingComments.length>0&&(0,V.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:M.sendComments,children:[`Send `,M.pendingComments.length,` comment`,M.pendingComments.length>1?`s`:``]}),g&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:He,onClick:ae,"aria-label":`Comment on cell`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:le,onClick:re,"aria-label":`Download CSV`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Oe,onClick:ie,"aria-label":`Export PDF`}),!se&&ce&&!j.poppedOut&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:j.handlePopout,"aria-label":`Pop out`}),!j.fullscreen&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ve,onClick:j.handleFullscreen,"aria-label":`Full screen`}),j.fullscreen&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:We,onClick:j.exitFullscreen,"aria-label":`Exit full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ge,onClick:j.handleMinimise,"aria-label":`Minimise`})]}),de=(0,V.jsxs)(`div`,{className:`grid-editor__table-wrap`,onPaste:ne,children:[M.showCommentInput?(0,V.jsxs)(`div`,{className:`grid-editor__comment-popover`,children:[(0,V.jsx)(`input`,{ref:M.commentInputRef,type:`text`,value:M.commentText,onChange:e=>M.setCommentText(e.target.value),onKeyDown:e=>{e.key===`Enter`&&oe(),e.key===`Escape`&&M.cancelComment()},placeholder:`Add a comment...`,className:`doc-editor__comment-input`,"aria-label":`Add comment on cell`}),(0,V.jsxs)(`div`,{className:`doc-editor__comment-actions`,children:[(0,V.jsx)(T,{variant:`primary`,size:`sm`,onClick:oe,disabled:!M.commentText.trim(),children:`Add`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:fe,onClick:M.cancelComment,"aria-label":`Cancel`})]})]}):null,(0,V.jsxs)(`table`,{className:`grid-editor__table`,role:`grid`,"aria-label":d,children:[(0,V.jsx)(`thead`,{children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`grid-editor__row-header`}),f.map((e,t)=>(0,V.jsxs)(`th`,{className:`grid-editor__col-header`,style:{width:x[t]},children:[e,(0,V.jsx)(`div`,{className:`grid-editor__resize-handle`,onMouseDown:e=>L(t,e),role:`separator`,"aria-orientation":`vertical`})]},t))]})}),(0,V.jsx)(`tbody`,{children:m.map((e,t)=>(0,V.jsxs)(`tr`,{children:[(0,V.jsxs)(`td`,{className:`grid-editor__row-header`,children:[(0,V.jsx)(`span`,{className:`grid-editor__row-num`,children:t+1}),m.length>1&&(0,V.jsx)(`button`,{className:`grid-editor__row-delete`,onClick:()=>I(t),"aria-label":`Delete row ${t+1}`,children:(0,V.jsx)(i,{size:12})})]}),e.map((e,n)=>{let r=g?.row===t&&g?.col===n;return(0,V.jsx)(`td`,{className:`grid-editor__cell ${r?`grid-editor__cell--active`:``}`,onClick:()=>!r&&N(t,n),role:`gridcell`,"aria-selected":r,style:{width:x[n]},children:r?(0,V.jsx)(`input`,{ref:b,type:`text`,className:`grid-editor__cell-input`,value:v,onChange:e=>y(e.target.value),onKeyDown:F,onBlur:P,"aria-label":`${f[n]} row ${t+1}`}):(0,V.jsx)(`span`,{className:`grid-editor__cell-text`,children:e})},n)})]},t))})]}),(0,V.jsxs)(`button`,{className:`grid-editor__add-row`,onClick:te,"aria-label":`Add row`,children:[(0,V.jsx)(xe,{size:14}),(0,V.jsx)(`span`,{children:`Add row`})]})]});return j.fullscreen?(0,V.jsxs)(`div`,{className:`editor-base-fullscreen`,children:[(0,V.jsxs)(`div`,{className:`editor-base-fullscreen__bar`,...j.dragBarProps,children:[(0,V.jsx)(`span`,{className:`editor-base-fullscreen__title`,children:d}),ue]}),(0,V.jsx)(`div`,{className:`editor-base-fullscreen__body`,style:{maxWidth:`none`},children:de})]}):j.poppedOut?(0,V.jsx)(`div`,{className:`editor-base editor-base--popout`,children:(0,V.jsxs)(`div`,{className:`editor-base__bar`,...j.dragBarProps,children:[(0,V.jsx)(`span`,{className:`editor-base__title`,children:d}),(0,V.jsxs)(`div`,{className:`editor-base__actions`,children:[(0,V.jsx)(`span`,{className:`editor-base__status`,children:`Popped out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ze,onClick:j.handlePopIn,"aria-label":`Pop back in`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ge,onClick:j.handleMinimise,"aria-label":`Close`})]})]})}):j.minimised?(0,V.jsx)(`div`,{className:`editor-base editor-base--minimised`,onClick:j.handleExpand,role:`button`,tabIndex:0,onKeyDown:e=>e.key===`Enter`&&j.handleExpand(),children:(0,V.jsxs)(`div`,{className:`editor-base__bar`,...j.dragBarProps,children:[(0,V.jsx)(`span`,{className:`editor-base__title`,children:d}),(0,V.jsxs)(`div`,{className:`editor-base__actions`,onClick:e=>e.stopPropagation(),children:[!se&&ce&&(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:j.handlePopout,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ve,onClick:j.handleFullscreen,"aria-label":`Full screen`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:Je,onClick:j.handleExpand,"aria-label":`Expand`})]})]})}):(0,V.jsxs)(`div`,{className:`editor-base grid-editor`,children:[(0,V.jsxs)(`div`,{className:`editor-base__bar`,...j.dragBarProps,children:[(0,V.jsx)(`span`,{className:`editor-base__title`,children:d}),ue]}),(0,V.jsx)(`div`,{className:`grid-editor__body`,children:de})]})}var iT=Object.defineProperty,aT=Object.getOwnPropertySymbols,oT=Object.prototype.hasOwnProperty,sT=Object.prototype.propertyIsEnumerable,cT=(e,t,n)=>t in e?iT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lT=(e,t)=>{for(var n in t||={})oT.call(t,n)&&cT(e,n,t[n]);if(aT)for(var n of aT(t))sT.call(t,n)&&cT(e,n,t[n]);return e},uT=(e,t)=>{var n={};for(var r in e)oT.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&aT)for(var r of aT(e))t.indexOf(r)<0&&sT.call(e,r)&&(n[r]=e[r]);return n},dT;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+(t?1:0),n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(dT||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(dT||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(dT||={});var fT=dT,pT={L:fT.QrCode.Ecc.LOW,M:fT.QrCode.Ecc.MEDIUM,Q:fT.QrCode.Ecc.QUARTILE,H:fT.QrCode.Ecc.HIGH},mT=128,hT=`L`,gT=`#FFFFFF`,_T=`#000000`,vT=!1,yT=1,bT=4,xT=0,ST=.1;function CT(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function wT(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function TT(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*ST),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function ET(e,t){return t==null?e?bT:xT:Math.max(Math.floor(t),0)}function DT({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=B.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...fT.QrSegment.makeSegments(t)),e),[]);return fT.QrCode.encodeSegments(r,pT[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=B.useMemo(()=>{let e=c.getModules(),t=ET(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:TT(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var OT=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),kT=B.forwardRef(function(e,t){let n=e,{value:r,size:i=mT,level:a=hT,bgColor:o=gT,fgColor:s=_T,includeMargin:c=vT,minVersion:l=yT,boostLevel:u,marginSize:d,imageSettings:f}=n,p=uT(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=uT(p,[`style`]),g=f?.src,_=B.useRef(null),v=B.useRef(null),y=B.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=B.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=DT({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});B.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=wT(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,OT?t.fill(new Path2D(CT(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),B.useEffect(()=>{x(!1)},[g]);let E=lT({height:i,width:i},m),D=null;return g!=null&&(D=B.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),B.createElement(B.Fragment,null,B.createElement(`canvas`,lT({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});kT.displayName=`QRCodeCanvas`;var AT=B.forwardRef(function(e,t){let n=e,{value:r,size:i=mT,level:a=hT,bgColor:o=gT,fgColor:s=_T,includeMargin:c=vT,minVersion:l=yT,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=uT(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=DT({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=wT(g,v.excavation)),b=B.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=CT(y,h);return B.createElement(`svg`,lT({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&B.createElement(`title`,null,d),B.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),B.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});AT.displayName=`QRCodeSVG`;function jT({data:e,onSubmit:t,submitted:n}){let r=e,i=(0,B.useRef)(!1),a=r?.value?.trim()??``;return(0,B.useEffect)(()=>{a&&!n&&!i.current&&(i.current=!0,t(``))},[a,n,t]),a?(0,V.jsxs)(`div`,{className:`qr-code`,children:[(0,V.jsx)(`div`,{className:`qr-code__canvas`,children:(0,V.jsx)(AT,{value:a,size:240,level:`M`,bgColor:`#ffffff`,fgColor:`#000000`})}),r?.label&&(0,V.jsx)(`div`,{className:`qr-code__label`,children:r.label})]}):(0,V.jsx)(`div`,{className:`qr-code qr-code--error`,children:`No QR data provided. Try again or ask the agent to generate a new QR code.`})}function MT(e){return e===0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function NT(e){return e.startsWith(`image/`)?(0,V.jsx)(ke,{size:18}):e===`application/pdf`?(0,V.jsx)(c,{size:18}):e===`text/calendar`?(0,V.jsx)(ve,{size:18}):e.startsWith(`text/`)?(0,V.jsx)(D,{size:18}):(0,V.jsx)(ue,{size:18})}function PT({data:e,onSubmit:t,submitted:n,sessionKey:r}){let i=e,a=(0,B.useRef)(!1),o=!!(i?.attachmentId&&i?.filename);(0,B.useEffect)(()=>{o&&!n&&!a.current&&(a.current=!0,t(JSON.stringify({_lifecycle:!0,component:`file-attachment`,event:`rendered`,attachmentId:i.attachmentId,filename:i.filename})))},[o,n,t,i]);let s=(0,B.useCallback)(()=>{if(!i?.attachmentId||!r)return;let e=`/api/admin/attachment/${i.attachmentId}?session_key=${encodeURIComponent(r)}`,t=document.createElement(`a`);t.href=e,t.download=i.filename,t.click()},[i,r]);return o?(0,V.jsx)(k,{submitted:!1,submittedLabel:`Downloaded`,actions:[{label:`Download`,variant:`primary`,onClick:s,disabled:!r}],children:(0,V.jsxs)(`div`,{className:`file-attachment`,children:[(0,V.jsx)(`div`,{className:`file-attachment__icon`,children:NT(i.mimeType)}),(0,V.jsxs)(`div`,{className:`file-attachment__info`,children:[(0,V.jsx)(`div`,{className:`file-attachment__name`,title:i.filename,children:i.filename}),(0,V.jsxs)(`div`,{className:`file-attachment__meta`,children:[MT(i.sizeBytes),` · `,i.mimeType]})]}),(0,V.jsx)(`button`,{className:`file-attachment__download`,onClick:s,disabled:!r,title:`Download file`,children:(0,V.jsx)(le,{size:16})})]})}):null}var FT=/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/,IT=/^[a-z0-9-]$/;function LT(e){return e?FT.test(e):!1}function RT(e){let t=e.toLowerCase(),n=``;for(let e of t)IT.test(e)&&(n+=e);for(;n.startsWith(`-`);)n=n.slice(1);return n}function zT(e){return[{key:`length`,label:`At least 8 characters`,met:e.length>=8},{key:`number`,label:`Contains a number`,met:/\d/.test(e)},{key:`special`,label:`Contains a special character`,met:/[^A-Za-z0-9]/.test(e)},{key:`whitespace`,label:`No spaces`,met:e.length>0&&!/\s/.test(e)}]}var BT=18e4,VT=4096;function HT(e){let t=new TextEncoder().encode(e);return t.length<=VT?e:`${new TextDecoder(`utf-8`,{fatal:!1}).decode(t.slice(0,VT))}\n… ${t.length-VT} bytes truncated (total ${t.length} bytes)`}function UT({data:e,onSubmit:t,submitted:n,sessionKey:r}){let i=e,[a,o]=(0,B.useState)({status:`loading`}),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(``),[_,v]=(0,B.useState)(``),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(!1),[T,E]=(0,B.useState)(null),D=(0,B.useRef)(null),O=(0,B.useCallback)(async()=>{if(!r){o({status:`error`,field:`session`,message:`No session key available — refresh the page.`});return}o({status:`loading`});try{let e=await(await fetch(`/api/admin/cloudflare/domains?session_key=${encodeURIComponent(r)}`,{method:`GET`,headers:{Accept:`application/json`}})).json();if(!e.ok){o({status:`error`,field:e.field,message:e.message,output:e.output,correlationId:e.correlationId,streamLogPath:e.streamLogPath});return}if(e.domains.length===0){o({status:`empty`});return}o({status:`populated`,domains:e.domains}),u(t=>t||e.domains[0]),m(t=>t||e.domains[0])}catch(e){o({status:`error`,field:`script`,message:e instanceof Error?e.message:`Network error loading domains.`})}},[r]);(0,B.useEffect)(()=>{O()},[O]),(0,B.useEffect)(()=>()=>{D.current&&clearTimeout(D.current)},[]);let A=a.status===`populated`?a.domains:[],j=e=>{n||x||(c(RT(e)),E(null))},M=e=>{n||x||(f(RT(e)),E(null))},N=LT(s)&&l.length>0,P=d!==``,ee=!P||LT(d)&&p.length>0,F=N?`${s.replace(/-+$/,``)}.${l}`:``,te=P&&ee?`${d.replace(/-+$/,``)}.${p}`:``,I=!(te&&te===F),ne=zT(_),re=ne.every(e=>e.met),ie=a.status===`populated`&&N&&ee&&I&&re&&!x,L=s!==``&&!LT(s)?`Use lowercase letters, numbers, and hyphens. Start and end with a letter or number.`:null,ae=P&&!LT(d)?`Use lowercase letters, numbers, and hyphens. Start and end with a letter or number.`:I?null:`Public address must differ from the admin address.`,oe=T?.field===`admin`?T.message:null,se=T?.field===`public`?T.message:null,ce=T?.field===`password`?T.message:null,le=T?.field===`script`||T?.field===`request`?T.message:null,ue=()=>{w(!1),E(null),S(!1)},de=async()=>{if(!ie)return;if(!r){E({field:`request`,message:`No session key available — refresh the page.`});return}S(!0),E(null),w(!1);let e=new AbortController;D.current=setTimeout(()=>{e.abort(),w(!0)},BT);let n={session_key:r,adminLabel:s.replace(/-+$/,``),adminDomain:l,password:_};P&&(n.publicLabel=d.replace(/-+$/,``),n.publicDomain=p),h&&(n.apex=h);try{let r=await fetch(`/api/admin/cloudflare/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n),signal:e.signal});D.current&&clearTimeout(D.current),D.current=null;let i=await r.json();if(!i.ok){E({field:i.field,message:i.message,output:i.output,correlationId:i.correlationId,streamLogPath:i.streamLogPath});let e=i.streamLogPath?`\n\nstream log: ${i.streamLogPath}`:``;t(i.output&&i.output.length>0?`Cloudflare setup failed: ${i.message}\n\n${i.output}${e}`:`Cloudflare setup failed: ${i.message}${e}`),S(!1);return}t(i.output)}catch(t){if(D.current&&clearTimeout(D.current),D.current=null,e.signal.aborted)return;E({field:`script`,message:t instanceof Error?t.message:`Network error — try again.`}),S(!1)}},fe=(0,B.useMemo)(()=>s?`${s}.${l||`your-domain`}`:`your-name.${l||`your-domain`}`,[s,l]);if(a.status===`loading`)return(0,V.jsx)(k,{submitted:!1,actions:[],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[i?.title&&(0,V.jsx)(`div`,{className:`form-input__title`,children:i.title}),(0,V.jsx)(`div`,{className:`form-input__desc`,children:`Reading the domains on your Cloudflare account…`})]})});if(a.status===`empty`)return(0,V.jsx)(k,{submitted:!1,actions:[{label:`Retry`,variant:`primary`,onClick:O}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[(0,V.jsx)(`div`,{className:`form-input__title`,children:`No domains on this Cloudflare account`}),(0,V.jsx)(`div`,{className:`form-input__desc`,children:`Add a domain in the Cloudflare dashboard first, then click Retry.`}),(0,V.jsxs)(`ol`,{className:`form-input__field-desc`,style:{margin:0,paddingLeft:20},children:[(0,V.jsxs)(`li`,{children:[`With the correct account active (top-left), click `,(0,V.jsx)(`strong`,{children:`Websites`}),` in the left-hand sidebar.`]}),(0,V.jsxs)(`li`,{children:[`Click the `,(0,V.jsx)(`strong`,{children:`Add a site`}),` button.`]}),(0,V.jsxs)(`li`,{children:[`Enter the bare domain (e.g. `,(0,V.jsx)(`code`,{children:`example.com`}),`) and click `,(0,V.jsx)(`strong`,{children:`Continue`}),`.`]}),(0,V.jsxs)(`li`,{children:[`Review Cloudflare's imported DNS records — preserve website (`,(0,V.jsx)(`code`,{children:`A`}),`), email (`,(0,V.jsx)(`code`,{children:`MX`}),`), and verification (`,(0,V.jsx)(`code`,{children:`TXT`}),`) entries.`]}),(0,V.jsx)(`li`,{children:`Copy Cloudflare's two nameservers and set them on your domain registrar.`}),(0,V.jsxs)(`li`,{children:[`Return to Cloudflare and click `,(0,V.jsx)(`strong`,{children:`Check nameservers`}),`. Wait for the zone to show `,(0,V.jsx)(`strong`,{children:`Active`}),`.`]})]})]})});if(a.status===`error`){let e=a.field===`dashboard`,t=e?`Not signed into Cloudflare on this device`:`Could not read domains from Cloudflare`,n=e?`Sign in again at the Cloudflare dashboard in the VNC browser, then click Retry. If the VNC browser is not open, ask me to run vnc.sh restart.`:a.message;return(0,V.jsx)(k,{submitted:!1,actions:[{label:`Retry`,variant:`primary`,onClick:O}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[(0,V.jsx)(`div`,{className:`form-input__title`,children:t}),(0,V.jsx)(`div`,{className:`form-input__desc`,children:n}),a.output&&a.output.length>0&&(0,V.jsx)(`pre`,{style:{marginTop:8,padding:8,maxHeight:280,overflow:`auto`,fontFamily:`var(--font-mono, ui-monospace, monospace)`,fontSize:12,lineHeight:1.4,whiteSpace:`pre-wrap`,wordBreak:`break-word`,background:`var(--surface-2, rgba(0,0,0,0.04))`,borderRadius:4},children:HT(a.output)}),(a.correlationId||a.streamLogPath)&&(0,V.jsxs)(`div`,{style:{marginTop:8,fontFamily:`var(--font-mono, ui-monospace, monospace)`,fontSize:11,color:`var(--text-secondary)`,wordBreak:`break-all`},children:[a.correlationId&&(0,V.jsxs)(`div`,{children:[`conversationId: `,a.correlationId]}),a.streamLogPath&&(0,V.jsxs)(`div`,{children:[`stream log: `,a.streamLogPath]})]})]})})}return C?(0,V.jsx)(k,{submitted:!1,actions:[{label:`Reset form`,variant:`ghost`,onClick:ue}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[(0,V.jsx)(`div`,{className:`form-input__title`,children:`Setup is taking longer than expected`}),(0,V.jsx)(`div`,{className:`form-input__desc`,children:`The request is still running on the device — check the chat for live progress. Do not resubmit. If the script fails, the error will appear in chat and you can retry from there.`})]})}):(0,V.jsx)(k,{submitted:n,submittedLabel:`Submitting…`,actions:[{label:x?`Setting up…`:i?.submitLabel??`Set up Cloudflare`,variant:`primary`,disabled:!ie,onClick:de}],children:(0,V.jsxs)(`div`,{className:`form-input`,children:[i?.title&&(0,V.jsx)(`div`,{className:`form-input__title`,children:i.title}),i?.description&&(0,V.jsx)(`div`,{className:`form-input__desc`,children:i.description}),(0,V.jsxs)(`div`,{className:`form-input__fields`,children:[(0,V.jsxs)(`div`,{className:`form-input__field`,children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`cf-admin-label`,children:[`Admin address`,(0,V.jsx)(`span`,{className:`form-input__required`,children:`*`})]}),(0,V.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,V.jsx)(`input`,{id:`cf-admin-label`,className:`form-input__input tunnel-route__input`,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`your-name`,value:s,onChange:e=>j(e.target.value),disabled:n||x}),(0,V.jsx)(WT,{id:`cf-admin-domain`,value:l,options:A,onChange:u,disabled:n||x})]}),(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:`Where you access your platform remotely, via your main domain.`}),(0,V.jsxs)(`div`,{className:`form-input__field-desc`,children:[`Preview: `,(0,V.jsx)(`span`,{className:`tunnel-route__preview`,children:fe})]}),(oe||L)&&(0,V.jsx)(`div`,{className:`tunnel-route__error`,children:oe??L})]}),(0,V.jsxs)(`div`,{className:`form-input__field`,children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`cf-public-label`,children:[`Public address`,(0,V.jsx)(`span`,{className:`tunnel-route__optional`,children:`Optional`})]}),(0,V.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,V.jsx)(`input`,{id:`cf-public-label`,className:`form-input__input tunnel-route__input`,type:`text`,autoCapitalize:`none`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`leave empty to skip`,value:d,onChange:e=>M(e.target.value),disabled:n||x}),(0,V.jsx)(WT,{id:`cf-public-domain`,value:p,options:A,onChange:m,disabled:n||x||!P})]}),(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:`Where visitors engage with your public agents, via your main domain. Leave empty for admin-only access.`}),(se||ae)&&(0,V.jsx)(`div`,{className:`tunnel-route__error`,children:se??ae})]}),(0,V.jsxs)(`div`,{className:`form-input__field`,children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`cf-apex`,children:[`Proxy apex`,(0,V.jsx)(`span`,{className:`tunnel-route__optional`,children:`Optional`})]}),(0,V.jsxs)(`select`,{id:`cf-apex`,className:`form-input__input`,value:h,onChange:e=>g(e.target.value),disabled:n||x,children:[(0,V.jsx)(`option`,{value:``,children:`None`}),A.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]}),(0,V.jsx)(`div`,{className:`form-input__field-desc`,children:`Alternative domain for public agent visitors.`})]}),(0,V.jsxs)(`div`,{className:`form-input__field`,children:[(0,V.jsxs)(`label`,{className:`form-input__label`,htmlFor:`cf-password`,children:[`Admin password`,(0,V.jsx)(`span`,{className:`form-input__required`,children:`*`})]}),(0,V.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,V.jsx)(`input`,{id:`cf-password`,className:`form-input__input tunnel-route__input`,type:y?`text`:`password`,autoCapitalize:`none`,autoComplete:`new-password`,autoCorrect:`off`,spellCheck:!1,value:_,onChange:e=>{v(e.target.value),E(null)},disabled:n||x}),(0,V.jsx)(`button`,{type:`button`,className:`tunnel-route__suffix`,onClick:()=>b(e=>!e),disabled:n||x,style:{cursor:`pointer`,border:`none`,background:`inherit`},"aria-label":y?`Hide password`:`Show password`,children:y?`Hide`:`Show`})]}),(0,V.jsx)(`ul`,{className:`form-input__field-desc`,style:{margin:0,paddingLeft:16},children:ne.map(e=>(0,V.jsxs)(`li`,{style:{color:e.met?`var(--text)`:`var(--text-secondary)`},children:[e.met?`✓`:`○`,` `,e.label]},e.key))}),ce&&(0,V.jsx)(`div`,{className:`tunnel-route__error`,children:ce})]}),le&&(0,V.jsxs)(`div`,{className:`tunnel-route__error`,role:`alert`,children:[(0,V.jsx)(`div`,{children:le}),T?.output&&T.output.length>0&&(0,V.jsx)(`pre`,{style:{marginTop:8,padding:8,maxHeight:280,overflow:`auto`,fontFamily:`var(--font-mono, ui-monospace, monospace)`,fontSize:12,lineHeight:1.4,whiteSpace:`pre-wrap`,wordBreak:`break-word`,background:`var(--surface-2, rgba(0,0,0,0.04))`,borderRadius:4},children:HT(T.output)}),(T?.correlationId||T?.streamLogPath)&&(0,V.jsxs)(`div`,{style:{marginTop:8,fontFamily:`var(--font-mono, ui-monospace, monospace)`,fontSize:11,color:`var(--text-secondary)`,wordBreak:`break-all`},children:[T.correlationId&&(0,V.jsxs)(`div`,{children:[`conversationId: `,T.correlationId]}),T.streamLogPath&&(0,V.jsxs)(`div`,{children:[`stream log: `,T.streamLogPath]})]})]})]})]})})}function WT({id:e,value:t,options:n,onChange:r,disabled:i}){return(0,V.jsx)(`select`,{id:e,className:`tunnel-route__suffix`,value:t,onChange:e=>r(e.target.value),disabled:i,style:{cursor:i?`default`:`pointer`,border:`none`},children:n.map(e=>(0,V.jsxs)(`option`,{value:e,children:[`.`,e]},e))})}var GT={"single-select":x,"multi-select":ee,confirm:jt,"info-card":Mt,"action-list":Nt,form:Pt,progress:It,"browser-viewer":Rt,"document-editor":Pw,"rich-content-editor":Xw,"grid-editor":rT,"qr-code":jT,"file-attachment":PT,"action-buttons":M,"cloudflare-setup-form":UT,"output-style":x,"thinking-view":x,"plugin-selector":ee};function KT({name:e,data:t,onSubmit:n,submitted:r,isStreaming:i,sessionKey:a}){let o=GT[e];return o?(0,V.jsx)(o,{data:t,onSubmit:n,submitted:r,isStreaming:i,sessionKey:a}):(console.warn(`[ComponentRenderer] Unknown component: "${e}". Registered: ${Object.keys(GT).join(`, `)}`),(0,V.jsx)(`div`,{className:`component-card component-card--error`,children:(0,V.jsxs)(`p`,{style:{fontFamily:`var(--font-body)`,fontSize:12,color:`var(--text-secondary)`},children:[`Component “`,e,`” is not available. This may require a platform update.`]})}))}var qT=/\b(?:fail|error|unable|could not|cannot|CAPTCHA|SIGN_IN_REQUIRED)\b/i;function JT(e){let t=new Date(e),n=new Date,r=String(t.getHours()).padStart(2,`0`),i=String(t.getMinutes()).padStart(2,`0`);return t.toDateString()===n.toDateString()?`${r}:${i}`:`${String(t.getDate()).padStart(2,`0`)}-${String(t.getMonth()+1).padStart(2,`0`)}-${t.getFullYear()} ${r}:${i}`}var YT=[et,Xe,me,Je,Ee];function XT({size:e=13}){let[t,n]=(0,B.useState)(0);(0,B.useEffect)(()=>{let e=setInterval(()=>n(e=>(e+1)%8),300);return()=>clearInterval(e)},[]);let r=t<=4?t:8-t,i=YT[r];return(0,V.jsx)(i,{size:e,className:`star-loader star-frame-${r}`})}var ZT=[`Thinking`,`Reasoning`,`Analyzing`,`Considering`,`Reflecting`,`Evaluating`,`Weighing`,`Synthesizing`,`Processing`,`Exploring`,`Examining`,`Assessing`,`Reviewing`,`Contemplating`,`Deliberating`],QT=60,$T=1500;function eE(){let e=(0,B.useRef)(-1),t=(0,B.useRef)(void 0),[n,r]=(0,B.useState)(()=>{let t=Math.floor(Math.random()*ZT.length);return e.current=t,ZT[t]+`…`});return(0,B.useEffect)(()=>{let n=!1;function i(){let t;do t=Math.floor(Math.random()*ZT.length);while(t===e.current&&ZT.length>1);return e.current=t,t}function a(){if(n)return;let e=ZT[i()]+`…`,o=0;function s(){n||(o++,r(e.slice(0,o)),o<e.length?t.current=setTimeout(s,QT):t.current=setTimeout(a,$T))}t.current=setTimeout(s,QT)}return t.current=setTimeout(a,$T),()=>{n=!0,clearTimeout(t.current)}},[]),(0,V.jsx)(`span`,{className:`tl-thinking-typewriter`,children:n})}function tE(e,t){let n=e=>String(e??``);switch(e){case`Read`:return`Read ${n(t.file_path??t.path)}`;case`Write`:return`Write ${n(t.file_path??t.path)}`;case`Edit`:return`Edit ${n(t.file_path??t.path)}`;case`Bash`:return n(t.description??String(t.command??``).slice(0,70));case`Glob`:return`Glob ${n(t.pattern)}`;case`Grep`:return`Grep "${n(t.pattern)}" in ${n(t.path??`.`)}`;case`WebFetch`:return`Fetch ${n(t.url)}`;case`Agent`:return n(t.description??t.task??`Subagent`);case`Skill`:return n(t.skill??`Skill`);default:{let r=e.match(/^mcp__[^_]+__(.+)$/),i=r?r[1]:e,a=Object.keys(t)[0];return a?`${i}: ${n(t[a]).slice(0,50)}`:i}}}function nE({name:e,size:t=12}){let n=e.match(/^mcp__[^_]+__(.+)$/);switch(n?n[1]:e){case`Read`:return(0,V.jsx)(c,{size:t});case`Write`:return(0,V.jsx)(je,{size:t});case`Edit`:return(0,V.jsx)(Ae,{size:t});case`Bash`:return(0,V.jsx)(tt,{size:t});case`Glob`:case`Grep`:return(0,V.jsx)(ae,{size:t});case`WebFetch`:return(0,V.jsx)(O,{size:t});case`Agent`:return(0,V.jsx)(_e,{size:t});case`Skill`:return(0,V.jsx)(Xe,{size:t});case`memory-search`:return(0,V.jsx)(Te,{size:t});case`memory-write`:return(0,V.jsx)(we,{size:t});case`task-list`:return(0,V.jsx)(R,{size:t});case`task-create`:return(0,V.jsx)(Se,{size:t});case`contact-create`:return(0,V.jsx)(nt,{size:t});default:return(0,V.jsx)(rt,{size:t})}}function rE(e){let t=new Map,n=new Map;return e.forEach((e,r)=>{if(e.type===`tool_use`){let t=n.get(e.name)??[];t.push(r),n.set(e.name,t)}else if(e.type===`tool_result`){let i=n.get(e.name);i?.length&&t.set(i.shift(),r)}}),t}function iE(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function aE(e){let t=``;switch(e.type){case`text`:case`thinking`:t=e.content??``;break;case`tool_use`:t=JSON.stringify(e.input??{});break;case`tool_result`:t=e.output??``;break;case`subagent_start`:t=e.task??``;break;case`subagent_end`:t=e.result??``;break;case`component`:t=JSON.stringify(e.data??{});break;case`status`:t=e.message??``;break;default:return 0}return Math.ceil(t.length/4)}function oE(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function sE(e){if(e<60)return`${e.toFixed(1)}s`;let t=Math.floor(e/60),n=e%60;return n>=.1?`${t}m ${Math.floor(n)}s`:`${t}m`}function cE({icon:e,isPending:t,isError:n,doneClass:r=`tl-done`,summary:i,detail:a,tokens:o,elapsed:s,isLast:c,expanded:l,onToggle:u,selectCheck:d}){let f=!!a;return(0,V.jsxs)(`div`,{className:`tl-step`,children:[d,(0,V.jsxs)(`div`,{className:`tl-col`,children:[(0,V.jsx)(`div`,{className:`tl-icon${t?` tl-pending`:n?` tl-error`:` ${r}`}`,children:e}),!c&&(0,V.jsx)(`div`,{className:`tl-line tl-line-grow`})]}),(0,V.jsxs)(`div`,{className:`tl-body`,children:[(0,V.jsxs)(`div`,{className:`tl-row`,onClick:f?()=>{window.getSelection()?.toString()||u()}:void 0,style:{cursor:f?`pointer`:`default`},children:[(0,V.jsx)(`span`,{className:`tl-summary`,children:i}),o>0&&(0,V.jsxs)(`span`,{className:`tl-step-tokens`,children:[(0,V.jsx)(it,{size:9}),iE(o)]}),(0,V.jsx)(`span`,{className:`tl-step-elapsed`,children:sE(s)}),f&&(0,V.jsx)(`span`,{className:`tl-chevron`,children:l?(0,V.jsx)(p,{size:10}):(0,V.jsx)(ye,{size:10})})]}),f&&l&&(0,V.jsx)(`pre`,{className:`tl-detail`,children:a})]})]})}function lE({events:e,isStreaming:t,elapsedSeconds:n,streamStartMs:r,expandAll:i,onCompactNow:a,isCompacting:o,sessionCompacted:s,onComponentSubmit:c,submittedComponents:l,timestamp:u,selectionMode:d,selectedItems:f,onToggleItem:m,sessionKey:g}){let[_,v]=(0,B.useState)(new Set),[y,b]=(0,B.useState)(!t),x=(0,B.useRef)(t);(0,B.useEffect)(()=>{x.current&&!t&&b(!0),!x.current&&t&&b(!1),x.current=t},[t]);let C=(0,B.useRef)(new Map),E=(0,B.useRef)(0),[D,O]=(0,B.useState)(Date.now());(0,B.useEffect)(()=>{let t=Date.now();for(let n=E.current;n<e.length;n++)C.current.has(n)||C.current.set(n,t);E.current=e.length},[e]),(0,B.useEffect)(()=>{if(!t)return;let e=setInterval(()=>O(Date.now()),100);return()=>clearInterval(e)},[t]);let k=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},A=(e,t)=>{let n=e===L[0]?.i&&r?r:C.current.get(e)??D,i=t===void 0?D:C.current.get(t)??D;return Math.max(0,(i-n)/1e3)},j=rE(e),M=new Set(j.values()),N=e.map((e,t)=>({e,i:t})).filter(({e})=>e.type===`text`),P=new Set(t?[]:e.map((e,t)=>({e,i:t})).filter(({e})=>e.type===`component`).map(({i:e})=>e)),ee=e=>e.type===`component`&&[`browser-viewer`,`qr-code`].includes(e.name);function F(e){if(!d||t||!u)return null;let n=`${u}_${e}`;return(0,V.jsx)(`div`,{className:`tl-select-check`,onClick:e=>e.stopPropagation(),children:(0,V.jsx)(w,{checked:f?.has(n)??!1,onChange:()=>m?.(n)})})}let I=e.findLast(e=>e.type===`usage`),ne=e.findLast(e=>e.type===`history_usage`),re=e.findLast(e=>e.type===`status`),ie=e.some(e=>e.type===`subagent_start`),L=e.map((e,t)=>({e,i:t})).filter(({e,i:n})=>e.type!==`text`&&e.type!==`usage`&&e.type!==`rate_limit`&&e.type!==`history_usage`&&e.type!==`status`&&e.type!==`done`&&e.type!==`subagent_progress`&&!M.has(n)&&!P.has(n)&&!(t&&e.type===`component`&&!ee(e))&&!(e.type===`tool_use`&&e.name===`Agent`&&ie)),ae=new Map;for(let e=0;e<L.length-1;e++)ae.set(L[e].i,L[e+1].i);let oe=(()=>{let e=[],t=!1,n=0;for(let{e:r}of L)if(n+=aE(r),r.type===`thinking`)t=!0;else if(r.type===`tool_use`){let t=r.name;e.includes(t)||e.push(t)}let r=[`${L.length} step${L.length===1?``:`s`}`];if(e.length>0){let t=e.slice(0,3),n=e.length-t.length;r.push(t.join(`, `)+(n>0?` +${n}`:``))}return{text:r.join(` · `),hasThinking:t,tokenSum:n}})(),se=I?.peak_request_pct==null?I?.context_window?Math.round((I.input_tokens+I.cache_creation_tokens+I.cache_read_tokens)/I.context_window*100):null:Math.round(I.peak_request_pct*100),ce=L.length>0,le=N.length>0,ue=new Set(L.map(e=>e.i)),de=new Set(N.map(e=>e.i)),me=[];for(let t=0;t<e.length;t++){let n=e[t],r=null;if(ue.has(t)?r=`steps`:de.has(t)&&(r=`text`),!r)continue;let i=me[me.length-1];i&&i.role===r?i.items.push({e:n,i:t}):me.push({role:r,items:[{e:n,i:t}]})}let he=N.length>0?N[N.length-1].i:-1;function ge(n,r,a,o){let s=o===a.length-1;if(n.type===`thinking`){let e=i===void 0?!_.has(r):i,t=ae.get(r);return(0,V.jsxs)(`div`,{className:`tl-step`,children:[F(r),(0,V.jsxs)(`div`,{className:`tl-col`,children:[(0,V.jsx)(`div`,{className:`tl-icon tl-dim`,children:(0,V.jsx)(Le,{size:11})}),!s&&(0,V.jsx)(`div`,{className:`tl-line tl-line-grow`})]}),(0,V.jsx)(`div`,{className:`tl-body`,children:(0,V.jsxs)(`div`,{className:`tl-row tl-row-top`,onClick:()=>{window.getSelection()?.toString()||k(r)},style:{cursor:`pointer`},children:[(0,V.jsx)(`div`,{className:`tl-thinking-col`,children:e?(0,V.jsx)(`div`,{className:`tl-thinking-body`,children:n.content}):(0,V.jsxs)(`span`,{className:`tl-summary tl-thinking-label`,children:[n.content.slice(0,80),n.content.length>80?`…`:``]})}),aE(n)>0&&(0,V.jsxs)(`span`,{className:`tl-step-tokens`,children:[(0,V.jsx)(it,{size:9}),iE(aE(n))]}),(0,V.jsx)(`span`,{className:`tl-step-elapsed`,children:sE(A(r,t))}),(0,V.jsx)(`span`,{className:`tl-chevron`,children:e?(0,V.jsx)(p,{size:10}):(0,V.jsx)(ye,{size:10})})]})})]},r)}if(n.type===`status`)return(0,V.jsx)(`div`,{className:`tl-status`,children:n.message},r);if(n.type===`tool_use`){let t=j.get(r),a=t===void 0?void 0:e[t],o=a===void 0,c=a?.type===`tool_result`&&!!a.error,l=o?(0,V.jsx)(Be,{size:11,className:`tl-spinner`}):c?(0,V.jsx)(fe,{size:11}):(0,V.jsx)(nE,{name:n.name,size:11}),u=n,d=a?.type===`tool_result`?`Input:
|
|
344
344
|
${JSON.stringify(u.input,null,2)}
|
|
345
345
|
|
|
346
346
|
Result:
|
|
347
347
|
${a.output}`:`Input:
|
|
348
|
-
${JSON.stringify(u.input,null,2)}`,f=ae.get(r),p=o?void 0:f??t;return(0,V.jsx)(cE,{icon:l,isPending:o,isError:c,doneClass:u.name===`Read`?`tl-done`:`tl-success`,summary:tE(u.name,u.input),detail:d,tokens:aE(n),elapsed:A(r,p),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>k(r),selectCheck:F(r)},r)}if(n.type===`subagent_start`){let t=n,a=e.some(e=>e.type===`subagent_end`&&e.name===t.name),o=a?e.findIndex(e=>e.type===`subagent_end`&&e.name===t.name):void 0,c=t.background===!0,l=t.task.slice(0,60)+(t.task.length>60?`…`:``),u=t.task;if(c&&!a){let n=[...e].reverse().find(e=>e.type===`subagent_progress`&&e.name===t.name);n?.last_tool_name&&(u=`${t.task}\nLast tool: ${n.last_tool_name} (${n.tool_uses??0} calls)`)}let d=a?e.find(e=>e.type===`subagent_end`&&e.name===t.name):void 0,f=a&&d?qT.test(d.result):!1;return(0,V.jsx)(cE,{icon:a?f?(0,V.jsx)(fe,{size:11}):(0,V.jsx)(_e,{size:11}):(0,V.jsx)(Be,{size:11,className:`tl-spinner`}),isPending:!a,isError:f,summary:c?`${t.name} (background) — ${l}`:`${t.name} — ${l}`,detail:c?u:t.task,tokens:aE(n),elapsed:A(r,o),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>k(r),selectCheck:F(r)},r)}if(n.type===`component`){let e=l?.has(`${u}_${r}`)??!1,i=n;return(0,V.jsxs)(`div`,{className:`tl-step`,children:[F(r),(0,V.jsxs)(`div`,{className:`tl-col`,children:[(0,V.jsx)(`div`,{className:`tl-icon ${e?`tl-done`:`tl-pending`}`,children:(0,V.jsx)(Ke,{size:11})}),!s&&(0,V.jsx)(`div`,{className:`tl-line tl-line-grow`})]}),(0,V.jsx)(`div`,{className:`tl-body`,children:(0,V.jsx)(KT,{name:i.name,data:i.data,submitted:e,onSubmit:e=>c?.(r,e,i.name),isStreaming:t,sessionKey:g})})]},r)}if(n.type===`subagent_end`){let e=n,t=qT.test(e.result);return(0,V.jsx)(cE,{icon:t?(0,V.jsx)(fe,{size:11}):(0,V.jsx)(h,{size:11}),isPending:!1,isError:t,summary:`${e.name} ${t?`failed`:`complete`}`,detail:e.result,tokens:aE(n),elapsed:A(r,ae.get(r)),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>k(r),selectCheck:F(r)},r)}if(n.type===`script_stream`){let e=n,t=e.line.match(/https:\/\/dash\.cloudflare\.com\/argotunnel\?[^\s]+/)?.[0],i=t?JSON.stringify({url:t,intent:`Cloudflare tunnel authorization`}):void 0;return(0,V.jsxs)(`div`,{className:`tl-script-stream`,children:[(0,V.jsxs)(`div`,{className:`tl-script-stream-line`,children:[(0,V.jsxs)(`span`,{className:`tl-script-stream-source`,children:[`[`,e.source,`]`]}),(0,V.jsx)(`span`,{className:`tl-script-stream-content`,children:e.line})]}),i&&(0,V.jsx)(S,{source:i})]},r)}return null}return(0,V.jsxs)(`div`,{className:`admin-activity`,children:[ce&&!t&&i===void 0&&(0,V.jsx)(`div`,{className:`tl-steps`,children:(0,V.jsxs)(`div`,{className:`tl-step tl-summary-row`,onClick:()=>{window.getSelection()?.toString()||b(e=>!e)},children:[(0,V.jsx)(`div`,{className:`tl-col`,children:(0,V.jsx)(`div`,{className:`tl-icon tl-done`,children:oe.hasThinking?(0,V.jsx)(Le,{size:11}):(0,V.jsx)(h,{size:11})})}),(0,V.jsx)(`div`,{className:`tl-body`,children:(0,V.jsxs)(`div`,{className:`tl-row`,style:{cursor:`pointer`},children:[(0,V.jsx)(`span`,{className:`tl-summary`,children:oe.text}),oe.tokenSum>0&&(0,V.jsxs)(`span`,{className:`tl-step-tokens`,children:[(0,V.jsx)(it,{size:9}),iE(oe.tokenSum)]}),(0,V.jsx)(`span`,{className:`tl-step-elapsed`,children:oE(n)}),(0,V.jsx)(`span`,{className:`tl-chevron`,children:y?(0,V.jsx)(ye,{size:10}):(0,V.jsx)(p,{size:10})})]})})]})}),me.map((e,n)=>e.role===`steps`?!t&&i===void 0&&y?null:(0,V.jsx)(`div`,{className:`tl-steps`,children:e.items.map(({e:t,i:n},r)=>ge(t,n,e.items,r))},`seg-${n}`):e.items.map(({e,i:n})=>{let r=e,i=n===he;return(0,V.jsxs)(`div`,{className:`tl-text-block`,onClick:d&&!t&&u?()=>m?.(`${u}_${n}`):void 0,style:d&&!t?{cursor:`pointer`}:void 0,children:[F(n),(0,V.jsx)(te,{content:r.content,timestamp:!t&&i&&u?JT(u):void 0})]},n)})),t&&!le&&(0,V.jsxs)(`div`,{className:`tl-loading`,children:[(0,V.jsx)(XT,{size:13}),(0,V.jsx)(eE,{}),(0,V.jsx)(`span`,{className:`tl-elapsed`,children:oE(n)})]}),!t&&P.size>0&&(0,V.jsx)(`div`,{className:`tl-post-components`,children:e.map((e,t)=>({e,i:t})).filter(({i:e})=>P.has(e)).map(({e,i:n})=>{if(e.type!==`component`)return null;let r=l?.has(`${u}_${n}`)??!1;return(0,V.jsx)(KT,{name:e.name,data:e.data,submitted:r,onSubmit:t=>c?.(n,t,e.name),isStreaming:t,sessionKey:g},n)})}),(le||!t&&ce)&&(0,V.jsxs)(`div`,{className:`tl-footer`,children:[t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(XT,{size:10}),(0,V.jsx)(eE,{})]}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat`,children:[(0,V.jsx)(Se,{size:10}),oE(n)]}),I?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat`,children:[(0,V.jsx)(it,{size:10}),iE(I.input_tokens+I.cache_creation_tokens+I.cache_read_tokens+I.output_tokens)]})]}):t&&oe.tokenSum>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat tl-footer-est`,children:[(0,V.jsx)(it,{size:10}),`~`,iE(oe.tokenSum)]})]}):null,ne&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-pct${ne.budget>0&&ne.tokens/ne.budget>=.7?` tl-ctx-high`:ne.budget>0&&ne.tokens/ne.budget>=.5?` tl-ctx-mid`:``}`,children:[(0,V.jsx)(Ue,{size:10}),ne.messages]})]}),s?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-compacted`,children:[(0,V.jsx)(pe,{size:10}),`compacted`]})]}):se===null?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),!s&&a&&!t?(0,V.jsxs)(T,{variant:`ghost`,size:`sm`,className:`tl-footer-icon-stat tl-ctx-pct${se>=70?` tl-ctx-high`:se>=50?` tl-ctx-mid`:``}`,style:{padding:0,fontSize:`11px`},onClick:a,children:[(0,V.jsx)(pe,{size:10}),se,`%`]}):(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-pct${se>=70?` tl-ctx-high`:se>=50?` tl-ctx-mid`:``}`,children:[(0,V.jsx)(pe,{size:10}),se,`%`]})]}),o||t&&re?(0,V.jsxs)(`span`,{className:`tl-footer-status`,children:[(0,V.jsx)(Be,{size:10,className:`tl-spinner`}),re?.message??`Compacting session...`]}):null]})]})}function uE(e){let{messages:t,isStreaming:n,elapsedSeconds:r,sessionTurnStart:i,expandAll:a,setExpandAll:o,conversationCompacted:s,isCompacting:l,setShowCompactConfirm:u,handleComponentSubmit:d,effectiveSubmitted:f,selectionMode:m,selectedItems:h,toggleSelectItem:g,sessionKey:_,setLightboxSrc:v,messageQueue:b,messageQueueRef:x,setQueue:S,sendMessage:C,appState:T,onboardingComplete:E}=e,O=(0,B.useRef)(null),k=(0,B.useRef)(null),A=(0,B.useRef)(null),j=(0,B.useRef)(!1),[M,N]=B.useState(!0);(0,B.useEffect)(()=>{if(!M){j.current=n;return}if(j.current&&!n&&A.current&&k.current){let e=A.current;if(e.offsetHeight>k.current.clientHeight){e.scrollIntoView({behavior:`smooth`,block:`start`}),j.current=n;return}}O.current?.scrollIntoView({behavior:`smooth`}),j.current=n},[t,b,M,n]),(0,B.useEffect)(()=>{if(T!==`chat`)return;let e=k.current;if(!e)return;let t=()=>{N(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[T]);let P=[...t].sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),ee=P.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,V.jsxs)(`div`,{className:`chat-messages-wrap`,children:[m&&(0,V.jsx)(`div`,{className:`selection-overlay-band`}),(0,V.jsxs)(`div`,{className:`chat-messages`,ref:k,children:[t.length===0&&T===`chat`&&E!==!1&&(0,V.jsxs)(`div`,{className:`idle-tips`,children:[(0,V.jsx)(`p`,{className:`idle-tips-hint`,children:`What would you like to do?`}),(0,V.jsx)(`div`,{className:`idle-tips-chips`,children:[`What needs doing?`,`Start a new task`].map(e=>(0,V.jsx)(`button`,{type:`button`,className:`idle-tip-chip`,onClick:()=>C(e),children:e},e))})]}),P.map((e,t,o)=>{if(e.hidden)return null;let p=n&&t===o.length-1,b=e.role,x=`${e.timestamp??0}_admin`,S=b===`admin`&&h.has(x),C=(t>0?o[t-1]:null)?.historical&&!e.historical;return(0,V.jsxs)(B.Fragment,{children:[C&&(0,V.jsx)(`div`,{className:`resume-divider`,children:(0,V.jsx)(`span`,{children:`Resumed conversation`})}),(0,V.jsxs)(`div`,{ref:t===ee?A:void 0,className:`message ${b===`admin`?`visitor`:`maxy`}${S?` selected`:``}${e.historical?` message-historical`:``}`,children:[m&&!p&&b===`admin`&&(0,V.jsx)(`div`,{className:`message-select-check`,children:(0,V.jsx)(w,{checked:S,onChange:()=>g(x)})}),e.role===`admin`?(0,V.jsxs)(`div`,{className:`bubble`,children:[e.content,e.attachments&&e.attachments.length>0&&(0,V.jsx)(`div`,{className:`message-attachments`,children:e.attachments.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,className:`message-attachment-chip${e.attachmentId&&_?``:` no-action`}`,onClick:()=>{if(!e.attachmentId||!_)return;let t=`/api/admin/attachment/${e.attachmentId}?session_key=${encodeURIComponent(_)}`;e.mimeType.startsWith(`image/`)?v(t):window.open(t,`_blank`)},children:[e.mimeType===`application/pdf`?(0,V.jsx)(c,{size:12}):e.mimeType.startsWith(`text/`)?(0,V.jsx)(D,{size:12}):null,(0,V.jsx)(`span`,{children:e.filename})]},t))}),(0,V.jsx)(`span`,{className:`message-timestamp`,children:y(e.timestamp)})]}):(0,V.jsx)(`div`,{className:`maxy-content-wrap`,children:(0,V.jsx)(lE,{events:e.events??[],isStreaming:p,elapsedSeconds:t===o.length-1?r:e.elapsedSeconds??0,streamStartMs:t===o.length-1?i.current??void 0:void 0,expandAll:a,onCompactNow:t===o.length-1&&!s?()=>u(!0):void 0,isCompacting:t===o.length-1?l:void 0,sessionCompacted:t===o.length-1?s:void 0,onComponentSubmit:(t,n,r)=>d(e.timestamp,t,n,r),submittedComponents:f,timestamp:e.timestamp,selectionMode:m,selectedItems:h,onToggleItem:g,sessionKey:_})})]})]},t)}),b.map((e,t)=>(0,V.jsx)(`div`,{className:`message visitor`,children:(0,V.jsxs)(`div`,{className:`bubble bubble-queued`,children:[e.text||null,e.files.length>0&&(0,V.jsx)(`div`,{className:`message-attachments`,children:e.files.map((e,t)=>(0,V.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.type===`application/pdf`?(0,V.jsx)(c,{size:12}):e.type.startsWith(`text/`)?(0,V.jsx)(D,{size:12}):null,(0,V.jsx)(`span`,{children:e.name})]},t))}),(0,V.jsx)(`span`,{className:`message-timestamp`,children:y(e.timestamp)}),(0,V.jsx)(`button`,{type:`button`,className:`queued-bubble-delete`,onClick:()=>S(x.current.filter((e,n)=>n!==t)),"aria-label":`Remove queued message`,children:`×`})]})},e.timestamp)),(0,V.jsx)(`div`,{ref:O})]}),!M&&(0,V.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>O.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,V.jsx)(p,{size:18})}),t.some(e=>e.role===`maxy`)&&(0,V.jsx)(`button`,{className:`expand-toggle expand-toggle-${a===void 0?`default`:a?`all`:`off`}`,onClick:()=>o(e=>e===void 0?!0:e===!0?!1:void 0),"aria-label":a===void 0?`Expand all`:a?`Collapse all`:`Reset to default`,children:a===!1?(0,V.jsx)(Ie,{size:14}):(0,V.jsx)(Le,{size:14})})]})}function dE({offer:e,onFreshStart:t,onContinue:n,disabled:r}){return e.active?(0,V.jsxs)(`div`,{className:`topic-change-bar`,children:[(0,V.jsx)(`div`,{className:`topic-change-bar__icon`,children:(0,V.jsx)(Me,{size:16})}),(0,V.jsxs)(`div`,{className:`topic-change-bar__actions`,children:[(0,V.jsx)(T,{variant:`primary`,size:`sm`,onClick:t,disabled:r,children:`Start fresh`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,onClick:n,disabled:r,children:`Continue here`})]})]}):null}function fE(e,t){let n=t.lastIndexOf(`_`),r=t.slice(0,n),i=t.slice(n+1),a=parseInt(r,10),o=i===`admin`?`admin`:`maxy`,s=e.find(e=>e.timestamp===a&&e.role===o);if(!s)return``;if(i===`admin`)return s.content??``;let c=parseInt(i,10),l=s.events?.[c];if(!l)return``;if(l.type===`text`||l.type===`thinking`)return l.content;if(l.type===`tool_use`){let e=l,t=`[Tool: ${e.name}]`,n=`Input:\n${JSON.stringify(e.input,null,2)}`,r=s.events??[],i=``;for(let t=c+1;t<r.length;t++){let n=r[t];if(n.type===`tool_result`&&n.name===e.name){i=`\n\nResult:\n${n.output}`;break}}return`${t}\n${n}${i}`}if(l.type===`subagent_start`){let e=l,t=s.events??[],n=``;for(let r=c+1;r<t.length;r++){let i=t[r];if(i.type===`subagent_end`&&i.name===e.name){n=`\n\nResult:\n${i.result}`;break}}return`[${e.name}: ${e.task}]${n}`}return``}function pE(e,t){let n=[...e].sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),r=[];for(let e of n)if(!e.hidden)if(e.role===`admin`)(t===`all`||t===`text`)&&r.push(`User:\n${e.content}`);else{let n=e.events??[];for(let e=0;e<n.length;e++){let i=n[e];if(i.type===`text`&&(t===`all`||t===`text`))r.push(`Maxy:\n${i.content}`);else if(i.type===`thinking`&&(t===`all`||t===`non-text`))r.push(`Maxy [thinking]:\n${i.content}`);else if(i.type===`tool_use`&&(t===`all`||t===`non-text`)){let t=i,a=``;for(let r=e+1;r<n.length;r++)if(n[r].type===`tool_result`&&n[r].name===t.name){a=`\n\nResult:\n${n[r].output}`;break}r.push(`Maxy [tool: ${t.name}]:\nInput:\n${JSON.stringify(t.input,null,2)}${a}`)}else if(i.type===`subagent_start`&&(t===`all`||t===`non-text`)){let t=i,a=``;for(let r=e+1;r<n.length;r++)if(n[r].type===`subagent_end`&&n[r].name===t.name){a=`\n\nResult:\n${n[r].result}`;break}r.push(`Maxy [agent: ${t.name}]\nTask: ${t.task}${a}`)}}}return r.join(`
|
|
348
|
+
${JSON.stringify(u.input,null,2)}`,f=ae.get(r),p=o?void 0:f??t;return(0,V.jsx)(cE,{icon:l,isPending:o,isError:c,doneClass:u.name===`Read`?`tl-done`:`tl-success`,summary:tE(u.name,u.input),detail:d,tokens:aE(n),elapsed:A(r,p),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>k(r),selectCheck:F(r)},r)}if(n.type===`subagent_start`){let t=n,a=e.some(e=>e.type===`subagent_end`&&e.name===t.name),o=a?e.findIndex(e=>e.type===`subagent_end`&&e.name===t.name):void 0,c=t.background===!0,l=t.task.slice(0,60)+(t.task.length>60?`…`:``),u=t.task;if(c&&!a){let n=[...e].reverse().find(e=>e.type===`subagent_progress`&&e.name===t.name);n?.last_tool_name&&(u=`${t.task}\nLast tool: ${n.last_tool_name} (${n.tool_uses??0} calls)`)}let d=a?e.find(e=>e.type===`subagent_end`&&e.name===t.name):void 0,f=a&&d?qT.test(d.result):!1;return(0,V.jsx)(cE,{icon:a?f?(0,V.jsx)(fe,{size:11}):(0,V.jsx)(_e,{size:11}):(0,V.jsx)(Be,{size:11,className:`tl-spinner`}),isPending:!a,isError:f,summary:c?`${t.name} (background) — ${l}`:`${t.name} — ${l}`,detail:c?u:t.task,tokens:aE(n),elapsed:A(r,o),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>k(r),selectCheck:F(r)},r)}if(n.type===`component`){let e=l?.has(`${u}_${r}`)??!1,i=n;return(0,V.jsxs)(`div`,{className:`tl-step`,children:[F(r),(0,V.jsxs)(`div`,{className:`tl-col`,children:[(0,V.jsx)(`div`,{className:`tl-icon ${e?`tl-done`:`tl-pending`}`,children:(0,V.jsx)(Ke,{size:11})}),!s&&(0,V.jsx)(`div`,{className:`tl-line tl-line-grow`})]}),(0,V.jsx)(`div`,{className:`tl-body`,children:(0,V.jsx)(KT,{name:i.name,data:i.data,submitted:e,onSubmit:e=>c?.(r,e,i.name),isStreaming:t,sessionKey:g})})]},r)}if(n.type===`subagent_end`){let e=n,t=qT.test(e.result);return(0,V.jsx)(cE,{icon:t?(0,V.jsx)(fe,{size:11}):(0,V.jsx)(h,{size:11}),isPending:!1,isError:t,summary:`${e.name} ${t?`failed`:`complete`}`,detail:e.result,tokens:aE(n),elapsed:A(r,ae.get(r)),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>k(r),selectCheck:F(r)},r)}if(n.type===`script_stream`){let e=n,t=e.line.match(/https:\/\/dash\.cloudflare\.com\/argotunnel\?[^\s]+/)?.[0],i=t?JSON.stringify({url:t,intent:`Cloudflare tunnel authorization`}):void 0;return(0,V.jsxs)(`div`,{className:`tl-script-stream`,children:[(0,V.jsxs)(`div`,{className:`tl-script-stream-line`,children:[(0,V.jsxs)(`span`,{className:`tl-script-stream-source`,children:[`[`,e.source,`]`]}),(0,V.jsx)(`span`,{className:`tl-script-stream-content`,children:e.line})]}),i&&(0,V.jsx)(S,{source:i})]},r)}return null}return(0,V.jsxs)(`div`,{className:`admin-activity`,children:[ce&&!t&&i===void 0&&(0,V.jsx)(`div`,{className:`tl-steps`,children:(0,V.jsxs)(`div`,{className:`tl-step tl-summary-row`,onClick:()=>{window.getSelection()?.toString()||b(e=>!e)},children:[(0,V.jsx)(`div`,{className:`tl-col`,children:(0,V.jsx)(`div`,{className:`tl-icon tl-done`,children:oe.hasThinking?(0,V.jsx)(Le,{size:11}):(0,V.jsx)(h,{size:11})})}),(0,V.jsx)(`div`,{className:`tl-body`,children:(0,V.jsxs)(`div`,{className:`tl-row`,style:{cursor:`pointer`},children:[(0,V.jsx)(`span`,{className:`tl-summary`,children:oe.text}),oe.tokenSum>0&&(0,V.jsxs)(`span`,{className:`tl-step-tokens`,children:[(0,V.jsx)(it,{size:9}),iE(oe.tokenSum)]}),(0,V.jsx)(`span`,{className:`tl-step-elapsed`,children:oE(n)}),(0,V.jsx)(`span`,{className:`tl-chevron`,children:y?(0,V.jsx)(ye,{size:10}):(0,V.jsx)(p,{size:10})})]})})]})}),me.map((e,n)=>e.role===`steps`?!t&&i===void 0&&y?null:(0,V.jsx)(`div`,{className:`tl-steps`,children:e.items.map(({e:t,i:n},r)=>ge(t,n,e.items,r))},`seg-${n}`):e.items.map(({e,i:n})=>{let r=e,i=n===he;return(0,V.jsxs)(`div`,{className:`tl-text-block`,onClick:d&&!t&&u?()=>m?.(`${u}_${n}`):void 0,style:d&&!t?{cursor:`pointer`}:void 0,children:[F(n),(0,V.jsx)(te,{content:r.content,timestamp:!t&&i&&u?JT(u):void 0})]},n)})),t&&!le&&(0,V.jsxs)(`div`,{className:`tl-loading`,children:[(0,V.jsx)(XT,{size:13}),(0,V.jsx)(eE,{}),(0,V.jsx)(`span`,{className:`tl-elapsed`,children:oE(n)})]}),!t&&P.size>0&&(0,V.jsx)(`div`,{className:`tl-post-components`,children:e.map((e,t)=>({e,i:t})).filter(({i:e})=>P.has(e)).map(({e,i:n})=>{if(e.type!==`component`)return null;let r=l?.has(`${u}_${n}`)??!1;return(0,V.jsx)(KT,{name:e.name,data:e.data,submitted:r,onSubmit:t=>c?.(n,t,e.name),isStreaming:t,sessionKey:g},n)})}),(le||!t&&ce)&&(0,V.jsxs)(`div`,{className:`tl-footer`,children:[t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(XT,{size:10}),(0,V.jsx)(eE,{})]}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat`,children:[(0,V.jsx)(z,{size:10}),oE(n)]}),I?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat`,children:[(0,V.jsx)(it,{size:10}),iE(I.input_tokens+I.cache_creation_tokens+I.cache_read_tokens+I.output_tokens)]})]}):t&&oe.tokenSum>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat tl-footer-est`,children:[(0,V.jsx)(it,{size:10}),`~`,iE(oe.tokenSum)]})]}):null,ne&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-pct${ne.budget>0&&ne.tokens/ne.budget>=.7?` tl-ctx-high`:ne.budget>0&&ne.tokens/ne.budget>=.5?` tl-ctx-mid`:``}`,children:[(0,V.jsx)(Ue,{size:10}),ne.messages]})]}),s?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-compacted`,children:[(0,V.jsx)(pe,{size:10}),`compacted`]})]}):se===null?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),!s&&a&&!t?(0,V.jsxs)(T,{variant:`ghost`,size:`sm`,className:`tl-footer-icon-stat tl-ctx-pct${se>=70?` tl-ctx-high`:se>=50?` tl-ctx-mid`:``}`,style:{padding:0,fontSize:`11px`},onClick:a,children:[(0,V.jsx)(pe,{size:10}),se,`%`]}):(0,V.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-pct${se>=70?` tl-ctx-high`:se>=50?` tl-ctx-mid`:``}`,children:[(0,V.jsx)(pe,{size:10}),se,`%`]})]}),o||t&&re?(0,V.jsxs)(`span`,{className:`tl-footer-status`,children:[(0,V.jsx)(Be,{size:10,className:`tl-spinner`}),re?.message??`Compacting session...`]}):null]})]})}function uE(e){let{messages:t,isStreaming:n,elapsedSeconds:r,sessionTurnStart:i,expandAll:a,setExpandAll:o,conversationCompacted:s,isCompacting:l,setShowCompactConfirm:u,handleComponentSubmit:d,effectiveSubmitted:f,selectionMode:m,selectedItems:h,toggleSelectItem:g,sessionKey:_,setLightboxSrc:v,messageQueue:b,messageQueueRef:x,setQueue:S,sendMessage:C,appState:T,onboardingComplete:E}=e,O=(0,B.useRef)(null),k=(0,B.useRef)(null),A=(0,B.useRef)(null),j=(0,B.useRef)(!1),[M,N]=B.useState(!0);(0,B.useEffect)(()=>{if(!M){j.current=n;return}if(j.current&&!n&&A.current&&k.current){let e=A.current;if(e.offsetHeight>k.current.clientHeight){e.scrollIntoView({behavior:`smooth`,block:`start`}),j.current=n;return}}O.current?.scrollIntoView({behavior:`smooth`}),j.current=n},[t,b,M,n]),(0,B.useEffect)(()=>{if(T!==`chat`)return;let e=k.current;if(!e)return;let t=()=>{N(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[T]);let P=[...t].sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),ee=P.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,V.jsxs)(`div`,{className:`chat-messages-wrap`,children:[m&&(0,V.jsx)(`div`,{className:`selection-overlay-band`}),(0,V.jsxs)(`div`,{className:`chat-messages`,ref:k,children:[t.length===0&&T===`chat`&&E!==!1&&(0,V.jsxs)(`div`,{className:`idle-tips`,children:[(0,V.jsx)(`p`,{className:`idle-tips-hint`,children:`What would you like to do?`}),(0,V.jsx)(`div`,{className:`idle-tips-chips`,children:[`What needs doing?`,`Start a new task`].map(e=>(0,V.jsx)(`button`,{type:`button`,className:`idle-tip-chip`,onClick:()=>C(e),children:e},e))})]}),P.map((e,t,o)=>{if(e.hidden)return null;let p=n&&t===o.length-1,b=e.role,x=`${e.timestamp??0}_admin`,S=b===`admin`&&h.has(x),C=(t>0?o[t-1]:null)?.historical&&!e.historical;return(0,V.jsxs)(B.Fragment,{children:[C&&(0,V.jsx)(`div`,{className:`resume-divider`,children:(0,V.jsx)(`span`,{children:`Resumed conversation`})}),(0,V.jsxs)(`div`,{ref:t===ee?A:void 0,className:`message ${b===`admin`?`visitor`:`maxy`}${S?` selected`:``}${e.historical?` message-historical`:``}`,children:[m&&!p&&b===`admin`&&(0,V.jsx)(`div`,{className:`message-select-check`,children:(0,V.jsx)(w,{checked:S,onChange:()=>g(x)})}),e.role===`admin`?(0,V.jsxs)(`div`,{className:`bubble`,children:[e.content,e.attachments&&e.attachments.length>0&&(0,V.jsx)(`div`,{className:`message-attachments`,children:e.attachments.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,className:`message-attachment-chip${e.attachmentId&&_?``:` no-action`}`,onClick:()=>{if(!e.attachmentId||!_)return;let t=`/api/admin/attachment/${e.attachmentId}?session_key=${encodeURIComponent(_)}`;e.mimeType.startsWith(`image/`)?v(t):window.open(t,`_blank`)},children:[e.mimeType===`application/pdf`?(0,V.jsx)(c,{size:12}):e.mimeType.startsWith(`text/`)?(0,V.jsx)(D,{size:12}):null,(0,V.jsx)(`span`,{children:e.filename})]},t))}),(0,V.jsx)(`span`,{className:`message-timestamp`,children:y(e.timestamp)})]}):(0,V.jsx)(`div`,{className:`maxy-content-wrap`,children:(0,V.jsx)(lE,{events:e.events??[],isStreaming:p,elapsedSeconds:t===o.length-1?r:e.elapsedSeconds??0,streamStartMs:t===o.length-1?i.current??void 0:void 0,expandAll:a,onCompactNow:t===o.length-1&&!s?()=>u(!0):void 0,isCompacting:t===o.length-1?l:void 0,sessionCompacted:t===o.length-1?s:void 0,onComponentSubmit:(t,n,r)=>d(e.timestamp,t,n,r),submittedComponents:f,timestamp:e.timestamp,selectionMode:m,selectedItems:h,onToggleItem:g,sessionKey:_})})]})]},t)}),b.map((e,t)=>(0,V.jsx)(`div`,{className:`message visitor`,children:(0,V.jsxs)(`div`,{className:`bubble bubble-queued`,children:[e.text||null,e.files.length>0&&(0,V.jsx)(`div`,{className:`message-attachments`,children:e.files.map((e,t)=>(0,V.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.type===`application/pdf`?(0,V.jsx)(c,{size:12}):e.type.startsWith(`text/`)?(0,V.jsx)(D,{size:12}):null,(0,V.jsx)(`span`,{children:e.name})]},t))}),(0,V.jsx)(`span`,{className:`message-timestamp`,children:y(e.timestamp)}),(0,V.jsx)(`button`,{type:`button`,className:`queued-bubble-delete`,onClick:()=>S(x.current.filter((e,n)=>n!==t)),"aria-label":`Remove queued message`,children:`×`})]})},e.timestamp)),(0,V.jsx)(`div`,{ref:O})]}),!M&&(0,V.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>O.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,V.jsx)(p,{size:18})}),t.some(e=>e.role===`maxy`)&&(0,V.jsx)(`button`,{className:`expand-toggle expand-toggle-${a===void 0?`default`:a?`all`:`off`}`,onClick:()=>o(e=>e===void 0?!0:e===!0?!1:void 0),"aria-label":a===void 0?`Expand all`:a?`Collapse all`:`Reset to default`,children:a===!1?(0,V.jsx)(Ie,{size:14}):(0,V.jsx)(Le,{size:14})})]})}function dE({offer:e,onFreshStart:t,onContinue:n,disabled:r}){return e.active?(0,V.jsxs)(`div`,{className:`topic-change-bar`,children:[(0,V.jsx)(`div`,{className:`topic-change-bar__icon`,children:(0,V.jsx)(Me,{size:16})}),(0,V.jsxs)(`div`,{className:`topic-change-bar__actions`,children:[(0,V.jsx)(T,{variant:`primary`,size:`sm`,onClick:t,disabled:r,children:`Start fresh`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,onClick:n,disabled:r,children:`Continue here`})]})]}):null}function fE(e,t){let n=t.lastIndexOf(`_`),r=t.slice(0,n),i=t.slice(n+1),a=parseInt(r,10),o=i===`admin`?`admin`:`maxy`,s=e.find(e=>e.timestamp===a&&e.role===o);if(!s)return``;if(i===`admin`)return s.content??``;let c=parseInt(i,10),l=s.events?.[c];if(!l)return``;if(l.type===`text`||l.type===`thinking`)return l.content;if(l.type===`tool_use`){let e=l,t=`[Tool: ${e.name}]`,n=`Input:\n${JSON.stringify(e.input,null,2)}`,r=s.events??[],i=``;for(let t=c+1;t<r.length;t++){let n=r[t];if(n.type===`tool_result`&&n.name===e.name){i=`\n\nResult:\n${n.output}`;break}}return`${t}\n${n}${i}`}if(l.type===`subagent_start`){let e=l,t=s.events??[],n=``;for(let r=c+1;r<t.length;r++){let i=t[r];if(i.type===`subagent_end`&&i.name===e.name){n=`\n\nResult:\n${i.result}`;break}}return`[${e.name}: ${e.task}]${n}`}return``}function pE(e,t){let n=[...e].sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),r=[];for(let e of n)if(!e.hidden)if(e.role===`admin`)(t===`all`||t===`text`)&&r.push(`User:\n${e.content}`);else{let n=e.events??[];for(let e=0;e<n.length;e++){let i=n[e];if(i.type===`text`&&(t===`all`||t===`text`))r.push(`Maxy:\n${i.content}`);else if(i.type===`thinking`&&(t===`all`||t===`non-text`))r.push(`Maxy [thinking]:\n${i.content}`);else if(i.type===`tool_use`&&(t===`all`||t===`non-text`)){let t=i,a=``;for(let r=e+1;r<n.length;r++)if(n[r].type===`tool_result`&&n[r].name===t.name){a=`\n\nResult:\n${n[r].output}`;break}r.push(`Maxy [tool: ${t.name}]:\nInput:\n${JSON.stringify(t.input,null,2)}${a}`)}else if(i.type===`subagent_start`&&(t===`all`||t===`non-text`)){let t=i,a=``;for(let r=e+1;r<n.length;r++)if(n[r].type===`subagent_end`&&n[r].name===t.name){a=`\n\nResult:\n${n[r].result}`;break}r.push(`Maxy [agent: ${t.name}]\nTask: ${t.task}${a}`)}}}return r.join(`
|
|
349
349
|
|
|
350
350
|
---
|
|
351
351
|
|
|
352
|
-
`)}function mE(e){let{selectionMode:t,selectedItems:n,copyToast:r,exitSelection:i,enterSelection:a,copySelected:o,showCopyToast:s,input:l,setInput:p,inputRef:h,pendingFiles:v,setPendingFiles:y,isDragOver:b,attachError:x,fileInputRef:S,addFiles:C,removeFile:w,onDragOver:O,onDragLeave:k,onDrop:A,isStreaming:M,wasPaused:N,messages:ee,messageQueueRef:te,setQueue:ne,sendMessage:re,stopStreaming:L,disconnecting:ae,handleDisconnect:oe,claudeInfo:ce,setClaudeInfo:le,setShowClaudeInfo:ue,conversationId:de,onNewConversation:fe,newConversationDisabled:pe,onOpenConversations:me}=e,[he,_e]=(0,B.useState)(!1),ve=(0,B.useRef)(null),[ye,R]=(0,B.useState)(!1),be=(0,B.useRef)(null),z=(0,B.useRef)(!1),xe=F(),Se=xe.state===`recording`||xe.state===`paused`||xe.state===`sending`,Ce=!Se&&!N&&!l.trim()&&v.length===0;async function we(){let e=await xe.send();if(!e)return;let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`,n=new File([e],`voice-note${t}`,{type:e.type});if(M){ne([...te.current,{text:`[Voice note]`,files:[n],timestamp:Date.now()}]);return}re(`[Voice note]`,[n])}return(0,B.useEffect)(()=>{t||R(!1)},[t]),(0,B.useEffect)(()=>{if(!ye)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||R(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[ye]),(0,B.useEffect)(()=>{if(!he)return;let e=e=>{if(e.key===`Escape`){_e(!1);return}if(e.key===`Tab`&&ve.current){let t=ve.current.querySelectorAll(`.actions-menu-items button:not([disabled])`);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}},t=e=>{ve.current&&!ve.current.contains(e.target)&&_e(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[he]),t?(0,V.jsx)(`div`,{className:`chat-input-area`,children:(0,V.jsxs)(`div`,{className:`selection-bar`,children:[(0,V.jsxs)(`span`,{className:`selection-count`,children:[n.size,` Selected`]}),(0,V.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(ye){R(!1);return}z.current=!1,be.current=setTimeout(()=>{z.current=!0,R(!0),be.current=null},500)},onPointerUp:()=>{be.current!==null&&(clearTimeout(be.current),be.current=null)},onPointerLeave:()=>{be.current!==null&&(clearTimeout(be.current),be.current=null)},onPointerCancel:()=>{be.current!==null&&(clearTimeout(be.current),be.current=null)},onClick:async()=>{z.current||await o(e=>fE(ee,e),(e,t)=>{let[n,r]=[e.slice(0,e.lastIndexOf(`_`)),e.slice(e.lastIndexOf(`_`)+1)],[i,a]=[t.slice(0,t.lastIndexOf(`_`)),t.slice(t.lastIndexOf(`_`)+1)],o=parseInt(n,10)-parseInt(i,10);return o===0?r===`admin`?-1:a===`admin`?1:parseInt(r,10)-parseInt(a,10):o})},children:[(0,V.jsx)(f,{size:18}),(0,V.jsx)(`span`,{children:`Copy`})]}),ye&&(0,V.jsx)(`div`,{className:`copy-menu`,children:[[`all`,`All events`],[`text`,`Text messages only`],[`non-text`,`Non-text only`]].map(([e,t])=>(0,V.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let t=pE(ee,e);t&&s(await g(t)),i()},children:t},e))})]}),(0,V.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:i,children:`Cancel`})]})}):(0,V.jsxs)(`div`,{className:`chat-input-area`,children:[(0,V.jsx)(`input`,{ref:S,type:`file`,multiple:!0,accept:ut,style:{display:`none`},onChange:e=>{e.target.files&&C([...e.target.files]),e.target.value=``}}),v.length>0&&(0,V.jsx)(`div`,{className:`attachment-strip`,children:v.map((e,t)=>(0,V.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,V.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type===`application/pdf`?(0,V.jsx)(c,{size:14}):(0,V.jsx)(D,{size:14}),(0,V.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,V.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>w(t),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),x&&(0,V.jsx)(`p`,{className:`attach-error`,children:x}),xe.state===`error`&&xe.errorMessage&&(0,V.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,V.jsx)(m,{size:14}),xe.errorMessage]}),(0,V.jsx)(E,{inputRef:h}),Se?(0,V.jsx)(`div`,{className:`chat-form voice-active`,children:(0,V.jsx)(j,{state:xe.state,elapsedSeconds:xe.elapsedSeconds,waveform:xe.waveform,onTogglePause:xe.togglePause,onDiscard:xe.discard,onSend:we})}):(0,V.jsxs)(`form`,{className:`chat-form${b?` drag-over`:``}`,onSubmit:e=>{e.preventDefault();let t=l.trim()||(N?`continue`:``);if(!(!t&&v.length===0)){if(M){ne([...te.current,{text:t,files:[...v],timestamp:Date.now()}]),p(``),y([]),h.current?.resetHeight();return}re(t),h.current?.resetHeight()}},onDragOver:O,onDragLeave:k,onDrop:A,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&C(n)},children:[(0,V.jsx)(T,{variant:`icon`,type:`button`,onClick:()=>S.current?.click(),"aria-label":`Attach file`,children:(0,V.jsx)(u,{size:14})}),(0,V.jsx)(P,{ref:h,value:l,onChange:p}),M?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(T,{variant:`send`,type:`button`,onClick:()=>L(!0),"aria-label":`Pause`,style:{background:`var(--text-secondary)`},children:(0,V.jsx)(d,{size:14})}),(0,V.jsx)(T,{variant:`send`,type:`button`,onClick:()=>L(!1),"aria-label":`Stop`,style:{background:`var(--danger)`},children:(0,V.jsx)($e,{size:14})})]}):Ce?(0,V.jsx)(T,{variant:`send`,type:`button`,onClick:xe.start,"aria-label":`Record voice note`,children:(0,V.jsx)(m,{size:14})}):(0,V.jsx)(T,{variant:`send`,type:`submit`,disabled:!l.trim()&&v.length===0&&!N,"aria-label":`Send message`,children:N?(0,V.jsx)(_,{size:14}):(0,V.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,V.jsxs)(`div`,{className:`chat-actions`,ref:ve,children:[(0,V.jsx)(`button`,{className:`burger-trigger`,onClick:()=>_e(e=>!e),"aria-expanded":he,"aria-haspopup":`true`,"aria-label":`Actions menu`,children:(0,V.jsx)(se,{size:16})}),(0,V.jsxs)(`div`,{className:`actions-menu-items${he?` actions-menu-open`:``}`,children:[(0,V.jsxs)(`button`,{className:`chat-action`,disabled:pe,onClick:()=>{_e(!1),fe()},children:[(0,V.jsx)(je,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:`New conversation`})]}),(0,V.jsxs)(`button`,{className:`chat-action`,onClick:()=>{_e(!1),me()},children:[(0,V.jsx)(ze,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:`Conversations`})]}),(0,V.jsxs)(`button`,{className:`chat-action`,disabled:ae,onClick:async()=>{_e(!1),await oe()},children:[ae?(0,V.jsx)(ie,{size:14,className:`animate-spin`}):(0,V.jsx)(ge,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:ae?`Disconnecting...`:`Disconnect Claude`})]}),(0,V.jsxs)(`button`,{className:`chat-action`,disabled:!de,onClick:()=>{if(_e(!1),!de){console.debug(`[stream-log-button] disabled reason=no-conversation-id`);return}let e=document.createElement(`a`);e.href=`/api/admin/logs?type=stream&conversationId=${encodeURIComponent(de)}&download=1`,e.click()},title:de?`Download stream log`:`No conversation active — start a message to create a stream log`,children:[(0,V.jsx)(Ye,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:`Stream log`})]}),(0,V.jsxs)(`button`,{className:`chat-action`,onClick:()=>{_e(!1),a()},title:`Select messages`,children:[(0,V.jsx)(I,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:`Select`})]})]}),(0,V.jsxs)(`div`,{className:`powered-by`,onClick:async()=>{if(ue(!0),!ce){let e=await fetch(`/api/admin/claude-info`);e.ok&&le(await e.json())}},children:[(0,V.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,V.jsx)(`span`,{children:`Powered by Claude Code`})]})]})]})}var hE=t(((e,t)=>{(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r();else if(typeof define==`function`&&define.amd)define([],r);else{var i=r();for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(globalThis,(()=>(()=>{var e={4567:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AccessibilityManager=void 0;let a=n(9042),o=n(9924),s=n(844),c=n(4725),l=n(2585),u=n(3656),d=t.AccessibilityManager=class extends s.Disposable{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``,this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new o.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this.register(this._terminal.onResize((e=>this._handleResize(e.rows)))),this.register(this._terminal.onRender((e=>this._refreshRows(e.start,e.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((e=>this._handleChar(e)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
352
|
+
`)}function mE(e){let{selectionMode:t,selectedItems:n,copyToast:r,exitSelection:i,enterSelection:a,copySelected:o,showCopyToast:s,input:l,setInput:p,inputRef:h,pendingFiles:v,setPendingFiles:y,isDragOver:b,attachError:x,fileInputRef:S,addFiles:C,removeFile:w,onDragOver:O,onDragLeave:k,onDrop:A,isStreaming:M,wasPaused:N,messages:ee,messageQueueRef:te,setQueue:ne,sendMessage:re,stopStreaming:L,disconnecting:ae,handleDisconnect:oe,claudeInfo:ce,setClaudeInfo:le,setShowClaudeInfo:ue,conversationId:de,onNewConversation:fe,newConversationDisabled:pe,onOpenConversations:me}=e,[he,_e]=(0,B.useState)(!1),ve=(0,B.useRef)(null),[ye,be]=(0,B.useState)(!1),xe=(0,B.useRef)(null),R=(0,B.useRef)(!1),Se=F(),z=Se.state===`recording`||Se.state===`paused`||Se.state===`sending`,Ce=!z&&!N&&!l.trim()&&v.length===0;async function we(){let e=await Se.send();if(!e)return;let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`,n=new File([e],`voice-note${t}`,{type:e.type});if(M){ne([...te.current,{text:`[Voice note]`,files:[n],timestamp:Date.now()}]);return}re(`[Voice note]`,[n])}return(0,B.useEffect)(()=>{t||be(!1)},[t]),(0,B.useEffect)(()=>{if(!ye)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||be(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[ye]),(0,B.useEffect)(()=>{if(!he)return;let e=e=>{if(e.key===`Escape`){_e(!1);return}if(e.key===`Tab`&&ve.current){let t=ve.current.querySelectorAll(`.actions-menu-items button:not([disabled])`);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}},t=e=>{ve.current&&!ve.current.contains(e.target)&&_e(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[he]),t?(0,V.jsx)(`div`,{className:`chat-input-area`,children:(0,V.jsxs)(`div`,{className:`selection-bar`,children:[(0,V.jsxs)(`span`,{className:`selection-count`,children:[n.size,` Selected`]}),(0,V.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(ye){be(!1);return}R.current=!1,xe.current=setTimeout(()=>{R.current=!0,be(!0),xe.current=null},500)},onPointerUp:()=>{xe.current!==null&&(clearTimeout(xe.current),xe.current=null)},onPointerLeave:()=>{xe.current!==null&&(clearTimeout(xe.current),xe.current=null)},onPointerCancel:()=>{xe.current!==null&&(clearTimeout(xe.current),xe.current=null)},onClick:async()=>{R.current||await o(e=>fE(ee,e),(e,t)=>{let[n,r]=[e.slice(0,e.lastIndexOf(`_`)),e.slice(e.lastIndexOf(`_`)+1)],[i,a]=[t.slice(0,t.lastIndexOf(`_`)),t.slice(t.lastIndexOf(`_`)+1)],o=parseInt(n,10)-parseInt(i,10);return o===0?r===`admin`?-1:a===`admin`?1:parseInt(r,10)-parseInt(a,10):o})},children:[(0,V.jsx)(f,{size:18}),(0,V.jsx)(`span`,{children:`Copy`})]}),ye&&(0,V.jsx)(`div`,{className:`copy-menu`,children:[[`all`,`All events`],[`text`,`Text messages only`],[`non-text`,`Non-text only`]].map(([e,t])=>(0,V.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let t=pE(ee,e);t&&s(await g(t)),i()},children:t},e))})]}),(0,V.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:i,children:`Cancel`})]})}):(0,V.jsxs)(`div`,{className:`chat-input-area`,children:[(0,V.jsx)(`input`,{ref:S,type:`file`,multiple:!0,accept:ut,style:{display:`none`},onChange:e=>{e.target.files&&C([...e.target.files]),e.target.value=``}}),v.length>0&&(0,V.jsx)(`div`,{className:`attachment-strip`,children:v.map((e,t)=>(0,V.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,V.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type===`application/pdf`?(0,V.jsx)(c,{size:14}):(0,V.jsx)(D,{size:14}),(0,V.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,V.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>w(t),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),x&&(0,V.jsx)(`p`,{className:`attach-error`,children:x}),Se.state===`error`&&Se.errorMessage&&(0,V.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,V.jsx)(m,{size:14}),Se.errorMessage]}),(0,V.jsx)(E,{inputRef:h}),z?(0,V.jsx)(`div`,{className:`chat-form voice-active`,children:(0,V.jsx)(j,{state:Se.state,elapsedSeconds:Se.elapsedSeconds,waveform:Se.waveform,onTogglePause:Se.togglePause,onDiscard:Se.discard,onSend:we})}):(0,V.jsxs)(`form`,{className:`chat-form${b?` drag-over`:``}`,onSubmit:e=>{e.preventDefault();let t=l.trim()||(N?`continue`:``);if(!(!t&&v.length===0)){if(M){ne([...te.current,{text:t,files:[...v],timestamp:Date.now()}]),p(``),y([]),h.current?.resetHeight();return}re(t),h.current?.resetHeight()}},onDragOver:O,onDragLeave:k,onDrop:A,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&C(n)},children:[(0,V.jsx)(T,{variant:`icon`,type:`button`,onClick:()=>S.current?.click(),"aria-label":`Attach file`,children:(0,V.jsx)(u,{size:14})}),(0,V.jsx)(P,{ref:h,value:l,onChange:p}),M?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(T,{variant:`send`,type:`button`,onClick:()=>L(!0),"aria-label":`Pause`,style:{background:`var(--text-secondary)`},children:(0,V.jsx)(d,{size:14})}),(0,V.jsx)(T,{variant:`send`,type:`button`,onClick:()=>L(!1),"aria-label":`Stop`,style:{background:`var(--danger)`},children:(0,V.jsx)($e,{size:14})})]}):Ce?(0,V.jsx)(T,{variant:`send`,type:`button`,onClick:Se.start,"aria-label":`Record voice note`,children:(0,V.jsx)(m,{size:14})}):(0,V.jsx)(T,{variant:`send`,type:`submit`,disabled:!l.trim()&&v.length===0&&!N,"aria-label":`Send message`,children:N?(0,V.jsx)(_,{size:14}):(0,V.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,V.jsxs)(`div`,{className:`chat-actions`,ref:ve,children:[(0,V.jsx)(`button`,{className:`burger-trigger`,onClick:()=>_e(e=>!e),"aria-expanded":he,"aria-haspopup":`true`,"aria-label":`Actions menu`,children:(0,V.jsx)(se,{size:16})}),(0,V.jsxs)(`div`,{className:`actions-menu-items${he?` actions-menu-open`:``}`,children:[(0,V.jsxs)(`button`,{className:`chat-action`,disabled:pe,onClick:()=>{_e(!1),fe()},children:[(0,V.jsx)(je,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:`New conversation`})]}),(0,V.jsxs)(`button`,{className:`chat-action`,onClick:()=>{_e(!1),me()},children:[(0,V.jsx)(ze,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:`Conversations`})]}),(0,V.jsxs)(`button`,{className:`chat-action`,disabled:ae,onClick:async()=>{_e(!1),await oe()},children:[ae?(0,V.jsx)(ie,{size:14,className:`animate-spin`}):(0,V.jsx)(ge,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:ae?`Disconnecting...`:`Disconnect Claude`})]}),(0,V.jsxs)(`button`,{className:`chat-action`,disabled:!de,onClick:()=>{if(_e(!1),!de){console.debug(`[stream-log-button] disabled reason=no-conversation-id`);return}let e=document.createElement(`a`);e.href=`/api/admin/logs?type=stream&conversationId=${encodeURIComponent(de)}&download=1`,e.click()},title:de?`Download stream log`:`No conversation active — start a message to create a stream log`,children:[(0,V.jsx)(Ye,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:`Stream log`})]}),(0,V.jsxs)(`button`,{className:`chat-action`,onClick:()=>{_e(!1),a()},title:`Select messages`,children:[(0,V.jsx)(I,{size:14}),(0,V.jsx)(`span`,{className:`action-label`,children:`Select`})]})]}),(0,V.jsxs)(`div`,{className:`powered-by`,onClick:async()=>{if(ue(!0),!ce){let e=await fetch(`/api/admin/claude-info`);e.ok&&le(await e.json())}},children:[(0,V.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,V.jsx)(`span`,{children:`Powered by Claude Code`})]})]})]})}var hE=t(((e,t)=>{(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r();else if(typeof define==`function`&&define.amd)define([],r);else{var i=r();for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(globalThis,(()=>(()=>{var e={4567:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AccessibilityManager=void 0;let a=n(9042),o=n(9924),s=n(844),c=n(4725),l=n(2585),u=n(3656),d=t.AccessibilityManager=class extends s.Disposable{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``,this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new o.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this.register(this._terminal.onResize((e=>this._handleResize(e.rows)))),this.register(this._terminal.onRender((e=>this._refreshRows(e.start,e.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((e=>this._handleChar(e)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
353
353
|
`)))),this.register(this._terminal.onA11yTab((e=>this._handleTab(e)))),this.register(this._terminal.onKey((e=>this._handleKey(e.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,u.addDisposableDomListener)(document,`selectionchange`,(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,s.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
354
354
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=a.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.innerText=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=document.getSelection();if(!e)return;if(e.isCollapsed)return void(this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection());if(!e.anchorNode||!e.focusNode)return void console.error(`anchorNode and/or focusNode are null`);let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}};t.AccessibilityManager=d=r([i(1,l.IInstantiationService),i(2,c.ICoreBrowserService),i(3,c.IRenderService)],d)},3614:(e,t)=>{function n(e){return e.replace(/\r?\n/g,`\r`)}function r(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function i(e,t,i,a){e=r(e=n(e),i.decPrivateModes.bracketedPasteMode&&!0!==a.rawOptions.ignoreBracketedPasteMode),i.triggerDataEvent(e,!0),t.value=``}function a(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}Object.defineProperty(t,`__esModule`,{value:!0}),t.rightClickHandler=t.moveTextAreaUnderMouseCursor=t.paste=t.handlePasteEvent=t.copyHandler=t.bracketTextForPaste=t.prepareTextForTerminal=void 0,t.prepareTextForTerminal=n,t.bracketTextForPaste=r,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,n,r){e.stopPropagation(),e.clipboardData&&i(e.clipboardData.getData(`text/plain`),t,n,r)},t.paste=i,t.moveTextAreaUnderMouseCursor=a,t.rightClickHandler=function(e,t,n,r,i){a(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}},7239:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.ColorContrastCache=void 0;let r=n(1505);t.ColorContrastCache=class{constructor(){this._color=new r.TwoKeyMap,this._css=new r.TwoKeyMap}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}}},3656:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.addDisposableDomListener=void 0,t.addDisposableDomListener=function(e,t,n,r){e.addEventListener(t,n,r);let i=!1;return{dispose:()=>{i||(i=!0,e.removeEventListener(t,n,r))}}}},3551:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.Linkifier=void 0;let a=n(3656),o=n(8460),s=n(844),c=n(2585),l=n(4725),u=t.Linkifier=class extends s.Disposable{get currentLink(){return this._currentLink}constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new o.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new o.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,s.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,s.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,a.addDisposableDomListener)(this._element,`mouseleave`,(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,a.addDisposableDomListener)(this._element,`mousemove`,this._handleMouseMove.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,`mousedown`,this._handleMouseDown.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,`mouseup`,this._handleMouseUp.bind(this)))}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(e,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){this._activeProviderReplies&&t||(this._activeProviderReplies?.forEach((e=>{e?.forEach((e=>{e.link.dispose&&e.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,(t=>{if(this._isMouseOut)return;let i=t?.map((e=>({link:e})));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)}))}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)this._activeProviderReplies.has(t)&&!this._activeProviderReplies.get(t)||(i=!0);if(!i&&r){let e=r.find((e=>this._linkAtPosition(e.link,t)));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find((e=>this._linkAtPosition(e.link,t)));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){this._currentLink&&this._lastMouseEvent&&(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,s.disposeArray)(this._linkCacheDisposables))}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}}))))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};t.Linkifier=u=r([i(1,l.IMouseService),i(2,l.IRenderService),i(3,c.IBufferService),i(4,l.ILinkProviderService)],u)},9042:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.tooMuchOutput=t.promptLabel=void 0,t.promptLabel=`Terminal input`,t.tooMuchOutput=`Too much output to announce, navigate to rows manually to read`},3730:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.OscLinkProvider=void 0;let a=n(511),o=n(2585),s=t.OscLinkProvider=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n)return void t(void 0);let r=[],i=this._optionsService.rawOptions.linkHandler,o=new a.CellData,s=n.getTrimmedLength(),l=-1,u=-1,d=!1;for(let t=0;t<s;t++)if(u!==-1||n.hasContent(t)){if(n.loadCell(t,o),o.hasExtendedAttrs()&&o.extended.urlId){if(u===-1){u=t,l=o.extended.urlId;continue}d=o.extended.urlId!==l}else u!==-1&&(d=!0);if(d||u!==-1&&t===s-1){let n=this._oscLinkService.getLinkData(l)?.uri;if(n){let a={start:{x:u+1,y:e},end:{x:t+(d||t!==s-1?0:1),y:e}},o=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(o=!0)}catch{o=!0}o||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):c(0,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(u=t,l=o.extended.urlId):(u=-1,l=-1)}}t(r)}};function c(e,t){if(confirm(`Do you want to navigate to ${t}?\n\nWARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}t.OscLinkProvider=s=r([i(0,o.IBufferService),i(1,o.IOptionsService),i(2,o.IOscLinkService)],s)},6193:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.RenderDebouncer=void 0,t.RenderDebouncer=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}}},3236:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.Terminal=void 0;let r=n(3614),i=n(3656),a=n(3551),o=n(9042),s=n(3730),c=n(1680),l=n(3107),u=n(5744),d=n(2950),f=n(1296),p=n(428),m=n(4269),h=n(5114),g=n(8934),_=n(3230),v=n(9312),y=n(4725),b=n(6731),x=n(8055),S=n(8969),C=n(8460),w=n(844),T=n(6114),E=n(8437),D=n(2584),O=n(7399),k=n(5941),A=n(9074),j=n(2585),M=n(5435),N=n(4567),P=n(779);class ee extends S.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(e={}){super(e),this.browser=T,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new w.MutableDisposable),this._onCursorMove=this.register(new C.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new C.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new C.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new C.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new C.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new C.EventEmitter),this._onBlur=this.register(new C.EventEmitter),this._onA11yCharEmitter=this.register(new C.EventEmitter),this._onA11yTabEmitter=this.register(new C.EventEmitter),this._onWillOpen=this.register(new C.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(A.DecorationService),this._instantiationService.setService(j.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(P.LinkProviderService),this._instantiationService.setService(y.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(s.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((e,t)=>this.refresh(e,t)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((e=>this._reportWindowsOptions(e)))),this.register(this._inputHandler.onColor((e=>this._handleColorEvent(e)))),this.register((0,C.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,C.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((e=>this._afterResize(e.cols,e.rows)))),this.register((0,w.toDisposable)((()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)})))}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=x.color.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${D.C0.ESC}]${n};${(0,k.toRgbString)(r)}${D.C1_ESCAPED.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors((e=>e.ansi[t.index]=x.channels.toColor(...t.color)));else{let n=e;this._themeService.modifyColors((e=>e[n]=x.channels.toColor(...t.color)))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(N.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(D.C0.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(D.C0.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this.register((0,i.addDisposableDomListener)(this.element,`copy`,(e=>{this.hasSelection()&&(0,r.copyHandler)(e,this._selectionService)})));let e=e=>(0,r.handlePasteEvent)(e,this.textarea,this.coreService,this.optionsService);this.register((0,i.addDisposableDomListener)(this.textarea,`paste`,e)),this.register((0,i.addDisposableDomListener)(this.element,`paste`,e)),T.isFirefox?this.register((0,i.addDisposableDomListener)(this.element,`mousedown`,(e=>{e.button===2&&(0,r.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,i.addDisposableDomListener)(this.element,`contextmenu`,(e=>{(0,r.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),T.isLinux&&this.register((0,i.addDisposableDomListener)(this.element,`auxclick`,(e=>{e.button===1&&(0,r.moveTextAreaUnderMouseCursor)(e,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,i.addDisposableDomListener)(this.textarea,`keyup`,(e=>this._keyUp(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`keydown`,(e=>this._keyDown(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`keypress`,(e=>this._keyPress(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionstart`,(()=>this._compositionHelper.compositionstart()))),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionupdate`,(e=>this._compositionHelper.compositionupdate(e)))),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionend`,(()=>this._compositionHelper.compositionend()))),this.register((0,i.addDisposableDomListener)(this.textarea,`input`,(e=>this._inputEvent(e)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement(`div`),this._viewportScrollArea.classList.add(`xterm-scroll-area`),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this.register((0,i.addDisposableDomListener)(this.screenElement,`mousemove`,(e=>this.updateCursorStyle(e)))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement),this.textarea=this._document.createElement(`textarea`),this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,o.promptLabel),T.isChromeOS||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(h.CoreBrowserService,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(y.ICoreBrowserService,this._coreBrowserService),this.register((0,i.addDisposableDomListener)(this.textarea,`focus`,(e=>this._handleTextAreaFocus(e)))),this.register((0,i.addDisposableDomListener)(this.textarea,`blur`,(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(p.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(y.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(b.ThemeService),this._instantiationService.setService(y.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(m.CharacterJoinerService),this._instantiationService.setService(y.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(_.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(y.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((e=>this._onRender.fire(e)))),this.onResize((e=>this._renderService.resize(e.cols,e.rows))),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(g.MouseService),this._instantiationService.setService(y.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(a.Linkifier,this.screenElement)),this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(c.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((e=>this.scrollLines(e.amount,e.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(v.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(y.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((e=>this.scrollLines(e.amount,e.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((e=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,i.addDisposableDomListener)(this._viewportElement,`scroll`,(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(l.BufferDecorationRenderer,this.screenElement)),this.register((0,i.addDisposableDomListener)(this.element,`mousedown`,(e=>this._selectionService.handleMouseDown(e)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(N.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,(e=>this._handleScreenReaderModeOptionChange(e)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(u.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRulerWidth`,(e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(u.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(f.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=1&t.buttons?0:4&t.buttons?1:2&t.buttons?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(t)||e.viewport.getLinesScrolled(t)===0)return!1;i=t.deltaY<0?0:1,r=4;break;default:return!1}return!(i===void 0||r===void 0||r>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this.register(this.coreMouseService.onProtocolChange((e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),8&e?r.mousemove||=(t.addEventListener(`mousemove`,a.mousemove),a.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),16&e?r.wheel||=(t.addEventListener(`wheel`,a.wheel,{passive:!1}),a.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),2&e?r.mouseup||=a.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),4&e?r.mousedrag||=a.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,i.addDisposableDomListener)(t,`mousedown`,(e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)}))),this.register((0,i.addDisposableDomListener)(t,`wheel`,(e=>{if(!r.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(e))return!1;if(!this.buffer.hasScrollback){let t=this.viewport.getLinesScrolled(e);if(t===0)return;let n=D.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(e.deltaY<0?`A`:`B`),r=``;for(let e=0;e<Math.abs(t);e++)r+=n;return this.coreService.triggerDataEvent(r,!0),this.cancel(e,!0)}return this.viewport.handleWheel(e)?this.cancel(e):void 0}}),{passive:!1})),this.register((0,i.addDisposableDomListener)(t,`touchstart`,(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(e),this.cancel(e)}),{passive:!0})),this.register((0,i.addDisposableDomListener)(t,`touchmove`,(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(e)?void 0:this.cancel(e)}),{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t,n=0){n===1?(super.scrollLines(e,t,n),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(e)}paste(e){(0,r.paste)(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=(0,O.evaluateKeyboardEvent)(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}return n.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key||!!(e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(n.key!==D.C0.ETX&&n.key!==D.C0.CR||(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey?this.cancel(e,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(function(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else{if(e.which===0||e.charCode===0)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)||(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e!==this.cols||t!==this.rows?super.resize(e,t):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(e,t){this._charSizeService?.measure(),this.viewport?.syncScrollArea(!0)}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(E.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),this.viewport?.reset(),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this.viewport?.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(D.C0.ESC+`[I`):this.coreService.triggerDataEvent(D.C0.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case M.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${D.C0.ESC}[4;${t};${e}t`);break;case M.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${D.C0.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}}t.Terminal=ee},9924:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.TimeBasedDebouncer=void 0,t.TimeBasedDebouncer=class{constructor(e,t=1e3){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=Date.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}}},1680:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.Viewport=void 0;let a=n(3656),o=n(4725),s=n(8460),c=n(844),l=n(2585),u=t.Viewport=class extends c.Disposable{constructor(e,t,n,r,i,o,c,l){super(),this._viewportElement=e,this._scrollArea=t,this._bufferService=n,this._optionsService=r,this._charSizeService=i,this._renderService=o,this._coreBrowserService=c,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new s.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,a.addDisposableDomListener)(this._viewportElement,`scroll`,this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((e=>this._activeBuffer=e.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((e=>this._renderDimensions=e))),this._handleThemeChange(l.colors),this.register(l.onChangeColors((e=>this._handleThemeChange(e)))),this.register(this._optionsService.onSpecificOptionChange(`scrollback`,(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(e){this._viewportElement.style.backgroundColor=e.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(e){if(e)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;let e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+`px`)}let e=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==e&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=e),this._refreshAnimationFrame=null}syncScrollArea(e=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(e);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(e)}_handleScroll(e){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});let t=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:t,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;let e=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(e*(this._smoothScrollState.target-this._smoothScrollState.origin)),e<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(e,t){let n=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(t<0&&this._viewportElement.scrollTop!==0||t>0&&n<this._lastRecordedBufferHeight)||(e.cancelable&&e.preventDefault(),!1)}handleWheel(e){let t=this._getPixelsScrolled(e);return t!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+t:this._smoothScrollState.target+=t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}scrollLines(e){if(e!==0)if(this._optionsService.rawOptions.smoothScrollDuration){let t=e*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:e,suppressScrollEvent:!1})}_getPixelsScrolled(e){if(e.deltaY===0||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=this._currentRowHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._currentRowHeight*this._bufferService.rows),t}getBufferElements(e,t){let n,r=``,i=[],a=t??this._bufferService.buffer.lines.length,o=this._bufferService.buffer.lines;for(let t=e;t<a;t++){let e=o.get(t);if(!e)continue;let a=o.get(t+1)?.isWrapped;if(r+=e.translateToString(!a),!a||t===o.length-1){let e=document.createElement(`div`);e.textContent=r,i.push(e),r.length>0&&(n=e),r=``}}return{bufferElements:i,cursorElement:n}}getLinesScrolled(e){if(e.deltaY===0||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(t/=this._currentRowHeight+0,this._wheelPartialScroll+=t,t=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._bufferService.rows),t}_applyScrollModifier(e,t){let n=this._optionsService.rawOptions.fastScrollModifier;return n===`alt`&&t.altKey||n===`ctrl`&&t.ctrlKey||n===`shift`&&t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(e){this._lastTouchY=e.touches[0].pageY}handleTouchMove(e){let t=this._lastTouchY-e.touches[0].pageY;return this._lastTouchY=e.touches[0].pageY,t!==0&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}};t.Viewport=u=r([i(2,l.IBufferService),i(3,l.IOptionsService),i(4,o.ICharSizeService),i(5,o.IRenderService),i(6,o.ICoreBrowserService),i(7,o.IThemeService)],u)},3107:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferDecorationRenderer=void 0;let a=n(4725),o=n(844),s=n(2585),c=t.BufferDecorationRenderer=class extends o.Disposable{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((e=>this._removeDecoration(e)))),this.register((0,o.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=(e.options.height||1)*this._renderService.dimensions.css.cell.height+`px`,t.style.top=(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+`px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose((()=>{this._decorationElements.delete(e),n.remove()}))),n.style.top=t*this._renderService.dimensions.css.cell.height+`px`,n.style.display=this._altBufferIsActive?`none`:`block`,e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?n*this._renderService.dimensions.css.cell.width+`px`:``:t.style.left=n?n*this._renderService.dimensions.css.cell.width+`px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};t.BufferDecorationRenderer=c=r([i(1,s.IBufferService),i(2,a.ICoreBrowserService),i(3,s.IDecorationService),i(4,a.IRenderService)],c)},5871:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.ColorZoneStore=void 0,t.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(t,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}}},5744:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.OverviewRulerRenderer=void 0;let a=n(5871),o=n(4725),s=n(844),c=n(2585),l={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0},f=t.OverviewRulerRenderer=class extends s.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(e,t,n,r,i,o,c){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=o,this._coreBrowserService=c,this._colorZoneStore=new a.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement);let l=this._canvas.getContext(`2d`);if(!l)throw Error(`Ctx cannot be null`);this._ctx=l,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,s.toDisposable)((()=>{this._canvas?.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange(`overviewRulerWidth`,(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){let e=Math.floor(this._canvas.width/3),t=Math.ceil(this._canvas.width/3);u.full=this._canvas.width,u.left=e,u.center=t,u.right=e,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=u.left,d.right=u.left+u.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);l.left=t,l.center=t,l.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1;let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(d[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-l[e.position||`full`]/2),u[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};t.OverviewRulerRenderer=f=r([i(2,c.IBufferService),i(3,c.IDecorationService),i(4,o.IRenderService),i(5,c.IOptionsService),i(6,o.ICoreBrowserService)],f)},2950:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CompositionHelper=void 0;let a=n(4725),o=n(2585),s=n(2584),c=t.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let t;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,e.end):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}}),0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout((()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${s.C0.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}}),0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};t.CompositionHelper=c=r([i(2,o.IBufferService),i(3,o.IOptionsService),i(4,o.ICoreService),i(5,a.IRenderService)],c)},9806:(e,t)=>{function n(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}Object.defineProperty(t,`__esModule`,{value:!0}),t.getCoords=t.getCoordsRelativeToElement=void 0,t.getCoordsRelativeToElement=n,t.getCoords=function(e,t,r,i,a,o,s,c,l){if(!o)return;let u=n(e,t,r);return u?(u[0]=Math.ceil((u[0]+(l?s/2:0))/s),u[1]=Math.ceil(u[1]/c),u[0]=Math.min(Math.max(u[0],1),i+(l?1:0)),u[1]=Math.min(Math.max(u[1],1),a),u):void 0}},9504:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.moveToCellSequence=void 0;let r=n(2584);function i(e,t,n,r){let i=e-a(e,n),s=t-a(t,n);return l(Math.abs(i-s)-function(e,t,n){let r=0,i=e-a(e,n),s=t-a(t,n);for(let a=0;a<Math.abs(i-s);a++){let s=o(e,t)===`A`?-1:1;n.buffer.lines.get(i+s*a)?.isWrapped&&r++}return r}(e,t,n),c(o(e,t),r))}function a(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function o(e,t){return e>t?`A`:`B`}function s(e,t,n,r,i,a){let o=e,s=t,c=``;for(;o!==n||s!==r;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function c(e,t){let n=t?`O`:`[`;return r.C0.ESC+n+e}function l(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}t.moveToCellSequence=function(e,t,n,r){let o=n.buffer.x,u=n.buffer.y;if(!n.buffer.hasScrollback)return function(e,t,n,r,o,u){return i(t,r,o,u).length===0?``:l(s(e,t,e,t-a(t,o),!1,o).length,c(`D`,u))}(o,u,0,t,n,r)+i(u,t,n,r)+function(e,t,n,r,o,u){let d;d=i(t,r,o,u).length>0?r-a(r,o):t;let f=r,p=function(e,t,n,r,o,s){let c;return c=i(n,r,o,s).length>0?r-a(r,o):t,e<n&&c<=r||e>=n&&c<r?`C`:`D`}(e,t,n,r,o,u);return l(s(e,d,n,f,p===`C`,o).length,c(p,u))}(o,u,e,t,n,r);let d;if(u===t)return d=o>e?`D`:`C`,l(Math.abs(o-e),c(d,r));d=u>t?`D`:`C`;let f=Math.abs(u-t);return l(function(e,t){return t.cols-e}(u>t?e:o,n)+(f-1)*n.cols+1+((u>t?o:e)-1),c(d,r))}},1296:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.DomRenderer=void 0;let a=n(3787),o=n(2550),s=n(2223),c=n(6171),l=n(6052),u=n(4725),d=n(8055),f=n(8460),p=n(844),m=n(2585),h=`xterm-dom-renderer-owner-`,g=`xterm-rows`,_=`xterm-fg-`,v=`xterm-bg-`,y=`xterm-focus`,b=`xterm-selection`,x=1,S=t.DomRenderer=class extends p.Disposable{constructor(e,t,n,r,i,s,u,d,m,_,v,y,S){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=s,this._linkifier2=u,this._charSizeService=m,this._optionsService=_,this._bufferService=v,this._coreBrowserService=y,this._themeService=S,this._terminalClass=x++,this._rowElements=[],this._selectionRenderModel=(0,l.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new f.EventEmitter).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(g),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(b),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=(0,c.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((e=>this._injectCss(e)))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(a.DomRendererRowFactory,document),this._element.classList.add(h+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((e=>this._handleLinkHover(e)))),this.register(this._linkifier2.onHideLinkUnderline((e=>this._handleLinkLeave(e)))),this.register((0,p.toDisposable)((()=>{this._element.classList.remove(h+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new o.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${g} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${g} { color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${g} .xterm-dim { color: ${d.color.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${b} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${b} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${b} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${_}${n} { color: ${r.css}; }${this._terminalSelector} .${_}${n}.xterm-dim { color: ${d.color.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${v}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${_}${s.INVERTED_DEFAULT_COLOR} { color: ${d.color.opaque(e.background).css}; }${this._terminalSelector} .${_}${s.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${d.color.multiplyOpacity(d.color.opaque(e.background),.5).css}; }${this._terminalSelector} .${v}${s.INVERTED_DEFAULT_COLOR} { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(y),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(y),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t)return;this._selectionRenderModel.update(this._terminal,e,t,n);let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow;if(a>=this._bufferService.rows||o<0)return;let s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=r*this.dimensions.css.cell.height+`px`,i.style.top=e*this.dimensions.css.cell.height+`px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._optionsService.rawOptions.cursorBlink,o=this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${h}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};t.DomRenderer=S=r([i(7,m.IInstantiationService),i(8,u.ICharSizeService),i(9,m.IOptionsService),i(10,m.IBufferService),i(11,u.ICoreBrowserService),i(12,u.IThemeService)],S)},3787:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.DomRendererRowFactory=void 0;let a=n(2223),o=n(643),s=n(511),c=n(2585),l=n(8055),u=n(4725),d=n(4269),f=n(6171),p=n(3734),m=t.DomRendererRowFactory=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new s.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,s,c,u,f,m,g){let _=[],v=this._characterJoinerService.getJoinedCharacters(t),y=this._themeService.colors,b,x=e.getNoBgTrimmedLength();n&&x<s+1&&(x=s+1);let S=0,C=``,w=0,T=0,E=0,D=!1,O=0,k=!1,A=0,j=[],M=m!==-1&&g!==-1;for(let N=0;N<x;N++){e.loadCell(N,this._workCell);let x=this._workCell.getWidth();if(x===0)continue;let P=!1,ee=N,F=this._workCell;if(v.length>0&&N===v[0][0]){P=!0;let t=v.shift();F=new d.JoinedCellData(this._workCell,e.translateToString(!0,t[0],t[1]),t[1]-t[0]),ee=t[1]-1,x=F.getWidth()}let te=this._isCellInSelection(N,t),I=n&&N===s,ne=M&&N>=m&&N<=g,re=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,(e=>{re=!0}));let ie=F.getChars()||o.WHITESPACE_CELL_CHAR;if(ie===` `&&(F.isUnderline()||F.isOverline())&&(ie=`\xA0`),A=x*u-f.get(ie,F.isBold(),F.isItalic()),b){if(S&&(te&&k||!te&&!k&&F.bg===w)&&(te&&k&&y.selectionForeground||F.fg===T)&&F.extended.ext===E&&ne===D&&A===O&&!I&&!P&&!re){F.isInvisible()?C+=o.WHITESPACE_CELL_CHAR:C+=ie,S++;continue}S&&(b.textContent=C),b=this._document.createElement(`span`),S=0,C=``}else b=this._document.createElement(`span`);if(w=F.bg,T=F.fg,E=F.extended.ext,D=ne,O=A,k=te,P&&s>=N&&s<=ee&&(s=N),!this._coreService.isCursorHidden&&I&&this._coreService.isCursorInitialized){if(j.push(`xterm-cursor`),this._coreBrowserService.isFocused)c&&j.push(`xterm-cursor-blink`),j.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:j.push(`xterm-cursor-outline`);break;case`block`:j.push(`xterm-cursor-block`);break;case`bar`:j.push(`xterm-cursor-bar`);break;case`underline`:j.push(`xterm-cursor-underline`)}}if(F.isBold()&&j.push(`xterm-bold`),F.isItalic()&&j.push(`xterm-italic`),F.isDim()&&j.push(`xterm-dim`),C=F.isInvisible()?o.WHITESPACE_CELL_CHAR:F.getChars()||o.WHITESPACE_CELL_CHAR,F.isUnderline()&&(j.push(`xterm-underline-${F.extended.underlineStyle}`),C===` `&&(C=`\xA0`),!F.isUnderlineColorDefault()))if(F.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${p.AttributeData.toColorRGB(F.getUnderlineColor()).join(`,`)})`;else{let e=F.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&F.isBold()&&e<8&&(e+=8),b.style.textDecorationColor=y.ansi[e].css}F.isOverline()&&(j.push(`xterm-overline`),C===` `&&(C=`\xA0`)),F.isStrikethrough()&&j.push(`xterm-strikethrough`),ne&&(b.style.textDecoration=`underline`);let L=F.getFgColor(),ae=F.getFgColorMode(),oe=F.getBgColor(),se=F.getBgColorMode(),ce=!!F.isInverse();if(ce){let e=L;L=oe,oe=e;let t=ae;ae=se,se=t}let le,ue,de,fe=!1;switch(this._decorationService.forEachDecorationAtCell(N,t,void 0,(e=>{e.options.layer!==`top`&&fe||(e.backgroundColorRGB&&(se=50331648,oe=e.backgroundColorRGB.rgba>>8&16777215,le=e.backgroundColorRGB),e.foregroundColorRGB&&(ae=50331648,L=e.foregroundColorRGB.rgba>>8&16777215,ue=e.foregroundColorRGB),fe=e.options.layer===`top`)})),!fe&&te&&(le=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,oe=le.rgba>>8&16777215,se=50331648,fe=!0,y.selectionForeground&&(ae=50331648,L=y.selectionForeground.rgba>>8&16777215,ue=y.selectionForeground)),fe&&j.push(`xterm-decoration-top`),se){case 16777216:case 33554432:de=y.ansi[oe],j.push(`xterm-bg-${oe}`);break;case 50331648:de=l.channels.toColor(oe>>16,oe>>8&255,255&oe),this._addStyle(b,`background-color:#${h((oe>>>0).toString(16),`0`,6)}`);break;default:ce?(de=y.foreground,j.push(`xterm-bg-${a.INVERTED_DEFAULT_COLOR}`)):de=y.background}switch(le||F.isDim()&&(le=l.color.multiplyOpacity(de,.5)),ae){case 16777216:case 33554432:F.isBold()&&L<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(L+=8),this._applyMinimumContrast(b,de,y.ansi[L],F,le,void 0)||j.push(`xterm-fg-${L}`);break;case 50331648:let e=l.channels.toColor(L>>16&255,L>>8&255,255&L);this._applyMinimumContrast(b,de,e,F,le,ue)||this._addStyle(b,`color:#${h(L.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(b,de,y.foreground,F,le,ue)||ce&&j.push(`xterm-fg-${a.INVERTED_DEFAULT_COLOR}`)}j.length&&=(b.className=j.join(` `),0),I||P||re?b.textContent=C:S++,A!==this.defaultSpacing&&(b.style.letterSpacing=`${A}px`),_.push(b),N=ee}return b&&S&&(b.textContent=C),_}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,f.treatGlyphAsBackgroundColor)(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(i||a||(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=l.color.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return!!s&&(this._addStyle(e,`color:${s.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!(!n||!r)&&(this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0])}};function h(e,t,n){for(;e.length<n;)e=t+e;return e}t.DomRendererRowFactory=m=r([i(1,u.ICharacterJoinerService),i(2,c.IOptionsService),i(3,u.ICoreBrowserService),i(4,c.ICoreService),i(5,c.IDecorationService),i(6,u.IThemeService)],m)},2550:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.WidthCache=void 0,t.WidthCache=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}}},2223:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.TEXT_BASELINE=t.DIM_OPACITY=t.INVERTED_DEFAULT_COLOR=void 0;let r=n(6114);t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.TEXT_BASELINE=r.isFirefox||r.isLegacyEdge?`bottom`:`ideographic`},6171:(e,t)=>{function n(e){return 57508<=e&&e<=57558}function r(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}Object.defineProperty(t,`__esModule`,{value:!0}),t.computeNextVariantOffset=t.createRenderDimensions=t.treatGlyphAsBackgroundColor=t.allowRescaling=t.isEmoji=t.isRestrictedPowerlineGlyph=t.isPowerlineGlyph=t.throwIfFalsy=void 0,t.throwIfFalsy=function(e){if(!e)throw Error(`value must not be falsy`);return e},t.isPowerlineGlyph=n,t.isRestrictedPowerlineGlyph=function(e){return 57520<=e&&e<=57527},t.isEmoji=r,t.allowRescaling=function(e,t,i,a){return t===1&&i>Math.ceil(1.5*a)&&e!==void 0&&e>255&&!r(e)&&!n(e)&&!function(e){return 57344<=e&&e<=63743}(e)},t.treatGlyphAsBackgroundColor=function(e){return n(e)||function(e){return 9472<=e&&e<=9631}(e)},t.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},t.computeNextVariantOffset=function(e,t,n=0){return(e-(2*Math.round(t)-n))%(2*Math.round(t))}},6052:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.createSelectionRenderModel=void 0;class n{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1])return void this.clear();let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);s>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return!!this.hasSelection&&(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol)}}t.createSelectionRenderModel=function(){return new n}},456:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.SelectionModel=void 0,t.SelectionModel=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!(!e||!t)&&(e[1]>t[1]||e[1]===t[1]&&e[0]>t[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CharSizeService=void 0;let a=n(2585),o=n(8460),s=n(844),c=t.CharSizeService=class extends s.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this.register(new o.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new d(this._optionsService))}catch{this._measureStrategy=this.register(new u(e,t,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],(()=>this.measure())))}measure(){let e=this._measureStrategy.measure();e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};t.CharSizeService=c=r([i(2,a.IOptionsService)],c);class l extends s.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}}class u extends l{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class d extends l{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}}},4269:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CharacterJoinerService=t.JoinedCellData=void 0;let a=n(3734),o=n(643),s=n(511),c=n(2585);class l extends a.AttributeData{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.JoinedCellData=l;let u=t.CharacterJoinerService=class e{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new s.CellData}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,s=0,c=t.getFg(0),l=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==c||this._workCell.bg!==l){if(e-i>1){let e=this._getJoinedRanges(r,s,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,s=a,c=this._workCell.fg,l=this._workCell.bg}a+=this._workCell.getChars().length||o.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,s,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(t,n,r,i,a){let o=t.substring(n,r),s=[];try{s=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let t=1;t<this._characterJoiners.length;t++)try{let n=this._characterJoiners[t].handler(o);for(let t=0;t<n.length;t++)e._mergeRanges(s,n[t])}catch(e){console.error(e)}return this._stringRangesToCellRanges(s,i,a),s}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,s=e[r];if(s){for(let c=n;c<this._bufferService.cols;c++){let n=t.getWidth(c),l=t.getString(c).length||o.WHITESPACE_CELL_CHAR.length;if(n!==0){if(!i&&s[0]<=a&&(s[0]=c,i=!0),s[1]<=a){if(s[1]=c,s=e[++r],!s)break;s[0]<=a?(s[0]=c,i=!0):i=!1}a+=l}}s&&(s[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0)}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};t.CharacterJoinerService=u=r([i(0,c.IBufferService)],u)},5114:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CoreBrowserService=void 0;let r=n(844),i=n(8460),a=n(3656);class o extends r.Disposable{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new s(this._window),this._onDprChange=this.register(new i.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new i.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((e=>this._screenDprMonitor.setWindow(e)))),this.register((0,i.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener(`focus`,(()=>this._isFocused=!0)),this._textarea.addEventListener(`blur`,(()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}t.CoreBrowserService=o;class s extends r.Disposable{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this.register(new r.MutableDisposable),this._onDprChange=this.register(new i.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,r.toDisposable)((()=>this.clearListener())))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,a.addDisposableDomListener)(this._parentWindow,`resize`,(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.LinkProviderService=void 0;let r=n(844);class i extends r.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,r.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}}t.LinkProviderService=i},8934:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.MouseService=void 0;let a=n(4725),o=n(9806),s=t.MouseService=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return(0,o.getCoords)(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=(0,o.getCoordsRelativeToElement)(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};t.MouseService=s=r([i(0,a.IRenderService),i(1,a.ICharSizeService)],s)},3230:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.RenderService=void 0;let a=n(6193),o=n(4725),s=n(8460),c=n(844),l=n(7226),u=n(2585),d=t.RenderService=class extends c.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(e,t,n,r,i,o,u,d){super(),this._rowCount=e,this._charSizeService=r,this._renderer=this.register(new c.MutableDisposable),this._pausedResizeTask=new l.DebouncedIdleTask,this._observerDisposable=this.register(new c.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new s.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new s.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new s.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new s.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new a.RenderDebouncer(((e,t)=>this._renderRows(e,t)),u),this.register(this._renderDebouncer),this.register(u.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(o.onResize((()=>this._fullRefresh()))),this.register(o.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this.register(n.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(i.onDecorationRegistered((()=>this._fullRefresh()))),this.register(i.onDecorationRemoved((()=>this._fullRefresh()))),this.register(n.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],(()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()}))),this.register(n.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],(()=>this.refreshRows(o.buffer.y,o.buffer.y,!0)))),this.register(d.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(u.window,t),this.register(u.onWindowChange((e=>this._registerIntersectionObserver(e,t))))}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver((e=>this._handleIntersectionChange(e[e.length-1])),{threshold:0});n.observe(t),this._observerDisposable.value=(0,c.toDisposable)((()=>n.disconnect()))}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){this._isPaused?this._needsFullRefresh=!0:(n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount))}_renderRows(e,t){this._renderer.value&&(e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0)}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw((e=>this.refreshRows(e.start,e.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(e,t))):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};t.RenderService=d=r([i(2,u.IOptionsService),i(3,o.ICharSizeService),i(4,u.IDecorationService),i(5,u.IBufferService),i(6,o.ICoreBrowserService),i(7,o.IThemeService)],d)},9312:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.SelectionService=void 0;let a=n(9806),o=n(9504),s=n(456),c=n(4725),l=n(8460),u=n(844),d=n(6114),f=n(4841),p=n(511),m=n(2585),h=RegExp(`\xA0`,`g`),g=t.SelectionService=class extends u.Disposable{constructor(e,t,n,r,i,a,o,c,d){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=c,this._coreBrowserService=d,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new p.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new l.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new l.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new l.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new l.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((e=>this._handleTrim(e))),this.register(this._bufferService.buffers.onBufferActivate((e=>this._handleBufferActivate(e)))),this.enable(),this._model=new s.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,u.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!(!e||!t||e[0]===t[0]&&e[1]===t[1])}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map((e=>e.replace(h,` `))).join(d.isWindows?`\r
|
|
355
355
|
`:`
|
|
@@ -359,4 +359,4 @@ ${JSON.stringify(u.input,null,2)}`,f=ae.get(r),p=o?void 0:f??t;return(0,V.jsx)(c
|
|
|
359
359
|
\x1B[32m[terminal] reattached\x1B[0m\r
|
|
360
360
|
`),console.info(`[terminal] reattached`)):(u.current=!0,h.current?.())},onClose:e=>{e!==1e3&&u.current&&t.write(`\r
|
|
361
361
|
\x1B[33m[terminal] server restart detected — reconnecting…\x1B[0m\r
|
|
362
|
-
`)},onUnavailable:()=>{_.current?.()}});c.current=r;let i=()=>{try{n.fit()}catch{}};return window.addEventListener(`resize`,i),()=>{window.removeEventListener(`resize`,i);try{l.current?.dispose()}catch{}l.current=null,r.dispose();try{t.dispose()}catch{}o.current=null,s.current=null,c.current=null,f.current=0,p.current=0,m.current=0,u.current=!1,d.current=!1}},[e]),(0,V.jsx)(`div`,{ref:a,className:`remote-terminal`,style:{width:`100%`,height:`100%`,minHeight:360,background:`#0a0a0a`}})});function TE(e){let{show:t,onClose:n,conversationsLoading:r,conversationsError:a,conversationsList:o,setConversationsList:s,sessionKey:c,isStreaming:l,resetConversation:u,setMessages:d,setConversationId:f}=e,[p,m]=(0,B.useState)(null),[g,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(``),[x,S]=(0,B.useState)(!1),C=(0,B.useRef)(null);(0,B.useEffect)(()=>{t||(m(null),v(null),b(``),S(!1))},[t]),(0,B.useEffect)(()=>{g?.phase===`editing`&&(C.current?.focus(),C.current?.select())},[g]);function w(){m(null),v(null),b(``),S(!1)}async function T(e){if(c){w(),m(e),v({phase:`loading`});try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label?session_key=${encodeURIComponent(c)}`,{method:`POST`});if(!t.ok){v({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Request failed`});return}let n=await t.json();n.label?(v({phase:`editing`}),b(n.label)):v({phase:`error`,reason:`Not enough message content to suggest a name`})}catch(e){console.error(`[admin-modal] label suggestion failed:`,e),v({phase:`error`,reason:e instanceof Error?e.message:String(e)})}}}async function E(e){if(!(!c||!y.trim()||x)){S(!0);try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:y.trim(),session_key:c})});if(!t.ok){v({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Rename failed`}),S(!1);return}s(t=>t.map(t=>t.conversationId===e?{...t,name:y.trim()}:t)),w()}catch(e){console.error(`[admin-modal] label rename failed:`,e),v({phase:`error`,reason:e instanceof Error?e.message:String(e)}),S(!1)}}}return t?(0,V.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,V.jsxs)(`div`,{className:`claude-info-modal conversations-modal`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`claude-info-header`,children:[(0,V.jsx)(ze,{size:12}),`Conversations`,(0,V.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,V.jsxs)(`div`,{className:`conversations-list`,children:[r&&(0,V.jsxs)(`div`,{className:`conversations-empty`,children:[(0,V.jsx)(ie,{size:14,className:`spin`}),` Loading…`]}),a&&(0,V.jsx)(`div`,{className:`conversations-empty conversations-error`,children:a}),!r&&!a&&o.length===0&&(0,V.jsx)(`div`,{className:`conversations-empty`,children:`No recent conversations`}),!r&&!a&&o.map(e=>{let t=p===e.conversationId,r=t&&g?.phase===`loading`,a=t&&g?.phase===`editing`,o=t&&g?.phase===`error`;return(0,V.jsxs)(`div`,{className:`conversations-row`,children:[(0,V.jsxs)(`div`,{className:`conversations-row-info`,children:[r&&(0,V.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading`,children:[(0,V.jsx)(ie,{size:12,className:`spin`}),` Generating suggestion…`]}),a&&(0,V.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,V.jsx)(`input`,{ref:C,type:`text`,className:`conversations-edit-input`,value:y,onChange:e=>b(e.target.value),onKeyDown:t=>{t.key===`Enter`&&y.trim()&&E(e.conversationId),t.key===`Escape`&&w()},maxLength:200}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!y.trim()||x,onClick:()=>E(e.conversationId),children:x?(0,V.jsx)(ie,{size:13,className:`spin`}):(0,V.jsx)(h,{size:13})}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:w,children:(0,V.jsx)(fe,{size:13})})]}),o&&(0,V.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,V.jsx)(`span`,{className:`conversations-edit-error`,children:g.reason}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>T(e.conversationId),children:(0,V.jsx)(de,{size:13})}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:w,children:(0,V.jsx)(fe,{size:13})})]}),!t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`conversations-row-name`,children:e.name||e.conversationId.slice(0,12)+`…`}),(0,V.jsxs)(`span`,{className:`conversations-row-meta`,children:[(0,V.jsx)(`span`,{className:`conversations-row-id`,children:e.conversationId.slice(0,8)}),(0,V.jsxs)(`span`,{className:`conversations-row-time`,children:[(0,V.jsx)(Se,{size:10}),(()=>{try{let t=new Date(e.updatedAt),n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}catch{return``}})()]})]})]})]}),(0,V.jsx)(`div`,{className:`conversations-row-actions`,children:!t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-rename`,title:`Rename conversation`,onClick:()=>T(e.conversationId),children:(0,V.jsx)(qe,{size:13})}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Resume conversation`,disabled:l,onClick:()=>{l||!c||(n(),u(),fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/resume?session_key=${encodeURIComponent(c)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to resume conversation`))).then(e=>{e.conversationId&&f(e.conversationId);let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?[{type:`text`,content:e.content}]:void 0,timestamp:new Date(e.createdAt).getTime()||0,historical:!0}));t.length>0&&d(t)}).catch(e=>{console.error(`[chat] conversation resume failed:`,e),d([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])}))},children:(0,V.jsx)(_,{size:13})}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-delete`,title:`Delete conversation`,onClick:()=>{s(t=>t.filter(t=>t.conversationId!==e.conversationId)),c&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(c)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e))},children:(0,V.jsx)(i,{size:13})})]})})]},e.conversationId)})]})]})}):null}function EE({src:e,onClose:t}){return e?(0,V.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,V.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,V.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function DE({show:e,onClose:t,onConfirm:n}){return e?(0,V.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,V.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`claude-info-header`,children:[(0,V.jsx)(`span`,{children:`Compact conversation?`}),(0,V.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,V.jsx)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:`Summarises the conversation history to free up context window space. The session continues with a compressed summary.`}),(0,V.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,V.jsx)(T,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,V.jsx)(T,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function OE(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,conversationId:o,contextModeHint:s,handleContextModeToggle:c}=e;if(!t)return null;let l=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),u=l.at(-1),d=u?.peak_request_pct==null?u?.context_window?Math.round((u.input_tokens+u.cache_creation_tokens+u.cache_read_tokens)/u.context_window*100):0:Math.round(u.peak_request_pct*100),f=l.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),p=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),m=l.reduce((e,t)=>e+(t.total_cost_usd??0),0),h=r?.account?.subscriptionType,g=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,V.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,V.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`claude-info-header`,children:[(0,V.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,V.jsx)(`span`,{children:`Claude Code`}),(0,V.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,V.jsxs)(`div`,{className:`claude-info-section`,children:[(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(h||p||m>0)&&(0,V.jsxs)(`div`,{className:`claude-info-section`,children:[h&&(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,V.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:h})]}),p&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,V.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(p.utilization*100),`%`]})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:g(p.resetsAt)})]}),p.isUsingOverage&&(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),m>0&&(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,V.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,m<.01?m.toFixed(4):m.toFixed(2)]})]})]}),(0,V.jsxs)(`div`,{className:`claude-info-section`,children:[(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Context mode`}),(0,V.jsxs)(`span`,{className:`claude-info-value claude-info-toggle`,role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},children:[r?.contextMode??`…`,s?` (next turn)`:``]})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:d>0?`${d}%`:`—`})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:f>0?ct(f):`—`})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:st(a)})]}),o&&(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Conversation`}),(0,V.jsx)(`span`,{className:`claude-info-value`,style:{fontFamily:`monospace`,fontSize:10},children:o.slice(0,8)})]})]})]})})}var kE=5e3,AE=5e3,jE=3e4;function ME(e){try{fetch(`/api/_client-error`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`unknown`,tag:`terminal-unavailable`,msg:`source=${e} corrId=upgrade-modal`}),keepalive:!0})}catch{}}function NE({show:e,onClose:t,versionInfo:n,sessionKey:r,onUpgradeComplete:i}){let[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null),_=(0,B.useRef)(null),v=(0,B.useRef)(null),y=(0,B.useRef)(0),b=(0,B.useRef)(null),x=(0,B.useRef)(0),S=(0,B.useRef)(0),C=n?.latest??null,w=(0,B.useCallback)(()=>{v.current&&=(clearInterval(v.current),null),b.current&&=(clearTimeout(b.current),null)},[]),T=(0,B.useCallback)(async()=>{let e=++y.current;f(null);try{let t=await fetch(`/api/health`,{cache:`no-store`});if(e!==y.current)return;if(!t.ok){f(!1),m(!0),ME(`pre-flight`);return}let n=await t.json();if(e!==y.current)return;let r=n?.terminal_ready===!0;f(r),r||(m(!0),ME(`pre-flight`))}catch{if(e!==y.current)return;f(!1),m(!0),ME(`pre-flight`)}},[]);(0,B.useEffect)(()=>{if(!e){w(),o(!1),c(!1),f(null),m(!1),u(!1),g(null),y.current++;return}T()},[e,w,T]),(0,B.useEffect)(()=>w,[w]),(0,B.useEffect)(()=>{if(!(!e||!a||s||!C))return v.current=setInterval(async()=>{try{let e=await fetch(`/api/admin/version`,{cache:`no-store`});if(!e.ok)return;(await e.json()).installed===C&&(w(),c(!0),i(),setTimeout(()=>window.location.reload(),2e3))}catch{}},kE),w},[e,a,s,C,i,w]);function E(){if(!C){console.warn(`[update] Upgrade blocked: no target version`);return}p||h!==null||a||(g(`printf '[upgrade] starting at %s — shell+ws+tmux+xterm chain OK\\n' "$(date -u +%FT%TZ)" && npx -y @rubytech/create-maxy@latest\r`),l||u(!0))}let D=(0,B.useCallback)(e=>{b.current=setTimeout(()=>{let e=_.current;if(!e)return;let t=e.getBytesReceived();if(t===x.current){let n=e.getLastByteAt(),r=n===0?S.current:n,i=`\r\n\x1b[33m[terminal] no bytes from upstream in ${Math.max(1,Math.round((Date.now()-r)/1e3))}s — ws.readyState=${e.getReadyState()}, bytesReceived=${t}, attempt=${e.getAttempt()}\x1b[0m\r\n`;e.writeDiagnostic(i)}x.current=t,D(jE)},e)},[]);function O(){if(h!==null){if(!_.current?.send(h)){console.warn(`[update] send() returned false on onReady — terminal closed between OPEN and send`);return}S.current=Date.now(),x.current=_.current?.getBytesReceived()??0,console.info(`[update] upgrade command sent via onReady corrId=upgrade-modal`),g(null),o(!0),D(AE)}}function k(){if(S.current===0)return;let e=Date.now()-S.current;console.info(`[update] first upstream byte observed corrId=upgrade-modal elapsed_ms=${e}`)}function A(){p||(m(!0),ME(`on-unavailable`))}function j(){w(),m(!1),u(!1),o(!1),g(null),T()}if(!e)return null;let M=l&&d===!0&&!p;return(0,V.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(!a||s)&&t()},children:(0,V.jsxs)(`div`,{className:`claude-info-modal update-modal update-modal-terminal`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`claude-info-header`,children:[(0,V.jsx)(le,{size:12}),`Software Update`,(0,V.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),(0,V.jsxs)(`div`,{className:`update-modal-body update-modal-body-terminal`,children:[(0,V.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,V.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,V.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,C??`…`]})]})]}),p?(0,V.jsx)(`div`,{className:`update-modal-terminal-wrap`,style:{height:420},children:(0,V.jsxs)(`div`,{className:`update-modal-terminal-unavailable`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`update-modal-terminal-unavailable-title`,children:`Admin terminal not available.`}),(0,V.jsxs)(`div`,{className:`update-modal-terminal-unavailable-body`,children:[`Re-run the installer from a shell:`,(0,V.jsx)(`code`,{className:`update-modal-terminal-unavailable-cmd`,children:`npx -y @rubytech/create-maxy@latest`})]}),(0,V.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:j,children:`Try again`})]})}):M?(0,V.jsx)(`div`,{className:`update-modal-terminal-wrap`,style:{height:420},children:(0,V.jsx)(wE,{ref:_,corrId:`upgrade-modal`,onReady:O,onFirstByte:k,onUnavailable:A})}):(0,V.jsx)(`div`,{className:`update-modal-ready-row`,children:d===null?`Checking admin terminal…`:`Ready to upgrade — click Upgrade to begin.`}),!a&&!s&&!p&&(0,V.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:E,disabled:d!==!0||h!==null,children:`Upgrade`}),s&&(0,V.jsxs)(`div`,{className:`update-modal-result`,children:[(0,V.jsx)(R,{size:14,className:`update-success-icon`}),(0,V.jsxs)(`span`,{children:[`Upgraded to v`,C,` — reloading…`]})]})]})]})})}function PE({onClose:e}){ot();let[t,n]=(0,B.useState)(!1),r=(0,B.useRef)(null),i=(0,B.useRef)(null),a=(0,B.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),r.current&&!r.current.closed&&r.current.close(),r.current=null,n(!1)},[]),o=(0,B.useCallback)(()=>{let t=`/vnc-popout.html?title=${encodeURIComponent(v.productName)}`,o=window.open(t,`maxy-vnc-overlay-popout`,`width=1024,height=768`);o&&(r.current=o,n(!0),i.current=setInterval(()=>{r.current?.closed&&(a(),e())},500))},[a,e]),s=(0,B.useCallback)(()=>{a(),e()},[a,e]);(0,B.useEffect)(()=>{if(t)return;let e=e=>{e.key===`Escape`&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,s]),(0,B.useEffect)(()=>()=>a(),[a]);let c=Lt({handlePopout:o,disabled:t});return t?(0,V.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer__title`,children:v.productName}),(0,V.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:We,onClick:()=>{a()},"aria-label":`Pop back in`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:fe,onClick:s,"aria-label":`Close`})]}):(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...c,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:v.productName}),(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:o,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:fe,onClick:s,"aria-label":`Close`})]})]}),(0,V.jsx)(`iframe`,{src:`/vnc-viewer.html`,className:`browser-viewer-fullscreen__iframe`,title:v.productName})]})}function FE({onClose:e}){let[t,n]=(0,B.useState)(`connecting`),[r,i]=(0,B.useState)(0);(0,B.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let a=(0,B.useCallback)(()=>n(`connected`),[]),o=(0,B.useCallback)(()=>n(`unavailable`),[]),s=(0,B.useCallback)(()=>{n(`connecting`),i(e=>e+1)},[]);return(0,V.jsxs)(`div`,{className:`terminal-overlay-fullscreen`,children:[(0,V.jsxs)(`div`,{className:`terminal-overlay-fullscreen__bar`,children:[(0,V.jsxs)(`span`,{className:`terminal-overlay-fullscreen__heading`,children:[(0,V.jsx)(Qe,{className:`terminal-overlay-fullscreen__icon`}),(0,V.jsx)(`span`,{className:`terminal-overlay-fullscreen__title`,children:v.productName}),t===`connecting`&&(0,V.jsx)(`span`,{className:`terminal-overlay-fullscreen__status`,children:`· Attaching…`})]}),(0,V.jsx)(`div`,{className:`terminal-overlay-fullscreen__actions`,children:(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:fe,onClick:e,"aria-label":`Close`})})]}),(0,V.jsx)(`div`,{className:`terminal-overlay-fullscreen__body`,children:t===`unavailable`?(0,V.jsxs)(`div`,{className:`terminal-overlay-fullscreen__error`,children:[(0,V.jsx)(`p`,{className:`terminal-overlay-fullscreen__error-msg`,children:`Remote terminal not available. Re-run the installer:`}),(0,V.jsx)(`code`,{className:`terminal-overlay-fullscreen__error-cmd`,children:`npx -y @rubytech/create-maxy@latest`}),(0,V.jsx)(T,{variant:`secondary`,size:`sm`,onClick:s,children:`Try again`})]}):(0,V.jsx)(wE,{corrId:`header-overlay`,onReady:a,onUnavailable:o},r)})]})}function IE(){ot();let e=(0,B.useRef)(null),[t,n]=(0,B.useState)(null),[r,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!1),[c,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null),[g,_]=(0,B.useState)(!1),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(null),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)([]),[k,A]=(0,B.useState)(!1),[j,M]=(0,B.useState)(null),[N,P]=(0,B.useState)(null),[ee,F]=(0,B.useState)(!1),[te,I]=(0,B.useState)(null),[ne,ae]=(0,B.useState)(!1),[le,ue]=(0,B.useState)(!1),[de,pe]=(0,B.useState)(!1),me=(0,B.useRef)(!1),he=(0,B.useRef)(!1),ge=(0,B.useRef)(!1),_e=(0,B.useRef)(null),ve=l(),ye=lt(),R=ht(),be=wt(),z=Ct({sessionKey:R.sessionKey,setSessionKey:R.setSessionKey,setAppState:R.setAppState,setConversationId:R.setConversationId,startElapsedTimer:ye.startElapsedTimer,stopElapsedTimer:ye.stopElapsedTimer,resetTimerState:ye.resetTimerState,pausedElapsedRef:ye.pausedElapsedRef,expandAllDefaultRef:R.expandAllDefaultRef,setExpandAll:R.setExpandAll,getPendingFiles:()=>be.pendingFiles,clearPendingFiles:be.clearFiles,inputRef:e});(0,B.useEffect)(()=>{u(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,B.useEffect)(()=>{function e(e){e.key===`Escape`&&(t?n(null):ve.selectionMode&&ve.exitSelection())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,ve.selectionMode]),(0,B.useEffect)(()=>{(R.appState===`set-pin`||R.appState===`enter-pin`)&&setTimeout(()=>R.pinInputRef.current?.focus(),100),R.appState===`chat`&&setTimeout(()=>e.current?.focus(),100)},[R.appState,z.greetingGeneration]),(0,B.useEffect)(()=>{if(R.appState!==`chat`)return;history.pushState({maxyChat:!0},``);function e(){console.debug(`[history-guard] popstate absorbed`),history.pushState({maxyChat:!0},``)}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[R.appState]);let xe=(0,B.useRef)(z.greetingGeneration);return(0,B.useEffect)(()=>{z.greetingGeneration!==xe.current&&(xe.current=z.greetingGeneration,R.onboardingComplete===!1&&(me.current=!1))},[z.greetingGeneration,R.onboardingComplete]),(0,B.useEffect)(()=>{R.appState===`chat`&&R.onboardingComplete===!1&&(me.current||(me.current=!0,z.sendSystemPrompt(`[Begin onboarding.]`)))},[R.appState,R.onboardingComplete,z.greetingGeneration]),(0,B.useEffect)(()=>{if(!d)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||P(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[d]),(0,B.useEffect)(()=>{if(R.appState!==`chat`){he.current=!1,ge.current=!1;return}if(he.current)return;he.current=!0;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||(P(t),!(!t.updateAvailable||ge.current)&&(I(t),F(!0),fetch(`/api/admin/version/alert-surfaced`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({installed:t.installed,latest:t.latest})}).catch(e=>{console.error(`[admin/version] alert-surfaced signal failed:`,e)})))}).catch(e=>{console.error(`[admin/version] session-start client fetch failed:`,e)}),()=>{e=!0}},[R.appState]),(0,B.useEffect)(()=>{if(!d){m(null),b(null),S(null),P(null);return}function e(e){_e.current&&!_e.current.contains(e.target)&&f(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[d]),(0,B.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`platform-onboarding`);return e.onmessage=e=>{e.data?.type===`remote-password-set`&&z.sendMessageRef.current(`I've set the remote password`)},()=>e.close()},[]),R.appState===`loading`?(0,V.jsx)(`div`,{className:`chat-page admin-page`,children:(0,V.jsx)(`header`,{className:`chat-header`,children:(0,V.jsx)(`img`,{src:re,alt:v.productName,className:`chat-logo`})})}):R.appState===`set-pin`?(0,V.jsx)(Et,{pin:R.pin,setPin:R.setPin,confirmPin:R.confirmPin,setConfirmPin:R.setConfirmPin,showPin:R.showPin,setShowPin:R.setShowPin,pinLoading:R.pinLoading,pinError:R.pinError,pinInputRef:R.pinInputRef,confirmPinInputRef:R.confirmPinInputRef,setPinFormRef:R.setPinFormRef,onSubmit:R.handleSetPin}):R.appState===`onboarding-choice`?(0,V.jsx)(At,{setAppState:R.setAppState,setOnboardingComplete:R.setOnboardingComplete}):R.appState===`connect-claude`?(0,V.jsx)(kt,{authPolling:R.authPolling,setAuthPolling:R.setAuthPolling,authLoading:R.authLoading,setAuthLoading:R.setAuthLoading,pinError:R.pinError,setPinError:R.setPinError,setAppState:R.setAppState}):R.appState===`enter-pin`?(0,V.jsx)(Dt,{pin:R.pin,setPin:R.setPin,showPin:R.showPin,setShowPin:R.setShowPin,pinLoading:R.pinLoading,pinError:R.pinError,pinInputRef:R.pinInputRef,onSubmit:R.handleLogin,onChangePin:R.handleChangePin}):R.appState===`account-picker`?(0,V.jsx)(Ot,{accounts:R.accounts,loading:R.accountPickerLoading,error:R.pinError,onSelect:R.handleAccountSelect}):(0,V.jsx)(C,{value:{onShowVnc:()=>ae(!0)},children:(0,V.jsxs)(`div`,{className:`chat-page admin-page`,children:[(0,V.jsxs)(`header`,{className:`chat-header`,children:[(0,V.jsx)(`img`,{src:re,alt:v.productName,className:`chat-logo`}),(!v.logoContainsName||R.businessName)&&(0,V.jsx)(`div`,{children:(0,V.jsx)(`h1`,{className:`chat-tagline`,children:R.businessName||v.productName})}),(0,V.jsxs)(`div`,{className:`chat-burger-wrap`,ref:_e,children:[(0,V.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>f(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":d,children:(0,V.jsx)(se,{size:20})}),d&&(0,V.jsxs)(`div`,{className:`chat-menu`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(!(ne||le)){ue(!0),f(!1);try{let e=await(await fetch(`/api/admin/browser/launch`,{method:`POST`})).json().catch(()=>({ok:!1,error:`Invalid response`}));if(!e.ok)throw Error(e.error??`Failed to launch browser`);ae(!0)}catch(e){console.error(`[browser] Launch failed:`,e),alert(e instanceof Error?e.message:`Failed to launch browser`)}finally{ue(!1)}}},disabled:le,children:[(0,V.jsx)(O,{size:14}),` Browser`,le&&(0,V.jsx)(ie,{size:12,className:`spin`})]}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{de||(f(!1),pe(!0))},children:[(0,V.jsx)(Qe,{size:14}),` Terminal`]}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{f(!1),window.location.href=`/data`},children:[(0,V.jsx)(oe,{size:14}),` Data`]}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{f(!1),window.location.href=`/graph`},children:[(0,V.jsx)(ce,{size:14}),` Graph`]}),(0,V.jsx)(`div`,{className:`chat-menu-divider`}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(p!==null){m(null),S(null);return}_(!0),b(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);m((await e.json()).agents??[])}catch(e){console.error(`[admin] agent list failed:`,e),b(e instanceof Error?e.message:String(e))}finally{_(!1)}},children:[(0,V.jsx)(De,{size:14}),` Public`,g&&(0,V.jsx)(ie,{size:12,className:`spin`})]}),p!==null&&(0,V.jsxs)(`div`,{className:`chat-menu-agents`,children:[y&&(0,V.jsx)(`span`,{className:`chat-menu-agent-error`,children:y}),p.length===0&&!y&&(0,V.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),p.map(e=>(0,V.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,V.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,V.jsxs)(`span`,{className:`agent-text`,children:[(0,V.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,V.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),x===e.slug?(0,V.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,V.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>{S(null),m(t=>t?.filter(t=>t.slug!==e.slug)??null),fetch(`/api/admin/agents/${encodeURIComponent(e.slug)}`,{method:`DELETE`}).catch(e=>console.error(`[admin/agents] delete failed:`,e))},children:(0,V.jsx)(h,{size:12})}),(0,V.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>S(null),children:(0,V.jsx)(fe,{size:12})})]}):(0,V.jsxs)(`span`,{className:`agent-actions`,children:[(0,V.jsx)(`a`,{href:`${c}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>f(!1),children:(0,V.jsx)(De,{size:12})}),(0,V.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>S(e.slug),children:(0,V.jsx)(i,{size:12})})]})]},e.slug))]}),(0,V.jsx)(`div`,{className:`chat-menu-divider`}),N?.updateAvailable?(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-version`,onClick:()=>{N.latest&&(I(N),f(!1),F(!0))},children:[(0,V.jsx)(Pe,{size:14}),(0,V.jsxs)(`span`,{className:`version-installed`,children:[`v`,N.installed,(0,V.jsx)(`span`,{className:`version-update-dot`})]})]}):(0,V.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,V.jsx)(Pe,{size:14}),(0,V.jsxs)(`span`,{className:`version-installed`,children:[N?`v${N.installed}`:`…`,N&&!N.updateAvailable&&(0,V.jsx)(`span`,{className:`version-uptodate-dot`})]})]}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{f(!1),R.handleLogout(),z.setMessages([])},children:[(0,V.jsx)(L,{size:14}),` Log out`]})]})]})]}),(0,V.jsx)(uE,{messages:z.messages,isStreaming:z.isStreaming,elapsedSeconds:ye.elapsedSeconds,sessionTurnStart:ye.sessionTurnStart,expandAll:R.expandAll,setExpandAll:R.setExpandAll,conversationCompacted:z.conversationCompacted,isCompacting:z.isCompacting,setShowCompactConfirm:s,handleComponentSubmit:z.handleComponentSubmit,effectiveSubmitted:z.effectiveSubmitted,selectionMode:ve.selectionMode,selectedItems:ve.selectedItems,toggleSelectItem:ve.toggleSelectItem,sessionKey:R.sessionKey,setLightboxSrc:n,messageQueue:z.messageQueue,messageQueueRef:z.messageQueueRef,setQueue:z.setQueue,sendMessage:z.sendMessage,appState:R.appState,onboardingComplete:R.onboardingComplete}),(0,V.jsx)(dE,{offer:z.topicChangeOffer,onFreshStart:z.handleTopicFreshStart,onContinue:z.handleTopicContinue,disabled:z.isStreaming}),(0,V.jsx)(mE,{selectionMode:ve.selectionMode,selectedItems:ve.selectedItems,copyToast:ve.copyToast||null,exitSelection:ve.exitSelection,enterSelection:ve.enterSelection,copySelected:ve.copySelected,showCopyToast:ve.showCopyToast,input:z.input,setInput:z.setInput,inputRef:e,pendingFiles:be.pendingFiles,setPendingFiles:be.setPendingFiles,isDragOver:be.isDragOver,attachError:be.attachError,fileInputRef:be.fileInputRef,addFiles:be.addFiles,removeFile:be.removeFile,onDragOver:be.onDragOver,onDragLeave:be.onDragLeave,onDrop:be.onDrop,isStreaming:z.isStreaming,wasPaused:z.wasPaused,messages:z.messages,messageQueueRef:z.messageQueueRef,setQueue:z.setQueue,sendMessage:z.sendMessage,stopStreaming:z.stopStreaming,disconnecting:R.disconnecting,handleDisconnect:R.handleDisconnect,claudeInfo:R.claudeInfo,setClaudeInfo:R.setClaudeInfo,setShowClaudeInfo:a,conversationId:R.conversationId,onNewConversation:z.startNewConversation,newConversationDisabled:z.isStreaming||z.isCompacting,onOpenConversations:async()=>{T(!0),A(!0),M(null);try{let e=await fetch(`/api/admin/sessions?session_key=${encodeURIComponent(R.sessionKey)}`);if(!e.ok)throw Error(`Failed to load conversations`);D((await e.json()).sessions??[])}catch(e){console.error(`[admin] conversation list failed:`,e),M(e instanceof Error?e.message:String(e))}finally{A(!1)}}}),ve.copyToast&&(0,V.jsx)(`span`,{className:`copy-toast${ve.copyToast===`failed`?` copy-toast-failed`:``}`,children:ve.copyToast===`copied`?`Copied`:`Copy failed`}),(0,V.jsx)(TE,{show:w,onClose:()=>T(!1),conversationsLoading:k,conversationsError:j,conversationsList:E,setConversationsList:D,sessionKey:R.sessionKey,isStreaming:z.isStreaming,resetConversation:z.resetConversation,setMessages:z.setMessages,setConversationId:R.setConversationId}),(0,V.jsx)(EE,{src:t,onClose:()=>n(null)}),(0,V.jsx)(DE,{show:o,onClose:()=>s(!1),onConfirm:z.handleCompactNow}),(0,V.jsx)(OE,{show:r,onClose:()=>{a(!1),R.setClaudeInfo(null)},claudeInfo:R.claudeInfo,messages:z.messages,sessionElapsed:ye.sessionElapsed,conversationId:R.conversationId,contextModeHint:R.contextModeHint,handleContextModeToggle:R.handleContextModeToggle}),(0,V.jsx)(NE,{show:ee,onClose:()=>{F(!1),ge.current=!0},versionInfo:te,sessionKey:R.sessionKey,onUpgradeComplete:()=>P(null)}),ne&&(0,V.jsx)(PE,{onClose:()=>ae(!1)}),de&&(0,V.jsx)(FE,{onClose:()=>pe(!1)})]})})}(0,at.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(IE,{}));
|
|
362
|
+
`)},onUnavailable:()=>{_.current?.()}});c.current=r;let i=()=>{try{n.fit()}catch{}};return window.addEventListener(`resize`,i),()=>{window.removeEventListener(`resize`,i);try{l.current?.dispose()}catch{}l.current=null,r.dispose();try{t.dispose()}catch{}o.current=null,s.current=null,c.current=null,f.current=0,p.current=0,m.current=0,u.current=!1,d.current=!1}},[e]),(0,V.jsx)(`div`,{ref:a,className:`remote-terminal`,style:{width:`100%`,height:`100%`,minHeight:360,background:`#0a0a0a`}})});function TE(e){let{show:t,onClose:n,conversationsLoading:r,conversationsError:a,conversationsList:o,setConversationsList:s,sessionKey:c,isStreaming:l,resetConversation:u,setMessages:d,setConversationId:f}=e,[p,m]=(0,B.useState)(null),[g,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(``),[x,S]=(0,B.useState)(!1),C=(0,B.useRef)(null);(0,B.useEffect)(()=>{t||(m(null),v(null),b(``),S(!1))},[t]),(0,B.useEffect)(()=>{g?.phase===`editing`&&(C.current?.focus(),C.current?.select())},[g]);function w(){m(null),v(null),b(``),S(!1)}async function T(e){if(c){w(),m(e),v({phase:`loading`});try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label?session_key=${encodeURIComponent(c)}`,{method:`POST`});if(!t.ok){v({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Request failed`});return}let n=await t.json();n.label?(v({phase:`editing`}),b(n.label)):v({phase:`error`,reason:`Not enough message content to suggest a name`})}catch(e){console.error(`[admin-modal] label suggestion failed:`,e),v({phase:`error`,reason:e instanceof Error?e.message:String(e)})}}}async function E(e){if(!(!c||!y.trim()||x)){S(!0);try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:y.trim(),session_key:c})});if(!t.ok){v({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Rename failed`}),S(!1);return}s(t=>t.map(t=>t.conversationId===e?{...t,name:y.trim()}:t)),w()}catch(e){console.error(`[admin-modal] label rename failed:`,e),v({phase:`error`,reason:e instanceof Error?e.message:String(e)}),S(!1)}}}return t?(0,V.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,V.jsxs)(`div`,{className:`claude-info-modal conversations-modal`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`claude-info-header`,children:[(0,V.jsx)(ze,{size:12}),`Conversations`,(0,V.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,V.jsxs)(`div`,{className:`conversations-list`,children:[r&&(0,V.jsxs)(`div`,{className:`conversations-empty`,children:[(0,V.jsx)(ie,{size:14,className:`spin`}),` Loading…`]}),a&&(0,V.jsx)(`div`,{className:`conversations-empty conversations-error`,children:a}),!r&&!a&&o.length===0&&(0,V.jsx)(`div`,{className:`conversations-empty`,children:`No recent conversations`}),!r&&!a&&o.map(e=>{let t=p===e.conversationId,r=t&&g?.phase===`loading`,a=t&&g?.phase===`editing`,o=t&&g?.phase===`error`;return(0,V.jsxs)(`div`,{className:`conversations-row`,children:[(0,V.jsxs)(`div`,{className:`conversations-row-info`,children:[r&&(0,V.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading`,children:[(0,V.jsx)(ie,{size:12,className:`spin`}),` Generating suggestion…`]}),a&&(0,V.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,V.jsx)(`input`,{ref:C,type:`text`,className:`conversations-edit-input`,value:y,onChange:e=>b(e.target.value),onKeyDown:t=>{t.key===`Enter`&&y.trim()&&E(e.conversationId),t.key===`Escape`&&w()},maxLength:200}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!y.trim()||x,onClick:()=>E(e.conversationId),children:x?(0,V.jsx)(ie,{size:13,className:`spin`}):(0,V.jsx)(h,{size:13})}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:w,children:(0,V.jsx)(fe,{size:13})})]}),o&&(0,V.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,V.jsx)(`span`,{className:`conversations-edit-error`,children:g.reason}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>T(e.conversationId),children:(0,V.jsx)(de,{size:13})}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:w,children:(0,V.jsx)(fe,{size:13})})]}),!t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`conversations-row-name`,children:e.name||e.conversationId.slice(0,12)+`…`}),(0,V.jsxs)(`span`,{className:`conversations-row-meta`,children:[(0,V.jsx)(`span`,{className:`conversations-row-id`,children:e.conversationId.slice(0,8)}),(0,V.jsxs)(`span`,{className:`conversations-row-time`,children:[(0,V.jsx)(z,{size:10}),(()=>{try{let t=new Date(e.updatedAt),n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}catch{return``}})()]})]})]})]}),(0,V.jsx)(`div`,{className:`conversations-row-actions`,children:!t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-rename`,title:`Rename conversation`,onClick:()=>T(e.conversationId),children:(0,V.jsx)(qe,{size:13})}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Resume conversation`,disabled:l,onClick:()=>{l||!c||(n(),u(),fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/resume?session_key=${encodeURIComponent(c)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to resume conversation`))).then(e=>{e.conversationId&&f(e.conversationId);let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?[{type:`text`,content:e.content}]:void 0,timestamp:new Date(e.createdAt).getTime()||0,historical:!0}));t.length>0&&d(t)}).catch(e=>{console.error(`[chat] conversation resume failed:`,e),d([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])}))},children:(0,V.jsx)(_,{size:13})}),(0,V.jsx)(`button`,{type:`button`,className:`conversations-action conversations-delete`,title:`Delete conversation`,onClick:()=>{s(t=>t.filter(t=>t.conversationId!==e.conversationId)),c&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(c)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e))},children:(0,V.jsx)(i,{size:13})})]})})]},e.conversationId)})]})]})}):null}function EE({src:e,onClose:t}){return e?(0,V.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,V.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,V.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function DE({show:e,onClose:t,onConfirm:n}){return e?(0,V.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,V.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`claude-info-header`,children:[(0,V.jsx)(`span`,{children:`Compact conversation?`}),(0,V.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,V.jsx)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:`Summarises the conversation history to free up context window space. The session continues with a compressed summary.`}),(0,V.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,V.jsx)(T,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,V.jsx)(T,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function OE(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,conversationId:o,contextModeHint:s,handleContextModeToggle:c}=e;if(!t)return null;let l=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),u=l.at(-1),d=u?.peak_request_pct==null?u?.context_window?Math.round((u.input_tokens+u.cache_creation_tokens+u.cache_read_tokens)/u.context_window*100):0:Math.round(u.peak_request_pct*100),f=l.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),p=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),m=l.reduce((e,t)=>e+(t.total_cost_usd??0),0),h=r?.account?.subscriptionType,g=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,V.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,V.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`claude-info-header`,children:[(0,V.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,V.jsx)(`span`,{children:`Claude Code`}),(0,V.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,V.jsxs)(`div`,{className:`claude-info-section`,children:[(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(h||p||m>0)&&(0,V.jsxs)(`div`,{className:`claude-info-section`,children:[h&&(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,V.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:h})]}),p&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,V.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(p.utilization*100),`%`]})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:g(p.resetsAt)})]}),p.isUsingOverage&&(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),m>0&&(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,V.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,m<.01?m.toFixed(4):m.toFixed(2)]})]})]}),(0,V.jsxs)(`div`,{className:`claude-info-section`,children:[(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Context mode`}),(0,V.jsxs)(`span`,{className:`claude-info-value claude-info-toggle`,role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},children:[r?.contextMode??`…`,s?` (next turn)`:``]})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:d>0?`${d}%`:`—`})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:f>0?ct(f):`—`})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,V.jsx)(`span`,{className:`claude-info-value`,children:st(a)})]}),o&&(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Conversation`}),(0,V.jsx)(`span`,{className:`claude-info-value`,style:{fontFamily:`monospace`,fontSize:10},children:o.slice(0,8)})]})]})]})})}var kE=5e3,AE=5e3,jE=3e4;function ME(e){try{fetch(`/api/_client-error`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`unknown`,tag:`terminal-unavailable`,msg:`source=${e} corrId=upgrade-modal`}),keepalive:!0})}catch{}}function NE({show:e,onClose:t,versionInfo:n,sessionKey:r,onUpgradeComplete:i}){let[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null),_=(0,B.useRef)(null),v=(0,B.useRef)(null),y=(0,B.useRef)(0),b=(0,B.useRef)(null),x=(0,B.useRef)(0),S=(0,B.useRef)(0),C=n?.latest??null,w=(0,B.useCallback)(()=>{v.current&&=(clearInterval(v.current),null),b.current&&=(clearTimeout(b.current),null)},[]),T=(0,B.useCallback)(async()=>{let e=++y.current;f(null);try{let t=await fetch(`/api/health`,{cache:`no-store`});if(e!==y.current)return;if(!t.ok){f(!1),m(!0),ME(`pre-flight`);return}let n=await t.json();if(e!==y.current)return;let r=n?.terminal_ready===!0;f(r),r||(m(!0),ME(`pre-flight`))}catch{if(e!==y.current)return;f(!1),m(!0),ME(`pre-flight`)}},[]);(0,B.useEffect)(()=>{if(!e){w(),o(!1),c(!1),f(null),m(!1),u(!1),g(null),y.current++;return}T()},[e,w,T]),(0,B.useEffect)(()=>w,[w]),(0,B.useEffect)(()=>{if(!(!e||!a||s||!C))return v.current=setInterval(async()=>{try{let e=await fetch(`/api/admin/version`,{cache:`no-store`});if(!e.ok)return;(await e.json()).installed===C&&(w(),c(!0),i(),setTimeout(()=>window.location.reload(),2e3))}catch{}},kE),w},[e,a,s,C,i,w]);function E(){if(!C){console.warn(`[update] Upgrade blocked: no target version`);return}p||h!==null||a||(g(`printf '[upgrade] starting at %s — shell+ws+tmux+xterm chain OK\\n' "$(date -u +%FT%TZ)" && npx -y @rubytech/create-maxy@latest\r`),l||u(!0))}let D=(0,B.useCallback)(e=>{b.current=setTimeout(()=>{let e=_.current;if(!e)return;let t=e.getBytesReceived();if(t===x.current){let n=e.getLastByteAt(),r=n===0?S.current:n,i=`\r\n\x1b[33m[terminal] no bytes from upstream in ${Math.max(1,Math.round((Date.now()-r)/1e3))}s — ws.readyState=${e.getReadyState()}, bytesReceived=${t}, attempt=${e.getAttempt()}\x1b[0m\r\n`;e.writeDiagnostic(i)}x.current=t,D(jE)},e)},[]);function O(){if(h!==null){if(!_.current?.send(h)){console.warn(`[update] send() returned false on onReady — terminal closed between OPEN and send`);return}S.current=Date.now(),x.current=_.current?.getBytesReceived()??0,console.info(`[update] upgrade command sent via onReady corrId=upgrade-modal`),g(null),o(!0),D(AE)}}function k(){if(S.current===0)return;let e=Date.now()-S.current;console.info(`[update] first upstream byte observed corrId=upgrade-modal elapsed_ms=${e}`)}function A(){p||(m(!0),ME(`on-unavailable`))}function j(){w(),m(!1),u(!1),o(!1),g(null),T()}if(!e)return null;let M=l&&d===!0&&!p;return(0,V.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(!a||s)&&t()},children:(0,V.jsxs)(`div`,{className:`claude-info-modal update-modal update-modal-terminal`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`claude-info-header`,children:[(0,V.jsx)(le,{size:12}),`Software Update`,(0,V.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),(0,V.jsxs)(`div`,{className:`update-modal-body update-modal-body-terminal`,children:[(0,V.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,V.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,V.jsxs)(`div`,{className:`claude-info-row`,children:[(0,V.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,V.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,C??`…`]})]})]}),p?(0,V.jsx)(`div`,{className:`update-modal-terminal-wrap`,style:{height:420},children:(0,V.jsxs)(`div`,{className:`update-modal-terminal-unavailable`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`update-modal-terminal-unavailable-title`,children:`Admin terminal not available.`}),(0,V.jsxs)(`div`,{className:`update-modal-terminal-unavailable-body`,children:[`Re-run the installer from a shell:`,(0,V.jsx)(`code`,{className:`update-modal-terminal-unavailable-cmd`,children:`npx -y @rubytech/create-maxy@latest`})]}),(0,V.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:j,children:`Try again`})]})}):M?(0,V.jsx)(`div`,{className:`update-modal-terminal-wrap`,style:{height:420},children:(0,V.jsx)(wE,{ref:_,corrId:`upgrade-modal`,onReady:O,onFirstByte:k,onUnavailable:A})}):(0,V.jsx)(`div`,{className:`update-modal-ready-row`,children:d===null?`Checking admin terminal…`:`Ready to upgrade — click Upgrade to begin.`}),!a&&!s&&!p&&(0,V.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:E,disabled:d!==!0||h!==null,children:`Upgrade`}),s&&(0,V.jsxs)(`div`,{className:`update-modal-result`,children:[(0,V.jsx)(be,{size:14,className:`update-success-icon`}),(0,V.jsxs)(`span`,{children:[`Upgraded to v`,C,` — reloading…`]})]})]})]})})}function PE({onClose:e}){ot();let[t,n]=(0,B.useState)(!1),r=(0,B.useRef)(null),i=(0,B.useRef)(null),a=(0,B.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),r.current&&!r.current.closed&&r.current.close(),r.current=null,n(!1)},[]),o=(0,B.useCallback)(()=>{let t=`/vnc-popout.html?title=${encodeURIComponent(v.productName)}`,o=window.open(t,`maxy-vnc-overlay-popout`,`width=1024,height=768`);o&&(r.current=o,n(!0),i.current=setInterval(()=>{r.current?.closed&&(a(),e())},500))},[a,e]),s=(0,B.useCallback)(()=>{a(),e()},[a,e]);(0,B.useEffect)(()=>{if(t)return;let e=e=>{e.key===`Escape`&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,s]),(0,B.useEffect)(()=>()=>a(),[a]);let c=Lt({handlePopout:o,disabled:t});return t?(0,V.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer__title`,children:v.productName}),(0,V.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:We,onClick:()=>{a()},"aria-label":`Pop back in`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:fe,onClick:s,"aria-label":`Close`})]}):(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...c,children:[(0,V.jsx)(O,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:v.productName}),(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:o,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:fe,onClick:s,"aria-label":`Close`})]})]}),(0,V.jsx)(`iframe`,{src:`/vnc-viewer.html`,className:`browser-viewer-fullscreen__iframe`,title:v.productName})]})}function FE({onClose:e}){ot();let[t,n]=(0,B.useState)(!1),r=(0,B.useRef)(null),i=(0,B.useRef)(null),a=(0,B.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),r.current&&!r.current.closed&&r.current.close(),r.current=null,n(!1)},[]),o=(0,B.useCallback)(()=>{let t=`/vnc-popout.html?title=${encodeURIComponent(v.productName)}`,o=window.open(t,`maxy-terminal-overlay-popout`,`width=1024,height=768`);o&&(r.current=o,n(!0),i.current=setInterval(()=>{r.current?.closed&&(a(),e())},500))},[a,e]),s=(0,B.useCallback)(()=>{a(),e()},[a,e]);(0,B.useEffect)(()=>{if(t)return;let e=e=>{e.key===`Escape`&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,s]),(0,B.useEffect)(()=>()=>a(),[a]);let c=Lt({handlePopout:o,disabled:t});return t?(0,V.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,V.jsx)(Qe,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer__title`,children:v.productName}),(0,V.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:We,onClick:()=>{a()},"aria-label":`Pop back in`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:fe,onClick:s,"aria-label":`Close`})]}):(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...c,children:[(0,V.jsx)(Qe,{className:`browser-viewer__icon`}),(0,V.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:v.productName}),(0,V.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:De,onClick:o,"aria-label":`Pop out`}),(0,V.jsx)(T,{variant:`ghost`,size:`sm`,icon:fe,onClick:s,"aria-label":`Close`})]})]}),(0,V.jsx)(`iframe`,{src:`/vnc-viewer.html`,className:`browser-viewer-fullscreen__iframe`,title:v.productName})]})}function IE(){ot();let e=(0,B.useRef)(null),[t,n]=(0,B.useState)(null),[r,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!1),[c,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null),[g,_]=(0,B.useState)(!1),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(null),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)([]),[k,A]=(0,B.useState)(!1),[j,M]=(0,B.useState)(null),[N,P]=(0,B.useState)(null),[ee,F]=(0,B.useState)(!1),[te,I]=(0,B.useState)(null),[ne,ae]=(0,B.useState)(!1),[le,ue]=(0,B.useState)(!1),[de,pe]=(0,B.useState)(!1),[me,he]=(0,B.useState)(!1),ge=(0,B.useRef)(!1),_e=(0,B.useRef)(!1),ve=(0,B.useRef)(!1),ye=(0,B.useRef)(null),be=l(),xe=lt(),R=ht(),Se=wt(),z=Ct({sessionKey:R.sessionKey,setSessionKey:R.setSessionKey,setAppState:R.setAppState,setConversationId:R.setConversationId,startElapsedTimer:xe.startElapsedTimer,stopElapsedTimer:xe.stopElapsedTimer,resetTimerState:xe.resetTimerState,pausedElapsedRef:xe.pausedElapsedRef,expandAllDefaultRef:R.expandAllDefaultRef,setExpandAll:R.setExpandAll,getPendingFiles:()=>Se.pendingFiles,clearPendingFiles:Se.clearFiles,inputRef:e});(0,B.useEffect)(()=>{u(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,B.useEffect)(()=>{function e(e){e.key===`Escape`&&(t?n(null):be.selectionMode&&be.exitSelection())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,be.selectionMode]),(0,B.useEffect)(()=>{(R.appState===`set-pin`||R.appState===`enter-pin`)&&setTimeout(()=>R.pinInputRef.current?.focus(),100),R.appState===`chat`&&setTimeout(()=>e.current?.focus(),100)},[R.appState,z.greetingGeneration]),(0,B.useEffect)(()=>{if(R.appState!==`chat`)return;history.pushState({maxyChat:!0},``);function e(){console.debug(`[history-guard] popstate absorbed`),history.pushState({maxyChat:!0},``)}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[R.appState]);let Ce=(0,B.useRef)(z.greetingGeneration);return(0,B.useEffect)(()=>{z.greetingGeneration!==Ce.current&&(Ce.current=z.greetingGeneration,R.onboardingComplete===!1&&(ge.current=!1))},[z.greetingGeneration,R.onboardingComplete]),(0,B.useEffect)(()=>{R.appState===`chat`&&R.onboardingComplete===!1&&(ge.current||(ge.current=!0,z.sendSystemPrompt(`[Begin onboarding.]`)))},[R.appState,R.onboardingComplete,z.greetingGeneration]),(0,B.useEffect)(()=>{if(!d)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||P(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[d]),(0,B.useEffect)(()=>{if(R.appState!==`chat`){_e.current=!1,ve.current=!1;return}if(_e.current)return;_e.current=!0;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||(P(t),!(!t.updateAvailable||ve.current)&&(I(t),F(!0),fetch(`/api/admin/version/alert-surfaced`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({installed:t.installed,latest:t.latest})}).catch(e=>{console.error(`[admin/version] alert-surfaced signal failed:`,e)})))}).catch(e=>{console.error(`[admin/version] session-start client fetch failed:`,e)}),()=>{e=!0}},[R.appState]),(0,B.useEffect)(()=>{if(!d){m(null),b(null),S(null),P(null);return}function e(e){ye.current&&!ye.current.contains(e.target)&&f(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[d]),(0,B.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`platform-onboarding`);return e.onmessage=e=>{e.data?.type===`remote-password-set`&&z.sendMessageRef.current(`I've set the remote password`)},()=>e.close()},[]),R.appState===`loading`?(0,V.jsx)(`div`,{className:`chat-page admin-page`,children:(0,V.jsx)(`header`,{className:`chat-header`,children:(0,V.jsx)(`img`,{src:re,alt:v.productName,className:`chat-logo`})})}):R.appState===`set-pin`?(0,V.jsx)(Et,{pin:R.pin,setPin:R.setPin,confirmPin:R.confirmPin,setConfirmPin:R.setConfirmPin,showPin:R.showPin,setShowPin:R.setShowPin,pinLoading:R.pinLoading,pinError:R.pinError,pinInputRef:R.pinInputRef,confirmPinInputRef:R.confirmPinInputRef,setPinFormRef:R.setPinFormRef,onSubmit:R.handleSetPin}):R.appState===`onboarding-choice`?(0,V.jsx)(At,{setAppState:R.setAppState,setOnboardingComplete:R.setOnboardingComplete}):R.appState===`connect-claude`?(0,V.jsx)(kt,{authPolling:R.authPolling,setAuthPolling:R.setAuthPolling,authLoading:R.authLoading,setAuthLoading:R.setAuthLoading,pinError:R.pinError,setPinError:R.setPinError,setAppState:R.setAppState}):R.appState===`enter-pin`?(0,V.jsx)(Dt,{pin:R.pin,setPin:R.setPin,showPin:R.showPin,setShowPin:R.setShowPin,pinLoading:R.pinLoading,pinError:R.pinError,pinInputRef:R.pinInputRef,onSubmit:R.handleLogin,onChangePin:R.handleChangePin}):R.appState===`account-picker`?(0,V.jsx)(Ot,{accounts:R.accounts,loading:R.accountPickerLoading,error:R.pinError,onSelect:R.handleAccountSelect}):(0,V.jsx)(C,{value:{onShowVnc:()=>ae(!0)},children:(0,V.jsxs)(`div`,{className:`chat-page admin-page`,children:[(0,V.jsxs)(`header`,{className:`chat-header`,children:[(0,V.jsx)(`img`,{src:re,alt:v.productName,className:`chat-logo`}),(!v.logoContainsName||R.businessName)&&(0,V.jsx)(`div`,{children:(0,V.jsx)(`h1`,{className:`chat-tagline`,children:R.businessName||v.productName})}),(0,V.jsxs)(`div`,{className:`chat-burger-wrap`,ref:ye,children:[(0,V.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>f(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":d,children:(0,V.jsx)(se,{size:20})}),d&&(0,V.jsxs)(`div`,{className:`chat-menu`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(!(ne||le)){ue(!0),f(!1);try{let e=await(await fetch(`/api/admin/browser/launch`,{method:`POST`})).json().catch(()=>({ok:!1,error:`Invalid response`}));if(!e.ok)throw Error(e.error??`Failed to launch browser`);ae(!0)}catch(e){console.error(`[browser] Launch failed:`,e),alert(e instanceof Error?e.message:`Failed to launch browser`)}finally{ue(!1)}}},disabled:le,children:[(0,V.jsx)(O,{size:14}),` Browser`,le&&(0,V.jsx)(ie,{size:12,className:`spin`})]}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(!(de||me)){he(!0),f(!1),console.log(`[terminal-overlay] launching`);try{let e=await(await fetch(`/api/admin/terminal/launch`,{method:`POST`})).json().catch(()=>({ok:!1,error:`Invalid response`}));if(!e.ok)throw Error(e.error??`Failed to launch terminal`);console.log(`[terminal-overlay] launched transport=${e.transport}`),pe(!0)}catch(e){let t=e instanceof Error?e.message:`Failed to launch terminal`;console.error(`[terminal-overlay] launch-failed err=${t}`),alert(t)}finally{he(!1)}}},disabled:me,children:[(0,V.jsx)(Qe,{size:14}),` Terminal`,me&&(0,V.jsx)(ie,{size:12,className:`spin`})]}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{f(!1),window.location.href=`/data`},children:[(0,V.jsx)(oe,{size:14}),` Data`]}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{f(!1),window.location.href=`/graph`},children:[(0,V.jsx)(ce,{size:14}),` Graph`]}),(0,V.jsx)(`div`,{className:`chat-menu-divider`}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(p!==null){m(null),S(null);return}_(!0),b(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);m((await e.json()).agents??[])}catch(e){console.error(`[admin] agent list failed:`,e),b(e instanceof Error?e.message:String(e))}finally{_(!1)}},children:[(0,V.jsx)(De,{size:14}),` Public`,g&&(0,V.jsx)(ie,{size:12,className:`spin`})]}),p!==null&&(0,V.jsxs)(`div`,{className:`chat-menu-agents`,children:[y&&(0,V.jsx)(`span`,{className:`chat-menu-agent-error`,children:y}),p.length===0&&!y&&(0,V.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),p.map(e=>(0,V.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,V.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,V.jsxs)(`span`,{className:`agent-text`,children:[(0,V.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,V.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),x===e.slug?(0,V.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,V.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>{S(null),m(t=>t?.filter(t=>t.slug!==e.slug)??null),fetch(`/api/admin/agents/${encodeURIComponent(e.slug)}`,{method:`DELETE`}).catch(e=>console.error(`[admin/agents] delete failed:`,e))},children:(0,V.jsx)(h,{size:12})}),(0,V.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>S(null),children:(0,V.jsx)(fe,{size:12})})]}):(0,V.jsxs)(`span`,{className:`agent-actions`,children:[(0,V.jsx)(`a`,{href:`${c}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>f(!1),children:(0,V.jsx)(De,{size:12})}),(0,V.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>S(e.slug),children:(0,V.jsx)(i,{size:12})})]})]},e.slug))]}),(0,V.jsx)(`div`,{className:`chat-menu-divider`}),N?.updateAvailable?(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-version`,onClick:()=>{N.latest&&(I(N),f(!1),F(!0))},children:[(0,V.jsx)(Pe,{size:14}),(0,V.jsxs)(`span`,{className:`version-installed`,children:[`v`,N.installed,(0,V.jsx)(`span`,{className:`version-update-dot`})]})]}):(0,V.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,V.jsx)(Pe,{size:14}),(0,V.jsxs)(`span`,{className:`version-installed`,children:[N?`v${N.installed}`:`…`,N&&!N.updateAvailable&&(0,V.jsx)(`span`,{className:`version-uptodate-dot`})]})]}),(0,V.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{f(!1),R.handleLogout(),z.setMessages([])},children:[(0,V.jsx)(L,{size:14}),` Log out`]})]})]})]}),(0,V.jsxs)(`div`,{className:`chat-content`,children:[(0,V.jsx)(uE,{messages:z.messages,isStreaming:z.isStreaming,elapsedSeconds:xe.elapsedSeconds,sessionTurnStart:xe.sessionTurnStart,expandAll:R.expandAll,setExpandAll:R.setExpandAll,conversationCompacted:z.conversationCompacted,isCompacting:z.isCompacting,setShowCompactConfirm:s,handleComponentSubmit:z.handleComponentSubmit,effectiveSubmitted:z.effectiveSubmitted,selectionMode:be.selectionMode,selectedItems:be.selectedItems,toggleSelectItem:be.toggleSelectItem,sessionKey:R.sessionKey,setLightboxSrc:n,messageQueue:z.messageQueue,messageQueueRef:z.messageQueueRef,setQueue:z.setQueue,sendMessage:z.sendMessage,appState:R.appState,onboardingComplete:R.onboardingComplete}),(0,V.jsx)(dE,{offer:z.topicChangeOffer,onFreshStart:z.handleTopicFreshStart,onContinue:z.handleTopicContinue,disabled:z.isStreaming}),(0,V.jsx)(mE,{selectionMode:be.selectionMode,selectedItems:be.selectedItems,copyToast:be.copyToast||null,exitSelection:be.exitSelection,enterSelection:be.enterSelection,copySelected:be.copySelected,showCopyToast:be.showCopyToast,input:z.input,setInput:z.setInput,inputRef:e,pendingFiles:Se.pendingFiles,setPendingFiles:Se.setPendingFiles,isDragOver:Se.isDragOver,attachError:Se.attachError,fileInputRef:Se.fileInputRef,addFiles:Se.addFiles,removeFile:Se.removeFile,onDragOver:Se.onDragOver,onDragLeave:Se.onDragLeave,onDrop:Se.onDrop,isStreaming:z.isStreaming,wasPaused:z.wasPaused,messages:z.messages,messageQueueRef:z.messageQueueRef,setQueue:z.setQueue,sendMessage:z.sendMessage,stopStreaming:z.stopStreaming,disconnecting:R.disconnecting,handleDisconnect:R.handleDisconnect,claudeInfo:R.claudeInfo,setClaudeInfo:R.setClaudeInfo,setShowClaudeInfo:a,conversationId:R.conversationId,onNewConversation:z.startNewConversation,newConversationDisabled:z.isStreaming||z.isCompacting,onOpenConversations:async()=>{T(!0),A(!0),M(null);try{let e=await fetch(`/api/admin/sessions?session_key=${encodeURIComponent(R.sessionKey)}`);if(!e.ok)throw Error(`Failed to load conversations`);D((await e.json()).sessions??[])}catch(e){console.error(`[admin] conversation list failed:`,e),M(e instanceof Error?e.message:String(e))}finally{A(!1)}}})]}),be.copyToast&&(0,V.jsx)(`span`,{className:`copy-toast${be.copyToast===`failed`?` copy-toast-failed`:``}`,children:be.copyToast===`copied`?`Copied`:`Copy failed`}),(0,V.jsx)(TE,{show:w,onClose:()=>T(!1),conversationsLoading:k,conversationsError:j,conversationsList:E,setConversationsList:D,sessionKey:R.sessionKey,isStreaming:z.isStreaming,resetConversation:z.resetConversation,setMessages:z.setMessages,setConversationId:R.setConversationId}),(0,V.jsx)(EE,{src:t,onClose:()=>n(null)}),(0,V.jsx)(DE,{show:o,onClose:()=>s(!1),onConfirm:z.handleCompactNow}),(0,V.jsx)(OE,{show:r,onClose:()=>{a(!1),R.setClaudeInfo(null)},claudeInfo:R.claudeInfo,messages:z.messages,sessionElapsed:xe.sessionElapsed,conversationId:R.conversationId,contextModeHint:R.contextModeHint,handleContextModeToggle:R.handleContextModeToggle}),(0,V.jsx)(NE,{show:ee,onClose:()=>{F(!1),ve.current=!0},versionInfo:te,sessionKey:R.sessionKey,onUpgradeComplete:()=>P(null)}),ne&&(0,V.jsx)(PE,{onClose:()=>ae(!1)}),de&&(0,V.jsx)(FE,{onClose:()=>{pe(!1),fetch(`/api/admin/terminal/close`,{method:`POST`}).catch(()=>{})}})]})})}(0,at.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(IE,{}));
|