@ours.network/messenger-server 1.0.10 → 1.0.11
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/chunks/{chunk-JXU2GN22.js → chunk-VAAEOUKO.js} +1 -1
- package/dist/chunks/{server-EPRSX4TT.js → server-ONX7REAF.js} +8200 -13
- package/dist/cli.js +2 -2
- package/dist/web/assets/{abnfDiagram-N423BO3Z-DSlHJIJP.js → abnfDiagram-N423BO3Z-CqPWn49C.js} +2 -2
- package/dist/web/assets/{abnfDiagram-N423BO3Z-DSlHJIJP.js.map → abnfDiagram-N423BO3Z-CqPWn49C.js.map} +1 -1
- package/dist/web/assets/{arc-CdCaNI80.js → arc-3B7PFRgm.js} +2 -2
- package/dist/web/assets/{arc-CdCaNI80.js.map → arc-3B7PFRgm.js.map} +1 -1
- package/dist/web/assets/{architectureDiagram-T3A2C74G-OxtEyu2s.js → architectureDiagram-T3A2C74G-DfLEjIUl.js} +2 -2
- package/dist/web/assets/{architectureDiagram-T3A2C74G-OxtEyu2s.js.map → architectureDiagram-T3A2C74G-DfLEjIUl.js.map} +1 -1
- package/dist/web/assets/{blockDiagram-VBNYF7ZC-BPVqsKcY.js → blockDiagram-VBNYF7ZC-DbJ87tB6.js} +2 -2
- package/dist/web/assets/{blockDiagram-VBNYF7ZC-BPVqsKcY.js.map → blockDiagram-VBNYF7ZC-DbJ87tB6.js.map} +1 -1
- package/dist/web/assets/{browser-CG3-I6-H.js → browser-CqRIlH-x.js} +2 -2
- package/dist/web/assets/{browser-CG3-I6-H.js.map → browser-CqRIlH-x.js.map} +1 -1
- package/dist/web/assets/{c4Diagram-5PPSVZJV-BWVjM8bO.js → c4Diagram-5PPSVZJV-aYlJS5PI.js} +2 -2
- package/dist/web/assets/{c4Diagram-5PPSVZJV-BWVjM8bO.js.map → c4Diagram-5PPSVZJV-aYlJS5PI.js.map} +1 -1
- package/dist/web/assets/channel-dW2gWx3T.js +2 -0
- package/dist/web/assets/{channel-DbWf2zys.js.map → channel-dW2gWx3T.js.map} +1 -1
- package/dist/web/assets/{chunk-2GRJ4B5K-PST0jprS.js → chunk-2GRJ4B5K-AJhprA8r.js} +2 -2
- package/dist/web/assets/{chunk-2GRJ4B5K-PST0jprS.js.map → chunk-2GRJ4B5K-AJhprA8r.js.map} +1 -1
- package/dist/web/assets/{chunk-2Q5K7J3B-BNntxzzw.js → chunk-2Q5K7J3B-DlHDneWM.js} +2 -2
- package/dist/web/assets/{chunk-2Q5K7J3B-BNntxzzw.js.map → chunk-2Q5K7J3B-DlHDneWM.js.map} +1 -1
- package/dist/web/assets/{chunk-5RXB4S5H-PrbaLeVn.js → chunk-5RXB4S5H-DVtX858s.js} +2 -2
- package/dist/web/assets/{chunk-5RXB4S5H-PrbaLeVn.js.map → chunk-5RXB4S5H-DVtX858s.js.map} +1 -1
- package/dist/web/assets/{chunk-5VM5RSS4-DIarBAx3.js → chunk-5VM5RSS4-BnqyETiw.js} +2 -2
- package/dist/web/assets/{chunk-5VM5RSS4-DIarBAx3.js.map → chunk-5VM5RSS4-BnqyETiw.js.map} +1 -1
- package/dist/web/assets/{chunk-6Q2QTUOP-Dz6Z6-tO.js → chunk-6Q2QTUOP-VwtdxEqq.js} +2 -2
- package/dist/web/assets/{chunk-6Q2QTUOP-Dz6Z6-tO.js.map → chunk-6Q2QTUOP-VwtdxEqq.js.map} +1 -1
- package/dist/web/assets/{chunk-GF5L2VYU-gKd_P7vP.js → chunk-GF5L2VYU-BP-GNqx9.js} +2 -2
- package/dist/web/assets/{chunk-GF5L2VYU-gKd_P7vP.js.map → chunk-GF5L2VYU-BP-GNqx9.js.map} +1 -1
- package/dist/web/assets/{chunk-JWPE2WC7-Z6Pt8LjM.js → chunk-JWPE2WC7-DzY9yv5e.js} +2 -2
- package/dist/web/assets/{chunk-JWPE2WC7-Z6Pt8LjM.js.map → chunk-JWPE2WC7-DzY9yv5e.js.map} +1 -1
- package/dist/web/assets/{chunk-KBJHAD2P-CudTPLkA.js → chunk-KBJHAD2P-EWGGIyEs.js} +2 -2
- package/dist/web/assets/{chunk-KBJHAD2P-CudTPLkA.js.map → chunk-KBJHAD2P-EWGGIyEs.js.map} +1 -1
- package/dist/web/assets/{chunk-RYQCIY6F-B30V852B.js → chunk-RYQCIY6F-zdkBQ149.js} +2 -2
- package/dist/web/assets/{chunk-RYQCIY6F-B30V852B.js.map → chunk-RYQCIY6F-zdkBQ149.js.map} +1 -1
- package/dist/web/assets/{chunk-XXDRQBXY-Din2wFei.js → chunk-XXDRQBXY-B5s1DPid.js} +2 -2
- package/dist/web/assets/{chunk-XXDRQBXY-Din2wFei.js.map → chunk-XXDRQBXY-B5s1DPid.js.map} +1 -1
- package/dist/web/assets/classDiagram-JCYQIIEL-qy_NR-tD.js +2 -0
- package/dist/web/assets/{classDiagram-JCYQIIEL-BxiDje2t.js.map → classDiagram-JCYQIIEL-qy_NR-tD.js.map} +1 -1
- package/dist/web/assets/classDiagram-v2-OCEON4UE-qy_NR-tD.js +2 -0
- package/dist/web/assets/{classDiagram-v2-OCEON4UE-BxiDje2t.js.map → classDiagram-v2-OCEON4UE-qy_NR-tD.js.map} +1 -1
- package/dist/web/assets/{cose-bilkent-JH36ORCC-DUgp7_Lk.js → cose-bilkent-JH36ORCC-D_C2gOXL.js} +2 -2
- package/dist/web/assets/{cose-bilkent-JH36ORCC-DUgp7_Lk.js.map → cose-bilkent-JH36ORCC-D_C2gOXL.js.map} +1 -1
- package/dist/web/assets/{cynefin-VYW2F7L2-8w56koxL.js → cynefin-VYW2F7L2-D5Shoam2.js} +2 -2
- package/dist/web/assets/{cynefin-VYW2F7L2-8w56koxL.js.map → cynefin-VYW2F7L2-D5Shoam2.js.map} +1 -1
- package/dist/web/assets/{cynefinDiagram-MW4NZA55-DXBEtfoQ.js → cynefinDiagram-MW4NZA55-BlnnDAn4.js} +2 -2
- package/dist/web/assets/{cynefinDiagram-MW4NZA55-DXBEtfoQ.js.map → cynefinDiagram-MW4NZA55-BlnnDAn4.js.map} +1 -1
- package/dist/web/assets/{dagre-VZM6K2ZE-CgUSo_J9.js → dagre-VZM6K2ZE-CcmbgD8y.js} +2 -2
- package/dist/web/assets/{dagre-VZM6K2ZE-CgUSo_J9.js.map → dagre-VZM6K2ZE-CcmbgD8y.js.map} +1 -1
- package/dist/web/assets/{diagram-7IWD3JNH-BoWnBz4Y.js → diagram-7IWD3JNH-BnuvXuOG.js} +2 -2
- package/dist/web/assets/{diagram-7IWD3JNH-BoWnBz4Y.js.map → diagram-7IWD3JNH-BnuvXuOG.js.map} +1 -1
- package/dist/web/assets/{diagram-B4RE2ZJO-CNzArfHi.js → diagram-B4RE2ZJO-qN04fvc2.js} +2 -2
- package/dist/web/assets/{diagram-B4RE2ZJO-CNzArfHi.js.map → diagram-B4RE2ZJO-qN04fvc2.js.map} +1 -1
- package/dist/web/assets/{diagram-LBJQPF4R-BFBG1VT-.js → diagram-LBJQPF4R-MyFiPTsp.js} +2 -2
- package/dist/web/assets/{diagram-LBJQPF4R-BFBG1VT-.js.map → diagram-LBJQPF4R-MyFiPTsp.js.map} +1 -1
- package/dist/web/assets/{diagram-Q27KOJAE-DSDx7FCa.js → diagram-Q27KOJAE-D6KbyLDa.js} +2 -2
- package/dist/web/assets/{diagram-Q27KOJAE-DSDx7FCa.js.map → diagram-Q27KOJAE-D6KbyLDa.js.map} +1 -1
- package/dist/web/assets/{diagram-UB23O5K3-CNYOAKqY.js → diagram-UB23O5K3-BYfEham2.js} +2 -2
- package/dist/web/assets/{diagram-UB23O5K3-CNYOAKqY.js.map → diagram-UB23O5K3-BYfEham2.js.map} +1 -1
- package/dist/web/assets/{ebnfDiagram-BXEA7PRR-CfcV-rzu.js → ebnfDiagram-BXEA7PRR-B2sQIaDq.js} +2 -2
- package/dist/web/assets/{ebnfDiagram-BXEA7PRR-CfcV-rzu.js.map → ebnfDiagram-BXEA7PRR-B2sQIaDq.js.map} +1 -1
- package/dist/web/assets/{erDiagram-JOGREHBK-BtpxrdHI.js → erDiagram-JOGREHBK-TTjrYibZ.js} +2 -2
- package/dist/web/assets/{erDiagram-JOGREHBK-BtpxrdHI.js.map → erDiagram-JOGREHBK-TTjrYibZ.js.map} +1 -1
- package/dist/web/assets/{flowDiagram-UKHOOZJN-Bso5L4JK.js → flowDiagram-UKHOOZJN-DBkhF11F.js} +2 -2
- package/dist/web/assets/{flowDiagram-UKHOOZJN-Bso5L4JK.js.map → flowDiagram-UKHOOZJN-DBkhF11F.js.map} +1 -1
- package/dist/web/assets/{ganttDiagram-PKOTCBZU-DaPVTEWX.js → ganttDiagram-PKOTCBZU-CZhiXP06.js} +2 -2
- package/dist/web/assets/{ganttDiagram-PKOTCBZU-DaPVTEWX.js.map → ganttDiagram-PKOTCBZU-CZhiXP06.js.map} +1 -1
- package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-DHoTeqwO.js → gitGraphDiagram-DS77QQ5N-DY6N0imD.js} +2 -2
- package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-DHoTeqwO.js.map → gitGraphDiagram-DS77QQ5N-DY6N0imD.js.map} +1 -1
- package/dist/web/assets/{index-BM57ScV8.js → index-2K1tlrb7.js} +14 -15
- package/dist/web/assets/index-2K1tlrb7.js.map +1 -0
- package/dist/web/assets/index-Dj3R_BQQ.css +1 -0
- package/dist/web/assets/{infoDiagram-6WML65LV-CaTGUitE.js → infoDiagram-6WML65LV-A8svJtko.js} +2 -2
- package/dist/web/assets/{infoDiagram-6WML65LV-CaTGUitE.js.map → infoDiagram-6WML65LV-A8svJtko.js.map} +1 -1
- package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-DE6z8X7L.js → ishikawaDiagram-WSZJBQD7-B_fUtCK4.js} +2 -2
- package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-DE6z8X7L.js.map → ishikawaDiagram-WSZJBQD7-B_fUtCK4.js.map} +1 -1
- package/dist/web/assets/{journeyDiagram-NVQOT4AX-CxGD9d0H.js → journeyDiagram-NVQOT4AX-CznRCnfr.js} +2 -2
- package/dist/web/assets/{journeyDiagram-NVQOT4AX-CxGD9d0H.js.map → journeyDiagram-NVQOT4AX-CznRCnfr.js.map} +1 -1
- package/dist/web/assets/{jsQR-DfrHZfxx.js → jsQR-Bf0UGUa9.js} +2 -2
- package/dist/web/assets/{jsQR-DfrHZfxx.js.map → jsQR-Bf0UGUa9.js.map} +1 -1
- package/dist/web/assets/{kanban-definition-27J2QSJJ-Dm2D1Sn4.js → kanban-definition-27J2QSJJ-DWDbR8YK.js} +2 -2
- package/dist/web/assets/{kanban-definition-27J2QSJJ-Dm2D1Sn4.js.map → kanban-definition-27J2QSJJ-DWDbR8YK.js.map} +1 -1
- package/dist/web/assets/{linear-CKTpO3cH.js → linear-v3DKup6r.js} +2 -2
- package/dist/web/assets/{linear-CKTpO3cH.js.map → linear-v3DKup6r.js.map} +1 -1
- package/dist/web/assets/{mermaid.core-DXnFjC8e.js → mermaid.core-DFaFLwYZ.js} +5 -5
- package/dist/web/assets/{mermaid.core-DXnFjC8e.js.map → mermaid.core-DFaFLwYZ.js.map} +1 -1
- package/dist/web/assets/{mindmap-definition-FAOFIHXS-DKplT5NA.js → mindmap-definition-FAOFIHXS-WlyKZ1qh.js} +2 -2
- package/dist/web/assets/{mindmap-definition-FAOFIHXS-DKplT5NA.js.map → mindmap-definition-FAOFIHXS-WlyKZ1qh.js.map} +1 -1
- package/dist/web/assets/{pegDiagram-VL7TDLO6-DqO2qbzW.js → pegDiagram-VL7TDLO6-J8XQMbkI.js} +2 -2
- package/dist/web/assets/{pegDiagram-VL7TDLO6-DqO2qbzW.js.map → pegDiagram-VL7TDLO6-J8XQMbkI.js.map} +1 -1
- package/dist/web/assets/{pieDiagram-7S7Q4E2Y-BJ6JX5hj.js → pieDiagram-7S7Q4E2Y-Y6kKLO8X.js} +2 -2
- package/dist/web/assets/{pieDiagram-7S7Q4E2Y-BJ6JX5hj.js.map → pieDiagram-7S7Q4E2Y-Y6kKLO8X.js.map} +1 -1
- package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-DPqx917B.js → quadrantDiagram-CIZ2JOQS-C75AhFwr.js} +2 -2
- package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-DPqx917B.js.map → quadrantDiagram-CIZ2JOQS-C75AhFwr.js.map} +1 -1
- package/dist/web/assets/{railroadDiagram-AXF67PYL-CRLrl80c.js → railroadDiagram-AXF67PYL-tU0Z34Hp.js} +2 -2
- package/dist/web/assets/{railroadDiagram-AXF67PYL-CRLrl80c.js.map → railroadDiagram-AXF67PYL-tU0Z34Hp.js.map} +1 -1
- package/dist/web/assets/{requirementDiagram-LRYGKXZP-Cv0kdVVi.js → requirementDiagram-LRYGKXZP-BCC1SaAL.js} +2 -2
- package/dist/web/assets/{requirementDiagram-LRYGKXZP-Cv0kdVVi.js.map → requirementDiagram-LRYGKXZP-BCC1SaAL.js.map} +1 -1
- package/dist/web/assets/{sankeyDiagram-W5VNT64P-B6mL20am.js → sankeyDiagram-W5VNT64P-TyaWRXVE.js} +2 -2
- package/dist/web/assets/{sankeyDiagram-W5VNT64P-B6mL20am.js.map → sankeyDiagram-W5VNT64P-TyaWRXVE.js.map} +1 -1
- package/dist/web/assets/{sequenceDiagram-SI44F4Z6-v9aRkk4W.js → sequenceDiagram-SI44F4Z6-DMfSW_GK.js} +2 -2
- package/dist/web/assets/{sequenceDiagram-SI44F4Z6-v9aRkk4W.js.map → sequenceDiagram-SI44F4Z6-DMfSW_GK.js.map} +1 -1
- package/dist/web/assets/{sizeCapture-X5ZJPWSS-0n3QmYM0.js → sizeCapture-X5ZJPWSS-CGk_4Pap.js} +2 -2
- package/dist/web/assets/{sizeCapture-X5ZJPWSS-0n3QmYM0.js.map → sizeCapture-X5ZJPWSS-CGk_4Pap.js.map} +1 -1
- package/dist/web/assets/{stateDiagram-OKZ733FA-wSS-UUDo.js → stateDiagram-OKZ733FA-BcV5L0Yw.js} +2 -2
- package/dist/web/assets/{stateDiagram-OKZ733FA-wSS-UUDo.js.map → stateDiagram-OKZ733FA-BcV5L0Yw.js.map} +1 -1
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-Bl46jJlT.js +2 -0
- package/dist/web/assets/{stateDiagram-v2-UEYNNEHI-Cc4Jg-2X.js.map → stateDiagram-v2-UEYNNEHI-Bl46jJlT.js.map} +1 -1
- package/dist/web/assets/{swimlanes-SLNWSIFB-iTRVKHDG.js → swimlanes-SLNWSIFB-qPeYgkYp.js} +3 -3
- package/dist/web/assets/{swimlanes-SLNWSIFB-iTRVKHDG.js.map → swimlanes-SLNWSIFB-qPeYgkYp.js.map} +1 -1
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-DImmVV5Y.js +9 -0
- package/dist/web/assets/{swimlanesDiagram-ULZ7WXOC-vFHOUw-m.js.map → swimlanesDiagram-ULZ7WXOC-DImmVV5Y.js.map} +1 -1
- package/dist/web/assets/{timeline-definition-Z64GVDOM-BXTMxWnb.js → timeline-definition-Z64GVDOM-DK8nOg_7.js} +2 -2
- package/dist/web/assets/{timeline-definition-Z64GVDOM-BXTMxWnb.js.map → timeline-definition-Z64GVDOM-DK8nOg_7.js.map} +1 -1
- package/dist/web/assets/{vennDiagram-T6HMQDX7-CoYRHKPf.js → vennDiagram-T6HMQDX7-gPw7k48o.js} +2 -2
- package/dist/web/assets/{vennDiagram-T6HMQDX7-CoYRHKPf.js.map → vennDiagram-T6HMQDX7-gPw7k48o.js.map} +1 -1
- package/dist/web/assets/{wardleyDiagram-T6FBY63Y-CUDyaIaI.js → wardleyDiagram-T6FBY63Y-DuSm8bGc.js} +2 -2
- package/dist/web/assets/{wardleyDiagram-T6FBY63Y-CUDyaIaI.js.map → wardleyDiagram-T6FBY63Y-DuSm8bGc.js.map} +1 -1
- package/dist/web/assets/{xychartDiagram-ELKLHX3M-OemnIeUx.js → xychartDiagram-ELKLHX3M-CWypWmMd.js} +2 -2
- package/dist/web/assets/{xychartDiagram-ELKLHX3M-OemnIeUx.js.map → xychartDiagram-ELKLHX3M-CWypWmMd.js.map} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/dist/web/version.json +1 -1
- package/package.json +5 -4
- package/dist/web/assets/channel-DbWf2zys.js +0 -2
- package/dist/web/assets/classDiagram-JCYQIIEL-BxiDje2t.js +0 -2
- package/dist/web/assets/classDiagram-v2-OCEON4UE-BxiDje2t.js +0 -2
- package/dist/web/assets/index-BM57ScV8.js.map +0 -1
- package/dist/web/assets/index-BmJUsLT3.css +0 -1
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-Cc4Jg-2X.js +0 -2
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-vFHOUw-m.js +0 -9
|
@@ -264,9 +264,8 @@ ${i}`:n||i}function Jj(e){const t=String(e??""),n=t.lastIndexOf(".");return`${n>
|
|
|
264
264
|
|
|
265
265
|
${l.join(`
|
|
266
266
|
`)}
|
|
267
|
-
`),a}const aD=["default-src 'none'","script-src 'none'","connect-src 'none'","frame-src 'none'","child-src 'none'","object-src 'none'","worker-src 'none'","manifest-src 'none'","form-action 'none'","base-uri 'none'","img-src data: blob:","media-src data: blob:","font-src data:","style-src 'unsafe-inline'"].join("; "),lD="",uD="application/octet-stream",cD=/\.([A-Za-z0-9]{1,12})$/;function h1(e){return String(e??"").split(";")[0].trim().toLowerCase()}function p1(e){const t=cD.exec(String(e??"").trim());return t?t[1].toLowerCase():""}function fD(e){const t=p1(e);return t==="html"||t==="htm"}function As(e,t){return fD(e)?!0:p1(e)?!1:h1(t)==="text/html"}function wh(e,t){const n=h1(e);return n==="text/html"||As(t,e)?uD:n}const dD=[":root{color-scheme:light}","html{background:#fff}","body{margin:0;padding:24px;color:#0f172a;font:15px/1.65 ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;overflow-wrap:break-word}","img,video,svg,canvas,iframe{max-width:100%;height:auto}","pre{overflow:auto}","table{max-width:100%}"].join("");function hD(e){return["<!doctype html>","<html>","<head>",`<meta http-equiv="Content-Security-Policy" content="${aD}">`,'<meta charset="utf-8">','<meta name="referrer" content="no-referrer">','<meta name="viewport" content="width=device-width, initial-scale=1">',`<style>${dD}</style>`,"</head>","<body>",String(e??""),"</body>","</html>"].join(`
|
|
268
|
-
`)}const fd=48e3,pD=Object.freeze([{rec:"audio/webm;codecs=opus",base:"audio/webm",ext:"webm"},{rec:"audio/ogg;codecs=opus",base:"audio/ogg",ext:"ogg"},{rec:"audio/webm",base:"audio/webm",ext:"webm"},{rec:"audio/mp4",base:"audio/mp4",ext:"m4a"}]),m1="x-ours-duration",mD=4e3;function gD(e){return!Number.isFinite(e)||e<=0?null:String(Math.round(e*100)/100)}function yD(e,t){const n=t===null?null:gD(t);return n===null?e:`${e};${m1}=${n}`}function vD(e){if(!e)return null;const t=new RegExp(`${m1}\\s*=\\s*([0-9]*\\.?[0-9]+)`,"i").exec(e);if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)&&n>0?n:null}function xD(e,t=mD){return typeof Audio!="function"||typeof URL?.createObjectURL!="function"?Promise.resolve(null):new Promise(n=>{const i=URL.createObjectURL(e),s=new Audio;let l=!1;const a=d=>{l||(l=!0,clearTimeout(c),s.removeAttribute("src"),s.load(),URL.revokeObjectURL(i),n(Number.isFinite(d)&&(d??0)>0?d:null))},c=setTimeout(()=>a(null),t);s.addEventListener("loadedmetadata",()=>{Number.isFinite(s.duration)&&s.duration>0?a(s.duration):s.currentTime=Number.MAX_SAFE_INTEGER},{once:!0}),s.addEventListener("durationchange",()=>{Number.isFinite(s.duration)&&s.duration>0&&a(s.duration)}),s.addEventListener("error",()=>a(null),{once:!0}),s.preload="metadata",s.src=i})}const g1=40,wD=44,y1=.14,kD=.5,SD=e=>e<0?0:e>1?1:e;function v1(e,{floor:t=y1,gamma:n=kD}={}){const i=Math.pow(SD(Number.isFinite(e)?e:0),n);return t+(1-t)*i}function bD(e,t=g1){const n=Math.max(1,Math.floor(t)),i=new Array(n).fill(0);if(!e||e.length===0)return i;const s=e.length/n;for(let l=0;l<n;l++){const a=Math.floor(l*s),c=Math.min(e.length,Math.max(a+1,Math.floor((l+1)*s)));let d=0;for(let h=a;h<c;h++)d+=e[h]*e[h];i[l]=Math.sqrt(d/(c-a))}return i}function CD(e,t={}){const{silenceFloor:n=1e-4}=t,i=e.reduce((s,l)=>l>s?l:s,0);return i>n?e.map(s=>v1(s/i,t)):e.map(()=>y1)}function ED({decay:e=.995,minReference:t=.02}={}){let n=t;return{push(i){const s=Number.isFinite(i)&&i>0?i:0;return n=Math.max(t,n*e,s),v1(s/n)},get reference(){return n}}}function x1(e){return wh(e.mime,e.filename)}function kh(e){const[t,n]=k.useState({url:null,size:0,loaded:!1});return k.useEffect(()=>{let i=null,s=!1;n({url:null,size:0,loaded:!1});const l=e.available?D2(e.id):null;return l?(n({url:l,size:e.size,loaded:!0}),()=>{}):(Ul(e.id).then(a=>{if(s)return;if(!a){n({url:null,size:0,loaded:!0});return}const c=URL.createObjectURL(new Blob([a],{type:x1(e)}));i=c,n({url:c,size:a.byteLength,loaded:!0})}),()=>{s=!0,i&&URL.revokeObjectURL(i)})},[e.id,e.available]),t}function Sh({label:e}){return v.jsxs("div",{className:"file-offdevice",children:[v.jsx("div",{className:"file-offdevice-ic",children:v.jsx(Ee,{name:"inbox",size:16})}),v.jsxs("div",{className:"filecard-meta",children:[v.jsx("div",{className:"filecard-name",title:e,children:e}),v.jsx("div",{className:"filecard-sub",children:"Available on your original device"})]})]})}function TD(e){const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Nv({rec:e}){if(!e.transcription)return null;const t=e.transcription.text?.trim();return v.jsx("div",{className:"voice-transcript",children:t||`Transcription ${e.transcription.status??"unavailable"}${e.transcription.error_category?` · ${e.transcription.error_category}`:""}`})}function PD({rec:e,receipt:t,receiptless:n,onPreview:i,onFetch:s}){const l=e.dir==="out",a=`bubble file-bubble${l?" me":""}`,c=eo(e.mime,e.filename)?"Voice message":"File",d=v.jsxs("div",{className:"bubble-at",children:[TD(e.date),l&&v.jsx(b0,{receipt:t,content:c,receiptless:n})]});return e.mime.startsWith("image/")?v.jsx(RD,{rec:e,cls:a,footer:d,onFetch:s}):eo(e.mime,e.filename)?v.jsx(MD,{rec:e,cls:a,footer:d,onFetch:s}):v.jsx(AD,{rec:e,cls:a,footer:d,onPreview:i,onFetch:s})}function bh({rec:e,onFetch:t}){const[n,i]=k.useState(!1),[s,l]=k.useState(!1);return v.jsxs("div",{className:"file-offdevice",children:[v.jsx("div",{className:"file-offdevice-ic",children:v.jsx(Ee,{name:"inbox",size:16})}),v.jsxs("div",{className:"filecard-meta",children:[v.jsx("div",{className:"filecard-name",title:e.filename,children:eo(e.mime,e.filename)?"Voice message":e.filename}),v.jsx("div",{className:"filecard-sub",children:s?"Could not fetch media":"Available after explicit fetch"})]}),v.jsx("button",{className:"btn sm",disabled:n,onClick:()=>{i(!0),l(!1),(t?.(e.id)??O2(e.id)).catch(()=>l(!0)).finally(()=>i(!1))},children:n?"Fetching…":"Fetch"})]})}function RD({rec:e,cls:t,footer:n,onFetch:i}){const{url:s,loaded:l}=kh(e);return l&&!s?v.jsxs("div",{className:t+" filecard-bubble file-offdevice-bubble",children:[e.available===!1?v.jsx(bh,{rec:e,onFetch:i}):v.jsx(Sh,{label:e.filename&&e.filename!=="file"?e.filename:"Photo"}),n]}):v.jsxs("div",{className:t+" image-bubble",children:[s?v.jsx("a",{href:s,target:"_blank",rel:"noreferrer",title:e.filename,children:v.jsx("img",{src:s,alt:e.filename})}):v.jsx("div",{className:"file-loading",children:"loading…"}),n]})}function MD({rec:e,cls:t,footer:n,onFetch:i}){const{url:s,loaded:l}=kh(e),a=k.useRef(null),c=k.useRef(null),[d,h]=k.useState(!1),[m,p]=k.useState(0),[y,w]=k.useState(()=>vD(e.mime)),[S,C]=k.useState(!1),[E,T]=k.useState(null);if(k.useEffect(()=>{if(!s)return;let U=!1;const O=typeof window>"u"?void 0:window.AudioContext||window.webkitAudioContext;if(!O)return;const N=new O,X=()=>{try{N.close()?.catch?.(()=>{})}catch{}};return(async()=>{try{const V=await fetch(s).then(J=>J.arrayBuffer()),fe=await N.decodeAudioData(V);if(U)return;T(CD(bD(fe.getChannelData(0),g1)))}catch{}finally{X()}})(),()=>{U=!0,X()}},[s]),l&&!s)return v.jsxs("div",{className:t+" filecard-bubble file-offdevice-bubble",children:[e.available===!1?v.jsx(bh,{rec:e,onFetch:i}):v.jsx(Sh,{label:"Voice message"}),n,v.jsx(Nv,{rec:e})]});const M=()=>{const U=a.current;U&&(d?U.pause():U.play())},P=U=>{const O=c.current;if(!O)return 0;const N=O.getBoundingClientRect();return Math.max(0,Math.min(1,(U-N.left)/N.width))},D=U=>{const O=a.current;p(U),O&&y&&isFinite(y)&&(O.currentTime=U*y)},$=U=>{s&&(U.currentTarget.setPointerCapture?.(U.pointerId),C(!0),D(P(U.clientX)))},j=U=>{S&&D(P(U.clientX))},Y=U=>{S&&(U.currentTarget.releasePointerCapture?.(U.pointerId),C(!1))};return v.jsxs("div",{className:t+" voice-bubble",children:[v.jsx("button",{className:"voice-play",onClick:M,disabled:!s,title:d?"Pause":"Play",children:v.jsx(Ee,{name:d?"pause":"play",size:14})}),v.jsxs("div",{className:"voice-track"+(s?" seekable":"")+(S?" scrubbing":"")+(E?" has-wave":""),ref:c,onPointerDown:$,onPointerMove:j,onPointerUp:Y,onPointerCancel:Y,role:s?"slider":void 0,"aria-label":s?"Seek":void 0,"aria-valuenow":Math.round(m*100),children:[E?v.jsx("div",{className:"voice-wave","aria-hidden":!0,children:E.map((U,O)=>v.jsx("span",{className:"voice-wave-bar"+(O/E.length<m?" played":""),style:{height:`${Math.round(U*100)}%`}},O))}):v.jsx("div",{className:"voice-track-fill",style:{width:`${m*100}%`}}),s&&v.jsx("span",{className:"voice-track-knob",style:{left:`${m*100}%`}})]}),v.jsx("span",{className:"voice-dur mono",children:y!==null?`${Math.floor(y/60)}:${String(Math.floor(y%60)).padStart(2,"0")}`:"·:··"}),s&&v.jsx("audio",{ref:a,src:s,onPlay:()=>h(!0),onPause:()=>h(!1),onEnded:()=>{h(!1),p(0)},onTimeUpdate:U=>{const O=U.currentTarget;!S&&O.duration>0&&isFinite(O.duration)&&p(O.currentTime/O.duration)},onLoadedMetadata:U=>{const O=U.currentTarget.duration;isFinite(O)&&O>0&&w(O)}}),n,v.jsx(Nv,{rec:e})]})}function AD({rec:e,cls:t,footer:n,onPreview:i,onFetch:s}){const{url:l,size:a,loaded:c}=kh(e);return c&&!l?v.jsxs("div",{className:t+" filecard-bubble file-offdevice-bubble",children:[e.available===!1?v.jsx(bh,{rec:e,onFetch:s}):v.jsx(Sh,{label:e.filename}),n]}):v.jsxs("div",{className:t+" filecard-bubble",children:[v.jsxs("div",{className:"filecard",children:[v.jsx("div",{className:"filecard-ic",children:v.jsx(Ee,{name:"copy",size:18})}),v.jsxs("div",{className:"filecard-meta",children:[v.jsx("div",{className:"filecard-name",title:e.filename,children:e.filename}),v.jsx("div",{className:"filecard-sub",children:a?Fr(a):e.size?Fr(e.size):""})]}),d1(e.filename)&&l&&i&&v.jsx("button",{className:"icon-btn",onClick:()=>i(e),title:"Preview markdown",children:v.jsx(Ee,{name:"monitor",size:16})}),As(e.filename,e.mime)&&l&&i&&v.jsx("button",{className:"icon-btn",onClick:()=>i(e),title:"Preview HTML",children:v.jsx(Ee,{name:"monitor",size:16})}),v.jsx("a",{className:"icon-btn"+(l?"":" disabled"),href:l??void 0,download:e.filename,title:"Download",children:v.jsx(Ee,{name:"download",size:16})})]}),n]})}function w1(e){const{att:t}=e,[n,i]=k.useState(null);return k.useEffect(()=>{const s=x1({mime:t.mime,filename:t.filename}),l=URL.createObjectURL(new Blob([t.bytes],{type:s}));return i(l),()=>URL.revokeObjectURL(l)},[t]),v.jsxs("div",{className:"attach-preview",children:[t.mime.startsWith("image/")&&n?v.jsx("img",{className:"attach-thumb",src:n,alt:t.filename}):t.voice&&n?v.jsx("audio",{className:"attach-audio",src:n,controls:!0}):v.jsx("div",{className:"filecard-ic",children:v.jsx(Ee,{name:"copy",size:16})}),v.jsxs("div",{className:"filecard-meta",children:[v.jsx("div",{className:"filecard-name",title:t.filename,children:t.voice?"Voice message":t.filename}),v.jsxs("div",{className:"filecard-sub",children:[Fr(t.bytes.length),t.originalSize&&t.originalSize>t.bytes.length?` · optimized from ${Fr(t.originalSize)}`:""]})]}),v.jsx("button",{className:"btn primary sm",disabled:e.sending,onClick:e.onSend,children:e.sending?"Sending…":"Send"}),v.jsx("button",{className:"icon-btn",title:"Discard",disabled:e.sending,onClick:e.onDiscard,children:v.jsx(Ee,{name:"close"})})]})}const ND={channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},ID=e=>`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,"0")}`,Iv=84,jv=120,jD=550,DD=Math.floor(ts/(fd/8)),_D=Math.min(300,DD),LD=wD;function k1(e){const[t,n]=k.useState("idle"),[i,s]=k.useState(0),[l,a]=k.useState([]),[c,d]=k.useState(0),[h,m]=k.useState(0),p=k.useRef("idle"),y=k.useRef(null),w=k.useRef(null),S=k.useRef([]),C=k.useRef("webm"),E=k.useRef("audio/webm"),T=k.useRef(!1),M=k.useRef({x:0,y:0}),P=k.useRef(0),D=k.useRef(!1),$=k.useRef(null),j=k.useRef(null),Y=k.useRef(null),U=k.useRef(e.onReady),O=k.useRef(e.onError),N=k.useRef(e.onActiveChange);U.current=e.onReady,O.current=e.onError,N.current=e.onActiveChange;const X=te=>{p.current=te,n(te),N.current?.(te==="recording"||te==="locked"||te==="arming")},V=()=>{j.current!=null&&cancelAnimationFrame(j.current),j.current=null,Y.current&&clearInterval(Y.current),Y.current=null,$.current?.close().catch(()=>{}),$.current=null,w.current?.getTracks().forEach(te=>te.stop()),w.current=null},fe=()=>{window.removeEventListener("pointermove",Pe),window.removeEventListener("pointerup",Q),window.removeEventListener("pointercancel",Q)},J=te=>{T.current=te;const ge=y.current;ge&&ge.state!=="inactive"?ge.stop():ee(),fe()},ee=()=>{V(),X("idle"),s(0),a([]),d(0),m(0)},xe=()=>{p.current==="recording"&&(fe(),m(0),X("locked"))};function Pe(te){if(p.current!=="recording")return;const ge=M.current.y-te.clientY,ye=M.current.x-te.clientX,me=Math.max(0,Math.min(1,ge/Iv)),we=Math.max(0,Math.min(1,ye/jv));d(me),m(we),ge>=Iv?xe():ye>=jv&&J(!0)}function Q(){if(p.current==="arming"){D.current=!0,fe();return}if(p.current!=="recording")return;const te=Date.now()-P.current<jD;J(te)}const de=te=>{e.disabled||p.current!=="idle"||(te.preventDefault(),M.current={x:te.clientX,y:te.clientY},D.current=!1,T.current=!1,S.current=[],d(0),m(0),X("arming"),window.addEventListener("pointermove",Pe),window.addEventListener("pointerup",Q),window.addEventListener("pointercancel",Q),R())};async function R(){let te;try{te=await navigator.mediaDevices.getUserMedia({audio:ND})}catch{O.current("Microphone unavailable — check the browser permission."),fe(),X("idle");return}if(D.current||p.current==="idle"){te.getTracks().forEach(me=>me.stop()),X("idle");return}w.current=te;const ge=pD.find(me=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(me.rec));C.current=ge?.ext??"webm",E.current=ge?.base??"audio/webm";const ye=ge?new MediaRecorder(te,{mimeType:ge.rec,audioBitsPerSecond:fd}):new MediaRecorder(te,{audioBitsPerSecond:fd});y.current=ye,ye.ondataavailable=me=>{me.data.size>0&&S.current.push(me.data)},ye.onstop=()=>{if(T.current){ee();return}const we=new Blob(S.current,{type:E.current});Promise.all([we.arrayBuffer(),xD(we)]).then(([pe,Ve])=>{if(ee(),pe.byteLength===0)return;const qe=new Date().toISOString().replace(/[-:]/g,"").replace(/\..+/,"").replace("T","-");U.current({filename:`${k0}${qe}.${C.current}`,mime:yD(_2(E.current),Ve),bytes:new Uint8Array(pe),voice:!0})})},ye.start(),P.current=Date.now(),X("recording"),s(0),Y.current=setInterval(()=>{s(me=>{const we=me+1;return we>=_D&&J(!1),we})},1e3),F(te)}function F(te){try{const ge=window.AudioContext||window.webkitAudioContext,ye=new ge;$.current=ye;const me=ye.createMediaStreamSource(te),we=ye.createAnalyser();we.fftSize=256,me.connect(we);const pe=new Uint8Array(we.fftSize),Ve=ED();let qe=0;const it=We=>{if(j.current=requestAnimationFrame(it),We-qe<80)return;qe=We,we.getByteTimeDomainData(pe);let at=0;for(let lt=0;lt<pe.length;lt++){const Pt=(pe[lt]-128)/128;at+=Pt*Pt}const xt=Math.sqrt(at/pe.length),Vt=Ve.push(xt);a(lt=>{const Pt=lt.length>=LD?lt.slice(1):lt.slice();return Pt.push(Vt),Pt})};j.current=requestAnimationFrame(it)}catch{}}k.useEffect(()=>()=>{T.current=!0,y.current?.stop(),fe(),V()},[]);const G=t==="recording"||t==="locked"||t==="arming",A=v.jsx("div",{className:"vr-wave","aria-hidden":!0,children:l.map((te,ge)=>v.jsx("span",{className:"vr-bar",style:{height:`${Math.round(te*100)}%`}},ge))});return v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"icon-btn composer-tool vr-mic",title:"Hold to record a voice message",disabled:e.disabled,onPointerDown:de,onContextMenu:te=>te.preventDefault(),children:v.jsx(Ee,{name:"mic",size:18})}),G&&v.jsxs("div",{className:"voice-rec-overlay","data-mode":t,children:[t==="recording"&&v.jsxs("div",{className:"vr-lock",style:{"--p":c},"aria-hidden":!0,children:[v.jsx(Ee,{name:"lock",size:13}),v.jsx(Ee,{name:"chevronDown",size:12})]}),v.jsx("span",{className:"voice-rec-dot"}),v.jsx("span",{className:"vr-time mono",children:ID(i)}),t==="locked"?v.jsxs(v.Fragment,{children:[A,v.jsx("button",{className:"icon-btn vr-trash",title:"Cancel",onClick:()=>J(!0),children:v.jsx(Ee,{name:"trash",size:16})}),v.jsxs("button",{className:"btn primary sm vr-stop",onClick:()=>J(!1),children:[v.jsx(Ee,{name:"check",size:13}),"Stop"]})]}):v.jsxs("div",{className:"vr-slide",style:{opacity:1-h},children:[A,v.jsx("span",{className:"vr-hint",children:"‹ slide to cancel · slide up to lock"})]})]})]})}const OD="modulepreload",FD=function(e){return"/"+e},Dv={},Ch=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let a=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=c?.nonce||c?.getAttribute("nonce");s=a(n.map(h=>{if(h=FD(h),h in Dv)return;Dv[h]=!0;const m=h.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const y=document.createElement("link");if(y.rel=m?"stylesheet":OD,m||(y.as="script"),y.crossOrigin="",y.href=h,d&&y.setAttribute("nonce",d),document.head.appendChild(y),m)return new Promise((w,S)=>{y.addEventListener("load",w),y.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return s.then(a=>{for(const c of a||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})};var zD=Object.defineProperty,ao=(e,t)=>zD(e,"name",{value:t,configurable:!0}),S1=!!(typeof window<"u"&&window.document&&window.document.createElement);function _r(e,t,{checkForDefaultPrevented:n=!0}={}){return ao(function(s){if(e?.(s),n===!1||!s||!s.defaultPrevented)return t?.(s)},"handleEvent")}ao(_r,"composeEventHandlers");function VD(e){if(!S1)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}ao(VD,"getOwnerWindow");function dd(e){if(!S1)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}ao(dd,"getOwnerDocument");function b1(e,t=!1){const{activeElement:n}=dd(e);if(!n?.nodeName)return null;if(C1(n)&&n.contentDocument)return b1(n.contentDocument.body,t);if(t){const i=n.getAttribute("aria-activedescendant");if(i){const s=dd(n).getElementById(i);if(s)return s}}return n}ao(b1,"getActiveElement");function C1(e){return e.tagName==="IFRAME"}ao(C1,"isFrame");var BD=Object.defineProperty,Eh=(e,t)=>BD(e,"name",{value:t,configurable:!0});function hd(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Eh(hd,"setRef");function E1(...e){return t=>{let n=!1;const i=e.map(s=>{const l=hd(s,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let s=0;s<i.length;s++){const l=i[s];typeof l=="function"?l():hd(e[s],null)}}}}Eh(E1,"composeRefs");function lo(...e){return k.useCallback(E1(...e),e)}Eh(lo,"useComposedRefs");var $D=Object.defineProperty,xn=(e,t)=>$D(e,"name",{value:t,configurable:!0});function UD(e,t){const n=k.createContext(t);n.displayName=e+"Context";const i=xn(l=>{const{children:a,...c}=l,d=k.useMemo(()=>c,Object.values(c));return v.jsx(n.Provider,{value:d,children:a})},"Provider");i.displayName=e+"Provider";function s(l,a={}){const{optional:c=!1}=a,d=k.useContext(n);if(d)return d;if(t!==void 0)return t;if(!c)throw new Error(`\`${l}\` must be used within \`${e}\``)}return xn(s,"useContext"),[i,s]}xn(UD,"createContext");function T1(e,t=[]){let n=[];function i(l,a){const c=k.createContext(a);c.displayName=l+"Context";const d=n.length;n=[...n,a];const h=xn(p=>{const{scope:y,children:w,...S}=p,C=y?.[e]?.[d]||c,E=k.useMemo(()=>S,Object.values(S));return v.jsx(C.Provider,{value:E,children:w})},"Provider");h.displayName=l+"Provider";function m(p,y,w={}){const{optional:S=!1}=w,C=y?.[e]?.[d]||c,E=k.useContext(C);if(E)return E;if(a!==void 0)return a;if(!S)throw new Error(`\`${p}\` must be used within \`${l}\``)}return xn(m,"useContext"),[h,m]}xn(i,"createContext");const s=xn(()=>{const l=n.map(a=>k.createContext(a));return xn(function(c){const d=c?.[e]||l;return k.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])},"useScope")},"createScope");return s.scopeName=e,[i,P1(s,...t)]}xn(T1,"createContextScope");function P1(...e){const t=e[0];if(e.length===1)return t;const n=xn(()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return xn(function(l){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(l)[`__scope${h}`];return{...c,...p}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}xn(P1,"composeContextScopes");var zr=globalThis?.document?k.useLayoutEffect:()=>{},WD=Object.defineProperty,HD=(e,t)=>WD(e,"name",{value:t,configurable:!0}),KD=bs[" useId ".trim().toString()]||(()=>{}),qD=0;function pl(e){const[t,n]=k.useState(KD());return zr(()=>{e||n(i=>i??String(qD++))},[e]),e||(t?`radix-${t}`:"")}HD(pl,"useId");var XD=Object.defineProperty,YD=(e,t)=>XD(e,"name",{value:t,configurable:!0}),_v=bs[" useEffectEvent ".trim().toString()],Lv=bs[" useInsertionEffect ".trim().toString()];function R1(e){if(typeof _v=="function")return _v(e);const t=k.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Lv=="function"?Lv(()=>{t.current=e}):zr(()=>{t.current=e}),k.useMemo(()=>(...n)=>t.current?.(...n),[])}YD(R1,"useEffectEvent");var GD=Object.defineProperty,Ns=(e,t)=>GD(e,"name",{value:t,configurable:!0}),QD=bs[" useInsertionEffect ".trim().toString()]||zr;function M1({prop:e,defaultProp:t,onChange:n=Ns(()=>{},"onChange"),caller:i}){const[s,l,a]=A1({defaultProp:t,onChange:n}),c=e!==void 0,d=c?e:s,h=k.useCallback(m=>{if(c){const p=N1(m)?m(e):m;p!==e&&a.current?.(p)}else l(m)},[c,e,l,a]);return[d,h]}Ns(M1,"useControllableState");function A1({defaultProp:e,onChange:t}){const[n,i]=k.useState(e),s=k.useRef(n),l=k.useRef(t);return QD(()=>{l.current=t},[t]),k.useEffect(()=>{s.current!==n&&(l.current?.(n),s.current=n)},[n,s]),[n,i,l]}Ns(A1,"useUncontrolledState");function N1(e){return typeof e=="function"}Ns(N1,"isFunction");var Ov=Symbol("RADIX:SYNC_STATE");function ZD(e,t,n,i){const{prop:s,defaultProp:l,onChange:a,caller:c}=t,d=s!==void 0,h=R1(a),m=[{...n,state:l}];i&&m.push(i);const[p,y]=k.useReducer((E,T)=>{if(T.type===Ov)return{...E,state:T.state};const M=e(E,T);return d&&!Object.is(M.state,E.state)&&h(M.state),M},...m),w=p.state,S=k.useRef(w);k.useEffect(()=>{S.current!==w&&(S.current=w,d||h(w))},[w,S,d]);const C=k.useMemo(()=>s!==void 0?{...p,state:s}:p,[p,s]);return k.useEffect(()=>{d&&!Object.is(s,p.state)&&y({type:Ov,state:s})},[s,p.state,d]),[C,y]}Ns(ZD,"useControllableStateReducer");var I1=Rx(),JD=Object.defineProperty,_n=(e,t)=>JD(e,"name",{value:t,configurable:!0});function Th(e){const t=k.forwardRef((n,i)=>{let{children:s,...l}=n,a=null,c=!1;const d=[];pd(s)&&typeof Ya=="function"&&(s=Ya(s._payload)),k.Children.forEach(s,y=>{if(L1(y)){c=!0;const w=y;let S="child"in w.props?w.props.child:w.props.children;pd(S)&&typeof Ya=="function"&&(S=Ya(S._payload)),a=t_(w,S),d.push(a?.props?.children)}else d.push(y)}),a?a=k.cloneElement(a,void 0,d):!c&&k.Children.count(s)===1&&k.isValidElement(s)&&(a=s);const h=a?_1(a):void 0,m=lo(i,h);if(!a){if(s||s===0)throw new Error(c?i_(e):r_(e));return s}const p=D1(l,a.props??{});return a.type!==k.Fragment&&(p.ref=i?m:h),k.cloneElement(a,p)});return t.displayName=`${e}.Slot`,t}_n(Th,"createSlot");var j1=Symbol.for("radix.slottable");function e_(e){const t=_n(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=j1,t}_n(e_,"createSlottable");var t_=_n((e,t)=>{if("child"in e.props){const n=e.props.child;return k.isValidElement(n)?k.cloneElement(n,void 0,e.props.children(n.props.children)):null}return k.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function D1(e,t){const n={...t};for(const i in t){const s=e[i],l=t[i];/^on[A-Z]/.test(i)?s&&l?n[i]=(...c)=>{const d=l(...c);return s(...c),d}:s&&(n[i]=s):i==="style"?n[i]={...s,...l}:i==="className"&&(n[i]=[s,l].filter(Boolean).join(" "))}return{...e,...n}}_n(D1,"mergeProps");function _1(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}_n(_1,"getElementRef");function L1(e){return k.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===j1}_n(L1,"isSlottable");var n_=Symbol.for("react.lazy");function pd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===n_&&"_payload"in e&&O1(e._payload)}_n(pd,"isLazyComponent");function O1(e){return typeof e=="object"&&e!==null&&"then"in e}_n(O1,"isPromiseLike");var r_=_n(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),i_=_n(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Ya=bs[" use ".trim().toString()],o_=Object.defineProperty,s_=(e,t)=>o_(e,"name",{value:t,configurable:!0}),a_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mi=a_.reduce((e,t)=>{const n=Th(`Primitive.${t}`),i=k.forwardRef((s,l)=>{const{asChild:a,...c}=s,d=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(d,{...c,ref:l})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function F1(e,t){e&&I1.flushSync(()=>e.dispatchEvent(t))}s_(F1,"dispatchDiscreteCustomEvent");var l_=Object.defineProperty,u_=(e,t)=>l_(e,"name",{value:t,configurable:!0});function no(e){const t=k.useRef(e);return k.useEffect(()=>{t.current=e}),k.useMemo(()=>(...n)=>t.current?.(...n),[])}u_(no,"useCallbackRef");var c_=Object.defineProperty,Tt=(e,t)=>c_(e,"name",{value:t,configurable:!0}),md="dismissableLayer.update",f_="dismissableLayer.pointerDownOutside",d_="dismissableLayer.focusOutside",Fv,z1=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),h_=k.forwardRef(Tt(function(t,n){const{disableOutsidePointerEvents:i=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:d,onDismiss:h,...m}=t,p=k.useContext(z1),[y,w]=k.useState(null),S=y?.ownerDocument??globalThis?.document,[,C]=k.useState({}),E=lo(n,w),T=Array.from(p.layers),[M]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),P=M?T.indexOf(M):-1,D=y?T.indexOf(y):-1,$=p.layersWithOutsidePointerEventsDisabled.size>0,j=D>=P,Y=k.useRef(!1),U=B1(V=>{a?.(V),d?.(V),V.defaultPrevented||h?.()},{ownerDocument:S,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:Y,dismissableSurfaces:p.dismissableSurfaces,shouldHandlePointerDownOutside:k.useCallback(V=>{if(!(V instanceof Node))return!1;const fe=[...p.branches].some(J=>J.contains(V));return j&&!fe},[p.branches,j])}),O=$1(V=>{if(s&&Y.current)return;const fe=V.target;[...p.branches].some(ee=>ee.contains(fe))||(c?.(V),d?.(V),V.defaultPrevented||h?.())},S),N=y?D===T.length-1:!1,X=no(V=>{V.key==="Escape"&&(l?.(V),!V.defaultPrevented&&h&&(V.preventDefault(),h()))});return k.useEffect(()=>{if(N)return S.addEventListener("keydown",X,{capture:!0}),()=>S.removeEventListener("keydown",X,{capture:!0})},[S,N,X]),k.useEffect(()=>{if(y)return i&&(p.layersWithOutsidePointerEventsDisabled.size===0&&(Fv=S.body.style.pointerEvents,S.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(y)),p.layers.add(y),gd(),()=>{i&&(p.layersWithOutsidePointerEventsDisabled.delete(y),p.layersWithOutsidePointerEventsDisabled.size===0&&(S.body.style.pointerEvents=Fv))}},[y,S,i,p]),k.useEffect(()=>()=>{y&&(p.layers.delete(y),p.layersWithOutsidePointerEventsDisabled.delete(y),gd())},[y,p]),k.useEffect(()=>{const V=Tt(()=>C({}),"handleUpdate");return document.addEventListener(md,V),()=>document.removeEventListener(md,V)},[]),v.jsx(mi.div,{...m,ref:E,style:{pointerEvents:$?j?"auto":"none":void 0,...t.style},onFocusCapture:_r(t.onFocusCapture,O.onFocusCapture),onBlurCapture:_r(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:_r(t.onPointerDownCapture,U.onPointerDownCapture)})},"DismissableLayer"));function V1(){const e=k.useContext(z1),[t,n]=k.useState(null);return k.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}Tt(V1,"useDismissableLayerSurface");var p_=Tt(()=>!0,"IS_TRUE");function B1(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:l,shouldHandlePointerDownOutside:a=p_}=t,c=no(e),d=k.useRef(!1),h=k.useRef(!1),m=k.useRef(new Map),p=k.useRef(()=>{});return k.useEffect(()=>{function y(){h.current=!1,s.current=!1,m.current.clear()}Tt(y,"resetOutsideInteraction");function w(){return Array.from(m.current.values()).some(Boolean)}Tt(w,"isOutsideInteractionIntercepted");function S(P){if(!h.current)return;const D=P.target;D instanceof Node&&[...l].some(j=>j.contains(D))||m.current.set(P.type,!0),P.type==="click"&&window.setTimeout(()=>{h.current&&p.current()},0)}Tt(S,"handleInteractionCapture");function C(P){h.current&&m.current.set(P.type,!1)}Tt(C,"handleInteractionBubble");const E=Tt(P=>{if(P.target&&!d.current){let D=function(){n.removeEventListener("click",p.current);const j=w();y(),j||Ph(f_,c,$,{discrete:!0})};if(Tt(D,"handleAndDispatchPointerDownOutsideEvent"),!a(P.target)){n.removeEventListener("click",p.current),y(),d.current=!1;return}const $={originalEvent:P};h.current=!0,s.current=i&&P.button===0,m.current.clear(),!i||P.button!==0?D():(n.removeEventListener("click",p.current),p.current=D,n.addEventListener("click",p.current,{once:!0}))}else n.removeEventListener("click",p.current),y();d.current=!1},"handlePointerDown"),T=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const P of T)n.addEventListener(P,S,!0),n.addEventListener(P,C);const M=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(M),n.removeEventListener("pointerdown",E),n.removeEventListener("click",p.current);for(const P of T)n.removeEventListener(P,S,!0),n.removeEventListener(P,C)}},[n,c,i,s,l,a]),{onPointerDownCapture:Tt(()=>d.current=!0,"onPointerDownCapture")}}Tt(B1,"usePointerDownOutside");function $1(e,t=globalThis?.document){const n=no(e),i=k.useRef(!1);return k.useEffect(()=>{const s=Tt(l=>{l.target&&!i.current&&Ph(d_,n,{originalEvent:l},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:Tt(()=>i.current=!0,"onFocusCapture"),onBlurCapture:Tt(()=>i.current=!1,"onBlurCapture")}}Tt($1,"useFocusOutside");function gd(){const e=new CustomEvent(md);document.dispatchEvent(e)}Tt(gd,"dispatchUpdate");function Ph(e,t,n,{discrete:i}){const s=n.originalEvent.target,l=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),i?F1(s,l):s.dispatchEvent(l)}Tt(Ph,"handleAndDispatchCustomEvent");var m_=Object.defineProperty,qt=(e,t)=>m_(e,"name",{value:t,configurable:!0}),lf="focusScope.autoFocusOnMount",uf="focusScope.autoFocusOnUnmount",zv={bubbles:!1,cancelable:!0},g_=k.forwardRef(qt(function(t,n){const{loop:i=!1,trapped:s=!1,onMountAutoFocus:l,onUnmountAutoFocus:a,...c}=t,[d,h]=k.useState(null),m=no(l),p=no(a),y=k.useRef(null),w=lo(n,h),S=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(s){let E=function(D){if(S.paused||!d)return;const $=D.target;d.contains($)?y.current=$:sr(y.current,{select:!0})},T=function(D){if(S.paused||!d)return;const $=D.relatedTarget;$!==null&&(d.contains($)||sr(y.current,{select:!0}))},M=function(D){if(document.activeElement===document.body)for(const j of D)j.removedNodes.length>0&&sr(d)};qt(E,"handleFocusIn"),qt(T,"handleFocusOut"),qt(M,"handleMutations"),document.addEventListener("focusin",E),document.addEventListener("focusout",T);const P=new MutationObserver(M);return d&&P.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",T),P.disconnect()}}},[s,d,S.paused]),k.useEffect(()=>{if(d){Vv.add(S);const E=document.activeElement;if(!d.contains(E)){const M=new CustomEvent(lf,zv);d.addEventListener(lf,m),d.dispatchEvent(M),M.defaultPrevented||(U1(X1(Rh(d)),{select:!0}),document.activeElement===E&&sr(d))}return()=>{d.removeEventListener(lf,m),setTimeout(()=>{const M=new CustomEvent(uf,zv);d.addEventListener(uf,p),d.dispatchEvent(M),M.defaultPrevented||sr(E??document.body,{select:!0}),d.removeEventListener(uf,p),Vv.remove(S)},0)}}},[d,m,p,S]);const C=k.useCallback(E=>{if(!i&&!s||S.paused)return;const T=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,M=document.activeElement;if(T&&M){const P=E.currentTarget,[D,$]=W1(P);D&&$?!E.shiftKey&&M===$?(E.preventDefault(),i&&sr(D,{select:!0})):E.shiftKey&&M===D&&(E.preventDefault(),i&&sr($,{select:!0})):M===P&&E.preventDefault()}},[i,s,S.paused]);return v.jsx(mi.div,{tabIndex:-1,...c,ref:w,onKeyDown:C})},"FocusScope"));function U1(e,{select:t=!1}={}){const n=document.activeElement;for(const i of e)if(sr(i,{select:t}),document.activeElement!==n)return}qt(U1,"focusFirst");function W1(e){const t=Rh(e),n=yd(t,e),i=yd(t.reverse(),e);return[n,i]}qt(W1,"getTabbableEdges");function Rh(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:qt(i=>{const s=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||s?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}qt(Rh,"getTabbableCandidates");function yd(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const i of e)if(!(n?!i.checkVisibility({checkVisibilityCSS:!0}):H1(i,{upTo:t})))return i}qt(yd,"findVisible");function H1(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}qt(H1,"isHidden");function K1(e){return e instanceof HTMLInputElement&&"select"in e}qt(K1,"isSelectableInput");function sr(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&K1(e)&&t&&e.select()}}qt(sr,"focus");var Vv=q1();function q1(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=vd(e,t),e.unshift(t)},remove(t){e=vd(e,t),e[0]?.resume()}}}qt(q1,"createFocusScopesStack");function vd(e,t){const n=[...e],i=n.indexOf(t);return i!==-1&&n.splice(i,1),n}qt(vd,"arrayRemove");function X1(e){return e.filter(t=>t.tagName!=="A")}qt(X1,"removeLinks");var y_=Object.defineProperty,v_=(e,t)=>y_(e,"name",{value:t,configurable:!0}),x_=k.forwardRef(v_(function(t,n){const{container:i,...s}=t,[l,a]=k.useState(!1);zr(()=>a(!0),[]);const c=i||l&&globalThis?.document?.body;return c?I1.createPortal(v.jsx(mi.div,{...s,ref:n}),c):null},"Portal")),w_=Object.defineProperty,ar=(e,t)=>w_(e,"name",{value:t,configurable:!0});function Y1(e,t){return k.useReducer((n,i)=>t[n][i]??n,e)}ar(Y1,"useStateMachine");var Mh=ar(e=>{const{present:t,children:n}=e,i=G1(t),s=typeof n=="function"?n({present:i.isPresent}):k.Children.only(n),l=Q1(i.ref,Z1(s));return typeof n=="function"||i.isPresent?k.cloneElement(s,{ref:l}):null},"Presence");function G1(e){const[t,n]=k.useState(),i=k.useRef(null),s=k.useRef(e),l=k.useRef("none"),a=k.useRef(void 0),c=e?"mounted":"unmounted",[d,h]=Y1(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{d==="mounted"?(l.current=a.current??qi(i.current),a.current=void 0):l.current="none"},[d]),zr(()=>{const m=i.current,p=s.current;if(p!==e){const w=l.current,S=qi(m);e?(a.current=S,h("MOUNT")):S==="none"||m?.display==="none"?h("UNMOUNT"):h(p&&w!==S?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,h]),zr(()=>{if(t){let m;const p=t.ownerDocument.defaultView??window,y=ar(S=>{const E=qi(i.current).includes(CSS.escape(S.animationName));if(S.target===t&&E&&(h("ANIMATION_END"),!s.current)){const T=t.style.animationFillMode;t.style.animationFillMode="forwards",m=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=T)})}},"handleAnimationEnd"),w=ar(S=>{S.target===t&&(l.current=qi(i.current))},"handleAnimationStart");return t.addEventListener("animationstart",w),t.addEventListener("animationcancel",y),t.addEventListener("animationend",y),()=>{p.clearTimeout(m),t.removeEventListener("animationstart",w),t.removeEventListener("animationcancel",y),t.removeEventListener("animationend",y)}}else h("ANIMATION_END")},[t,h]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:k.useCallback(m=>{if(m){const p=getComputedStyle(m);i.current=p,a.current=qi(p)}else i.current=null;n(m)},[])}}ar(G1,"usePresence");function xd(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}ar(xd,"setRef");function Q1(...e){const t=k.useRef(e);return t.current=e,k.useCallback(n=>{const i=t.current;let s=!1;const l=i.map(a=>{const c=xd(a,n);return!s&&typeof c=="function"&&(s=!0),c});if(s)return()=>{for(let a=0;a<l.length;a++){const c=l[a];typeof c=="function"?c():xd(i[a],null)}}},[])}ar(Q1,"useStableComposedRefs");function qi(e){return e?.animationName||"none"}ar(qi,"getAnimationName");function Z1(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ar(Z1,"getElementRef");var k_=Object.defineProperty,Ah=(e,t)=>k_(e,"name",{value:t,configurable:!0}),Ga=0,Vi=null;function S_(e){return Nh(),e.children}Ah(S_,"FocusGuards");function Nh(){k.useEffect(()=>{Vi||(Vi={start:wd(),end:wd()});const{start:e,end:t}=Vi;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Ga++,()=>{Ga===1&&(Vi?.start.remove(),Vi?.end.remove(),Vi=null),Ga=Math.max(0,Ga-1)}},[])}Ah(Nh,"useFocusGuards");function wd(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}Ah(wd,"createFocusGuard");var Hn=function(){return Hn=Object.assign||function(t){for(var n,i=1,s=arguments.length;i<s;i++){n=arguments[i];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(t[l]=n[l])}return t},Hn.apply(this,arguments)};function J1(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++)t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(n[i[s]]=e[i[s]]);return n}function b_(e,t,n){if(n||arguments.length===2)for(var i=0,s=t.length,l;i<s;i++)(l||!(i in t))&&(l||(l=Array.prototype.slice.call(t,0,i)),l[i]=t[i]);return e.concat(l||Array.prototype.slice.call(t))}var ml="right-scroll-bar-position",gl="width-before-scroll-bar",C_="with-scroll-bars-hidden",E_="--removed-body-scroll-bar-size";function cf(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function T_(e,t){var n=k.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(i){var s=n.value;s!==i&&(n.value=i,n.callback(i,s))}}}})[0];return n.callback=t,n.facade}var P_=typeof window<"u"?k.useLayoutEffect:k.useEffect,Bv=new WeakMap;function R_(e,t){var n=T_(null,function(i){return e.forEach(function(s){return cf(s,i)})});return P_(function(){var i=Bv.get(n);if(i){var s=new Set(i),l=new Set(e),a=n.current;s.forEach(function(c){l.has(c)||cf(c,null)}),l.forEach(function(c){s.has(c)||cf(c,a)})}Bv.set(n,e)},[e]),n}function M_(e){return e}function A_(e,t){t===void 0&&(t=M_);var n=[],i=!1,s={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(l){var a=t(l,i);return n.push(a),function(){n=n.filter(function(c){return c!==a})}},assignSyncMedium:function(l){for(i=!0;n.length;){var a=n;n=[],a.forEach(l)}n={push:function(c){return l(c)},filter:function(){return n}}},assignMedium:function(l){i=!0;var a=[];if(n.length){var c=n;n=[],c.forEach(l),a=n}var d=function(){var m=a;a=[],m.forEach(l)},h=function(){return Promise.resolve().then(d)};h(),n={push:function(m){a.push(m),h()},filter:function(m){return a=a.filter(m),n}}}};return s}function N_(e){e===void 0&&(e={});var t=A_(null);return t.options=Hn({async:!0,ssr:!1},e),t}var ek=function(e){var t=e.sideCar,n=J1(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=t.read();if(!i)throw new Error("Sidecar medium not found");return k.createElement(i,Hn({},n))};ek.isSideCarExport=!0;function I_(e,t){return e.useMedium(t),ek}var tk=N_(),ff=function(){},Xl=k.forwardRef(function(e,t){var n=k.useRef(null),i=k.useState({onScrollCapture:ff,onWheelCapture:ff,onTouchMoveCapture:ff}),s=i[0],l=i[1],a=e.forwardProps,c=e.children,d=e.className,h=e.removeScrollBar,m=e.enabled,p=e.shards,y=e.sideCar,w=e.noRelative,S=e.noIsolation,C=e.inert,E=e.allowPinchZoom,T=e.as,M=T===void 0?"div":T,P=e.gapMode,D=J1(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),$=y,j=R_([n,t]),Y=Hn(Hn({},D),s);return k.createElement(k.Fragment,null,m&&k.createElement($,{sideCar:tk,removeScrollBar:h,shards:p,noRelative:w,noIsolation:S,inert:C,setCallbacks:l,allowPinchZoom:!!E,lockRef:n,gapMode:P}),a?k.cloneElement(k.Children.only(c),Hn(Hn({},Y),{ref:j})):k.createElement(M,Hn({},Y,{className:d,ref:j}),c))});Xl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Xl.classNames={fullWidth:gl,zeroRight:ml};var j_=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function D_(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=j_();return t&&e.setAttribute("nonce",t),e}function __(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function L_(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var O_=function(){var e=0,t=null;return{add:function(n){e==0&&(t=D_())&&(__(t,n),L_(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},F_=function(){var e=O_();return function(t,n){k.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},nk=function(){var e=F_(),t=function(n){var i=n.styles,s=n.dynamic;return e(i,s),null};return t},z_={left:0,top:0,right:0,gap:0},df=function(e){return parseInt(e||"",10)||0},V_=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],i=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[df(n),df(i),df(s)]},B_=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return z_;var t=V_(e),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-n+t[2]-t[0])}},$_=nk(),Qi="data-scroll-locked",U_=function(e,t,n,i){var s=e.left,l=e.top,a=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
269
|
-
.`.concat(C_,` {
|
|
267
|
+
`),a}const aD="",lD="application/octet-stream",uD=/\.([A-Za-z0-9]{1,12})$/;function h1(e){return String(e??"").split(";")[0].trim().toLowerCase()}function p1(e){const t=uD.exec(String(e??"").trim());return t?t[1].toLowerCase():""}function cD(e){const t=p1(e);return t==="html"||t==="htm"}function As(e,t){return cD(e)?!0:p1(e)?!1:h1(t)==="text/html"}function wh(e,t){const n=h1(e);return n==="text/html"||As(t,e)?lD:n}const fd=48e3,fD=Object.freeze([{rec:"audio/webm;codecs=opus",base:"audio/webm",ext:"webm"},{rec:"audio/ogg;codecs=opus",base:"audio/ogg",ext:"ogg"},{rec:"audio/webm",base:"audio/webm",ext:"webm"},{rec:"audio/mp4",base:"audio/mp4",ext:"m4a"}]),m1="x-ours-duration",dD=4e3;function hD(e){return!Number.isFinite(e)||e<=0?null:String(Math.round(e*100)/100)}function pD(e,t){const n=t===null?null:hD(t);return n===null?e:`${e};${m1}=${n}`}function mD(e){if(!e)return null;const t=new RegExp(`${m1}\\s*=\\s*([0-9]*\\.?[0-9]+)`,"i").exec(e);if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)&&n>0?n:null}function gD(e,t=dD){return typeof Audio!="function"||typeof URL?.createObjectURL!="function"?Promise.resolve(null):new Promise(n=>{const i=URL.createObjectURL(e),s=new Audio;let l=!1;const a=d=>{l||(l=!0,clearTimeout(c),s.removeAttribute("src"),s.load(),URL.revokeObjectURL(i),n(Number.isFinite(d)&&(d??0)>0?d:null))},c=setTimeout(()=>a(null),t);s.addEventListener("loadedmetadata",()=>{Number.isFinite(s.duration)&&s.duration>0?a(s.duration):s.currentTime=Number.MAX_SAFE_INTEGER},{once:!0}),s.addEventListener("durationchange",()=>{Number.isFinite(s.duration)&&s.duration>0&&a(s.duration)}),s.addEventListener("error",()=>a(null),{once:!0}),s.preload="metadata",s.src=i})}const g1=40,yD=44,y1=.14,vD=.5,xD=e=>e<0?0:e>1?1:e;function v1(e,{floor:t=y1,gamma:n=vD}={}){const i=Math.pow(xD(Number.isFinite(e)?e:0),n);return t+(1-t)*i}function wD(e,t=g1){const n=Math.max(1,Math.floor(t)),i=new Array(n).fill(0);if(!e||e.length===0)return i;const s=e.length/n;for(let l=0;l<n;l++){const a=Math.floor(l*s),c=Math.min(e.length,Math.max(a+1,Math.floor((l+1)*s)));let d=0;for(let h=a;h<c;h++)d+=e[h]*e[h];i[l]=Math.sqrt(d/(c-a))}return i}function kD(e,t={}){const{silenceFloor:n=1e-4}=t,i=e.reduce((s,l)=>l>s?l:s,0);return i>n?e.map(s=>v1(s/i,t)):e.map(()=>y1)}function SD({decay:e=.995,minReference:t=.02}={}){let n=t;return{push(i){const s=Number.isFinite(i)&&i>0?i:0;return n=Math.max(t,n*e,s),v1(s/n)},get reference(){return n}}}function x1(e){return wh(e.mime,e.filename)}function kh(e){const[t,n]=k.useState({url:null,size:0,loaded:!1});return k.useEffect(()=>{let i=null,s=!1;n({url:null,size:0,loaded:!1});const l=e.available?D2(e.id):null;return l?(n({url:l,size:e.size,loaded:!0}),()=>{}):(Ul(e.id).then(a=>{if(s)return;if(!a){n({url:null,size:0,loaded:!0});return}const c=URL.createObjectURL(new Blob([a],{type:x1(e)}));i=c,n({url:c,size:a.byteLength,loaded:!0})}),()=>{s=!0,i&&URL.revokeObjectURL(i)})},[e.id,e.available]),t}function Sh({label:e}){return v.jsxs("div",{className:"file-offdevice",children:[v.jsx("div",{className:"file-offdevice-ic",children:v.jsx(Ee,{name:"inbox",size:16})}),v.jsxs("div",{className:"filecard-meta",children:[v.jsx("div",{className:"filecard-name",title:e,children:e}),v.jsx("div",{className:"filecard-sub",children:"Available on your original device"})]})]})}function bD(e){const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Nv({rec:e}){if(!e.transcription)return null;const t=e.transcription.text?.trim();return v.jsx("div",{className:"voice-transcript",children:t||`Transcription ${e.transcription.status??"unavailable"}${e.transcription.error_category?` · ${e.transcription.error_category}`:""}`})}function CD({rec:e,receipt:t,receiptless:n,onPreview:i,onFetch:s}){const l=e.dir==="out",a=`bubble file-bubble${l?" me":""}`,c=eo(e.mime,e.filename)?"Voice message":"File",d=v.jsxs("div",{className:"bubble-at",children:[bD(e.date),l&&v.jsx(b0,{receipt:t,content:c,receiptless:n})]});return e.mime.startsWith("image/")?v.jsx(ED,{rec:e,cls:a,footer:d,onFetch:s}):eo(e.mime,e.filename)?v.jsx(TD,{rec:e,cls:a,footer:d,onFetch:s}):v.jsx(PD,{rec:e,cls:a,footer:d,onPreview:i,onFetch:s})}function bh({rec:e,onFetch:t}){const[n,i]=k.useState(!1),[s,l]=k.useState(!1);return v.jsxs("div",{className:"file-offdevice",children:[v.jsx("div",{className:"file-offdevice-ic",children:v.jsx(Ee,{name:"inbox",size:16})}),v.jsxs("div",{className:"filecard-meta",children:[v.jsx("div",{className:"filecard-name",title:e.filename,children:eo(e.mime,e.filename)?"Voice message":e.filename}),v.jsx("div",{className:"filecard-sub",children:s?"Could not fetch media":"Available after explicit fetch"})]}),v.jsx("button",{className:"btn sm",disabled:n,onClick:()=>{i(!0),l(!1),(t?.(e.id)??O2(e.id)).catch(()=>l(!0)).finally(()=>i(!1))},children:n?"Fetching…":"Fetch"})]})}function ED({rec:e,cls:t,footer:n,onFetch:i}){const{url:s,loaded:l}=kh(e);return l&&!s?v.jsxs("div",{className:t+" filecard-bubble file-offdevice-bubble",children:[e.available===!1?v.jsx(bh,{rec:e,onFetch:i}):v.jsx(Sh,{label:e.filename&&e.filename!=="file"?e.filename:"Photo"}),n]}):v.jsxs("div",{className:t+" image-bubble",children:[s?v.jsx("a",{href:s,target:"_blank",rel:"noreferrer",title:e.filename,children:v.jsx("img",{src:s,alt:e.filename})}):v.jsx("div",{className:"file-loading",children:"loading…"}),n]})}function TD({rec:e,cls:t,footer:n,onFetch:i}){const{url:s,loaded:l}=kh(e),a=k.useRef(null),c=k.useRef(null),[d,h]=k.useState(!1),[m,p]=k.useState(0),[y,w]=k.useState(()=>mD(e.mime)),[S,C]=k.useState(!1),[E,T]=k.useState(null);if(k.useEffect(()=>{if(!s)return;let U=!1;const O=typeof window>"u"?void 0:window.AudioContext||window.webkitAudioContext;if(!O)return;const N=new O,X=()=>{try{N.close()?.catch?.(()=>{})}catch{}};return(async()=>{try{const V=await fetch(s).then(J=>J.arrayBuffer()),fe=await N.decodeAudioData(V);if(U)return;T(kD(wD(fe.getChannelData(0),g1)))}catch{}finally{X()}})(),()=>{U=!0,X()}},[s]),l&&!s)return v.jsxs("div",{className:t+" filecard-bubble file-offdevice-bubble",children:[e.available===!1?v.jsx(bh,{rec:e,onFetch:i}):v.jsx(Sh,{label:"Voice message"}),n,v.jsx(Nv,{rec:e})]});const M=()=>{const U=a.current;U&&(d?U.pause():U.play())},P=U=>{const O=c.current;if(!O)return 0;const N=O.getBoundingClientRect();return Math.max(0,Math.min(1,(U-N.left)/N.width))},D=U=>{const O=a.current;p(U),O&&y&&isFinite(y)&&(O.currentTime=U*y)},$=U=>{s&&(U.currentTarget.setPointerCapture?.(U.pointerId),C(!0),D(P(U.clientX)))},j=U=>{S&&D(P(U.clientX))},Y=U=>{S&&(U.currentTarget.releasePointerCapture?.(U.pointerId),C(!1))};return v.jsxs("div",{className:t+" voice-bubble",children:[v.jsx("button",{className:"voice-play",onClick:M,disabled:!s,title:d?"Pause":"Play",children:v.jsx(Ee,{name:d?"pause":"play",size:14})}),v.jsxs("div",{className:"voice-track"+(s?" seekable":"")+(S?" scrubbing":"")+(E?" has-wave":""),ref:c,onPointerDown:$,onPointerMove:j,onPointerUp:Y,onPointerCancel:Y,role:s?"slider":void 0,"aria-label":s?"Seek":void 0,"aria-valuenow":Math.round(m*100),children:[E?v.jsx("div",{className:"voice-wave","aria-hidden":!0,children:E.map((U,O)=>v.jsx("span",{className:"voice-wave-bar"+(O/E.length<m?" played":""),style:{height:`${Math.round(U*100)}%`}},O))}):v.jsx("div",{className:"voice-track-fill",style:{width:`${m*100}%`}}),s&&v.jsx("span",{className:"voice-track-knob",style:{left:`${m*100}%`}})]}),v.jsx("span",{className:"voice-dur mono",children:y!==null?`${Math.floor(y/60)}:${String(Math.floor(y%60)).padStart(2,"0")}`:"·:··"}),s&&v.jsx("audio",{ref:a,src:s,onPlay:()=>h(!0),onPause:()=>h(!1),onEnded:()=>{h(!1),p(0)},onTimeUpdate:U=>{const O=U.currentTarget;!S&&O.duration>0&&isFinite(O.duration)&&p(O.currentTime/O.duration)},onLoadedMetadata:U=>{const O=U.currentTarget.duration;isFinite(O)&&O>0&&w(O)}}),n,v.jsx(Nv,{rec:e})]})}function PD({rec:e,cls:t,footer:n,onPreview:i,onFetch:s}){const{url:l,size:a,loaded:c}=kh(e);return c&&!l?v.jsxs("div",{className:t+" filecard-bubble file-offdevice-bubble",children:[e.available===!1?v.jsx(bh,{rec:e,onFetch:s}):v.jsx(Sh,{label:e.filename}),n]}):v.jsxs("div",{className:t+" filecard-bubble",children:[v.jsxs("div",{className:"filecard",children:[v.jsx("div",{className:"filecard-ic",children:v.jsx(Ee,{name:"copy",size:18})}),v.jsxs("div",{className:"filecard-meta",children:[v.jsx("div",{className:"filecard-name",title:e.filename,children:e.filename}),v.jsx("div",{className:"filecard-sub",children:a?Fr(a):e.size?Fr(e.size):""})]}),d1(e.filename)&&l&&i&&v.jsx("button",{className:"icon-btn",onClick:()=>i(e),title:"Preview markdown",children:v.jsx(Ee,{name:"monitor",size:16})}),As(e.filename,e.mime)&&l&&i&&v.jsx("button",{className:"icon-btn",onClick:()=>i(e),title:"Preview HTML",children:v.jsx(Ee,{name:"monitor",size:16})}),v.jsx("a",{className:"icon-btn"+(l?"":" disabled"),href:l??void 0,download:e.filename,title:"Download",children:v.jsx(Ee,{name:"download",size:16})})]}),n]})}function w1(e){const{att:t}=e,[n,i]=k.useState(null);return k.useEffect(()=>{const s=x1({mime:t.mime,filename:t.filename}),l=URL.createObjectURL(new Blob([t.bytes],{type:s}));return i(l),()=>URL.revokeObjectURL(l)},[t]),v.jsxs("div",{className:"attach-preview",children:[t.mime.startsWith("image/")&&n?v.jsx("img",{className:"attach-thumb",src:n,alt:t.filename}):t.voice&&n?v.jsx("audio",{className:"attach-audio",src:n,controls:!0}):v.jsx("div",{className:"filecard-ic",children:v.jsx(Ee,{name:"copy",size:16})}),v.jsxs("div",{className:"filecard-meta",children:[v.jsx("div",{className:"filecard-name",title:t.filename,children:t.voice?"Voice message":t.filename}),v.jsxs("div",{className:"filecard-sub",children:[Fr(t.bytes.length),t.originalSize&&t.originalSize>t.bytes.length?` · optimized from ${Fr(t.originalSize)}`:""]})]}),v.jsx("button",{className:"btn primary sm",disabled:e.sending,onClick:e.onSend,children:e.sending?"Sending…":"Send"}),v.jsx("button",{className:"icon-btn",title:"Discard",disabled:e.sending,onClick:e.onDiscard,children:v.jsx(Ee,{name:"close"})})]})}const RD={channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},MD=e=>`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,"0")}`,Iv=84,jv=120,AD=550,ND=Math.floor(ts/(fd/8)),ID=Math.min(300,ND),jD=yD;function k1(e){const[t,n]=k.useState("idle"),[i,s]=k.useState(0),[l,a]=k.useState([]),[c,d]=k.useState(0),[h,m]=k.useState(0),p=k.useRef("idle"),y=k.useRef(null),w=k.useRef(null),S=k.useRef([]),C=k.useRef("webm"),E=k.useRef("audio/webm"),T=k.useRef(!1),M=k.useRef({x:0,y:0}),P=k.useRef(0),D=k.useRef(!1),$=k.useRef(null),j=k.useRef(null),Y=k.useRef(null),U=k.useRef(e.onReady),O=k.useRef(e.onError),N=k.useRef(e.onActiveChange);U.current=e.onReady,O.current=e.onError,N.current=e.onActiveChange;const X=te=>{p.current=te,n(te),N.current?.(te==="recording"||te==="locked"||te==="arming")},V=()=>{j.current!=null&&cancelAnimationFrame(j.current),j.current=null,Y.current&&clearInterval(Y.current),Y.current=null,$.current?.close().catch(()=>{}),$.current=null,w.current?.getTracks().forEach(te=>te.stop()),w.current=null},fe=()=>{window.removeEventListener("pointermove",Pe),window.removeEventListener("pointerup",Q),window.removeEventListener("pointercancel",Q)},J=te=>{T.current=te;const ge=y.current;ge&&ge.state!=="inactive"?ge.stop():ee(),fe()},ee=()=>{V(),X("idle"),s(0),a([]),d(0),m(0)},xe=()=>{p.current==="recording"&&(fe(),m(0),X("locked"))};function Pe(te){if(p.current!=="recording")return;const ge=M.current.y-te.clientY,ye=M.current.x-te.clientX,me=Math.max(0,Math.min(1,ge/Iv)),we=Math.max(0,Math.min(1,ye/jv));d(me),m(we),ge>=Iv?xe():ye>=jv&&J(!0)}function Q(){if(p.current==="arming"){D.current=!0,fe();return}if(p.current!=="recording")return;const te=Date.now()-P.current<AD;J(te)}const de=te=>{e.disabled||p.current!=="idle"||(te.preventDefault(),M.current={x:te.clientX,y:te.clientY},D.current=!1,T.current=!1,S.current=[],d(0),m(0),X("arming"),window.addEventListener("pointermove",Pe),window.addEventListener("pointerup",Q),window.addEventListener("pointercancel",Q),R())};async function R(){let te;try{te=await navigator.mediaDevices.getUserMedia({audio:RD})}catch{O.current("Microphone unavailable — check the browser permission."),fe(),X("idle");return}if(D.current||p.current==="idle"){te.getTracks().forEach(me=>me.stop()),X("idle");return}w.current=te;const ge=fD.find(me=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(me.rec));C.current=ge?.ext??"webm",E.current=ge?.base??"audio/webm";const ye=ge?new MediaRecorder(te,{mimeType:ge.rec,audioBitsPerSecond:fd}):new MediaRecorder(te,{audioBitsPerSecond:fd});y.current=ye,ye.ondataavailable=me=>{me.data.size>0&&S.current.push(me.data)},ye.onstop=()=>{if(T.current){ee();return}const we=new Blob(S.current,{type:E.current});Promise.all([we.arrayBuffer(),gD(we)]).then(([pe,Ve])=>{if(ee(),pe.byteLength===0)return;const qe=new Date().toISOString().replace(/[-:]/g,"").replace(/\..+/,"").replace("T","-");U.current({filename:`${k0}${qe}.${C.current}`,mime:pD(_2(E.current),Ve),bytes:new Uint8Array(pe),voice:!0})})},ye.start(),P.current=Date.now(),X("recording"),s(0),Y.current=setInterval(()=>{s(me=>{const we=me+1;return we>=ID&&J(!1),we})},1e3),F(te)}function F(te){try{const ge=window.AudioContext||window.webkitAudioContext,ye=new ge;$.current=ye;const me=ye.createMediaStreamSource(te),we=ye.createAnalyser();we.fftSize=256,me.connect(we);const pe=new Uint8Array(we.fftSize),Ve=SD();let qe=0;const it=We=>{if(j.current=requestAnimationFrame(it),We-qe<80)return;qe=We,we.getByteTimeDomainData(pe);let at=0;for(let lt=0;lt<pe.length;lt++){const Pt=(pe[lt]-128)/128;at+=Pt*Pt}const xt=Math.sqrt(at/pe.length),Vt=Ve.push(xt);a(lt=>{const Pt=lt.length>=jD?lt.slice(1):lt.slice();return Pt.push(Vt),Pt})};j.current=requestAnimationFrame(it)}catch{}}k.useEffect(()=>()=>{T.current=!0,y.current?.stop(),fe(),V()},[]);const G=t==="recording"||t==="locked"||t==="arming",A=v.jsx("div",{className:"vr-wave","aria-hidden":!0,children:l.map((te,ge)=>v.jsx("span",{className:"vr-bar",style:{height:`${Math.round(te*100)}%`}},ge))});return v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"icon-btn composer-tool vr-mic",title:"Hold to record a voice message",disabled:e.disabled,onPointerDown:de,onContextMenu:te=>te.preventDefault(),children:v.jsx(Ee,{name:"mic",size:18})}),G&&v.jsxs("div",{className:"voice-rec-overlay","data-mode":t,children:[t==="recording"&&v.jsxs("div",{className:"vr-lock",style:{"--p":c},"aria-hidden":!0,children:[v.jsx(Ee,{name:"lock",size:13}),v.jsx(Ee,{name:"chevronDown",size:12})]}),v.jsx("span",{className:"voice-rec-dot"}),v.jsx("span",{className:"vr-time mono",children:MD(i)}),t==="locked"?v.jsxs(v.Fragment,{children:[A,v.jsx("button",{className:"icon-btn vr-trash",title:"Cancel",onClick:()=>J(!0),children:v.jsx(Ee,{name:"trash",size:16})}),v.jsxs("button",{className:"btn primary sm vr-stop",onClick:()=>J(!1),children:[v.jsx(Ee,{name:"check",size:13}),"Stop"]})]}):v.jsxs("div",{className:"vr-slide",style:{opacity:1-h},children:[A,v.jsx("span",{className:"vr-hint",children:"‹ slide to cancel · slide up to lock"})]})]})]})}const DD="modulepreload",_D=function(e){return"/"+e},Dv={},Ch=function(t,n,i){let s=Promise.resolve();if(n&&n.length>0){let a=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=c?.nonce||c?.getAttribute("nonce");s=a(n.map(h=>{if(h=_D(h),h in Dv)return;Dv[h]=!0;const m=h.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const y=document.createElement("link");if(y.rel=m?"stylesheet":DD,m||(y.as="script"),y.crossOrigin="",y.href=h,d&&y.setAttribute("nonce",d),document.head.appendChild(y),m)return new Promise((w,S)=>{y.addEventListener("load",w),y.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return s.then(a=>{for(const c of a||[])c.status==="rejected"&&l(c.reason);return t().catch(l)})};var LD=Object.defineProperty,ao=(e,t)=>LD(e,"name",{value:t,configurable:!0}),S1=!!(typeof window<"u"&&window.document&&window.document.createElement);function _r(e,t,{checkForDefaultPrevented:n=!0}={}){return ao(function(s){if(e?.(s),n===!1||!s||!s.defaultPrevented)return t?.(s)},"handleEvent")}ao(_r,"composeEventHandlers");function OD(e){if(!S1)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}ao(OD,"getOwnerWindow");function dd(e){if(!S1)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}ao(dd,"getOwnerDocument");function b1(e,t=!1){const{activeElement:n}=dd(e);if(!n?.nodeName)return null;if(C1(n)&&n.contentDocument)return b1(n.contentDocument.body,t);if(t){const i=n.getAttribute("aria-activedescendant");if(i){const s=dd(n).getElementById(i);if(s)return s}}return n}ao(b1,"getActiveElement");function C1(e){return e.tagName==="IFRAME"}ao(C1,"isFrame");var FD=Object.defineProperty,Eh=(e,t)=>FD(e,"name",{value:t,configurable:!0});function hd(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Eh(hd,"setRef");function E1(...e){return t=>{let n=!1;const i=e.map(s=>{const l=hd(s,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let s=0;s<i.length;s++){const l=i[s];typeof l=="function"?l():hd(e[s],null)}}}}Eh(E1,"composeRefs");function lo(...e){return k.useCallback(E1(...e),e)}Eh(lo,"useComposedRefs");var zD=Object.defineProperty,xn=(e,t)=>zD(e,"name",{value:t,configurable:!0});function VD(e,t){const n=k.createContext(t);n.displayName=e+"Context";const i=xn(l=>{const{children:a,...c}=l,d=k.useMemo(()=>c,Object.values(c));return v.jsx(n.Provider,{value:d,children:a})},"Provider");i.displayName=e+"Provider";function s(l,a={}){const{optional:c=!1}=a,d=k.useContext(n);if(d)return d;if(t!==void 0)return t;if(!c)throw new Error(`\`${l}\` must be used within \`${e}\``)}return xn(s,"useContext"),[i,s]}xn(VD,"createContext");function T1(e,t=[]){let n=[];function i(l,a){const c=k.createContext(a);c.displayName=l+"Context";const d=n.length;n=[...n,a];const h=xn(p=>{const{scope:y,children:w,...S}=p,C=y?.[e]?.[d]||c,E=k.useMemo(()=>S,Object.values(S));return v.jsx(C.Provider,{value:E,children:w})},"Provider");h.displayName=l+"Provider";function m(p,y,w={}){const{optional:S=!1}=w,C=y?.[e]?.[d]||c,E=k.useContext(C);if(E)return E;if(a!==void 0)return a;if(!S)throw new Error(`\`${p}\` must be used within \`${l}\``)}return xn(m,"useContext"),[h,m]}xn(i,"createContext");const s=xn(()=>{const l=n.map(a=>k.createContext(a));return xn(function(c){const d=c?.[e]||l;return k.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])},"useScope")},"createScope");return s.scopeName=e,[i,P1(s,...t)]}xn(T1,"createContextScope");function P1(...e){const t=e[0];if(e.length===1)return t;const n=xn(()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return xn(function(l){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(l)[`__scope${h}`];return{...c,...p}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}xn(P1,"composeContextScopes");var zr=globalThis?.document?k.useLayoutEffect:()=>{},BD=Object.defineProperty,$D=(e,t)=>BD(e,"name",{value:t,configurable:!0}),UD=bs[" useId ".trim().toString()]||(()=>{}),WD=0;function pl(e){const[t,n]=k.useState(UD());return zr(()=>{e||n(i=>i??String(WD++))},[e]),e||(t?`radix-${t}`:"")}$D(pl,"useId");var HD=Object.defineProperty,KD=(e,t)=>HD(e,"name",{value:t,configurable:!0}),_v=bs[" useEffectEvent ".trim().toString()],Lv=bs[" useInsertionEffect ".trim().toString()];function R1(e){if(typeof _v=="function")return _v(e);const t=k.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Lv=="function"?Lv(()=>{t.current=e}):zr(()=>{t.current=e}),k.useMemo(()=>(...n)=>t.current?.(...n),[])}KD(R1,"useEffectEvent");var qD=Object.defineProperty,Ns=(e,t)=>qD(e,"name",{value:t,configurable:!0}),XD=bs[" useInsertionEffect ".trim().toString()]||zr;function M1({prop:e,defaultProp:t,onChange:n=Ns(()=>{},"onChange"),caller:i}){const[s,l,a]=A1({defaultProp:t,onChange:n}),c=e!==void 0,d=c?e:s,h=k.useCallback(m=>{if(c){const p=N1(m)?m(e):m;p!==e&&a.current?.(p)}else l(m)},[c,e,l,a]);return[d,h]}Ns(M1,"useControllableState");function A1({defaultProp:e,onChange:t}){const[n,i]=k.useState(e),s=k.useRef(n),l=k.useRef(t);return XD(()=>{l.current=t},[t]),k.useEffect(()=>{s.current!==n&&(l.current?.(n),s.current=n)},[n,s]),[n,i,l]}Ns(A1,"useUncontrolledState");function N1(e){return typeof e=="function"}Ns(N1,"isFunction");var Ov=Symbol("RADIX:SYNC_STATE");function YD(e,t,n,i){const{prop:s,defaultProp:l,onChange:a,caller:c}=t,d=s!==void 0,h=R1(a),m=[{...n,state:l}];i&&m.push(i);const[p,y]=k.useReducer((E,T)=>{if(T.type===Ov)return{...E,state:T.state};const M=e(E,T);return d&&!Object.is(M.state,E.state)&&h(M.state),M},...m),w=p.state,S=k.useRef(w);k.useEffect(()=>{S.current!==w&&(S.current=w,d||h(w))},[w,S,d]);const C=k.useMemo(()=>s!==void 0?{...p,state:s}:p,[p,s]);return k.useEffect(()=>{d&&!Object.is(s,p.state)&&y({type:Ov,state:s})},[s,p.state,d]),[C,y]}Ns(YD,"useControllableStateReducer");var I1=Rx(),GD=Object.defineProperty,_n=(e,t)=>GD(e,"name",{value:t,configurable:!0});function Th(e){const t=k.forwardRef((n,i)=>{let{children:s,...l}=n,a=null,c=!1;const d=[];pd(s)&&typeof Ya=="function"&&(s=Ya(s._payload)),k.Children.forEach(s,y=>{if(L1(y)){c=!0;const w=y;let S="child"in w.props?w.props.child:w.props.children;pd(S)&&typeof Ya=="function"&&(S=Ya(S._payload)),a=ZD(w,S),d.push(a?.props?.children)}else d.push(y)}),a?a=k.cloneElement(a,void 0,d):!c&&k.Children.count(s)===1&&k.isValidElement(s)&&(a=s);const h=a?_1(a):void 0,m=lo(i,h);if(!a){if(s||s===0)throw new Error(c?t_(e):e_(e));return s}const p=D1(l,a.props??{});return a.type!==k.Fragment&&(p.ref=i?m:h),k.cloneElement(a,p)});return t.displayName=`${e}.Slot`,t}_n(Th,"createSlot");var j1=Symbol.for("radix.slottable");function QD(e){const t=_n(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=j1,t}_n(QD,"createSlottable");var ZD=_n((e,t)=>{if("child"in e.props){const n=e.props.child;return k.isValidElement(n)?k.cloneElement(n,void 0,e.props.children(n.props.children)):null}return k.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function D1(e,t){const n={...t};for(const i in t){const s=e[i],l=t[i];/^on[A-Z]/.test(i)?s&&l?n[i]=(...c)=>{const d=l(...c);return s(...c),d}:s&&(n[i]=s):i==="style"?n[i]={...s,...l}:i==="className"&&(n[i]=[s,l].filter(Boolean).join(" "))}return{...e,...n}}_n(D1,"mergeProps");function _1(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}_n(_1,"getElementRef");function L1(e){return k.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===j1}_n(L1,"isSlottable");var JD=Symbol.for("react.lazy");function pd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===JD&&"_payload"in e&&O1(e._payload)}_n(pd,"isLazyComponent");function O1(e){return typeof e=="object"&&e!==null&&"then"in e}_n(O1,"isPromiseLike");var e_=_n(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),t_=_n(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Ya=bs[" use ".trim().toString()],n_=Object.defineProperty,r_=(e,t)=>n_(e,"name",{value:t,configurable:!0}),i_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mi=i_.reduce((e,t)=>{const n=Th(`Primitive.${t}`),i=k.forwardRef((s,l)=>{const{asChild:a,...c}=s,d=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(d,{...c,ref:l})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function F1(e,t){e&&I1.flushSync(()=>e.dispatchEvent(t))}r_(F1,"dispatchDiscreteCustomEvent");var o_=Object.defineProperty,s_=(e,t)=>o_(e,"name",{value:t,configurable:!0});function no(e){const t=k.useRef(e);return k.useEffect(()=>{t.current=e}),k.useMemo(()=>(...n)=>t.current?.(...n),[])}s_(no,"useCallbackRef");var a_=Object.defineProperty,Tt=(e,t)=>a_(e,"name",{value:t,configurable:!0}),md="dismissableLayer.update",l_="dismissableLayer.pointerDownOutside",u_="dismissableLayer.focusOutside",Fv,z1=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),c_=k.forwardRef(Tt(function(t,n){const{disableOutsidePointerEvents:i=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:d,onDismiss:h,...m}=t,p=k.useContext(z1),[y,w]=k.useState(null),S=y?.ownerDocument??globalThis?.document,[,C]=k.useState({}),E=lo(n,w),T=Array.from(p.layers),[M]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),P=M?T.indexOf(M):-1,D=y?T.indexOf(y):-1,$=p.layersWithOutsidePointerEventsDisabled.size>0,j=D>=P,Y=k.useRef(!1),U=B1(V=>{a?.(V),d?.(V),V.defaultPrevented||h?.()},{ownerDocument:S,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:Y,dismissableSurfaces:p.dismissableSurfaces,shouldHandlePointerDownOutside:k.useCallback(V=>{if(!(V instanceof Node))return!1;const fe=[...p.branches].some(J=>J.contains(V));return j&&!fe},[p.branches,j])}),O=$1(V=>{if(s&&Y.current)return;const fe=V.target;[...p.branches].some(ee=>ee.contains(fe))||(c?.(V),d?.(V),V.defaultPrevented||h?.())},S),N=y?D===T.length-1:!1,X=no(V=>{V.key==="Escape"&&(l?.(V),!V.defaultPrevented&&h&&(V.preventDefault(),h()))});return k.useEffect(()=>{if(N)return S.addEventListener("keydown",X,{capture:!0}),()=>S.removeEventListener("keydown",X,{capture:!0})},[S,N,X]),k.useEffect(()=>{if(y)return i&&(p.layersWithOutsidePointerEventsDisabled.size===0&&(Fv=S.body.style.pointerEvents,S.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(y)),p.layers.add(y),gd(),()=>{i&&(p.layersWithOutsidePointerEventsDisabled.delete(y),p.layersWithOutsidePointerEventsDisabled.size===0&&(S.body.style.pointerEvents=Fv))}},[y,S,i,p]),k.useEffect(()=>()=>{y&&(p.layers.delete(y),p.layersWithOutsidePointerEventsDisabled.delete(y),gd())},[y,p]),k.useEffect(()=>{const V=Tt(()=>C({}),"handleUpdate");return document.addEventListener(md,V),()=>document.removeEventListener(md,V)},[]),v.jsx(mi.div,{...m,ref:E,style:{pointerEvents:$?j?"auto":"none":void 0,...t.style},onFocusCapture:_r(t.onFocusCapture,O.onFocusCapture),onBlurCapture:_r(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:_r(t.onPointerDownCapture,U.onPointerDownCapture)})},"DismissableLayer"));function V1(){const e=k.useContext(z1),[t,n]=k.useState(null);return k.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}Tt(V1,"useDismissableLayerSurface");var f_=Tt(()=>!0,"IS_TRUE");function B1(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:l,shouldHandlePointerDownOutside:a=f_}=t,c=no(e),d=k.useRef(!1),h=k.useRef(!1),m=k.useRef(new Map),p=k.useRef(()=>{});return k.useEffect(()=>{function y(){h.current=!1,s.current=!1,m.current.clear()}Tt(y,"resetOutsideInteraction");function w(){return Array.from(m.current.values()).some(Boolean)}Tt(w,"isOutsideInteractionIntercepted");function S(P){if(!h.current)return;const D=P.target;D instanceof Node&&[...l].some(j=>j.contains(D))||m.current.set(P.type,!0),P.type==="click"&&window.setTimeout(()=>{h.current&&p.current()},0)}Tt(S,"handleInteractionCapture");function C(P){h.current&&m.current.set(P.type,!1)}Tt(C,"handleInteractionBubble");const E=Tt(P=>{if(P.target&&!d.current){let D=function(){n.removeEventListener("click",p.current);const j=w();y(),j||Ph(l_,c,$,{discrete:!0})};if(Tt(D,"handleAndDispatchPointerDownOutsideEvent"),!a(P.target)){n.removeEventListener("click",p.current),y(),d.current=!1;return}const $={originalEvent:P};h.current=!0,s.current=i&&P.button===0,m.current.clear(),!i||P.button!==0?D():(n.removeEventListener("click",p.current),p.current=D,n.addEventListener("click",p.current,{once:!0}))}else n.removeEventListener("click",p.current),y();d.current=!1},"handlePointerDown"),T=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const P of T)n.addEventListener(P,S,!0),n.addEventListener(P,C);const M=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(M),n.removeEventListener("pointerdown",E),n.removeEventListener("click",p.current);for(const P of T)n.removeEventListener(P,S,!0),n.removeEventListener(P,C)}},[n,c,i,s,l,a]),{onPointerDownCapture:Tt(()=>d.current=!0,"onPointerDownCapture")}}Tt(B1,"usePointerDownOutside");function $1(e,t=globalThis?.document){const n=no(e),i=k.useRef(!1);return k.useEffect(()=>{const s=Tt(l=>{l.target&&!i.current&&Ph(u_,n,{originalEvent:l},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:Tt(()=>i.current=!0,"onFocusCapture"),onBlurCapture:Tt(()=>i.current=!1,"onBlurCapture")}}Tt($1,"useFocusOutside");function gd(){const e=new CustomEvent(md);document.dispatchEvent(e)}Tt(gd,"dispatchUpdate");function Ph(e,t,n,{discrete:i}){const s=n.originalEvent.target,l=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),i?F1(s,l):s.dispatchEvent(l)}Tt(Ph,"handleAndDispatchCustomEvent");var d_=Object.defineProperty,qt=(e,t)=>d_(e,"name",{value:t,configurable:!0}),lf="focusScope.autoFocusOnMount",uf="focusScope.autoFocusOnUnmount",zv={bubbles:!1,cancelable:!0},h_=k.forwardRef(qt(function(t,n){const{loop:i=!1,trapped:s=!1,onMountAutoFocus:l,onUnmountAutoFocus:a,...c}=t,[d,h]=k.useState(null),m=no(l),p=no(a),y=k.useRef(null),w=lo(n,h),S=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(s){let E=function(D){if(S.paused||!d)return;const $=D.target;d.contains($)?y.current=$:sr(y.current,{select:!0})},T=function(D){if(S.paused||!d)return;const $=D.relatedTarget;$!==null&&(d.contains($)||sr(y.current,{select:!0}))},M=function(D){if(document.activeElement===document.body)for(const j of D)j.removedNodes.length>0&&sr(d)};qt(E,"handleFocusIn"),qt(T,"handleFocusOut"),qt(M,"handleMutations"),document.addEventListener("focusin",E),document.addEventListener("focusout",T);const P=new MutationObserver(M);return d&&P.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",T),P.disconnect()}}},[s,d,S.paused]),k.useEffect(()=>{if(d){Vv.add(S);const E=document.activeElement;if(!d.contains(E)){const M=new CustomEvent(lf,zv);d.addEventListener(lf,m),d.dispatchEvent(M),M.defaultPrevented||(U1(X1(Rh(d)),{select:!0}),document.activeElement===E&&sr(d))}return()=>{d.removeEventListener(lf,m),setTimeout(()=>{const M=new CustomEvent(uf,zv);d.addEventListener(uf,p),d.dispatchEvent(M),M.defaultPrevented||sr(E??document.body,{select:!0}),d.removeEventListener(uf,p),Vv.remove(S)},0)}}},[d,m,p,S]);const C=k.useCallback(E=>{if(!i&&!s||S.paused)return;const T=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,M=document.activeElement;if(T&&M){const P=E.currentTarget,[D,$]=W1(P);D&&$?!E.shiftKey&&M===$?(E.preventDefault(),i&&sr(D,{select:!0})):E.shiftKey&&M===D&&(E.preventDefault(),i&&sr($,{select:!0})):M===P&&E.preventDefault()}},[i,s,S.paused]);return v.jsx(mi.div,{tabIndex:-1,...c,ref:w,onKeyDown:C})},"FocusScope"));function U1(e,{select:t=!1}={}){const n=document.activeElement;for(const i of e)if(sr(i,{select:t}),document.activeElement!==n)return}qt(U1,"focusFirst");function W1(e){const t=Rh(e),n=yd(t,e),i=yd(t.reverse(),e);return[n,i]}qt(W1,"getTabbableEdges");function Rh(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:qt(i=>{const s=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||s?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}qt(Rh,"getTabbableCandidates");function yd(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const i of e)if(!(n?!i.checkVisibility({checkVisibilityCSS:!0}):H1(i,{upTo:t})))return i}qt(yd,"findVisible");function H1(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}qt(H1,"isHidden");function K1(e){return e instanceof HTMLInputElement&&"select"in e}qt(K1,"isSelectableInput");function sr(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&K1(e)&&t&&e.select()}}qt(sr,"focus");var Vv=q1();function q1(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=vd(e,t),e.unshift(t)},remove(t){e=vd(e,t),e[0]?.resume()}}}qt(q1,"createFocusScopesStack");function vd(e,t){const n=[...e],i=n.indexOf(t);return i!==-1&&n.splice(i,1),n}qt(vd,"arrayRemove");function X1(e){return e.filter(t=>t.tagName!=="A")}qt(X1,"removeLinks");var p_=Object.defineProperty,m_=(e,t)=>p_(e,"name",{value:t,configurable:!0}),g_=k.forwardRef(m_(function(t,n){const{container:i,...s}=t,[l,a]=k.useState(!1);zr(()=>a(!0),[]);const c=i||l&&globalThis?.document?.body;return c?I1.createPortal(v.jsx(mi.div,{...s,ref:n}),c):null},"Portal")),y_=Object.defineProperty,ar=(e,t)=>y_(e,"name",{value:t,configurable:!0});function Y1(e,t){return k.useReducer((n,i)=>t[n][i]??n,e)}ar(Y1,"useStateMachine");var Mh=ar(e=>{const{present:t,children:n}=e,i=G1(t),s=typeof n=="function"?n({present:i.isPresent}):k.Children.only(n),l=Q1(i.ref,Z1(s));return typeof n=="function"||i.isPresent?k.cloneElement(s,{ref:l}):null},"Presence");function G1(e){const[t,n]=k.useState(),i=k.useRef(null),s=k.useRef(e),l=k.useRef("none"),a=k.useRef(void 0),c=e?"mounted":"unmounted",[d,h]=Y1(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{d==="mounted"?(l.current=a.current??qi(i.current),a.current=void 0):l.current="none"},[d]),zr(()=>{const m=i.current,p=s.current;if(p!==e){const w=l.current,S=qi(m);e?(a.current=S,h("MOUNT")):S==="none"||m?.display==="none"?h("UNMOUNT"):h(p&&w!==S?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,h]),zr(()=>{if(t){let m;const p=t.ownerDocument.defaultView??window,y=ar(S=>{const E=qi(i.current).includes(CSS.escape(S.animationName));if(S.target===t&&E&&(h("ANIMATION_END"),!s.current)){const T=t.style.animationFillMode;t.style.animationFillMode="forwards",m=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=T)})}},"handleAnimationEnd"),w=ar(S=>{S.target===t&&(l.current=qi(i.current))},"handleAnimationStart");return t.addEventListener("animationstart",w),t.addEventListener("animationcancel",y),t.addEventListener("animationend",y),()=>{p.clearTimeout(m),t.removeEventListener("animationstart",w),t.removeEventListener("animationcancel",y),t.removeEventListener("animationend",y)}}else h("ANIMATION_END")},[t,h]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:k.useCallback(m=>{if(m){const p=getComputedStyle(m);i.current=p,a.current=qi(p)}else i.current=null;n(m)},[])}}ar(G1,"usePresence");function xd(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}ar(xd,"setRef");function Q1(...e){const t=k.useRef(e);return t.current=e,k.useCallback(n=>{const i=t.current;let s=!1;const l=i.map(a=>{const c=xd(a,n);return!s&&typeof c=="function"&&(s=!0),c});if(s)return()=>{for(let a=0;a<l.length;a++){const c=l[a];typeof c=="function"?c():xd(i[a],null)}}},[])}ar(Q1,"useStableComposedRefs");function qi(e){return e?.animationName||"none"}ar(qi,"getAnimationName");function Z1(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ar(Z1,"getElementRef");var v_=Object.defineProperty,Ah=(e,t)=>v_(e,"name",{value:t,configurable:!0}),Ga=0,Vi=null;function x_(e){return Nh(),e.children}Ah(x_,"FocusGuards");function Nh(){k.useEffect(()=>{Vi||(Vi={start:wd(),end:wd()});const{start:e,end:t}=Vi;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Ga++,()=>{Ga===1&&(Vi?.start.remove(),Vi?.end.remove(),Vi=null),Ga=Math.max(0,Ga-1)}},[])}Ah(Nh,"useFocusGuards");function wd(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}Ah(wd,"createFocusGuard");var Hn=function(){return Hn=Object.assign||function(t){for(var n,i=1,s=arguments.length;i<s;i++){n=arguments[i];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(t[l]=n[l])}return t},Hn.apply(this,arguments)};function J1(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++)t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(n[i[s]]=e[i[s]]);return n}function w_(e,t,n){if(n||arguments.length===2)for(var i=0,s=t.length,l;i<s;i++)(l||!(i in t))&&(l||(l=Array.prototype.slice.call(t,0,i)),l[i]=t[i]);return e.concat(l||Array.prototype.slice.call(t))}var ml="right-scroll-bar-position",gl="width-before-scroll-bar",k_="with-scroll-bars-hidden",S_="--removed-body-scroll-bar-size";function cf(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function b_(e,t){var n=k.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(i){var s=n.value;s!==i&&(n.value=i,n.callback(i,s))}}}})[0];return n.callback=t,n.facade}var C_=typeof window<"u"?k.useLayoutEffect:k.useEffect,Bv=new WeakMap;function E_(e,t){var n=b_(null,function(i){return e.forEach(function(s){return cf(s,i)})});return C_(function(){var i=Bv.get(n);if(i){var s=new Set(i),l=new Set(e),a=n.current;s.forEach(function(c){l.has(c)||cf(c,null)}),l.forEach(function(c){s.has(c)||cf(c,a)})}Bv.set(n,e)},[e]),n}function T_(e){return e}function P_(e,t){t===void 0&&(t=T_);var n=[],i=!1,s={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(l){var a=t(l,i);return n.push(a),function(){n=n.filter(function(c){return c!==a})}},assignSyncMedium:function(l){for(i=!0;n.length;){var a=n;n=[],a.forEach(l)}n={push:function(c){return l(c)},filter:function(){return n}}},assignMedium:function(l){i=!0;var a=[];if(n.length){var c=n;n=[],c.forEach(l),a=n}var d=function(){var m=a;a=[],m.forEach(l)},h=function(){return Promise.resolve().then(d)};h(),n={push:function(m){a.push(m),h()},filter:function(m){return a=a.filter(m),n}}}};return s}function R_(e){e===void 0&&(e={});var t=P_(null);return t.options=Hn({async:!0,ssr:!1},e),t}var ek=function(e){var t=e.sideCar,n=J1(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=t.read();if(!i)throw new Error("Sidecar medium not found");return k.createElement(i,Hn({},n))};ek.isSideCarExport=!0;function M_(e,t){return e.useMedium(t),ek}var tk=R_(),ff=function(){},Xl=k.forwardRef(function(e,t){var n=k.useRef(null),i=k.useState({onScrollCapture:ff,onWheelCapture:ff,onTouchMoveCapture:ff}),s=i[0],l=i[1],a=e.forwardProps,c=e.children,d=e.className,h=e.removeScrollBar,m=e.enabled,p=e.shards,y=e.sideCar,w=e.noRelative,S=e.noIsolation,C=e.inert,E=e.allowPinchZoom,T=e.as,M=T===void 0?"div":T,P=e.gapMode,D=J1(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),$=y,j=E_([n,t]),Y=Hn(Hn({},D),s);return k.createElement(k.Fragment,null,m&&k.createElement($,{sideCar:tk,removeScrollBar:h,shards:p,noRelative:w,noIsolation:S,inert:C,setCallbacks:l,allowPinchZoom:!!E,lockRef:n,gapMode:P}),a?k.cloneElement(k.Children.only(c),Hn(Hn({},Y),{ref:j})):k.createElement(M,Hn({},Y,{className:d,ref:j}),c))});Xl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Xl.classNames={fullWidth:gl,zeroRight:ml};var A_=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function N_(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=A_();return t&&e.setAttribute("nonce",t),e}function I_(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function j_(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var D_=function(){var e=0,t=null;return{add:function(n){e==0&&(t=N_())&&(I_(t,n),j_(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},__=function(){var e=D_();return function(t,n){k.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},nk=function(){var e=__(),t=function(n){var i=n.styles,s=n.dynamic;return e(i,s),null};return t},L_={left:0,top:0,right:0,gap:0},df=function(e){return parseInt(e||"",10)||0},O_=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],i=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[df(n),df(i),df(s)]},F_=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return L_;var t=O_(e),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-n+t[2]-t[0])}},z_=nk(),Qi="data-scroll-locked",V_=function(e,t,n,i){var s=e.left,l=e.top,a=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
268
|
+
.`.concat(k_,` {
|
|
270
269
|
overflow: hidden `).concat(i,`;
|
|
271
270
|
padding-right: `).concat(c,"px ").concat(i,`;
|
|
272
271
|
}
|
|
@@ -300,23 +299,23 @@ ${l.join(`
|
|
|
300
299
|
}
|
|
301
300
|
|
|
302
301
|
body[`).concat(Qi,`] {
|
|
303
|
-
`).concat(
|
|
302
|
+
`).concat(S_,": ").concat(c,`px;
|
|
304
303
|
}
|
|
305
|
-
`)},$v=function(){var e=parseInt(document.body.getAttribute(Qi)||"0",10);return isFinite(e)?e:0},
|
|
304
|
+
`)},$v=function(){var e=parseInt(document.body.getAttribute(Qi)||"0",10);return isFinite(e)?e:0},B_=function(){k.useEffect(function(){return document.body.setAttribute(Qi,($v()+1).toString()),function(){var e=$v()-1;e<=0?document.body.removeAttribute(Qi):document.body.setAttribute(Qi,e.toString())}},[])},$_=function(e){var t=e.noRelative,n=e.noImportant,i=e.gapMode,s=i===void 0?"margin":i;B_();var l=k.useMemo(function(){return F_(s)},[s]);return k.createElement(z_,{styles:V_(l,!t,s,n?"":"!important")})},kd=!1;if(typeof window<"u")try{var Qa=Object.defineProperty({},"passive",{get:function(){return kd=!0,!0}});window.addEventListener("test",Qa,Qa),window.removeEventListener("test",Qa,Qa)}catch{kd=!1}var Bi=kd?{passive:!1}:!1,U_=function(e){return e.tagName==="TEXTAREA"},rk=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!U_(e)&&n[t]==="visible")},W_=function(e){return rk(e,"overflowY")},H_=function(e){return rk(e,"overflowX")},Uv=function(e,t){var n=t.ownerDocument,i=t;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var s=ik(e,i);if(s){var l=ok(e,i),a=l[1],c=l[2];if(a>c)return!0}i=i.parentNode}while(i&&i!==n.body);return!1},K_=function(e){var t=e.scrollTop,n=e.scrollHeight,i=e.clientHeight;return[t,n,i]},q_=function(e){var t=e.scrollLeft,n=e.scrollWidth,i=e.clientWidth;return[t,n,i]},ik=function(e,t){return e==="v"?W_(t):H_(t)},ok=function(e,t){return e==="v"?K_(t):q_(t)},X_=function(e,t){return e==="h"&&t==="rtl"?-1:1},Y_=function(e,t,n,i,s){var l=X_(e,window.getComputedStyle(t).direction),a=l*i,c=n.target,d=t.contains(c),h=!1,m=a>0,p=0,y=0;do{if(!c)break;var w=ok(e,c),S=w[0],C=w[1],E=w[2],T=C-E-l*S;(S||T)&&ik(e,c)&&(p+=T,y+=S);var M=c.parentNode;c=M&&M.nodeType===Node.DOCUMENT_FRAGMENT_NODE?M.host:M}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(m&&Math.abs(p)<1||!m&&Math.abs(y)<1)&&(h=!0),h},Za=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Wv=function(e){return[e.deltaX,e.deltaY]},Hv=function(e){return e&&"current"in e?e.current:e},G_=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Q_=function(e){return`
|
|
306
305
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
307
306
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
308
|
-
`)},tL=0,$i=[];function nL(e){var t=k.useRef([]),n=k.useRef([0,0]),i=k.useRef(),s=k.useState(tL++)[0],l=k.useState(nk)[0],a=k.useRef(e);k.useEffect(function(){a.current=e},[e]),k.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var C=b_([e.lockRef.current],(e.shards||[]).map(Hv),!0).filter(Boolean);return C.forEach(function(E){return E.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),C.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var c=k.useCallback(function(C,E){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!a.current.allowPinchZoom;var T=Za(C),M=n.current,P="deltaX"in C?C.deltaX:M[0]-T[0],D="deltaY"in C?C.deltaY:M[1]-T[1],$,j=C.target,Y=Math.abs(P)>Math.abs(D)?"h":"v";if("touches"in C&&Y==="h"&&j.type==="range")return!1;var U=window.getSelection(),O=U&&U.anchorNode,N=O?O===j||O.contains(j):!1;if(N)return!1;var X=Uv(Y,j);if(!X)return!0;if(X?$=Y:($=Y==="v"?"h":"v",X=Uv(Y,j)),!X)return!1;if(!i.current&&"changedTouches"in C&&(P||D)&&(i.current=$),!$)return!0;var V=i.current||$;return Z_(V,E,C,V==="h"?P:D)},[]),d=k.useCallback(function(C){var E=C;if(!(!$i.length||$i[$i.length-1]!==l)){var T="deltaY"in E?Wv(E):Za(E),M=t.current.filter(function($){return $.name===E.type&&($.target===E.target||E.target===$.shadowParent)&&J_($.delta,T)})[0];if(M&&M.should){E.cancelable&&E.preventDefault();return}if(!M){var P=(a.current.shards||[]).map(Hv).filter(Boolean).filter(function($){return $.contains(E.target)}),D=P.length>0?c(E,P[0]):!a.current.noIsolation;D&&E.cancelable&&E.preventDefault()}}},[]),h=k.useCallback(function(C,E,T,M){var P={name:C,delta:E,target:T,should:M,shadowParent:rL(T)};t.current.push(P),setTimeout(function(){t.current=t.current.filter(function(D){return D!==P})},1)},[]),m=k.useCallback(function(C){n.current=Za(C),i.current=void 0},[]),p=k.useCallback(function(C){h(C.type,Wv(C),C.target,c(C,e.lockRef.current))},[]),y=k.useCallback(function(C){h(C.type,Za(C),C.target,c(C,e.lockRef.current))},[]);k.useEffect(function(){return $i.push(l),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:y}),document.addEventListener("wheel",d,Bi),document.addEventListener("touchmove",d,Bi),document.addEventListener("touchstart",m,Bi),function(){$i=$i.filter(function(C){return C!==l}),document.removeEventListener("wheel",d,Bi),document.removeEventListener("touchmove",d,Bi),document.removeEventListener("touchstart",m,Bi)}},[]);var w=e.removeScrollBar,S=e.inert;return k.createElement(k.Fragment,null,S?k.createElement(l,{styles:eL(s)}):null,w?k.createElement(H_,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function rL(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const iL=I_(tk,nL);var sk=k.forwardRef(function(e,t){return k.createElement(Xl,Hn({},e,{ref:t,sideCar:iL}))});sk.classNames=Xl.classNames;var oL=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ui=new WeakMap,Ja=new WeakMap,el={},hf=0,ak=function(e){return e&&(e.host||ak(e.parentNode))},sL=function(e,t){return t.map(function(n){if(e.contains(n))return n;var i=ak(n);return i&&e.contains(i)?i:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},aL=function(e,t,n,i){var s=sL(t,Array.isArray(e)?e:[e]);el[n]||(el[n]=new WeakMap);var l=el[n],a=[],c=new Set,d=new Set(s),h=function(p){!p||c.has(p)||(c.add(p),h(p.parentNode))};s.forEach(h);var m=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(y){if(c.has(y))m(y);else try{var w=y.getAttribute(i),S=w!==null&&w!=="false",C=(Ui.get(y)||0)+1,E=(l.get(y)||0)+1;Ui.set(y,C),l.set(y,E),a.push(y),C===1&&S&&Ja.set(y,!0),E===1&&y.setAttribute(n,"true"),S||y.setAttribute(i,"true")}catch(T){console.error("aria-hidden: cannot operate on ",y,T)}})};return m(t),c.clear(),hf++,function(){a.forEach(function(p){var y=Ui.get(p)-1,w=l.get(p)-1;Ui.set(p,y),l.set(p,w),y||(Ja.has(p)||p.removeAttribute(i),Ja.delete(p)),w||p.removeAttribute(n)}),hf--,hf||(Ui=new WeakMap,Ui=new WeakMap,Ja=new WeakMap,el={})}},lL=function(e,t,n){n===void 0&&(n="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),s=oL(e);return s?(i.push.apply(i,Array.from(s.querySelectorAll("[aria-live], script"))),aL(i,s,n,"aria-hidden")):function(){return null}},uL=Object.defineProperty,Sn=(e,t)=>uL(e,"name",{value:t,configurable:!0}),Ih="Dialog",[lk,zz]=T1(Ih),[cL,Yn]=lk(Ih),uk=Sn(e=>{const{__scopeDialog:t,children:n,open:i,defaultOpen:s,onOpenChange:l,modal:a=!0}=e,c=k.useRef(null),d=k.useRef(null),[h,m]=M1({prop:i,defaultProp:s??!1,onChange:l,caller:Ih}),[p,y]=k.useState(0),[w,S]=k.useState(0);return v.jsx(cL,{scope:t,triggerRef:c,contentRef:d,contentId:pl(),titleId:pl(),descriptionId:pl(),titlePresent:p>0,descriptionPresent:w>0,setTitleCount:y,setDescriptionCount:S,open:h,onOpenChange:m,onOpenToggle:k.useCallback(()=>m(C=>!C),[m]),modal:a,children:n})},"Dialog"),ck="DialogPortal",[fL,fk]=lk(ck,{forceMount:void 0}),dk=Sn(e=>{const{__scopeDialog:t,forceMount:n,children:i,container:s}=e,l=Yn(ck,t);return v.jsx(fL,{scope:t,forceMount:n,children:k.Children.map(i,a=>v.jsx(Mh,{present:n||l.open,children:v.jsx(x_,{asChild:!0,container:s,children:a})}))})},"DialogPortal"),Sd="DialogOverlay",hk=k.forwardRef(Sn(function(t,n){const i=fk(Sd,t.__scopeDialog),{forceMount:s=i.forceMount,...l}=t,a=Yn(Sd,t.__scopeDialog);return a.modal?v.jsx(Mh,{present:s||a.open,children:v.jsx(hL,{...l,ref:n})}):null},"DialogOverlay")),dL=Th("DialogOverlay.RemoveScroll"),hL=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,...s}=t,l=Yn(Sd,i),a=V1(),c=lo(n,a);return v.jsx(sk,{as:dL,allowPinchZoom:!0,shards:[l.contentRef],children:v.jsx(mi.div,{"data-state":jh(l.open),...s,ref:c,style:{pointerEvents:"auto",...s.style}})})},"DialogOverlayImpl")),ws="DialogContent",pk=k.forwardRef(Sn(function(t,n){const i=fk(ws,t.__scopeDialog),{forceMount:s=i.forceMount,...l}=t,a=Yn(ws,t.__scopeDialog);return v.jsx(Mh,{present:s||a.open,children:a.modal?v.jsx(pL,{...l,ref:n}):v.jsx(mL,{...l,ref:n})})},"DialogContent")),pL=k.forwardRef(Sn(function(t,n){const i=Yn(ws,t.__scopeDialog),s=k.useRef(null),l=lo(n,i.contentRef,s);return k.useEffect(()=>{const a=s.current;if(a)return lL(a)},[]),v.jsx(mk,{...t,ref:l,trapFocus:i.open,disableOutsidePointerEvents:i.open,onCloseAutoFocus:_r(t.onCloseAutoFocus,a=>{a.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:_r(t.onPointerDownOutside,a=>{const c=a.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0;(c.button===2||d)&&a.preventDefault()}),onFocusOutside:_r(t.onFocusOutside,a=>a.preventDefault())})},"DialogContentModal")),mL=k.forwardRef(Sn(function(t,n){const i=Yn(ws,t.__scopeDialog),s=k.useRef(!1),l=k.useRef(!1);return v.jsx(mk,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{t.onCloseAutoFocus?.(a),a.defaultPrevented||(s.current||i.triggerRef.current?.focus(),a.preventDefault()),s.current=!1,l.current=!1},onInteractOutside:a=>{t.onInteractOutside?.(a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const c=a.target;i.triggerRef.current?.contains(c)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&l.current&&a.preventDefault()}})},"DialogContentNonModal")),mk=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,trapFocus:s,onOpenAutoFocus:l,onCloseAutoFocus:a,...c}=t,d=Yn(ws,i);return Nh(),v.jsx(v.Fragment,{children:v.jsx(g_,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:l,onUnmountAutoFocus:a,children:v.jsx(h_,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionPresent?d.descriptionId:void 0,"aria-labelledby":d.titlePresent?d.titleId:void 0,"data-state":jh(d.open),...c,ref:n,deferPointerDownOutside:!0,onDismiss:()=>d.onOpenChange(!1)})})})},"DialogContentImpl")),gL="DialogTitle",gk=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,...s}=t,l=Yn(gL,i),{setTitleCount:a}=l;return zr(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),v.jsx(mi.h2,{id:l.titleId,...s,ref:n})},"DialogTitle")),yL="DialogDescription",yk=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,...s}=t,l=Yn(yL,i),{setDescriptionCount:a}=l;return zr(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),v.jsx(mi.p,{id:l.descriptionId,...s,ref:n})},"DialogDescription")),vL="DialogClose",vk=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,...s}=t,l=Yn(vL,i);return v.jsx(mi.button,{type:"button",...s,ref:n,onClick:_r(t.onClick,()=>l.onOpenChange(!1))})},"DialogClose"));function jh(e){return e?"open":"closed"}Sn(jh,"getState");function xL(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const wL=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kL=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,SL={};function Kv(e,t){return(SL.jsx?kL:wL).test(e)}const bL=/[ \t\n\f\r]/g;function CL(e){return typeof e=="object"?e.type==="text"?qv(e.value):!1:qv(e)}function qv(e){return e.replace(bL,"")===""}class Is{constructor(t,n,i){this.normal=n,this.property=t,i&&(this.space=i)}}Is.prototype.normal={};Is.prototype.property={};Is.prototype.space=void 0;function xk(e,t){const n={},i={};for(const s of e)Object.assign(n,s.property),Object.assign(i,s.normal);return new Is(n,i,t)}function bd(e){return e.toLowerCase()}class tn{constructor(t,n){this.attribute=n,this.property=t}}tn.prototype.attribute="";tn.prototype.booleanish=!1;tn.prototype.boolean=!1;tn.prototype.commaOrSpaceSeparated=!1;tn.prototype.commaSeparated=!1;tn.prototype.defined=!1;tn.prototype.mustUseProperty=!1;tn.prototype.number=!1;tn.prototype.overloadedBoolean=!1;tn.prototype.property="";tn.prototype.spaceSeparated=!1;tn.prototype.space=void 0;let EL=0;const Le=gi(),yt=gi(),Cd=gi(),ae=gi(),Qe=gi(),hi=gi(),ln=gi();function gi(){return 2**++EL}const Ed=Object.freeze(Object.defineProperty({__proto__:null,boolean:Le,booleanish:yt,commaOrSpaceSeparated:ln,commaSeparated:hi,number:ae,overloadedBoolean:Cd,spaceSeparated:Qe},Symbol.toStringTag,{value:"Module"})),pf=Object.keys(Ed);class Dh extends tn{constructor(t,n,i,s){let l=-1;if(super(t,n),Xv(this,"space",s),typeof i=="number")for(;++l<pf.length;){const a=pf[l];Xv(this,pf[l],(i&Ed[a])===Ed[a])}}}Dh.prototype.defined=!0;function Xv(e,t,n){n&&(e[t]=n)}function uo(e){const t={},n={};for(const[i,s]of Object.entries(e.properties)){const l=new Dh(i,e.transform(e.attributes||{},i),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(l.mustUseProperty=!0),t[i]=l,n[bd(i)]=i,n[bd(l.attribute)]=i}return new Is(t,n,e.space)}const wk=uo({properties:{ariaActiveDescendant:null,ariaAtomic:yt,ariaAutoComplete:null,ariaBusy:yt,ariaChecked:yt,ariaColCount:ae,ariaColIndex:ae,ariaColSpan:ae,ariaControls:Qe,ariaCurrent:null,ariaDescribedBy:Qe,ariaDetails:null,ariaDisabled:yt,ariaDropEffect:Qe,ariaErrorMessage:null,ariaExpanded:yt,ariaFlowTo:Qe,ariaGrabbed:yt,ariaHasPopup:null,ariaHidden:yt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qe,ariaLevel:ae,ariaLive:null,ariaModal:yt,ariaMultiLine:yt,ariaMultiSelectable:yt,ariaOrientation:null,ariaOwns:Qe,ariaPlaceholder:null,ariaPosInSet:ae,ariaPressed:yt,ariaReadOnly:yt,ariaRelevant:null,ariaRequired:yt,ariaRoleDescription:Qe,ariaRowCount:ae,ariaRowIndex:ae,ariaRowSpan:ae,ariaSelected:yt,ariaSetSize:ae,ariaSort:null,ariaValueMax:ae,ariaValueMin:ae,ariaValueNow:ae,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function kk(e,t){return t in e?e[t]:t}function Sk(e,t){return kk(e,t.toLowerCase())}const TL=uo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:hi,acceptCharset:Qe,accessKey:Qe,action:null,allow:null,allowFullScreen:Le,allowPaymentRequest:Le,allowUserMedia:Le,alpha:Le,alt:null,as:null,async:Le,autoCapitalize:null,autoComplete:Qe,autoFocus:Le,autoPlay:Le,blocking:Qe,capture:null,charSet:null,checked:Le,cite:null,className:Qe,closedBy:null,colorSpace:null,cols:ae,colSpan:ae,command:null,commandFor:null,content:null,contentEditable:yt,controls:Le,controlsList:Qe,coords:ae|hi,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Le,defer:Le,dir:null,dirName:null,disabled:Le,download:Cd,draggable:yt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Le,formTarget:null,headers:Qe,height:ae,hidden:Cd,high:ae,href:null,hrefLang:null,htmlFor:Qe,httpEquiv:Qe,id:null,imageSizes:null,imageSrcSet:null,inert:Le,inputMode:null,integrity:null,is:null,isMap:Le,itemId:null,itemProp:Qe,itemRef:Qe,itemScope:Le,itemType:Qe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Le,low:ae,manifest:null,max:null,maxLength:ae,media:null,method:null,min:null,minLength:ae,multiple:Le,muted:Le,name:null,nonce:null,noModule:Le,noValidate:Le,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Le,optimum:ae,pattern:null,ping:Qe,placeholder:null,playsInline:Le,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Le,referrerPolicy:null,rel:Qe,required:Le,reversed:Le,rows:ae,rowSpan:ae,sandbox:Qe,scope:null,scoped:Le,seamless:Le,selected:Le,shadowRootClonable:Le,shadowRootCustomElementRegistry:Le,shadowRootDelegatesFocus:Le,shadowRootMode:null,shadowRootSerializable:Le,shape:null,size:ae,sizes:null,slot:null,span:ae,spellCheck:yt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ae,step:null,style:null,tabIndex:ae,target:null,title:null,translate:null,type:null,typeMustMatch:Le,useMap:null,value:yt,width:ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qe,axis:null,background:null,bgColor:null,border:ae,borderColor:null,bottomMargin:ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Le,declare:Le,event:null,face:null,frame:null,frameBorder:null,hSpace:ae,leftMargin:ae,link:null,longDesc:null,lowSrc:null,marginHeight:ae,marginWidth:ae,noResize:Le,noHref:Le,noShade:Le,noWrap:Le,object:null,profile:null,prompt:null,rev:null,rightMargin:ae,rules:null,scheme:null,scrolling:yt,standby:null,summary:null,text:null,topMargin:ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ae,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Le,disablePictureInPicture:Le,disableRemotePlayback:Le,exportParts:hi,part:Qe,prefix:null,property:null,results:ae,security:null,unselectable:null},space:"html",transform:Sk}),PL=uo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ln,accentHeight:ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ae,amplitude:ae,arabicForm:null,ascent:ae,attributeName:null,attributeType:null,azimuth:ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ae,by:null,calcMode:null,capHeight:ae,className:Qe,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ae,diffuseConstant:ae,direction:null,display:null,dur:null,divisor:ae,dominantBaseline:null,download:Le,dx:null,dy:null,edgeMode:null,editable:null,elevation:ae,enableBackground:null,end:null,event:null,exponent:ae,externalResourcesRequired:null,fill:null,fillOpacity:ae,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:hi,g2:hi,glyphName:hi,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ae,horizOriginX:ae,horizOriginY:ae,id:null,ideographic:ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ae,k:ae,k1:ae,k2:ae,k3:ae,k4:ae,kernelMatrix:ln,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ae,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ae,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ae,overlineThickness:ae,paintOrder:null,panose1:null,path:null,pathLength:ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ae,pointsAtY:ae,pointsAtZ:ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ln,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ln,rev:ln,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ln,requiredFeatures:ln,requiredFonts:ln,requiredFormats:ln,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ae,specularExponent:ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ae,strikethroughThickness:ae,string:null,stroke:null,strokeDashArray:ln,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ae,strokeOpacity:ae,strokeWidth:null,style:null,surfaceScale:ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ln,tabIndex:ae,tableValues:null,target:null,targetX:ae,targetY:ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ln,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ae,underlineThickness:ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ae,values:null,vAlphabetic:ae,vMathematical:ae,vectorEffect:null,vHanging:ae,vIdeographic:ae,version:null,vertAdvY:ae,vertOriginX:ae,vertOriginY:ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:kk}),bk=uo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Ck=uo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Sk}),Ek=uo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),RL={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},ML=/[A-Z]/g,Yv=/-[a-z]/g,AL=/^data[-\w.:]+$/i;function NL(e,t){const n=bd(t);let i=t,s=tn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&AL.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(Yv,jL);i="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!Yv.test(l)){let a=l.replace(ML,IL);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Dh}return new s(i,t)}function IL(e){return"-"+e.toLowerCase()}function jL(e){return e.charAt(1).toUpperCase()}const DL=xk([wk,TL,bk,Ck,Ek],"html"),_h=xk([wk,PL,bk,Ck,Ek],"svg");function _L(e){return e.join(" ").trim()}var Wi={},mf,Gv;function LL(){if(Gv)return mf;Gv=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
|
|
309
|
-
`,h="/",m="*",p="",y="comment",w="declaration";function S(E,T){if(typeof E!="string")throw new TypeError("First argument must be a string");if(!E)return[];T=T||{};var M=1,P=1;function D(J){var ee=J.match(t);ee&&(M+=ee.length);var xe=J.lastIndexOf(d);P=~xe?J.length-xe:P+J.length}function $(){var J={line:M,column:P};return function(ee){return ee.position=new j(J),O(),ee}}function j(J){this.start=J,this.end={line:M,column:P},this.source=T.source}j.prototype.content=E;function Y(J){var ee=new Error(T.source+":"+M+":"+P+": "+J);if(ee.reason=J,ee.filename=T.source,ee.line=M,ee.column=P,ee.source=E,!T.silent)throw ee}function U(J){var ee=J.exec(E);if(ee){var xe=ee[0];return D(xe),E=E.slice(xe.length),ee}}function O(){U(n)}function N(J){var ee;for(J=J||[];ee=X();)ee!==!1&&J.push(ee);return J}function X(){var J=$();if(!(h!=E.charAt(0)||m!=E.charAt(1))){for(var ee=2;p!=E.charAt(ee)&&(m!=E.charAt(ee)||h!=E.charAt(ee+1));)++ee;if(ee+=2,p===E.charAt(ee-1))return Y("End of comment missing");var xe=E.slice(2,ee-2);return P+=2,D(xe),E=E.slice(ee),P+=2,J({type:y,comment:xe})}}function V(){var J=$(),ee=U(i);if(ee){if(X(),!U(s))return Y("property missing ':'");var xe=U(l),Pe=J({type:w,property:C(ee[0].replace(e,p)),value:xe?C(xe[0].replace(e,p)):p});return U(a),Pe}}function fe(){var J=[];N(J);for(var ee;ee=V();)ee!==!1&&(J.push(ee),N(J));return J}return O(),fe()}function C(E){return E?E.replace(c,p):p}return mf=S,mf}var Qv;function OL(){if(Qv)return Wi;Qv=1;var e=Wi&&Wi.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.default=n;const t=e(LL());function n(i,s){let l=null;if(!i||typeof i!="string")return l;const a=(0,t.default)(i),c=typeof s=="function";return a.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:m}=d;c?s(h,m,d):m&&(l=l||{},l[h]=m)}),l}return Wi}var Qo={},Zv;function FL(){if(Zv)return Qo;Zv=1,Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,l=function(h){return!h||n.test(h)||e.test(h)},a=function(h,m){return m.toUpperCase()},c=function(h,m){return"".concat(m,"-")},d=function(h,m){return m===void 0&&(m={}),l(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(s,c):h=h.replace(i,c),h.replace(t,a))};return Qo.camelCase=d,Qo}var Zo,Jv;function zL(){if(Jv)return Zo;Jv=1;var e=Zo&&Zo.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},t=e(OL()),n=FL();function i(s,l){var a={};return!s||typeof s!="string"||(0,t.default)(s,function(c,d){c&&d&&(a[(0,n.camelCase)(c,l)]=d)}),a}return i.default=i,Zo=i,Zo}var VL=zL();const BL=Id(VL),Tk=Pk("end"),Lh=Pk("start");function Pk(e){return t;function t(n){const i=n&&n.position&&n.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function $L(e){const t=Lh(e),n=Tk(e);if(t&&n)return{start:t,end:n}}class zt extends Error{constructor(t,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let s="",l={},a=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?s=t:!l.cause&&t&&(a=!0,s=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof i=="string"){const d=i.indexOf(":");d===-1?l.ruleId=i:(l.source=i.slice(0,d),l.ruleId=i.slice(d+1))}if(!l.place&&l.ancestors&&l.ancestors){const d=l.ancestors[l.ancestors.length-1];d&&(l.place=d.position)}const c=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=c?c.line:void 0,this.name=ls(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=a&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}zt.prototype.file="";zt.prototype.name="";zt.prototype.reason="";zt.prototype.message="";zt.prototype.stack="";zt.prototype.column=void 0;zt.prototype.line=void 0;zt.prototype.ancestors=void 0;zt.prototype.cause=void 0;zt.prototype.fatal=void 0;zt.prototype.place=void 0;zt.prototype.ruleId=void 0;zt.prototype.source=void 0;const Oh={}.hasOwnProperty,UL=new Map,WL=/[A-Z]/g,HL=new Set(["table","tbody","thead","tfoot","tr"]),KL=new Set(["td","th"]),Rk="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function qL(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let i;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=tO(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=eO(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:i,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?_h:DL,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=Mk(s,e,void 0);return l&&typeof l!="string"?l:s.create(e,s.Fragment,{children:l||void 0},void 0)}function Mk(e,t,n){if(t.type==="element")return XL(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return YL(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return QL(e,t,n);if(t.type==="mdxjsEsm")return GL(e,t);if(t.type==="root")return ZL(e,t,n);if(t.type==="text")return JL(e,t)}function XL(e,t,n){const i=e.schema;let s=i;t.tagName.toLowerCase()==="svg"&&i.space==="html"&&(s=_h,e.schema=s),e.ancestors.push(t);const l=Nk(e,t.tagName,!1),a=nO(e,t);let c=zh(e,t);return HL.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!CL(d):!0})),Ak(e,a,l,t),Fh(a,c),e.ancestors.pop(),e.schema=i,e.create(t,l,a,n)}function YL(e,t){if(t.data&&t.data.estree&&e.evaluater){const i=t.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}ks(e,t.position)}function GL(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ks(e,t.position)}function QL(e,t,n){const i=e.schema;let s=i;t.name==="svg"&&i.space==="html"&&(s=_h,e.schema=s),e.ancestors.push(t);const l=t.name===null?e.Fragment:Nk(e,t.name,!0),a=rO(e,t),c=zh(e,t);return Ak(e,a,l,t),Fh(a,c),e.ancestors.pop(),e.schema=i,e.create(t,l,a,n)}function ZL(e,t,n){const i={};return Fh(i,zh(e,t)),e.create(t,e.Fragment,i,n)}function JL(e,t){return t.value}function Ak(e,t,n,i){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=i)}function Fh(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function eO(e,t,n){return i;function i(s,l,a,c){const h=Array.isArray(a.children)?n:t;return c?h(l,a,c):h(l,a)}}function tO(e,t){return n;function n(i,s,l,a){const c=Array.isArray(l.children),d=Lh(i);return t(s,l,a,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function nO(e,t){const n={};let i,s;for(s in t.properties)if(s!=="children"&&Oh.call(t.properties,s)){const l=iO(e,s,t.properties[s]);if(l){const[a,c]=l;e.tableCellAlignToStyle&&a==="align"&&typeof c=="string"&&KL.has(t.tagName)?i=c:n[a]=c}}if(i){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return n}function rO(e,t){const n={};for(const i of t.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const l=i.data.estree.body[0];l.type;const a=l.expression;a.type;const c=a.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else ks(e,t.position);else{const s=i.name;let l;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const c=i.value.data.estree.body[0];c.type,l=e.evaluater.evaluateExpression(c.expression)}else ks(e,t.position);else l=i.value===null?!0:i.value;n[s]=l}return n}function zh(e,t){const n=[];let i=-1;const s=e.passKeys?new Map:UL;for(;++i<t.children.length;){const l=t.children[i];let a;if(e.passKeys){const d=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(d){const h=s.get(d)||0;a=d+"-"+h,s.set(d,h+1)}}const c=Mk(e,l,a);c!==void 0&&n.push(c)}return n}function iO(e,t,n){const i=NL(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=i.commaSeparated?xL(n):_L(n)),i.property==="style"){let s=typeof n=="object"?n:oO(e,String(n));return e.stylePropertyNameCase==="css"&&(s=sO(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&i.space?RL[i.property]||i.property:i.attribute,n]}}function oO(e,t){try{return BL(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const i=n,s=new zt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=Rk+"#cannot-parse-style-attribute",s}}function Nk(e,t,n){let i;if(!n)i={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let l=-1,a;for(;++l<s.length;){const c=Kv(s[l])?{type:"Identifier",name:s[l]}:{type:"Literal",value:s[l]};a=a?{type:"MemberExpression",object:a,property:c,computed:!!(l&&c.type==="Literal"),optional:!1}:c}i=a}else i=Kv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(i.type==="Literal"){const s=i.value;return Oh.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(i);ks(e)}function ks(e,t){const n=new zt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Rk+"#cannot-handle-mdx-estrees-without-createevaluater",n}function sO(e){const t={};let n;for(n in e)Oh.call(e,n)&&(t[aO(n)]=e[n]);return t}function aO(e){let t=e.replace(WL,lO);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function lO(e){return"-"+e.toLowerCase()}const gf={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};function uO(e){const t=this;t.parser=n;function n(i){return t1(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function cO(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function fO(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
310
|
-
`}]}function
|
|
311
|
-
`:"",i={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(i.className=["language-"+s[0]]);let l={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return t.meta&&(l.data={meta:t.meta}),e.patch(t,l),l=e.applyData(t,l),l={type:"element",tagName:"pre",properties:{},children:[l]},e.patch(t,l),l}function
|
|
307
|
+
`)},Z_=0,$i=[];function J_(e){var t=k.useRef([]),n=k.useRef([0,0]),i=k.useRef(),s=k.useState(Z_++)[0],l=k.useState(nk)[0],a=k.useRef(e);k.useEffect(function(){a.current=e},[e]),k.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var C=w_([e.lockRef.current],(e.shards||[]).map(Hv),!0).filter(Boolean);return C.forEach(function(E){return E.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),C.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var c=k.useCallback(function(C,E){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!a.current.allowPinchZoom;var T=Za(C),M=n.current,P="deltaX"in C?C.deltaX:M[0]-T[0],D="deltaY"in C?C.deltaY:M[1]-T[1],$,j=C.target,Y=Math.abs(P)>Math.abs(D)?"h":"v";if("touches"in C&&Y==="h"&&j.type==="range")return!1;var U=window.getSelection(),O=U&&U.anchorNode,N=O?O===j||O.contains(j):!1;if(N)return!1;var X=Uv(Y,j);if(!X)return!0;if(X?$=Y:($=Y==="v"?"h":"v",X=Uv(Y,j)),!X)return!1;if(!i.current&&"changedTouches"in C&&(P||D)&&(i.current=$),!$)return!0;var V=i.current||$;return Y_(V,E,C,V==="h"?P:D)},[]),d=k.useCallback(function(C){var E=C;if(!(!$i.length||$i[$i.length-1]!==l)){var T="deltaY"in E?Wv(E):Za(E),M=t.current.filter(function($){return $.name===E.type&&($.target===E.target||E.target===$.shadowParent)&&G_($.delta,T)})[0];if(M&&M.should){E.cancelable&&E.preventDefault();return}if(!M){var P=(a.current.shards||[]).map(Hv).filter(Boolean).filter(function($){return $.contains(E.target)}),D=P.length>0?c(E,P[0]):!a.current.noIsolation;D&&E.cancelable&&E.preventDefault()}}},[]),h=k.useCallback(function(C,E,T,M){var P={name:C,delta:E,target:T,should:M,shadowParent:eL(T)};t.current.push(P),setTimeout(function(){t.current=t.current.filter(function(D){return D!==P})},1)},[]),m=k.useCallback(function(C){n.current=Za(C),i.current=void 0},[]),p=k.useCallback(function(C){h(C.type,Wv(C),C.target,c(C,e.lockRef.current))},[]),y=k.useCallback(function(C){h(C.type,Za(C),C.target,c(C,e.lockRef.current))},[]);k.useEffect(function(){return $i.push(l),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:y}),document.addEventListener("wheel",d,Bi),document.addEventListener("touchmove",d,Bi),document.addEventListener("touchstart",m,Bi),function(){$i=$i.filter(function(C){return C!==l}),document.removeEventListener("wheel",d,Bi),document.removeEventListener("touchmove",d,Bi),document.removeEventListener("touchstart",m,Bi)}},[]);var w=e.removeScrollBar,S=e.inert;return k.createElement(k.Fragment,null,S?k.createElement(l,{styles:Q_(s)}):null,w?k.createElement($_,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function eL(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const tL=M_(tk,J_);var sk=k.forwardRef(function(e,t){return k.createElement(Xl,Hn({},e,{ref:t,sideCar:tL}))});sk.classNames=Xl.classNames;var nL=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ui=new WeakMap,Ja=new WeakMap,el={},hf=0,ak=function(e){return e&&(e.host||ak(e.parentNode))},rL=function(e,t){return t.map(function(n){if(e.contains(n))return n;var i=ak(n);return i&&e.contains(i)?i:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},iL=function(e,t,n,i){var s=rL(t,Array.isArray(e)?e:[e]);el[n]||(el[n]=new WeakMap);var l=el[n],a=[],c=new Set,d=new Set(s),h=function(p){!p||c.has(p)||(c.add(p),h(p.parentNode))};s.forEach(h);var m=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(y){if(c.has(y))m(y);else try{var w=y.getAttribute(i),S=w!==null&&w!=="false",C=(Ui.get(y)||0)+1,E=(l.get(y)||0)+1;Ui.set(y,C),l.set(y,E),a.push(y),C===1&&S&&Ja.set(y,!0),E===1&&y.setAttribute(n,"true"),S||y.setAttribute(i,"true")}catch(T){console.error("aria-hidden: cannot operate on ",y,T)}})};return m(t),c.clear(),hf++,function(){a.forEach(function(p){var y=Ui.get(p)-1,w=l.get(p)-1;Ui.set(p,y),l.set(p,w),y||(Ja.has(p)||p.removeAttribute(i),Ja.delete(p)),w||p.removeAttribute(n)}),hf--,hf||(Ui=new WeakMap,Ui=new WeakMap,Ja=new WeakMap,el={})}},oL=function(e,t,n){n===void 0&&(n="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),s=nL(e);return s?(i.push.apply(i,Array.from(s.querySelectorAll("[aria-live], script"))),iL(i,s,n,"aria-hidden")):function(){return null}},sL=Object.defineProperty,Sn=(e,t)=>sL(e,"name",{value:t,configurable:!0}),Ih="Dialog",[lk,Lz]=T1(Ih),[aL,Yn]=lk(Ih),uk=Sn(e=>{const{__scopeDialog:t,children:n,open:i,defaultOpen:s,onOpenChange:l,modal:a=!0}=e,c=k.useRef(null),d=k.useRef(null),[h,m]=M1({prop:i,defaultProp:s??!1,onChange:l,caller:Ih}),[p,y]=k.useState(0),[w,S]=k.useState(0);return v.jsx(aL,{scope:t,triggerRef:c,contentRef:d,contentId:pl(),titleId:pl(),descriptionId:pl(),titlePresent:p>0,descriptionPresent:w>0,setTitleCount:y,setDescriptionCount:S,open:h,onOpenChange:m,onOpenToggle:k.useCallback(()=>m(C=>!C),[m]),modal:a,children:n})},"Dialog"),ck="DialogPortal",[lL,fk]=lk(ck,{forceMount:void 0}),dk=Sn(e=>{const{__scopeDialog:t,forceMount:n,children:i,container:s}=e,l=Yn(ck,t);return v.jsx(lL,{scope:t,forceMount:n,children:k.Children.map(i,a=>v.jsx(Mh,{present:n||l.open,children:v.jsx(g_,{asChild:!0,container:s,children:a})}))})},"DialogPortal"),Sd="DialogOverlay",hk=k.forwardRef(Sn(function(t,n){const i=fk(Sd,t.__scopeDialog),{forceMount:s=i.forceMount,...l}=t,a=Yn(Sd,t.__scopeDialog);return a.modal?v.jsx(Mh,{present:s||a.open,children:v.jsx(cL,{...l,ref:n})}):null},"DialogOverlay")),uL=Th("DialogOverlay.RemoveScroll"),cL=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,...s}=t,l=Yn(Sd,i),a=V1(),c=lo(n,a);return v.jsx(sk,{as:uL,allowPinchZoom:!0,shards:[l.contentRef],children:v.jsx(mi.div,{"data-state":jh(l.open),...s,ref:c,style:{pointerEvents:"auto",...s.style}})})},"DialogOverlayImpl")),ws="DialogContent",pk=k.forwardRef(Sn(function(t,n){const i=fk(ws,t.__scopeDialog),{forceMount:s=i.forceMount,...l}=t,a=Yn(ws,t.__scopeDialog);return v.jsx(Mh,{present:s||a.open,children:a.modal?v.jsx(fL,{...l,ref:n}):v.jsx(dL,{...l,ref:n})})},"DialogContent")),fL=k.forwardRef(Sn(function(t,n){const i=Yn(ws,t.__scopeDialog),s=k.useRef(null),l=lo(n,i.contentRef,s);return k.useEffect(()=>{const a=s.current;if(a)return oL(a)},[]),v.jsx(mk,{...t,ref:l,trapFocus:i.open,disableOutsidePointerEvents:i.open,onCloseAutoFocus:_r(t.onCloseAutoFocus,a=>{a.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:_r(t.onPointerDownOutside,a=>{const c=a.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0;(c.button===2||d)&&a.preventDefault()}),onFocusOutside:_r(t.onFocusOutside,a=>a.preventDefault())})},"DialogContentModal")),dL=k.forwardRef(Sn(function(t,n){const i=Yn(ws,t.__scopeDialog),s=k.useRef(!1),l=k.useRef(!1);return v.jsx(mk,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{t.onCloseAutoFocus?.(a),a.defaultPrevented||(s.current||i.triggerRef.current?.focus(),a.preventDefault()),s.current=!1,l.current=!1},onInteractOutside:a=>{t.onInteractOutside?.(a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const c=a.target;i.triggerRef.current?.contains(c)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&l.current&&a.preventDefault()}})},"DialogContentNonModal")),mk=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,trapFocus:s,onOpenAutoFocus:l,onCloseAutoFocus:a,...c}=t,d=Yn(ws,i);return Nh(),v.jsx(v.Fragment,{children:v.jsx(h_,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:l,onUnmountAutoFocus:a,children:v.jsx(c_,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionPresent?d.descriptionId:void 0,"aria-labelledby":d.titlePresent?d.titleId:void 0,"data-state":jh(d.open),...c,ref:n,deferPointerDownOutside:!0,onDismiss:()=>d.onOpenChange(!1)})})})},"DialogContentImpl")),hL="DialogTitle",gk=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,...s}=t,l=Yn(hL,i),{setTitleCount:a}=l;return zr(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),v.jsx(mi.h2,{id:l.titleId,...s,ref:n})},"DialogTitle")),pL="DialogDescription",yk=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,...s}=t,l=Yn(pL,i),{setDescriptionCount:a}=l;return zr(()=>(a(c=>c+1),()=>a(c=>c-1)),[a]),v.jsx(mi.p,{id:l.descriptionId,...s,ref:n})},"DialogDescription")),mL="DialogClose",vk=k.forwardRef(Sn(function(t,n){const{__scopeDialog:i,...s}=t,l=Yn(mL,i);return v.jsx(mi.button,{type:"button",...s,ref:n,onClick:_r(t.onClick,()=>l.onOpenChange(!1))})},"DialogClose"));function jh(e){return e?"open":"closed"}Sn(jh,"getState");function gL(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const yL=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vL=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xL={};function Kv(e,t){return(xL.jsx?vL:yL).test(e)}const wL=/[ \t\n\f\r]/g;function kL(e){return typeof e=="object"?e.type==="text"?qv(e.value):!1:qv(e)}function qv(e){return e.replace(wL,"")===""}class Is{constructor(t,n,i){this.normal=n,this.property=t,i&&(this.space=i)}}Is.prototype.normal={};Is.prototype.property={};Is.prototype.space=void 0;function xk(e,t){const n={},i={};for(const s of e)Object.assign(n,s.property),Object.assign(i,s.normal);return new Is(n,i,t)}function bd(e){return e.toLowerCase()}class tn{constructor(t,n){this.attribute=n,this.property=t}}tn.prototype.attribute="";tn.prototype.booleanish=!1;tn.prototype.boolean=!1;tn.prototype.commaOrSpaceSeparated=!1;tn.prototype.commaSeparated=!1;tn.prototype.defined=!1;tn.prototype.mustUseProperty=!1;tn.prototype.number=!1;tn.prototype.overloadedBoolean=!1;tn.prototype.property="";tn.prototype.spaceSeparated=!1;tn.prototype.space=void 0;let SL=0;const Le=gi(),yt=gi(),Cd=gi(),ae=gi(),Qe=gi(),hi=gi(),ln=gi();function gi(){return 2**++SL}const Ed=Object.freeze(Object.defineProperty({__proto__:null,boolean:Le,booleanish:yt,commaOrSpaceSeparated:ln,commaSeparated:hi,number:ae,overloadedBoolean:Cd,spaceSeparated:Qe},Symbol.toStringTag,{value:"Module"})),pf=Object.keys(Ed);class Dh extends tn{constructor(t,n,i,s){let l=-1;if(super(t,n),Xv(this,"space",s),typeof i=="number")for(;++l<pf.length;){const a=pf[l];Xv(this,pf[l],(i&Ed[a])===Ed[a])}}}Dh.prototype.defined=!0;function Xv(e,t,n){n&&(e[t]=n)}function uo(e){const t={},n={};for(const[i,s]of Object.entries(e.properties)){const l=new Dh(i,e.transform(e.attributes||{},i),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(l.mustUseProperty=!0),t[i]=l,n[bd(i)]=i,n[bd(l.attribute)]=i}return new Is(t,n,e.space)}const wk=uo({properties:{ariaActiveDescendant:null,ariaAtomic:yt,ariaAutoComplete:null,ariaBusy:yt,ariaChecked:yt,ariaColCount:ae,ariaColIndex:ae,ariaColSpan:ae,ariaControls:Qe,ariaCurrent:null,ariaDescribedBy:Qe,ariaDetails:null,ariaDisabled:yt,ariaDropEffect:Qe,ariaErrorMessage:null,ariaExpanded:yt,ariaFlowTo:Qe,ariaGrabbed:yt,ariaHasPopup:null,ariaHidden:yt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qe,ariaLevel:ae,ariaLive:null,ariaModal:yt,ariaMultiLine:yt,ariaMultiSelectable:yt,ariaOrientation:null,ariaOwns:Qe,ariaPlaceholder:null,ariaPosInSet:ae,ariaPressed:yt,ariaReadOnly:yt,ariaRelevant:null,ariaRequired:yt,ariaRoleDescription:Qe,ariaRowCount:ae,ariaRowIndex:ae,ariaRowSpan:ae,ariaSelected:yt,ariaSetSize:ae,ariaSort:null,ariaValueMax:ae,ariaValueMin:ae,ariaValueNow:ae,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function kk(e,t){return t in e?e[t]:t}function Sk(e,t){return kk(e,t.toLowerCase())}const bL=uo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:hi,acceptCharset:Qe,accessKey:Qe,action:null,allow:null,allowFullScreen:Le,allowPaymentRequest:Le,allowUserMedia:Le,alpha:Le,alt:null,as:null,async:Le,autoCapitalize:null,autoComplete:Qe,autoFocus:Le,autoPlay:Le,blocking:Qe,capture:null,charSet:null,checked:Le,cite:null,className:Qe,closedBy:null,colorSpace:null,cols:ae,colSpan:ae,command:null,commandFor:null,content:null,contentEditable:yt,controls:Le,controlsList:Qe,coords:ae|hi,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Le,defer:Le,dir:null,dirName:null,disabled:Le,download:Cd,draggable:yt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Le,formTarget:null,headers:Qe,height:ae,hidden:Cd,high:ae,href:null,hrefLang:null,htmlFor:Qe,httpEquiv:Qe,id:null,imageSizes:null,imageSrcSet:null,inert:Le,inputMode:null,integrity:null,is:null,isMap:Le,itemId:null,itemProp:Qe,itemRef:Qe,itemScope:Le,itemType:Qe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Le,low:ae,manifest:null,max:null,maxLength:ae,media:null,method:null,min:null,minLength:ae,multiple:Le,muted:Le,name:null,nonce:null,noModule:Le,noValidate:Le,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Le,optimum:ae,pattern:null,ping:Qe,placeholder:null,playsInline:Le,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Le,referrerPolicy:null,rel:Qe,required:Le,reversed:Le,rows:ae,rowSpan:ae,sandbox:Qe,scope:null,scoped:Le,seamless:Le,selected:Le,shadowRootClonable:Le,shadowRootCustomElementRegistry:Le,shadowRootDelegatesFocus:Le,shadowRootMode:null,shadowRootSerializable:Le,shape:null,size:ae,sizes:null,slot:null,span:ae,spellCheck:yt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ae,step:null,style:null,tabIndex:ae,target:null,title:null,translate:null,type:null,typeMustMatch:Le,useMap:null,value:yt,width:ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qe,axis:null,background:null,bgColor:null,border:ae,borderColor:null,bottomMargin:ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Le,declare:Le,event:null,face:null,frame:null,frameBorder:null,hSpace:ae,leftMargin:ae,link:null,longDesc:null,lowSrc:null,marginHeight:ae,marginWidth:ae,noResize:Le,noHref:Le,noShade:Le,noWrap:Le,object:null,profile:null,prompt:null,rev:null,rightMargin:ae,rules:null,scheme:null,scrolling:yt,standby:null,summary:null,text:null,topMargin:ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ae,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Le,disablePictureInPicture:Le,disableRemotePlayback:Le,exportParts:hi,part:Qe,prefix:null,property:null,results:ae,security:null,unselectable:null},space:"html",transform:Sk}),CL=uo({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ln,accentHeight:ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ae,amplitude:ae,arabicForm:null,ascent:ae,attributeName:null,attributeType:null,azimuth:ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ae,by:null,calcMode:null,capHeight:ae,className:Qe,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ae,diffuseConstant:ae,direction:null,display:null,dur:null,divisor:ae,dominantBaseline:null,download:Le,dx:null,dy:null,edgeMode:null,editable:null,elevation:ae,enableBackground:null,end:null,event:null,exponent:ae,externalResourcesRequired:null,fill:null,fillOpacity:ae,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:hi,g2:hi,glyphName:hi,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ae,horizOriginX:ae,horizOriginY:ae,id:null,ideographic:ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ae,k:ae,k1:ae,k2:ae,k3:ae,k4:ae,kernelMatrix:ln,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ae,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ae,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ae,overlineThickness:ae,paintOrder:null,panose1:null,path:null,pathLength:ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ae,pointsAtY:ae,pointsAtZ:ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ln,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ln,rev:ln,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ln,requiredFeatures:ln,requiredFonts:ln,requiredFormats:ln,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ae,specularExponent:ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ae,strikethroughThickness:ae,string:null,stroke:null,strokeDashArray:ln,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ae,strokeOpacity:ae,strokeWidth:null,style:null,surfaceScale:ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ln,tabIndex:ae,tableValues:null,target:null,targetX:ae,targetY:ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ln,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ae,underlineThickness:ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ae,values:null,vAlphabetic:ae,vMathematical:ae,vectorEffect:null,vHanging:ae,vIdeographic:ae,version:null,vertAdvY:ae,vertOriginX:ae,vertOriginY:ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:kk}),bk=uo({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Ck=uo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Sk}),Ek=uo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),EL={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},TL=/[A-Z]/g,Yv=/-[a-z]/g,PL=/^data[-\w.:]+$/i;function RL(e,t){const n=bd(t);let i=t,s=tn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&PL.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(Yv,AL);i="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!Yv.test(l)){let a=l.replace(TL,ML);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Dh}return new s(i,t)}function ML(e){return"-"+e.toLowerCase()}function AL(e){return e.charAt(1).toUpperCase()}const NL=xk([wk,bL,bk,Ck,Ek],"html"),_h=xk([wk,CL,bk,Ck,Ek],"svg");function IL(e){return e.join(" ").trim()}var Wi={},mf,Gv;function jL(){if(Gv)return mf;Gv=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
|
|
308
|
+
`,h="/",m="*",p="",y="comment",w="declaration";function S(E,T){if(typeof E!="string")throw new TypeError("First argument must be a string");if(!E)return[];T=T||{};var M=1,P=1;function D(J){var ee=J.match(t);ee&&(M+=ee.length);var xe=J.lastIndexOf(d);P=~xe?J.length-xe:P+J.length}function $(){var J={line:M,column:P};return function(ee){return ee.position=new j(J),O(),ee}}function j(J){this.start=J,this.end={line:M,column:P},this.source=T.source}j.prototype.content=E;function Y(J){var ee=new Error(T.source+":"+M+":"+P+": "+J);if(ee.reason=J,ee.filename=T.source,ee.line=M,ee.column=P,ee.source=E,!T.silent)throw ee}function U(J){var ee=J.exec(E);if(ee){var xe=ee[0];return D(xe),E=E.slice(xe.length),ee}}function O(){U(n)}function N(J){var ee;for(J=J||[];ee=X();)ee!==!1&&J.push(ee);return J}function X(){var J=$();if(!(h!=E.charAt(0)||m!=E.charAt(1))){for(var ee=2;p!=E.charAt(ee)&&(m!=E.charAt(ee)||h!=E.charAt(ee+1));)++ee;if(ee+=2,p===E.charAt(ee-1))return Y("End of comment missing");var xe=E.slice(2,ee-2);return P+=2,D(xe),E=E.slice(ee),P+=2,J({type:y,comment:xe})}}function V(){var J=$(),ee=U(i);if(ee){if(X(),!U(s))return Y("property missing ':'");var xe=U(l),Pe=J({type:w,property:C(ee[0].replace(e,p)),value:xe?C(xe[0].replace(e,p)):p});return U(a),Pe}}function fe(){var J=[];N(J);for(var ee;ee=V();)ee!==!1&&(J.push(ee),N(J));return J}return O(),fe()}function C(E){return E?E.replace(c,p):p}return mf=S,mf}var Qv;function DL(){if(Qv)return Wi;Qv=1;var e=Wi&&Wi.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.default=n;const t=e(jL());function n(i,s){let l=null;if(!i||typeof i!="string")return l;const a=(0,t.default)(i),c=typeof s=="function";return a.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:m}=d;c?s(h,m,d):m&&(l=l||{},l[h]=m)}),l}return Wi}var Qo={},Zv;function _L(){if(Zv)return Qo;Zv=1,Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,l=function(h){return!h||n.test(h)||e.test(h)},a=function(h,m){return m.toUpperCase()},c=function(h,m){return"".concat(m,"-")},d=function(h,m){return m===void 0&&(m={}),l(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(s,c):h=h.replace(i,c),h.replace(t,a))};return Qo.camelCase=d,Qo}var Zo,Jv;function LL(){if(Jv)return Zo;Jv=1;var e=Zo&&Zo.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},t=e(DL()),n=_L();function i(s,l){var a={};return!s||typeof s!="string"||(0,t.default)(s,function(c,d){c&&d&&(a[(0,n.camelCase)(c,l)]=d)}),a}return i.default=i,Zo=i,Zo}var OL=LL();const FL=Id(OL),Tk=Pk("end"),Lh=Pk("start");function Pk(e){return t;function t(n){const i=n&&n.position&&n.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function zL(e){const t=Lh(e),n=Tk(e);if(t&&n)return{start:t,end:n}}class zt extends Error{constructor(t,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let s="",l={},a=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?s=t:!l.cause&&t&&(a=!0,s=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof i=="string"){const d=i.indexOf(":");d===-1?l.ruleId=i:(l.source=i.slice(0,d),l.ruleId=i.slice(d+1))}if(!l.place&&l.ancestors&&l.ancestors){const d=l.ancestors[l.ancestors.length-1];d&&(l.place=d.position)}const c=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=c?c.line:void 0,this.name=ls(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=a&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}zt.prototype.file="";zt.prototype.name="";zt.prototype.reason="";zt.prototype.message="";zt.prototype.stack="";zt.prototype.column=void 0;zt.prototype.line=void 0;zt.prototype.ancestors=void 0;zt.prototype.cause=void 0;zt.prototype.fatal=void 0;zt.prototype.place=void 0;zt.prototype.ruleId=void 0;zt.prototype.source=void 0;const Oh={}.hasOwnProperty,VL=new Map,BL=/[A-Z]/g,$L=new Set(["table","tbody","thead","tfoot","tr"]),UL=new Set(["td","th"]),Rk="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function WL(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let i;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=ZL(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=QL(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:i,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?_h:NL,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=Mk(s,e,void 0);return l&&typeof l!="string"?l:s.create(e,s.Fragment,{children:l||void 0},void 0)}function Mk(e,t,n){if(t.type==="element")return HL(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return KL(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return XL(e,t,n);if(t.type==="mdxjsEsm")return qL(e,t);if(t.type==="root")return YL(e,t,n);if(t.type==="text")return GL(e,t)}function HL(e,t,n){const i=e.schema;let s=i;t.tagName.toLowerCase()==="svg"&&i.space==="html"&&(s=_h,e.schema=s),e.ancestors.push(t);const l=Nk(e,t.tagName,!1),a=JL(e,t);let c=zh(e,t);return $L.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!kL(d):!0})),Ak(e,a,l,t),Fh(a,c),e.ancestors.pop(),e.schema=i,e.create(t,l,a,n)}function KL(e,t){if(t.data&&t.data.estree&&e.evaluater){const i=t.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}ks(e,t.position)}function qL(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ks(e,t.position)}function XL(e,t,n){const i=e.schema;let s=i;t.name==="svg"&&i.space==="html"&&(s=_h,e.schema=s),e.ancestors.push(t);const l=t.name===null?e.Fragment:Nk(e,t.name,!0),a=eO(e,t),c=zh(e,t);return Ak(e,a,l,t),Fh(a,c),e.ancestors.pop(),e.schema=i,e.create(t,l,a,n)}function YL(e,t,n){const i={};return Fh(i,zh(e,t)),e.create(t,e.Fragment,i,n)}function GL(e,t){return t.value}function Ak(e,t,n,i){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=i)}function Fh(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function QL(e,t,n){return i;function i(s,l,a,c){const h=Array.isArray(a.children)?n:t;return c?h(l,a,c):h(l,a)}}function ZL(e,t){return n;function n(i,s,l,a){const c=Array.isArray(l.children),d=Lh(i);return t(s,l,a,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function JL(e,t){const n={};let i,s;for(s in t.properties)if(s!=="children"&&Oh.call(t.properties,s)){const l=tO(e,s,t.properties[s]);if(l){const[a,c]=l;e.tableCellAlignToStyle&&a==="align"&&typeof c=="string"&&UL.has(t.tagName)?i=c:n[a]=c}}if(i){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return n}function eO(e,t){const n={};for(const i of t.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const l=i.data.estree.body[0];l.type;const a=l.expression;a.type;const c=a.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else ks(e,t.position);else{const s=i.name;let l;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const c=i.value.data.estree.body[0];c.type,l=e.evaluater.evaluateExpression(c.expression)}else ks(e,t.position);else l=i.value===null?!0:i.value;n[s]=l}return n}function zh(e,t){const n=[];let i=-1;const s=e.passKeys?new Map:VL;for(;++i<t.children.length;){const l=t.children[i];let a;if(e.passKeys){const d=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(d){const h=s.get(d)||0;a=d+"-"+h,s.set(d,h+1)}}const c=Mk(e,l,a);c!==void 0&&n.push(c)}return n}function tO(e,t,n){const i=RL(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=i.commaSeparated?gL(n):IL(n)),i.property==="style"){let s=typeof n=="object"?n:nO(e,String(n));return e.stylePropertyNameCase==="css"&&(s=rO(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&i.space?EL[i.property]||i.property:i.attribute,n]}}function nO(e,t){try{return FL(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const i=n,s=new zt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=Rk+"#cannot-parse-style-attribute",s}}function Nk(e,t,n){let i;if(!n)i={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let l=-1,a;for(;++l<s.length;){const c=Kv(s[l])?{type:"Identifier",name:s[l]}:{type:"Literal",value:s[l]};a=a?{type:"MemberExpression",object:a,property:c,computed:!!(l&&c.type==="Literal"),optional:!1}:c}i=a}else i=Kv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(i.type==="Literal"){const s=i.value;return Oh.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(i);ks(e)}function ks(e,t){const n=new zt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Rk+"#cannot-handle-mdx-estrees-without-createevaluater",n}function rO(e){const t={};let n;for(n in e)Oh.call(e,n)&&(t[iO(n)]=e[n]);return t}function iO(e){let t=e.replace(BL,oO);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function oO(e){return"-"+e.toLowerCase()}const gf={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};function sO(e){const t=this;t.parser=n;function n(i){return t1(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function aO(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function lO(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
309
|
+
`}]}function uO(e,t){const n=t.value?t.value+`
|
|
310
|
+
`:"",i={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(i.className=["language-"+s[0]]);let l={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return t.meta&&(l.data={meta:t.meta}),e.patch(t,l),l=e.applyData(t,l),l={type:"element",tagName:"pre",properties:{},children:[l]},e.patch(t,l),l}function cO(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function fO(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dO(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),s=so(i.toLowerCase()),l=e.footnoteOrder.indexOf(i);let a,c=e.footnoteCounts.get(i);c===void 0?(c=0,e.footnoteOrder.push(i),a=e.footnoteOrder.length):a=l+1,c+=1,e.footnoteCounts.set(i,c);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,d);const h={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,h),e.applyData(t,h)}function hO(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pO(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Ik(e,t){const n=t.referenceType;let i="]";if(n==="collapsed"?i+="[]":n==="full"&&(i+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+i}];const s=e.all(t),l=s[0];l&&l.type==="text"?l.value="["+l.value:s.unshift({type:"text",value:"["});const a=s[s.length-1];return a&&a.type==="text"?a.value+=i:s.push({type:"text",value:i}),s}function mO(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return Ik(e,t);const s={src:so(i.url||""),alt:t.alt};i.title!==null&&i.title!==void 0&&(s.title=i.title);const l={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,l),e.applyData(t,l)}function gO(e,t){const n={src:so(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,i),e.applyData(t,i)}function yO(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const i={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,i),e.applyData(t,i)}function vO(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return Ik(e,t);const s={href:so(i.url||"")};i.title!==null&&i.title!==void 0&&(s.title=i.title);const l={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function xO(e,t){const n={href:so(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const i={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function wO(e,t,n){const i=e.all(t),s=n?kO(n):jk(t),l={},a=[];if(typeof t.checked=="boolean"){const m=i[0];let p;m&&m.type==="element"&&m.tagName==="p"?p=m:(p={type:"element",tagName:"p",properties:{},children:[]},i.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let c=-1;for(;++c<i.length;){const m=i[c];(s||c!==0||m.type!=="element"||m.tagName!=="p")&&a.push({type:"text",value:`
|
|
312
311
|
`}),m.type==="element"&&m.tagName==="p"&&!s?a.push(...m.children):a.push(m)}const d=i[i.length-1];d&&(s||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
|
|
313
|
-
`});const h={type:"element",tagName:"li",properties:l,children:a};return e.patch(t,h),e.applyData(t,h)}function
|
|
312
|
+
`});const h={type:"element",tagName:"li",properties:l,children:a};return e.patch(t,h),e.applyData(t,h)}function kO(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let i=-1;for(;!t&&++i<n.length;)t=jk(n[i])}return t}function jk(e){const t=e.spread;return t??e.children.length>1}function SO(e,t){const n={},i=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<i.length;){const a=i[s];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const l={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(i,!0)};return e.patch(t,l),e.applyData(t,l)}function bO(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function CO(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function EO(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function TO(e,t){const n=e.all(t),i=n.shift(),s=[];if(i){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(t.children[0],a),s.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=Lh(t.children[1]),d=Tk(t.children[t.children.length-1]);c&&d&&(a.position={start:c,end:d}),s.push(a)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,l),e.applyData(t,l)}function PO(e,t,n){const i=n?n.children:void 0,l=(i?i.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,c=a?a.length:t.children.length;let d=-1;const h=[];for(;++d<c;){const p=t.children[d],y={},w=a?a[d]:void 0;w&&(y.align=w);let S={type:"element",tagName:l,properties:y,children:[]};p&&(S.children=e.all(p),e.patch(p,S),S=e.applyData(p,S)),h.push(S)}const m={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,m),e.applyData(t,m)}function RO(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const ex=9,tx=32;function MO(e){const t=String(e),n=/\r?\n|\r/g;let i=n.exec(t),s=0;const l=[];for(;i;)l.push(nx(t.slice(s,i.index),s>0,!0),i[0]),s=i.index+i[0].length,i=n.exec(t);return l.push(nx(t.slice(s),s>0,!1)),l.join("")}function nx(e,t,n){let i=0,s=e.length;if(t){let l=e.codePointAt(i);for(;l===ex||l===tx;)i++,l=e.codePointAt(i)}if(n){let l=e.codePointAt(s-1);for(;l===ex||l===tx;)s--,l=e.codePointAt(s-1)}return s>i?e.slice(i,s):""}function AO(e,t){const n={type:"text",value:MO(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function NO(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const IO={blockquote:aO,break:lO,code:uO,delete:cO,emphasis:fO,footnoteReference:dO,heading:hO,html:pO,imageReference:mO,image:gO,inlineCode:yO,linkReference:vO,link:xO,listItem:wO,list:SO,paragraph:bO,root:CO,strong:EO,table:TO,tableCell:RO,tableRow:PO,text:AO,thematicBreak:NO,toml:tl,yaml:tl,definition:tl,footnoteDefinition:tl};function tl(){}const Dk=-1,Yl=0,us=1,jl=2,Vh=3,Bh=4,$h=5,Uh=6,_k=7,Lk=8,Ok=typeof self=="object"?self:globalThis,rx=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new Ok[e](t)},jO=(e,t)=>{const n=(s,l)=>(e.set(l,s),s),i=s=>{if(e.has(s))return e.get(s);const[l,a]=t[s];switch(l){case Yl:case Dk:return n(a,s);case us:{const c=n([],s);for(const d of a)c.push(i(d));return c}case jl:{const c=n({},s);for(const[d,h]of a)c[i(d)]=i(h);return c}case Vh:return n(new Date(a),s);case Bh:{const{source:c,flags:d}=a;return n(new RegExp(c,d),s)}case $h:{const c=n(new Map,s);for(const[d,h]of a)c.set(i(d),i(h));return c}case Uh:{const c=n(new Set,s);for(const d of a)c.add(i(d));return c}case _k:{const{name:c,message:d}=a;return n(typeof Ok[c]=="function"?rx(c,d):new Error(d),s)}case Lk:return n(BigInt(a),s);case"BigInt":return n(Object(BigInt(a)),s);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:c}=new Uint8Array(a);return n(new DataView(c),a)}}return n(rx(l,a),s)};return i},ix=e=>jO(new Map,e)(0),ai="",{toString:DO}={},{keys:_O}=Object,Jo=e=>{const t=typeof e;if(t!=="object"||!e)return[Yl,t];const n=DO.call(e).slice(8,-1);switch(n){case"Array":return[us,ai];case"Object":return[jl,ai];case"Date":return[Vh,ai];case"RegExp":return[Bh,ai];case"Map":return[$h,ai];case"Set":return[Uh,ai];case"DataView":return[us,n]}return n.includes("Array")?[us,n]:e instanceof Error?[_k,e.name||"Error"]:[jl,n]},nl=([e,t])=>e===Yl&&(t==="function"||t==="symbol"),LO=(e,t,n,i)=>{const s=(a,c)=>{const d=i.push(a)-1;return n.set(c,d),d},l=a=>{if(n.has(a))return n.get(a);let[c,d]=Jo(a);switch(c){case Yl:{let m=a;switch(d){case"bigint":c=Lk,m=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);m=null;break;case"undefined":return s([Dk],a)}return s([c,m],a)}case us:{if(d){let y=a;return d==="DataView"?y=new Uint8Array(a.buffer):d==="ArrayBuffer"&&(y=new Uint8Array(a)),s([d,[...y]],a)}const m=[],p=s([c,m],a);for(const y of a)m.push(l(y));return p}case jl:{if(d)switch(d){case"BigInt":return s([d,a.toString()],a);case"Boolean":case"Number":case"String":return s([d,a.valueOf()],a)}if(t&&"toJSON"in a)return l(a.toJSON());const m=[],p=s([c,m],a);for(const y of _O(a))(e||!nl(Jo(a[y])))&&m.push([l(y),l(a[y])]);return p}case Vh:return s([c,isNaN(a.getTime())?ai:a.toISOString()],a);case Bh:{const{source:m,flags:p}=a;return s([c,{source:m,flags:p}],a)}case $h:{const m=[],p=s([c,m],a);for(const[y,w]of a)(e||!(nl(Jo(y))||nl(Jo(w))))&&m.push([l(y),l(w)]);return p}case Uh:{const m=[],p=s([c,m],a);for(const y of a)(e||!nl(Jo(y)))&&m.push(l(y));return p}}const{message:h}=a;return s([c,{name:d,message:h}],a)};return l},ox=(e,{json:t,lossy:n}={})=>{const i=[];return LO(!(t||n),!!t,new Map,i)(e),i},Dl=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ix(ox(e,t)):structuredClone(e):(e,t)=>ix(ox(e,t));function OO(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function FO(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function zO(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||OO,i=e.options.footnoteBackLabel||FO,s=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[d]);if(!h)continue;const m=e.all(h),p=String(h.identifier).toUpperCase(),y=so(p.toLowerCase());let w=0;const S=[],C=e.footnoteCounts.get(p);for(;C!==void 0&&++w<=C;){S.length>0&&S.push({type:"text",value:" "});let M=typeof n=="string"?n:n(d,w);typeof M=="string"&&(M={type:"text",value:M}),S.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+y+(w>1?"-"+w:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(d,w),className:["data-footnote-backref"]},children:Array.isArray(M)?M:[M]})}const E=m[m.length-1];if(E&&E.type==="element"&&E.tagName==="p"){const M=E.children[E.children.length-1];M&&M.type==="text"?M.value+=" ":E.children.push({type:"text",value:" "}),E.children.push(...S)}else m.push(...S);const T={type:"element",tagName:"li",properties:{id:t+"fn-"+y},children:e.wrap(m,!0)};e.patch(h,T),c.push(T)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...Dl(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
|
|
314
313
|
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
|
|
315
|
-
`}]}}const Td={}.hasOwnProperty,
|
|
314
|
+
`}]}}const Td={}.hasOwnProperty,VO={};function BO(e,t){const n=t||VO,i=new Map,s=new Map,l=new Map,a={...IO,...n.handlers},c={all:h,applyData:UO,definitionById:i,footnoteById:s,footnoteCounts:l,footnoteOrder:[],handlers:a,one:d,options:n,patch:$O,wrap:HO};return ph(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const p=m.type==="definition"?i:s,y=String(m.identifier).toUpperCase();p.has(y)||p.set(y,m)}}),c;function d(m,p){const y=m.type,w=c.handlers[y];if(Td.call(c.handlers,y)&&w)return w(c,m,p);if(c.options.passThrough&&c.options.passThrough.includes(y)){if("children"in m){const{children:C,...E}=m,T=Dl(E);return T.children=c.all(m),T}return Dl(m)}return(c.options.unknownHandler||WO)(c,m,p)}function h(m){const p=[];if("children"in m){const y=m.children;let w=-1;for(;++w<y.length;){const S=c.one(y[w],m);if(S){if(w&&y[w-1].type==="break"&&(!Array.isArray(S)&&S.type==="text"&&(S.value=sx(S.value)),!Array.isArray(S)&&S.type==="element")){const C=S.children[0];C&&C.type==="text"&&(C.value=sx(C.value))}Array.isArray(S)?p.push(...S):p.push(S)}}}return p}}function $O(e,t){e.position&&(t.position=zL(e))}function UO(e,t){let n=t;if(e&&e.data){const i=e.data.hName,s=e.data.hChildren,l=e.data.hProperties;if(typeof i=="string")if(n.type==="element")n.tagName=i;else{const a="children"in n?n.children:[n];n={type:"element",tagName:i,properties:{},children:a}}n.type==="element"&&l&&Object.assign(n.properties,Dl(l)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function WO(e,t){const n=t.data||{},i="value"in t&&!(Td.call(n,"hProperties")||Td.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function HO(e,t){const n=[];let i=-1;for(t&&n.push({type:"text",value:`
|
|
316
315
|
`});++i<e.length;)i&&n.push({type:"text",value:`
|
|
317
316
|
`}),n.push(e[i]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
318
|
-
`}),n}function sx(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ax(e,t){const n=
|
|
319
|
-
`},s),l}function YO(e,t){return e&&"run"in e?async function(n,i){const s=ax(n,{file:i,...t});await e.run(s,i)}:function(n,i){return ax(n,{file:i,...e||t})}}function lx(e){if(e)throw e}var yf,ux;function GO(){if(ux)return yf;ux=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},l=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),p=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!p)return!1;var y;for(y in h);return typeof y>"u"||e.call(h,y)},a=function(h,m){n&&m.name==="__proto__"?n(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},c=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(i)return i(h,m).value}else return;return h[m]};return yf=function d(){var h,m,p,y,w,S,C=arguments[0],E=1,T=arguments.length,M=!1;for(typeof C=="boolean"&&(M=C,C=arguments[1]||{},E=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});E<T;++E)if(h=arguments[E],h!=null)for(m in h)p=c(C,m),y=c(h,m),C!==y&&(M&&y&&(l(y)||(w=s(y)))?(w?(w=!1,S=p&&s(p)?p:[]):S=p&&l(p)?p:{},a(C,{name:m,newValue:d(M,S,y)})):typeof y<"u"&&a(C,{name:m,newValue:y}));return C},yf}var QO=GO();const vf=Id(QO);function Pd(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function ZO(){const e=[],t={run:n,use:i};return t;function n(...s){let l=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);c(null,...s);function c(d,...h){const m=e[++l];let p=-1;if(d){a(d);return}for(;++p<s.length;)(h[p]===null||h[p]===void 0)&&(h[p]=s[p]);s=h,m?JO(m,c)(...h):a(null,...h)}}function i(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function JO(e,t){let n;return i;function i(...a){const c=e.length>a.length;let d;c&&a.push(s);try{d=e.apply(this,a)}catch(h){const m=h;if(c&&n)throw m;return s(m)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,s):d instanceof Error?s(d):l(d))}function s(a,...c){n||(n=!0,t(a,...c))}function l(a){s(null,a)}}const Un={basename:eF,dirname:tF,extname:nF,join:rF,sep:"/"};function eF(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');js(e);let n=0,i=-1,s=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(l){n=s+1;break}}else i<0&&(l=!0,i=s+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let a=-1,c=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(l){n=s+1;break}}else a<0&&(l=!0,a=s+1),c>-1&&(e.codePointAt(s)===t.codePointAt(c--)?c<0&&(i=s):(c=-1,i=a));return n===i?i=a:i<0&&(i=e.length),e.slice(n,i)}function tF(e){if(js(e),e.length===0)return".";let t=-1,n=e.length,i;for(;--n;)if(e.codePointAt(n)===47){if(i){t=n;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function nF(e){js(e);let t=e.length,n=-1,i=0,s=-1,l=0,a;for(;t--;){const c=e.codePointAt(t);if(c===47){if(a){i=t+1;break}continue}n<0&&(a=!0,n=t+1),c===46?s<0?s=t:l!==1&&(l=1):s>-1&&(l=-1)}return s<0||n<0||l===0||l===1&&s===n-1&&s===i+1?"":e.slice(s,n)}function rF(...e){let t=-1,n;for(;++t<e.length;)js(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":iF(n)}function iF(e){js(e);const t=e.codePointAt(0)===47;let n=oF(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function oF(e,t){let n="",i=0,s=-1,l=0,a=-1,c,d;for(;++a<=e.length;){if(a<e.length)c=e.codePointAt(a);else{if(c===47)break;c=47}if(c===47){if(!(s===a-1||l===1))if(s!==a-1&&l===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",i=0):(n=n.slice(0,d),i=n.length-1-n.lastIndexOf("/")),s=a,l=0;continue}}else if(n.length>0){n="",i=0,s=a,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),i=a-s-1;s=a,l=0}else c===46&&l>-1?l++:l=-1}return n}function js(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const sF={cwd:aF};function aF(){return"/"}function Rd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function lF(e){if(typeof e=="string")e=new URL(e);else if(!Rd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return uF(e)}function uF(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const i=t.codePointAt(n+2);if(i===70||i===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const xf=["history","path","basename","stem","extname","dirname"];class Fk{constructor(t){let n;t?Rd(t)?n={path:t}:typeof t=="string"||cF(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":sF.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<xf.length;){const l=xf[i];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let s;for(s in n)xf.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Un.basename(this.path):void 0}set basename(t){kf(t,"basename"),wf(t,"basename"),this.path=Un.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Un.dirname(this.path):void 0}set dirname(t){cx(this.basename,"dirname"),this.path=Un.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Un.extname(this.path):void 0}set extname(t){if(wf(t,"extname"),cx(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Un.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Rd(t)&&(t=lF(t)),kf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Un.basename(this.path,this.extname):void 0}set stem(t){kf(t,"stem"),wf(t,"stem"),this.path=Un.join(this.dirname||"",t+(this.extname||""))}fail(t,n,i){const s=this.message(t,n,i);throw s.fatal=!0,s}info(t,n,i){const s=this.message(t,n,i);return s.fatal=void 0,s}message(t,n,i){const s=new zt(t,n,i);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function wf(e,t){if(e&&e.includes(Un.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Un.sep+"`")}function kf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function cx(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function cF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const fF=function(e){const i=this.constructor.prototype,s=i[e],l=function(){return s.apply(l,arguments)};return Object.setPrototypeOf(l,i),l},dF={}.hasOwnProperty;class Wh extends fF{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=ZO()}copy(){const t=new Wh;let n=-1;for(;++n<this.attachers.length;){const i=this.attachers[n];t.use(...i)}return t.data(vf(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Cf("data",this.frozen),this.namespace[t]=n,this):dF.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Cf("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const s=n.call(t,...i);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=rl(t),i=this.parser||this.Parser;return Sf("parse",i),i(String(n),n)}process(t,n){const i=this;return this.freeze(),Sf("process",this.parser||this.Parser),bf("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(l,a){const c=rl(t),d=i.parse(c);i.run(d,c,function(m,p,y){if(m||!p||!y)return h(m);const w=p,S=i.stringify(w,y);mF(S)?y.value=S:y.result=S,h(m,y)});function h(m,p){m||!p?a(m):l?l(p):n(void 0,p)}}}processSync(t){let n=!1,i;return this.freeze(),Sf("processSync",this.parser||this.Parser),bf("processSync",this.compiler||this.Compiler),this.process(t,s),dx("processSync","process",n),i;function s(l,a){n=!0,lx(l),i=a}}run(t,n,i){fx(t),this.freeze();const s=this.transformers;return!i&&typeof n=="function"&&(i=n,n=void 0),i?l(void 0,i):new Promise(l);function l(a,c){const d=rl(n);s.run(t,d,h);function h(m,p,y){const w=p||t;m?c(m):a?a(w):i(void 0,w,y)}}}runSync(t,n){let i=!1,s;return this.run(t,n,l),dx("runSync","run",i),s;function l(a,c){lx(a),s=c,i=!0}}stringify(t,n){this.freeze();const i=rl(n),s=this.compiler||this.Compiler;return bf("stringify",s),fx(t),s(t,i)}use(t,...n){const i=this.attachers,s=this.namespace;if(Cf("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...p]=h;d(m,p)}else a(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function a(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(h.plugins),h.settings&&(s.settings=vf(!0,s.settings,h.settings))}function c(h){let m=-1;if(h!=null)if(Array.isArray(h))for(;++m<h.length;){const p=h[m];l(p)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,m){let p=-1,y=-1;for(;++p<i.length;)if(i[p][0]===h){y=p;break}if(y===-1)i.push([h,...m]);else if(m.length>0){let[w,...S]=m;const C=i[y][1];Pd(C)&&Pd(w)&&(w=vf(!0,C,w)),i[y]=[h,w,...S]}}}}const hF=new Wh().freeze();function Sf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function bf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Cf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function fx(e){if(!Pd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function dx(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function rl(e){return pF(e)?e:new Fk(e)}function pF(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function mF(e){return typeof e=="string"||gF(e)}function gF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const yF="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",hx=[],px={allowDangerousHtml:!0},vF=/^(https?|ircs?|mailto|xmpp)$/i,xF=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function zk(e){const t=wF(e),n=kF(e);return SF(t.runSync(t.parse(n),n),e)}function wF(e){const t=e.rehypePlugins||hx,n=e.remarkPlugins||hx,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...px}:px;return hF().use(uO).use(n).use(YO,i).use(t)}function kF(e){const t=e.children||"",n=new Fk;return typeof t=="string"&&(n.value=t),n}function SF(e,t){const n=t.allowedElements,i=t.allowElement,s=t.components,l=t.disallowedElements,a=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||bF;for(const m of xF)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+yF+m.id,void 0);return ph(e,h),qL(e,{Fragment:v.Fragment,components:s,ignoreInvalidStyle:!0,jsx:v.jsx,jsxs:v.jsxs,passKeys:!0,passNode:!0});function h(m,p,y){if(m.type==="raw"&&y&&typeof p=="number")return a?y.children.splice(p,1):y.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let w;for(w in gf)if(Object.hasOwn(gf,w)&&Object.hasOwn(m.properties,w)){const S=m.properties[w],C=gf[w];(C===null||C.includes(m.tagName))&&(m.properties[w]=d(String(S||""),w,m))}}if(m.type==="element"){let w=n?!n.includes(m.tagName):l?l.includes(m.tagName):!1;if(!w&&i&&typeof p=="number"&&(w=!i(m,p,y)),w&&y&&typeof p=="number")return c&&m.children?y.children.splice(p,1,...m.children):y.children.splice(p,1),p}}}function bF(e){const t=e.indexOf(":"),n=e.indexOf("?"),i=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||i!==-1&&t>i||vF.test(e.slice(0,t))?e:""}const CF={};function Vk(e){const t=this,n=e||CF,i=t.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),l=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(f1(n)),l.push(U0()),a.push(RN(n))}function Ds(e){const t=k.useRef(null);return k.useEffect(()=>(t.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>{const n=t.current;n?.isConnected&&requestAnimationFrame(()=>n.focus())}),[]),v.jsx(uk,{open:!0,onOpenChange:n=>{n||e.onClose()},children:v.jsxs(dk,{children:[v.jsx(hk,{className:"modal-backdrop"}),v.jsxs(pk,{id:e.contentId,className:"modal"+(e.wide?" modal-wide":"")+(e.className?` ${e.className}`:""),children:[v.jsxs("div",{className:"modal-head",children:[v.jsxs("div",{children:[v.jsx(gk,{asChild:!0,children:v.jsx("h3",{children:e.title})}),e.description&&v.jsx(yk,{className:"modal-description",children:e.description})]}),v.jsx(vk,{asChild:!0,children:v.jsx("button",{className:"icon-btn","aria-label":`Close ${e.title}`,children:v.jsx(Ee,{name:"close"})})})]}),e.tabs,v.jsx("div",{className:"modal-body",children:e.children})]})]})})}const EF=.25,TF=8;let mx=Promise.resolve();function gx(){return document.documentElement.classList.contains("theme-dark")?"dark":"default"}function PF(){const[e,t]=k.useState(gx);return k.useEffect(()=>{const n=document.documentElement,i=()=>t(gx()),s=new MutationObserver(i);return s.observe(n,{attributes:!0,attributeFilter:["class"]}),i(),()=>s.disconnect()},[]),e}function RF(e,t,n){const i=mx.then(async()=>{const{default:s}=await Ch(async()=>{const{default:l}=await import("./mermaid.core-DXnFjC8e.js").then(a=>a.bp);return{default:l}},[]);return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:n,fontFamily:"var(--sans)"}),s.render(e,t)});return mx=i.then(()=>{},()=>{}),i}function MF(e){return Math.min(TF,Math.max(EF,e))}function AF(e){const t=k.useRef(null),n=k.useRef(null),[i,s]=k.useState(1),[l,a]=k.useState({x:0,y:0}),[c,d]=k.useState(!1),h=()=>{s(1),a({x:0,y:0})},m=(p,y,w)=>{const S=MF(p);if(S===i)return;const C=t.current?.getBoundingClientRect();if(C){const E=(y??C.left+C.width/2)-C.left-C.width/2,T=(w??C.top+C.height/2)-C.top-C.height/2,M=S/i;a(P=>({x:E-M*(E-P.x),y:T-M*(T-P.y)}))}s(S)};return k.useEffect(()=>{const p=y=>{y.key==="+"||y.key==="="?(y.preventDefault(),m(i*1.25)):y.key==="-"?(y.preventDefault(),m(i/1.25)):y.key==="0"&&(y.preventDefault(),h())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)}),v.jsx(uk,{open:!0,onOpenChange:p=>{p||e.onClose()},children:v.jsxs(dk,{children:[v.jsx(hk,{className:"mermaid-fullscreen-backdrop"}),v.jsxs(pk,{className:"mermaid-fullscreen","data-mermaid-theme":e.theme,"aria-describedby":"mermaid-fullscreen-help",children:[v.jsx(gk,{className:"mermaid-fullscreen-title",children:"Diagram viewer"}),v.jsxs("div",{className:"mermaid-fullscreen-tools",children:[v.jsx("button",{className:"icon-btn","aria-label":"Zoom out",title:"Zoom out (−)",onClick:()=>m(i/1.25),children:v.jsx(Ee,{name:"minus"})}),v.jsxs("button",{className:"mermaid-zoom-value",onClick:h,title:"Reset zoom and position",children:[Math.round(i*100),"%"]}),v.jsx("button",{className:"icon-btn","aria-label":"Zoom in",title:"Zoom in (+)",onClick:()=>m(i*1.25),children:v.jsx(Ee,{name:"plus"})}),v.jsx(vk,{asChild:!0,children:v.jsx("button",{className:"icon-btn","aria-label":"Close diagram viewer",title:"Close (Esc)",children:v.jsx(Ee,{name:"close"})})})]}),v.jsx("div",{ref:t,className:"mermaid-fullscreen-viewport"+(c?" dragging":""),onWheel:p=>{p.preventDefault(),m(i*Math.exp(-p.deltaY*.0015),p.clientX,p.clientY)},onDoubleClick:p=>m(i*1.5,p.clientX,p.clientY),onPointerDown:p=>{p.button===0&&(n.current={pointerId:p.pointerId,startX:p.clientX,startY:p.clientY,panX:l.x,panY:l.y},p.currentTarget.setPointerCapture(p.pointerId),d(!0))},onPointerMove:p=>{const y=n.current;!y||y.pointerId!==p.pointerId||a({x:y.panX+p.clientX-y.startX,y:y.panY+p.clientY-y.startY})},onPointerUp:p=>{n.current?.pointerId===p.pointerId&&(n.current=null,d(!1),p.currentTarget.releasePointerCapture(p.pointerId))},onPointerCancel:()=>{n.current=null,d(!1)},children:v.jsx("div",{className:"mermaid-fullscreen-canvas",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${i})`},dangerouslySetInnerHTML:{__html:e.svg}})}),v.jsx(yk,{id:"mermaid-fullscreen-help",className:"mermaid-fullscreen-help",children:"Scroll to zoom · drag to move · double-click to zoom in"})]})]})})}function NF({source:e}){const t=k.useId(),[n,i]=k.useState(""),[s,l]=k.useState(""),[a,c]=k.useState("default"),[d,h]=k.useState(!1),m=PF();return k.useEffect(()=>{let p=!0;const y=`mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"")}`;return i(""),l(""),RF(y,e,m).then(w=>{p&&(c(m),i(w.svg))}).catch(w=>{p&&l(w instanceof Error?w.message:String(w))}),()=>{p=!1,document.getElementById(`d${y}`)?.remove()}},[t,e,m]),s?v.jsxs("pre",{className:"markdown-mermaid-error",children:["Mermaid error: ",s]}):n?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"markdown-mermaid","data-mermaid-theme":a,children:[v.jsx("button",{className:"icon-btn markdown-mermaid-expand","aria-label":"View diagram fullscreen",title:"View diagram fullscreen",onClick:()=>h(!0),children:v.jsx(Ee,{name:"maximize"})}),v.jsx("div",{className:"markdown-mermaid-diagram",dangerouslySetInnerHTML:{__html:n}})]}),d&&v.jsx(AF,{svg:n,theme:a,onClose:()=>h(!1)})]}):v.jsx("div",{className:"markdown-mermaid-loading",children:"Rendering diagram…"})}const IF=k.memo(function(t){return v.jsx("article",{className:"markdown-body",ref:t.contentRef,children:v.jsx(zk,{remarkPlugins:[Vk],components:{a:({children:n,...i})=>v.jsx("a",{...i,target:"_blank",rel:"noreferrer",children:n}),code:({className:n,children:i,...s})=>{const l=/language-([\w-]+)/.exec(n??"")?.[1],a=String(i).replace(/\n$/,"");return l==="mermaid"?v.jsx(NF,{source:a}):v.jsx("code",{className:n,...s,children:i})}},children:t.markdown})})});function Bk(e){const{rec:t}=e,n=k.useRef(null),[i,s]=k.useState(""),[l,a]=k.useState(null),[c,d]=k.useState("loading"),[h,m]=k.useState(""),[p,y]=k.useState(0),[w,S]=k.useState(""),[C,E]=k.useState(0),[T,M]=k.useState(!1),[P,D]=k.useState(""),[$,j]=k.useState(!1),[Y,U]=k.useState(!1),[O,N]=k.useState([]),[X,V]=k.useState(!1),[fe,J]=k.useState(null),[ee,xe]=k.useState(!1),[Pe,Q]=k.useState("");k.useEffect(()=>{let A=!0,te=null;return d("loading"),Ul(t.id).then(ge=>{if(A){if(!ge){d("missing");return}s(new TextDecoder("utf-8").decode(ge)),te=URL.createObjectURL(new Blob([ge],{type:"text/markdown;charset=utf-8"})),a(te),d("ready")}}).catch(()=>{A&&d("error")}),()=>{A=!1,te&&URL.revokeObjectURL(te)}},[t.id]),k.useEffect(()=>{const A=()=>{const te=window.getSelection(),ge=n.current;if(!te||te.isCollapsed||!ge){m(""),y(0);return}if(!ge.contains(te.anchorNode)||!ge.contains(te.focusNode)){m(""),y(0);return}const ye=te.getRangeAt(0),me=te.toString(),we=me.length-me.trimStart().length,pe=me.trim().slice(0,4e3),Ve=document.createRange();Ve.selectNodeContents(ge),Ve.setEnd(ye.startContainer,ye.startOffset);const qe=Ve.toString().length+we;m(pe),y(eD(ge.textContent,pe,qe))};return document.addEventListener("selectionchange",A),()=>document.removeEventListener("selectionchange",A)},[]);const de=()=>{h&&(S(h),E(p),M(!0),Q(""))},R=async()=>{if(Y){if(!w||!P.trim())return;N(te=>[...te,{selection:w,comment:P.trim(),occurrence:C}]),D(""),M(!1),Q("Comment added to review");return}const A=Zj(w,P);if(!(!A||!P.trim()||$)){j(!0),Q("");try{await e.onSendText(A,t.id||void 0),D(""),M(!1),Q("Feedback sent")}catch(te){Q(`Send failed: ${String(te)}`)}finally{j(!1)}}},F=async()=>{if(O.length===0||X)return;const A=sD(i,O);V(!0),Q("");try{e.onSendFile?await e.onSendFile({filename:Jj(t.filename),mime:"text/markdown",bytes:new TextEncoder().encode(A)},t.id||void 0):await e.onSendText(A,t.id||void 0),N([]),U(!1),Q("Review submitted")}catch(te){Q(`Review send failed: ${String(te)}`)}finally{V(!1)}},G=async()=>{if(!(!fe||!e.onSendFile||ee)){xe(!0),Q("");try{await e.onSendFile(fe,t.id||void 0),J(null),Q("Voice feedback sent")}catch(A){Q(`Voice send failed: ${String(A)}`)}finally{xe(!1)}}};return v.jsx(Ds,{title:t.filename,description:"Markdown preview · select text to send precise feedback",onClose:e.onClose,wide:!0,className:"markdown-modal",children:v.jsxs("div",{className:"markdown-preview",children:[v.jsxs("div",{className:"markdown-review-toolbar",children:[v.jsxs("button",{className:"btn sm",disabled:!h,onMouseDown:A=>A.preventDefault(),onClick:de,children:[v.jsx(Ee,{name:"reply",size:14}),Y?"Add review comment":"Quick message",h?` (${h.length})`:""]}),Y?v.jsx("button",{className:"btn sm",onClick:()=>{U(!1),N([]),M(!1),Q("Review discarded")},children:"Cancel review"}):v.jsxs("button",{className:"btn sm",onClick:()=>{U(!0),N([]),Q("Review started — select passages to add comments")},children:[v.jsx(Ee,{name:"edit",size:14}),"Start review"]}),l&&v.jsxs("a",{className:"btn sm",href:l,download:t.filename,children:[v.jsx(Ee,{name:"download",size:14}),"Download"]}),e.onSendFile&&v.jsx(k1,{disabled:!!fe||ee,onReady:J,onError:Q}),v.jsx("span",{className:"markdown-review-hint",children:h?"Selection ready for feedback":"Highlight any passage to comment on it"})]}),T&&v.jsxs("div",{className:"markdown-feedback",children:[v.jsx("blockquote",{children:w}),v.jsx("textarea",{className:"field",rows:3,autoFocus:!0,placeholder:"What should change?",value:P,onChange:A=>D(A.target.value)}),v.jsxs("div",{className:"markdown-feedback-actions",children:[v.jsx("button",{className:"btn sm",onClick:()=>M(!1),children:"Cancel"}),v.jsxs("button",{className:"btn sm primary",disabled:!P.trim()||$,onClick:()=>void R(),children:[v.jsx(Ee,{name:"send",size:14}),Y?"Add to review":$?"Sending…":"Send feedback"]})]})]}),Y&&v.jsxs("div",{className:"markdown-review-draft",children:[v.jsxs("div",{className:"markdown-review-draft-head",children:[v.jsxs("strong",{children:["Review · ",O.length," comment",O.length===1?"":"s"]}),v.jsxs("button",{className:"btn sm primary",disabled:O.length===0||X,onClick:()=>void F(),children:[v.jsx(Ee,{name:"send",size:14}),X?"Submitting…":"Submit review"]})]}),O.map((A,te)=>v.jsxs("div",{className:"markdown-review-comment",children:[v.jsx("span",{children:te+1}),v.jsxs("div",{children:[v.jsx("blockquote",{children:A.selection}),v.jsx("p",{children:A.comment})]}),v.jsx("button",{className:"icon-btn",title:"Remove comment",onClick:()=>N(ge=>ge.filter((ye,me)=>me!==te)),children:v.jsx(Ee,{name:"close",size:14})})]},`${te}-${A.selection.slice(0,24)}`))]}),fe&&v.jsx(w1,{att:fe,sending:ee,onSend:()=>void G(),onDiscard:()=>J(null)}),Pe&&v.jsx("div",{className:"markdown-review-status",role:"status",children:Pe}),v.jsxs("div",{className:"markdown-preview-scroll",children:[c==="loading"&&v.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),c==="missing"&&v.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),c==="error"&&v.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),c==="ready"&&v.jsx(IF,{markdown:i,contentRef:n})]})]})})}function $k(e){const{rec:t}=e,[n,i]=k.useState(""),[s,l]=k.useState(null),[a,c]=k.useState(0),[d,h]=k.useState("loading");return k.useEffect(()=>{let m=!0,p=null;return h("loading"),Ul(t.id).then(y=>{if(m){if(!y){h("missing");return}i(hD(new TextDecoder("utf-8").decode(y))),c(y.byteLength),p=URL.createObjectURL(new Blob([y],{type:wh(t.mime,t.filename)})),l(p),h("ready")}}).catch(()=>{m&&h("error")}),()=>{m=!1,p&&URL.revokeObjectURL(p)}},[t.id,t.mime,t.filename]),v.jsx(Ds,{title:t.filename,description:"HTML preview · sandboxed, static rendering only",onClose:e.onClose,wide:!0,className:"markdown-modal html-modal",children:v.jsxs("div",{className:"html-preview",children:[v.jsxs("div",{className:"html-preview-toolbar",children:[v.jsxs("span",{className:"html-preview-shield",children:[v.jsx(Ee,{name:"shield",size:14}),"Scripts, forms and network requests are blocked"]}),s&&v.jsxs("a",{className:"btn sm",href:s,download:t.filename,children:[v.jsx(Ee,{name:"download",size:14}),"Download original",a?` · ${Fr(a)}`:""]})]}),v.jsxs("div",{className:"html-preview-frame",children:[d==="loading"&&v.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),d==="missing"&&v.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),d==="error"&&v.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),d==="ready"&&v.jsx("iframe",{className:"html-preview-iframe",title:`Sandboxed preview of ${t.filename}`,sandbox:lD,referrerPolicy:"no-referrer",srcDoc:n})]})]})})}function Uk(e){const t=(n,i)=>{const{key:s}=n;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(s))return;n.preventDefault();const l=e.options.length-1,a=s==="Home"?0:s==="End"?l:s==="ArrowLeft"||s==="ArrowUp"?(i-1+e.options.length)%e.options.length:(i+1)%e.options.length,c=e.options[a];c&&(e.onChange(c.id),document.getElementById(`${e.idPrefix}-${c.id}`)?.focus())};return v.jsx("div",{className:e.className,role:"tablist","aria-label":e.label,children:e.options.map((n,i)=>v.jsxs("button",{id:`${e.idPrefix}-${n.id}`,type:"button",role:"tab","aria-selected":e.value===n.id,"aria-controls":e.panelId,tabIndex:e.value===n.id?0:-1,className:"tab"+(e.value===n.id?" active":""),onClick:()=>e.onChange(n.id),onKeyDown:s=>t(s,i),children:[n.label,n.count===void 0?null:v.jsxs(v.Fragment,{children:[" ",v.jsx("span",{children:n.count})]})]},n.id))})}function Md(e){const{message:t}=e,[n,i]=k.useState(null),[s,l]=k.useState(0),a=S0(t.wireId)??{id:t.wireId,dir:t.dir,filename:t.filename??"file",mime:t.mime??"application/octet-stream",size:s,date:t.date};k.useEffect(()=>{let h=!0,m=null;if(t.wireId)return Ul(t.wireId).then(p=>{!h||!p||(l(p.byteLength),m=URL.createObjectURL(new Blob([p],{type:wh(a.mime,a.filename)})),i(m))}).catch(()=>{}),()=>{h=!1,m&&URL.revokeObjectURL(m)}},[t.wireId,a.mime,a.filename]);const c=cd(t)==="photo",d=eo(a.mime,a.filename);return v.jsxs("div",{className:"shared-media-item"+(c?" shared-photo-item":""),children:[v.jsxs("button",{className:"shared-media-jump",onClick:()=>e.onJump(e.messageKey),children:[c&&n?v.jsx("img",{src:n,alt:a.filename}):v.jsx("span",{className:"shared-media-icon",children:v.jsx(Ee,{name:d?"mic":"copy",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:c?a.filename||"Photo":d?"Voice message":a.filename}),v.jsxs("span",{children:[e.versionLabel?`${e.versionLabel} · `:"",ys(a.date),s?` · ${Fr(s)}`:""]})]})]}),v.jsxs("span",{className:"shared-media-actions",children:[d1(a.filename)&&n&&v.jsx("button",{className:"icon-btn",title:"Preview markdown",onClick:()=>e.onPreview(a),children:v.jsx(Ee,{name:"monitor",size:16})}),As(a.filename,a.mime)&&n&&v.jsx("button",{className:"icon-btn",title:"Preview HTML",onClick:()=>e.onPreview(a),children:v.jsx(Ee,{name:"monitor",size:16})}),v.jsx("a",{className:"icon-btn"+(n?"":" disabled"),href:n??void 0,download:a.filename,title:"Download",children:v.jsx(Ee,{name:"download",size:16})})]})]})}function jF(e){const[t,n]=k.useState(!1);if(e.versions.length===1){const i=e.versions[0];return v.jsx(Md,{message:i.message,messageKey:i.key,onJump:e.onJump,onPreview:e.onPreview})}return v.jsxs("div",{className:"file-version-stack"+(t?" expanded":""),children:[v.jsxs("button",{className:"file-version-stack-head",onClick:()=>n(i=>!i),children:[v.jsx("span",{className:"shared-media-icon",children:v.jsx(Ee,{name:"copy",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:e.filename}),v.jsxs("span",{children:[e.versions.length," versions · newest ",ys(e.versions[0].message.date)]})]}),v.jsx(Ee,{name:t?"chevronDown":"chevron",size:16})]}),t&&v.jsx("div",{className:"file-version-stack-list",children:e.versions.map((i,s)=>v.jsx(Md,{message:i.message,messageKey:i.key,versionLabel:`Version ${e.versions.length-s}`,onJump:e.onJump,onPreview:e.onPreview},i.key))})]})}function DF(e){const[t,n]=k.useState("photo"),i=e.messages.map((h,m)=>({message:h,key:h.wireId||`${h.date}-${(e.indexOffset??0)+m}`})),s=i.filter(({message:h})=>cd(h)==="photo"),l=i.filter(({message:h})=>cd(h)==="file"),a=nD(l),c=i.flatMap(({message:h,key:m})=>h.kind==="file"?[]:tD(h.text).map(p=>({url:p,message:h,key:m}))),d=[{id:"photo",label:"Photos",count:s.length},{id:"file",label:"Files",count:l.length},{id:"link",label:"Links",count:c.length}];return v.jsx(Ds,{title:"Shared media",description:"Photos, files, and links from this conversation",onClose:e.onClose,wide:!0,className:"shared-media-modal",tabs:v.jsx(Uk,{className:"shared-media-tabs",label:"Shared media type",options:d,value:t,onChange:n,idPrefix:"shared-media-tab",panelId:"shared-media-panel"}),children:v.jsxs("div",{id:"shared-media-panel",role:"tabpanel","aria-labelledby":`shared-media-tab-${t}`,className:"shared-media-list"+(t==="photo"?" photos":""),children:[t==="photo"&&s.map(h=>v.jsx(Md,{message:h.message,messageKey:h.key,onJump:e.onJump,onPreview:e.onPreview},h.key)),t==="file"&&a.map(h=>v.jsx(jF,{filename:h.filename,versions:h.versions,onJump:e.onJump,onPreview:e.onPreview},h.filename)),t==="link"&&c.map((h,m)=>v.jsxs("div",{className:"shared-media-item",children:[v.jsxs("a",{className:"shared-media-jump",href:h.url,target:"_blank",rel:"noreferrer",children:[v.jsx("span",{className:"shared-media-icon",children:v.jsx(Ee,{name:"link",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:h.url}),v.jsx("span",{children:ys(h.message.date)})]})]}),v.jsx("button",{className:"icon-btn",title:"Jump to message",onClick:()=>e.onJump(h.key),children:v.jsx(Ee,{name:"reply",size:16})})]},`${h.key}-${h.url}-${m}`)),(t==="photo"&&s.length===0||t==="file"&&l.length===0||t==="link"&&c.length===0)&&v.jsxs("div",{className:"markdown-empty",children:["No ",t==="photo"?"photos":`${t}s`," in this chat yet."]})]})})}const _F=Object.freeze(["image/avif","image/bmp","image/heic","image/heif","image/jpeg","image/jpg","image/png","image/webp"]),LF=/\.(avif|bmp|heic|heif|jpe?g|png|webp)$/i;function Wk(e,t=""){return _F.includes(String(e??"").toLowerCase())||LF.test(String(t??""))}function OF(e){return`${(String(e||"photo").trim()||"photo").replace(/\.[^./\\]+$/,"")||"photo"}.jpg`}function FF(e,t,n){const i=Math.max(1,Number(e)||1),s=Math.max(1,Number(t)||1),l=Math.max(1,Number(n)||1),a=Math.min(1,l/Math.max(i,s));return{width:Math.max(1,Math.round(i*a)),height:Math.max(1,Math.round(s*a))}}const zF=2048,VF=640,BF=.82,$F=[.84,.7,.56,.44],UF=.94;function WF(e){return new Promise((t,n)=>{const i=URL.createObjectURL(e),s=new Image,l=()=>URL.revokeObjectURL(i);s.onload=()=>t({image:s,release:l}),s.onerror=()=>{l(),n(new Error("This browser could not decode the selected image."))},s.src=i})}function HF(e,t){return new Promise((n,i)=>{e.toBlob(s=>s?n(s):i(new Error("This browser could not encode the optimized photo.")),"image/jpeg",t)})}async function KF(e,t){if(!Wk(e.type,e.name))throw new Error("This image format cannot be optimized safely in this browser.");const n=Math.max(1,Math.floor(t*UF)),{image:i,release:s}=await WF(e),l=document.createElement("canvas"),a=l.getContext("2d",{alpha:!1});if(!a)throw s(),new Error("Photo optimization is unavailable in this browser.");try{let c=Math.min(zF,Math.max(i.naturalWidth,i.naturalHeight));for(;c>=VF;){const d=FF(i.naturalWidth,i.naturalHeight,c);l.width=d.width,l.height=d.height,a.fillStyle="#fff",a.fillRect(0,0,l.width,l.height),a.drawImage(i,0,0,l.width,l.height);for(const h of $F){const m=await HF(l,h);if(m.size<=n)return{filename:OF(e.name),mime:"image/jpeg",bytes:new Uint8Array(await m.arrayBuffer()),width:l.width,height:l.height,originalSize:e.size}}c=Math.floor(c*BF)}}finally{s(),l.width=1,l.height=1}throw new Error("The photo is still too large after optimization.")}const qF=5e4,XF=new Set(["http:","https:","mailto:"]);function Hk(e){if(!(!e||e!==e.trim()||/[\u0000-\u001f\u007f]/u.test(e)))try{const t=new URL(e);return XF.has(t.protocol.toLowerCase())?e:void 0}catch{return}}function Kk(e){const t="language-";return e?.startsWith(t)&&e.slice(t.length)||void 0}function YF(e){return e.split(/(\n[ \t]*\n)/).map(t=>{if(/^\n[ \t]*\n$/.test(t))return t;const n=t.split(`
|
|
317
|
+
`}),n}function sx(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ax(e,t){const n=BO(e,t),i=n.one(e,void 0),s=zO(n),l=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return s&&l.children.push({type:"text",value:`
|
|
318
|
+
`},s),l}function KO(e,t){return e&&"run"in e?async function(n,i){const s=ax(n,{file:i,...t});await e.run(s,i)}:function(n,i){return ax(n,{file:i,...e||t})}}function lx(e){if(e)throw e}var yf,ux;function qO(){if(ux)return yf;ux=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},l=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),p=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!p)return!1;var y;for(y in h);return typeof y>"u"||e.call(h,y)},a=function(h,m){n&&m.name==="__proto__"?n(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},c=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(i)return i(h,m).value}else return;return h[m]};return yf=function d(){var h,m,p,y,w,S,C=arguments[0],E=1,T=arguments.length,M=!1;for(typeof C=="boolean"&&(M=C,C=arguments[1]||{},E=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});E<T;++E)if(h=arguments[E],h!=null)for(m in h)p=c(C,m),y=c(h,m),C!==y&&(M&&y&&(l(y)||(w=s(y)))?(w?(w=!1,S=p&&s(p)?p:[]):S=p&&l(p)?p:{},a(C,{name:m,newValue:d(M,S,y)})):typeof y<"u"&&a(C,{name:m,newValue:y}));return C},yf}var XO=qO();const vf=Id(XO);function Pd(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function YO(){const e=[],t={run:n,use:i};return t;function n(...s){let l=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);c(null,...s);function c(d,...h){const m=e[++l];let p=-1;if(d){a(d);return}for(;++p<s.length;)(h[p]===null||h[p]===void 0)&&(h[p]=s[p]);s=h,m?GO(m,c)(...h):a(null,...h)}}function i(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function GO(e,t){let n;return i;function i(...a){const c=e.length>a.length;let d;c&&a.push(s);try{d=e.apply(this,a)}catch(h){const m=h;if(c&&n)throw m;return s(m)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,s):d instanceof Error?s(d):l(d))}function s(a,...c){n||(n=!0,t(a,...c))}function l(a){s(null,a)}}const Un={basename:QO,dirname:ZO,extname:JO,join:eF,sep:"/"};function QO(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');js(e);let n=0,i=-1,s=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(l){n=s+1;break}}else i<0&&(l=!0,i=s+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let a=-1,c=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(l){n=s+1;break}}else a<0&&(l=!0,a=s+1),c>-1&&(e.codePointAt(s)===t.codePointAt(c--)?c<0&&(i=s):(c=-1,i=a));return n===i?i=a:i<0&&(i=e.length),e.slice(n,i)}function ZO(e){if(js(e),e.length===0)return".";let t=-1,n=e.length,i;for(;--n;)if(e.codePointAt(n)===47){if(i){t=n;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function JO(e){js(e);let t=e.length,n=-1,i=0,s=-1,l=0,a;for(;t--;){const c=e.codePointAt(t);if(c===47){if(a){i=t+1;break}continue}n<0&&(a=!0,n=t+1),c===46?s<0?s=t:l!==1&&(l=1):s>-1&&(l=-1)}return s<0||n<0||l===0||l===1&&s===n-1&&s===i+1?"":e.slice(s,n)}function eF(...e){let t=-1,n;for(;++t<e.length;)js(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":tF(n)}function tF(e){js(e);const t=e.codePointAt(0)===47;let n=nF(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function nF(e,t){let n="",i=0,s=-1,l=0,a=-1,c,d;for(;++a<=e.length;){if(a<e.length)c=e.codePointAt(a);else{if(c===47)break;c=47}if(c===47){if(!(s===a-1||l===1))if(s!==a-1&&l===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",i=0):(n=n.slice(0,d),i=n.length-1-n.lastIndexOf("/")),s=a,l=0;continue}}else if(n.length>0){n="",i=0,s=a,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),i=a-s-1;s=a,l=0}else c===46&&l>-1?l++:l=-1}return n}function js(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const rF={cwd:iF};function iF(){return"/"}function Rd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function oF(e){if(typeof e=="string")e=new URL(e);else if(!Rd(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return sF(e)}function sF(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const i=t.codePointAt(n+2);if(i===70||i===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const xf=["history","path","basename","stem","extname","dirname"];class Fk{constructor(t){let n;t?Rd(t)?n={path:t}:typeof t=="string"||aF(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":rF.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<xf.length;){const l=xf[i];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let s;for(s in n)xf.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Un.basename(this.path):void 0}set basename(t){kf(t,"basename"),wf(t,"basename"),this.path=Un.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Un.dirname(this.path):void 0}set dirname(t){cx(this.basename,"dirname"),this.path=Un.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Un.extname(this.path):void 0}set extname(t){if(wf(t,"extname"),cx(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Un.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Rd(t)&&(t=oF(t)),kf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Un.basename(this.path,this.extname):void 0}set stem(t){kf(t,"stem"),wf(t,"stem"),this.path=Un.join(this.dirname||"",t+(this.extname||""))}fail(t,n,i){const s=this.message(t,n,i);throw s.fatal=!0,s}info(t,n,i){const s=this.message(t,n,i);return s.fatal=void 0,s}message(t,n,i){const s=new zt(t,n,i);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function wf(e,t){if(e&&e.includes(Un.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Un.sep+"`")}function kf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function cx(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function aF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const lF=function(e){const i=this.constructor.prototype,s=i[e],l=function(){return s.apply(l,arguments)};return Object.setPrototypeOf(l,i),l},uF={}.hasOwnProperty;class Wh extends lF{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=YO()}copy(){const t=new Wh;let n=-1;for(;++n<this.attachers.length;){const i=this.attachers[n];t.use(...i)}return t.data(vf(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Cf("data",this.frozen),this.namespace[t]=n,this):uF.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Cf("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const s=n.call(t,...i);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=rl(t),i=this.parser||this.Parser;return Sf("parse",i),i(String(n),n)}process(t,n){const i=this;return this.freeze(),Sf("process",this.parser||this.Parser),bf("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(l,a){const c=rl(t),d=i.parse(c);i.run(d,c,function(m,p,y){if(m||!p||!y)return h(m);const w=p,S=i.stringify(w,y);dF(S)?y.value=S:y.result=S,h(m,y)});function h(m,p){m||!p?a(m):l?l(p):n(void 0,p)}}}processSync(t){let n=!1,i;return this.freeze(),Sf("processSync",this.parser||this.Parser),bf("processSync",this.compiler||this.Compiler),this.process(t,s),dx("processSync","process",n),i;function s(l,a){n=!0,lx(l),i=a}}run(t,n,i){fx(t),this.freeze();const s=this.transformers;return!i&&typeof n=="function"&&(i=n,n=void 0),i?l(void 0,i):new Promise(l);function l(a,c){const d=rl(n);s.run(t,d,h);function h(m,p,y){const w=p||t;m?c(m):a?a(w):i(void 0,w,y)}}}runSync(t,n){let i=!1,s;return this.run(t,n,l),dx("runSync","run",i),s;function l(a,c){lx(a),s=c,i=!0}}stringify(t,n){this.freeze();const i=rl(n),s=this.compiler||this.Compiler;return bf("stringify",s),fx(t),s(t,i)}use(t,...n){const i=this.attachers,s=this.namespace;if(Cf("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...p]=h;d(m,p)}else a(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function a(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(h.plugins),h.settings&&(s.settings=vf(!0,s.settings,h.settings))}function c(h){let m=-1;if(h!=null)if(Array.isArray(h))for(;++m<h.length;){const p=h[m];l(p)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,m){let p=-1,y=-1;for(;++p<i.length;)if(i[p][0]===h){y=p;break}if(y===-1)i.push([h,...m]);else if(m.length>0){let[w,...S]=m;const C=i[y][1];Pd(C)&&Pd(w)&&(w=vf(!0,C,w)),i[y]=[h,w,...S]}}}}const cF=new Wh().freeze();function Sf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function bf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Cf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function fx(e){if(!Pd(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function dx(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function rl(e){return fF(e)?e:new Fk(e)}function fF(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function dF(e){return typeof e=="string"||hF(e)}function hF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const pF="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",hx=[],px={allowDangerousHtml:!0},mF=/^(https?|ircs?|mailto|xmpp)$/i,gF=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function zk(e){const t=yF(e),n=vF(e);return xF(t.runSync(t.parse(n),n),e)}function yF(e){const t=e.rehypePlugins||hx,n=e.remarkPlugins||hx,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...px}:px;return cF().use(sO).use(n).use(KO,i).use(t)}function vF(e){const t=e.children||"",n=new Fk;return typeof t=="string"&&(n.value=t),n}function xF(e,t){const n=t.allowedElements,i=t.allowElement,s=t.components,l=t.disallowedElements,a=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||wF;for(const m of gF)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+pF+m.id,void 0);return ph(e,h),WL(e,{Fragment:v.Fragment,components:s,ignoreInvalidStyle:!0,jsx:v.jsx,jsxs:v.jsxs,passKeys:!0,passNode:!0});function h(m,p,y){if(m.type==="raw"&&y&&typeof p=="number")return a?y.children.splice(p,1):y.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let w;for(w in gf)if(Object.hasOwn(gf,w)&&Object.hasOwn(m.properties,w)){const S=m.properties[w],C=gf[w];(C===null||C.includes(m.tagName))&&(m.properties[w]=d(String(S||""),w,m))}}if(m.type==="element"){let w=n?!n.includes(m.tagName):l?l.includes(m.tagName):!1;if(!w&&i&&typeof p=="number"&&(w=!i(m,p,y)),w&&y&&typeof p=="number")return c&&m.children?y.children.splice(p,1,...m.children):y.children.splice(p,1),p}}}function wF(e){const t=e.indexOf(":"),n=e.indexOf("?"),i=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||i!==-1&&t>i||mF.test(e.slice(0,t))?e:""}const kF={};function Vk(e){const t=this,n=e||kF,i=t.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),l=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(f1(n)),l.push(U0()),a.push(RN(n))}function Ds(e){const t=k.useRef(null);return k.useEffect(()=>(t.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>{const n=t.current;n?.isConnected&&requestAnimationFrame(()=>n.focus())}),[]),v.jsx(uk,{open:!0,onOpenChange:n=>{n||e.onClose()},children:v.jsxs(dk,{children:[v.jsx(hk,{className:"modal-backdrop"}),v.jsxs(pk,{id:e.contentId,className:"modal"+(e.wide?" modal-wide":"")+(e.className?` ${e.className}`:""),children:[v.jsxs("div",{className:"modal-head",children:[v.jsxs("div",{children:[v.jsx(gk,{asChild:!0,children:v.jsx("h3",{children:e.title})}),e.description&&v.jsx(yk,{className:"modal-description",children:e.description})]}),v.jsx(vk,{asChild:!0,children:v.jsx("button",{className:"icon-btn","aria-label":`Close ${e.title}`,children:v.jsx(Ee,{name:"close"})})})]}),e.tabs,v.jsx("div",{className:"modal-body",children:e.children})]})]})})}const SF=.25,bF=8;let mx=Promise.resolve();function gx(){return document.documentElement.classList.contains("theme-dark")?"dark":"default"}function CF(){const[e,t]=k.useState(gx);return k.useEffect(()=>{const n=document.documentElement,i=()=>t(gx()),s=new MutationObserver(i);return s.observe(n,{attributes:!0,attributeFilter:["class"]}),i(),()=>s.disconnect()},[]),e}function EF(e,t,n){const i=mx.then(async()=>{const{default:s}=await Ch(async()=>{const{default:l}=await import("./mermaid.core-DFaFLwYZ.js").then(a=>a.bp);return{default:l}},[]);return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:n,fontFamily:"var(--sans)"}),s.render(e,t)});return mx=i.then(()=>{},()=>{}),i}function TF(e){return Math.min(bF,Math.max(SF,e))}function PF(e){const t=k.useRef(null),n=k.useRef(null),[i,s]=k.useState(1),[l,a]=k.useState({x:0,y:0}),[c,d]=k.useState(!1),h=()=>{s(1),a({x:0,y:0})},m=(p,y,w)=>{const S=TF(p);if(S===i)return;const C=t.current?.getBoundingClientRect();if(C){const E=(y??C.left+C.width/2)-C.left-C.width/2,T=(w??C.top+C.height/2)-C.top-C.height/2,M=S/i;a(P=>({x:E-M*(E-P.x),y:T-M*(T-P.y)}))}s(S)};return k.useEffect(()=>{const p=y=>{y.key==="+"||y.key==="="?(y.preventDefault(),m(i*1.25)):y.key==="-"?(y.preventDefault(),m(i/1.25)):y.key==="0"&&(y.preventDefault(),h())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)}),v.jsx(uk,{open:!0,onOpenChange:p=>{p||e.onClose()},children:v.jsxs(dk,{children:[v.jsx(hk,{className:"mermaid-fullscreen-backdrop"}),v.jsxs(pk,{className:"mermaid-fullscreen","data-mermaid-theme":e.theme,"aria-describedby":"mermaid-fullscreen-help",children:[v.jsx(gk,{className:"mermaid-fullscreen-title",children:"Diagram viewer"}),v.jsxs("div",{className:"mermaid-fullscreen-tools",children:[v.jsx("button",{className:"icon-btn","aria-label":"Zoom out",title:"Zoom out (−)",onClick:()=>m(i/1.25),children:v.jsx(Ee,{name:"minus"})}),v.jsxs("button",{className:"mermaid-zoom-value",onClick:h,title:"Reset zoom and position",children:[Math.round(i*100),"%"]}),v.jsx("button",{className:"icon-btn","aria-label":"Zoom in",title:"Zoom in (+)",onClick:()=>m(i*1.25),children:v.jsx(Ee,{name:"plus"})}),v.jsx(vk,{asChild:!0,children:v.jsx("button",{className:"icon-btn","aria-label":"Close diagram viewer",title:"Close (Esc)",children:v.jsx(Ee,{name:"close"})})})]}),v.jsx("div",{ref:t,className:"mermaid-fullscreen-viewport"+(c?" dragging":""),onWheel:p=>{p.preventDefault(),m(i*Math.exp(-p.deltaY*.0015),p.clientX,p.clientY)},onDoubleClick:p=>m(i*1.5,p.clientX,p.clientY),onPointerDown:p=>{p.button===0&&(n.current={pointerId:p.pointerId,startX:p.clientX,startY:p.clientY,panX:l.x,panY:l.y},p.currentTarget.setPointerCapture(p.pointerId),d(!0))},onPointerMove:p=>{const y=n.current;!y||y.pointerId!==p.pointerId||a({x:y.panX+p.clientX-y.startX,y:y.panY+p.clientY-y.startY})},onPointerUp:p=>{n.current?.pointerId===p.pointerId&&(n.current=null,d(!1),p.currentTarget.releasePointerCapture(p.pointerId))},onPointerCancel:()=>{n.current=null,d(!1)},children:v.jsx("div",{className:"mermaid-fullscreen-canvas",style:{transform:`translate(${l.x}px, ${l.y}px) scale(${i})`},dangerouslySetInnerHTML:{__html:e.svg}})}),v.jsx(yk,{id:"mermaid-fullscreen-help",className:"mermaid-fullscreen-help",children:"Scroll to zoom · drag to move · double-click to zoom in"})]})]})})}function RF({source:e}){const t=k.useId(),[n,i]=k.useState(""),[s,l]=k.useState(""),[a,c]=k.useState("default"),[d,h]=k.useState(!1),m=CF();return k.useEffect(()=>{let p=!0;const y=`mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"")}`;return i(""),l(""),EF(y,e,m).then(w=>{p&&(c(m),i(w.svg))}).catch(w=>{p&&l(w instanceof Error?w.message:String(w))}),()=>{p=!1,document.getElementById(`d${y}`)?.remove()}},[t,e,m]),s?v.jsxs("pre",{className:"markdown-mermaid-error",children:["Mermaid error: ",s]}):n?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"markdown-mermaid","data-mermaid-theme":a,children:[v.jsx("button",{className:"icon-btn markdown-mermaid-expand","aria-label":"View diagram fullscreen",title:"View diagram fullscreen",onClick:()=>h(!0),children:v.jsx(Ee,{name:"maximize"})}),v.jsx("div",{className:"markdown-mermaid-diagram",dangerouslySetInnerHTML:{__html:n}})]}),d&&v.jsx(PF,{svg:n,theme:a,onClose:()=>h(!1)})]}):v.jsx("div",{className:"markdown-mermaid-loading",children:"Rendering diagram…"})}const MF=k.memo(function(t){return v.jsx("article",{className:"markdown-body",ref:t.contentRef,children:v.jsx(zk,{remarkPlugins:[Vk],components:{a:({children:n,...i})=>v.jsx("a",{...i,target:"_blank",rel:"noreferrer",children:n}),code:({className:n,children:i,...s})=>{const l=/language-([\w-]+)/.exec(n??"")?.[1],a=String(i).replace(/\n$/,"");return l==="mermaid"?v.jsx(RF,{source:a}):v.jsx("code",{className:n,...s,children:i})}},children:t.markdown})})});function Bk(e){const{rec:t}=e,n=k.useRef(null),[i,s]=k.useState(""),[l,a]=k.useState(null),[c,d]=k.useState("loading"),[h,m]=k.useState(""),[p,y]=k.useState(0),[w,S]=k.useState(""),[C,E]=k.useState(0),[T,M]=k.useState(!1),[P,D]=k.useState(""),[$,j]=k.useState(!1),[Y,U]=k.useState(!1),[O,N]=k.useState([]),[X,V]=k.useState(!1),[fe,J]=k.useState(null),[ee,xe]=k.useState(!1),[Pe,Q]=k.useState("");k.useEffect(()=>{let A=!0,te=null;return d("loading"),Ul(t.id).then(ge=>{if(A){if(!ge){d("missing");return}s(new TextDecoder("utf-8").decode(ge)),te=URL.createObjectURL(new Blob([ge],{type:"text/markdown;charset=utf-8"})),a(te),d("ready")}}).catch(()=>{A&&d("error")}),()=>{A=!1,te&&URL.revokeObjectURL(te)}},[t.id]),k.useEffect(()=>{const A=()=>{const te=window.getSelection(),ge=n.current;if(!te||te.isCollapsed||!ge){m(""),y(0);return}if(!ge.contains(te.anchorNode)||!ge.contains(te.focusNode)){m(""),y(0);return}const ye=te.getRangeAt(0),me=te.toString(),we=me.length-me.trimStart().length,pe=me.trim().slice(0,4e3),Ve=document.createRange();Ve.selectNodeContents(ge),Ve.setEnd(ye.startContainer,ye.startOffset);const qe=Ve.toString().length+we;m(pe),y(eD(ge.textContent,pe,qe))};return document.addEventListener("selectionchange",A),()=>document.removeEventListener("selectionchange",A)},[]);const de=()=>{h&&(S(h),E(p),M(!0),Q(""))},R=async()=>{if(Y){if(!w||!P.trim())return;N(te=>[...te,{selection:w,comment:P.trim(),occurrence:C}]),D(""),M(!1),Q("Comment added to review");return}const A=Zj(w,P);if(!(!A||!P.trim()||$)){j(!0),Q("");try{await e.onSendText(A,t.id||void 0),D(""),M(!1),Q("Feedback sent")}catch(te){Q(`Send failed: ${String(te)}`)}finally{j(!1)}}},F=async()=>{if(O.length===0||X)return;const A=sD(i,O);V(!0),Q("");try{e.onSendFile?await e.onSendFile({filename:Jj(t.filename),mime:"text/markdown",bytes:new TextEncoder().encode(A)},t.id||void 0):await e.onSendText(A,t.id||void 0),N([]),U(!1),Q("Review submitted")}catch(te){Q(`Review send failed: ${String(te)}`)}finally{V(!1)}},G=async()=>{if(!(!fe||!e.onSendFile||ee)){xe(!0),Q("");try{await e.onSendFile(fe,t.id||void 0),J(null),Q("Voice feedback sent")}catch(A){Q(`Voice send failed: ${String(A)}`)}finally{xe(!1)}}};return v.jsx(Ds,{title:t.filename,description:"Markdown preview · select text to send precise feedback",onClose:e.onClose,wide:!0,className:"markdown-modal",children:v.jsxs("div",{className:"markdown-preview",children:[v.jsxs("div",{className:"markdown-review-toolbar",children:[v.jsxs("button",{className:"btn sm",disabled:!h,onMouseDown:A=>A.preventDefault(),onClick:de,children:[v.jsx(Ee,{name:"reply",size:14}),Y?"Add review comment":"Quick message",h?` (${h.length})`:""]}),Y?v.jsx("button",{className:"btn sm",onClick:()=>{U(!1),N([]),M(!1),Q("Review discarded")},children:"Cancel review"}):v.jsxs("button",{className:"btn sm",onClick:()=>{U(!0),N([]),Q("Review started — select passages to add comments")},children:[v.jsx(Ee,{name:"edit",size:14}),"Start review"]}),l&&v.jsxs("a",{className:"btn sm",href:l,download:t.filename,children:[v.jsx(Ee,{name:"download",size:14}),"Download"]}),e.onSendFile&&v.jsx(k1,{disabled:!!fe||ee,onReady:J,onError:Q}),v.jsx("span",{className:"markdown-review-hint",children:h?"Selection ready for feedback":"Highlight any passage to comment on it"})]}),T&&v.jsxs("div",{className:"markdown-feedback",children:[v.jsx("blockquote",{children:w}),v.jsx("textarea",{className:"field",rows:3,autoFocus:!0,placeholder:"What should change?",value:P,onChange:A=>D(A.target.value)}),v.jsxs("div",{className:"markdown-feedback-actions",children:[v.jsx("button",{className:"btn sm",onClick:()=>M(!1),children:"Cancel"}),v.jsxs("button",{className:"btn sm primary",disabled:!P.trim()||$,onClick:()=>void R(),children:[v.jsx(Ee,{name:"send",size:14}),Y?"Add to review":$?"Sending…":"Send feedback"]})]})]}),Y&&v.jsxs("div",{className:"markdown-review-draft",children:[v.jsxs("div",{className:"markdown-review-draft-head",children:[v.jsxs("strong",{children:["Review · ",O.length," comment",O.length===1?"":"s"]}),v.jsxs("button",{className:"btn sm primary",disabled:O.length===0||X,onClick:()=>void F(),children:[v.jsx(Ee,{name:"send",size:14}),X?"Submitting…":"Submit review"]})]}),O.map((A,te)=>v.jsxs("div",{className:"markdown-review-comment",children:[v.jsx("span",{children:te+1}),v.jsxs("div",{children:[v.jsx("blockquote",{children:A.selection}),v.jsx("p",{children:A.comment})]}),v.jsx("button",{className:"icon-btn",title:"Remove comment",onClick:()=>N(ge=>ge.filter((ye,me)=>me!==te)),children:v.jsx(Ee,{name:"close",size:14})})]},`${te}-${A.selection.slice(0,24)}`))]}),fe&&v.jsx(w1,{att:fe,sending:ee,onSend:()=>void G(),onDiscard:()=>J(null)}),Pe&&v.jsx("div",{className:"markdown-review-status",role:"status",children:Pe}),v.jsxs("div",{className:"markdown-preview-scroll",children:[c==="loading"&&v.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),c==="missing"&&v.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),c==="error"&&v.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),c==="ready"&&v.jsx(MF,{markdown:i,contentRef:n})]})]})})}function $k(e){const{rec:t}=e,[n,i]=k.useState(null),[s,l]=k.useState(0),[a,c]=k.useState("loading");return k.useEffect(()=>{let d=!0,h=null;return c("loading"),Ul(t.id).then(m=>{if(d){if(!m){c("missing");return}l(m.byteLength),h=URL.createObjectURL(new Blob([m],{type:wh(t.mime,t.filename)})),i(h),c("ready")}}).catch(()=>{d&&c("error")}),()=>{d=!1,h&&URL.revokeObjectURL(h)}},[t.id,t.mime,t.filename]),v.jsx(Ds,{title:t.filename,description:"Transformed safe preview · external navigation disabled",onClose:e.onClose,wide:!0,className:"markdown-modal html-modal",children:v.jsxs("div",{className:"html-preview",children:[v.jsxs("div",{className:"html-preview-toolbar",children:[v.jsxs("span",{className:"html-preview-shield",children:[v.jsx(Ee,{name:"shield",size:14}),"Scripts, forms and network requests are blocked"]}),n&&v.jsxs("a",{className:"btn sm",href:n,download:t.filename,children:[v.jsx(Ee,{name:"download",size:14}),"Download original",s?` · ${Fr(s)}`:""]})]}),v.jsxs("div",{className:"html-preview-frame",children:[a==="loading"&&v.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),a==="missing"&&v.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),a==="error"&&v.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),a==="ready"&&v.jsx("iframe",{className:"html-preview-iframe",title:`Sandboxed preview of ${t.filename}`,sandbox:aD,referrerPolicy:"no-referrer",src:`/api/html-preview/${encodeURIComponent(t.id)}`},t.id)]})]})})}function Uk(e){const t=(n,i)=>{const{key:s}=n;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(s))return;n.preventDefault();const l=e.options.length-1,a=s==="Home"?0:s==="End"?l:s==="ArrowLeft"||s==="ArrowUp"?(i-1+e.options.length)%e.options.length:(i+1)%e.options.length,c=e.options[a];c&&(e.onChange(c.id),document.getElementById(`${e.idPrefix}-${c.id}`)?.focus())};return v.jsx("div",{className:e.className,role:"tablist","aria-label":e.label,children:e.options.map((n,i)=>v.jsxs("button",{id:`${e.idPrefix}-${n.id}`,type:"button",role:"tab","aria-selected":e.value===n.id,"aria-controls":e.panelId,tabIndex:e.value===n.id?0:-1,className:"tab"+(e.value===n.id?" active":""),onClick:()=>e.onChange(n.id),onKeyDown:s=>t(s,i),children:[n.label,n.count===void 0?null:v.jsxs(v.Fragment,{children:[" ",v.jsx("span",{children:n.count})]})]},n.id))})}function Md(e){const{message:t}=e,[n,i]=k.useState(null),[s,l]=k.useState(0),a=S0(t.wireId)??{id:t.wireId,dir:t.dir,filename:t.filename??"file",mime:t.mime??"application/octet-stream",size:s,date:t.date};k.useEffect(()=>{let h=!0,m=null;if(t.wireId)return Ul(t.wireId).then(p=>{!h||!p||(l(p.byteLength),m=URL.createObjectURL(new Blob([p],{type:wh(a.mime,a.filename)})),i(m))}).catch(()=>{}),()=>{h=!1,m&&URL.revokeObjectURL(m)}},[t.wireId,a.mime,a.filename]);const c=cd(t)==="photo",d=eo(a.mime,a.filename);return v.jsxs("div",{className:"shared-media-item"+(c?" shared-photo-item":""),children:[v.jsxs("button",{className:"shared-media-jump",onClick:()=>e.onJump(e.messageKey),children:[c&&n?v.jsx("img",{src:n,alt:a.filename}):v.jsx("span",{className:"shared-media-icon",children:v.jsx(Ee,{name:d?"mic":"copy",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:c?a.filename||"Photo":d?"Voice message":a.filename}),v.jsxs("span",{children:[e.versionLabel?`${e.versionLabel} · `:"",ys(a.date),s?` · ${Fr(s)}`:""]})]})]}),v.jsxs("span",{className:"shared-media-actions",children:[d1(a.filename)&&n&&v.jsx("button",{className:"icon-btn",title:"Preview markdown",onClick:()=>e.onPreview(a),children:v.jsx(Ee,{name:"monitor",size:16})}),As(a.filename,a.mime)&&n&&v.jsx("button",{className:"icon-btn",title:"Preview HTML",onClick:()=>e.onPreview(a),children:v.jsx(Ee,{name:"monitor",size:16})}),v.jsx("a",{className:"icon-btn"+(n?"":" disabled"),href:n??void 0,download:a.filename,title:"Download",children:v.jsx(Ee,{name:"download",size:16})})]})]})}function AF(e){const[t,n]=k.useState(!1);if(e.versions.length===1){const i=e.versions[0];return v.jsx(Md,{message:i.message,messageKey:i.key,onJump:e.onJump,onPreview:e.onPreview})}return v.jsxs("div",{className:"file-version-stack"+(t?" expanded":""),children:[v.jsxs("button",{className:"file-version-stack-head",onClick:()=>n(i=>!i),children:[v.jsx("span",{className:"shared-media-icon",children:v.jsx(Ee,{name:"copy",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:e.filename}),v.jsxs("span",{children:[e.versions.length," versions · newest ",ys(e.versions[0].message.date)]})]}),v.jsx(Ee,{name:t?"chevronDown":"chevron",size:16})]}),t&&v.jsx("div",{className:"file-version-stack-list",children:e.versions.map((i,s)=>v.jsx(Md,{message:i.message,messageKey:i.key,versionLabel:`Version ${e.versions.length-s}`,onJump:e.onJump,onPreview:e.onPreview},i.key))})]})}function NF(e){const[t,n]=k.useState("photo"),i=e.messages.map((h,m)=>({message:h,key:h.wireId||`${h.date}-${(e.indexOffset??0)+m}`})),s=i.filter(({message:h})=>cd(h)==="photo"),l=i.filter(({message:h})=>cd(h)==="file"),a=nD(l),c=i.flatMap(({message:h,key:m})=>h.kind==="file"?[]:tD(h.text).map(p=>({url:p,message:h,key:m}))),d=[{id:"photo",label:"Photos",count:s.length},{id:"file",label:"Files",count:l.length},{id:"link",label:"Links",count:c.length}];return v.jsx(Ds,{title:"Shared media",description:"Photos, files, and links from this conversation",onClose:e.onClose,wide:!0,className:"shared-media-modal",tabs:v.jsx(Uk,{className:"shared-media-tabs",label:"Shared media type",options:d,value:t,onChange:n,idPrefix:"shared-media-tab",panelId:"shared-media-panel"}),children:v.jsxs("div",{id:"shared-media-panel",role:"tabpanel","aria-labelledby":`shared-media-tab-${t}`,className:"shared-media-list"+(t==="photo"?" photos":""),children:[t==="photo"&&s.map(h=>v.jsx(Md,{message:h.message,messageKey:h.key,onJump:e.onJump,onPreview:e.onPreview},h.key)),t==="file"&&a.map(h=>v.jsx(AF,{filename:h.filename,versions:h.versions,onJump:e.onJump,onPreview:e.onPreview},h.filename)),t==="link"&&c.map((h,m)=>v.jsxs("div",{className:"shared-media-item",children:[v.jsxs("a",{className:"shared-media-jump",href:h.url,target:"_blank",rel:"noreferrer",children:[v.jsx("span",{className:"shared-media-icon",children:v.jsx(Ee,{name:"link",size:18})}),v.jsxs("span",{className:"shared-media-copy",children:[v.jsx("strong",{children:h.url}),v.jsx("span",{children:ys(h.message.date)})]})]}),v.jsx("button",{className:"icon-btn",title:"Jump to message",onClick:()=>e.onJump(h.key),children:v.jsx(Ee,{name:"reply",size:16})})]},`${h.key}-${h.url}-${m}`)),(t==="photo"&&s.length===0||t==="file"&&l.length===0||t==="link"&&c.length===0)&&v.jsxs("div",{className:"markdown-empty",children:["No ",t==="photo"?"photos":`${t}s`," in this chat yet."]})]})})}const IF=Object.freeze(["image/avif","image/bmp","image/heic","image/heif","image/jpeg","image/jpg","image/png","image/webp"]),jF=/\.(avif|bmp|heic|heif|jpe?g|png|webp)$/i;function Wk(e,t=""){return IF.includes(String(e??"").toLowerCase())||jF.test(String(t??""))}function DF(e){return`${(String(e||"photo").trim()||"photo").replace(/\.[^./\\]+$/,"")||"photo"}.jpg`}function _F(e,t,n){const i=Math.max(1,Number(e)||1),s=Math.max(1,Number(t)||1),l=Math.max(1,Number(n)||1),a=Math.min(1,l/Math.max(i,s));return{width:Math.max(1,Math.round(i*a)),height:Math.max(1,Math.round(s*a))}}const LF=2048,OF=640,FF=.82,zF=[.84,.7,.56,.44],VF=.94;function BF(e){return new Promise((t,n)=>{const i=URL.createObjectURL(e),s=new Image,l=()=>URL.revokeObjectURL(i);s.onload=()=>t({image:s,release:l}),s.onerror=()=>{l(),n(new Error("This browser could not decode the selected image."))},s.src=i})}function $F(e,t){return new Promise((n,i)=>{e.toBlob(s=>s?n(s):i(new Error("This browser could not encode the optimized photo.")),"image/jpeg",t)})}async function UF(e,t){if(!Wk(e.type,e.name))throw new Error("This image format cannot be optimized safely in this browser.");const n=Math.max(1,Math.floor(t*VF)),{image:i,release:s}=await BF(e),l=document.createElement("canvas"),a=l.getContext("2d",{alpha:!1});if(!a)throw s(),new Error("Photo optimization is unavailable in this browser.");try{let c=Math.min(LF,Math.max(i.naturalWidth,i.naturalHeight));for(;c>=OF;){const d=_F(i.naturalWidth,i.naturalHeight,c);l.width=d.width,l.height=d.height,a.fillStyle="#fff",a.fillRect(0,0,l.width,l.height),a.drawImage(i,0,0,l.width,l.height);for(const h of zF){const m=await $F(l,h);if(m.size<=n)return{filename:DF(e.name),mime:"image/jpeg",bytes:new Uint8Array(await m.arrayBuffer()),width:l.width,height:l.height,originalSize:e.size}}c=Math.floor(c*FF)}}finally{s(),l.width=1,l.height=1}throw new Error("The photo is still too large after optimization.")}const WF=5e4,HF=new Set(["http:","https:","mailto:"]);function Hk(e){if(!(!e||e!==e.trim()||/[\u0000-\u001f\u007f]/u.test(e)))try{const t=new URL(e);return HF.has(t.protocol.toLowerCase())?e:void 0}catch{return}}function Kk(e){const t="language-";return e?.startsWith(t)&&e.slice(t.length)||void 0}function KF(e){return e.split(/(\n[ \t]*\n)/).map(t=>{if(/^\n[ \t]*\n$/.test(t))return t;const n=t.split(`
|
|
320
319
|
`),i=n.filter(a=>a.trim().length>0);if(i.length===0)return t;const s=i.map(a=>a.match(/^[ \t]+/)?.[0]??"");if(s.some(a=>a.length===0))return t;const l=Math.min(...s.map(a=>a.length));return n.map(a=>a.trim().length>0?a.slice(l):a).join(`
|
|
321
|
-
`)}).join("")}function GF({children:e}){const t=k.isValidElement(e)?e:null,n=Kk(t?.props.className);return v.jsxs("div",{className:"message-code-block","data-language":n||void 0,children:[n&&v.jsx("div",{className:"message-code-language",children:n}),v.jsx("pre",{children:e})]})}const QF=[Vk],ZF={a:({node:e,children:t,href:n,...i})=>{const s=Hk(n);return s?v.jsx("a",{...i,href:s,target:"_blank",rel:"noopener noreferrer",children:t}):v.jsx("span",{className:"message-link-blocked",children:t})},img:({alt:e})=>v.jsxs("span",{className:"message-image-placeholder",children:["[image: ",e||"remote image blocked","]"]}),pre:GF,code:({node:e,className:t,children:n,...i})=>v.jsx("code",{className:t,"data-language":Kk(t),...i,children:n})},yx=k.memo(function({text:t,className:n="bubble-text message-markdown"}){return t.length>qF?v.jsx("div",{className:`${n} message-markdown-plaintext`,"data-render-mode":"plaintext",children:t}):v.jsx("div",{className:n,"data-render-mode":"markdown",children:v.jsx(zk,{remarkPlugins:QF,components:ZF,urlTransform:i=>Hk(i)??"",children:YF(t)})})}),yl={type:"spring",stiffness:430,damping:38,mass:.72},vx=10,qk=56,JF=18,ez=650;function tz(e,t){return Math.abs(e)<vx&&Math.abs(t)<vx?"pending":Math.abs(e)>Math.abs(t)&&e>0?"drag":"reject"}function nz(e){const t=e.at(-1),n=t?e.slice(0,-1).reverse().find(i=>i.x!==t.x&&t.time-i.time<=100):void 0;return n&&t&&t.time>n.time?(t.x-n.x)/(t.time-n.time)*1e3:0}function rz(e,t){const n=nz(t);return n>=0&&(e>=qk||e>=JF&&n>=ez)}const Ad="ours.chats.listMode",cs="recent";function Xk(){try{return globalThis.localStorage}catch{return}}function iz(e=Xk()){try{return e?.getItem(Ad)==="identity"?"identity":cs}catch{return cs}}function oz(e,t=Xk()){const n=e==="identity"?"identity":cs;try{return t?.setItem(Ad,n),t?.getItem(Ad)===n?n:cs}catch{return cs}}function Ss(e){return typeof e=="string"?e:""}function _l(e,t){const n=Ss(e),i=Ss(t),s=n.normalize().toLowerCase(),l=i.normalize().toLowerCase();return s<l?-1:s>l?1:n<i?-1:n>i?1:0}function sz(e,t){const n=Rl(Ss(t.activityAt))-Rl(Ss(e.activityAt));if(n!==0)return n;const i=_l(e.name,t.name);return i!==0?i:_l(e.id,t.id)}function Nd(e){return[...e].sort(sz)}function xx(e){return e.contacts.length>0?Rl(Ss(e.contacts[0].activityAt)):0}function az(e,t){const n=new Map,i=[];for(const l of e){const a=l.root||(t?.[l.id]?l.id:null);if(!a){i.push(l);continue}const c=t?.[a]||{label:a,note:""};let d=n.get(a);d||(d={id:`root:${a}`,rootId:a,label:c.label,note:c.note,contacts:[]},n.set(a,d)),d.contacts.push(l)}const s=[...n.values()].map(l=>({...l,contacts:Nd(l.contacts)}));return i.length>0&&s.push({id:"rootless",rootId:null,label:"Independent identities",note:"People, agents and apps without a verified Human/root group",contacts:Nd(i)}),s.sort((l,a)=>{const c=xx(a)-xx(l);if(c!==0)return c;const d=_l(l.label,a.label);return d!==0?d:_l(l.id,a.id)})}const lz=15e3;function Ef(e){const{c:t,active:n,grouped:i}=e,[s,l]=k.useState(!1),a=async(h,m)=>{if(!(!h||s)){l(!0);try{const p=await h();requestAnimationFrame(()=>{p?document.getElementById("chat-list-title")?.focus():m.focus()})}finally{l(!1)}}},c=v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"contact-avatar","aria-hidden":!0,children:t.initials}),v.jsxs("span",{className:"contact-copy",children:[v.jsxs("span",{className:"contact-row-topline",children:[v.jsx("span",{className:"contact-name",children:t.name}),t.when&&v.jsx("span",{className:"contact-time",children:t.when})]}),v.jsxs("span",{className:"contact-row-bottomline",children:[v.jsx("span",{className:"contact-last",children:t.last}),t.status==="pending"&&v.jsx("span",{className:"chip",children:"pending approval"}),!!t.unread&&v.jsx("span",{className:"contact-unread",children:t.unread})]})]}),t.status==="pending"&&v.jsxs("span",{className:"pending-actions",role:"group","aria-label":`Decide whether to accept ${t.name}`,children:[v.jsx("button",{type:"button",className:"linkbtn",disabled:s,onClick:h=>void a(e.onApprove,h.currentTarget),children:"Approve"}),v.jsx("button",{type:"button",className:"linkbtn quiet",disabled:s,onClick:h=>void a(e.onReject,h.currentTarget),children:"Reject"})]}),n&&v.jsx(ss.span,{className:"contact-active-glow",layoutId:"active-contact",transition:yl})]}),d="contact-row"+(n?" active":"")+(i?" grouped":"")+(t.status==="pending"?" pending":"");return t.status==="pending"?v.jsx("div",{className:d,children:c}):v.jsx(ss.button,{type:"button",className:d,onClick:e.onClick,children:c})}function uz(e){const{contacts:t,roots:n,selected:i}=e,[s,l]=k.useState(""),a=k.useRef(null),c=k.useRef(null),[d,h]=k.useState(()=>iz()),m=O=>O.name.toLowerCase().includes(s.toLowerCase()),p=t.filter(O=>O.status!=="pending"&&m(O)),y=t.filter(O=>O.status==="pending"&&m(O)),w=Nd(p),S=az(p,n),C=p.length===0&&y.length===0,E=O=>{h(oz(O))},T=[{id:"recent",label:"Recent"},{id:"identity",label:"By identity"}],M=k.useRef(null),P=k.useRef({id:-1,x0:0,y0:0,mode:"idle"}),D=k.useRef(!1),$=(O,N)=>{const X=P.current;if(X.id!==O)return;const V=M.current;if(N&&X.mode==="drag"&&V){const fe=parseFloat(V.style.getPropertyValue("--mode-drag-x"))||0,J=Math.max(0,(V.clientWidth-8)/2);E(fe>=J/2?"identity":"recent"),D.current=!0,window.setTimeout(()=>{D.current=!1},0)}P.current={id:-1,x0:0,y0:0,mode:"idle"},V?.hasPointerCapture?.(O)&&V.releasePointerCapture(O),V?.classList.remove("dragging"),V?.style.removeProperty("--mode-drag-x")},j=O=>{!O.isPrimary||P.current.id!==-1||(P.current={id:O.pointerId,x0:O.clientX,y0:O.clientY,mode:"pending"})},Y=O=>{const N=P.current;if(N.id!==O.pointerId||N.mode==="idle")return;const X=O.clientX-N.x0,V=O.clientY-N.y0;if(N.mode==="pending"){if(Math.abs(X)<10&&Math.abs(V)<10)return;if(Math.abs(V)>Math.abs(X)){$(O.pointerId,!1);return}N.mode="drag",O.currentTarget.setPointerCapture?.(O.pointerId),O.currentTarget.classList.add("dragging")}O.preventDefault();const fe=Math.max(0,(O.currentTarget.clientWidth-8)/2),J=d==="identity"?fe:0;O.currentTarget.style.setProperty("--mode-drag-x",`${Math.min(fe,Math.max(0,J+X))}px`)},U=(O,N)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(O.key))return;O.preventDefault();const V=O.key==="Home"?"recent":O.key==="End"||N==="recent"?"identity":"recent";E(V),document.getElementById(`conversation-list-${V}`)?.focus()};return k.useLayoutEffect(()=>{const O=a.current,N=c.current;if(!O||!N)return;const X=()=>O.style.setProperty("--list-bottom-chrome-height",`${N.getBoundingClientRect().height}px`);X();const V=new ResizeObserver(X);return V.observe(N),()=>{V.disconnect(),O.style.removeProperty("--list-bottom-chrome-height")}},[]),v.jsxs("div",{className:"listcol",ref:a,children:[v.jsxs("div",{className:"listcol-head",children:[v.jsxs("div",{className:"listcol-titlebar",children:[v.jsxs("h2",{id:"chat-list-title",className:"listcol-title messenger-lockup",tabIndex:-1,children:[v.jsx("span",{className:"messenger-brand-ours",children:"Ours"}),v.jsx("span",{className:"messenger-brand-product",children:"messenger"})]}),v.jsxs("div",{className:"listcol-actions",children:[v.jsx("button",{className:"btn icon-btn desktop-invite","aria-label":"Invite",title:"Invite",onClick:e.onInvite,children:v.jsx(Ee,{name:"invite",size:18})}),v.jsx("button",{className:"icon-btn","aria-label":"Settings",title:"Settings",onClick:e.onSettings,children:v.jsx(Ee,{name:"settings",size:18})})]})]}),v.jsx("div",{ref:M,className:"conversation-list-modes",role:"tablist","aria-label":"Conversation list layout","data-mode":d,onPointerDown:j,onPointerMove:Y,onPointerUp:O=>$(O.pointerId,!0),onPointerCancel:O=>$(O.pointerId,!1),onLostPointerCapture:O=>$(O.pointerId,!1),children:T.map(O=>v.jsx("button",{id:`conversation-list-${O.id}`,type:"button",role:"tab","aria-selected":d===O.id,"aria-controls":"conversation-list-panel",tabIndex:d===O.id?0:-1,className:d===O.id?"active":"",onClick:N=>{if(D.current){N.preventDefault();return}E(O.id)},onKeyDown:N=>U(N,O.id),children:O.label},O.id))})]}),v.jsxs("div",{id:"conversation-list-panel",className:"listcol-scroll",role:"tabpanel","aria-labelledby":`conversation-list-${d}`,children:[d==="recent"&&w.length>0&&v.jsx("div",{className:"conversation-group",children:w.map(O=>v.jsx(Ef,{c:O,active:i===O.id,onClick:()=>e.onSelect(O.id)},O.id))}),d==="identity"&&S.map(O=>v.jsxs("div",{children:[v.jsxs("div",{className:"group-label",title:O.note,children:[O.rootId&&v.jsx(Ee,{name:"clusters"}),v.jsx("span",{children:O.label}),O.note&&v.jsxs("span",{className:"gl-note",children:["· ",O.note]})]}),v.jsx("div",{className:"conversation-group",children:O.contacts.map(N=>v.jsx(Ef,{c:N,grouped:O.rootId!==null,active:i===N.id,onClick:()=>e.onSelect(N.id)},N.id))})]},O.id)),y.length>0&&v.jsxs("div",{children:[v.jsx("div",{className:"group-label",children:v.jsx("span",{children:"Pending"})}),v.jsx("div",{className:"conversation-group",children:y.map(O=>v.jsx(Ef,{c:O,active:!1,onClick:()=>{},onApprove:()=>e.onApprovePending(O.id.slice(8)),onReject:()=>e.onRejectPending(O.id.slice(8))},O.id))})]}),C&&v.jsx("p",{className:"muted",style:{padding:"14px 10px",fontSize:"0.85rem"},children:"No contacts yet — share an invite to start."})]}),v.jsxs("div",{className:"list-bottom-chrome",ref:c,children:[v.jsxs("div",{className:"search adaptive-search",role:"search",children:[v.jsx("span",{className:"adaptive-search-icon","aria-hidden":!0,children:v.jsx(Ee,{name:"search"})}),v.jsx("input",{className:"field",placeholder:"Search people, agents, apps…",value:s,onChange:O=>l(O.target.value),onKeyDown:O=>{O.key==="Escape"&&(O.preventDefault(),l(""))}})]}),v.jsx("button",{type:"button",className:"icon-btn list-bottom-invite","aria-label":"Invite",title:"Invite",onClick:e.onInvite,children:v.jsx(Ee,{name:"invite",size:20})})]})]})}function cz(e){const[t,n]=k.useState(!1),[i,s]=k.useState(e.contact.name),[l,a]=k.useState(!1),[c,d]=k.useState(null),h=k.useRef(!1);k.useEffect(()=>{const p=y=>{y.key!=="Escape"||l||c||t||(y.preventDefault(),e.onBack())};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t,c,e.onBack,l]);const m=()=>{if(h.current)return;h.current=!0;const p=i.trim();p&&p!==e.contact.name?e.onRename(p):s(e.contact.name),n(!1)};return v.jsxs("div",{className:"detail contact-screen",children:[v.jsxs("div",{className:"detail-head contact-screen-head",children:[v.jsx("button",{type:"button",className:"icon-btn detail-back contact-back","aria-label":"Back to conversation",onClick:e.onBack,children:v.jsx(Ee,{name:"back"})}),v.jsx("strong",{children:"Contact"})]}),v.jsxs("div",{className:"contact-screen-scroll",children:[v.jsxs("section",{className:"contact-hero","aria-labelledby":"contact-screen-name",children:[v.jsx("div",{className:"avatar accent contact-avatar-large","aria-hidden":!0,children:e.contact.initials}),t?v.jsx("input",{id:"contact-screen-name",className:"field contact-name-input",value:i,autoFocus:!0,onChange:p=>s(p.target.value),onBlur:m,onKeyDown:p=>{p.key==="Enter"&&m(),p.key==="Escape"&&(h.current=!0,s(e.contact.name),n(!1))}}):v.jsx("h2",{id:"contact-screen-name",children:e.contact.name}),v.jsxs("p",{children:[v.jsx(Ee,{name:"lock",size:13})," End-to-end encrypted connection"]})]}),v.jsxs("section",{className:"contact-action-group","aria-label":"Contact actions",children:[v.jsxs("button",{type:"button",onClick:()=>a(!0),children:[v.jsxs("span",{children:[v.jsx(Ee,{name:"paperclip"}),"Shared photos, files, and links"]}),v.jsx(Ee,{name:"chevron"})]}),v.jsxs("button",{type:"button",onClick:()=>{h.current=!1,s(e.contact.name),n(!0)},children:[v.jsxs("span",{children:[v.jsx(Ee,{name:"edit"}),"Rename contact"]}),v.jsx(Ee,{name:"chevron"})]})]}),v.jsxs("section",{className:"contact-identity","aria-labelledby":"contact-identity-title",children:[v.jsx("h3",{id:"contact-identity-title",children:"Verified identity"}),e.contact.roleId&&v.jsxs("p",{children:["Role ",v.jsx("strong",{children:e.contact.roleId})," of ",v.jsx("strong",{children:e.contact.rootName})]}),v.jsx("code",{children:e.contact.id}),v.jsxs("button",{type:"button",className:"btn sm",onClick:()=>void navigator.clipboard.writeText(e.contact.id),children:[v.jsx(Ee,{name:"copy",size:14}),"Copy identity"]})]}),v.jsxs("button",{type:"button",className:"contact-remove",onClick:e.onRemove,children:[v.jsx(Ee,{name:"trash"}),"Remove contact"]})]}),l&&v.jsx(DF,{messages:e.messages,indexOffset:e.indexOffset,onClose:()=>a(!1),onJump:e.onOpenMessage,onPreview:p=>{a(!1),d(p)}}),c&&(As(c.filename,c.mime)?v.jsx($k,{rec:c,onClose:()=>d(null)}):v.jsx(Bk,{rec:c,onClose:()=>d(null),onSendText:e.onSendText,onSendFile:e.onSendFile}))]})}const wx=e=>`chat-message-${encodeURIComponent(e)}`,Yk=()=>typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function kx(e){const{dir:t,canReply:n,onReply:i}=e,s=k.useRef(null),l=k.useRef(null),a=k.useRef(null),c=k.useRef(i);c.current=i;const d=t==="in"?1:-1,h=qk,m=84,p=()=>({id:-1,x0:0,y0:0,mode:"idle",armed:!1,distance:0,samples:[]}),y=k.useRef(p()),w=M=>{const P=l.current,D=a.current,$=Yk();if(P&&(P.style.transform=M&&!$?`translateX(${M}px)`:""),D){const j=Math.min(1,Math.abs(M)/h);D.style.opacity=String(j),D.style.transform=$?"scale(1)":`scale(${.5+.5*j})`}},S=(M,P)=>{const D=y.current;if(D.id!==M)return;const $=P&&D.mode==="drag"&&rz(D.distance,D.samples);y.current=p(),l.current?.classList.remove("swiping"),a.current?.classList.remove("armed"),w(0);const j=s.current;j?.hasPointerCapture?.(M)&&j.releasePointerCapture(M),$&&c.current()};k.useEffect(()=>{const M=s.current;if(!M)return;const P=D=>S(D.pointerId,!1);return M.addEventListener("lostpointercapture",P),()=>{M.removeEventListener("lostpointercapture",P);const D=y.current.id;D!==-1&&S(D,!1)}},[]);const C=M=>{const P=M.target,D=window.getSelection?.();!n||!M.isPrimary||M.pointerType==="mouse"||M.pointerType==="pen"&&M.button!==0||y.current.id!==-1||D&&!D.isCollapsed||P.closest('a, button, input, textarea, select, [role="button"], audio, video, img, [draggable="true"], .filecard, .filecard-bubble, .image-bubble, .voice-bubble, .ours-message-file, .attachment')||(y.current={id:M.pointerId,x0:M.clientX,y0:M.clientY,mode:"maybe",armed:!1,distance:0,samples:[{x:M.clientX*d,time:M.timeStamp}]},w(0))},E=M=>{const P=y.current;if(P.id!==M.pointerId||P.mode==="idle")return;const D=M.clientX-P.x0,$=M.clientY-P.y0,j=window.getSelection?.();if(j&&!j.isCollapsed){S(M.pointerId,!1);return}if(P.mode==="maybe"){const X=tz(D*d,$);if(X==="pending")return;if(X==="drag")P.mode="drag",M.currentTarget.setPointerCapture?.(M.pointerId),l.current?.classList.add("swiping");else{P.mode="idle";return}}M.preventDefault();const Y=M.timeStamp;P.samples.push({x:M.clientX*d,time:Y}),P.samples=P.samples.filter(X=>Y-X.time<=120);let U=D*d;U<0&&(U=0),U>h&&(U=h+(U-h)*.35),U=Math.min(U,m),P.distance=U;const O=U*d,N=Math.abs(O)>=h;N!==P.armed&&(P.armed=N,a.current?.classList.toggle("armed",N),N&&navigator.vibrate?.(10)),w(O)},T=M=>{const P=y.current;P.id===M.pointerId&&P.mode==="drag"&&(P.samples.push({x:M.clientX*d,time:M.timeStamp}),P.distance=Math.max(0,(M.clientX-P.x0)*d),P.armed=P.distance>=h),S(M.pointerId,!0)};return v.jsxs("div",{ref:s,className:"msg-row "+(e.rowClass??t),style:n?{touchAction:"pan-y"}:void 0,onPointerDown:C,onPointerMove:E,onPointerUp:T,onPointerCancel:M=>S(M.pointerId,!1),onLostPointerCapture:M=>S(M.pointerId,!1),children:[n&&v.jsx("span",{className:"swipe-cue",ref:a,"aria-hidden":!0,children:v.jsx(Ee,{name:"reply",size:16})}),v.jsx("div",{className:"bubble-wrap",ref:l,children:e.children}),e.after]})}function fz(e){const{contact:t,messages:n}=e,[i,s]=k.useState(""),[l,a]=k.useState(!1),[c,d]=k.useState(null),[h,m]=k.useState(null),[p,y]=k.useState(null),[w,S]=k.useState(null),[C,E]=k.useState(null),[T,M]=k.useState(!1),[P,D]=k.useState(!1),[$,j]=k.useState(!1),[Y,U]=k.useState(null),O=k.useRef(null),N=k.useRef(null),X=k.useRef(null),V=k.useRef(null),fe=k.useRef(null),J=k.useRef(!1),ee=k.useRef(null),xe=k.useRef(!1),[Pe,Q]=k.useState(!1),[de,R]=k.useState(0),F=k.useRef(null),G=k.useRef(!0),A=k.useRef(null),te=k.useRef(0),ge=k.useRef(null),ye=k.useRef(new Map),me=k.useRef(0),we=k.useRef(null),pe=k.useRef(null),Ve=k.useRef(0),qe=k.useRef(null);k.useLayoutEffect(()=>{const _=X.current,Z=V.current,he=fe.current;if(!_||!Z||!he)return;let De=-1,W=-1,le=null;const ne=()=>{const ke=Math.round(Z.getBoundingClientRect().height),ce=Math.round(he.getBoundingClientRect().height);if(ke!==De&&(De=ke,_.style.setProperty("--conversation-head-height",`${ke}px`)),ce!==W){const Ae=G.current;W=ce,_.style.setProperty("--conversation-compose-height",`${ce}px`),Ae&&(le!==null&&cancelAnimationFrame(le),le=requestAnimationFrame(()=>{le=null;const ft=ee.current;ft&&G.current&&(ft.scrollTop=Math.max(0,ft.scrollHeight-ft.clientHeight))}))}};ne();const Me=new ResizeObserver(ne);return Me.observe(Z),Me.observe(he),()=>{Me.disconnect(),le!==null&&cancelAnimationFrame(le),_.style.removeProperty("--conversation-head-height"),_.style.removeProperty("--conversation-compose-height")}},[t?.id]),k.useEffect(()=>{s(""),m(null),y(null),d(null),S(null),E(null),M(!1),D(!1),j(!1),te.current+=1,U(null),ye.current.clear(),we.current=null,pe.current=null},[t?.id]),k.useEffect(()=>{if(!p)return;const _=p.reply?.wireId;n.some(he=>he.kind!=="file"&&he.dir==="out"&&!!he.wireId&&!p.wireIds.has(he.wireId)&&he.text===p.text&&(he.replyTo?.wireId??void 0)===_)&&(y(null),m(null),s(he=>he===p.draft?"":he),S(he=>he===p.reply?null:he))},[n,p]);const it=!!c?.wireId&&n.some(_=>_.wireId===c.wireId),We=k.useMemo(()=>c&&!it?[...n,c.message]:n,[n,c,it]);k.useEffect(()=>{it&&d(null)},[it]),k.useLayoutEffect(()=>{const _=N.current;if(!_)return;_.style.height="0px";const Z=Math.max(44,Math.min(_.scrollHeight,132));_.style.height=`${Z}px`,_.style.overflowY=_.scrollHeight>132?"auto":"hidden"},[i,t?.id]);const at=_=>{const Z=ee.current;if(!Z)return;const he=Math.max(0,Z.scrollHeight-Z.clientHeight);if(Math.abs(Z.scrollTop-he)<1){we.current=null,pe.current=null;return}const De=_&&!Yk();we.current=De?he:null,pe.current=De?Z.scrollTop:null,De?Z.scrollTo({top:he,behavior:"smooth"}):Z.scrollTop=he},xt=()=>{F.current===null&&(F.current=requestAnimationFrame(()=>{F.current=null;const _=ee.current;if(!_)return;const Z=_.scrollHeight-_.clientHeight-_.scrollTop>48;Q(Z),Z||R(0)}))};k.useLayoutEffect(()=>{if(!t){A.current=null,G.current=!0,Ve.current=0;return}const _=ee.current;if(!_)return;const Z=A.current!==t.id,he=Ve.current,De=We.length!==he,W=We.at(-1),le=W?W.wireId||`${W.date}:${W.text}`:null,ne=qe.current;if(Ve.current=We.length,qe.current=le,!Z&&!De&&we.current===null&&(G.current=_.scrollHeight-_.clientHeight-_.scrollTop<=48),Z||G.current)at(De&&!Z&&A.current!==null),G.current=!0;else if(De&&We.length>he&&le!==ne){const Me=ne===null?-1:We.findIndex(ke=>(ke.wireId||`${ke.date}:${ke.text}`)===ne);R(ke=>ke+Math.max(1,We.length-Math.max(0,Me+1)))}A.current=t.id,xt()},[t,We.length]),k.useLayoutEffect(()=>{if(xe.current||!e.unreadOpen||window.location.hash.startsWith("#chat-message-"))return;const _=ee.current,Z=document.getElementById(`unread-${wx(e.unreadOpen.wireId)}`);!_||!Z||(_.scrollTop=Math.max(0,Z.offsetTop-16),G.current=!1,xe.current=!0,xt())},[e.unreadOpen,We.length]),k.useLayoutEffect(()=>{const _=window.location.hash;if(!_.startsWith("#chat-message-"))return;const Z=document.getElementById(_.slice(1));Z&&(Z.scrollIntoView({block:"center"}),G.current=!1)},[t?.id,We.length]),k.useLayoutEffect(()=>{const _=ge.current,Z=ee.current;if(_===null||!Z)return;const he=requestAnimationFrame(()=>{ge.current===_&&(Z.scrollTop=_.top+Z.scrollHeight-_.height,ge.current=null)});return()=>cancelAnimationFrame(he)},[We.length]),k.useEffect(()=>{const _=ee.current;if(!_||typeof ResizeObserver>"u")return;const Z=_.firstElementChild;if(!Z)return;const he=new ResizeObserver(()=>{G.current&&at(we.current!==null),xt()});return he.observe(Z),he.observe(_),()=>{he.disconnect(),F.current!==null&&cancelAnimationFrame(F.current)}},[t?.id]);const Vt=async _=>{const Z=++te.current;m(null),j(!0);try{if(_.size>ts&&Wk(_.type,_.name)){const De=await KF(_,ts);if(Z!==te.current)return;E({filename:De.filename,mime:De.mime,bytes:De.bytes,originalSize:De.originalSize});return}if(_.size>ts){m(`"${_.name}" is ${Fr(_.size)} — files up to ${Fr(ts)} can be sent.`);return}const he=await _.arrayBuffer();if(Z!==te.current)return;E({filename:_.name||"file",mime:_.type||"application/octet-stream",bytes:new Uint8Array(he)})}catch(he){Z===te.current&&m(`Photo optimization failed: ${he instanceof Error?he.message:String(he)}`)}finally{Z===te.current&&j(!1)}},lt=()=>{!C||!e.onSendFile||P||(D(!0),e.onSendFile(C,w?.wireId).then(()=>{E(null),S(null)}).catch(_=>m(`File send failed: ${String(_)} — it was not delivered.`)).finally(()=>D(!1)))},Pt=e.onDraftChange;k.useEffect(()=>(Pt?.(i.trim().length>0||l),()=>Pt?.(!1)),[i,l,Pt]);const fn=new Map;for(const _ of We)_.wireId&&fn.set(_.wireId,_);const It=k.useMemo(()=>{const _=new Map;for(const Z of We)_.set(Z,Z.kind==="file"?null:Z.dir==="in"?y2(t?.announcedName??"",Z.text):null);return _},[We,t?.announcedName]),jt=_=>It.get(_)??null,Ln=_=>{if(_.dir==="out")return"You";const Z=jt(_);return Z&&Z.variant==="chat"?Z.author:t?.name??"Them"},ze=_=>{if(_.kind==="file")return _.mime?.startsWith("image/")?"Photo":eo(_.mime??"",_.filename??"")?"Voice message":_.filename||"File";const Z=jt(_);return Z?Z.text||C2(Z):_.text},ur=_=>{if(!_.replyTo)return null;const Z=fn.get(_.replyTo.wireId);return Z?{author:Ln(Z),text:ze(Z)}:{author:"",text:"Original message"}};if(!t)return e.emptyOverride?v.jsx(v.Fragment,{children:e.emptyOverride}):v.jsx("div",{className:"detail",children:v.jsxs("div",{className:"detail-empty",children:[v.jsx(Ee,{name:"chat"}),v.jsxs("div",{children:[v.jsx("div",{style:{fontWeight:650,color:"var(--text-2)"},children:"Select a conversation"}),v.jsx("div",{style:{fontSize:"0.85rem"},children:"Chat with people, agents and apps across ours."})]})]})});const bn=async()=>{const _=i,Z=_.trim(),he=!!p&&_===p.draft&&(w?.wireId??void 0)===p.reply?.wireId;if(!Z||J.current||he)return;p&&y(null),J.current=!0,a(!0),m(null);const De=w,W=De?.wireId,le=new AbortController;let ne=!1,Me=0;s(""),S(null);const ke=`optimistic-${++me.current}`;d({key:ke,wireId:null,message:{dir:"out",text:Z,date:new Date().toISOString(),read:!0,wireId:"",replyTo:W?{wireId:W}:null}});try{const ce=await Promise.race([e.onSend(Z,W,le.signal),new Promise((Ae,ft)=>{Me=window.setTimeout(()=>{ne=!0,le.abort(),ft(new Error("send timeout"))},lz)})]);ce?(ye.current.set(ce,ke),d(Ae=>Ae?.key===ke?{...Ae,wireId:ce}:Ae)):d(Ae=>Ae?.key===ke?null:Ae),y(null)}catch(ce){d(null),s(Ae=>Ae===""?_:Ae),S(Ae=>Ae===null?De:Ae),ne||!(ce instanceof Qf)?(y({draft:_,text:Z,reply:De,wireIds:new Set(n.flatMap(Ae=>Ae.wireId?[Ae.wireId]:[]))}),m(`${ne?"Send timed out":"Send connection was interrupted"} — delivery status is unknown. Check the conversation; edit the draft before sending again.`)):m(`Send failed: ${String(ce)} — the message was not delivered.`)}finally{window.clearTimeout(Me),J.current=!1,a(!1)}},q=!!p&&i===p.draft&&(w?.wireId??void 0)===p.reply?.wireId,se=_=>{_.wireId&&S({wireId:_.wireId,author:Ln(_),text:ze(_)})};return v.jsxs("div",{className:"detail detail-chat",ref:X,children:[v.jsx("div",{className:"detail-head",ref:V,children:v.jsxs("div",{className:"conv-peer",children:[v.jsx("button",{className:"icon-btn detail-back","aria-label":"Back to conversations",onClick:e.onBack,children:v.jsx(Ee,{name:"back"})}),v.jsxs("div",{className:"conv-peer-status",children:[v.jsx("span",{className:"conv-peer-name",children:t.name}),e.syncing&&v.jsxs("div",{className:"conv-sync",role:"status","aria-live":"polite",children:[v.jsx("span",{className:"conv-sync-dot","aria-hidden":!0}),e.syncing==="connecting"?"Connecting…":"Updating…"]}),!e.syncing&&v.jsxs("span",{className:"conv-contact-status",children:[v.jsx(Ee,{name:"lock",size:11}),"Encrypted connection"]})]}),v.jsx("button",{type:"button",className:"conv-contact-trigger conv-contact-avatar","data-contact-trigger":!0,onClick:e.onOpenContact,disabled:!e.onOpenContact,"aria-label":`Open contact details for ${t.name}`,children:v.jsx("span",{className:"conv-contact-initials","aria-hidden":!0,children:t.initials})})]})}),v.jsx("div",{className:"messages",ref:ee,tabIndex:-1,"aria-label":"Conversation timeline",onScroll:_=>{const Z=_.currentTarget,he=Z.scrollHeight-Z.clientHeight-Z.scrollTop;if(we.current!==null){const De=pe.current;if(De===null||Z.scrollTop>=De-1){pe.current=Z.scrollTop,he<=4&&(we.current=null,pe.current=null);return}we.current=null,pe.current=null}G.current=he<=48,xt()},onPointerDown:()=>{we.current=null,pe.current=null},onTouchStart:()=>{we.current=null,pe.current=null},onWheel:()=>{we.current=null,pe.current=null},onDragOver:_=>{e.onSendFile&&_.preventDefault()},onDrop:_=>{if(!e.onSendFile)return;_.preventDefault();const Z=_.dataTransfer.files?.[0];Z&&Vt(Z)},children:v.jsxs("div",{className:"messages-inner",children:[v.jsxs("div",{className:"e2e-note",children:[v.jsx(Ee,{name:"lock"}),"End-to-end encrypted · the broker only sees ciphertext"]}),(e.hiddenEarlier??0)>0&&e.onLoadEarlier&&v.jsxs("button",{className:"btn sm chat-load-earlier",onClick:()=>{G.current=!1;const _=ee.current;ge.current=_?{height:_.scrollHeight,top:_.scrollTop}:null,e.onLoadEarlier?.()},children:["Load earlier messages (",e.hiddenEarlier," remaining)"]}),v.jsx(qP,{initial:!1,children:We.map((_,Z)=>{const he=_===c?.message?c.key:_.wireId&&ye.current.get(_.wireId)||_.wireId||`${_.date}-${(e.hiddenEarlier??0)+Z}`,De=wx(_.wireId||he),W=We[Z-1],le=We[Z+1],ne=jt(_),Me=Ge=>{if(!Ge)return null;const Ye=jt(Ge);return Ye?Ye.variant==="system"?"room:system":`room:chat:${Ye.author}${Ye.role}`:Ge.dir},ke=Me(_),ce=!!W&&Me(W)===ke&&ke!=="room:system",Ae=!!le&&Me(le)===ke&&ke!=="room:system",ft=(_.dir==="out"?"out":"in")+(ce?" cont-top":"")+(Ae?" cont-bot":""),nn=_.wireId?v.jsx("button",{className:"msg-reply",title:"Reply",onClick:()=>se(_),children:v.jsx(Ee,{name:"reply",size:15})}):null;if(ne&&ne.variant==="system"){const Ge=ne.presentation??"system";return v.jsxs(ss.div,{className:"message-motion",id:De,initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:yl,children:[_.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${De}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsxs("div",{className:`room-system room-${Ge}-card`,role:"note",children:[ne.label&&v.jsx("span",{className:"room-system-label",children:ne.label}),ne.roomName&&v.jsx("strong",{className:"room-card-name",children:ne.roomName}),v.jsx(yx,{text:ne.text,className:"room-system-text message-markdown"}),!!ne.details?.length&&v.jsx("ul",{className:"room-card-details","aria-label":"Room event details",children:ne.details.map(Ye=>v.jsx("li",{children:Ye},Ye))}),v.jsxs("span",{className:"room-card-provenance",children:[ne.authoredBy&&v.jsx("span",{className:"room-card-author",children:ne.authoredBy}),v.jsx("span",{className:"room-system-at",children:ys(ne.authoredAt||_.date)})]})]})]},he)}if(_.kind==="file"){const Ge=S0(_.wireId)??{id:_.wireId,dir:_.dir,filename:_.filename??"file",mime:_.mime??"application/octet-stream",size:0,date:_.date};return v.jsxs(ss.div,{className:"message-motion",id:De,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:yl,children:[_.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${De}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsx(kx,{dir:_.dir==="out"?"out":"in",rowClass:ft,canReply:!!_.wireId,onReply:()=>se(_),after:nn,children:v.jsx("div",{className:`ours-message ours-message-file ours-message--${_.dir}`,children:v.jsx(PD,{rec:Ge,receipt:_.receipt,receiptless:_.receiptless,onPreview:U,onFetch:e.onFetchFile})})})]},he)}const ot=ur(_);return v.jsxs(ss.div,{className:"message-motion",id:De,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:yl,children:[_.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${De}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsx(kx,{dir:_.dir==="out"?"out":"in",rowClass:ft,canReply:!!_.wireId,onReply:()=>se(_),after:nn,children:v.jsxs("div",{className:`ours-message ours-message--${_.dir}`,children:[ot&&v.jsxs("div",{className:"quote",children:[ot.author&&v.jsx("span",{className:"quote-author",children:ot.author}),v.jsx("span",{className:"quote-text",children:ot.text})]}),ne&&!ce&&v.jsxs(v.Fragment,{children:[ne.roomName&&v.jsx("div",{className:"room-message-room",children:ne.roomName}),v.jsxs("div",{className:"room-author",children:[v.jsx("span",{className:"room-author-name",children:ne.author}),ne.role&&v.jsx("span",{className:"room-author-role",children:ne.role})]})]}),v.jsx(yx,{text:ne?ne.text:_.text}),v.jsxs("div",{className:"bubble-at",children:[ys(ne?.authoredAt||_.date),_.dir==="out"&&v.jsx(b0,{receipt:_.receipt,receiptless:_.receiptless})]})]})})]},he)})}),v.jsx("div",{className:"thread-end","aria-hidden":!0})]})},t.id),Pe&&v.jsxs("button",{type:"button",className:"jump-latest btn sm","aria-label":de?`Jump to latest, ${de} new messages`:"Jump to latest",onClick:_=>{const Z=_.currentTarget===document.activeElement;R(0),at(!0),Z&&requestAnimationFrame(()=>ee.current?.focus({preventScroll:!0}))},children:[v.jsx("span",{children:"Jump to latest"}),!!de&&v.jsx("span",{className:"jump-latest-count","aria-live":"polite",children:de})]}),h&&v.jsxs("div",{className:"banner error",role:"alert",children:[h,h.startsWith("Send failed:")&&v.jsx("span",{className:"banner-actions",children:v.jsx("button",{className:"linkbtn",onClick:()=>void bn(),children:"retry"})})]}),v.jsxs("div",{className:"composer-wrap",ref:fe,children:[w&&v.jsxs("div",{className:"reply-bar",children:[v.jsx("div",{className:"reply-bar-line"}),v.jsxs("div",{className:"reply-bar-body",children:[v.jsxs("div",{className:"reply-bar-author",children:["Replying to ",w.author]}),v.jsx("div",{className:"reply-bar-text",children:w.text})]}),v.jsx("button",{className:"icon-btn",title:"Cancel reply",onClick:()=>S(null),children:v.jsx(Ee,{name:"close",size:16})})]}),C&&v.jsx(w1,{att:C,sending:P,onSend:lt,onDiscard:()=>E(null)}),$&&v.jsx("div",{className:"attachment-processing",role:"status",children:"Optimizing photo for secure delivery…"}),v.jsxs("div",{className:"composer"+(T?" recording":""),children:[e.onSendFile&&v.jsxs(v.Fragment,{children:[v.jsx("input",{ref:O,type:"file",style:{display:"none"},onChange:_=>{const Z=_.target.files?.[0];Z&&Vt(Z),_.target.value=""}}),v.jsx("button",{className:"icon-btn composer-tool",title:"Attach a file or photo",disabled:P||$||T,onClick:()=>O.current?.click(),children:v.jsx(Ee,{name:"paperclip",size:18})})]}),v.jsx("textarea",{ref:N,className:"field",rows:1,placeholder:(w?"Reply to "+w.author:"Message "+t.name)+"…",value:i,"aria-busy":l,onChange:_=>s(_.target.value),onKeyDown:_=>{_.key==="Enter"?!(window.matchMedia("(pointer: coarse)").matches||window.innerWidth<=860)&&!_.shiftKey&&(_.preventDefault(),bn()):_.key==="Escape"&&S(null)}}),e.onSendFile&&!i.trim()&&!C&&!$&&!P?v.jsx(k1,{disabled:P||$||!!C,onReady:_=>{M(!1),E(_)},onError:_=>{M(!1),m(_)},onActiveChange:M},t.id):v.jsxs("button",{className:"btn primary","aria-label":"Send",onPointerDown:_=>{_.button===0&&document.activeElement===N.current&&_.preventDefault()},onClick:()=>void bn(),disabled:l||q||!i.trim(),title:q?"Delivery status unknown — edit before sending again":void 0,children:[v.jsx(Ee,{name:"send",size:16}),v.jsx("span",{className:"btn-label",children:"Send"})]})]})]}),Y&&(As(Y.filename,Y.mime)?v.jsx($k,{rec:Y,onClose:()=>U(null)}):v.jsx(Bk,{rec:Y,onClose:()=>U(null),onSendText:e.onSend,onSendFile:e.onSendFile}))]})}const Gk=3;function dz(e,t,n=Gk){return[t,...e.filter(i=>i.cid!==t.cid)].slice(0,n)}function hz(e,t){return e.filter(n=>n.id!==t)}const pz=6e3,mz=dz,gz=hz;function yz(){const[e,t]=k.useState([]),n=k.useRef(0),i=k.useCallback((a,c,d)=>{const h=Date.now(),m={id:`${a}:${h}:${n.current++}`,cid:a,name:c,preview:"",at:h};t(p=>mz(p,m,Gk))},[]),s=k.useCallback(a=>t(c=>gz(c,a)),[]),l=k.useCallback(a=>t(c=>c.filter(d=>d.cid!==a)),[]);return{toasts:e,push:i,dismiss:s,clear:l}}function vz(e){const{item:t,onOpen:n,onDismiss:i}=e,[s,l]=k.useState(!1),[a,c]=k.useState(!1),d=s||a;return k.useEffect(()=>{if(d)return;const h=setTimeout(()=>i(t.id),pz);return()=>clearTimeout(h)},[t.id,d,i]),v.jsxs("div",{className:"banner msg",role:"status",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocus:()=>c(!0),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||c(!1)},children:[v.jsxs("button",{className:"msg-open",title:`Open the conversation with ${t.name}`,onClick:()=>n(t.cid),children:[v.jsx("span",{className:"avatar sm accent","aria-hidden":"true",children:rd(t.name)}),v.jsxs("span",{className:"msg-text",children:[v.jsx("strong",{className:"msg-name",children:t.name}),v.jsx("span",{className:"msg-preview",children:t.preview||"New message"})]})]}),v.jsx("button",{className:"icon-btn msg-close",title:"Dismiss","aria-label":`Dismiss the notification from ${t.name}`,onClick:()=>i(t.id),children:v.jsx(Ee,{name:"close",size:15})})]})}function xz(e){return v.jsx(v.Fragment,{children:e.items.map(t=>v.jsx(vz,{item:t,onOpen:e.onOpen,onDismiss:e.onDismiss},t.id))})}function wz(e){const t=k.useRef(null),{text:n,size:i=240}=e;return k.useEffect(()=>{if(!t.current||!n)return;const s=t.current;Ch(()=>import("./browser-CG3-I6-H.js").then(l=>l.b),[]).then(l=>{l.toCanvas(s,n,{width:i,margin:2,errorCorrectionLevel:"M",color:{dark:"#000000",light:"#ffffff"}})})},[n,i]),v.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"8px 0"},children:v.jsx("canvas",{ref:t,"data-testid":"qr-canvas","data-invite":n,width:i,height:i,style:{borderRadius:8,border:"1px solid var(--line)",imageRendering:"pixelated"}})})}function kz(e){const t=k.useRef(null),n=k.useRef(null),i=k.useRef(null),s=k.useRef(0),l=k.useRef(!0),[a,c]=k.useState("requesting"),[d,h]=k.useState(""),m=k.useCallback(()=>{s.current&&cancelAnimationFrame(s.current),i.current&&(i.current.getTracks().forEach(w=>w.stop()),i.current=null),t.current&&(t.current.srcObject=null)},[]),p=k.useCallback(w=>{i.current=w;const S=t.current;S.srcObject=w,S.setAttribute("playsinline","true"),S.play();const C=n.current,E=C.getContext("2d"),T=()=>{if(l.current)if(S.readyState>=S.HAVE_ENOUGH_DATA){const M=S.videoWidth||320,P=S.videoHeight||240;C.width=M,C.height=P,E.drawImage(S,0,0,M,P);const D=E.getImageData(0,0,M,P);Ch(()=>import("./jsQR-DfrHZfxx.js").then($=>$.j),[]).then($=>{const j=$.default,Y=j(D.data,D.width,D.height,{inversionAttempts:"dontInvert"});if(Y&&Y.data&&l.current){m(),e.onDecode(Y.data);return}l.current&&(s.current=requestAnimationFrame(T))})}else s.current=requestAnimationFrame(T)};s.current=requestAnimationFrame(T)},[m,e]);k.useEffect(()=>{if(l.current=!0,!navigator.mediaDevices?.getUserMedia){c("nocamera");return}return navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then(w=>{if(!l.current){w.getTracks().forEach(S=>S.stop());return}c("scanning"),p(w)}).catch(w=>{if(!l.current)return;const S=w.name??"";S==="NotAllowedError"||S==="PermissionDeniedError"?c("denied"):S==="NotFoundError"||S==="DevicesNotFoundError"?c("nocamera"):(c("error"),h(w.message??String(w)))}),()=>{l.current=!1,m()}},[]);const y=()=>{m(),e.onClose()};return v.jsxs("div",{"data-testid":"qr-scanner",style:{display:"flex",flexDirection:"column",gap:12,padding:"12px 0"},children:[(a==="requesting"||a==="scanning")&&v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:a==="requesting"?"Requesting camera…":"Point your camera at the QR code."}),v.jsxs("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",background:"#000",minHeight:200},children:[v.jsx("canvas",{ref:n,"data-testid":"scanner-canvas",style:{display:"none"}}),v.jsx("video",{ref:t,"data-testid":"scanner-video",muted:!0,playsInline:!0,style:{width:"100%",display:"block",borderRadius:8}}),a==="scanning"&&v.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",display:"flex",alignItems:"center",justifyContent:"center"},children:v.jsx("div",{style:{width:160,height:160,borderRadius:12,border:"2px solid var(--accent)",boxShadow:"0 0 0 9999px rgba(0,0,0,0.4)"}})})]})]}),a==="denied"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[v.jsx(Ee,{name:"shield",size:16}),v.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"Camera access denied"})]}),v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"Camera permission was denied. To scan QR codes, allow camera access in your browser settings, then try again. Or paste the invite text below instead."})]}),a==="nocamera"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[v.jsx(Ee,{name:"close",size:16}),v.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"No camera available"})]}),v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"No camera was found on this device. Paste the invite text below instead."})]}),a==="error"&&v.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:v.jsxs("p",{style:{margin:0,fontSize:"0.85rem",color:"var(--danger, #e53)"},children:["Camera error: ",d||"unknown error",". Paste the invite text below instead."]})}),v.jsx("button",{className:"btn",style:{justifyContent:"center"},onClick:y,children:a==="scanning"?v.jsxs(v.Fragment,{children:[v.jsx(Ee,{name:"close",size:14}),"Cancel scan"]}):v.jsxs(v.Fragment,{children:[v.jsx(Ee,{name:"close",size:14}),"Close scanner"]})})]})}function Sz(e){const[t,n]=k.useState("generate"),[i,s]=k.useState("one_time"),[l,a]=k.useState(""),[c,d]=k.useState(null),[h,m]=k.useState("one_time"),[p,y]=k.useState(""),[w,S]=k.useState(""),[C,E]=k.useState(!1),[T,M]=k.useState(null),[P,D]=k.useState(null),[$,j]=k.useState(!1),[Y,U]=k.useState(null),O=k.useRef(!1),N=async()=>{if(!O.current){O.current=!0,E(!0),D(null),M(null);try{m(i),d(await e.onCreate(i,i==="one_time"&&l.trim()||void 0))}catch(V){D(V instanceof Error?V.message:String(V))}finally{O.current=!1,E(!1)}}},X=v.jsx(Uk,{className:"modal-tabs",label:"Invite mode",options:[{id:"generate",label:"Generate invite"},{id:"accept",label:"Accept invite"}],value:t,onChange:n,idPrefix:"invite-tab",panelId:"invite-panel"});return v.jsx(Ds,{title:t==="generate"?"Invite a contact":"Accept an invite",onClose:()=>{O.current||e.onClose()},tabs:X,children:v.jsxs("div",{id:"invite-panel",role:"tabpanel","aria-labelledby":`invite-tab-${t}`,children:[t==="generate"&&!c&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:13},children:[v.jsxs("p",{className:"muted","data-testid":"invite-identity",style:{margin:0,fontSize:"0.85rem"},children:["Creating as ",v.jsx("strong",{children:e.identity.name})," · ",v.jsxs("span",{className:"mono",children:["@",w0(e.identity.cid)]})]}),v.jsxs("div",{role:"radiogroup","aria-label":"Invite kind",style:{display:"flex",flexDirection:"column",gap:7},children:[v.jsxs("label",{children:[v.jsx("input",{type:"radio",name:"invite-kind",checked:i==="one_time",onChange:()=>s("one_time")})," One person (one time)"]}),v.jsxs("label",{children:[v.jsx("input",{type:"radio",name:"invite-kind",checked:i==="public",onChange:()=>s("public")})," Reusable public invite"]})]}),i==="one_time"?v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.9rem"},children:"Optionally name the person or agent this invite is for."}),v.jsx("input",{className:"field",value:l,onChange:V=>a(V.target.value),placeholder:"Their name (optional), e.g. Bob",maxLength:64})]}):v.jsx("p",{className:"onb-warning","data-testid":"public-invite-warning",style:{margin:0,fontSize:"0.9rem"},children:"Anyone with this invite can connect until you revoke it. It has no expiry and stays valid across server restarts."}),v.jsx("button",{className:"btn primary",style:{justifyContent:"center"},disabled:C,onClick:()=>void N(),children:C?"Generating…":i==="public"?"Create public invite":"Generate invite"}),i==="public"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsx("h4",{style:{margin:0,fontSize:"0.9rem"},children:"Active reusable invites"}),e.invites.filter(V=>V.mode==="public").length===0&&v.jsx("p",{className:"muted",style:{margin:0},children:"None right now."}),e.invites.filter(V=>V.mode==="public").map(V=>v.jsxs("div",{"data-testid":"public-invite-row",style:{padding:"8px 10px",background:"var(--inset)",borderRadius:7},children:[v.jsx("span",{className:"mono",children:V.invite_id}),v.jsxs("p",{className:"muted",children:["Created ",V.created?R2(V.created):"unknown"," · Active until revoked · No expiry"]}),Y===V.invite_id?v.jsxs("span",{children:[v.jsx("button",{className:"btn sm danger",onClick:()=>void e.onRevoke(V.invite_id).then(()=>(U(null),e.onRefresh())).catch(fe=>D(String(fe))),children:"Confirm revoke"})," ",v.jsx("button",{className:"btn sm",onClick:()=>U(null),children:"Keep it"})]}):v.jsx("button",{className:"btn sm",onClick:()=>U(V.invite_id),children:"Revoke"})]},V.invite_id))]}),T&&v.jsx("p",{className:"muted",children:T}),P&&v.jsx("p",{className:"onb-error",children:P})]}),t==="generate"&&c&&v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted","data-testid":h==="public"?"public-result-note":void 0,children:h==="public"?"Shown only on this screen. Copy it now; the text cannot be recovered later. The invite stays active until revoked.":`Send this invite to ${l.trim()||"your contact"}. It can be redeemed once.`}),v.jsx("textarea",{className:"field mono","data-testid":"invite-result-text",readOnly:!0,rows:5,value:c,onFocus:V=>V.currentTarget.select()}),h==="one_time"&&v.jsx(wz,{text:c}),v.jsxs("button",{className:"btn primary",onClick:()=>void navigator.clipboard.writeText(c).then(()=>M("Copied to clipboard.")),children:[v.jsx(Ee,{name:"copy",size:15}),"Copy invite"]}),h==="public"&&v.jsx("button",{className:"btn","data-testid":"done-hide-invite",onClick:()=>{d(null),a(""),e.onRefresh()},children:"Done — hide invite"}),T&&v.jsx("p",{className:"muted",children:T})]}),t==="accept"&&v.jsxs("form",{style:{display:"flex",flexDirection:"column",gap:13},onSubmit:V=>{V.preventDefault(),!(!p.trim()||C)&&(E(!0),D(null),e.onAccept(p.trim(),w.trim()||void 0).then(()=>{M("Invite accepted — the contact will appear once the sender verifies your identity."),y(""),S("")}).catch(fe=>D(String(fe))).finally(()=>E(!1)))},children:[v.jsx("p",{className:"muted",children:"Paste the invite you received, or scan a QR code."}),$?v.jsx(kz,{onDecode:V=>{y(V),j(!1)},onClose:()=>j(!1)}):v.jsxs("button",{type:"button",className:"btn",onClick:()=>j(!0),children:[v.jsx(Ee,{name:"monitor",size:15}),"Scan QR code"]}),v.jsx("textarea",{className:"field mono","aria-label":"Invite",rows:5,value:p,onChange:V=>y(V.target.value),placeholder:"Paste invite text…"}),v.jsx("input",{className:"field",value:w,onChange:V=>S(V.target.value),placeholder:"Rename them (optional)",maxLength:64}),v.jsx("button",{className:"btn primary",type:"submit",disabled:C||!p.trim(),children:C?"Connecting…":"Add contact"}),T&&v.jsx("p",{className:"muted",children:T}),P&&v.jsx("p",{className:"onb-error",children:P})]})]})})}function bz(e){const[t,n]=k.useState(e.identity.bio??""),[i,s]=k.useState(!1),[l,a]=k.useState(null),[c,d]=k.useState(e.push.preview),h=xM(),m=!e.workerSupported||e.push.status==="unsupported"?h??"Unavailable — requires a secure browser with service-worker support.":e.push.status==="needs-permission"?h??"Needs permission — allow notifications, then choose Enable or Repair.":e.push.status==="on"?"On — this browser and the server agree on the current Web Push configuration.":e.push.status==="repairing"?"Repairing — checking the browser subscription and server acknowledgement…":e.push.status==="error"?"Repair needed — the browser and server could not confirm the same subscription.":"Off — enable notifications for this browser.";return v.jsxs(Ds,{title:"Settings",onClose:e.onClose,wide:!0,children:[v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Display name"}),v.jsx("input",{className:"field",readOnly:!0,value:e.identity.name})]}),v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Your address"}),v.jsx("input",{className:"field mono",readOnly:!0,value:e.identity.cid,onFocus:p=>p.currentTarget.select()}),v.jsx("p",{className:"muted",children:"Your public address on ours. Share an invite to connect more easily."})]}),v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Public bio"}),v.jsx("textarea",{className:"field",rows:3,value:t,onChange:p=>{n(p.target.value),s(!1),a(null)}}),v.jsx("button",{className:"btn sm",onClick:()=>{a(null),e.onSaveBio(t).then(()=>s(!0)).catch(p=>a(String(p)))},children:i?"Saved":"Save bio"}),l&&v.jsx("p",{className:"onb-error",children:l})]}),v.jsxs("label",{style:{display:"flex",gap:9},children:[v.jsx("input",{type:"checkbox",checked:e.dark,onChange:e.onToggleDark})," Dark mode"]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"Notifications"}),v.jsx("p",{className:e.push.status==="needs-permission"||e.push.status==="error"?"onb-error":"muted",children:m}),h&&h!==m&&v.jsx("p",{className:"muted","data-testid":"push-platform-guidance",children:h}),v.jsxs("fieldset",{style:{border:0,padding:0,margin:"12px 0"},children:[v.jsx("legend",{className:"lbl",children:"Lock-screen preview"}),v.jsxs("label",{style:{display:"block",marginTop:7},children:[v.jsx("input",{type:"radio",name:"push-preview",checked:c==="full",onChange:()=>d("full")})," Full — sender and message text or filename"]}),v.jsxs("label",{style:{display:"block",marginTop:7},children:[v.jsx("input",{type:"radio",name:"push-preview",checked:c==="private",onChange:()=>d("private")})," Private — generic content only"]})]}),v.jsx("p",{className:"muted",children:"Full previews can expose sender names, message text, and filenames on the lock screen. The push provider still sees delivery endpoint, timing, and payload size metadata in either mode."}),v.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.push.status==="on"?v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("disable",c),children:"Disable notifications"}),v.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("repair",c),children:"Repair"}),c!==e.push.preview&&v.jsx("button",{className:"btn primary",disabled:e.busy,onClick:()=>void e.onPushAction("enable",c),children:"Save preview"})]}):v.jsx("button",{className:"btn primary",disabled:e.busy||!e.workerSupported||e.push.status==="unsupported",onClick:()=>void e.onPushAction(e.push.status==="error"||e.push.blocked?"repair":"enable",c),children:e.busy?"Repairing…":e.push.status==="error"||e.push.blocked?"Repair":"Enable notifications"})})]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"App status"}),v.jsx("p",{className:"muted",children:e.offline?"Offline — reconnecting. Message and identity data are never cached.":"Online."}),e.onInstall&&v.jsx("button",{className:"btn",onClick:e.onInstall,children:"Install app"}),e.updateAvailable&&v.jsx("button",{className:"btn primary",onClick:e.onReloadUpdate,children:"Reload to update"})]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"Build"}),v.jsx("input",{className:"field mono",readOnly:!0,value:e.build?`${e.build.version} · ${e.build.sha}`:"Loading…"})]})]})}function Cz(e,t,n,i,s=6e4){return!t||!t.sha?"current":t.sha===e?(n.remoteSha=null,n.firstMismatchAt=null,"current"):(n.remoteSha=t.sha,(n.firstMismatchAt===null||n.firstMismatchAt===void 0)&&(n.firstMismatchAt=i),n.controllerChanged?"newer-available":i-n.firstMismatchAt>=s?"stuck":"newer-available")}const Ez="4fdbcfd825d44710b00578b4b8358444fcdd493c",Tz=15*6e4,Pz=6e4,Rz=Cz;async function Mz(){try{const e=await fetch("/version.json",{cache:"no-store"});return e.ok?await e.json():null}catch{return null}}function Az(e){const t={remoteSha:null,firstMismatchAt:null,controllerChanged:!1},n=()=>{t.controllerChanged=!0};navigator.serviceWorker?.addEventListener("controllerchange",n);let i=!1;const s=async()=>{const d=await Mz(),h=Rz(Ez,d,t,Date.now(),Pz);h==="newer-available"?(e.onUpdateAvailable(),navigator.serviceWorker?.getRegistration().then(m=>m?.update())):h==="stuck"&&!i&&(i=!0,e.onStuck(d.sha))},l=setTimeout(()=>void s(),5e3),a=setInterval(()=>void s(),Tz),c=()=>{document.visibilityState==="visible"&&s()};return document.addEventListener("visibilitychange",c),()=>{clearTimeout(l),clearInterval(a),document.removeEventListener("visibilitychange",c),navigator.serviceWorker?.removeEventListener("controllerchange",n)}}async function Nz(e){try{const t=await navigator.serviceWorker.getRegistrations();await Promise.all(t.map(i=>i.unregister()));const n=await caches.keys();await Promise.all(n.map(i=>caches.delete(i)))}catch{}return location.replace(location.pathname+"?v="+encodeURIComponent(e)),new Promise(()=>{})}function Iz(){const e=new URL(location.href);e.searchParams.has("v")&&(e.searchParams.delete("v"),history.replaceState(null,"",e.pathname+e.search+e.hash))}const Sx=[0,100,400,1e3,3e3,6e3],bx=e=>new Promise(t=>setTimeout(t,e)),Cx={delivered:1,read:2},Ex="ours-dark-v3",Tx="#chat-message-",Px=Rl,jz=e=>e instanceof Error&&e.message?e.message:"The request could not be completed.";function Qk(e,t){const n=new Map,i=[];for(const s of e?.messages??[]){const l={dir:s.dir,text:s.text,date:s.date,read:s.read,wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:null,receipt:s.receipt??void 0,receiptless:s.dir==="out"&&!s.wire_id};s.wire_id?n.set(s.wire_id,l):i.push(l)}for(const s of t){const l=n.get(s.wire_id);n.set(s.wire_id,{dir:s.dir,text:"",date:s.date,read:l?.read??s.dir==="out",wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:l?.replyTo??null,kind:"file",filename:s.filename,mime:s.mime,receipt:l?.receipt})}return[...i,...n.values()].sort((s,l)=>{const a=Px(s.date)-Px(l.date);return a===0?s.wireId.localeCompare(l.wireId):a})}function Dz(e){const t={};for(const n of Object.values(e.roots??{}))t[n.root_cid]={label:n.root_name,note:"Verified identity"};return t}function _z(e,t){return[...e.contacts.contacts.map(i=>{const s=e.contacts.roots?.[i.container_id],l=or(e,i.container_id),c=Qk(l,t[i.container_id]??[]).at(-1),d=Al(i);return{id:i.container_id,name:d,announcedName:i.name,initials:rd(d),when:c?P2(c.date):"",activityAt:c?.date??"",last:c?.kind==="file"?L2(c.filename,c.mime):l?.preview??c?.text??"",unread:l?.unread??0,status:"active",root:s?.root_cid??null,sub:s?`role “${s.role_id}” of ${s.root_name}`:"",roleId:s?.role_id??null,rootName:s?.root_name??null,mine:!1,kind:s?"agent":"person"}}),...e.contacts.pending.map(i=>{const s=Al(i);return{id:`pending:${i.container_id}`,name:s,announcedName:i.name,initials:rd(s),when:"",activityAt:"",last:`${i.queued} queued · approval required`,unread:0,status:"pending",root:null,sub:"",roleId:null,rootName:null,mine:!1,kind:"person"}})]}function Lz(){return v.jsx(Oz,{})}function Oz(){const e=k.useRef(hM(Gy(window.location.pathname))).current,[t,n]=k.useReducer(Jy,e),[i,s]=k.useState(null),l=k.useRef(0),a=k.useRef(null),c=k.useRef(t),d=k.useRef(new uM),h=k.useRef(null),m=k.useRef(new Map),p=k.useRef(new Map),[y,w]=k.useState({}),S=k.useRef(y),[C,E]=k.useState(null),T=k.useRef(new Set),[M,P]=k.useState(null),D=k.useRef(M),$=k.useRef(!1),[j,Y]=k.useState([]),[U,O]=k.useState(null),[N,X]=k.useState(()=>localStorage.getItem(Ex)!=="0"),[V,fe]=k.useState(null),[J,ee]=k.useState({supported:!1,offline:!navigator.onLine,updateAvailable:!1,registration:null}),[xe,Pe]=k.useState({status:"unsupported",preview:"full"}),[Q,de]=k.useState(!1),R=k.useRef(!1),[F,G]=k.useState(()=>window.location.hash.startsWith(Tx)),{toasts:A,push:te,dismiss:ge,clear:ye}=yz(),me=k.useCallback(W=>{c.current=Jy(c.current,W),n(W)},[]),we=k.useCallback(W=>{$.current=W},[]);k.useEffect(()=>{c.current=t},[t]),D.current=M,S.current=y,k.useMemo(()=>(cv(Object.values(y).flat()),null),[y]),k.useEffect(()=>(document.documentElement.classList.toggle("theme-dark",N),()=>document.documentElement.classList.remove("theme-dark")),[N]);const pe=k.useCallback(W=>me({type:"error",message:jz(W)}),[me]),Ve=k.useCallback(()=>{const W=c.current;return{visibility:document.visibilityState,appRoute:W.route.name==="chats"?"chats":"other",selectedContactCid:ri(W),desktopLayout:h.current?.matches??window.innerWidth>=861,mobileDetailOpen:W.mobileDetailOpen,conversationCoveringDialogOpen:D.current!==null}},[]),qe=k.useCallback(async(W,le=!0)=>{try{const ne=await Ke.conversation(W);return me({type:"page",contactCid:W,page:ne}),ne}catch(ne){return le&&pe(ne),null}},[me,pe]),it=k.useCallback(async(W,le=!0)=>{try{const ne=await Ke.files(W);return cv(ne.files),w(Me=>({...Me,[W]:ne.files})),ne.files}catch(ne){return le&&pe(ne),null}},[pe]);k.useEffect(()=>Az({onUpdateAvailable:()=>ee(W=>({...W,updateAvailable:!0})),onStuck:W=>{Nz(W)}}),[]);const We=k.useCallback(async()=>{const W=await Ke.contacts();return me({type:"contacts",contacts:{...W,pending:W.pending??[]}}),W},[me]),at=k.useCallback(async()=>{try{const[W,le,ne]=await Promise.all([Ke.identity(),Ke.contacts(),Ke.buildInfo()]),Me={...le,pending:le.pending??[]};return c.current.identity&&c.current.identity.cid!==W.cid&&(j2(),S.current={},w({})),me({type:"snapshot",identity:W,contacts:Me}),O(ne),await Promise.all(Me.contacts.flatMap(ke=>[qe(ke.container_id,!1),it(ke.container_id,!1)])),ri(c.current)}catch(W){return pe(W),null}},[me,it,qe,pe]),xt=k.useCallback(async W=>{await d.current.request(W,async()=>{lM(W,Ve())&&(await Ke.markRead(W),await Promise.all([qe(W),We()]))}).catch(pe)},[Ve,We,qe,pe]),Vt=k.useCallback(async W=>{const le=++l.current;a.current?.abort();const ne=new AbortController;a.current=ne,s(null),ye(W),it(W,!1);let Me;try{Me=await Ke.conversation(W,void 0,ne.signal)}catch(Ye){ne.signal.aborted||pe(Ye);return}if(ne.signal.aborted||le!==l.current)return;me({type:"page",contactCid:W,page:Me});const ke=Me.unread;let ce=[...Me.messages],Ae=Me.nextBefore;const ft=new Set,nn=new Set(ce.map(Ye=>Ye.wire_id).filter(Boolean)),ot=()=>ce.filter(Ye=>Ye.dir==="in"&&!Ye.read);for(;ot().length<ke&&Ae&&!ft.has(Ae);){ft.add(Ae);let Ye;try{Ye=await Ke.conversation(W,Ae,ne.signal)}catch{break}if(ne.signal.aborted||le!==l.current)return;const cr=Ye.messages.filter(fr=>!fr.wire_id||!nn.has(fr.wire_id));if(!cr.length&&Ye.nextBefore===Ae)break;for(const fr of cr)fr.wire_id&&nn.add(fr.wire_id);ce=[...cr,...ce],me({type:"older_page",contactCid:W,page:Ye,newer:Me.messages}),Ae=Ye.nextBefore}const Ge=ot()[0];Ge?.wire_id&&le===l.current&&!ne.signal.aborted&&s({contactCid:W,wireId:Ge.wire_id,count:ke}),await xt(W)},[ye,me,xt,it,pe]),lt=k.useCallback(async(W,le,ne="page")=>{const Me=`page:${W}:${ne}`,ke=(m.current.get(Me)??0)+1;m.current.set(Me,ke);for(const ce of Sx){if(ce&&await bx(ce),m.current.get(Me)!==ke)return;const Ae=await qe(W,!1);if(Ae&&le(Ae))return}},[qe]),Pt=k.useCallback(async(W,le)=>{const ne=`file:${W}`,Me=(m.current.get(ne)??0)+1;m.current.set(ne,Me);for(const ke of Sx)if(ke&&await bx(ke),m.current.get(ne)!==Me||(await it(W,!1))?.some(Ae=>Ae.wire_id===le))return},[it]),fn=k.useRef(!1);k.useEffect(()=>{if(!F||!t.loaded)return;const W=decodeURIComponent(window.location.hash.slice(Tx.length)),le=ri(c.current);if(!W||!le){G(!1);return}if(or(c.current,le)?.messages.some(ne=>ne.wire_id===W)){G(!1);return}fn.current||(fn.current=!0,lt(le,ne=>ne.messages.some(Me=>Me.wire_id===W),`anchor:${W}`).catch(()=>{}).finally(()=>G(!1)))},[F,lt,t.loaded,t.pages]),k.useMemo(()=>(I2({url:W=>Object.values(S.current).flat().find(ne=>ne.wire_id===W)?.available?Ke.mediaUrl(W):null,bytes:async W=>{if(!Object.values(S.current).flat().find(Me=>Me.wire_id===W)?.available)return null;const ne=await fetch(Ke.mediaUrl(W),{cache:"no-store",credentials:"same-origin"});if(!ne.ok)throw new Error(`Media request failed (HTTP ${ne.status})`);return new Uint8Array(await ne.arrayBuffer())},fetch:async W=>{const le=Object.values(S.current).flat().find(ne=>ne.wire_id===W);if(!le)throw new Error("Media record is unavailable");await Ke.fetchFiles([W]),await it(le.contact_id)}}),null),[it]),k.useEffect(()=>{let W;gM(ne=>{ee(ne),nv(ne.registration).then(Pe).catch(()=>Pe(Me=>({...Me,status:"error"})))},{shouldDeferReload:()=>$.current||D.current!==null}).then(ne=>{W=ne}).catch(pe);const le=ne=>{ne.preventDefault(),fe(ne)};return window.addEventListener("beforeinstallprompt",le),()=>{W?.(),window.removeEventListener("beforeinstallprompt",le)}},[pe]),k.useEffect(()=>CM(),[]),k.useEffect(()=>{if(!(!J.registration||xe.status!=="on"))return aM({registration:J.registration,identity:Ke.identity,onEvent:d0})},[xe.status,xe.bindingId,J.registration]),k.useEffect(()=>{const W=()=>Pe(le=>({...le,status:"error"}));return window.addEventListener("ours-push-repair-required",W),()=>window.removeEventListener("ours-push-repair-required",W)},[]),k.useEffect(()=>{window.location.pathname==="/"&&window.history.replaceState(null,"",ni()),h.current=window.matchMedia("(min-width: 861px)");const W=()=>{const ce=Gy(window.location.pathname);a.current?.abort(),l.current+=1,s(null),me({type:"route",route:ce}),R.current&&ce.name==="chats"&&ce.contactCid&&(R.current=!1,requestAnimationFrame(()=>document.querySelector("[data-contact-trigger]")?.focus({preventScroll:!0}))),ce.name==="chats"&&ce.contactCid&&Vt(ce.contactCid)},le=()=>{if(document.visibilityState!=="visible")return;const ce=ri(c.current);ce&&xt(ce),g0(),J.registration&&nv(J.registration).then(Pe).catch(()=>Pe(Ae=>({...Ae,status:"error"})))};window.addEventListener("popstate",W),document.addEventListener("visibilitychange",le);const ne=ce=>{const Ae=ce.type==="sync_required"?`${ce.type}:${ce.reason}`:ce.type==="receipt_received"?`${ce.type}:${ce.contact_id}:${ce.kind}:${ce.wire_ids.join(",")}`:`${ce.type}:${ce.contact_id}:${ce.wire_id}`,ft=Date.now(),nn=p.current.get(Ae)??0;p.current.set(Ae,ft);for(const[ot,Ge]of p.current)ft-Ge>6e4&&p.current.delete(ot);ft-nn<6e4||(async()=>{if(ce.type==="sync_required"){await at();return}if(We().catch(pe),ce.type==="file_received"){await Pt(ce.contact_id,ce.wire_id);const ot=c.current.contacts.contacts.find(Ge=>Ge.container_id===ce.contact_id);ri(c.current)!==ce.contact_id&&ot&&te(ce.contact_id,Al(ot),"New file");return}if(ce.type==="message_received"){const ot=c.current.contacts.contacts.find(Ge=>Ge.container_id===ce.contact_id);await lt(ce.contact_id,Ge=>Ge.messages.some(Ye=>Ye.wire_id===ce.wire_id),`message:${ce.wire_id}`),ri(c.current)===ce.contact_id?await xt(ce.contact_id):ot&&te(ce.contact_id,Al(ot),"New message");return}me({type:"receipt",contactCid:ce.contact_id,kind:ce.kind,wireIds:ce.wire_ids}),await lt(ce.contact_id,ot=>ce.wire_ids.every(Ge=>{const Ye=ot.messages.find(cr=>cr.wire_id===Ge);return!!Ye?.receipt&&Cx[Ye.receipt]>=Cx[ce.kind]}),`receipt:${ce.wire_ids.join(",")}`)})().catch(pe)},Me=rM(ne),ke=iM(ne,ce=>me({type:"connection",connection:ce}));return at().then(ce=>{ce&&Vt(ce)}),()=>{ke(),Me(),window.removeEventListener("popstate",W),document.removeEventListener("visibilitychange",le)}},[lt,Pt,me,xt,Vt,te,We,at,pe,J.registration]);const It=(W,le,ne)=>{window.history.pushState({oursMessenger:!0},"",le),me({type:"route",route:W,mobileDetailOpen:ne})},jt=async W=>{It({name:"chats",contactCid:W},ni(W),!0),await Vt(W)},Ln=async W=>{const le=or(c.current,W);if(!(!le?.nextBefore||T.current.has(W))){T.current.add(W),E(W);try{const ne=await Ke.conversation(W,le.nextBefore);me({type:"older_page",contactCid:W,page:ne,newer:le.messages})}catch(ne){pe(ne)}finally{T.current.delete(W),E(null)}}},ze=ri(t),ur=t.contacts.contacts.find(W=>W.container_id===ze),bn=k.useMemo(()=>_z(t,y),[t,y]),q=bn.find(W=>W.id===ze)??null,se=ze?Qk(or(t,ze),y[ze]??[]):[],_=t.identity,Z=t.loaded?ze&&!or(t,ze)||F?"updating":t.connection!=="live"?"connecting":null:"connecting",he=async(W,le=xe.preview)=>{if(J.registration){de(!0),Pe(ne=>({...ne,status:"repairing",preview:le}));try{Pe(await(W==="enable"?m0(J.registration,{preview:le}):W==="repair"?SM(J.registration,le):bM(J.registration,xe)))}catch(ne){Pe(Me=>({...Me,status:"error"})),pe(ne)}finally{de(!1)}}},De=()=>{Y([]),P("invite"),Ke.invites().then(Y).catch(pe)};return t.route.name==="not_found"?v.jsxs("div",{className:"centered-screen",children:[v.jsx("h1",{children:"Page not found"}),v.jsx("button",{className:"btn primary",onClick:()=>It({name:"chats",contactCid:null},ni()),children:"Open chats"})]}):_?v.jsx("div",{className:N?"theme-dark":"",style:{height:"100%"},children:v.jsxs("div",{className:"app signal-app",children:[v.jsxs("main",{className:"section signal-stage"+(t.mobileDetailOpen?" show-detail":""),children:[v.jsx(uz,{contacts:bn,roots:Dz(t.contacts),selected:ze,onSelect:W=>{W.startsWith("pending:")||jt(W)},onInvite:De,onSettings:()=>P("settings"),onApprovePending:async W=>{try{return await Ke.respondToIntroduction(W,"approve"),await at(),!0}catch(le){return pe(le),!1}},onRejectPending:async W=>{try{return await Ke.respondToIntroduction(W,"reject"),await at(),!0}catch(le){return pe(le),!1}}}),t.route.name==="contact"&&q?v.jsx(cz,{contact:q,messages:se,onBack:()=>{R.current=!0,fM(window.history.state)==="back"?window.history.back():(window.history.replaceState({oursMessenger:!0},"",ni(q.id)),me({type:"route",route:{name:"chats",contactCid:q.id},mobileDetailOpen:!0}),requestAnimationFrame(()=>document.querySelector("[data-contact-trigger]")?.focus({preventScroll:!0})),R.current=!1)},onRename:W=>void Ke.renameContact(q.id,W).then(at).catch(pe),onRemove:()=>{confirm(`Remove “${ur?.name??"contact"}”?`)&&Ke.removeContact(q.id).then(()=>(window.history.replaceState({oursMessenger:!0},"",ni()),me({type:"route",route:{name:"chats",contactCid:null},mobileDetailOpen:!1}),at())).catch(pe)},onOpenMessage:W=>{It({name:"chats",contactCid:q.id},ni(q.id),!0);let le=12;const ne=()=>{const Me=document.getElementById(`chat-message-${encodeURIComponent(W)}`),ke=Me?.closest(".messages");if((!Me||!ke||ke.clientHeight<=0)&&le-- >0){requestAnimationFrame(ne);return}if(!Me||!ke)return;const ce=Me.getBoundingClientRect(),Ae=ke.getBoundingClientRect(),ft=ke.scrollTop+ce.top-Ae.top-Math.max(0,(ke.clientHeight-ce.height)/2),nn=Math.max(0,Math.min(ft,ke.scrollHeight-ke.clientHeight));ke.scrollTo({top:nn,behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"})};requestAnimationFrame(ne)},indexOffset:or(t,q.id)?.hasMore?Math.max(1,(or(t,q.id)?.total??se.length)-se.length):0,onSendText:async(W,le)=>{const ne=await Ke.send(q.id,W,le);return await qe(q.id,!1),ne.wire_id??void 0},onSendFile:async(W,le)=>{await Ke.sendFile(q.id,new Blob([W.bytes],{type:W.mime}),W.filename,W.mime,le),await Promise.all([it(q.id),qe(q.id,!1)])}}):v.jsx(fz,{contact:q,messages:se,syncing:Z,unreadOpen:i?.contactCid===ze?i:null,hiddenEarlier:or(t,ze??"")?.hasMore?Math.max(1,(or(t,ze??"")?.total??se.length)-se.length):0,onLoadEarlier:ze&&C!==ze?()=>void Ln(ze):void 0,onBack:()=>{a.current?.abort(),l.current+=1,s(null),It({name:"chats",contactCid:null},ni(),!1)},onOpenContact:()=>{ze&&It({name:"contact",contactCid:ze},cM(ze),!0)},onDraftChange:we,onSend:async(W,le,ne)=>{if(!ze)return;const Me=ze,ke=await Ke.send(Me,W,le,ne);return me({type:"sent_message",contactCid:Me,message:{dir:"out",text:W,date:new Date().toISOString(),read:!0,wire_id:ke.wire_id??"",receipt:null,reply_to:le?{wire_id:le}:null}}),ke.wire_id?lt(Me,ce=>ce.messages.some(Ae=>Ae.wire_id===ke.wire_id),`send:${ke.wire_id}`):We().catch(pe),ke.wire_id??void 0},onSendFile:async(W,le)=>{ze&&(await Ke.sendFile(ze,new Blob([W.bytes],{type:W.mime}),W.filename,W.mime,le),await Promise.all([it(ze),qe(ze,!1)]))},onFetchFile:async W=>{await Ke.fetchFiles([W]),ze&&await it(ze)}},ze??"no-conversation")]}),v.jsxs("div",{className:"app-banners",children:[J.offline&&v.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:"Offline — reconnecting to the network…"}),t.connection!=="live"&&v.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:t.connection==="retrying"?"Live updates interrupted — reconnecting…":"Connecting to live updates…"}),J.updateAvailable&&v.jsxs("div",{className:"banner info",children:[v.jsx("span",{role:"status","aria-live":"polite",children:"A new version is available."}),v.jsx("span",{className:"banner-actions",children:v.jsx("button",{className:"linkbtn",onClick:()=>{J.registration&&ev(J.registration)},children:"Restart now"})})]}),v.jsx(xz,{items:A,onDismiss:ge,onOpen:W=>void jt(W)})]}),M==="invite"&&v.jsx(Sz,{identity:_,invites:j,onRefresh:async()=>Y(await Ke.invites()),onCreate:async(W,le)=>(await Ke.createInvite(W,le)).blob,onAccept:async(W,le)=>{await Ke.addContact(W,le),await at()},onRevoke:async W=>{await Ke.revokeInvite(W)},onClose:()=>{P(null),at()}}),M==="settings"&&v.jsx(bz,{identity:_,push:xe,workerSupported:J.supported,busy:Q,offline:J.offline,updateAvailable:J.updateAvailable,build:U,dark:N,onToggleDark:()=>X(W=>(localStorage.setItem(Ex,W?"0":"1"),!W)),onSaveBio:async W=>{await Ke.setBio(W),await at()},onPushAction:he,onInstall:V?()=>void V.prompt().then(()=>fe(null)):void 0,onReloadUpdate:()=>{J.registration&&ev(J.registration)},onClose:()=>{D.current=null,P(null),ze&&xt(ze)}}),t.error&&v.jsxs("div",{className:"banner error",role:"alert","aria-live":"assertive",children:[t.error,v.jsx("button",{className:"linkbtn",onClick:()=>me({type:"error",message:null}),children:"dismiss"})]})]})}):v.jsx("div",{className:N?"theme-dark":"",style:{height:"100%"},children:v.jsx("div",{className:"centered-screen",children:v.jsx("p",{className:"muted",children:"Loading…"})})})}Iz();const Zk=document.getElementById("root");if(!Zk)throw new Error("missing #root");tC.createRoot(Zk).render(v.jsx(ZP,{reducedMotion:"user",children:v.jsx(Lz,{})}));export{Ch as _,Id as g};
|
|
322
|
-
//# sourceMappingURL=index-
|
|
320
|
+
`)}).join("")}function qF({children:e}){const t=k.isValidElement(e)?e:null,n=Kk(t?.props.className);return v.jsxs("div",{className:"message-code-block","data-language":n||void 0,children:[n&&v.jsx("div",{className:"message-code-language",children:n}),v.jsx("pre",{children:e})]})}const XF=[Vk],YF={a:({node:e,children:t,href:n,...i})=>{const s=Hk(n);return s?v.jsx("a",{...i,href:s,target:"_blank",rel:"noopener noreferrer",children:t}):v.jsx("span",{className:"message-link-blocked",children:t})},img:({alt:e})=>v.jsxs("span",{className:"message-image-placeholder",children:["[image: ",e||"remote image blocked","]"]}),pre:qF,code:({node:e,className:t,children:n,...i})=>v.jsx("code",{className:t,"data-language":Kk(t),...i,children:n})},yx=k.memo(function({text:t,className:n="bubble-text message-markdown"}){return t.length>WF?v.jsx("div",{className:`${n} message-markdown-plaintext`,"data-render-mode":"plaintext",children:t}):v.jsx("div",{className:n,"data-render-mode":"markdown",children:v.jsx(zk,{remarkPlugins:XF,components:YF,urlTransform:i=>Hk(i)??"",children:KF(t)})})}),yl={type:"spring",stiffness:430,damping:38,mass:.72},vx=10,qk=56,GF=18,QF=650;function ZF(e,t){return Math.abs(e)<vx&&Math.abs(t)<vx?"pending":Math.abs(e)>Math.abs(t)&&e>0?"drag":"reject"}function JF(e){const t=e.at(-1),n=t?e.slice(0,-1).reverse().find(i=>i.x!==t.x&&t.time-i.time<=100):void 0;return n&&t&&t.time>n.time?(t.x-n.x)/(t.time-n.time)*1e3:0}function ez(e,t){const n=JF(t);return n>=0&&(e>=qk||e>=GF&&n>=QF)}const Ad="ours.chats.listMode",cs="recent";function Xk(){try{return globalThis.localStorage}catch{return}}function tz(e=Xk()){try{return e?.getItem(Ad)==="identity"?"identity":cs}catch{return cs}}function nz(e,t=Xk()){const n=e==="identity"?"identity":cs;try{return t?.setItem(Ad,n),t?.getItem(Ad)===n?n:cs}catch{return cs}}function Ss(e){return typeof e=="string"?e:""}function _l(e,t){const n=Ss(e),i=Ss(t),s=n.normalize().toLowerCase(),l=i.normalize().toLowerCase();return s<l?-1:s>l?1:n<i?-1:n>i?1:0}function rz(e,t){const n=Rl(Ss(t.activityAt))-Rl(Ss(e.activityAt));if(n!==0)return n;const i=_l(e.name,t.name);return i!==0?i:_l(e.id,t.id)}function Nd(e){return[...e].sort(rz)}function xx(e){return e.contacts.length>0?Rl(Ss(e.contacts[0].activityAt)):0}function iz(e,t){const n=new Map,i=[];for(const l of e){const a=l.root||(t?.[l.id]?l.id:null);if(!a){i.push(l);continue}const c=t?.[a]||{label:a,note:""};let d=n.get(a);d||(d={id:`root:${a}`,rootId:a,label:c.label,note:c.note,contacts:[]},n.set(a,d)),d.contacts.push(l)}const s=[...n.values()].map(l=>({...l,contacts:Nd(l.contacts)}));return i.length>0&&s.push({id:"rootless",rootId:null,label:"Independent identities",note:"People, agents and apps without a verified Human/root group",contacts:Nd(i)}),s.sort((l,a)=>{const c=xx(a)-xx(l);if(c!==0)return c;const d=_l(l.label,a.label);return d!==0?d:_l(l.id,a.id)})}const oz=15e3;function Ef(e){const{c:t,active:n,grouped:i}=e,[s,l]=k.useState(!1),a=async(h,m)=>{if(!(!h||s)){l(!0);try{const p=await h();requestAnimationFrame(()=>{p?document.getElementById("chat-list-title")?.focus():m.focus()})}finally{l(!1)}}},c=v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"contact-avatar","aria-hidden":!0,children:t.initials}),v.jsxs("span",{className:"contact-copy",children:[v.jsxs("span",{className:"contact-row-topline",children:[v.jsx("span",{className:"contact-name",children:t.name}),t.when&&v.jsx("span",{className:"contact-time",children:t.when})]}),v.jsxs("span",{className:"contact-row-bottomline",children:[v.jsx("span",{className:"contact-last",children:t.last}),t.status==="pending"&&v.jsx("span",{className:"chip",children:"pending approval"}),!!t.unread&&v.jsx("span",{className:"contact-unread",children:t.unread})]})]}),t.status==="pending"&&v.jsxs("span",{className:"pending-actions",role:"group","aria-label":`Decide whether to accept ${t.name}`,children:[v.jsx("button",{type:"button",className:"linkbtn",disabled:s,onClick:h=>void a(e.onApprove,h.currentTarget),children:"Approve"}),v.jsx("button",{type:"button",className:"linkbtn quiet",disabled:s,onClick:h=>void a(e.onReject,h.currentTarget),children:"Reject"})]}),n&&v.jsx(ss.span,{className:"contact-active-glow",layoutId:"active-contact",transition:yl})]}),d="contact-row"+(n?" active":"")+(i?" grouped":"")+(t.status==="pending"?" pending":"");return t.status==="pending"?v.jsx("div",{className:d,children:c}):v.jsx(ss.button,{type:"button",className:d,onClick:e.onClick,children:c})}function sz(e){const{contacts:t,roots:n,selected:i}=e,[s,l]=k.useState(""),a=k.useRef(null),c=k.useRef(null),[d,h]=k.useState(()=>tz()),m=O=>O.name.toLowerCase().includes(s.toLowerCase()),p=t.filter(O=>O.status!=="pending"&&m(O)),y=t.filter(O=>O.status==="pending"&&m(O)),w=Nd(p),S=iz(p,n),C=p.length===0&&y.length===0,E=O=>{h(nz(O))},T=[{id:"recent",label:"Recent"},{id:"identity",label:"By identity"}],M=k.useRef(null),P=k.useRef({id:-1,x0:0,y0:0,mode:"idle"}),D=k.useRef(!1),$=(O,N)=>{const X=P.current;if(X.id!==O)return;const V=M.current;if(N&&X.mode==="drag"&&V){const fe=parseFloat(V.style.getPropertyValue("--mode-drag-x"))||0,J=Math.max(0,(V.clientWidth-8)/2);E(fe>=J/2?"identity":"recent"),D.current=!0,window.setTimeout(()=>{D.current=!1},0)}P.current={id:-1,x0:0,y0:0,mode:"idle"},V?.hasPointerCapture?.(O)&&V.releasePointerCapture(O),V?.classList.remove("dragging"),V?.style.removeProperty("--mode-drag-x")},j=O=>{!O.isPrimary||P.current.id!==-1||(P.current={id:O.pointerId,x0:O.clientX,y0:O.clientY,mode:"pending"})},Y=O=>{const N=P.current;if(N.id!==O.pointerId||N.mode==="idle")return;const X=O.clientX-N.x0,V=O.clientY-N.y0;if(N.mode==="pending"){if(Math.abs(X)<10&&Math.abs(V)<10)return;if(Math.abs(V)>Math.abs(X)){$(O.pointerId,!1);return}N.mode="drag",O.currentTarget.setPointerCapture?.(O.pointerId),O.currentTarget.classList.add("dragging")}O.preventDefault();const fe=Math.max(0,(O.currentTarget.clientWidth-8)/2),J=d==="identity"?fe:0;O.currentTarget.style.setProperty("--mode-drag-x",`${Math.min(fe,Math.max(0,J+X))}px`)},U=(O,N)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(O.key))return;O.preventDefault();const V=O.key==="Home"?"recent":O.key==="End"||N==="recent"?"identity":"recent";E(V),document.getElementById(`conversation-list-${V}`)?.focus()};return k.useLayoutEffect(()=>{const O=a.current,N=c.current;if(!O||!N)return;const X=()=>O.style.setProperty("--list-bottom-chrome-height",`${N.getBoundingClientRect().height}px`);X();const V=new ResizeObserver(X);return V.observe(N),()=>{V.disconnect(),O.style.removeProperty("--list-bottom-chrome-height")}},[]),v.jsxs("div",{className:"listcol",ref:a,children:[v.jsxs("div",{className:"listcol-head",children:[v.jsxs("div",{className:"listcol-titlebar",children:[v.jsxs("h2",{id:"chat-list-title",className:"listcol-title messenger-lockup",tabIndex:-1,children:[v.jsx("span",{className:"messenger-brand-ours",children:"Ours"}),v.jsx("span",{className:"messenger-brand-product",children:"messenger"})]}),v.jsxs("div",{className:"listcol-actions",children:[v.jsx("button",{className:"btn icon-btn desktop-invite","aria-label":"Invite",title:"Invite",onClick:e.onInvite,children:v.jsx(Ee,{name:"invite",size:18})}),v.jsx("button",{className:"icon-btn","aria-label":"Settings",title:"Settings",onClick:e.onSettings,children:v.jsx(Ee,{name:"settings",size:18})})]})]}),v.jsx("div",{ref:M,className:"conversation-list-modes",role:"tablist","aria-label":"Conversation list layout","data-mode":d,onPointerDown:j,onPointerMove:Y,onPointerUp:O=>$(O.pointerId,!0),onPointerCancel:O=>$(O.pointerId,!1),onLostPointerCapture:O=>$(O.pointerId,!1),children:T.map(O=>v.jsx("button",{id:`conversation-list-${O.id}`,type:"button",role:"tab","aria-selected":d===O.id,"aria-controls":"conversation-list-panel",tabIndex:d===O.id?0:-1,className:d===O.id?"active":"",onClick:N=>{if(D.current){N.preventDefault();return}E(O.id)},onKeyDown:N=>U(N,O.id),children:O.label},O.id))})]}),v.jsxs("div",{id:"conversation-list-panel",className:"listcol-scroll",role:"tabpanel","aria-labelledby":`conversation-list-${d}`,children:[d==="recent"&&w.length>0&&v.jsx("div",{className:"conversation-group",children:w.map(O=>v.jsx(Ef,{c:O,active:i===O.id,onClick:()=>e.onSelect(O.id)},O.id))}),d==="identity"&&S.map(O=>v.jsxs("div",{children:[v.jsxs("div",{className:"group-label",title:O.note,children:[O.rootId&&v.jsx(Ee,{name:"clusters"}),v.jsx("span",{children:O.label}),O.note&&v.jsxs("span",{className:"gl-note",children:["· ",O.note]})]}),v.jsx("div",{className:"conversation-group",children:O.contacts.map(N=>v.jsx(Ef,{c:N,grouped:O.rootId!==null,active:i===N.id,onClick:()=>e.onSelect(N.id)},N.id))})]},O.id)),y.length>0&&v.jsxs("div",{children:[v.jsx("div",{className:"group-label",children:v.jsx("span",{children:"Pending"})}),v.jsx("div",{className:"conversation-group",children:y.map(O=>v.jsx(Ef,{c:O,active:!1,onClick:()=>{},onApprove:()=>e.onApprovePending(O.id.slice(8)),onReject:()=>e.onRejectPending(O.id.slice(8))},O.id))})]}),C&&v.jsx("p",{className:"muted",style:{padding:"14px 10px",fontSize:"0.85rem"},children:"No contacts yet — share an invite to start."})]}),v.jsxs("div",{className:"list-bottom-chrome",ref:c,children:[v.jsxs("div",{className:"search adaptive-search",role:"search",children:[v.jsx("span",{className:"adaptive-search-icon","aria-hidden":!0,children:v.jsx(Ee,{name:"search"})}),v.jsx("input",{className:"field",placeholder:"Search people, agents, apps…",value:s,onChange:O=>l(O.target.value),onKeyDown:O=>{O.key==="Escape"&&(O.preventDefault(),l(""))}})]}),v.jsx("button",{type:"button",className:"icon-btn list-bottom-invite","aria-label":"Invite",title:"Invite",onClick:e.onInvite,children:v.jsx(Ee,{name:"invite",size:20})})]})]})}function az(e){const[t,n]=k.useState(!1),[i,s]=k.useState(e.contact.name),[l,a]=k.useState(!1),[c,d]=k.useState(null),h=k.useRef(!1);k.useEffect(()=>{const p=y=>{y.key!=="Escape"||l||c||t||(y.preventDefault(),e.onBack())};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t,c,e.onBack,l]);const m=()=>{if(h.current)return;h.current=!0;const p=i.trim();p&&p!==e.contact.name?e.onRename(p):s(e.contact.name),n(!1)};return v.jsxs("div",{className:"detail contact-screen",children:[v.jsxs("div",{className:"detail-head contact-screen-head",children:[v.jsx("button",{type:"button",className:"icon-btn detail-back contact-back","aria-label":"Back to conversation",onClick:e.onBack,children:v.jsx(Ee,{name:"back"})}),v.jsx("strong",{children:"Contact"})]}),v.jsxs("div",{className:"contact-screen-scroll",children:[v.jsxs("section",{className:"contact-hero","aria-labelledby":"contact-screen-name",children:[v.jsx("div",{className:"avatar accent contact-avatar-large","aria-hidden":!0,children:e.contact.initials}),t?v.jsx("input",{id:"contact-screen-name",className:"field contact-name-input",value:i,autoFocus:!0,onChange:p=>s(p.target.value),onBlur:m,onKeyDown:p=>{p.key==="Enter"&&m(),p.key==="Escape"&&(h.current=!0,s(e.contact.name),n(!1))}}):v.jsx("h2",{id:"contact-screen-name",children:e.contact.name}),v.jsxs("p",{children:[v.jsx(Ee,{name:"lock",size:13})," End-to-end encrypted connection"]})]}),v.jsxs("section",{className:"contact-action-group","aria-label":"Contact actions",children:[v.jsxs("button",{type:"button",onClick:()=>a(!0),children:[v.jsxs("span",{children:[v.jsx(Ee,{name:"paperclip"}),"Shared photos, files, and links"]}),v.jsx(Ee,{name:"chevron"})]}),v.jsxs("button",{type:"button",onClick:()=>{h.current=!1,s(e.contact.name),n(!0)},children:[v.jsxs("span",{children:[v.jsx(Ee,{name:"edit"}),"Rename contact"]}),v.jsx(Ee,{name:"chevron"})]})]}),v.jsxs("section",{className:"contact-identity","aria-labelledby":"contact-identity-title",children:[v.jsx("h3",{id:"contact-identity-title",children:"Verified identity"}),e.contact.roleId&&v.jsxs("p",{children:["Role ",v.jsx("strong",{children:e.contact.roleId})," of ",v.jsx("strong",{children:e.contact.rootName})]}),v.jsx("code",{children:e.contact.id}),v.jsxs("button",{type:"button",className:"btn sm",onClick:()=>void navigator.clipboard.writeText(e.contact.id),children:[v.jsx(Ee,{name:"copy",size:14}),"Copy identity"]})]}),v.jsxs("button",{type:"button",className:"contact-remove",onClick:e.onRemove,children:[v.jsx(Ee,{name:"trash"}),"Remove contact"]})]}),l&&v.jsx(NF,{messages:e.messages,indexOffset:e.indexOffset,onClose:()=>a(!1),onJump:e.onOpenMessage,onPreview:p=>{a(!1),d(p)}}),c&&(As(c.filename,c.mime)?v.jsx($k,{rec:c,onClose:()=>d(null)}):v.jsx(Bk,{rec:c,onClose:()=>d(null),onSendText:e.onSendText,onSendFile:e.onSendFile}))]})}const wx=e=>`chat-message-${encodeURIComponent(e)}`,Yk=()=>typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function kx(e){const{dir:t,canReply:n,onReply:i}=e,s=k.useRef(null),l=k.useRef(null),a=k.useRef(null),c=k.useRef(i);c.current=i;const d=t==="in"?1:-1,h=qk,m=84,p=()=>({id:-1,x0:0,y0:0,mode:"idle",armed:!1,distance:0,samples:[]}),y=k.useRef(p()),w=M=>{const P=l.current,D=a.current,$=Yk();if(P&&(P.style.transform=M&&!$?`translateX(${M}px)`:""),D){const j=Math.min(1,Math.abs(M)/h);D.style.opacity=String(j),D.style.transform=$?"scale(1)":`scale(${.5+.5*j})`}},S=(M,P)=>{const D=y.current;if(D.id!==M)return;const $=P&&D.mode==="drag"&&ez(D.distance,D.samples);y.current=p(),l.current?.classList.remove("swiping"),a.current?.classList.remove("armed"),w(0);const j=s.current;j?.hasPointerCapture?.(M)&&j.releasePointerCapture(M),$&&c.current()};k.useEffect(()=>{const M=s.current;if(!M)return;const P=D=>S(D.pointerId,!1);return M.addEventListener("lostpointercapture",P),()=>{M.removeEventListener("lostpointercapture",P);const D=y.current.id;D!==-1&&S(D,!1)}},[]);const C=M=>{const P=M.target,D=window.getSelection?.();!n||!M.isPrimary||M.pointerType==="mouse"||M.pointerType==="pen"&&M.button!==0||y.current.id!==-1||D&&!D.isCollapsed||P.closest('a, button, input, textarea, select, [role="button"], audio, video, img, [draggable="true"], .filecard, .filecard-bubble, .image-bubble, .voice-bubble, .ours-message-file, .attachment')||(y.current={id:M.pointerId,x0:M.clientX,y0:M.clientY,mode:"maybe",armed:!1,distance:0,samples:[{x:M.clientX*d,time:M.timeStamp}]},w(0))},E=M=>{const P=y.current;if(P.id!==M.pointerId||P.mode==="idle")return;const D=M.clientX-P.x0,$=M.clientY-P.y0,j=window.getSelection?.();if(j&&!j.isCollapsed){S(M.pointerId,!1);return}if(P.mode==="maybe"){const X=ZF(D*d,$);if(X==="pending")return;if(X==="drag")P.mode="drag",M.currentTarget.setPointerCapture?.(M.pointerId),l.current?.classList.add("swiping");else{P.mode="idle";return}}M.preventDefault();const Y=M.timeStamp;P.samples.push({x:M.clientX*d,time:Y}),P.samples=P.samples.filter(X=>Y-X.time<=120);let U=D*d;U<0&&(U=0),U>h&&(U=h+(U-h)*.35),U=Math.min(U,m),P.distance=U;const O=U*d,N=Math.abs(O)>=h;N!==P.armed&&(P.armed=N,a.current?.classList.toggle("armed",N),N&&navigator.vibrate?.(10)),w(O)},T=M=>{const P=y.current;P.id===M.pointerId&&P.mode==="drag"&&(P.samples.push({x:M.clientX*d,time:M.timeStamp}),P.distance=Math.max(0,(M.clientX-P.x0)*d),P.armed=P.distance>=h),S(M.pointerId,!0)};return v.jsxs("div",{ref:s,className:"msg-row "+(e.rowClass??t),style:n?{touchAction:"pan-y"}:void 0,onPointerDown:C,onPointerMove:E,onPointerUp:T,onPointerCancel:M=>S(M.pointerId,!1),onLostPointerCapture:M=>S(M.pointerId,!1),children:[n&&v.jsx("span",{className:"swipe-cue",ref:a,"aria-hidden":!0,children:v.jsx(Ee,{name:"reply",size:16})}),v.jsx("div",{className:"bubble-wrap",ref:l,children:e.children}),e.after]})}function lz(e){const{contact:t,messages:n}=e,[i,s]=k.useState(""),[l,a]=k.useState(!1),[c,d]=k.useState(null),[h,m]=k.useState(null),[p,y]=k.useState(null),[w,S]=k.useState(null),[C,E]=k.useState(null),[T,M]=k.useState(!1),[P,D]=k.useState(!1),[$,j]=k.useState(!1),[Y,U]=k.useState(null),O=k.useRef(null),N=k.useRef(null),X=k.useRef(null),V=k.useRef(null),fe=k.useRef(null),J=k.useRef(!1),ee=k.useRef(null),xe=k.useRef(!1),[Pe,Q]=k.useState(!1),[de,R]=k.useState(0),F=k.useRef(null),G=k.useRef(!0),A=k.useRef(null),te=k.useRef(0),ge=k.useRef(null),ye=k.useRef(new Map),me=k.useRef(0),we=k.useRef(null),pe=k.useRef(null),Ve=k.useRef(0),qe=k.useRef(null);k.useLayoutEffect(()=>{const _=X.current,Z=V.current,he=fe.current;if(!_||!Z||!he)return;let De=-1,W=-1,le=null;const ne=()=>{const ke=Math.round(Z.getBoundingClientRect().height),ce=Math.round(he.getBoundingClientRect().height);if(ke!==De&&(De=ke,_.style.setProperty("--conversation-head-height",`${ke}px`)),ce!==W){const Ae=G.current;W=ce,_.style.setProperty("--conversation-compose-height",`${ce}px`),Ae&&(le!==null&&cancelAnimationFrame(le),le=requestAnimationFrame(()=>{le=null;const ft=ee.current;ft&&G.current&&(ft.scrollTop=Math.max(0,ft.scrollHeight-ft.clientHeight))}))}};ne();const Me=new ResizeObserver(ne);return Me.observe(Z),Me.observe(he),()=>{Me.disconnect(),le!==null&&cancelAnimationFrame(le),_.style.removeProperty("--conversation-head-height"),_.style.removeProperty("--conversation-compose-height")}},[t?.id]),k.useEffect(()=>{s(""),m(null),y(null),d(null),S(null),E(null),M(!1),D(!1),j(!1),te.current+=1,U(null),ye.current.clear(),we.current=null,pe.current=null},[t?.id]),k.useEffect(()=>{if(!p)return;const _=p.reply?.wireId;n.some(he=>he.kind!=="file"&&he.dir==="out"&&!!he.wireId&&!p.wireIds.has(he.wireId)&&he.text===p.text&&(he.replyTo?.wireId??void 0)===_)&&(y(null),m(null),s(he=>he===p.draft?"":he),S(he=>he===p.reply?null:he))},[n,p]);const it=!!c?.wireId&&n.some(_=>_.wireId===c.wireId),We=k.useMemo(()=>c&&!it?[...n,c.message]:n,[n,c,it]);k.useEffect(()=>{it&&d(null)},[it]),k.useLayoutEffect(()=>{const _=N.current;if(!_)return;_.style.height="0px";const Z=Math.max(44,Math.min(_.scrollHeight,132));_.style.height=`${Z}px`,_.style.overflowY=_.scrollHeight>132?"auto":"hidden"},[i,t?.id]);const at=_=>{const Z=ee.current;if(!Z)return;const he=Math.max(0,Z.scrollHeight-Z.clientHeight);if(Math.abs(Z.scrollTop-he)<1){we.current=null,pe.current=null;return}const De=_&&!Yk();we.current=De?he:null,pe.current=De?Z.scrollTop:null,De?Z.scrollTo({top:he,behavior:"smooth"}):Z.scrollTop=he},xt=()=>{F.current===null&&(F.current=requestAnimationFrame(()=>{F.current=null;const _=ee.current;if(!_)return;const Z=_.scrollHeight-_.clientHeight-_.scrollTop>48;Q(Z),Z||R(0)}))};k.useLayoutEffect(()=>{if(!t){A.current=null,G.current=!0,Ve.current=0;return}const _=ee.current;if(!_)return;const Z=A.current!==t.id,he=Ve.current,De=We.length!==he,W=We.at(-1),le=W?W.wireId||`${W.date}:${W.text}`:null,ne=qe.current;if(Ve.current=We.length,qe.current=le,!Z&&!De&&we.current===null&&(G.current=_.scrollHeight-_.clientHeight-_.scrollTop<=48),Z||G.current)at(De&&!Z&&A.current!==null),G.current=!0;else if(De&&We.length>he&&le!==ne){const Me=ne===null?-1:We.findIndex(ke=>(ke.wireId||`${ke.date}:${ke.text}`)===ne);R(ke=>ke+Math.max(1,We.length-Math.max(0,Me+1)))}A.current=t.id,xt()},[t,We.length]),k.useLayoutEffect(()=>{if(xe.current||!e.unreadOpen||window.location.hash.startsWith("#chat-message-"))return;const _=ee.current,Z=document.getElementById(`unread-${wx(e.unreadOpen.wireId)}`);!_||!Z||(_.scrollTop=Math.max(0,Z.offsetTop-16),G.current=!1,xe.current=!0,xt())},[e.unreadOpen,We.length]),k.useLayoutEffect(()=>{const _=window.location.hash;if(!_.startsWith("#chat-message-"))return;const Z=document.getElementById(_.slice(1));Z&&(Z.scrollIntoView({block:"center"}),G.current=!1)},[t?.id,We.length]),k.useLayoutEffect(()=>{const _=ge.current,Z=ee.current;if(_===null||!Z)return;const he=requestAnimationFrame(()=>{ge.current===_&&(Z.scrollTop=_.top+Z.scrollHeight-_.height,ge.current=null)});return()=>cancelAnimationFrame(he)},[We.length]),k.useEffect(()=>{const _=ee.current;if(!_||typeof ResizeObserver>"u")return;const Z=_.firstElementChild;if(!Z)return;const he=new ResizeObserver(()=>{G.current&&at(we.current!==null),xt()});return he.observe(Z),he.observe(_),()=>{he.disconnect(),F.current!==null&&cancelAnimationFrame(F.current)}},[t?.id]);const Vt=async _=>{const Z=++te.current;m(null),j(!0);try{if(_.size>ts&&Wk(_.type,_.name)){const De=await UF(_,ts);if(Z!==te.current)return;E({filename:De.filename,mime:De.mime,bytes:De.bytes,originalSize:De.originalSize});return}if(_.size>ts){m(`"${_.name}" is ${Fr(_.size)} — files up to ${Fr(ts)} can be sent.`);return}const he=await _.arrayBuffer();if(Z!==te.current)return;E({filename:_.name||"file",mime:_.type||"application/octet-stream",bytes:new Uint8Array(he)})}catch(he){Z===te.current&&m(`Photo optimization failed: ${he instanceof Error?he.message:String(he)}`)}finally{Z===te.current&&j(!1)}},lt=()=>{!C||!e.onSendFile||P||(D(!0),e.onSendFile(C,w?.wireId).then(()=>{E(null),S(null)}).catch(_=>m(`File send failed: ${String(_)} — it was not delivered.`)).finally(()=>D(!1)))},Pt=e.onDraftChange;k.useEffect(()=>(Pt?.(i.trim().length>0||l),()=>Pt?.(!1)),[i,l,Pt]);const fn=new Map;for(const _ of We)_.wireId&&fn.set(_.wireId,_);const It=k.useMemo(()=>{const _=new Map;for(const Z of We)_.set(Z,Z.kind==="file"?null:Z.dir==="in"?y2(t?.announcedName??"",Z.text):null);return _},[We,t?.announcedName]),jt=_=>It.get(_)??null,Ln=_=>{if(_.dir==="out")return"You";const Z=jt(_);return Z&&Z.variant==="chat"?Z.author:t?.name??"Them"},ze=_=>{if(_.kind==="file")return _.mime?.startsWith("image/")?"Photo":eo(_.mime??"",_.filename??"")?"Voice message":_.filename||"File";const Z=jt(_);return Z?Z.text||C2(Z):_.text},ur=_=>{if(!_.replyTo)return null;const Z=fn.get(_.replyTo.wireId);return Z?{author:Ln(Z),text:ze(Z)}:{author:"",text:"Original message"}};if(!t)return e.emptyOverride?v.jsx(v.Fragment,{children:e.emptyOverride}):v.jsx("div",{className:"detail",children:v.jsxs("div",{className:"detail-empty",children:[v.jsx(Ee,{name:"chat"}),v.jsxs("div",{children:[v.jsx("div",{style:{fontWeight:650,color:"var(--text-2)"},children:"Select a conversation"}),v.jsx("div",{style:{fontSize:"0.85rem"},children:"Chat with people, agents and apps across ours."})]})]})});const bn=async()=>{const _=i,Z=_.trim(),he=!!p&&_===p.draft&&(w?.wireId??void 0)===p.reply?.wireId;if(!Z||J.current||he)return;p&&y(null),J.current=!0,a(!0),m(null);const De=w,W=De?.wireId,le=new AbortController;let ne=!1,Me=0;s(""),S(null);const ke=`optimistic-${++me.current}`;d({key:ke,wireId:null,message:{dir:"out",text:Z,date:new Date().toISOString(),read:!0,wireId:"",replyTo:W?{wireId:W}:null}});try{const ce=await Promise.race([e.onSend(Z,W,le.signal),new Promise((Ae,ft)=>{Me=window.setTimeout(()=>{ne=!0,le.abort(),ft(new Error("send timeout"))},oz)})]);ce?(ye.current.set(ce,ke),d(Ae=>Ae?.key===ke?{...Ae,wireId:ce}:Ae)):d(Ae=>Ae?.key===ke?null:Ae),y(null)}catch(ce){d(null),s(Ae=>Ae===""?_:Ae),S(Ae=>Ae===null?De:Ae),ne||!(ce instanceof Qf)?(y({draft:_,text:Z,reply:De,wireIds:new Set(n.flatMap(Ae=>Ae.wireId?[Ae.wireId]:[]))}),m(`${ne?"Send timed out":"Send connection was interrupted"} — delivery status is unknown. Check the conversation; edit the draft before sending again.`)):m(`Send failed: ${String(ce)} — the message was not delivered.`)}finally{window.clearTimeout(Me),J.current=!1,a(!1)}},q=!!p&&i===p.draft&&(w?.wireId??void 0)===p.reply?.wireId,se=_=>{_.wireId&&S({wireId:_.wireId,author:Ln(_),text:ze(_)})};return v.jsxs("div",{className:"detail detail-chat",ref:X,children:[v.jsx("div",{className:"detail-head",ref:V,children:v.jsxs("div",{className:"conv-peer",children:[v.jsx("button",{className:"icon-btn detail-back","aria-label":"Back to conversations",onClick:e.onBack,children:v.jsx(Ee,{name:"back"})}),v.jsxs("div",{className:"conv-peer-status",children:[v.jsx("span",{className:"conv-peer-name",children:t.name}),e.syncing&&v.jsxs("div",{className:"conv-sync",role:"status","aria-live":"polite",children:[v.jsx("span",{className:"conv-sync-dot","aria-hidden":!0}),e.syncing==="connecting"?"Connecting…":"Updating…"]}),!e.syncing&&v.jsxs("span",{className:"conv-contact-status",children:[v.jsx(Ee,{name:"lock",size:11}),"Encrypted connection"]})]}),v.jsx("button",{type:"button",className:"conv-contact-trigger conv-contact-avatar","data-contact-trigger":!0,onClick:e.onOpenContact,disabled:!e.onOpenContact,"aria-label":`Open contact details for ${t.name}`,children:v.jsx("span",{className:"conv-contact-initials","aria-hidden":!0,children:t.initials})})]})}),v.jsx("div",{className:"messages",ref:ee,tabIndex:-1,"aria-label":"Conversation timeline",onScroll:_=>{const Z=_.currentTarget,he=Z.scrollHeight-Z.clientHeight-Z.scrollTop;if(we.current!==null){const De=pe.current;if(De===null||Z.scrollTop>=De-1){pe.current=Z.scrollTop,he<=4&&(we.current=null,pe.current=null);return}we.current=null,pe.current=null}G.current=he<=48,xt()},onPointerDown:()=>{we.current=null,pe.current=null},onTouchStart:()=>{we.current=null,pe.current=null},onWheel:()=>{we.current=null,pe.current=null},onDragOver:_=>{e.onSendFile&&_.preventDefault()},onDrop:_=>{if(!e.onSendFile)return;_.preventDefault();const Z=_.dataTransfer.files?.[0];Z&&Vt(Z)},children:v.jsxs("div",{className:"messages-inner",children:[v.jsxs("div",{className:"e2e-note",children:[v.jsx(Ee,{name:"lock"}),"End-to-end encrypted · the broker only sees ciphertext"]}),(e.hiddenEarlier??0)>0&&e.onLoadEarlier&&v.jsxs("button",{className:"btn sm chat-load-earlier",onClick:()=>{G.current=!1;const _=ee.current;ge.current=_?{height:_.scrollHeight,top:_.scrollTop}:null,e.onLoadEarlier?.()},children:["Load earlier messages (",e.hiddenEarlier," remaining)"]}),v.jsx(qP,{initial:!1,children:We.map((_,Z)=>{const he=_===c?.message?c.key:_.wireId&&ye.current.get(_.wireId)||_.wireId||`${_.date}-${(e.hiddenEarlier??0)+Z}`,De=wx(_.wireId||he),W=We[Z-1],le=We[Z+1],ne=jt(_),Me=Ge=>{if(!Ge)return null;const Ye=jt(Ge);return Ye?Ye.variant==="system"?"room:system":`room:chat:${Ye.author}${Ye.role}`:Ge.dir},ke=Me(_),ce=!!W&&Me(W)===ke&&ke!=="room:system",Ae=!!le&&Me(le)===ke&&ke!=="room:system",ft=(_.dir==="out"?"out":"in")+(ce?" cont-top":"")+(Ae?" cont-bot":""),nn=_.wireId?v.jsx("button",{className:"msg-reply",title:"Reply",onClick:()=>se(_),children:v.jsx(Ee,{name:"reply",size:15})}):null;if(ne&&ne.variant==="system"){const Ge=ne.presentation??"system";return v.jsxs(ss.div,{className:"message-motion",id:De,initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:yl,children:[_.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${De}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsxs("div",{className:`room-system room-${Ge}-card`,role:"note",children:[ne.label&&v.jsx("span",{className:"room-system-label",children:ne.label}),ne.roomName&&v.jsx("strong",{className:"room-card-name",children:ne.roomName}),v.jsx(yx,{text:ne.text,className:"room-system-text message-markdown"}),!!ne.details?.length&&v.jsx("ul",{className:"room-card-details","aria-label":"Room event details",children:ne.details.map(Ye=>v.jsx("li",{children:Ye},Ye))}),v.jsxs("span",{className:"room-card-provenance",children:[ne.authoredBy&&v.jsx("span",{className:"room-card-author",children:ne.authoredBy}),v.jsx("span",{className:"room-system-at",children:ys(ne.authoredAt||_.date)})]})]})]},he)}if(_.kind==="file"){const Ge=S0(_.wireId)??{id:_.wireId,dir:_.dir,filename:_.filename??"file",mime:_.mime??"application/octet-stream",size:0,date:_.date};return v.jsxs(ss.div,{className:"message-motion",id:De,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:yl,children:[_.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${De}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsx(kx,{dir:_.dir==="out"?"out":"in",rowClass:ft,canReply:!!_.wireId,onReply:()=>se(_),after:nn,children:v.jsx("div",{className:`ours-message ours-message-file ours-message--${_.dir}`,children:v.jsx(CD,{rec:Ge,receipt:_.receipt,receiptless:_.receiptless,onPreview:U,onFetch:e.onFetchFile})})})]},he)}const ot=ur(_);return v.jsxs(ss.div,{className:"message-motion",id:De,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:yl,children:[_.wireId===e.unreadOpen?.wireId&&v.jsx("div",{id:`unread-${De}`,className:"unread-divider",role:"separator",children:v.jsx("span",{children:"Unread messages"})}),v.jsx(kx,{dir:_.dir==="out"?"out":"in",rowClass:ft,canReply:!!_.wireId,onReply:()=>se(_),after:nn,children:v.jsxs("div",{className:`ours-message ours-message--${_.dir}`,children:[ot&&v.jsxs("div",{className:"quote",children:[ot.author&&v.jsx("span",{className:"quote-author",children:ot.author}),v.jsx("span",{className:"quote-text",children:ot.text})]}),ne&&!ce&&v.jsxs(v.Fragment,{children:[ne.roomName&&v.jsx("div",{className:"room-message-room",children:ne.roomName}),v.jsxs("div",{className:"room-author",children:[v.jsx("span",{className:"room-author-name",children:ne.author}),ne.role&&v.jsx("span",{className:"room-author-role",children:ne.role})]})]}),v.jsx(yx,{text:ne?ne.text:_.text}),v.jsxs("div",{className:"bubble-at",children:[ys(ne?.authoredAt||_.date),_.dir==="out"&&v.jsx(b0,{receipt:_.receipt,receiptless:_.receiptless})]})]})})]},he)})}),v.jsx("div",{className:"thread-end","aria-hidden":!0})]})},t.id),Pe&&v.jsxs("button",{type:"button",className:"jump-latest btn sm","aria-label":de?`Jump to latest, ${de} new messages`:"Jump to latest",onClick:_=>{const Z=_.currentTarget===document.activeElement;R(0),at(!0),Z&&requestAnimationFrame(()=>ee.current?.focus({preventScroll:!0}))},children:[v.jsx("span",{children:"Jump to latest"}),!!de&&v.jsx("span",{className:"jump-latest-count","aria-live":"polite",children:de})]}),h&&v.jsxs("div",{className:"banner error",role:"alert",children:[h,h.startsWith("Send failed:")&&v.jsx("span",{className:"banner-actions",children:v.jsx("button",{className:"linkbtn",onClick:()=>void bn(),children:"retry"})})]}),v.jsxs("div",{className:"composer-wrap",ref:fe,children:[w&&v.jsxs("div",{className:"reply-bar",children:[v.jsx("div",{className:"reply-bar-line"}),v.jsxs("div",{className:"reply-bar-body",children:[v.jsxs("div",{className:"reply-bar-author",children:["Replying to ",w.author]}),v.jsx("div",{className:"reply-bar-text",children:w.text})]}),v.jsx("button",{className:"icon-btn",title:"Cancel reply",onClick:()=>S(null),children:v.jsx(Ee,{name:"close",size:16})})]}),C&&v.jsx(w1,{att:C,sending:P,onSend:lt,onDiscard:()=>E(null)}),$&&v.jsx("div",{className:"attachment-processing",role:"status",children:"Optimizing photo for secure delivery…"}),v.jsxs("div",{className:"composer"+(T?" recording":""),children:[e.onSendFile&&v.jsxs(v.Fragment,{children:[v.jsx("input",{ref:O,type:"file",style:{display:"none"},onChange:_=>{const Z=_.target.files?.[0];Z&&Vt(Z),_.target.value=""}}),v.jsx("button",{className:"icon-btn composer-tool",title:"Attach a file or photo",disabled:P||$||T,onClick:()=>O.current?.click(),children:v.jsx(Ee,{name:"paperclip",size:18})})]}),v.jsx("textarea",{ref:N,className:"field",rows:1,placeholder:(w?"Reply to "+w.author:"Message "+t.name)+"…",value:i,"aria-busy":l,onChange:_=>s(_.target.value),onKeyDown:_=>{_.key==="Enter"?!(window.matchMedia("(pointer: coarse)").matches||window.innerWidth<=860)&&!_.shiftKey&&(_.preventDefault(),bn()):_.key==="Escape"&&S(null)}}),e.onSendFile&&!i.trim()&&!C&&!$&&!P?v.jsx(k1,{disabled:P||$||!!C,onReady:_=>{M(!1),E(_)},onError:_=>{M(!1),m(_)},onActiveChange:M},t.id):v.jsxs("button",{className:"btn primary","aria-label":"Send",onPointerDown:_=>{_.button===0&&document.activeElement===N.current&&_.preventDefault()},onClick:()=>void bn(),disabled:l||q||!i.trim(),title:q?"Delivery status unknown — edit before sending again":void 0,children:[v.jsx(Ee,{name:"send",size:16}),v.jsx("span",{className:"btn-label",children:"Send"})]})]})]}),Y&&(As(Y.filename,Y.mime)?v.jsx($k,{rec:Y,onClose:()=>U(null)}):v.jsx(Bk,{rec:Y,onClose:()=>U(null),onSendText:e.onSend,onSendFile:e.onSendFile}))]})}const Gk=3;function uz(e,t,n=Gk){return[t,...e.filter(i=>i.cid!==t.cid)].slice(0,n)}function cz(e,t){return e.filter(n=>n.id!==t)}const fz=6e3,dz=uz,hz=cz;function pz(){const[e,t]=k.useState([]),n=k.useRef(0),i=k.useCallback((a,c,d)=>{const h=Date.now(),m={id:`${a}:${h}:${n.current++}`,cid:a,name:c,preview:"",at:h};t(p=>dz(p,m,Gk))},[]),s=k.useCallback(a=>t(c=>hz(c,a)),[]),l=k.useCallback(a=>t(c=>c.filter(d=>d.cid!==a)),[]);return{toasts:e,push:i,dismiss:s,clear:l}}function mz(e){const{item:t,onOpen:n,onDismiss:i}=e,[s,l]=k.useState(!1),[a,c]=k.useState(!1),d=s||a;return k.useEffect(()=>{if(d)return;const h=setTimeout(()=>i(t.id),fz);return()=>clearTimeout(h)},[t.id,d,i]),v.jsxs("div",{className:"banner msg",role:"status",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocus:()=>c(!0),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||c(!1)},children:[v.jsxs("button",{className:"msg-open",title:`Open the conversation with ${t.name}`,onClick:()=>n(t.cid),children:[v.jsx("span",{className:"avatar sm accent","aria-hidden":"true",children:rd(t.name)}),v.jsxs("span",{className:"msg-text",children:[v.jsx("strong",{className:"msg-name",children:t.name}),v.jsx("span",{className:"msg-preview",children:t.preview||"New message"})]})]}),v.jsx("button",{className:"icon-btn msg-close",title:"Dismiss","aria-label":`Dismiss the notification from ${t.name}`,onClick:()=>i(t.id),children:v.jsx(Ee,{name:"close",size:15})})]})}function gz(e){return v.jsx(v.Fragment,{children:e.items.map(t=>v.jsx(mz,{item:t,onOpen:e.onOpen,onDismiss:e.onDismiss},t.id))})}function yz(e){const t=k.useRef(null),{text:n,size:i=240}=e;return k.useEffect(()=>{if(!t.current||!n)return;const s=t.current;Ch(()=>import("./browser-CqRIlH-x.js").then(l=>l.b),[]).then(l=>{l.toCanvas(s,n,{width:i,margin:2,errorCorrectionLevel:"M",color:{dark:"#000000",light:"#ffffff"}})})},[n,i]),v.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"8px 0"},children:v.jsx("canvas",{ref:t,"data-testid":"qr-canvas","data-invite":n,width:i,height:i,style:{borderRadius:8,border:"1px solid var(--line)",imageRendering:"pixelated"}})})}function vz(e){const t=k.useRef(null),n=k.useRef(null),i=k.useRef(null),s=k.useRef(0),l=k.useRef(!0),[a,c]=k.useState("requesting"),[d,h]=k.useState(""),m=k.useCallback(()=>{s.current&&cancelAnimationFrame(s.current),i.current&&(i.current.getTracks().forEach(w=>w.stop()),i.current=null),t.current&&(t.current.srcObject=null)},[]),p=k.useCallback(w=>{i.current=w;const S=t.current;S.srcObject=w,S.setAttribute("playsinline","true"),S.play();const C=n.current,E=C.getContext("2d"),T=()=>{if(l.current)if(S.readyState>=S.HAVE_ENOUGH_DATA){const M=S.videoWidth||320,P=S.videoHeight||240;C.width=M,C.height=P,E.drawImage(S,0,0,M,P);const D=E.getImageData(0,0,M,P);Ch(()=>import("./jsQR-Bf0UGUa9.js").then($=>$.j),[]).then($=>{const j=$.default,Y=j(D.data,D.width,D.height,{inversionAttempts:"dontInvert"});if(Y&&Y.data&&l.current){m(),e.onDecode(Y.data);return}l.current&&(s.current=requestAnimationFrame(T))})}else s.current=requestAnimationFrame(T)};s.current=requestAnimationFrame(T)},[m,e]);k.useEffect(()=>{if(l.current=!0,!navigator.mediaDevices?.getUserMedia){c("nocamera");return}return navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then(w=>{if(!l.current){w.getTracks().forEach(S=>S.stop());return}c("scanning"),p(w)}).catch(w=>{if(!l.current)return;const S=w.name??"";S==="NotAllowedError"||S==="PermissionDeniedError"?c("denied"):S==="NotFoundError"||S==="DevicesNotFoundError"?c("nocamera"):(c("error"),h(w.message??String(w)))}),()=>{l.current=!1,m()}},[]);const y=()=>{m(),e.onClose()};return v.jsxs("div",{"data-testid":"qr-scanner",style:{display:"flex",flexDirection:"column",gap:12,padding:"12px 0"},children:[(a==="requesting"||a==="scanning")&&v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:a==="requesting"?"Requesting camera…":"Point your camera at the QR code."}),v.jsxs("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",background:"#000",minHeight:200},children:[v.jsx("canvas",{ref:n,"data-testid":"scanner-canvas",style:{display:"none"}}),v.jsx("video",{ref:t,"data-testid":"scanner-video",muted:!0,playsInline:!0,style:{width:"100%",display:"block",borderRadius:8}}),a==="scanning"&&v.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",display:"flex",alignItems:"center",justifyContent:"center"},children:v.jsx("div",{style:{width:160,height:160,borderRadius:12,border:"2px solid var(--accent)",boxShadow:"0 0 0 9999px rgba(0,0,0,0.4)"}})})]})]}),a==="denied"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[v.jsx(Ee,{name:"shield",size:16}),v.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"Camera access denied"})]}),v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"Camera permission was denied. To scan QR codes, allow camera access in your browser settings, then try again. Or paste the invite text below instead."})]}),a==="nocamera"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[v.jsx(Ee,{name:"close",size:16}),v.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"No camera available"})]}),v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"No camera was found on this device. Paste the invite text below instead."})]}),a==="error"&&v.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:v.jsxs("p",{style:{margin:0,fontSize:"0.85rem",color:"var(--danger, #e53)"},children:["Camera error: ",d||"unknown error",". Paste the invite text below instead."]})}),v.jsx("button",{className:"btn",style:{justifyContent:"center"},onClick:y,children:a==="scanning"?v.jsxs(v.Fragment,{children:[v.jsx(Ee,{name:"close",size:14}),"Cancel scan"]}):v.jsxs(v.Fragment,{children:[v.jsx(Ee,{name:"close",size:14}),"Close scanner"]})})]})}function xz(e){const[t,n]=k.useState("generate"),[i,s]=k.useState("one_time"),[l,a]=k.useState(""),[c,d]=k.useState(null),[h,m]=k.useState("one_time"),[p,y]=k.useState(""),[w,S]=k.useState(""),[C,E]=k.useState(!1),[T,M]=k.useState(null),[P,D]=k.useState(null),[$,j]=k.useState(!1),[Y,U]=k.useState(null),O=k.useRef(!1),N=async()=>{if(!O.current){O.current=!0,E(!0),D(null),M(null);try{m(i),d(await e.onCreate(i,i==="one_time"&&l.trim()||void 0))}catch(V){D(V instanceof Error?V.message:String(V))}finally{O.current=!1,E(!1)}}},X=v.jsx(Uk,{className:"modal-tabs",label:"Invite mode",options:[{id:"generate",label:"Generate invite"},{id:"accept",label:"Accept invite"}],value:t,onChange:n,idPrefix:"invite-tab",panelId:"invite-panel"});return v.jsx(Ds,{title:t==="generate"?"Invite a contact":"Accept an invite",onClose:()=>{O.current||e.onClose()},tabs:X,children:v.jsxs("div",{id:"invite-panel",role:"tabpanel","aria-labelledby":`invite-tab-${t}`,children:[t==="generate"&&!c&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:13},children:[v.jsxs("p",{className:"muted","data-testid":"invite-identity",style:{margin:0,fontSize:"0.85rem"},children:["Creating as ",v.jsx("strong",{children:e.identity.name})," · ",v.jsxs("span",{className:"mono",children:["@",w0(e.identity.cid)]})]}),v.jsxs("div",{role:"radiogroup","aria-label":"Invite kind",style:{display:"flex",flexDirection:"column",gap:7},children:[v.jsxs("label",{children:[v.jsx("input",{type:"radio",name:"invite-kind",checked:i==="one_time",onChange:()=>s("one_time")})," One person (one time)"]}),v.jsxs("label",{children:[v.jsx("input",{type:"radio",name:"invite-kind",checked:i==="public",onChange:()=>s("public")})," Reusable public invite"]})]}),i==="one_time"?v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.9rem"},children:"Optionally name the person or agent this invite is for."}),v.jsx("input",{className:"field",value:l,onChange:V=>a(V.target.value),placeholder:"Their name (optional), e.g. Bob",maxLength:64})]}):v.jsx("p",{className:"onb-warning","data-testid":"public-invite-warning",style:{margin:0,fontSize:"0.9rem"},children:"Anyone with this invite can connect until you revoke it. It has no expiry and stays valid across server restarts."}),v.jsx("button",{className:"btn primary",style:{justifyContent:"center"},disabled:C,onClick:()=>void N(),children:C?"Generating…":i==="public"?"Create public invite":"Generate invite"}),i==="public"&&v.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[v.jsx("h4",{style:{margin:0,fontSize:"0.9rem"},children:"Active reusable invites"}),e.invites.filter(V=>V.mode==="public").length===0&&v.jsx("p",{className:"muted",style:{margin:0},children:"None right now."}),e.invites.filter(V=>V.mode==="public").map(V=>v.jsxs("div",{"data-testid":"public-invite-row",style:{padding:"8px 10px",background:"var(--inset)",borderRadius:7},children:[v.jsx("span",{className:"mono",children:V.invite_id}),v.jsxs("p",{className:"muted",children:["Created ",V.created?R2(V.created):"unknown"," · Active until revoked · No expiry"]}),Y===V.invite_id?v.jsxs("span",{children:[v.jsx("button",{className:"btn sm danger",onClick:()=>void e.onRevoke(V.invite_id).then(()=>(U(null),e.onRefresh())).catch(fe=>D(String(fe))),children:"Confirm revoke"})," ",v.jsx("button",{className:"btn sm",onClick:()=>U(null),children:"Keep it"})]}):v.jsx("button",{className:"btn sm",onClick:()=>U(V.invite_id),children:"Revoke"})]},V.invite_id))]}),T&&v.jsx("p",{className:"muted",children:T}),P&&v.jsx("p",{className:"onb-error",children:P})]}),t==="generate"&&c&&v.jsxs(v.Fragment,{children:[v.jsx("p",{className:"muted","data-testid":h==="public"?"public-result-note":void 0,children:h==="public"?"Shown only on this screen. Copy it now; the text cannot be recovered later. The invite stays active until revoked.":`Send this invite to ${l.trim()||"your contact"}. It can be redeemed once.`}),v.jsx("textarea",{className:"field mono","data-testid":"invite-result-text",readOnly:!0,rows:5,value:c,onFocus:V=>V.currentTarget.select()}),h==="one_time"&&v.jsx(yz,{text:c}),v.jsxs("button",{className:"btn primary",onClick:()=>void navigator.clipboard.writeText(c).then(()=>M("Copied to clipboard.")),children:[v.jsx(Ee,{name:"copy",size:15}),"Copy invite"]}),h==="public"&&v.jsx("button",{className:"btn","data-testid":"done-hide-invite",onClick:()=>{d(null),a(""),e.onRefresh()},children:"Done — hide invite"}),T&&v.jsx("p",{className:"muted",children:T})]}),t==="accept"&&v.jsxs("form",{style:{display:"flex",flexDirection:"column",gap:13},onSubmit:V=>{V.preventDefault(),!(!p.trim()||C)&&(E(!0),D(null),e.onAccept(p.trim(),w.trim()||void 0).then(()=>{M("Invite accepted — the contact will appear once the sender verifies your identity."),y(""),S("")}).catch(fe=>D(String(fe))).finally(()=>E(!1)))},children:[v.jsx("p",{className:"muted",children:"Paste the invite you received, or scan a QR code."}),$?v.jsx(vz,{onDecode:V=>{y(V),j(!1)},onClose:()=>j(!1)}):v.jsxs("button",{type:"button",className:"btn",onClick:()=>j(!0),children:[v.jsx(Ee,{name:"monitor",size:15}),"Scan QR code"]}),v.jsx("textarea",{className:"field mono","aria-label":"Invite",rows:5,value:p,onChange:V=>y(V.target.value),placeholder:"Paste invite text…"}),v.jsx("input",{className:"field",value:w,onChange:V=>S(V.target.value),placeholder:"Rename them (optional)",maxLength:64}),v.jsx("button",{className:"btn primary",type:"submit",disabled:C||!p.trim(),children:C?"Connecting…":"Add contact"}),T&&v.jsx("p",{className:"muted",children:T}),P&&v.jsx("p",{className:"onb-error",children:P})]})]})})}function wz(e){const[t,n]=k.useState(e.identity.bio??""),[i,s]=k.useState(!1),[l,a]=k.useState(null),[c,d]=k.useState(e.push.preview),h=xM(),m=!e.workerSupported||e.push.status==="unsupported"?h??"Unavailable — requires a secure browser with service-worker support.":e.push.status==="needs-permission"?h??"Needs permission — allow notifications, then choose Enable or Repair.":e.push.status==="on"?"On — this browser and the server agree on the current Web Push configuration.":e.push.status==="repairing"?"Repairing — checking the browser subscription and server acknowledgement…":e.push.status==="error"?"Repair needed — the browser and server could not confirm the same subscription.":"Off — enable notifications for this browser.";return v.jsxs(Ds,{title:"Settings",onClose:e.onClose,wide:!0,children:[v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Display name"}),v.jsx("input",{className:"field",readOnly:!0,value:e.identity.name})]}),v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Your address"}),v.jsx("input",{className:"field mono",readOnly:!0,value:e.identity.cid,onFocus:p=>p.currentTarget.select()}),v.jsx("p",{className:"muted",children:"Your public address on ours. Share an invite to connect more easily."})]}),v.jsxs("div",{children:[v.jsx("span",{className:"lbl",children:"Public bio"}),v.jsx("textarea",{className:"field",rows:3,value:t,onChange:p=>{n(p.target.value),s(!1),a(null)}}),v.jsx("button",{className:"btn sm",onClick:()=>{a(null),e.onSaveBio(t).then(()=>s(!0)).catch(p=>a(String(p)))},children:i?"Saved":"Save bio"}),l&&v.jsx("p",{className:"onb-error",children:l})]}),v.jsxs("label",{style:{display:"flex",gap:9},children:[v.jsx("input",{type:"checkbox",checked:e.dark,onChange:e.onToggleDark})," Dark mode"]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"Notifications"}),v.jsx("p",{className:e.push.status==="needs-permission"||e.push.status==="error"?"onb-error":"muted",children:m}),h&&h!==m&&v.jsx("p",{className:"muted","data-testid":"push-platform-guidance",children:h}),v.jsxs("fieldset",{style:{border:0,padding:0,margin:"12px 0"},children:[v.jsx("legend",{className:"lbl",children:"Lock-screen preview"}),v.jsxs("label",{style:{display:"block",marginTop:7},children:[v.jsx("input",{type:"radio",name:"push-preview",checked:c==="full",onChange:()=>d("full")})," Full — sender and message text or filename"]}),v.jsxs("label",{style:{display:"block",marginTop:7},children:[v.jsx("input",{type:"radio",name:"push-preview",checked:c==="private",onChange:()=>d("private")})," Private — generic content only"]})]}),v.jsx("p",{className:"muted",children:"Full previews can expose sender names, message text, and filenames on the lock screen. The push provider still sees delivery endpoint, timing, and payload size metadata in either mode."}),v.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.push.status==="on"?v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("disable",c),children:"Disable notifications"}),v.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("repair",c),children:"Repair"}),c!==e.push.preview&&v.jsx("button",{className:"btn primary",disabled:e.busy,onClick:()=>void e.onPushAction("enable",c),children:"Save preview"})]}):v.jsx("button",{className:"btn primary",disabled:e.busy||!e.workerSupported||e.push.status==="unsupported",onClick:()=>void e.onPushAction(e.push.status==="error"||e.push.blocked?"repair":"enable",c),children:e.busy?"Repairing…":e.push.status==="error"||e.push.blocked?"Repair":"Enable notifications"})})]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"App status"}),v.jsx("p",{className:"muted",children:e.offline?"Offline — reconnecting. Message and identity data are never cached.":"Online."}),e.onInstall&&v.jsx("button",{className:"btn",onClick:e.onInstall,children:"Install app"}),e.updateAvailable&&v.jsx("button",{className:"btn primary",onClick:e.onReloadUpdate,children:"Reload to update"})]}),v.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[v.jsx("h4",{children:"Build"}),v.jsx("input",{className:"field mono",readOnly:!0,value:e.build?`${e.build.version} · ${e.build.sha}`:"Loading…"})]})]})}function kz(e,t,n,i,s=6e4){return!t||!t.sha?"current":t.sha===e?(n.remoteSha=null,n.firstMismatchAt=null,"current"):(n.remoteSha=t.sha,(n.firstMismatchAt===null||n.firstMismatchAt===void 0)&&(n.firstMismatchAt=i),n.controllerChanged?"newer-available":i-n.firstMismatchAt>=s?"stuck":"newer-available")}const Sz="31a3834ab34539ece7cc07af9ee4efaaef5c7151",bz=15*6e4,Cz=6e4,Ez=kz;async function Tz(){try{const e=await fetch("/version.json",{cache:"no-store"});return e.ok?await e.json():null}catch{return null}}function Pz(e){const t={remoteSha:null,firstMismatchAt:null,controllerChanged:!1},n=()=>{t.controllerChanged=!0};navigator.serviceWorker?.addEventListener("controllerchange",n);let i=!1;const s=async()=>{const d=await Tz(),h=Ez(Sz,d,t,Date.now(),Cz);h==="newer-available"?(e.onUpdateAvailable(),navigator.serviceWorker?.getRegistration().then(m=>m?.update())):h==="stuck"&&!i&&(i=!0,e.onStuck(d.sha))},l=setTimeout(()=>void s(),5e3),a=setInterval(()=>void s(),bz),c=()=>{document.visibilityState==="visible"&&s()};return document.addEventListener("visibilitychange",c),()=>{clearTimeout(l),clearInterval(a),document.removeEventListener("visibilitychange",c),navigator.serviceWorker?.removeEventListener("controllerchange",n)}}async function Rz(e){try{const t=await navigator.serviceWorker.getRegistrations();await Promise.all(t.map(i=>i.unregister()));const n=await caches.keys();await Promise.all(n.map(i=>caches.delete(i)))}catch{}return location.replace(location.pathname+"?v="+encodeURIComponent(e)),new Promise(()=>{})}function Mz(){const e=new URL(location.href);e.searchParams.has("v")&&(e.searchParams.delete("v"),history.replaceState(null,"",e.pathname+e.search+e.hash))}const Sx=[0,100,400,1e3,3e3,6e3],bx=e=>new Promise(t=>setTimeout(t,e)),Cx={delivered:1,read:2},Ex="ours-dark-v3",Tx="#chat-message-",Px=Rl,Az=e=>e instanceof Error&&e.message?e.message:"The request could not be completed.";function Qk(e,t){const n=new Map,i=[];for(const s of e?.messages??[]){const l={dir:s.dir,text:s.text,date:s.date,read:s.read,wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:null,receipt:s.receipt??void 0,receiptless:s.dir==="out"&&!s.wire_id};s.wire_id?n.set(s.wire_id,l):i.push(l)}for(const s of t){const l=n.get(s.wire_id);n.set(s.wire_id,{dir:s.dir,text:"",date:s.date,read:l?.read??s.dir==="out",wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:l?.replyTo??null,kind:"file",filename:s.filename,mime:s.mime,receipt:l?.receipt})}return[...i,...n.values()].sort((s,l)=>{const a=Px(s.date)-Px(l.date);return a===0?s.wireId.localeCompare(l.wireId):a})}function Nz(e){const t={};for(const n of Object.values(e.roots??{}))t[n.root_cid]={label:n.root_name,note:"Verified identity"};return t}function Iz(e,t){return[...e.contacts.contacts.map(i=>{const s=e.contacts.roots?.[i.container_id],l=or(e,i.container_id),c=Qk(l,t[i.container_id]??[]).at(-1),d=Al(i);return{id:i.container_id,name:d,announcedName:i.name,initials:rd(d),when:c?P2(c.date):"",activityAt:c?.date??"",last:c?.kind==="file"?L2(c.filename,c.mime):l?.preview??c?.text??"",unread:l?.unread??0,status:"active",root:s?.root_cid??null,sub:s?`role “${s.role_id}” of ${s.root_name}`:"",roleId:s?.role_id??null,rootName:s?.root_name??null,mine:!1,kind:s?"agent":"person"}}),...e.contacts.pending.map(i=>{const s=Al(i);return{id:`pending:${i.container_id}`,name:s,announcedName:i.name,initials:rd(s),when:"",activityAt:"",last:`${i.queued} queued · approval required`,unread:0,status:"pending",root:null,sub:"",roleId:null,rootName:null,mine:!1,kind:"person"}})]}function jz(){return v.jsx(Dz,{})}function Dz(){const e=k.useRef(hM(Gy(window.location.pathname))).current,[t,n]=k.useReducer(Jy,e),[i,s]=k.useState(null),l=k.useRef(0),a=k.useRef(null),c=k.useRef(t),d=k.useRef(new uM),h=k.useRef(null),m=k.useRef(new Map),p=k.useRef(new Map),[y,w]=k.useState({}),S=k.useRef(y),[C,E]=k.useState(null),T=k.useRef(new Set),[M,P]=k.useState(null),D=k.useRef(M),$=k.useRef(!1),[j,Y]=k.useState([]),[U,O]=k.useState(null),[N,X]=k.useState(()=>localStorage.getItem(Ex)!=="0"),[V,fe]=k.useState(null),[J,ee]=k.useState({supported:!1,offline:!navigator.onLine,updateAvailable:!1,registration:null}),[xe,Pe]=k.useState({status:"unsupported",preview:"full"}),[Q,de]=k.useState(!1),R=k.useRef(!1),[F,G]=k.useState(()=>window.location.hash.startsWith(Tx)),{toasts:A,push:te,dismiss:ge,clear:ye}=pz(),me=k.useCallback(W=>{c.current=Jy(c.current,W),n(W)},[]),we=k.useCallback(W=>{$.current=W},[]);k.useEffect(()=>{c.current=t},[t]),D.current=M,S.current=y,k.useMemo(()=>(cv(Object.values(y).flat()),null),[y]),k.useEffect(()=>(document.documentElement.classList.toggle("theme-dark",N),()=>document.documentElement.classList.remove("theme-dark")),[N]);const pe=k.useCallback(W=>me({type:"error",message:Az(W)}),[me]),Ve=k.useCallback(()=>{const W=c.current;return{visibility:document.visibilityState,appRoute:W.route.name==="chats"?"chats":"other",selectedContactCid:ri(W),desktopLayout:h.current?.matches??window.innerWidth>=861,mobileDetailOpen:W.mobileDetailOpen,conversationCoveringDialogOpen:D.current!==null}},[]),qe=k.useCallback(async(W,le=!0)=>{try{const ne=await Ke.conversation(W);return me({type:"page",contactCid:W,page:ne}),ne}catch(ne){return le&&pe(ne),null}},[me,pe]),it=k.useCallback(async(W,le=!0)=>{try{const ne=await Ke.files(W);return cv(ne.files),w(Me=>({...Me,[W]:ne.files})),ne.files}catch(ne){return le&&pe(ne),null}},[pe]);k.useEffect(()=>Pz({onUpdateAvailable:()=>ee(W=>({...W,updateAvailable:!0})),onStuck:W=>{Rz(W)}}),[]);const We=k.useCallback(async()=>{const W=await Ke.contacts();return me({type:"contacts",contacts:{...W,pending:W.pending??[]}}),W},[me]),at=k.useCallback(async()=>{try{const[W,le,ne]=await Promise.all([Ke.identity(),Ke.contacts(),Ke.buildInfo()]),Me={...le,pending:le.pending??[]};return c.current.identity&&c.current.identity.cid!==W.cid&&(j2(),S.current={},w({})),me({type:"snapshot",identity:W,contacts:Me}),O(ne),await Promise.all(Me.contacts.flatMap(ke=>[qe(ke.container_id,!1),it(ke.container_id,!1)])),ri(c.current)}catch(W){return pe(W),null}},[me,it,qe,pe]),xt=k.useCallback(async W=>{await d.current.request(W,async()=>{lM(W,Ve())&&(await Ke.markRead(W),await Promise.all([qe(W),We()]))}).catch(pe)},[Ve,We,qe,pe]),Vt=k.useCallback(async W=>{const le=++l.current;a.current?.abort();const ne=new AbortController;a.current=ne,s(null),ye(W),it(W,!1);let Me;try{Me=await Ke.conversation(W,void 0,ne.signal)}catch(Ye){ne.signal.aborted||pe(Ye);return}if(ne.signal.aborted||le!==l.current)return;me({type:"page",contactCid:W,page:Me});const ke=Me.unread;let ce=[...Me.messages],Ae=Me.nextBefore;const ft=new Set,nn=new Set(ce.map(Ye=>Ye.wire_id).filter(Boolean)),ot=()=>ce.filter(Ye=>Ye.dir==="in"&&!Ye.read);for(;ot().length<ke&&Ae&&!ft.has(Ae);){ft.add(Ae);let Ye;try{Ye=await Ke.conversation(W,Ae,ne.signal)}catch{break}if(ne.signal.aborted||le!==l.current)return;const cr=Ye.messages.filter(fr=>!fr.wire_id||!nn.has(fr.wire_id));if(!cr.length&&Ye.nextBefore===Ae)break;for(const fr of cr)fr.wire_id&&nn.add(fr.wire_id);ce=[...cr,...ce],me({type:"older_page",contactCid:W,page:Ye,newer:Me.messages}),Ae=Ye.nextBefore}const Ge=ot()[0];Ge?.wire_id&&le===l.current&&!ne.signal.aborted&&s({contactCid:W,wireId:Ge.wire_id,count:ke}),await xt(W)},[ye,me,xt,it,pe]),lt=k.useCallback(async(W,le,ne="page")=>{const Me=`page:${W}:${ne}`,ke=(m.current.get(Me)??0)+1;m.current.set(Me,ke);for(const ce of Sx){if(ce&&await bx(ce),m.current.get(Me)!==ke)return;const Ae=await qe(W,!1);if(Ae&&le(Ae))return}},[qe]),Pt=k.useCallback(async(W,le)=>{const ne=`file:${W}`,Me=(m.current.get(ne)??0)+1;m.current.set(ne,Me);for(const ke of Sx)if(ke&&await bx(ke),m.current.get(ne)!==Me||(await it(W,!1))?.some(Ae=>Ae.wire_id===le))return},[it]),fn=k.useRef(!1);k.useEffect(()=>{if(!F||!t.loaded)return;const W=decodeURIComponent(window.location.hash.slice(Tx.length)),le=ri(c.current);if(!W||!le){G(!1);return}if(or(c.current,le)?.messages.some(ne=>ne.wire_id===W)){G(!1);return}fn.current||(fn.current=!0,lt(le,ne=>ne.messages.some(Me=>Me.wire_id===W),`anchor:${W}`).catch(()=>{}).finally(()=>G(!1)))},[F,lt,t.loaded,t.pages]),k.useMemo(()=>(I2({url:W=>Object.values(S.current).flat().find(ne=>ne.wire_id===W)?.available?Ke.mediaUrl(W):null,bytes:async W=>{if(!Object.values(S.current).flat().find(Me=>Me.wire_id===W)?.available)return null;const ne=await fetch(Ke.mediaUrl(W),{cache:"no-store",credentials:"same-origin"});if(!ne.ok)throw new Error(`Media request failed (HTTP ${ne.status})`);return new Uint8Array(await ne.arrayBuffer())},fetch:async W=>{const le=Object.values(S.current).flat().find(ne=>ne.wire_id===W);if(!le)throw new Error("Media record is unavailable");await Ke.fetchFiles([W]),await it(le.contact_id)}}),null),[it]),k.useEffect(()=>{let W;gM(ne=>{ee(ne),nv(ne.registration).then(Pe).catch(()=>Pe(Me=>({...Me,status:"error"})))},{shouldDeferReload:()=>$.current||D.current!==null}).then(ne=>{W=ne}).catch(pe);const le=ne=>{ne.preventDefault(),fe(ne)};return window.addEventListener("beforeinstallprompt",le),()=>{W?.(),window.removeEventListener("beforeinstallprompt",le)}},[pe]),k.useEffect(()=>CM(),[]),k.useEffect(()=>{if(!(!J.registration||xe.status!=="on"))return aM({registration:J.registration,identity:Ke.identity,onEvent:d0})},[xe.status,xe.bindingId,J.registration]),k.useEffect(()=>{const W=()=>Pe(le=>({...le,status:"error"}));return window.addEventListener("ours-push-repair-required",W),()=>window.removeEventListener("ours-push-repair-required",W)},[]),k.useEffect(()=>{window.location.pathname==="/"&&window.history.replaceState(null,"",ni()),h.current=window.matchMedia("(min-width: 861px)");const W=()=>{const ce=Gy(window.location.pathname);a.current?.abort(),l.current+=1,s(null),me({type:"route",route:ce}),R.current&&ce.name==="chats"&&ce.contactCid&&(R.current=!1,requestAnimationFrame(()=>document.querySelector("[data-contact-trigger]")?.focus({preventScroll:!0}))),ce.name==="chats"&&ce.contactCid&&Vt(ce.contactCid)},le=()=>{if(document.visibilityState!=="visible")return;const ce=ri(c.current);ce&&xt(ce),g0(),J.registration&&nv(J.registration).then(Pe).catch(()=>Pe(Ae=>({...Ae,status:"error"})))};window.addEventListener("popstate",W),document.addEventListener("visibilitychange",le);const ne=ce=>{const Ae=ce.type==="sync_required"?`${ce.type}:${ce.reason}`:ce.type==="receipt_received"?`${ce.type}:${ce.contact_id}:${ce.kind}:${ce.wire_ids.join(",")}`:`${ce.type}:${ce.contact_id}:${ce.wire_id}`,ft=Date.now(),nn=p.current.get(Ae)??0;p.current.set(Ae,ft);for(const[ot,Ge]of p.current)ft-Ge>6e4&&p.current.delete(ot);ft-nn<6e4||(async()=>{if(ce.type==="sync_required"){await at();return}if(We().catch(pe),ce.type==="file_received"){await Pt(ce.contact_id,ce.wire_id);const ot=c.current.contacts.contacts.find(Ge=>Ge.container_id===ce.contact_id);ri(c.current)!==ce.contact_id&&ot&&te(ce.contact_id,Al(ot),"New file");return}if(ce.type==="message_received"){const ot=c.current.contacts.contacts.find(Ge=>Ge.container_id===ce.contact_id);await lt(ce.contact_id,Ge=>Ge.messages.some(Ye=>Ye.wire_id===ce.wire_id),`message:${ce.wire_id}`),ri(c.current)===ce.contact_id?await xt(ce.contact_id):ot&&te(ce.contact_id,Al(ot),"New message");return}me({type:"receipt",contactCid:ce.contact_id,kind:ce.kind,wireIds:ce.wire_ids}),await lt(ce.contact_id,ot=>ce.wire_ids.every(Ge=>{const Ye=ot.messages.find(cr=>cr.wire_id===Ge);return!!Ye?.receipt&&Cx[Ye.receipt]>=Cx[ce.kind]}),`receipt:${ce.wire_ids.join(",")}`)})().catch(pe)},Me=rM(ne),ke=iM(ne,ce=>me({type:"connection",connection:ce}));return at().then(ce=>{ce&&Vt(ce)}),()=>{ke(),Me(),window.removeEventListener("popstate",W),document.removeEventListener("visibilitychange",le)}},[lt,Pt,me,xt,Vt,te,We,at,pe,J.registration]);const It=(W,le,ne)=>{window.history.pushState({oursMessenger:!0},"",le),me({type:"route",route:W,mobileDetailOpen:ne})},jt=async W=>{It({name:"chats",contactCid:W},ni(W),!0),await Vt(W)},Ln=async W=>{const le=or(c.current,W);if(!(!le?.nextBefore||T.current.has(W))){T.current.add(W),E(W);try{const ne=await Ke.conversation(W,le.nextBefore);me({type:"older_page",contactCid:W,page:ne,newer:le.messages})}catch(ne){pe(ne)}finally{T.current.delete(W),E(null)}}},ze=ri(t),ur=t.contacts.contacts.find(W=>W.container_id===ze),bn=k.useMemo(()=>Iz(t,y),[t,y]),q=bn.find(W=>W.id===ze)??null,se=ze?Qk(or(t,ze),y[ze]??[]):[],_=t.identity,Z=t.loaded?ze&&!or(t,ze)||F?"updating":t.connection!=="live"?"connecting":null:"connecting",he=async(W,le=xe.preview)=>{if(J.registration){de(!0),Pe(ne=>({...ne,status:"repairing",preview:le}));try{Pe(await(W==="enable"?m0(J.registration,{preview:le}):W==="repair"?SM(J.registration,le):bM(J.registration,xe)))}catch(ne){Pe(Me=>({...Me,status:"error"})),pe(ne)}finally{de(!1)}}},De=()=>{Y([]),P("invite"),Ke.invites().then(Y).catch(pe)};return t.route.name==="not_found"?v.jsxs("div",{className:"centered-screen",children:[v.jsx("h1",{children:"Page not found"}),v.jsx("button",{className:"btn primary",onClick:()=>It({name:"chats",contactCid:null},ni()),children:"Open chats"})]}):_?v.jsx("div",{className:N?"theme-dark":"",style:{height:"100%"},children:v.jsxs("div",{className:"app signal-app",children:[v.jsxs("main",{className:"section signal-stage"+(t.mobileDetailOpen?" show-detail":""),children:[v.jsx(sz,{contacts:bn,roots:Nz(t.contacts),selected:ze,onSelect:W=>{W.startsWith("pending:")||jt(W)},onInvite:De,onSettings:()=>P("settings"),onApprovePending:async W=>{try{return await Ke.respondToIntroduction(W,"approve"),await at(),!0}catch(le){return pe(le),!1}},onRejectPending:async W=>{try{return await Ke.respondToIntroduction(W,"reject"),await at(),!0}catch(le){return pe(le),!1}}}),t.route.name==="contact"&&q?v.jsx(az,{contact:q,messages:se,onBack:()=>{R.current=!0,fM(window.history.state)==="back"?window.history.back():(window.history.replaceState({oursMessenger:!0},"",ni(q.id)),me({type:"route",route:{name:"chats",contactCid:q.id},mobileDetailOpen:!0}),requestAnimationFrame(()=>document.querySelector("[data-contact-trigger]")?.focus({preventScroll:!0})),R.current=!1)},onRename:W=>void Ke.renameContact(q.id,W).then(at).catch(pe),onRemove:()=>{confirm(`Remove “${ur?.name??"contact"}”?`)&&Ke.removeContact(q.id).then(()=>(window.history.replaceState({oursMessenger:!0},"",ni()),me({type:"route",route:{name:"chats",contactCid:null},mobileDetailOpen:!1}),at())).catch(pe)},onOpenMessage:W=>{It({name:"chats",contactCid:q.id},ni(q.id),!0);let le=12;const ne=()=>{const Me=document.getElementById(`chat-message-${encodeURIComponent(W)}`),ke=Me?.closest(".messages");if((!Me||!ke||ke.clientHeight<=0)&&le-- >0){requestAnimationFrame(ne);return}if(!Me||!ke)return;const ce=Me.getBoundingClientRect(),Ae=ke.getBoundingClientRect(),ft=ke.scrollTop+ce.top-Ae.top-Math.max(0,(ke.clientHeight-ce.height)/2),nn=Math.max(0,Math.min(ft,ke.scrollHeight-ke.clientHeight));ke.scrollTo({top:nn,behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"})};requestAnimationFrame(ne)},indexOffset:or(t,q.id)?.hasMore?Math.max(1,(or(t,q.id)?.total??se.length)-se.length):0,onSendText:async(W,le)=>{const ne=await Ke.send(q.id,W,le);return await qe(q.id,!1),ne.wire_id??void 0},onSendFile:async(W,le)=>{await Ke.sendFile(q.id,new Blob([W.bytes],{type:W.mime}),W.filename,W.mime,le),await Promise.all([it(q.id),qe(q.id,!1)])}}):v.jsx(lz,{contact:q,messages:se,syncing:Z,unreadOpen:i?.contactCid===ze?i:null,hiddenEarlier:or(t,ze??"")?.hasMore?Math.max(1,(or(t,ze??"")?.total??se.length)-se.length):0,onLoadEarlier:ze&&C!==ze?()=>void Ln(ze):void 0,onBack:()=>{a.current?.abort(),l.current+=1,s(null),It({name:"chats",contactCid:null},ni(),!1)},onOpenContact:()=>{ze&&It({name:"contact",contactCid:ze},cM(ze),!0)},onDraftChange:we,onSend:async(W,le,ne)=>{if(!ze)return;const Me=ze,ke=await Ke.send(Me,W,le,ne);return me({type:"sent_message",contactCid:Me,message:{dir:"out",text:W,date:new Date().toISOString(),read:!0,wire_id:ke.wire_id??"",receipt:null,reply_to:le?{wire_id:le}:null}}),ke.wire_id?lt(Me,ce=>ce.messages.some(Ae=>Ae.wire_id===ke.wire_id),`send:${ke.wire_id}`):We().catch(pe),ke.wire_id??void 0},onSendFile:async(W,le)=>{ze&&(await Ke.sendFile(ze,new Blob([W.bytes],{type:W.mime}),W.filename,W.mime,le),await Promise.all([it(ze),qe(ze,!1)]))},onFetchFile:async W=>{await Ke.fetchFiles([W]),ze&&await it(ze)}},ze??"no-conversation")]}),v.jsxs("div",{className:"app-banners",children:[J.offline&&v.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:"Offline — reconnecting to the network…"}),t.connection!=="live"&&v.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:t.connection==="retrying"?"Live updates interrupted — reconnecting…":"Connecting to live updates…"}),J.updateAvailable&&v.jsxs("div",{className:"banner info",children:[v.jsx("span",{role:"status","aria-live":"polite",children:"A new version is available."}),v.jsx("span",{className:"banner-actions",children:v.jsx("button",{className:"linkbtn",onClick:()=>{J.registration&&ev(J.registration)},children:"Restart now"})})]}),v.jsx(gz,{items:A,onDismiss:ge,onOpen:W=>void jt(W)})]}),M==="invite"&&v.jsx(xz,{identity:_,invites:j,onRefresh:async()=>Y(await Ke.invites()),onCreate:async(W,le)=>(await Ke.createInvite(W,le)).blob,onAccept:async(W,le)=>{await Ke.addContact(W,le),await at()},onRevoke:async W=>{await Ke.revokeInvite(W)},onClose:()=>{P(null),at()}}),M==="settings"&&v.jsx(wz,{identity:_,push:xe,workerSupported:J.supported,busy:Q,offline:J.offline,updateAvailable:J.updateAvailable,build:U,dark:N,onToggleDark:()=>X(W=>(localStorage.setItem(Ex,W?"0":"1"),!W)),onSaveBio:async W=>{await Ke.setBio(W),await at()},onPushAction:he,onInstall:V?()=>void V.prompt().then(()=>fe(null)):void 0,onReloadUpdate:()=>{J.registration&&ev(J.registration)},onClose:()=>{D.current=null,P(null),ze&&xt(ze)}}),t.error&&v.jsxs("div",{className:"banner error",role:"alert","aria-live":"assertive",children:[t.error,v.jsx("button",{className:"linkbtn",onClick:()=>me({type:"error",message:null}),children:"dismiss"})]})]})}):v.jsx("div",{className:N?"theme-dark":"",style:{height:"100%"},children:v.jsx("div",{className:"centered-screen",children:v.jsx("p",{className:"muted",children:"Loading…"})})})}Mz();const Zk=document.getElementById("root");if(!Zk)throw new Error("missing #root");tC.createRoot(Zk).render(v.jsx(ZP,{reducedMotion:"user",children:v.jsx(jz,{})}));export{Ch as _,Id as g};
|
|
321
|
+
//# sourceMappingURL=index-2K1tlrb7.js.map
|