@ours.network/messenger-server 1.0.23 → 1.0.24
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-G4IVQ6I4.js → chunk-HQH6GSXE.js} +1 -1
- package/dist/chunks/{server-TX7WLV64.js → server-RQJSKTA2.js} +14 -3
- package/dist/cli.js +2 -2
- package/dist/web/assets/{abnfDiagram-N423BO3Z-DluufZNF.js → abnfDiagram-N423BO3Z-BhkydZGp.js} +2 -2
- package/dist/web/assets/{abnfDiagram-N423BO3Z-DluufZNF.js.map → abnfDiagram-N423BO3Z-BhkydZGp.js.map} +1 -1
- package/dist/web/assets/{arc-CQ3ltbkj.js → arc-BU9pStho.js} +2 -2
- package/dist/web/assets/{arc-CQ3ltbkj.js.map → arc-BU9pStho.js.map} +1 -1
- package/dist/web/assets/{architectureDiagram-T3A2C74G-D_OLaJJP.js → architectureDiagram-T3A2C74G-BtOUi_r1.js} +2 -2
- package/dist/web/assets/{architectureDiagram-T3A2C74G-D_OLaJJP.js.map → architectureDiagram-T3A2C74G-BtOUi_r1.js.map} +1 -1
- package/dist/web/assets/{blockDiagram-VBNYF7ZC-zWQJpXUI.js → blockDiagram-VBNYF7ZC-DdLiUFD5.js} +2 -2
- package/dist/web/assets/{blockDiagram-VBNYF7ZC-zWQJpXUI.js.map → blockDiagram-VBNYF7ZC-DdLiUFD5.js.map} +1 -1
- package/dist/web/assets/{browser-BtETXeFB.js → browser-DinAcYN1.js} +2 -2
- package/dist/web/assets/{browser-BtETXeFB.js.map → browser-DinAcYN1.js.map} +1 -1
- package/dist/web/assets/{c4Diagram-5PPSVZJV-Ccpd3-UB.js → c4Diagram-5PPSVZJV-MiAVf84A.js} +2 -2
- package/dist/web/assets/{c4Diagram-5PPSVZJV-Ccpd3-UB.js.map → c4Diagram-5PPSVZJV-MiAVf84A.js.map} +1 -1
- package/dist/web/assets/channel-BiTTYqhX.js +2 -0
- package/dist/web/assets/{channel-p16PN_NW.js.map → channel-BiTTYqhX.js.map} +1 -1
- package/dist/web/assets/{chunk-2GRJ4B5K-BCgfd6Td.js → chunk-2GRJ4B5K-DrKjMtyi.js} +2 -2
- package/dist/web/assets/{chunk-2GRJ4B5K-BCgfd6Td.js.map → chunk-2GRJ4B5K-DrKjMtyi.js.map} +1 -1
- package/dist/web/assets/{chunk-2Q5K7J3B-CQ48PhVz.js → chunk-2Q5K7J3B-SOZuaq5V.js} +2 -2
- package/dist/web/assets/{chunk-2Q5K7J3B-CQ48PhVz.js.map → chunk-2Q5K7J3B-SOZuaq5V.js.map} +1 -1
- package/dist/web/assets/{chunk-5RXB4S5H-BTQ5wpp1.js → chunk-5RXB4S5H-C7TlW4kZ.js} +2 -2
- package/dist/web/assets/{chunk-5RXB4S5H-BTQ5wpp1.js.map → chunk-5RXB4S5H-C7TlW4kZ.js.map} +1 -1
- package/dist/web/assets/{chunk-5VM5RSS4-OmXNC4IB.js → chunk-5VM5RSS4-x9tl13uG.js} +2 -2
- package/dist/web/assets/{chunk-5VM5RSS4-OmXNC4IB.js.map → chunk-5VM5RSS4-x9tl13uG.js.map} +1 -1
- package/dist/web/assets/{chunk-6Q2QTUOP-C8ooDwW4.js → chunk-6Q2QTUOP-CnISbcvm.js} +2 -2
- package/dist/web/assets/{chunk-6Q2QTUOP-C8ooDwW4.js.map → chunk-6Q2QTUOP-CnISbcvm.js.map} +1 -1
- package/dist/web/assets/{chunk-GF5L2VYU-BsX1H_fv.js → chunk-GF5L2VYU-B0juAWIy.js} +2 -2
- package/dist/web/assets/{chunk-GF5L2VYU-BsX1H_fv.js.map → chunk-GF5L2VYU-B0juAWIy.js.map} +1 -1
- package/dist/web/assets/{chunk-JWPE2WC7-Df86oX4z.js → chunk-JWPE2WC7-Dp9ureFc.js} +2 -2
- package/dist/web/assets/{chunk-JWPE2WC7-Df86oX4z.js.map → chunk-JWPE2WC7-Dp9ureFc.js.map} +1 -1
- package/dist/web/assets/{chunk-KBJHAD2P-DHWP2W4_.js → chunk-KBJHAD2P-CLEHCOyQ.js} +2 -2
- package/dist/web/assets/{chunk-KBJHAD2P-DHWP2W4_.js.map → chunk-KBJHAD2P-CLEHCOyQ.js.map} +1 -1
- package/dist/web/assets/{chunk-RYQCIY6F-BxxxebdI.js → chunk-RYQCIY6F-BsOScth2.js} +2 -2
- package/dist/web/assets/{chunk-RYQCIY6F-BxxxebdI.js.map → chunk-RYQCIY6F-BsOScth2.js.map} +1 -1
- package/dist/web/assets/{chunk-XXDRQBXY-VkYGSsGl.js → chunk-XXDRQBXY-BNzBffwF.js} +2 -2
- package/dist/web/assets/{chunk-XXDRQBXY-VkYGSsGl.js.map → chunk-XXDRQBXY-BNzBffwF.js.map} +1 -1
- package/dist/web/assets/classDiagram-JCYQIIEL-D4Mygsch.js +2 -0
- package/dist/web/assets/{classDiagram-JCYQIIEL-DniFmDq7.js.map → classDiagram-JCYQIIEL-D4Mygsch.js.map} +1 -1
- package/dist/web/assets/classDiagram-v2-OCEON4UE-D4Mygsch.js +2 -0
- package/dist/web/assets/{classDiagram-v2-OCEON4UE-DniFmDq7.js.map → classDiagram-v2-OCEON4UE-D4Mygsch.js.map} +1 -1
- package/dist/web/assets/{cose-bilkent-JH36ORCC-CwABkF0h.js → cose-bilkent-JH36ORCC-CYK5l5Qu.js} +2 -2
- package/dist/web/assets/{cose-bilkent-JH36ORCC-CwABkF0h.js.map → cose-bilkent-JH36ORCC-CYK5l5Qu.js.map} +1 -1
- package/dist/web/assets/{cynefin-VYW2F7L2-YRT0jK8r.js → cynefin-VYW2F7L2-DGdg-N7t.js} +2 -2
- package/dist/web/assets/{cynefin-VYW2F7L2-YRT0jK8r.js.map → cynefin-VYW2F7L2-DGdg-N7t.js.map} +1 -1
- package/dist/web/assets/{cynefinDiagram-MW4NZA55-HpASrz5x.js → cynefinDiagram-MW4NZA55-Z8Dn7zEv.js} +2 -2
- package/dist/web/assets/{cynefinDiagram-MW4NZA55-HpASrz5x.js.map → cynefinDiagram-MW4NZA55-Z8Dn7zEv.js.map} +1 -1
- package/dist/web/assets/{dagre-VZM6K2ZE-Bxqqu1Sj.js → dagre-VZM6K2ZE-B54Q6GJN.js} +2 -2
- package/dist/web/assets/{dagre-VZM6K2ZE-Bxqqu1Sj.js.map → dagre-VZM6K2ZE-B54Q6GJN.js.map} +1 -1
- package/dist/web/assets/{diagram-7IWD3JNH-CdOULw_j.js → diagram-7IWD3JNH-Cdp54-az.js} +2 -2
- package/dist/web/assets/{diagram-7IWD3JNH-CdOULw_j.js.map → diagram-7IWD3JNH-Cdp54-az.js.map} +1 -1
- package/dist/web/assets/{diagram-B4RE2ZJO-BmAH_WZj.js → diagram-B4RE2ZJO-B2UPZ15D.js} +2 -2
- package/dist/web/assets/{diagram-B4RE2ZJO-BmAH_WZj.js.map → diagram-B4RE2ZJO-B2UPZ15D.js.map} +1 -1
- package/dist/web/assets/{diagram-LBJQPF4R-DhV2Gh-F.js → diagram-LBJQPF4R-DJft3GaQ.js} +2 -2
- package/dist/web/assets/{diagram-LBJQPF4R-DhV2Gh-F.js.map → diagram-LBJQPF4R-DJft3GaQ.js.map} +1 -1
- package/dist/web/assets/{diagram-Q27KOJAE-C84KsWMY.js → diagram-Q27KOJAE-C_4A0WTc.js} +2 -2
- package/dist/web/assets/{diagram-Q27KOJAE-C84KsWMY.js.map → diagram-Q27KOJAE-C_4A0WTc.js.map} +1 -1
- package/dist/web/assets/{diagram-UB23O5K3-DdedAaau.js → diagram-UB23O5K3-Blb0rE9Y.js} +2 -2
- package/dist/web/assets/{diagram-UB23O5K3-DdedAaau.js.map → diagram-UB23O5K3-Blb0rE9Y.js.map} +1 -1
- package/dist/web/assets/{ebnfDiagram-BXEA7PRR-DfNXtSHl.js → ebnfDiagram-BXEA7PRR-CixUbW4I.js} +2 -2
- package/dist/web/assets/{ebnfDiagram-BXEA7PRR-DfNXtSHl.js.map → ebnfDiagram-BXEA7PRR-CixUbW4I.js.map} +1 -1
- package/dist/web/assets/{erDiagram-JOGREHBK-DYuWNOEG.js → erDiagram-JOGREHBK-Ci4ZMSF2.js} +2 -2
- package/dist/web/assets/{erDiagram-JOGREHBK-DYuWNOEG.js.map → erDiagram-JOGREHBK-Ci4ZMSF2.js.map} +1 -1
- package/dist/web/assets/{flowDiagram-UKHOOZJN-0vb0_3vx.js → flowDiagram-UKHOOZJN-DChHQ7Vq.js} +2 -2
- package/dist/web/assets/{flowDiagram-UKHOOZJN-0vb0_3vx.js.map → flowDiagram-UKHOOZJN-DChHQ7Vq.js.map} +1 -1
- package/dist/web/assets/{ganttDiagram-PKOTCBZU-CK8tyfEC.js → ganttDiagram-PKOTCBZU-BUnDgkKT.js} +2 -2
- package/dist/web/assets/{ganttDiagram-PKOTCBZU-CK8tyfEC.js.map → ganttDiagram-PKOTCBZU-BUnDgkKT.js.map} +1 -1
- package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-DF6tegGR.js → gitGraphDiagram-DS77QQ5N-Ec9P4zAx.js} +2 -2
- package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-DF6tegGR.js.map → gitGraphDiagram-DS77QQ5N-Ec9P4zAx.js.map} +1 -1
- package/dist/web/assets/{index-CaFh5gEt.js → index-hasCROMp.js} +3 -3
- package/dist/web/assets/{index-CaFh5gEt.js.map → index-hasCROMp.js.map} +1 -1
- package/dist/web/assets/{infoDiagram-6WML65LV-CGrFzjRa.js → infoDiagram-6WML65LV-DopSEvYK.js} +2 -2
- package/dist/web/assets/{infoDiagram-6WML65LV-CGrFzjRa.js.map → infoDiagram-6WML65LV-DopSEvYK.js.map} +1 -1
- package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-CEo4pf_7.js → ishikawaDiagram-WSZJBQD7-Ckc8Rm5h.js} +2 -2
- package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-CEo4pf_7.js.map → ishikawaDiagram-WSZJBQD7-Ckc8Rm5h.js.map} +1 -1
- package/dist/web/assets/{journeyDiagram-NVQOT4AX-CspNWhHp.js → journeyDiagram-NVQOT4AX-Bil_9GIL.js} +2 -2
- package/dist/web/assets/{journeyDiagram-NVQOT4AX-CspNWhHp.js.map → journeyDiagram-NVQOT4AX-Bil_9GIL.js.map} +1 -1
- package/dist/web/assets/{jsQR-DcKyKt8x.js → jsQR-D3MZZ4y1.js} +2 -2
- package/dist/web/assets/{jsQR-DcKyKt8x.js.map → jsQR-D3MZZ4y1.js.map} +1 -1
- package/dist/web/assets/{kanban-definition-27J2QSJJ-V17PR9V-.js → kanban-definition-27J2QSJJ-BNdZ7Ele.js} +2 -2
- package/dist/web/assets/{kanban-definition-27J2QSJJ-V17PR9V-.js.map → kanban-definition-27J2QSJJ-BNdZ7Ele.js.map} +1 -1
- package/dist/web/assets/{linear-DJQlR9NW.js → linear-CZzNB5i2.js} +2 -2
- package/dist/web/assets/{linear-DJQlR9NW.js.map → linear-CZzNB5i2.js.map} +1 -1
- package/dist/web/assets/{mermaid.core-BJxvfP_g.js → mermaid.core-ZWBuMtbe.js} +5 -5
- package/dist/web/assets/{mermaid.core-BJxvfP_g.js.map → mermaid.core-ZWBuMtbe.js.map} +1 -1
- package/dist/web/assets/{mindmap-definition-FAOFIHXS-CRdQH63m.js → mindmap-definition-FAOFIHXS-Bi2k0JPi.js} +2 -2
- package/dist/web/assets/{mindmap-definition-FAOFIHXS-CRdQH63m.js.map → mindmap-definition-FAOFIHXS-Bi2k0JPi.js.map} +1 -1
- package/dist/web/assets/{pegDiagram-VL7TDLO6-Ba0KPauI.js → pegDiagram-VL7TDLO6-CR7-LzvK.js} +2 -2
- package/dist/web/assets/{pegDiagram-VL7TDLO6-Ba0KPauI.js.map → pegDiagram-VL7TDLO6-CR7-LzvK.js.map} +1 -1
- package/dist/web/assets/{pieDiagram-7S7Q4E2Y-B923JQAs.js → pieDiagram-7S7Q4E2Y-CTHmJKTC.js} +2 -2
- package/dist/web/assets/{pieDiagram-7S7Q4E2Y-B923JQAs.js.map → pieDiagram-7S7Q4E2Y-CTHmJKTC.js.map} +1 -1
- package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-CRgKLy79.js → quadrantDiagram-CIZ2JOQS-BpC9jF8t.js} +2 -2
- package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-CRgKLy79.js.map → quadrantDiagram-CIZ2JOQS-BpC9jF8t.js.map} +1 -1
- package/dist/web/assets/{railroadDiagram-AXF67PYL-ox905hPN.js → railroadDiagram-AXF67PYL-CXAKlWx7.js} +2 -2
- package/dist/web/assets/{railroadDiagram-AXF67PYL-ox905hPN.js.map → railroadDiagram-AXF67PYL-CXAKlWx7.js.map} +1 -1
- package/dist/web/assets/{requirementDiagram-LRYGKXZP-Duq__sqN.js → requirementDiagram-LRYGKXZP-BW3nRbtj.js} +2 -2
- package/dist/web/assets/{requirementDiagram-LRYGKXZP-Duq__sqN.js.map → requirementDiagram-LRYGKXZP-BW3nRbtj.js.map} +1 -1
- package/dist/web/assets/{sankeyDiagram-W5VNT64P-wHwQYnBB.js → sankeyDiagram-W5VNT64P-D7nzUd1h.js} +2 -2
- package/dist/web/assets/{sankeyDiagram-W5VNT64P-wHwQYnBB.js.map → sankeyDiagram-W5VNT64P-D7nzUd1h.js.map} +1 -1
- package/dist/web/assets/{sequenceDiagram-SI44F4Z6-DxIJk57u.js → sequenceDiagram-SI44F4Z6-C7M93O88.js} +2 -2
- package/dist/web/assets/{sequenceDiagram-SI44F4Z6-DxIJk57u.js.map → sequenceDiagram-SI44F4Z6-C7M93O88.js.map} +1 -1
- package/dist/web/assets/{sizeCapture-X5ZJPWSS-DTR7sbJ5.js → sizeCapture-X5ZJPWSS-DXVYHDAz.js} +2 -2
- package/dist/web/assets/{sizeCapture-X5ZJPWSS-DTR7sbJ5.js.map → sizeCapture-X5ZJPWSS-DXVYHDAz.js.map} +1 -1
- package/dist/web/assets/{stateDiagram-OKZ733FA-BVFtM2sL.js → stateDiagram-OKZ733FA-toEJ79DS.js} +2 -2
- package/dist/web/assets/{stateDiagram-OKZ733FA-BVFtM2sL.js.map → stateDiagram-OKZ733FA-toEJ79DS.js.map} +1 -1
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-DomhVykT.js +2 -0
- package/dist/web/assets/{stateDiagram-v2-UEYNNEHI-cPQcuNzH.js.map → stateDiagram-v2-UEYNNEHI-DomhVykT.js.map} +1 -1
- package/dist/web/assets/{swimlanes-SLNWSIFB-CD9G4YCZ.js → swimlanes-SLNWSIFB-CaDpxm0q.js} +3 -3
- package/dist/web/assets/{swimlanes-SLNWSIFB-CD9G4YCZ.js.map → swimlanes-SLNWSIFB-CaDpxm0q.js.map} +1 -1
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-urWS98ZF.js +9 -0
- package/dist/web/assets/{swimlanesDiagram-ULZ7WXOC-CyR-kDwU.js.map → swimlanesDiagram-ULZ7WXOC-urWS98ZF.js.map} +1 -1
- package/dist/web/assets/{timeline-definition-Z64GVDOM-Dvedkrz5.js → timeline-definition-Z64GVDOM-CRFA5jt1.js} +2 -2
- package/dist/web/assets/{timeline-definition-Z64GVDOM-Dvedkrz5.js.map → timeline-definition-Z64GVDOM-CRFA5jt1.js.map} +1 -1
- package/dist/web/assets/{vennDiagram-T6HMQDX7-D5CnNWtW.js → vennDiagram-T6HMQDX7-ni-TS5Gk.js} +2 -2
- package/dist/web/assets/{vennDiagram-T6HMQDX7-D5CnNWtW.js.map → vennDiagram-T6HMQDX7-ni-TS5Gk.js.map} +1 -1
- package/dist/web/assets/{wardleyDiagram-T6FBY63Y-n746vsfx.js → wardleyDiagram-T6FBY63Y-DR1Am4Fj.js} +2 -2
- package/dist/web/assets/{wardleyDiagram-T6FBY63Y-n746vsfx.js.map → wardleyDiagram-T6FBY63Y-DR1Am4Fj.js.map} +1 -1
- package/dist/web/assets/{xychartDiagram-ELKLHX3M-zEDnFO9e.js → xychartDiagram-ELKLHX3M-B5LYw6vX.js} +2 -2
- package/dist/web/assets/{xychartDiagram-ELKLHX3M-zEDnFO9e.js.map → xychartDiagram-ELKLHX3M-B5LYw6vX.js.map} +1 -1
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/dist/web/version.json +1 -1
- package/package.json +1 -1
- package/dist/web/assets/channel-p16PN_NW.js +0 -2
- package/dist/web/assets/classDiagram-JCYQIIEL-DniFmDq7.js +0 -2
- package/dist/web/assets/classDiagram-v2-OCEON4UE-DniFmDq7.js +0 -2
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-cPQcuNzH.js +0 -2
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-CyR-kDwU.js +0 -9
|
@@ -320,7 +320,7 @@ ${a.join(`
|
|
|
320
320
|
`});++i<e.length;)i&&n.push({type:"text",value:`
|
|
321
321
|
`}),n.push(e[i]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
322
322
|
`}),n}function px(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function mx(e,t){const n=iF(e,t),i=n.one(e,void 0),s=nF(n),a=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return s&&a.children.push({type:"text",value:`
|
|
323
|
-
`},s),a}function uF(e,t){return e&&"run"in e?async function(n,i){const s=mx(n,{file:i,...t});await e.run(s,i)}:function(n,i){return mx(n,{file:i,...e||t})}}function gx(e){if(e)throw e}var Sf,yx;function cF(){if(yx)return Sf;yx=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]"},a=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 v;for(v in h);return typeof v>"u"||e.call(h,v)},l=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 Sf=function f(){var h,m,p,v,w,S,C=arguments[0],E=1,R=arguments.length,A=!1;for(typeof C=="boolean"&&(A=C,C=arguments[1]||{},E=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});E<R;++E)if(h=arguments[E],h!=null)for(m in h)p=c(C,m),v=c(h,m),C!==v&&(A&&v&&(a(v)||(w=s(v)))?(w?(w=!1,S=p&&s(p)?p:[]):S=p&&a(p)?p:{},l(C,{name:m,newValue:f(A,S,v)})):typeof v<"u"&&l(C,{name:m,newValue:v}));return C},Sf}var fF=cF();const bf=Vd(fF);function Id(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 dF(){const e=[],t={run:n,use:i};return t;function n(...s){let a=-1;const l=s.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);c(null,...s);function c(f,...h){const m=e[++a];let p=-1;if(f){l(f);return}for(;++p<s.length;)(h[p]===null||h[p]===void 0)&&(h[p]=s[p]);s=h,m?hF(m,c)(...h):l(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 hF(e,t){let n;return i;function i(...l){const c=e.length>l.length;let f;c&&l.push(s);try{f=e.apply(this,l)}catch(h){const m=h;if(c&&n)throw m;return s(m)}c||(f&&f.then&&typeof f.then=="function"?f.then(a,s):f instanceof Error?s(f):a(f))}function s(l,...c){n||(n=!0,t(l,...c))}function a(l){s(null,l)}}const Hn={basename:pF,dirname:mF,extname:gF,join:yF,sep:"/"};function pF(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');_s(e);let n=0,i=-1,s=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(a){n=s+1;break}}else i<0&&(a=!0,i=s+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let l=-1,c=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(a){n=s+1;break}}else l<0&&(a=!0,l=s+1),c>-1&&(e.codePointAt(s)===t.codePointAt(c--)?c<0&&(i=s):(c=-1,i=l));return n===i?i=l:i<0&&(i=e.length),e.slice(n,i)}function mF(e){if(_s(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 gF(e){_s(e);let t=e.length,n=-1,i=0,s=-1,a=0,l;for(;t--;){const c=e.codePointAt(t);if(c===47){if(l){i=t+1;break}continue}n<0&&(l=!0,n=t+1),c===46?s<0?s=t:a!==1&&(a=1):s>-1&&(a=-1)}return s<0||n<0||a===0||a===1&&s===n-1&&s===i+1?"":e.slice(s,n)}function yF(...e){let t=-1,n;for(;++t<e.length;)_s(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":vF(n)}function vF(e){_s(e);const t=e.codePointAt(0)===47;let n=xF(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function xF(e,t){let n="",i=0,s=-1,a=0,l=-1,c,f;for(;++l<=e.length;){if(l<e.length)c=e.codePointAt(l);else{if(c===47)break;c=47}if(c===47){if(!(s===l-1||a===1))if(s!==l-1&&a===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(f=n.lastIndexOf("/"),f!==n.length-1){f<0?(n="",i=0):(n=n.slice(0,f),i=n.length-1-n.lastIndexOf("/")),s=l,a=0;continue}}else if(n.length>0){n="",i=0,s=l,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(s+1,l):n=e.slice(s+1,l),i=l-s-1;s=l,a=0}else c===46&&a>-1?a++:a=-1}return n}function _s(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const wF={cwd:kF};function kF(){return"/"}function Dd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function SF(e){if(typeof e=="string")e=new URL(e);else if(!Dd(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 bF(e)}function bF(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 Cf=["history","path","basename","stem","extname","dirname"];class Jk{constructor(t){let n;t?Dd(t)?n={path:t}:typeof t=="string"||CF(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":wF.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<Cf.length;){const a=Cf[i];a in n&&n[a]!==void 0&&n[a]!==null&&(this[a]=a==="history"?[...n[a]]:n[a])}let s;for(s in n)Cf.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Hn.basename(this.path):void 0}set basename(t){Tf(t,"basename"),Ef(t,"basename"),this.path=Hn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Hn.dirname(this.path):void 0}set dirname(t){vx(this.basename,"dirname"),this.path=Hn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Hn.extname(this.path):void 0}set extname(t){if(Ef(t,"extname"),vx(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=Hn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Dd(t)&&(t=SF(t)),Tf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Hn.basename(this.path,this.extname):void 0}set stem(t){Tf(t,"stem"),Ef(t,"stem"),this.path=Hn.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 Bt(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 Ef(e,t){if(e&&e.includes(Hn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Hn.sep+"`")}function Tf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function vx(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 EF=function(e){const i=this.constructor.prototype,s=i[e],a=function(){return s.apply(a,arguments)};return Object.setPrototypeOf(a,i),a},TF={}.hasOwnProperty;class Jh extends EF{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=dF()}copy(){const t=new Jh;let n=-1;for(;++n<this.attachers.length;){const i=this.attachers[n];t.use(...i)}return t.data(bf(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Af("data",this.frozen),this.namespace[t]=n,this):TF.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Af("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=ol(t),i=this.parser||this.Parser;return Pf("parse",i),i(String(n),n)}process(t,n){const i=this;return this.freeze(),Pf("process",this.parser||this.Parser),Rf("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(a,l){const c=ol(t),f=i.parse(c);i.run(f,c,function(m,p,v){if(m||!p||!v)return h(m);const w=p,S=i.stringify(w,v);AF(S)?v.value=S:v.result=S,h(m,v)});function h(m,p){m||!p?l(m):a?a(p):n(void 0,p)}}}processSync(t){let n=!1,i;return this.freeze(),Pf("processSync",this.parser||this.Parser),Rf("processSync",this.compiler||this.Compiler),this.process(t,s),wx("processSync","process",n),i;function s(a,l){n=!0,gx(a),i=l}}run(t,n,i){xx(t),this.freeze();const s=this.transformers;return!i&&typeof n=="function"&&(i=n,n=void 0),i?a(void 0,i):new Promise(a);function a(l,c){const f=ol(n);s.run(t,f,h);function h(m,p,v){const w=p||t;m?c(m):l?l(w):i(void 0,w,v)}}}runSync(t,n){let i=!1,s;return this.run(t,n,a),wx("runSync","run",i),s;function a(l,c){gx(l),s=c,i=!0}}stringify(t,n){this.freeze();const i=ol(n),s=this.compiler||this.Compiler;return Rf("stringify",s),xx(t),s(t,i)}use(t,...n){const i=this.attachers,s=this.namespace;if(Af("use",this.frozen),t!=null)if(typeof t=="function")f(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):l(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function a(h){if(typeof h=="function")f(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...p]=h;f(m,p)}else l(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function l(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=bf(!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];a(p)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function f(h,m){let p=-1,v=-1;for(;++p<i.length;)if(i[p][0]===h){v=p;break}if(v===-1)i.push([h,...m]);else if(m.length>0){let[w,...S]=m;const C=i[v][1];Id(C)&&Id(w)&&(w=bf(!0,C,w)),i[v]=[h,w,...S]}}}}const PF=new Jh().freeze();function Pf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Rf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Af(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 xx(e){if(!Id(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function wx(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ol(e){return RF(e)?e:new Jk(e)}function RF(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function AF(e){return typeof e=="string"||jF(e)}function jF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const NF="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",kx=[],Sx={allowDangerousHtml:!0},MF=/^(https?|ircs?|mailto|xmpp)$/i,IF=[{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=DF(e),n=_F(e);return LF(t.runSync(t.parse(n),n),e)}function DF(e){const t=e.rehypePlugins||kx,n=e.remarkPlugins||kx,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Sx}:Sx;return PF().use(bO).use(n).use(uF,i).use(t)}function _F(e){const t=e.children||"",n=new Jk;return typeof t=="string"&&(n.value=t),n}function LF(e,t){const n=t.allowedElements,i=t.allowElement,s=t.components,a=t.disallowedElements,l=t.skipHtml,c=t.unwrapDisallowed,f=t.urlTransform||OF;for(const m of IF)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+NF+m.id,void 0);return Sh(e,h),aO(e,{Fragment:y.Fragment,components:s,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function h(m,p,v){if(m.type==="raw"&&v&&typeof p=="number")return l?v.children.splice(p,1):v.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let w;for(w in kf)if(Object.hasOwn(kf,w)&&Object.hasOwn(m.properties,w)){const S=m.properties[w],C=kf[w];(C===null||C.includes(m.tagName))&&(m.properties[w]=f(String(S||""),w,m))}}if(m.type==="element"){let w=n?!n.includes(m.tagName):a?a.includes(m.tagName):!1;if(!w&&i&&typeof p=="number"&&(w=!i(m,p,v)),w&&v&&typeof p=="number")return c&&m.children?v.children.splice(p,1,...m.children):v.children.splice(p,1),p}}}function OF(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 FF={};function eS(e){const t=this,n=e||FF,i=t.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),a=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),l=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(E1(n)),a.push(r1()),l.push(q2(n))}function Ls(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())}),[]),y.jsx(bk,{open:!0,onOpenChange:n=>{n||e.onClose()},children:y.jsxs(Tk,{children:[y.jsx(Pk,{className:"modal-backdrop"}),y.jsxs(Rk,{id:e.contentId,className:"modal"+(e.wide?" modal-wide":"")+(e.className?` ${e.className}`:""),children:[y.jsxs("div",{className:"modal-head",children:[y.jsxs("div",{children:[y.jsx(jk,{asChild:!0,children:y.jsx("h3",{children:e.title})}),e.description&&y.jsx(Nk,{className:"modal-description",children:e.description})]}),y.jsx(Mk,{asChild:!0,children:y.jsx("button",{className:"icon-btn","aria-label":`Close ${e.title}`,children:y.jsx(ke,{name:"close"})})})]}),e.tabs,y.jsx("div",{className:"modal-body",children:e.children})]})]})})}const zF=.25,VF=8;let bx=Promise.resolve();function Cx(){return document.documentElement.classList.contains("theme-dark")?"dark":"default"}function BF(){const[e,t]=k.useState(Cx);return k.useEffect(()=>{const n=document.documentElement,i=()=>t(Cx()),s=new MutationObserver(i);return s.observe(n,{attributes:!0,attributeFilter:["class"]}),i(),()=>s.disconnect()},[]),e}function $F(e,t,n){const i=bx.then(async()=>{const{default:s}=await Mh(async()=>{const{default:a}=await import("./mermaid.core-BJxvfP_g.js").then(l=>l.bp);return{default:a}},[]);return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:n,fontFamily:"var(--sans)"}),s.render(e,t)});return bx=i.then(()=>{},()=>{}),i}function UF(e){return Math.min(VF,Math.max(zF,e))}function WF(e){const t=k.useRef(null),n=k.useRef(null),[i,s]=k.useState(1),[a,l]=k.useState({x:0,y:0}),[c,f]=k.useState(!1),h=()=>{s(1),l({x:0,y:0})},m=(p,v,w)=>{const S=UF(p);if(S===i)return;const C=t.current?.getBoundingClientRect();if(C){const E=(v??C.left+C.width/2)-C.left-C.width/2,R=(w??C.top+C.height/2)-C.top-C.height/2,A=S/i;l(T=>({x:E-A*(E-T.x),y:R-A*(R-T.y)}))}s(S)};return k.useEffect(()=>{const p=v=>{v.key==="+"||v.key==="="?(v.preventDefault(),m(i*1.25)):v.key==="-"?(v.preventDefault(),m(i/1.25)):v.key==="0"&&(v.preventDefault(),h())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)}),y.jsx(bk,{open:!0,onOpenChange:p=>{p||e.onClose()},children:y.jsxs(Tk,{children:[y.jsx(Pk,{className:"mermaid-fullscreen-backdrop"}),y.jsxs(Rk,{className:"mermaid-fullscreen","data-mermaid-theme":e.theme,"aria-describedby":"mermaid-fullscreen-help",children:[y.jsx(jk,{className:"mermaid-fullscreen-title",children:"Diagram viewer"}),y.jsxs("div",{className:"mermaid-fullscreen-tools",children:[y.jsx("button",{className:"icon-btn","aria-label":"Zoom out",title:"Zoom out (−)",onClick:()=>m(i/1.25),children:y.jsx(ke,{name:"minus"})}),y.jsxs("button",{className:"mermaid-zoom-value",onClick:h,title:"Reset zoom and position",children:[Math.round(i*100),"%"]}),y.jsx("button",{className:"icon-btn","aria-label":"Zoom in",title:"Zoom in (+)",onClick:()=>m(i*1.25),children:y.jsx(ke,{name:"plus"})}),y.jsx(Mk,{asChild:!0,children:y.jsx("button",{className:"icon-btn","aria-label":"Close diagram viewer",title:"Close (Esc)",children:y.jsx(ke,{name:"close"})})})]}),y.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:a.x,panY:a.y},p.currentTarget.setPointerCapture(p.pointerId),f(!0))},onPointerMove:p=>{const v=n.current;!v||v.pointerId!==p.pointerId||l({x:v.panX+p.clientX-v.startX,y:v.panY+p.clientY-v.startY})},onPointerUp:p=>{n.current?.pointerId===p.pointerId&&(n.current=null,f(!1),p.currentTarget.releasePointerCapture(p.pointerId))},onPointerCancel:()=>{n.current=null,f(!1)},children:y.jsx("div",{className:"mermaid-fullscreen-canvas",style:{transform:`translate(${a.x}px, ${a.y}px) scale(${i})`},dangerouslySetInnerHTML:{__html:e.svg}})}),y.jsx(Nk,{id:"mermaid-fullscreen-help",className:"mermaid-fullscreen-help",children:"Scroll to zoom · drag to move · double-click to zoom in"})]})]})})}function HF({source:e}){const t=k.useId(),[n,i]=k.useState(""),[s,a]=k.useState(""),[l,c]=k.useState("default"),[f,h]=k.useState(!1),m=BF();return k.useEffect(()=>{let p=!0;const v=`mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"")}`;return i(""),a(""),$F(v,e,m).then(w=>{p&&(c(m),i(w.svg))}).catch(w=>{p&&a(w instanceof Error?w.message:String(w))}),()=>{p=!1,document.getElementById(`d${v}`)?.remove()}},[t,e,m]),s?y.jsxs("pre",{className:"markdown-mermaid-error",children:["Mermaid error: ",s]}):n?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"markdown-mermaid","data-mermaid-theme":l,children:[y.jsx("button",{className:"icon-btn markdown-mermaid-expand","aria-label":"View diagram fullscreen",title:"View diagram fullscreen",onClick:()=>h(!0),children:y.jsx(ke,{name:"maximize"})}),y.jsx("div",{className:"markdown-mermaid-diagram",dangerouslySetInnerHTML:{__html:n}})]}),f&&y.jsx(WF,{svg:n,theme:l,onClose:()=>h(!1)})]}):y.jsx("div",{className:"markdown-mermaid-loading",children:"Rendering diagram…"})}const qF=k.memo(function(t){return y.jsx("article",{className:"markdown-body",ref:t.contentRef,children:y.jsx(Zk,{remarkPlugins:[eS],components:{a:({children:n,...i})=>y.jsx("a",{...i,target:"_blank",rel:"noreferrer",children:n}),code:({className:n,children:i,...s})=>{const a=/language-([\w-]+)/.exec(n??"")?.[1],l=String(i).replace(/\n$/,"");return a==="mermaid"?y.jsx(HF,{source:l}):y.jsx("code",{className:n,...s,children:i})}},children:t.markdown})})});function tS(e){const{rec:t}=e,n=k.useRef(null),[i,s]=k.useState(""),[a,l]=k.useState(null),[c,f]=k.useState("loading"),[h,m]=k.useState(""),[p,v]=k.useState(0),[w,S]=k.useState(""),[C,E]=k.useState(0),[R,A]=k.useState(!1),[T,P]=k.useState(""),[O,D]=k.useState(!1),[K,$]=k.useState(!1),[_,M]=k.useState([]),[Y,B]=k.useState(!1),[ce,Z]=k.useState(null),[ee,pe]=k.useState(!1),[xe,Q]=k.useState("");k.useEffect(()=>{let N=!0,te=null;return f("loading"),Kl(t.id).then(me=>{if(N){if(!me){f("missing");return}s(new TextDecoder("utf-8").decode(me)),te=URL.createObjectURL(new Blob([me],{type:"text/markdown;charset=utf-8"})),l(te),f("ready")}}).catch(()=>{N&&f("error")}),()=>{N=!1,te&&URL.revokeObjectURL(te)}},[t.id]),k.useEffect(()=>{const N=()=>{const te=window.getSelection(),me=n.current;if(!te||te.isCollapsed||!me){m(""),v(0);return}if(!me.contains(te.anchorNode)||!me.contains(te.focusNode)){m(""),v(0);return}const ye=te.getRangeAt(0),he=te.toString(),Te=he.length-he.trimStart().length,ge=he.trim().slice(0,4e3),_e=document.createRange();_e.selectNodeContents(me),_e.setEnd(ye.startContainer,ye.startOffset);const He=_e.toString().length+Te;m(ge),v(vD(me.textContent,ge,He))};return document.addEventListener("selectionchange",N),()=>document.removeEventListener("selectionchange",N)},[]);const fe=()=>{h&&(S(h),E(p),A(!0),Q(""))},j=async()=>{if(K){if(!w||!T.trim())return;M(te=>[...te,{selection:w,comment:T.trim(),occurrence:C}]),P(""),A(!1),Q("Comment added to review");return}const N=gD(w,T);if(!(!N||!T.trim()||O)){D(!0),Q("");try{await e.onSendText(N,t.id||void 0),P(""),A(!1),Q("Feedback sent")}catch(te){Q(`Send failed: ${String(te)}`)}finally{D(!1)}}},F=async()=>{if(_.length===0||Y)return;const N=CD(i,_);B(!0),Q("");try{e.onSendFile?await e.onSendFile({filename:yD(t.filename),mime:"text/markdown",bytes:new TextEncoder().encode(N)},t.id||void 0):await e.onSendText(N,t.id||void 0),M([]),$(!1),Q("Review submitted")}catch(te){Q(`Review send failed: ${String(te)}`)}finally{B(!1)}},J=async()=>{if(!(!ce||!e.onSendFile||ee)){pe(!0),Q("");try{await e.onSendFile(ce,t.id||void 0),Z(null),Q("Voice feedback sent")}catch(N){Q(`Voice send failed: ${String(N)}`)}finally{pe(!1)}}};return y.jsx(Ls,{title:t.filename,description:"Markdown preview · select text to send precise feedback",onClose:e.onClose,wide:!0,className:"markdown-modal",children:y.jsxs("div",{className:"markdown-preview",children:[y.jsxs("div",{className:"markdown-review-toolbar",children:[y.jsxs("button",{className:"btn sm",disabled:!h,onMouseDown:N=>N.preventDefault(),onClick:fe,children:[y.jsx(ke,{name:"reply",size:14}),K?"Add review comment":"Quick message",h?` (${h.length})`:""]}),K?y.jsx("button",{className:"btn sm",onClick:()=>{$(!1),M([]),A(!1),Q("Review discarded")},children:"Cancel review"}):y.jsxs("button",{className:"btn sm",onClick:()=>{$(!0),M([]),Q("Review started — select passages to add comments")},children:[y.jsx(ke,{name:"edit",size:14}),"Start review"]}),a&&y.jsxs("a",{className:"btn sm",href:a,download:t.filename,children:[y.jsx(ke,{name:"download",size:14}),"Download"]}),e.onSendFile&&y.jsx(_1,{disabled:!!ce||ee,onReady:Z,onError:Q}),y.jsx("span",{className:"markdown-review-hint",children:h?"Selection ready for feedback":"Highlight any passage to comment on it"})]}),R&&y.jsxs("div",{className:"markdown-feedback",children:[y.jsx("blockquote",{children:w}),y.jsx("textarea",{className:"field",rows:3,autoFocus:!0,placeholder:"What should change?",value:T,onChange:N=>P(N.target.value)}),y.jsxs("div",{className:"markdown-feedback-actions",children:[y.jsx("button",{className:"btn sm",onClick:()=>A(!1),children:"Cancel"}),y.jsxs("button",{className:"btn sm primary",disabled:!T.trim()||O,onClick:()=>void j(),children:[y.jsx(ke,{name:"send",size:14}),K?"Add to review":O?"Sending…":"Send feedback"]})]})]}),K&&y.jsxs("div",{className:"markdown-review-draft",children:[y.jsxs("div",{className:"markdown-review-draft-head",children:[y.jsxs("strong",{children:["Review · ",_.length," comment",_.length===1?"":"s"]}),y.jsxs("button",{className:"btn sm primary",disabled:_.length===0||Y,onClick:()=>void F(),children:[y.jsx(ke,{name:"send",size:14}),Y?"Submitting…":"Submit review"]})]}),_.map((N,te)=>y.jsxs("div",{className:"markdown-review-comment",children:[y.jsx("span",{children:te+1}),y.jsxs("div",{children:[y.jsx("blockquote",{children:N.selection}),y.jsx("p",{children:N.comment})]}),y.jsx("button",{className:"icon-btn",title:"Remove comment",onClick:()=>M(me=>me.filter((ye,he)=>he!==te)),children:y.jsx(ke,{name:"close",size:14})})]},`${te}-${N.selection.slice(0,24)}`))]}),ce&&y.jsx(D1,{att:ce,sending:ee,onSend:()=>void J(),onDiscard:()=>Z(null)}),xe&&y.jsx("div",{className:"markdown-review-status",role:"status",children:xe}),y.jsxs("div",{className:"markdown-preview-scroll",children:[c==="loading"&&y.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),c==="missing"&&y.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),c==="error"&&y.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),c==="ready"&&y.jsx(qF,{markdown:i,contentRef:n})]})]})})}function nS(e){const{rec:t}=e,[n,i]=k.useState(null),[s,a]=k.useState(0),[l,c]=k.useState(!1),[f,h]=k.useState("loading");return k.useEffect(()=>{let m=!0,p=null;return h("loading"),Kl(t.id).then(v=>{if(m){if(!v){h("missing");return}a(v.byteLength),p=URL.createObjectURL(new Blob([v],{type:Rh(t.mime,t.filename)})),i(p),h("ready")}}).catch(()=>{m&&h("error")}),()=>{m=!1,p&&URL.revokeObjectURL(p)}},[t.id,t.mime,t.filename]),y.jsx(Ls,{title:t.filename,description:"Transformed safe preview · external navigation disabled",onClose:e.onClose,wide:!0,className:"markdown-modal html-modal"+(l?" html-modal-fullscreen":""),children:y.jsxs("div",{className:"html-preview",children:[y.jsxs("div",{className:"html-preview-toolbar",children:[y.jsxs("span",{className:"html-preview-shield",children:[y.jsx(ke,{name:"shield",size:14}),"Scripts, forms and network requests are blocked"]}),y.jsxs("span",{className:"html-preview-actions",children:[f==="ready"&&y.jsxs("button",{className:"btn sm",type:"button",title:"View HTML fullscreen","aria-label":"View HTML fullscreen",onClick:()=>c(!0),children:[y.jsx(ke,{name:"maximize",size:14}),"Fullscreen"]}),n&&y.jsxs("a",{className:"btn sm",href:n,download:t.filename,children:[y.jsx(ke,{name:"download",size:14}),"Download original",s?` · ${Vr(s)}`:""]})]})]}),y.jsxs("div",{className:"html-preview-frame",children:[f==="loading"&&y.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),f==="missing"&&y.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),f==="error"&&y.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),f==="ready"&&y.jsx("iframe",{className:"html-preview-iframe",title:`Sandboxed preview of ${t.filename}`,sandbox:ED,referrerPolicy:"no-referrer",src:`/api/html-preview/${encodeURIComponent(t.id)}`},t.id)]})]})})}function rS(e){const t=(n,i)=>{const{key:s}=n;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(s))return;n.preventDefault();const a=e.options.length-1,l=s==="Home"?0:s==="End"?a:s==="ArrowLeft"||s==="ArrowUp"?(i-1+e.options.length)%e.options.length:(i+1)%e.options.length,c=e.options[l];c&&(e.onChange(c.id),document.getElementById(`${e.idPrefix}-${c.id}`)?.focus())};return y.jsx("div",{className:e.className,role:"tablist","aria-label":e.label,children:e.options.map((n,i)=>y.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:y.jsxs(y.Fragment,{children:[" ",y.jsx("span",{children:n.count})]})]},n.id))})}function _d(e){const{message:t}=e,[n,i]=k.useState(null),[s,a]=k.useState(0),l=O0(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 Kl(t.wireId).then(p=>{!h||!p||(a(p.byteLength),m=URL.createObjectURL(new Blob([p],{type:Rh(l.mime,l.filename)})),i(m))}).catch(()=>{}),()=>{h=!1,m&&URL.revokeObjectURL(m)}},[t.wireId,l.mime,l.filename]);const c=gd(t)==="photo",f=ro(l.mime,l.filename);return y.jsxs("div",{className:"shared-media-item"+(c?" shared-photo-item":""),children:[y.jsxs("button",{className:"shared-media-jump",onClick:()=>e.onJump(e.messageKey),children:[c&&n?y.jsx("img",{src:n,alt:l.filename}):y.jsx("span",{className:"shared-media-icon",children:y.jsx(ke,{name:f?"mic":"copy",size:18})}),y.jsxs("span",{className:"shared-media-copy",children:[y.jsx("strong",{children:c?l.filename||"Photo":f?"Voice message":l.filename}),y.jsxs("span",{children:[e.versionLabel?`${e.versionLabel} · `:"",hi(l.date),s?` · ${Vr(s)}`:""]})]})]}),y.jsxs("span",{className:"shared-media-actions",children:[T1(l.filename)&&n&&y.jsx("button",{className:"icon-btn",title:"Preview markdown",onClick:()=>e.onPreview(l),children:y.jsx(ke,{name:"monitor",size:16})}),Ms(l.filename,l.mime)&&n&&y.jsx("button",{className:"icon-btn",title:"Preview HTML",onClick:()=>e.onPreview(l),children:y.jsx(ke,{name:"monitor",size:16})}),y.jsx("a",{className:"icon-btn"+(n?"":" disabled"),href:n??void 0,download:l.filename,title:"Download",children:y.jsx(ke,{name:"download",size:16})})]})]})}function KF(e){const[t,n]=k.useState(!1);if(e.versions.length===1){const i=e.versions[0];return y.jsx(_d,{message:i.message,messageKey:i.key,onJump:e.onJump,onPreview:e.onPreview})}return y.jsxs("div",{className:"file-version-stack"+(t?" expanded":""),children:[y.jsxs("button",{className:"file-version-stack-head",onClick:()=>n(i=>!i),children:[y.jsx("span",{className:"shared-media-icon",children:y.jsx(ke,{name:"copy",size:18})}),y.jsxs("span",{className:"shared-media-copy",children:[y.jsx("strong",{children:e.filename}),y.jsxs("span",{children:[e.versions.length," versions · newest ",hi(e.versions[0].message.date)]})]}),y.jsx(ke,{name:t?"chevronDown":"chevron",size:16})]}),t&&y.jsx("div",{className:"file-version-stack-list",children:e.versions.map((i,s)=>y.jsx(_d,{message:i.message,messageKey:i.key,versionLabel:`Version ${e.versions.length-s}`,onJump:e.onJump,onPreview:e.onPreview},i.key))})]})}function XF(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})=>gd(h)==="photo"),a=i.filter(({message:h})=>gd(h)==="file"),l=wD(a),c=i.flatMap(({message:h,key:m})=>h.kind==="file"?[]:xD(h.text).map(p=>({url:p,message:h,key:m}))),f=[{id:"photo",label:"Photos",count:s.length},{id:"file",label:"Files",count:a.length},{id:"link",label:"Links",count:c.length}];return y.jsx(Ls,{title:"Shared media",description:"Photos, files, and links from this conversation",onClose:e.onClose,wide:!0,className:"shared-media-modal",tabs:y.jsx(rS,{className:"shared-media-tabs",label:"Shared media type",options:f,value:t,onChange:n,idPrefix:"shared-media-tab",panelId:"shared-media-panel"}),children:y.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=>y.jsx(_d,{message:h.message,messageKey:h.key,onJump:e.onJump,onPreview:e.onPreview},h.key)),t==="file"&&l.map(h=>y.jsx(KF,{filename:h.filename,versions:h.versions,onJump:e.onJump,onPreview:e.onPreview},h.filename)),t==="link"&&c.map((h,m)=>y.jsxs("div",{className:"shared-media-item",children:[y.jsxs("a",{className:"shared-media-jump",href:h.url,target:"_blank",rel:"noreferrer",children:[y.jsx("span",{className:"shared-media-icon",children:y.jsx(ke,{name:"link",size:18})}),y.jsxs("span",{className:"shared-media-copy",children:[y.jsx("strong",{children:h.url}),y.jsx("span",{children:hi(h.message.date)})]})]}),y.jsx("button",{className:"icon-btn",title:"Jump to message",onClick:()=>e.onJump(h.key),children:y.jsx(ke,{name:"reply",size:16})})]},`${h.key}-${h.url}-${m}`)),(t==="photo"&&s.length===0||t==="file"&&a.length===0||t==="link"&&c.length===0)&&y.jsxs("div",{className:"markdown-empty",children:["No ",t==="photo"?"photos":`${t}s`," in this chat yet."]})]})})}const YF=Object.freeze(["image/avif","image/bmp","image/heic","image/heif","image/jpeg","image/jpg","image/png","image/webp"]),GF=/\.(avif|bmp|heic|heif|jpe?g|png|webp)$/i;function iS(e,t=""){return YF.includes(String(e??"").toLowerCase())||GF.test(String(t??""))}function QF(e){return`${(String(e||"photo").trim()||"photo").replace(/\.[^./\\]+$/,"")||"photo"}.jpg`}function JF(e,t,n){const i=Math.max(1,Number(e)||1),s=Math.max(1,Number(t)||1),a=Math.max(1,Number(n)||1),l=Math.min(1,a/Math.max(i,s));return{width:Math.max(1,Math.round(i*l)),height:Math.max(1,Math.round(s*l))}}const ZF=2048,ez=640,tz=.82,nz=[.84,.7,.56,.44],rz=.94;function iz(e){return new Promise((t,n)=>{const i=URL.createObjectURL(e),s=new Image,a=()=>URL.revokeObjectURL(i);s.onload=()=>t({image:s,release:a}),s.onerror=()=>{a(),n(new Error("This browser could not decode the selected image."))},s.src=i})}function oz(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 sz(e,t){if(!iS(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*rz)),{image:i,release:s}=await iz(e),a=document.createElement("canvas"),l=a.getContext("2d",{alpha:!1});if(!l)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>=ez;){const f=JF(i.naturalWidth,i.naturalHeight,c);a.width=f.width,a.height=f.height,l.fillStyle="#fff",l.fillRect(0,0,a.width,a.height),l.drawImage(i,0,0,a.width,a.height);for(const h of nz){const m=await oz(a,h);if(m.size<=n)return{filename:QF(e.name),mime:"image/jpeg",bytes:new Uint8Array(await m.arrayBuffer()),width:a.width,height:a.height,originalSize:e.size}}c=Math.floor(c*tz)}}finally{s(),a.width=1,a.height=1}throw new Error("The photo is still too large after optimization.")}const az=5e4,lz=new Set(["http:","https:","mailto:"]);function oS(e){if(!(!e||e!==e.trim()||/[\u0000-\u001f\u007f]/u.test(e)))try{const t=new URL(e);return lz.has(t.protocol.toLowerCase())?e:void 0}catch{return}}function sS(e){const t="language-";return e?.startsWith(t)&&e.slice(t.length)||void 0}function uz(e){return e.split(/(\n[ \t]*\n)/).map(t=>{if(/^\n[ \t]*\n$/.test(t))return t;const n=t.split(`
|
|
323
|
+
`},s),a}function uF(e,t){return e&&"run"in e?async function(n,i){const s=mx(n,{file:i,...t});await e.run(s,i)}:function(n,i){return mx(n,{file:i,...e||t})}}function gx(e){if(e)throw e}var Sf,yx;function cF(){if(yx)return Sf;yx=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]"},a=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 v;for(v in h);return typeof v>"u"||e.call(h,v)},l=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 Sf=function f(){var h,m,p,v,w,S,C=arguments[0],E=1,R=arguments.length,A=!1;for(typeof C=="boolean"&&(A=C,C=arguments[1]||{},E=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});E<R;++E)if(h=arguments[E],h!=null)for(m in h)p=c(C,m),v=c(h,m),C!==v&&(A&&v&&(a(v)||(w=s(v)))?(w?(w=!1,S=p&&s(p)?p:[]):S=p&&a(p)?p:{},l(C,{name:m,newValue:f(A,S,v)})):typeof v<"u"&&l(C,{name:m,newValue:v}));return C},Sf}var fF=cF();const bf=Vd(fF);function Id(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 dF(){const e=[],t={run:n,use:i};return t;function n(...s){let a=-1;const l=s.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);c(null,...s);function c(f,...h){const m=e[++a];let p=-1;if(f){l(f);return}for(;++p<s.length;)(h[p]===null||h[p]===void 0)&&(h[p]=s[p]);s=h,m?hF(m,c)(...h):l(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 hF(e,t){let n;return i;function i(...l){const c=e.length>l.length;let f;c&&l.push(s);try{f=e.apply(this,l)}catch(h){const m=h;if(c&&n)throw m;return s(m)}c||(f&&f.then&&typeof f.then=="function"?f.then(a,s):f instanceof Error?s(f):a(f))}function s(l,...c){n||(n=!0,t(l,...c))}function a(l){s(null,l)}}const Hn={basename:pF,dirname:mF,extname:gF,join:yF,sep:"/"};function pF(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');_s(e);let n=0,i=-1,s=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(a){n=s+1;break}}else i<0&&(a=!0,i=s+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let l=-1,c=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(a){n=s+1;break}}else l<0&&(a=!0,l=s+1),c>-1&&(e.codePointAt(s)===t.codePointAt(c--)?c<0&&(i=s):(c=-1,i=l));return n===i?i=l:i<0&&(i=e.length),e.slice(n,i)}function mF(e){if(_s(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 gF(e){_s(e);let t=e.length,n=-1,i=0,s=-1,a=0,l;for(;t--;){const c=e.codePointAt(t);if(c===47){if(l){i=t+1;break}continue}n<0&&(l=!0,n=t+1),c===46?s<0?s=t:a!==1&&(a=1):s>-1&&(a=-1)}return s<0||n<0||a===0||a===1&&s===n-1&&s===i+1?"":e.slice(s,n)}function yF(...e){let t=-1,n;for(;++t<e.length;)_s(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":vF(n)}function vF(e){_s(e);const t=e.codePointAt(0)===47;let n=xF(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function xF(e,t){let n="",i=0,s=-1,a=0,l=-1,c,f;for(;++l<=e.length;){if(l<e.length)c=e.codePointAt(l);else{if(c===47)break;c=47}if(c===47){if(!(s===l-1||a===1))if(s!==l-1&&a===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(f=n.lastIndexOf("/"),f!==n.length-1){f<0?(n="",i=0):(n=n.slice(0,f),i=n.length-1-n.lastIndexOf("/")),s=l,a=0;continue}}else if(n.length>0){n="",i=0,s=l,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(s+1,l):n=e.slice(s+1,l),i=l-s-1;s=l,a=0}else c===46&&a>-1?a++:a=-1}return n}function _s(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const wF={cwd:kF};function kF(){return"/"}function Dd(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function SF(e){if(typeof e=="string")e=new URL(e);else if(!Dd(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 bF(e)}function bF(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 Cf=["history","path","basename","stem","extname","dirname"];class Jk{constructor(t){let n;t?Dd(t)?n={path:t}:typeof t=="string"||CF(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":wF.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<Cf.length;){const a=Cf[i];a in n&&n[a]!==void 0&&n[a]!==null&&(this[a]=a==="history"?[...n[a]]:n[a])}let s;for(s in n)Cf.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Hn.basename(this.path):void 0}set basename(t){Tf(t,"basename"),Ef(t,"basename"),this.path=Hn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Hn.dirname(this.path):void 0}set dirname(t){vx(this.basename,"dirname"),this.path=Hn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Hn.extname(this.path):void 0}set extname(t){if(Ef(t,"extname"),vx(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=Hn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Dd(t)&&(t=SF(t)),Tf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Hn.basename(this.path,this.extname):void 0}set stem(t){Tf(t,"stem"),Ef(t,"stem"),this.path=Hn.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 Bt(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 Ef(e,t){if(e&&e.includes(Hn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Hn.sep+"`")}function Tf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function vx(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 EF=function(e){const i=this.constructor.prototype,s=i[e],a=function(){return s.apply(a,arguments)};return Object.setPrototypeOf(a,i),a},TF={}.hasOwnProperty;class Jh extends EF{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=dF()}copy(){const t=new Jh;let n=-1;for(;++n<this.attachers.length;){const i=this.attachers[n];t.use(...i)}return t.data(bf(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Af("data",this.frozen),this.namespace[t]=n,this):TF.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Af("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=ol(t),i=this.parser||this.Parser;return Pf("parse",i),i(String(n),n)}process(t,n){const i=this;return this.freeze(),Pf("process",this.parser||this.Parser),Rf("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(a,l){const c=ol(t),f=i.parse(c);i.run(f,c,function(m,p,v){if(m||!p||!v)return h(m);const w=p,S=i.stringify(w,v);AF(S)?v.value=S:v.result=S,h(m,v)});function h(m,p){m||!p?l(m):a?a(p):n(void 0,p)}}}processSync(t){let n=!1,i;return this.freeze(),Pf("processSync",this.parser||this.Parser),Rf("processSync",this.compiler||this.Compiler),this.process(t,s),wx("processSync","process",n),i;function s(a,l){n=!0,gx(a),i=l}}run(t,n,i){xx(t),this.freeze();const s=this.transformers;return!i&&typeof n=="function"&&(i=n,n=void 0),i?a(void 0,i):new Promise(a);function a(l,c){const f=ol(n);s.run(t,f,h);function h(m,p,v){const w=p||t;m?c(m):l?l(w):i(void 0,w,v)}}}runSync(t,n){let i=!1,s;return this.run(t,n,a),wx("runSync","run",i),s;function a(l,c){gx(l),s=c,i=!0}}stringify(t,n){this.freeze();const i=ol(n),s=this.compiler||this.Compiler;return Rf("stringify",s),xx(t),s(t,i)}use(t,...n){const i=this.attachers,s=this.namespace;if(Af("use",this.frozen),t!=null)if(typeof t=="function")f(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):l(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function a(h){if(typeof h=="function")f(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[m,...p]=h;f(m,p)}else l(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function l(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=bf(!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];a(p)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function f(h,m){let p=-1,v=-1;for(;++p<i.length;)if(i[p][0]===h){v=p;break}if(v===-1)i.push([h,...m]);else if(m.length>0){let[w,...S]=m;const C=i[v][1];Id(C)&&Id(w)&&(w=bf(!0,C,w)),i[v]=[h,w,...S]}}}}const PF=new Jh().freeze();function Pf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Rf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Af(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 xx(e){if(!Id(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function wx(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ol(e){return RF(e)?e:new Jk(e)}function RF(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function AF(e){return typeof e=="string"||jF(e)}function jF(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const NF="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",kx=[],Sx={allowDangerousHtml:!0},MF=/^(https?|ircs?|mailto|xmpp)$/i,IF=[{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=DF(e),n=_F(e);return LF(t.runSync(t.parse(n),n),e)}function DF(e){const t=e.rehypePlugins||kx,n=e.remarkPlugins||kx,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Sx}:Sx;return PF().use(bO).use(n).use(uF,i).use(t)}function _F(e){const t=e.children||"",n=new Jk;return typeof t=="string"&&(n.value=t),n}function LF(e,t){const n=t.allowedElements,i=t.allowElement,s=t.components,a=t.disallowedElements,l=t.skipHtml,c=t.unwrapDisallowed,f=t.urlTransform||OF;for(const m of IF)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+NF+m.id,void 0);return Sh(e,h),aO(e,{Fragment:y.Fragment,components:s,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function h(m,p,v){if(m.type==="raw"&&v&&typeof p=="number")return l?v.children.splice(p,1):v.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let w;for(w in kf)if(Object.hasOwn(kf,w)&&Object.hasOwn(m.properties,w)){const S=m.properties[w],C=kf[w];(C===null||C.includes(m.tagName))&&(m.properties[w]=f(String(S||""),w,m))}}if(m.type==="element"){let w=n?!n.includes(m.tagName):a?a.includes(m.tagName):!1;if(!w&&i&&typeof p=="number"&&(w=!i(m,p,v)),w&&v&&typeof p=="number")return c&&m.children?v.children.splice(p,1,...m.children):v.children.splice(p,1),p}}}function OF(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 FF={};function eS(e){const t=this,n=e||FF,i=t.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),a=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),l=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(E1(n)),a.push(r1()),l.push(q2(n))}function Ls(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())}),[]),y.jsx(bk,{open:!0,onOpenChange:n=>{n||e.onClose()},children:y.jsxs(Tk,{children:[y.jsx(Pk,{className:"modal-backdrop"}),y.jsxs(Rk,{id:e.contentId,className:"modal"+(e.wide?" modal-wide":"")+(e.className?` ${e.className}`:""),children:[y.jsxs("div",{className:"modal-head",children:[y.jsxs("div",{children:[y.jsx(jk,{asChild:!0,children:y.jsx("h3",{children:e.title})}),e.description&&y.jsx(Nk,{className:"modal-description",children:e.description})]}),y.jsx(Mk,{asChild:!0,children:y.jsx("button",{className:"icon-btn","aria-label":`Close ${e.title}`,children:y.jsx(ke,{name:"close"})})})]}),e.tabs,y.jsx("div",{className:"modal-body",children:e.children})]})]})})}const zF=.25,VF=8;let bx=Promise.resolve();function Cx(){return document.documentElement.classList.contains("theme-dark")?"dark":"default"}function BF(){const[e,t]=k.useState(Cx);return k.useEffect(()=>{const n=document.documentElement,i=()=>t(Cx()),s=new MutationObserver(i);return s.observe(n,{attributes:!0,attributeFilter:["class"]}),i(),()=>s.disconnect()},[]),e}function $F(e,t,n){const i=bx.then(async()=>{const{default:s}=await Mh(async()=>{const{default:a}=await import("./mermaid.core-ZWBuMtbe.js").then(l=>l.bp);return{default:a}},[]);return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:n,fontFamily:"var(--sans)"}),s.render(e,t)});return bx=i.then(()=>{},()=>{}),i}function UF(e){return Math.min(VF,Math.max(zF,e))}function WF(e){const t=k.useRef(null),n=k.useRef(null),[i,s]=k.useState(1),[a,l]=k.useState({x:0,y:0}),[c,f]=k.useState(!1),h=()=>{s(1),l({x:0,y:0})},m=(p,v,w)=>{const S=UF(p);if(S===i)return;const C=t.current?.getBoundingClientRect();if(C){const E=(v??C.left+C.width/2)-C.left-C.width/2,R=(w??C.top+C.height/2)-C.top-C.height/2,A=S/i;l(T=>({x:E-A*(E-T.x),y:R-A*(R-T.y)}))}s(S)};return k.useEffect(()=>{const p=v=>{v.key==="+"||v.key==="="?(v.preventDefault(),m(i*1.25)):v.key==="-"?(v.preventDefault(),m(i/1.25)):v.key==="0"&&(v.preventDefault(),h())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)}),y.jsx(bk,{open:!0,onOpenChange:p=>{p||e.onClose()},children:y.jsxs(Tk,{children:[y.jsx(Pk,{className:"mermaid-fullscreen-backdrop"}),y.jsxs(Rk,{className:"mermaid-fullscreen","data-mermaid-theme":e.theme,"aria-describedby":"mermaid-fullscreen-help",children:[y.jsx(jk,{className:"mermaid-fullscreen-title",children:"Diagram viewer"}),y.jsxs("div",{className:"mermaid-fullscreen-tools",children:[y.jsx("button",{className:"icon-btn","aria-label":"Zoom out",title:"Zoom out (−)",onClick:()=>m(i/1.25),children:y.jsx(ke,{name:"minus"})}),y.jsxs("button",{className:"mermaid-zoom-value",onClick:h,title:"Reset zoom and position",children:[Math.round(i*100),"%"]}),y.jsx("button",{className:"icon-btn","aria-label":"Zoom in",title:"Zoom in (+)",onClick:()=>m(i*1.25),children:y.jsx(ke,{name:"plus"})}),y.jsx(Mk,{asChild:!0,children:y.jsx("button",{className:"icon-btn","aria-label":"Close diagram viewer",title:"Close (Esc)",children:y.jsx(ke,{name:"close"})})})]}),y.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:a.x,panY:a.y},p.currentTarget.setPointerCapture(p.pointerId),f(!0))},onPointerMove:p=>{const v=n.current;!v||v.pointerId!==p.pointerId||l({x:v.panX+p.clientX-v.startX,y:v.panY+p.clientY-v.startY})},onPointerUp:p=>{n.current?.pointerId===p.pointerId&&(n.current=null,f(!1),p.currentTarget.releasePointerCapture(p.pointerId))},onPointerCancel:()=>{n.current=null,f(!1)},children:y.jsx("div",{className:"mermaid-fullscreen-canvas",style:{transform:`translate(${a.x}px, ${a.y}px) scale(${i})`},dangerouslySetInnerHTML:{__html:e.svg}})}),y.jsx(Nk,{id:"mermaid-fullscreen-help",className:"mermaid-fullscreen-help",children:"Scroll to zoom · drag to move · double-click to zoom in"})]})]})})}function HF({source:e}){const t=k.useId(),[n,i]=k.useState(""),[s,a]=k.useState(""),[l,c]=k.useState("default"),[f,h]=k.useState(!1),m=BF();return k.useEffect(()=>{let p=!0;const v=`mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"")}`;return i(""),a(""),$F(v,e,m).then(w=>{p&&(c(m),i(w.svg))}).catch(w=>{p&&a(w instanceof Error?w.message:String(w))}),()=>{p=!1,document.getElementById(`d${v}`)?.remove()}},[t,e,m]),s?y.jsxs("pre",{className:"markdown-mermaid-error",children:["Mermaid error: ",s]}):n?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"markdown-mermaid","data-mermaid-theme":l,children:[y.jsx("button",{className:"icon-btn markdown-mermaid-expand","aria-label":"View diagram fullscreen",title:"View diagram fullscreen",onClick:()=>h(!0),children:y.jsx(ke,{name:"maximize"})}),y.jsx("div",{className:"markdown-mermaid-diagram",dangerouslySetInnerHTML:{__html:n}})]}),f&&y.jsx(WF,{svg:n,theme:l,onClose:()=>h(!1)})]}):y.jsx("div",{className:"markdown-mermaid-loading",children:"Rendering diagram…"})}const qF=k.memo(function(t){return y.jsx("article",{className:"markdown-body",ref:t.contentRef,children:y.jsx(Zk,{remarkPlugins:[eS],components:{a:({children:n,...i})=>y.jsx("a",{...i,target:"_blank",rel:"noreferrer",children:n}),code:({className:n,children:i,...s})=>{const a=/language-([\w-]+)/.exec(n??"")?.[1],l=String(i).replace(/\n$/,"");return a==="mermaid"?y.jsx(HF,{source:l}):y.jsx("code",{className:n,...s,children:i})}},children:t.markdown})})});function tS(e){const{rec:t}=e,n=k.useRef(null),[i,s]=k.useState(""),[a,l]=k.useState(null),[c,f]=k.useState("loading"),[h,m]=k.useState(""),[p,v]=k.useState(0),[w,S]=k.useState(""),[C,E]=k.useState(0),[R,A]=k.useState(!1),[T,P]=k.useState(""),[O,D]=k.useState(!1),[K,$]=k.useState(!1),[_,M]=k.useState([]),[Y,B]=k.useState(!1),[ce,Z]=k.useState(null),[ee,pe]=k.useState(!1),[xe,Q]=k.useState("");k.useEffect(()=>{let N=!0,te=null;return f("loading"),Kl(t.id).then(me=>{if(N){if(!me){f("missing");return}s(new TextDecoder("utf-8").decode(me)),te=URL.createObjectURL(new Blob([me],{type:"text/markdown;charset=utf-8"})),l(te),f("ready")}}).catch(()=>{N&&f("error")}),()=>{N=!1,te&&URL.revokeObjectURL(te)}},[t.id]),k.useEffect(()=>{const N=()=>{const te=window.getSelection(),me=n.current;if(!te||te.isCollapsed||!me){m(""),v(0);return}if(!me.contains(te.anchorNode)||!me.contains(te.focusNode)){m(""),v(0);return}const ye=te.getRangeAt(0),he=te.toString(),Te=he.length-he.trimStart().length,ge=he.trim().slice(0,4e3),_e=document.createRange();_e.selectNodeContents(me),_e.setEnd(ye.startContainer,ye.startOffset);const He=_e.toString().length+Te;m(ge),v(vD(me.textContent,ge,He))};return document.addEventListener("selectionchange",N),()=>document.removeEventListener("selectionchange",N)},[]);const fe=()=>{h&&(S(h),E(p),A(!0),Q(""))},j=async()=>{if(K){if(!w||!T.trim())return;M(te=>[...te,{selection:w,comment:T.trim(),occurrence:C}]),P(""),A(!1),Q("Comment added to review");return}const N=gD(w,T);if(!(!N||!T.trim()||O)){D(!0),Q("");try{await e.onSendText(N,t.id||void 0),P(""),A(!1),Q("Feedback sent")}catch(te){Q(`Send failed: ${String(te)}`)}finally{D(!1)}}},F=async()=>{if(_.length===0||Y)return;const N=CD(i,_);B(!0),Q("");try{e.onSendFile?await e.onSendFile({filename:yD(t.filename),mime:"text/markdown",bytes:new TextEncoder().encode(N)},t.id||void 0):await e.onSendText(N,t.id||void 0),M([]),$(!1),Q("Review submitted")}catch(te){Q(`Review send failed: ${String(te)}`)}finally{B(!1)}},J=async()=>{if(!(!ce||!e.onSendFile||ee)){pe(!0),Q("");try{await e.onSendFile(ce,t.id||void 0),Z(null),Q("Voice feedback sent")}catch(N){Q(`Voice send failed: ${String(N)}`)}finally{pe(!1)}}};return y.jsx(Ls,{title:t.filename,description:"Markdown preview · select text to send precise feedback",onClose:e.onClose,wide:!0,className:"markdown-modal",children:y.jsxs("div",{className:"markdown-preview",children:[y.jsxs("div",{className:"markdown-review-toolbar",children:[y.jsxs("button",{className:"btn sm",disabled:!h,onMouseDown:N=>N.preventDefault(),onClick:fe,children:[y.jsx(ke,{name:"reply",size:14}),K?"Add review comment":"Quick message",h?` (${h.length})`:""]}),K?y.jsx("button",{className:"btn sm",onClick:()=>{$(!1),M([]),A(!1),Q("Review discarded")},children:"Cancel review"}):y.jsxs("button",{className:"btn sm",onClick:()=>{$(!0),M([]),Q("Review started — select passages to add comments")},children:[y.jsx(ke,{name:"edit",size:14}),"Start review"]}),a&&y.jsxs("a",{className:"btn sm",href:a,download:t.filename,children:[y.jsx(ke,{name:"download",size:14}),"Download"]}),e.onSendFile&&y.jsx(_1,{disabled:!!ce||ee,onReady:Z,onError:Q}),y.jsx("span",{className:"markdown-review-hint",children:h?"Selection ready for feedback":"Highlight any passage to comment on it"})]}),R&&y.jsxs("div",{className:"markdown-feedback",children:[y.jsx("blockquote",{children:w}),y.jsx("textarea",{className:"field",rows:3,autoFocus:!0,placeholder:"What should change?",value:T,onChange:N=>P(N.target.value)}),y.jsxs("div",{className:"markdown-feedback-actions",children:[y.jsx("button",{className:"btn sm",onClick:()=>A(!1),children:"Cancel"}),y.jsxs("button",{className:"btn sm primary",disabled:!T.trim()||O,onClick:()=>void j(),children:[y.jsx(ke,{name:"send",size:14}),K?"Add to review":O?"Sending…":"Send feedback"]})]})]}),K&&y.jsxs("div",{className:"markdown-review-draft",children:[y.jsxs("div",{className:"markdown-review-draft-head",children:[y.jsxs("strong",{children:["Review · ",_.length," comment",_.length===1?"":"s"]}),y.jsxs("button",{className:"btn sm primary",disabled:_.length===0||Y,onClick:()=>void F(),children:[y.jsx(ke,{name:"send",size:14}),Y?"Submitting…":"Submit review"]})]}),_.map((N,te)=>y.jsxs("div",{className:"markdown-review-comment",children:[y.jsx("span",{children:te+1}),y.jsxs("div",{children:[y.jsx("blockquote",{children:N.selection}),y.jsx("p",{children:N.comment})]}),y.jsx("button",{className:"icon-btn",title:"Remove comment",onClick:()=>M(me=>me.filter((ye,he)=>he!==te)),children:y.jsx(ke,{name:"close",size:14})})]},`${te}-${N.selection.slice(0,24)}`))]}),ce&&y.jsx(D1,{att:ce,sending:ee,onSend:()=>void J(),onDiscard:()=>Z(null)}),xe&&y.jsx("div",{className:"markdown-review-status",role:"status",children:xe}),y.jsxs("div",{className:"markdown-preview-scroll",children:[c==="loading"&&y.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),c==="missing"&&y.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),c==="error"&&y.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),c==="ready"&&y.jsx(qF,{markdown:i,contentRef:n})]})]})})}function nS(e){const{rec:t}=e,[n,i]=k.useState(null),[s,a]=k.useState(0),[l,c]=k.useState(!1),[f,h]=k.useState("loading");return k.useEffect(()=>{let m=!0,p=null;return h("loading"),Kl(t.id).then(v=>{if(m){if(!v){h("missing");return}a(v.byteLength),p=URL.createObjectURL(new Blob([v],{type:Rh(t.mime,t.filename)})),i(p),h("ready")}}).catch(()=>{m&&h("error")}),()=>{m=!1,p&&URL.revokeObjectURL(p)}},[t.id,t.mime,t.filename]),y.jsx(Ls,{title:t.filename,description:"Transformed safe preview · external navigation disabled",onClose:e.onClose,wide:!0,className:"markdown-modal html-modal"+(l?" html-modal-fullscreen":""),children:y.jsxs("div",{className:"html-preview",children:[y.jsxs("div",{className:"html-preview-toolbar",children:[y.jsxs("span",{className:"html-preview-shield",children:[y.jsx(ke,{name:"shield",size:14}),"Scripts, forms and network requests are blocked"]}),y.jsxs("span",{className:"html-preview-actions",children:[f==="ready"&&y.jsxs("button",{className:"btn sm",type:"button",title:"View HTML fullscreen","aria-label":"View HTML fullscreen",onClick:()=>c(!0),children:[y.jsx(ke,{name:"maximize",size:14}),"Fullscreen"]}),n&&y.jsxs("a",{className:"btn sm",href:n,download:t.filename,children:[y.jsx(ke,{name:"download",size:14}),"Download original",s?` · ${Vr(s)}`:""]})]})]}),y.jsxs("div",{className:"html-preview-frame",children:[f==="loading"&&y.jsx("div",{className:"markdown-empty",children:"Loading preview…"}),f==="missing"&&y.jsx("div",{className:"markdown-empty",children:"This file is available on the original device only."}),f==="error"&&y.jsx("div",{className:"markdown-empty",children:"The file could not be opened."}),f==="ready"&&y.jsx("iframe",{className:"html-preview-iframe",title:`Sandboxed preview of ${t.filename}`,sandbox:ED,referrerPolicy:"no-referrer",src:`/api/html-preview/${encodeURIComponent(t.id)}`},t.id)]})]})})}function rS(e){const t=(n,i)=>{const{key:s}=n;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(s))return;n.preventDefault();const a=e.options.length-1,l=s==="Home"?0:s==="End"?a:s==="ArrowLeft"||s==="ArrowUp"?(i-1+e.options.length)%e.options.length:(i+1)%e.options.length,c=e.options[l];c&&(e.onChange(c.id),document.getElementById(`${e.idPrefix}-${c.id}`)?.focus())};return y.jsx("div",{className:e.className,role:"tablist","aria-label":e.label,children:e.options.map((n,i)=>y.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:y.jsxs(y.Fragment,{children:[" ",y.jsx("span",{children:n.count})]})]},n.id))})}function _d(e){const{message:t}=e,[n,i]=k.useState(null),[s,a]=k.useState(0),l=O0(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 Kl(t.wireId).then(p=>{!h||!p||(a(p.byteLength),m=URL.createObjectURL(new Blob([p],{type:Rh(l.mime,l.filename)})),i(m))}).catch(()=>{}),()=>{h=!1,m&&URL.revokeObjectURL(m)}},[t.wireId,l.mime,l.filename]);const c=gd(t)==="photo",f=ro(l.mime,l.filename);return y.jsxs("div",{className:"shared-media-item"+(c?" shared-photo-item":""),children:[y.jsxs("button",{className:"shared-media-jump",onClick:()=>e.onJump(e.messageKey),children:[c&&n?y.jsx("img",{src:n,alt:l.filename}):y.jsx("span",{className:"shared-media-icon",children:y.jsx(ke,{name:f?"mic":"copy",size:18})}),y.jsxs("span",{className:"shared-media-copy",children:[y.jsx("strong",{children:c?l.filename||"Photo":f?"Voice message":l.filename}),y.jsxs("span",{children:[e.versionLabel?`${e.versionLabel} · `:"",hi(l.date),s?` · ${Vr(s)}`:""]})]})]}),y.jsxs("span",{className:"shared-media-actions",children:[T1(l.filename)&&n&&y.jsx("button",{className:"icon-btn",title:"Preview markdown",onClick:()=>e.onPreview(l),children:y.jsx(ke,{name:"monitor",size:16})}),Ms(l.filename,l.mime)&&n&&y.jsx("button",{className:"icon-btn",title:"Preview HTML",onClick:()=>e.onPreview(l),children:y.jsx(ke,{name:"monitor",size:16})}),y.jsx("a",{className:"icon-btn"+(n?"":" disabled"),href:n??void 0,download:l.filename,title:"Download",children:y.jsx(ke,{name:"download",size:16})})]})]})}function KF(e){const[t,n]=k.useState(!1);if(e.versions.length===1){const i=e.versions[0];return y.jsx(_d,{message:i.message,messageKey:i.key,onJump:e.onJump,onPreview:e.onPreview})}return y.jsxs("div",{className:"file-version-stack"+(t?" expanded":""),children:[y.jsxs("button",{className:"file-version-stack-head",onClick:()=>n(i=>!i),children:[y.jsx("span",{className:"shared-media-icon",children:y.jsx(ke,{name:"copy",size:18})}),y.jsxs("span",{className:"shared-media-copy",children:[y.jsx("strong",{children:e.filename}),y.jsxs("span",{children:[e.versions.length," versions · newest ",hi(e.versions[0].message.date)]})]}),y.jsx(ke,{name:t?"chevronDown":"chevron",size:16})]}),t&&y.jsx("div",{className:"file-version-stack-list",children:e.versions.map((i,s)=>y.jsx(_d,{message:i.message,messageKey:i.key,versionLabel:`Version ${e.versions.length-s}`,onJump:e.onJump,onPreview:e.onPreview},i.key))})]})}function XF(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})=>gd(h)==="photo"),a=i.filter(({message:h})=>gd(h)==="file"),l=wD(a),c=i.flatMap(({message:h,key:m})=>h.kind==="file"?[]:xD(h.text).map(p=>({url:p,message:h,key:m}))),f=[{id:"photo",label:"Photos",count:s.length},{id:"file",label:"Files",count:a.length},{id:"link",label:"Links",count:c.length}];return y.jsx(Ls,{title:"Shared media",description:"Photos, files, and links from this conversation",onClose:e.onClose,wide:!0,className:"shared-media-modal",tabs:y.jsx(rS,{className:"shared-media-tabs",label:"Shared media type",options:f,value:t,onChange:n,idPrefix:"shared-media-tab",panelId:"shared-media-panel"}),children:y.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=>y.jsx(_d,{message:h.message,messageKey:h.key,onJump:e.onJump,onPreview:e.onPreview},h.key)),t==="file"&&l.map(h=>y.jsx(KF,{filename:h.filename,versions:h.versions,onJump:e.onJump,onPreview:e.onPreview},h.filename)),t==="link"&&c.map((h,m)=>y.jsxs("div",{className:"shared-media-item",children:[y.jsxs("a",{className:"shared-media-jump",href:h.url,target:"_blank",rel:"noreferrer",children:[y.jsx("span",{className:"shared-media-icon",children:y.jsx(ke,{name:"link",size:18})}),y.jsxs("span",{className:"shared-media-copy",children:[y.jsx("strong",{children:h.url}),y.jsx("span",{children:hi(h.message.date)})]})]}),y.jsx("button",{className:"icon-btn",title:"Jump to message",onClick:()=>e.onJump(h.key),children:y.jsx(ke,{name:"reply",size:16})})]},`${h.key}-${h.url}-${m}`)),(t==="photo"&&s.length===0||t==="file"&&a.length===0||t==="link"&&c.length===0)&&y.jsxs("div",{className:"markdown-empty",children:["No ",t==="photo"?"photos":`${t}s`," in this chat yet."]})]})})}const YF=Object.freeze(["image/avif","image/bmp","image/heic","image/heif","image/jpeg","image/jpg","image/png","image/webp"]),GF=/\.(avif|bmp|heic|heif|jpe?g|png|webp)$/i;function iS(e,t=""){return YF.includes(String(e??"").toLowerCase())||GF.test(String(t??""))}function QF(e){return`${(String(e||"photo").trim()||"photo").replace(/\.[^./\\]+$/,"")||"photo"}.jpg`}function JF(e,t,n){const i=Math.max(1,Number(e)||1),s=Math.max(1,Number(t)||1),a=Math.max(1,Number(n)||1),l=Math.min(1,a/Math.max(i,s));return{width:Math.max(1,Math.round(i*l)),height:Math.max(1,Math.round(s*l))}}const ZF=2048,ez=640,tz=.82,nz=[.84,.7,.56,.44],rz=.94;function iz(e){return new Promise((t,n)=>{const i=URL.createObjectURL(e),s=new Image,a=()=>URL.revokeObjectURL(i);s.onload=()=>t({image:s,release:a}),s.onerror=()=>{a(),n(new Error("This browser could not decode the selected image."))},s.src=i})}function oz(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 sz(e,t){if(!iS(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*rz)),{image:i,release:s}=await iz(e),a=document.createElement("canvas"),l=a.getContext("2d",{alpha:!1});if(!l)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>=ez;){const f=JF(i.naturalWidth,i.naturalHeight,c);a.width=f.width,a.height=f.height,l.fillStyle="#fff",l.fillRect(0,0,a.width,a.height),l.drawImage(i,0,0,a.width,a.height);for(const h of nz){const m=await oz(a,h);if(m.size<=n)return{filename:QF(e.name),mime:"image/jpeg",bytes:new Uint8Array(await m.arrayBuffer()),width:a.width,height:a.height,originalSize:e.size}}c=Math.floor(c*tz)}}finally{s(),a.width=1,a.height=1}throw new Error("The photo is still too large after optimization.")}const az=5e4,lz=new Set(["http:","https:","mailto:"]);function oS(e){if(!(!e||e!==e.trim()||/[\u0000-\u001f\u007f]/u.test(e)))try{const t=new URL(e);return lz.has(t.protocol.toLowerCase())?e:void 0}catch{return}}function sS(e){const t="language-";return e?.startsWith(t)&&e.slice(t.length)||void 0}function uz(e){return e.split(/(\n[ \t]*\n)/).map(t=>{if(/^\n[ \t]*\n$/.test(t))return t;const n=t.split(`
|
|
324
324
|
`),i=n.filter(l=>l.trim().length>0);if(i.length===0)return t;const s=i.map(l=>l.match(/^[ \t]+/)?.[0]??"");if(s.some(l=>l.length===0))return t;const a=Math.min(...s.map(l=>l.length));return n.map(l=>l.trim().length>0?l.slice(a):l).join(`
|
|
325
|
-
`)}).join("")}function cz({children:e}){const t=k.isValidElement(e)?e:null,n=sS(t?.props.className);return y.jsxs("div",{className:"message-code-block","data-language":n||void 0,children:[n&&y.jsx("div",{className:"message-code-language",children:n}),y.jsx("pre",{children:e})]})}const fz=[eS],dz={a:({node:e,children:t,href:n,...i})=>{const s=oS(n);return s?y.jsx("a",{...i,href:s,target:"_blank",rel:"noopener noreferrer",children:t}):y.jsx("span",{className:"message-link-blocked",children:t})},img:({alt:e})=>y.jsxs("span",{className:"message-image-placeholder",children:["[image: ",e||"remote image blocked","]"]}),pre:cz,code:({node:e,className:t,children:n,...i})=>y.jsx("code",{className:t,"data-language":sS(t),...i,children:n})},Ex=k.memo(function({text:t,className:n="bubble-text message-markdown"}){return t.length>az?y.jsx("div",{className:`${n} message-markdown-plaintext`,"data-render-mode":"plaintext",children:t}):y.jsx("div",{className:n,"data-render-mode":"markdown",children:y.jsx(Zk,{remarkPlugins:fz,components:dz,urlTransform:i=>oS(i)??"",children:uz(t)})})}),hz=new Set(["type","title","description","default","enum","const","minimum","maximum","minLength","maxLength","pattern","properties","required","items","minItems","maxItems","additionalProperties"]),Tx=6,Px=64,Rx=256,Ax=256,jx=12,Nx=2048,Mx=64*1024;function aS(e){if(typeof e!="string")return"pattern must be a string";if(e.length>Rx)return`pattern exceeds ${Rx} characters`;if(!e.startsWith("^")||!e.endsWith("$"))return"pattern must be anchored with ^ and $";let t=!1,n=!1;for(let i=0;i<e.length;i++){const s=e[i];if(s==="\\"){if(++i>=e.length)return"pattern has invalid syntax";if(/\d/.test(e[i])||e[i]==="k")return"pattern backreferences are not supported";continue}if(t){s==="]"&&(t=!1);continue}if(s==="["){t=!0;continue}if("()?*+|".includes(s))return"pattern must use only bounded, non-grouped expressions";if(s==="{"){const a=/^\{(\d+)(?:,(\d+))?\}/.exec(e.slice(i));if(!a)return"pattern has an invalid or unbounded repetition";const l=Number(a[1]),c=Number(a[2]??a[1]);if(l>c||c>Ax)return`pattern repetition must not exceed ${Ax}`;if(l!==c){const f=e.slice(i+a[0].length);if(n||f!==""&&f!=="$")return"a variable pattern repetition is supported only once, at the end";n=!0}i+=a[0].length-1}}if(t)return"pattern has invalid syntax";try{new RegExp(e)}catch{return"pattern has invalid syntax"}return null}function Ld(e,t=0,n={value:0}){if(t>Tx)return`Schema depth exceeds ${Tx}`;if(n.value++,n.value>Px)return`Schema exceeds ${Px} controls`;const i=Object.keys(e).find(a=>!hz.has(a));if(i)return`Unsupported JSON Schema keyword: ${i}`;if(e.title!==void 0&&typeof e.title!="string")return"title must be a string";if(e.description!==void 0&&typeof e.description!="string")return"description must be a string";if(e.enum!==void 0&&(!Array.isArray(e.enum)||e.enum.length===0))return"enum must be a non-empty array";const s=e.type;if(s===void 0&&e.enum===void 0&&!Object.hasOwn(e,"const"))return"An explicit type, enum, or const is required";if(s!==void 0&&!["object","array","string","number","integer","boolean","null"].includes(String(s)))return`Unsupported JSON Schema type: ${String(s)}`;for(const a of["minimum","maximum"])if(e[a]!==void 0&&(typeof e[a]!="number"||!Number.isFinite(e[a])))return`${a} must be a finite number`;for(const a of["minLength","maxLength","minItems","maxItems"])if(e[a]!==void 0&&(typeof e[a]!="number"||!Number.isInteger(e[a])||e[a]<0))return`${a} must be a non-negative integer`;if((e.minimum!==void 0||e.maximum!==void 0)&&s!=="number"&&s!=="integer")return"minimum/maximum require a numeric type";if((e.minLength!==void 0||e.maxLength!==void 0)&&s!=="string")return"minLength/maxLength require string type";if(e.pattern!==void 0){if(s!=="string")return"pattern requires a string type";const a=aS(e.pattern);if(a)return a}if((e.minItems!==void 0||e.maxItems!==void 0)&&s!=="array")return"minItems/maxItems require array type";if(e.additionalProperties!==void 0){if(s!=="object")return"additionalProperties requires an object type";if(e.additionalProperties===!0)return"additionalProperties: true is not supported";if(e.additionalProperties!==!1)return e.additionalProperties&&typeof e.additionalProperties=="object"&&!Array.isArray(e.additionalProperties)?"Schema-valued additionalProperties is not supported":"additionalProperties must be false"}if(s==="object"){const a=e.properties;if(a!==void 0&&(!a||typeof a!="object"||Array.isArray(a)))return"properties must be an object";if(e.required!==void 0&&(!Array.isArray(e.required)||e.required.some(l=>typeof l!="string")))return"required must be an array of property names";for(const l of Object.values(a??{})){if(!l||typeof l!="object"||Array.isArray(l))return"property schema must be an object";const c=Ld(l,t+1,n);if(c)return c}}return s==="array"&&e.items!==void 0?!e.items||typeof e.items!="object"||Array.isArray(e.items)?"items must be one schema object":Ld(e.items,t+1,n):null}function Ol(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((s,a)=>Ol(s,t[a]));const n=Object.keys(e).sort(),i=Object.keys(t).sort();return n.length===i.length&&n.every((s,a)=>s===i[a]&&Ol(e[s],t[s]))}function pz(e,t){let n=0;const i=(a,l)=>{if(l>jx)return`${t} exceeds depth ${jx}`;if(n++,n>Nx)return`${t} exceeds ${Nx} JSON values`;if(a===null||typeof a!="object")return null;for(const c of Array.isArray(a)?a:Object.values(a)){const f=i(c,l+1);if(f)return f}return null},s=i(e,0);return s||(new TextEncoder().encode(JSON.stringify(e)).byteLength>Mx?`${t} exceeds ${Mx} UTF-8 bytes`:null)}function Od(e,t,n){if(Object.hasOwn(e,"const")&&!Ol(e.const,t))return`${n} must use the fixed value`;if(Array.isArray(e.enum)&&!e.enum.some(i=>Ol(i,t)))return`${n} is not an allowed value`;if(e.type==="null")return t===null?null:`${n} must be null`;if(e.type==="boolean")return typeof t=="boolean"?null:`${n} must be boolean`;if(e.type==="string"){if(typeof t!="string")return`${n} must be text`;if(typeof e.minLength=="number"&&t.length<e.minLength)return`${n} is too short`;if(typeof e.maxLength=="number"&&t.length>e.maxLength)return`${n} is too long`;if(e.pattern!==void 0){const i=aS(e.pattern);if(i)return`${n} cannot be validated safely: ${i}`;if(!new RegExp(e.pattern).test(t))return`${n} does not match the required format`}return null}if(e.type==="number"||e.type==="integer")return typeof t!="number"||!Number.isFinite(t)?`${n} must be a finite number`:e.type==="integer"&&!Number.isInteger(t)?`${n} must be an integer`:typeof e.minimum=="number"&&t<e.minimum?`${n} is below the minimum`:typeof e.maximum=="number"&&t>e.maximum?`${n} is above the maximum`:null;if(e.type==="array"){if(!Array.isArray(t))return`${n} must be an array`;if(typeof e.minItems=="number"&&t.length<e.minItems)return`${n} has too few items`;if(typeof e.maxItems=="number"&&t.length>e.maxItems)return`${n} has too many items`;if(e.items&&typeof e.items=="object"&&!Array.isArray(e.items))for(let i=0;i<t.length;i++){const s=Od(e.items,t[i],`${n}[${i}]`);if(s)return s}return null}if(e.type==="object"){if(!t||typeof t!="object"||Array.isArray(t))return`${n} must be an object`;const i=e.properties??{};for(const a of Object.keys(t))if(e.additionalProperties===!1&&!Object.hasOwn(i,a))return`${n}.${a||"(empty key)"} is not declared by the schema`;const s=Array.isArray(e.required)?e.required:[];for(const a of s)if(!Object.hasOwn(t,a))return`${n}.${a||"(empty key)"} is required`;for(const[a,l]of Object.entries(i)){if(!Object.hasOwn(t,a))continue;const c=Od(l,t[a],`${n}.${a||"(empty key)"}`);if(c)return c}}return null}function Fl(e,t,n="Arguments"){return pz(t,n)??Od(e,t,n)}function eo(e){if(Object.hasOwn(e,"const"))return e.const;if(e.default!==void 0)return e.default;if(Array.isArray(e.enum)&&e.enum.length)return e.enum[0];if(e.type==="object"){const t=Object.create(null),n=new Set(Array.isArray(e.required)?e.required.filter(i=>typeof i=="string"):[]);for(const[i,s]of Object.entries(e.properties??{})){const a=s;(n.has(i)||a.default!==void 0)&&(t[i]=eo(a))}return t}return e.type==="array"?[]:e.type==="boolean"?!1:e.type==="number"||e.type==="integer"?0:e.type==="null"?null:""}function Ix(e,t){return typeof e.title=="string"&&e.title?e.title:t||"(empty key)"}function Dx(e,t,n){const i=Object.create(null);for(const[s,a]of Object.entries(e))i[s]=a;return i[t]=n,i}function mz(e,t){const n=Object.create(null);for(const[i,s]of Object.entries(e))i!==t&&(n[i]=s);return n}function gz(e){const{schema:t,label:n,path:i,value:s,required:a,description:l,onChange:c,onValidityChange:f}=e,h=k.useId().replace(/[^a-zA-Z0-9_-]/g,""),p=`command-array-${i.replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"root"}-${h}-help`,[v,w]=k.useState(()=>JSON.stringify(s,null,2)),[S,C]=k.useState(null),E=k.useRef(JSON.stringify(s));k.useEffect(()=>{const A=JSON.stringify(s);A!==E.current&&(E.current=A,w(JSON.stringify(s,null,2)),C(null),f(i,null))},[f,i,s]),k.useEffect(()=>()=>f(i,null),[f,i]);const R=A=>{w(A);let T;try{T=JSON.parse(A)}catch{const O=`${n} must contain valid JSON`;C(O),f(i,O);return}if(!Array.isArray(T)){const O=`${n} must be a JSON array`;C(O),f(i,O);return}const P=Fl(t,T,n);C(P),f(i,P),E.current=JSON.stringify(T),c(T)};return y.jsxs("label",{className:"command-field",children:[y.jsxs("span",{children:[n,a?" *":""]}),y.jsx("textarea",{value:v,rows:3,"aria-describedby":p,"aria-invalid":S?"true":void 0,onChange:A=>R(A.target.value)}),y.jsx("small",{id:p,children:l??"JSON array"}),S&&y.jsx("span",{className:"command-field-error",role:"alert",children:S})]})}function yz(e){const{schema:t,label:n,path:i,value:s,required:a,description:l,numeric:c,onChange:f,onValidityChange:h}=e,m=Fl(t,s,n);return k.useEffect(()=>(h(i,m),()=>h(i,null)),[m,h,i]),y.jsxs("label",{className:"command-field",children:[y.jsxs("span",{children:[n,a?" *":""]}),y.jsx("input",{type:c?"number":"text",value:String(s??""),min:typeof t.minimum=="number"?t.minimum:void 0,max:typeof t.maximum=="number"?t.maximum:void 0,minLength:typeof t.minLength=="number"?t.minLength:void 0,maxLength:typeof t.maxLength=="number"?t.maxLength:void 0,step:t.type==="integer"?1:c?"any":void 0,required:a,"aria-invalid":m?"true":void 0,onChange:p=>f(c?Number(p.target.value):p.target.value)}),l&&y.jsx("small",{children:l}),m&&y.jsx("span",{className:"command-field-error",role:"alert",children:m})]})}function lS(e){const{schema:t,name:n,path:i,value:s,required:a,onChange:l,onValidityChange:c}=e,f=Ix(t,n),h=typeof t.description=="string"?t.description:void 0;if(Object.hasOwn(t,"const"))return y.jsxs("div",{className:"command-field",children:[y.jsxs("span",{children:[f,a?" *":""]}),y.jsxs("small",{children:["Fixed value: ",JSON.stringify(t.const)]})]});if(Array.isArray(t.enum))return y.jsxs("label",{className:"command-field",children:[y.jsxs("span",{children:[f,a?" *":""]}),y.jsx("select",{value:JSON.stringify(s),onChange:p=>l(JSON.parse(p.target.value)),children:t.enum.map((p,v)=>y.jsx("option",{value:JSON.stringify(p),children:String(p)},v))}),h&&y.jsx("small",{children:h})]});if(t.type==="object"){const p=s&&typeof s=="object"&&!Array.isArray(s)?s:{},v=new Set(Array.isArray(t.required)?t.required.filter(w=>typeof w=="string"):[]);return y.jsxs("fieldset",{className:"command-object",children:[y.jsx("legend",{children:f}),h&&y.jsx("p",{children:h}),Object.entries(t.properties??{}).map(([w,S])=>{const C=S,E=Object.hasOwn(p,w),R=Ix(C,w),A=`${i}.${w||"(empty key)"}`;return!E&&!v.has(w)?y.jsxs("button",{type:"button",className:"linkbtn command-property-add",onClick:()=>l(Dx(p,w,eo(C))),children:["Add ",R]},w):y.jsxs("div",{className:"command-property",children:[y.jsx(lS,{schema:C,name:w,path:A,value:E?p[w]:eo(C),required:v.has(w),onValidityChange:c,onChange:T=>l(Dx(p,w,T))}),!v.has(w)&&y.jsx("button",{type:"button",className:"linkbtn command-property-remove","aria-label":`Remove ${R}`,onClick:()=>l(mz(p,w)),children:"Remove"})]},w)})]})}if(t.type==="array")return y.jsx(gz,{schema:t,label:f,path:i,value:s,required:a,description:h,onChange:l,onValidityChange:c});if(t.type==="boolean")return y.jsxs("label",{className:"command-check",children:[y.jsx("input",{type:"checkbox",checked:s===!0,onChange:p=>l(p.target.checked)})," ",f]});if(t.type==="null")return y.jsxs("div",{className:"command-field",children:[y.jsx("span",{children:f}),y.jsx("small",{children:"Null value"})]});const m=t.type==="number"||t.type==="integer";return y.jsx(yz,{schema:t,label:f,path:i,value:s,required:a,description:h,numeric:m,onChange:l,onValidityChange:c})}function vz(e){const t=e.catalog.commands[0],[n,i]=k.useState(t?.name??""),s=e.catalog.commands.find(T=>T.name===n)??t,a=k.useMemo(()=>s?Ld(s.input_schema):null,[s]),[l,c]=k.useState(()=>t?eo(t.input_schema):null),[f,h]=k.useState(""),[m,p]=k.useState("idle"),[v,w]=k.useState({}),S=k.useRef(0),C=k.useCallback((T,P)=>{w(O=>{if(P===null){if(!Object.hasOwn(O,T))return O;const D={...O};return delete D[T],D}return O[T]===P?O:{...O,[T]:P}})},[]),E=T=>{const P=e.catalog.commands.find(O=>O.name===T);i(T),c(P?eo(P.input_schema):null),h(""),p("idle"),w({})},R=T=>{if(T.preventDefault(),!s||a||e.busy)return;const O=Object.values(v)[0]??Fl(s.input_schema,l);if(O){h(`Validation denied: ${O}`),p("error");return}const D=++S.current,K=s,$=l;c(eo(K.input_schema)),w({}),h(`Sending ${K.name}…`),p("pending"),e.onSend(K,$,crypto.randomUUID(),e.catalog.fingerprint).then(_=>{S.current===D&&(_.status==="failed"?(h(`${K.name} was refused before delivery.`),p("error")):_.status==="pending"?(h(`${K.name} delivery is pending.`),p("warning")):_.status==="indeterminate"||!_.wire_id?(h(`${K.name} delivery could not be confirmed.`),p("indeterminate")):(h(`${K.name} sent. Its result will appear in the conversation.`),p("success")))}).catch(()=>{S.current===D&&(h(`${K.name} could not be sent. You can try it again.`),p("error"))})},A=s&&!a?Fl(s.input_schema,l):null;return y.jsxs("form",{className:"command-panel","aria-label":"Send a typed command",onSubmit:R,onKeyDown:T=>{T.key==="Escape"&&e.onClose()},children:[y.jsxs("div",{className:"command-panel-head",children:[y.jsxs("div",{className:"command-panel-recipient",children:[y.jsxs("strong",{children:["Commands for ",e.recipientName]}),y.jsxs("span",{className:"mono",title:e.catalog.recipient_cid,children:[e.catalog.recipient_cid.slice(0,12),"…"]})]}),y.jsx("button",{type:"button",className:"linkbtn",onClick:e.onRefresh,children:"Refresh"}),y.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close commands",onClick:e.onClose,children:"×"})]}),e.catalog.commands.length===0?y.jsx("p",{role:"status",children:"This recipient does not advertise commands."}):y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"command-field",children:[y.jsx("span",{children:"Command"}),y.jsx("select",{autoFocus:!0,value:n,onChange:T=>E(T.target.value),children:e.catalog.commands.map(T=>y.jsx("option",{value:T.name,children:T.name},T.name))})]}),s?.description&&y.jsx("p",{children:s.description}),a?y.jsxs("div",{className:"banner error",role:"alert",children:["Cannot render this command safely: ",a]}):s&&y.jsx(lS,{schema:s.input_schema,name:"Arguments",path:"Arguments",value:l,onChange:c,onValidityChange:C}),s&&y.jsx("button",{className:"btn primary",disabled:!!a||e.busy||!!A||Object.keys(v).length>0,children:"Send command"}),y.jsx("div",{className:`command-status ${m}`,"data-state":m,role:"status","aria-live":"polite",children:f})]})]})}const os={type:"spring",stiffness:430,damping:38,mass:.72},_x=10,uS=56,xz=18,wz=650;function kz(e,t){return Math.abs(e)<_x&&Math.abs(t)<_x?"pending":Math.abs(e)>Math.abs(t)&&e>0?"drag":"reject"}function Sz(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 bz(e,t){const n=Sz(t);return n>=0&&(e>=uS||e>=xz&&n>=wz)}const Fd="ours.chats.listMode",hs="recent";function cS(){try{return globalThis.localStorage}catch{return}}function Cz(e=cS()){try{return e?.getItem(Fd)==="identity"?"identity":hs}catch{return hs}}function Ez(e,t=cS()){const n=e==="identity"?"identity":hs;try{return t?.setItem(Fd,n),t?.getItem(Fd)===n?n:hs}catch{return hs}}function Cs(e){return typeof e=="string"?e:""}function zl(e,t){const n=Cs(e),i=Cs(t),s=n.normalize().toLowerCase(),a=i.normalize().toLowerCase();return s<a?-1:s>a?1:n<i?-1:n>i?1:0}function Tz(e,t){const n=jl(Cs(t.activityAt))-jl(Cs(e.activityAt));if(n!==0)return n;const i=zl(e.name,t.name);return i!==0?i:zl(e.id,t.id)}function zd(e){return[...e].sort(Tz)}function Lx(e){return e.contacts.length>0?jl(Cs(e.contacts[0].activityAt)):0}function Pz(e,t){const n=new Map,i=[];for(const a of e){const l=a.root||(t?.[a.id]?a.id:null);if(!l){i.push(a);continue}const c=t?.[l]||{label:l,note:""};let f=n.get(l);f||(f={id:`root:${l}`,rootId:l,label:c.label,note:c.note,contacts:[]},n.set(l,f)),f.contacts.push(a)}const s=[...n.values()].map(a=>({...a,contacts:zd(a.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:zd(i)}),s.sort((a,l)=>{const c=Lx(l)-Lx(a);if(c!==0)return c;const f=zl(a.label,l.label);return f!==0?f:zl(a.id,l.id)})}const Rz=15e3;function jf(e){const{c:t,active:n,grouped:i}=e,[s,a]=k.useState(!1),l=async(h,m)=>{if(!(!h||s)){a(!0);try{const p=await h();requestAnimationFrame(()=>{p?document.getElementById("chat-list-title")?.focus():m.focus()})}finally{a(!1)}}},c=y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"contact-avatar","aria-hidden":!0,children:t.initials}),y.jsxs("span",{className:"contact-copy",children:[y.jsxs("span",{className:"contact-row-topline",children:[y.jsx("span",{className:"contact-name",children:t.name}),t.when&&y.jsx("span",{className:"contact-time",children:t.when})]}),y.jsxs("span",{className:"contact-row-bottomline",children:[y.jsx("span",{className:"contact-last",children:t.last}),t.status==="pending"&&y.jsx("span",{className:"chip",children:"pending approval"}),!!t.unread&&y.jsx("span",{className:"contact-unread",children:t.unread})]})]}),t.status==="pending"&&y.jsxs("span",{className:"pending-actions",role:"group","aria-label":`Decide whether to accept ${t.name}`,children:[y.jsx("button",{type:"button",className:"linkbtn",disabled:s,onClick:h=>void l(e.onApprove,h.currentTarget),children:"Approve"}),y.jsx("button",{type:"button",className:"linkbtn quiet",disabled:s,onClick:h=>void l(e.onReject,h.currentTarget),children:"Reject"})]}),n&&y.jsx(Ji.span,{className:"contact-active-glow",layoutId:"active-contact",transition:os})]}),f="contact-row"+(n?" active":"")+(i?" grouped":"")+(t.status==="pending"?" pending":"");return t.status==="pending"?y.jsx("div",{className:f,children:c}):y.jsx(Ji.button,{type:"button",className:f,onClick:e.onClick,children:c})}function Az(e){const{contacts:t,roots:n,selected:i}=e,[s,a]=k.useState(""),l=k.useRef(null),c=k.useRef(null),[f,h]=k.useState(()=>Cz()),m=_=>_.name.toLowerCase().includes(s.toLowerCase()),p=t.filter(_=>_.status!=="pending"&&m(_)),v=t.filter(_=>_.status==="pending"&&m(_)),w=zd(p),S=Pz(p,n),C=p.length===0&&v.length===0,E=_=>{h(Ez(_))},R=[{id:"recent",label:"Recent"},{id:"identity",label:"By identity"}],A=k.useRef(null),T=k.useRef({id:-1,x0:0,y0:0,mode:"idle"}),P=k.useRef(!1),O=(_,M)=>{const Y=T.current;if(Y.id!==_)return;const B=A.current;if(M&&Y.mode==="drag"&&B){const ce=parseFloat(B.style.getPropertyValue("--mode-drag-x"))||0,Z=Math.max(0,(B.clientWidth-8)/2);E(ce>=Z/2?"identity":"recent"),P.current=!0,window.setTimeout(()=>{P.current=!1},0)}T.current={id:-1,x0:0,y0:0,mode:"idle"},B?.hasPointerCapture?.(_)&&B.releasePointerCapture(_),B?.classList.remove("dragging"),B?.style.removeProperty("--mode-drag-x")},D=_=>{!_.isPrimary||T.current.id!==-1||(T.current={id:_.pointerId,x0:_.clientX,y0:_.clientY,mode:"pending"})},K=_=>{const M=T.current;if(M.id!==_.pointerId||M.mode==="idle")return;const Y=_.clientX-M.x0,B=_.clientY-M.y0;if(M.mode==="pending"){if(Math.abs(Y)<10&&Math.abs(B)<10)return;if(Math.abs(B)>Math.abs(Y)){O(_.pointerId,!1);return}M.mode="drag",_.currentTarget.setPointerCapture?.(_.pointerId),_.currentTarget.classList.add("dragging")}_.preventDefault();const ce=Math.max(0,(_.currentTarget.clientWidth-8)/2),Z=f==="identity"?ce:0;_.currentTarget.style.setProperty("--mode-drag-x",`${Math.min(ce,Math.max(0,Z+Y))}px`)},$=(_,M)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(_.key))return;_.preventDefault();const B=_.key==="Home"?"recent":_.key==="End"||M==="recent"?"identity":"recent";E(B),document.getElementById(`conversation-list-${B}`)?.focus()};return k.useLayoutEffect(()=>{const _=l.current,M=c.current;if(!_||!M)return;const Y=()=>_.style.setProperty("--list-bottom-chrome-height",`${M.getBoundingClientRect().height}px`);Y();const B=new ResizeObserver(Y);return B.observe(M),()=>{B.disconnect(),_.style.removeProperty("--list-bottom-chrome-height")}},[]),y.jsxs("div",{className:"listcol",ref:l,children:[y.jsxs("div",{className:"listcol-head",children:[y.jsxs("div",{className:"listcol-titlebar",children:[y.jsxs("h2",{id:"chat-list-title",className:"listcol-title messenger-lockup",tabIndex:-1,children:[y.jsx("span",{className:"messenger-brand-ours",children:"Ours"}),y.jsx("span",{className:"messenger-brand-product",children:"messenger"})]}),y.jsxs("div",{className:"listcol-actions",children:[y.jsx("button",{className:"btn icon-btn desktop-invite","aria-label":"Invite",title:"Invite",onClick:e.onInvite,children:y.jsx(ke,{name:"invite",size:18})}),y.jsx("button",{className:"icon-btn","aria-label":"Settings",title:"Settings",onClick:e.onSettings,children:y.jsx(ke,{name:"settings",size:18})})]})]}),y.jsx("div",{ref:A,className:"conversation-list-modes",role:"tablist","aria-label":"Conversation list layout","data-mode":f,onPointerDown:D,onPointerMove:K,onPointerUp:_=>O(_.pointerId,!0),onPointerCancel:_=>O(_.pointerId,!1),onLostPointerCapture:_=>O(_.pointerId,!1),children:R.map(_=>y.jsx("button",{id:`conversation-list-${_.id}`,type:"button",role:"tab","aria-selected":f===_.id,"aria-controls":"conversation-list-panel",tabIndex:f===_.id?0:-1,className:f===_.id?"active":"",onClick:M=>{if(P.current){M.preventDefault();return}E(_.id)},onKeyDown:M=>$(M,_.id),children:_.label},_.id))})]}),y.jsxs("div",{id:"conversation-list-panel",className:"listcol-scroll",role:"tabpanel","aria-labelledby":`conversation-list-${f}`,children:[f==="recent"&&w.length>0&&y.jsx("div",{className:"conversation-group",children:w.map(_=>y.jsx(jf,{c:_,active:i===_.id,onClick:()=>e.onSelect(_.id)},_.id))}),f==="identity"&&S.map(_=>y.jsxs("div",{children:[y.jsxs("div",{className:"group-label",title:_.note,children:[_.rootId&&y.jsx(ke,{name:"clusters"}),y.jsx("span",{children:_.label}),_.note&&y.jsxs("span",{className:"gl-note",children:["· ",_.note]})]}),y.jsx("div",{className:"conversation-group",children:_.contacts.map(M=>y.jsx(jf,{c:M,grouped:_.rootId!==null,active:i===M.id,onClick:()=>e.onSelect(M.id)},M.id))})]},_.id)),v.length>0&&y.jsxs("div",{children:[y.jsx("div",{className:"group-label",children:y.jsx("span",{children:"Pending"})}),y.jsx("div",{className:"conversation-group",children:v.map(_=>y.jsx(jf,{c:_,active:!1,onClick:()=>{},onApprove:()=>e.onApprovePending(_.id.slice(8)),onReject:()=>e.onRejectPending(_.id.slice(8))},_.id))})]}),C&&y.jsx("p",{className:"muted",style:{padding:"14px 10px",fontSize:"0.85rem"},children:"No contacts yet — share an invite to start."})]}),y.jsxs("div",{className:"list-bottom-chrome",ref:c,children:[y.jsxs("div",{className:"search adaptive-search",role:"search",children:[y.jsx("span",{className:"adaptive-search-icon","aria-hidden":!0,children:y.jsx(ke,{name:"search"})}),y.jsx("input",{className:"field",placeholder:"Search people, agents, apps…",value:s,onChange:_=>a(_.target.value),onKeyDown:_=>{_.key==="Escape"&&(_.preventDefault(),a(""))}})]}),y.jsx("button",{type:"button",className:"icon-btn list-bottom-invite","aria-label":"Invite",title:"Invite",onClick:e.onInvite,children:y.jsx(ke,{name:"invite",size:20})})]})]})}function jz(e){const[t,n]=k.useState(!1),[i,s]=k.useState(e.contact.name),[a,l]=k.useState(!1),[c,f]=k.useState(null),h=k.useRef(!1);k.useEffect(()=>{const p=v=>{v.key!=="Escape"||a||c||t||(v.preventDefault(),e.onBack())};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t,c,e.onBack,a]);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 y.jsxs("div",{className:"detail contact-screen",children:[y.jsxs("div",{className:"detail-head contact-screen-head",children:[y.jsx("button",{type:"button",className:"icon-btn detail-back contact-back","aria-label":"Back to conversation",onClick:e.onBack,children:y.jsx(ke,{name:"back"})}),y.jsx("strong",{children:"Contact"})]}),y.jsxs("div",{className:"contact-screen-scroll",children:[y.jsxs("section",{className:"contact-hero","aria-labelledby":"contact-screen-name",children:[y.jsx("div",{className:"avatar accent contact-avatar-large","aria-hidden":!0,children:e.contact.initials}),t?y.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))}}):y.jsx("h2",{id:"contact-screen-name",children:e.contact.name}),y.jsxs("p",{children:[y.jsx(ke,{name:"lock",size:13})," End-to-end encrypted connection"]})]}),y.jsxs("section",{className:"contact-action-group","aria-label":"Contact actions",children:[y.jsxs("button",{type:"button",onClick:()=>l(!0),children:[y.jsxs("span",{children:[y.jsx(ke,{name:"paperclip"}),"Shared photos, files, and links"]}),y.jsx(ke,{name:"chevron"})]}),y.jsxs("button",{type:"button",onClick:()=>{h.current=!1,s(e.contact.name),n(!0)},children:[y.jsxs("span",{children:[y.jsx(ke,{name:"edit"}),"Rename contact"]}),y.jsx(ke,{name:"chevron"})]})]}),y.jsxs("section",{className:"contact-identity","aria-labelledby":"contact-identity-title",children:[y.jsx("h3",{id:"contact-identity-title",children:"Verified identity"}),e.contact.roleId&&y.jsxs("p",{children:["Role ",y.jsx("strong",{children:e.contact.roleId})," of ",y.jsx("strong",{children:e.contact.rootName})]}),y.jsx("code",{children:e.contact.id}),y.jsxs("button",{type:"button",className:"btn sm",onClick:()=>void navigator.clipboard.writeText(e.contact.id),children:[y.jsx(ke,{name:"copy",size:14}),"Copy identity"]})]}),y.jsxs("button",{type:"button",className:"contact-remove",onClick:e.onRemove,children:[y.jsx(ke,{name:"trash"}),"Remove contact"]})]}),a&&y.jsx(XF,{messages:e.messages,indexOffset:e.indexOffset,onClose:()=>l(!1),onJump:e.onOpenMessage,onPreview:p=>{l(!1),f(p)}}),c&&(Ms(c.filename,c.mime)?y.jsx(nS,{rec:c,onClose:()=>f(null)}):y.jsx(tS,{rec:c,onClose:()=>f(null),onSendText:e.onSendText,onSendFile:e.onSendFile}))]})}const fS=e=>`chat-message-${encodeURIComponent(e)}`,dS=()=>typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function Nf(e){const{dir:t,canReply:n,onReply:i}=e,s=k.useRef(null),a=k.useRef(null),l=k.useRef(null),c=k.useRef(i);c.current=i;const f=t==="in"?1:-1,h=uS,m=84,p=()=>({id:-1,x0:0,y0:0,mode:"idle",armed:!1,distance:0,samples:[]}),v=k.useRef(p()),w=A=>{const T=a.current,P=l.current,O=dS();if(T&&(T.style.transform=A&&!O?`translateX(${A}px)`:""),P){const D=Math.min(1,Math.abs(A)/h);P.style.opacity=String(D),P.style.transform=O?"scale(1)":`scale(${.5+.5*D})`}},S=(A,T)=>{const P=v.current;if(P.id!==A)return;const O=T&&P.mode==="drag"&&bz(P.distance,P.samples);v.current=p(),a.current?.classList.remove("swiping"),l.current?.classList.remove("armed"),w(0);const D=s.current;D?.hasPointerCapture?.(A)&&D.releasePointerCapture(A),O&&c.current()};k.useEffect(()=>{const A=s.current;if(!A)return;const T=P=>S(P.pointerId,!1);return A.addEventListener("lostpointercapture",T),()=>{A.removeEventListener("lostpointercapture",T);const P=v.current.id;P!==-1&&S(P,!1)}},[]);const C=A=>{const T=A.target,P=window.getSelection?.();!n||!A.isPrimary||A.pointerType==="mouse"||A.pointerType==="pen"&&A.button!==0||v.current.id!==-1||P&&!P.isCollapsed||T.closest('a, button, input, textarea, select, [role="button"], audio, video, img, [draggable="true"], .filecard, .filecard-bubble, .image-bubble, .voice-bubble, .ours-message-file, .attachment')||(v.current={id:A.pointerId,x0:A.clientX,y0:A.clientY,mode:"maybe",armed:!1,distance:0,samples:[{x:A.clientX*f,time:A.timeStamp}]},w(0))},E=A=>{const T=v.current;if(T.id!==A.pointerId||T.mode==="idle")return;const P=A.clientX-T.x0,O=A.clientY-T.y0,D=window.getSelection?.();if(D&&!D.isCollapsed){S(A.pointerId,!1);return}if(T.mode==="maybe"){const Y=kz(P*f,O);if(Y==="pending")return;if(Y==="drag")T.mode="drag",A.currentTarget.setPointerCapture?.(A.pointerId),a.current?.classList.add("swiping");else{T.mode="idle";return}}A.preventDefault();const K=A.timeStamp;T.samples.push({x:A.clientX*f,time:K}),T.samples=T.samples.filter(Y=>K-Y.time<=120);let $=P*f;$<0&&($=0),$>h&&($=h+($-h)*.35),$=Math.min($,m),T.distance=$;const _=$*f,M=Math.abs(_)>=h;M!==T.armed&&(T.armed=M,l.current?.classList.toggle("armed",M),M&&navigator.vibrate?.(10)),w(_)},R=A=>{const T=v.current;T.id===A.pointerId&&T.mode==="drag"&&(T.samples.push({x:A.clientX*f,time:A.timeStamp}),T.distance=Math.max(0,(A.clientX-T.x0)*f),T.armed=T.distance>=h),S(A.pointerId,!0)};return y.jsxs("div",{ref:s,className:"msg-row "+(e.rowClass??t),style:n?{touchAction:"pan-y"}:void 0,onPointerDown:C,onPointerMove:E,onPointerUp:R,onPointerCancel:A=>S(A.pointerId,!1),onLostPointerCapture:A=>S(A.pointerId,!1),children:[n&&y.jsx("span",{className:"swipe-cue",ref:l,"aria-hidden":!0,children:y.jsx(ke,{name:"reply",size:16})}),y.jsx("div",{className:"bubble-wrap",ref:a,children:e.children}),e.after]})}const Nz=k.memo(function(t){const{messages:n,optimisticSend:i,sentKeys:s,hiddenEarlier:a,unreadWireId:l,roomLines:c,contactCid:f,contactName:h,onStartReply:m,onPreview:p,onFetchFile:v}=t,w=new Map;for(const P of n)P.wireId&&w.set(P.wireId,P);const S=P=>c.get(P)??null,C=P=>{if(P.dir==="out")return"You";const O=S(P);return O&&O.variant==="chat"?O.author:h},E=P=>{if(P.kind==="file")return P.mime?.startsWith("image/")?"Photo":ro(P.mime??"",P.filename??"")?"Voice message":P.filename||"File";const O=S(P);return O?O.text||$j(O):P.text},R=P=>{if(!P.replyTo)return null;const O=w.get(P.replyTo.wireId);return O?{author:C(O),text:E(O)}:{author:"",text:"Original message"}},A=P=>{P.wireId&&m({wireId:P.wireId,author:C(P),text:E(P)})},T=P=>{if(!P)return null;const O=S(P);return O?O.variant==="system"?"room:system":`room:chat:${O.author}${O.role}`:P.dir};return y.jsx(cR,{initial:!1,children:n.map((P,O)=>{const D=P===i?.message?i.key:P.wireId&&s.get(P.wireId)||P.wireId||`${P.date}-${a+O}`,K=fS(P.wireId||D),$=n[O-1],_=n[O+1],M=S(P),Y=T(P),B=!!$&&T($)===Y&&Y!=="room:system",ce=!!_&&T(_)===Y&&Y!=="room:system",Z=(P.dir==="out"?"out":"in")+(B?" cont-top":"")+(ce?" cont-bot":""),ee=P.wireId?y.jsx("button",{className:"msg-reply",title:"Reply",onClick:()=>A(P),children:y.jsx(ke,{name:"reply",size:15})}):null,pe=P.wireId===l?y.jsx("div",{id:`unread-${K}`,className:"unread-divider",role:"separator",children:y.jsx("span",{children:"Unread messages"})}):null;if(M&&M.variant==="system"){const Q=M.presentation??"system";return y.jsxs(Ji.div,{className:"message-motion",id:K,initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:os,children:[pe,y.jsxs("div",{className:`room-system room-${Q}-card`,role:"note",children:[M.label&&y.jsx("span",{className:"room-system-label",children:M.label}),M.roomName&&y.jsx("strong",{className:"room-card-name",children:M.roomName}),y.jsx(Ex,{text:M.text,className:"room-system-text message-markdown"}),!!M.details?.length&&y.jsx("ul",{className:"room-card-details","aria-label":"Room event details",children:M.details.map(fe=>y.jsx("li",{children:fe},fe))}),y.jsxs("span",{className:"room-card-provenance",children:[M.authoredBy&&y.jsx("span",{className:"room-card-author",children:M.authoredBy}),y.jsx("span",{className:"room-system-at",children:hi(P.date)})]})]})]},D)}if(P.kind==="file"){const Q=O0(P.wireId)??{id:P.wireId,dir:P.dir,filename:P.filename??"file",mime:P.mime??"application/octet-stream",size:0,date:P.date};return y.jsxs(Ji.div,{className:"message-motion",id:K,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:os,children:[pe,y.jsx(Nf,{dir:P.dir==="out"?"out":"in",rowClass:Z,canReply:!!P.wireId,onReply:()=>A(P),after:ee,children:y.jsx("div",{className:`ours-message ours-message-file ours-message--${P.dir}`,children:y.jsx(BD,{rec:Q,receipt:P.receipt,receiptless:P.receiptless,onPreview:p,onFetch:v})})})]},D)}if(P.typed){const Q=P.typed.kind==="command_result"&&P.replyTo?w.get(P.replyTo.wireId):void 0,fe=P.typed.kind==="command_result"&&P.dir==="in"&&P.peerCid===f&&Q?.dir==="out"&&Q.peerCid===f&&Q.typed?.kind==="command",j=P.typed.kind==="command_result"&&!P.typed.outcome.ok?P.typed.outcome.error.toLowerCase():"",F=P.typed.kind==="command"?P.dir==="out"?"Accepted · pending result":"Received command":P.typed.kind==="unknown"?"Safe failure":P.dir==="out"?"Result sent":fe?j==="validation_denied"||j==="validation_failed"?"Validation denied":j==="policy_denied"||j==="unauthorized"||j==="forbidden"?"Policy denied":P.typed.outcome.ok?"Completed":"Failed":"Unmatched result · safe failure",J=P.typed.kind==="command"?P.typed.command:P.typed.kind==="command_result"?`Result for ${fe&&Q?.typed?.kind==="command"?Q.typed.command:"unmatched command"}`:`Unsupported ${P.typed.wire_kind}`,N=P.typed.kind==="command"?P.typed.arguments:P.typed.kind==="command_result"?P.typed.outcome:{safe_failure:P.typed.malformed?"Malformed typed message":"Future typed message preserved"};return y.jsxs(Ji.div,{className:"message-motion",id:K,initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0},transition:os,children:[pe,y.jsx(Nf,{dir:P.dir,rowClass:Z,canReply:!!P.wireId,onReply:()=>A(P),after:ee,children:y.jsxs("div",{className:`ours-message typed-message ours-message--${P.dir}`,children:[y.jsx("div",{className:"typed-message-kind",children:P.typed.kind==="command"?"Command":P.typed.kind==="command_result"?"Result":"Typed message"}),y.jsx("strong",{children:J}),y.jsx("div",{className:"typed-message-state",role:"status",children:F}),y.jsx("pre",{children:JSON.stringify(N,null,2)}),y.jsxs("div",{className:"bubble-at",children:[hi(P.date),P.dir==="out"&&y.jsx(cd,{receipt:P.receipt,receiptless:P.receiptless})]})]})})]},D)}const xe=R(P);return y.jsxs(Ji.div,{className:"message-motion",id:K,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:os,children:[pe,y.jsx(Nf,{dir:P.dir==="out"?"out":"in",rowClass:Z,canReply:!!P.wireId,onReply:()=>A(P),after:ee,children:y.jsxs("div",{className:`ours-message ours-message--${P.dir}`,children:[xe&&y.jsxs("div",{className:"quote",children:[xe.author&&y.jsx("span",{className:"quote-author",children:xe.author}),y.jsx("span",{className:"quote-text",children:xe.text})]}),M&&!B&&y.jsxs(y.Fragment,{children:[M.roomName&&y.jsx("div",{className:"room-message-room",children:M.roomName}),y.jsxs("div",{className:"room-author",children:[y.jsx("span",{className:"room-author-name",children:M.author}),M.role&&y.jsx("span",{className:"room-author-role",children:M.role})]})]}),y.jsx(Ex,{text:M?M.text:P.text}),y.jsxs("div",{className:"bubble-at",children:[hi(P.date),P.dir==="out"&&y.jsx(cd,{receipt:P.receipt,receiptless:P.receiptless})]})]})})]},D)})})});function Mz(e){const{contact:t,messages:n}=e,[i,s]=k.useState(""),[a,l]=k.useState(!1),[c,f]=k.useState(null),[h,m]=k.useState(null),[p,v]=k.useState(null),[w,S]=k.useState(null),[C,E]=k.useState(null),[R,A]=k.useState(!1),[T,P]=k.useState(!1),[O,D]=k.useState(!1),[K,$]=k.useState(null),[_,M]=k.useState(null),[Y,B]=k.useState(!1),[ce,Z]=k.useState(!1),ee=k.useRef(null),pe=k.useRef(null),xe=k.useRef(null),Q=k.useRef(null),fe=k.useRef(null),j=k.useRef(null),F=k.useRef(null),J=k.useRef(!1),N=k.useRef(null),te=k.useRef(!1),[me,ye]=k.useState(!1),[he,Te]=k.useState(0),ge=k.useRef(null),_e=k.useRef(!0),He=k.useRef(null),tt=k.useRef(0),gt=k.useRef(null),at=k.useRef(new Map),_t=k.useRef(0),ot=k.useRef(null),qe=k.useRef(null),At=k.useRef(0),hn=k.useRef(null),jt=k.useRef("");k.useLayoutEffect(()=>{const V=fe.current,q=j.current,re=F.current;if(!V||!q||!re)return;let de=-1,le=-1,Ne=null;const ut=()=>{const $e=Math.round(q.getBoundingClientRect().height),Ye=Math.round(re.getBoundingClientRect().height);if($e!==de&&(de=$e,V.style.setProperty("--conversation-head-height",`${$e}px`)),Ye!==le){const Le=_e.current;le=Ye,V.style.setProperty("--conversation-compose-height",`${Ye}px`),Le&&(Ne!==null&&cancelAnimationFrame(Ne),Ne=requestAnimationFrame(()=>{Ne=null;const $t=N.current;$t&&_e.current&&($t.scrollTop=Math.max(0,$t.scrollHeight-$t.clientHeight))}))}};ut();const kt=new ResizeObserver(ut);return kt.observe(q),kt.observe(re),()=>{kt.disconnect(),Ne!==null&&cancelAnimationFrame(Ne),V.style.removeProperty("--conversation-head-height"),V.style.removeProperty("--conversation-compose-height")}},[t?.id]),k.useEffect(()=>{s(""),m(null),v(null),f(null),S(null),E(null),A(!1),P(!1),D(!1),tt.current+=1,$(null),ee.current?.abort(),M(null),B(!1),Z(!1),at.current.clear(),ot.current=null,qe.current=null},[t?.id]);const Gt=async(V=!0,q=!0)=>{if(!t||!e.onLoadCommands)return;ee.current?.abort();const re=new AbortController;ee.current=re,Z(!0),m(null);try{const de=await e.onLoadCommands(t.id,re.signal);!re.signal.aborted&&de.recipient_cid===t.id?(M(de),de.commands.length===0?(B(!1),Y&&requestAnimationFrame(()=>Q.current?.focus({preventScroll:!0}))):V&&B(!0)):re.signal.aborted||(M(null),B(!1),q&&m("Command discovery was refused because the authenticated recipient changed."))}catch(de){re.signal.aborted||(M(null),B(!1),q&&m(de instanceof Al?`Command discovery failed: ${de.message}`:"Command discovery failed safely. The recipient may be offline or unsupported."))}finally{ee.current===re&&Z(!1)}};k.useEffect(()=>(Gt(!1,!1),()=>ee.current?.abort()),[t?.id]);const Fn=()=>{B(!1),pe.current?.focus()};k.useEffect(()=>{if(!p)return;const V=p.reply?.wireId;n.some(re=>re.kind!=="file"&&re.dir==="out"&&!!re.wireId&&!p.wireIds.has(re.wireId)&&re.text===p.text&&(re.replyTo?.wireId??void 0)===V)&&(v(null),m(null),s(re=>re===p.draft?"":re),S(re=>re===p.reply?null:re))},[n,p]);const Oe=!!c?.wireId&&n.some(V=>V.wireId===c.wireId),yt=k.useMemo(()=>c&&!Oe?[...n,c.message]:n,[n,c,Oe]);k.useEffect(()=>{Oe&&f(null)},[Oe]),k.useLayoutEffect(()=>{const V=Q.current;if(!V)return;i.startsWith(jt.current)||(V.style.height="0px");const re=V.scrollHeight,le=`${Math.max(44,Math.min(re,132))}px`;V.style.height!==le&&(V.style.height=le),V.style.overflowY=re>132?"auto":"hidden",jt.current=i},[i,t?.id]);const En=V=>{const q=N.current;if(!q)return;const re=Math.max(0,q.scrollHeight-q.clientHeight);if(Math.abs(q.scrollTop-re)<1){ot.current=null,qe.current=null;return}const de=V&&!dS();ot.current=de?re:null,qe.current=de?q.scrollTop:null,de?q.scrollTo({top:re,behavior:"smooth"}):q.scrollTop=re},G=()=>{ge.current===null&&(ge.current=requestAnimationFrame(()=>{ge.current=null;const V=N.current;if(!V)return;const q=V.scrollHeight-V.clientHeight-V.scrollTop>48;ye(q),q||Te(0)}))};k.useLayoutEffect(()=>{if(!t){He.current=null,_e.current=!0,At.current=0;return}const V=N.current;if(!V)return;const q=He.current!==t.id,re=At.current,de=yt.length!==re,le=yt.at(-1),Ne=le?le.wireId||`${le.date}:${le.text}`:null,ut=hn.current;if(At.current=yt.length,hn.current=Ne,!q&&!de&&ot.current===null&&(_e.current=V.scrollHeight-V.clientHeight-V.scrollTop<=48),q||_e.current)En(de&&!q&&He.current!==null),_e.current=!0;else if(de&&yt.length>re&&Ne!==ut){const kt=ut===null?-1:yt.findIndex($e=>($e.wireId||`${$e.date}:${$e.text}`)===ut);Te($e=>$e+Math.max(1,yt.length-Math.max(0,kt+1)))}He.current=t.id,G()},[t,yt.length]),k.useLayoutEffect(()=>{if(te.current||!e.unreadOpen||window.location.hash.startsWith("#chat-message-"))return;const V=N.current,q=document.getElementById(`unread-${fS(e.unreadOpen.wireId)}`);!V||!q||(V.scrollTop=Math.max(0,q.offsetTop-16),_e.current=!1,te.current=!0,G())},[e.unreadOpen,yt.length]),k.useLayoutEffect(()=>{const V=window.location.hash;if(!V.startsWith("#chat-message-"))return;const q=document.getElementById(V.slice(1));q&&(q.scrollIntoView({block:"center"}),_e.current=!1)},[t?.id,yt.length]),k.useLayoutEffect(()=>{const V=gt.current,q=N.current;if(V===null||!q)return;const re=requestAnimationFrame(()=>{gt.current===V&&(q.scrollTop=V.top+q.scrollHeight-V.height,gt.current=null)});return()=>cancelAnimationFrame(re)},[yt.length]),k.useEffect(()=>{const V=N.current;if(!V||typeof ResizeObserver>"u")return;const q=V.firstElementChild;if(!q)return;const re=new ResizeObserver(()=>{_e.current&&En(ot.current!==null),G()});return re.observe(q),re.observe(V),()=>{re.disconnect(),ge.current!==null&&cancelAnimationFrame(ge.current)}},[t?.id]);const se=async V=>{const q=++tt.current;m(null),D(!0);try{if(V.size>is&&iS(V.type,V.name)){const de=await sz(V,is);if(q!==tt.current)return;E({filename:de.filename,mime:de.mime,bytes:de.bytes,originalSize:de.originalSize});return}if(V.size>is){m(`"${V.name}" is ${Vr(V.size)} — files up to ${Vr(is)} can be sent.`);return}const re=await V.arrayBuffer();if(q!==tt.current)return;E({filename:V.name||"file",mime:V.type||"application/octet-stream",bytes:new Uint8Array(re)})}catch(re){q===tt.current&&m(`Photo optimization failed: ${re instanceof Error?re.message:String(re)}`)}finally{q===tt.current&&D(!1)}},Pe=()=>{!C||!e.onSendFile||T||(P(!0),e.onSendFile(C,w?.wireId).then(()=>{E(null),S(null)}).catch(V=>m(`File send failed: ${String(V)} — it was not delivered.`)).finally(()=>P(!1)))},De=e.onDraftChange;k.useEffect(()=>(De?.(i.trim().length>0||a),()=>De?.(!1)),[i,a,De]);const ze=k.useMemo(()=>{const V=new Map;for(const q of yt)V.set(q,q.kind==="file"?null:q.dir==="in"?_j(t?.announcedName??"",q.text):null);return V},[yt,t?.announcedName]);if(!t)return e.emptyOverride?y.jsx(y.Fragment,{children:e.emptyOverride}):y.jsx("div",{className:"detail",children:y.jsxs("div",{className:"detail-empty",children:[y.jsx(ke,{name:"chat"}),y.jsxs("div",{children:[y.jsx("div",{style:{fontWeight:650,color:"var(--text-2)"},children:"Select a conversation"}),y.jsx("div",{style:{fontSize:"0.85rem"},children:"Chat with people, agents and apps across ours."})]})]})});const lt=async()=>{const V=i,q=V.trim(),re=!!p&&V===p.draft&&(w?.wireId??void 0)===p.reply?.wireId;if(!q||J.current||re)return;p&&v(null),J.current=!0,l(!0),m(null);const de=w,le=de?.wireId,Ne=new AbortController;let ut=!1,kt=0;s(""),S(null);const $e=`optimistic-${++_t.current}`;f({key:$e,wireId:null,message:{dir:"out",text:q,date:new Date().toISOString(),read:!0,wireId:"",replyTo:le?{wireId:le}:null}});try{const Ye=await Promise.race([e.onSend(q,le,Ne.signal),new Promise((Le,$t)=>{kt=window.setTimeout(()=>{ut=!0,Ne.abort(),$t(new Error("send timeout"))},Rz)})]);Ye?(at.current.set(Ye,$e),f(Le=>Le?.key===$e?{...Le,wireId:Ye}:Le)):f(Le=>Le?.key===$e?null:Le),v(null)}catch(Ye){f(null),s(Le=>Le===""?V:Le),S(Le=>Le===null?de:Le),ut||!(Ye instanceof Al)?(v({draft:V,text:q,reply:de,wireIds:new Set(n.flatMap(Le=>Le.wireId?[Le.wireId]:[]))}),m(`${ut?"Send timed out":"Send connection was interrupted"} — delivery status is unknown. Check the conversation; edit the draft before sending again.`)):m(`Send failed: ${String(Ye)} — the message was not delivered.`)}finally{window.clearTimeout(kt),J.current=!1,l(!1)}},W=!!p&&i===p.draft&&(w?.wireId??void 0)===p.reply?.wireId;return y.jsxs("div",{className:"detail detail-chat",ref:fe,children:[y.jsx("div",{className:"detail-head",ref:j,children:y.jsxs("div",{className:"conv-peer",children:[y.jsx("button",{className:"icon-btn detail-back","aria-label":"Back to conversations",onClick:e.onBack,children:y.jsx(ke,{name:"back"})}),y.jsxs("div",{className:"conv-peer-status",children:[y.jsx("span",{className:"conv-peer-name",children:t.name}),e.syncing&&y.jsxs("div",{className:"conv-sync",role:"status","aria-live":"polite",children:[y.jsx("span",{className:"conv-sync-dot","aria-hidden":!0}),e.syncing==="connecting"?"Connecting…":"Updating…"]}),!e.syncing&&y.jsxs("span",{className:"conv-contact-status",children:[y.jsx(ke,{name:"lock",size:11}),"Encrypted connection"]})]}),y.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:y.jsx("span",{className:"conv-contact-initials","aria-hidden":!0,children:t.initials})})]})}),y.jsx("div",{className:"messages",ref:N,tabIndex:-1,"aria-label":"Conversation timeline",onScroll:V=>{const q=V.currentTarget,re=q.scrollHeight-q.clientHeight-q.scrollTop;if(ot.current!==null){const de=qe.current;if(de===null||q.scrollTop>=de-1){qe.current=q.scrollTop,re<=4&&(ot.current=null,qe.current=null);return}ot.current=null,qe.current=null}_e.current=re<=48,G()},onPointerDown:()=>{ot.current=null,qe.current=null},onTouchStart:()=>{ot.current=null,qe.current=null},onWheel:()=>{ot.current=null,qe.current=null},onDragOver:V=>{e.onSendFile&&V.preventDefault()},onDrop:V=>{if(!e.onSendFile)return;V.preventDefault();const q=V.dataTransfer.files?.[0];q&&se(q)},children:y.jsxs("div",{className:"messages-inner",children:[y.jsxs("div",{className:"e2e-note",children:[y.jsx(ke,{name:"lock"}),"End-to-end encrypted · the broker only sees ciphertext"]}),(e.hiddenEarlier??0)>0&&e.onLoadEarlier&&y.jsxs("button",{className:"btn sm chat-load-earlier",onClick:()=>{_e.current=!1;const V=N.current;gt.current=V?{height:V.scrollHeight,top:V.scrollTop}:null,e.onLoadEarlier?.()},children:["Load earlier messages (",e.hiddenEarlier," remaining)"]}),y.jsx(Nz,{messages:yt,optimisticSend:c,sentKeys:at.current,hiddenEarlier:e.hiddenEarlier??0,unreadWireId:e.unreadOpen?.wireId,roomLines:ze,contactCid:t.id,contactName:t.name,onStartReply:S,onPreview:$,onFetchFile:e.onFetchFile}),y.jsx("div",{className:"thread-end","aria-hidden":!0})]})},t.id),me&&y.jsxs("button",{type:"button",className:"jump-latest btn sm","aria-label":he?`Jump to latest, ${he} new messages`:"Jump to latest",onClick:V=>{const q=V.currentTarget===document.activeElement;Te(0),En(!0),q&&requestAnimationFrame(()=>N.current?.focus({preventScroll:!0}))},children:[y.jsx("span",{children:"Jump to latest"}),!!he&&y.jsx("span",{className:"jump-latest-count","aria-live":"polite",children:he})]}),h&&y.jsxs("div",{className:"banner error",role:"alert",children:[h,h.startsWith("Send failed:")&&y.jsx("span",{className:"banner-actions",children:y.jsx("button",{className:"linkbtn",onClick:()=>void lt(),children:"retry"})})]}),y.jsxs("div",{className:"composer-wrap",ref:F,children:[Y&&_&&e.onSendCommand&&y.jsx(vz,{catalog:_,recipientName:t.name,busy:ce,onRefresh:()=>void Gt(!0,!0),onClose:Fn,onSend:async(V,q,re,de)=>{if(!t||t.id!==_.recipient_cid)throw new Error("Recipient changed; refresh commands");return e.onSendCommand(t.id,V.name,q,re,de)}},`${_.recipient_cid}:${_.fingerprint}`),w&&y.jsxs("div",{className:"reply-bar",children:[y.jsx("div",{className:"reply-bar-line"}),y.jsxs("div",{className:"reply-bar-body",children:[y.jsxs("div",{className:"reply-bar-author",children:["Replying to ",w.author]}),y.jsx("div",{className:"reply-bar-text",children:w.text})]}),y.jsx("button",{className:"icon-btn",title:"Cancel reply",onClick:()=>S(null),children:y.jsx(ke,{name:"close",size:16})})]}),C&&y.jsx(D1,{att:C,sending:T,onSend:Pe,onDiscard:()=>E(null)}),O&&y.jsx("div",{className:"attachment-processing",role:"status",children:"Optimizing photo for secure delivery…"}),y.jsxs("div",{className:"composer"+(R?" recording":""),children:[e.onLoadCommands&&_&&_.commands.length>0&&y.jsx("button",{ref:pe,type:"button",className:"icon-btn composer-tool command-trigger",title:"Recipient commands","aria-label":"Recipient commands","aria-expanded":Y,disabled:ce,onClick:()=>Y?Fn():B(!0),children:y.jsx(ke,{name:"menu",size:19})}),e.onSendFile&&y.jsxs(y.Fragment,{children:[y.jsx("input",{ref:xe,type:"file",style:{display:"none"},onChange:V=>{const q=V.target.files?.[0];q&&se(q),V.target.value=""}}),y.jsx("button",{className:"icon-btn composer-tool",title:"Attach a file or photo",disabled:T||O||R,onClick:()=>xe.current?.click(),children:y.jsx(ke,{name:"paperclip",size:18})})]}),y.jsx("textarea",{ref:Q,className:"field",rows:1,placeholder:(w?"Reply to "+w.author:"Message "+t.name)+"…",value:i,"aria-busy":a,onChange:V=>s(V.target.value),onKeyDown:V=>{V.key==="Enter"?!(window.matchMedia("(pointer: coarse)").matches||window.innerWidth<=860)&&!V.shiftKey&&(V.preventDefault(),lt()):V.key==="Escape"&&S(null)}}),e.onSendFile&&!i.trim()&&!C&&!O&&!T?y.jsx(_1,{disabled:T||O||!!C,onReady:V=>{A(!1),E(V)},onError:V=>{A(!1),m(V)},onActiveChange:A},t.id):y.jsxs("button",{className:"btn primary","aria-label":"Send",onPointerDown:V=>{V.button===0&&document.activeElement===Q.current&&V.preventDefault()},onClick:()=>void lt(),disabled:a||W||!i.trim(),title:W?"Delivery status unknown — edit before sending again":void 0,children:[y.jsx(ke,{name:"send",size:16}),y.jsx("span",{className:"btn-label",children:"Send"})]})]})]}),K&&(Ms(K.filename,K.mime)?y.jsx(nS,{rec:K,onClose:()=>$(null)}):y.jsx(tS,{rec:K,onClose:()=>$(null),onSendText:e.onSend,onSendFile:e.onSendFile}))]})}const hS=3;function Iz(e,t,n=hS){return[t,...e.filter(i=>i.cid!==t.cid)].slice(0,n)}function Dz(e,t){return e.filter(n=>n.id!==t)}const _z=6e3,Lz=Iz,Oz=Dz;function Fz(){const[e,t]=k.useState([]),n=k.useRef(0),i=k.useCallback((l,c,f)=>{const h=Date.now(),m={id:`${l}:${h}:${n.current++}`,cid:l,name:c,preview:"",at:h};t(p=>Lz(p,m,hS))},[]),s=k.useCallback(l=>t(c=>Oz(c,l)),[]),a=k.useCallback(l=>t(c=>c.filter(f=>f.cid!==l)),[]);return{toasts:e,push:i,dismiss:s,clear:a}}function zz(e){const{item:t,onOpen:n,onDismiss:i}=e,[s,a]=k.useState(!1),[l,c]=k.useState(!1),f=s||l;return k.useEffect(()=>{if(f)return;const h=setTimeout(()=>i(t.id),_z);return()=>clearTimeout(h)},[t.id,f,i]),y.jsxs("div",{className:"banner msg",role:"status",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onFocus:()=>c(!0),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||c(!1)},children:[y.jsxs("button",{className:"msg-open",title:`Open the conversation with ${t.name}`,onClick:()=>n(t.cid),children:[y.jsx("span",{className:"avatar sm accent","aria-hidden":"true",children:ld(t.name)}),y.jsxs("span",{className:"msg-text",children:[y.jsx("strong",{className:"msg-name",children:t.name}),y.jsx("span",{className:"msg-preview",children:t.preview||"New message"})]})]}),y.jsx("button",{className:"icon-btn msg-close",title:"Dismiss","aria-label":`Dismiss the notification from ${t.name}`,onClick:()=>i(t.id),children:y.jsx(ke,{name:"close",size:15})})]})}function Vz(e){return y.jsx(y.Fragment,{children:e.items.map(t=>y.jsx(zz,{item:t,onOpen:e.onOpen,onDismiss:e.onDismiss},t.id))})}function Bz(e){const t=k.useRef(null),{text:n,size:i=240}=e;return k.useEffect(()=>{if(!t.current||!n)return;const s=t.current;Mh(()=>import("./browser-BtETXeFB.js").then(a=>a.b),[]).then(a=>{a.toCanvas(s,n,{width:i,margin:2,errorCorrectionLevel:"M",color:{dark:"#000000",light:"#ffffff"}})})},[n,i]),y.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"8px 0"},children:y.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 $z(e){const t=k.useRef(null),n=k.useRef(null),i=k.useRef(null),s=k.useRef(0),a=k.useRef(!0),[l,c]=k.useState("requesting"),[f,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"),R=()=>{if(a.current)if(S.readyState>=S.HAVE_ENOUGH_DATA){const A=S.videoWidth||320,T=S.videoHeight||240;C.width=A,C.height=T,E.drawImage(S,0,0,A,T);const P=E.getImageData(0,0,A,T);Mh(()=>import("./jsQR-DcKyKt8x.js").then(O=>O.j),[]).then(O=>{const D=O.default,K=D(P.data,P.width,P.height,{inversionAttempts:"dontInvert"});if(K&&K.data&&a.current){m(),e.onDecode(K.data);return}a.current&&(s.current=requestAnimationFrame(R))})}else s.current=requestAnimationFrame(R)};s.current=requestAnimationFrame(R)},[m,e]);k.useEffect(()=>{if(a.current=!0,!navigator.mediaDevices?.getUserMedia){c("nocamera");return}return navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then(w=>{if(!a.current){w.getTracks().forEach(S=>S.stop());return}c("scanning"),p(w)}).catch(w=>{if(!a.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)))}),()=>{a.current=!1,m()}},[]);const v=()=>{m(),e.onClose()};return y.jsxs("div",{"data-testid":"qr-scanner",style:{display:"flex",flexDirection:"column",gap:12,padding:"12px 0"},children:[(l==="requesting"||l==="scanning")&&y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:l==="requesting"?"Requesting camera…":"Point your camera at the QR code."}),y.jsxs("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",background:"#000",minHeight:200},children:[y.jsx("canvas",{ref:n,"data-testid":"scanner-canvas",style:{display:"none"}}),y.jsx("video",{ref:t,"data-testid":"scanner-video",muted:!0,playsInline:!0,style:{width:"100%",display:"block",borderRadius:8}}),l==="scanning"&&y.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",display:"flex",alignItems:"center",justifyContent:"center"},children:y.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)"}})})]})]}),l==="denied"&&y.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[y.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[y.jsx(ke,{name:"shield",size:16}),y.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"Camera access denied"})]}),y.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."})]}),l==="nocamera"&&y.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[y.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[y.jsx(ke,{name:"close",size:16}),y.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"No camera available"})]}),y.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"No camera was found on this device. Paste the invite text below instead."})]}),l==="error"&&y.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:y.jsxs("p",{style:{margin:0,fontSize:"0.85rem",color:"var(--danger, #e53)"},children:["Camera error: ",f||"unknown error",". Paste the invite text below instead."]})}),y.jsx("button",{className:"btn",style:{justifyContent:"center"},onClick:v,children:l==="scanning"?y.jsxs(y.Fragment,{children:[y.jsx(ke,{name:"close",size:14}),"Cancel scan"]}):y.jsxs(y.Fragment,{children:[y.jsx(ke,{name:"close",size:14}),"Close scanner"]})})]})}function Uz(e){const[t,n]=k.useState("generate"),[i,s]=k.useState("one_time"),[a,l]=k.useState(""),[c,f]=k.useState(null),[h,m]=k.useState("one_time"),[p,v]=k.useState(""),[w,S]=k.useState(""),[C,E]=k.useState(!1),[R,A]=k.useState(null),[T,P]=k.useState(null),[O,D]=k.useState(!1),[K,$]=k.useState(null),_=k.useRef(!1),M=async()=>{if(!_.current){_.current=!0,E(!0),P(null),A(null);try{m(i),f(await e.onCreate(i,i==="one_time"&&a.trim()||void 0))}catch(B){P(B instanceof Error?B.message:String(B))}finally{_.current=!1,E(!1)}}},Y=y.jsx(rS,{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 y.jsx(Ls,{title:t==="generate"?"Invite a contact":"Accept an invite",onClose:()=>{_.current||e.onClose()},tabs:Y,children:y.jsxs("div",{id:"invite-panel",role:"tabpanel","aria-labelledby":`invite-tab-${t}`,children:[t==="generate"&&!c&&y.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:13},children:[y.jsxs("p",{className:"muted","data-testid":"invite-identity",style:{margin:0,fontSize:"0.85rem"},children:["Creating as ",y.jsx("strong",{children:e.identity.name})," · ",y.jsxs("span",{className:"mono",children:["@",_0(e.identity.cid)]})]}),y.jsxs("div",{role:"radiogroup","aria-label":"Invite kind",style:{display:"flex",flexDirection:"column",gap:7},children:[y.jsxs("label",{children:[y.jsx("input",{type:"radio",name:"invite-kind",checked:i==="one_time",onChange:()=>s("one_time")})," One person (one time)"]}),y.jsxs("label",{children:[y.jsx("input",{type:"radio",name:"invite-kind",checked:i==="public",onChange:()=>s("public")})," Reusable public invite"]})]}),i==="one_time"?y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.9rem"},children:"Optionally name the person or agent this invite is for."}),y.jsx("input",{className:"field",value:a,onChange:B=>l(B.target.value),placeholder:"Their name (optional), e.g. Bob",maxLength:64})]}):y.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."}),y.jsx("button",{className:"btn primary",style:{justifyContent:"center"},disabled:C,onClick:()=>void M(),children:C?"Generating…":i==="public"?"Create public invite":"Generate invite"}),i==="public"&&y.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[y.jsx("h4",{style:{margin:0,fontSize:"0.9rem"},children:"Active reusable invites"}),e.invites.filter(B=>B.mode==="public").length===0&&y.jsx("p",{className:"muted",style:{margin:0},children:"None right now."}),e.invites.filter(B=>B.mode==="public").map(B=>y.jsxs("div",{"data-testid":"public-invite-row",style:{padding:"8px 10px",background:"var(--inset)",borderRadius:7},children:[y.jsx("span",{className:"mono",children:B.invite_id}),y.jsxs("p",{className:"muted",children:["Created ",B.created?qj(B.created):"unknown"," · Active until revoked · No expiry"]}),K===B.invite_id?y.jsxs("span",{children:[y.jsx("button",{className:"btn sm danger",onClick:()=>void e.onRevoke(B.invite_id).then(()=>($(null),e.onRefresh())).catch(ce=>P(String(ce))),children:"Confirm revoke"})," ",y.jsx("button",{className:"btn sm",onClick:()=>$(null),children:"Keep it"})]}):y.jsx("button",{className:"btn sm",onClick:()=>$(B.invite_id),children:"Revoke"})]},B.invite_id))]}),R&&y.jsx("p",{className:"muted",children:R}),T&&y.jsx("p",{className:"onb-error",children:T})]}),t==="generate"&&c&&y.jsxs(y.Fragment,{children:[y.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 ${a.trim()||"your contact"}. It can be redeemed once.`}),y.jsx("textarea",{className:"field mono","data-testid":"invite-result-text",readOnly:!0,rows:5,value:c,onFocus:B=>B.currentTarget.select()}),h==="one_time"&&y.jsx(Bz,{text:c}),y.jsxs("button",{className:"btn primary",onClick:()=>void navigator.clipboard.writeText(c).then(()=>A("Copied to clipboard.")),children:[y.jsx(ke,{name:"copy",size:15}),"Copy invite"]}),h==="public"&&y.jsx("button",{className:"btn","data-testid":"done-hide-invite",onClick:()=>{f(null),l(""),e.onRefresh()},children:"Done — hide invite"}),R&&y.jsx("p",{className:"muted",children:R})]}),t==="accept"&&y.jsxs("form",{style:{display:"flex",flexDirection:"column",gap:13},onSubmit:B=>{B.preventDefault(),!(!p.trim()||C)&&(E(!0),P(null),e.onAccept(p.trim(),w.trim()||void 0).then(()=>{A("Invite accepted — the contact will appear once the sender verifies your identity."),v(""),S("")}).catch(ce=>P(String(ce))).finally(()=>E(!1)))},children:[y.jsx("p",{className:"muted",children:"Paste the invite you received, or scan a QR code."}),O?y.jsx($z,{onDecode:B=>{v(B),D(!1)},onClose:()=>D(!1)}):y.jsxs("button",{type:"button",className:"btn",onClick:()=>D(!0),children:[y.jsx(ke,{name:"monitor",size:15}),"Scan QR code"]}),y.jsx("textarea",{className:"field mono","aria-label":"Invite",rows:5,value:p,onChange:B=>v(B.target.value),placeholder:"Paste invite text…"}),y.jsx("input",{className:"field",value:w,onChange:B=>S(B.target.value),placeholder:"Rename them (optional)",maxLength:64}),y.jsx("button",{className:"btn primary",type:"submit",disabled:C||!p.trim(),children:C?"Connecting…":"Add contact"}),R&&y.jsx("p",{className:"muted",children:R}),T&&y.jsx("p",{className:"onb-error",children:T})]})]})})}function Wz(e){const[t,n]=k.useState(e.identity.bio??""),[i,s]=k.useState(!1),[a,l]=k.useState(null),[c,f]=k.useState(e.push.preview),h=LA(),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 y.jsxs(Ls,{title:"Settings",onClose:e.onClose,wide:!0,children:[y.jsxs("div",{children:[y.jsx("span",{className:"lbl",children:"Display name"}),y.jsx("input",{className:"field",readOnly:!0,value:e.identity.name})]}),y.jsxs("div",{children:[y.jsx("span",{className:"lbl",children:"Your address"}),y.jsx("input",{className:"field mono",readOnly:!0,value:e.identity.cid,onFocus:p=>p.currentTarget.select()}),y.jsx("p",{className:"muted",children:"Your public address on ours. Share an invite to connect more easily."})]}),y.jsxs("div",{children:[y.jsx("span",{className:"lbl",children:"Public bio"}),y.jsx("textarea",{className:"field",rows:3,value:t,onChange:p=>{n(p.target.value),s(!1),l(null)}}),y.jsx("button",{className:"btn sm",onClick:()=>{l(null),e.onSaveBio(t).then(()=>s(!0)).catch(p=>l(String(p)))},children:i?"Saved":"Save bio"}),a&&y.jsx("p",{className:"onb-error",children:a})]}),y.jsxs("label",{style:{display:"flex",gap:9},children:[y.jsx("input",{type:"checkbox",checked:e.dark,onChange:e.onToggleDark})," Dark mode"]}),y.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[y.jsx("h4",{children:"Notifications"}),y.jsx("p",{className:e.push.status==="needs-permission"||e.push.status==="error"?"onb-error":"muted",children:m}),h&&h!==m&&y.jsx("p",{className:"muted","data-testid":"push-platform-guidance",children:h}),y.jsxs("fieldset",{style:{border:0,padding:0,margin:"12px 0"},children:[y.jsx("legend",{className:"lbl",children:"Lock-screen preview"}),y.jsxs("label",{style:{display:"block",marginTop:7},children:[y.jsx("input",{type:"radio",name:"push-preview",checked:c==="full",onChange:()=>f("full")})," Full — sender and message text or filename"]}),y.jsxs("label",{style:{display:"block",marginTop:7},children:[y.jsx("input",{type:"radio",name:"push-preview",checked:c==="private",onChange:()=>f("private")})," Private — generic content only"]})]}),y.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."}),y.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.push.status==="on"?y.jsxs(y.Fragment,{children:[y.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("disable",c),children:"Disable notifications"}),y.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("repair",c),children:"Repair"}),c!==e.push.preview&&y.jsx("button",{className:"btn primary",disabled:e.busy,onClick:()=>void e.onPushAction("enable",c),children:"Save preview"})]}):y.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"})})]}),y.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[y.jsx("h4",{children:"App status"}),y.jsx("p",{className:"muted",children:e.offline?"Offline — reconnecting. Message and identity data are never cached.":"Online."}),e.onInstall&&y.jsx("button",{className:"btn",onClick:e.onInstall,children:"Install app"}),e.updateAvailable&&y.jsx("button",{className:"btn primary",onClick:e.onReloadUpdate,children:"Reload to update"})]}),y.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[y.jsx("h4",{children:"Build"}),y.jsx("input",{className:"field mono",readOnly:!0,value:e.build?`${e.build.version} · ${e.build.sha}`:"Loading…"})]})]})}function Hz(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 qz="f0fb7b3c92e6e0d6c74da2b1a83a54eb71bf7925",Kz=15*6e4,Xz=6e4,Yz=Hz;async function Gz(){try{const e=await fetch("/version.json",{cache:"no-store"});return e.ok?await e.json():null}catch{return null}}function Qz(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 f=await Gz(),h=Yz(qz,f,t,Date.now(),Xz);h==="newer-available"?(e.onUpdateAvailable(),navigator.serviceWorker?.getRegistration().then(m=>m?.update())):h==="stuck"&&!i&&(i=!0,e.onStuck(f.sha))},a=setTimeout(()=>void s(),5e3),l=setInterval(()=>void s(),Kz),c=()=>{document.visibilityState==="visible"&&s()};return document.addEventListener("visibilitychange",c),()=>{clearTimeout(a),clearInterval(l),document.removeEventListener("visibilitychange",c),navigator.serviceWorker?.removeEventListener("controllerchange",n)}}async function Jz(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 Zz(){const e=new URL(location.href);e.searchParams.has("v")&&(e.searchParams.delete("v"),history.replaceState(null,"",e.pathname+e.search+e.hash))}const Ox=[0,100,400,1e3,3e3,6e3],Fx=e=>new Promise(t=>setTimeout(t,e)),zx={delivered:1,read:2},Vx="ours-dark-v3",Bx="#chat-message-",$x=jl,e4=e=>e instanceof Error&&e.message?e.message:"The request could not be completed.";function pS(e,t){const n=new Map,i=[];for(const s of e?.messages??[]){const a={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,peerCid:s.peer_cid,receipt:s.receipt??void 0,receiptless:s.dir==="out"&&!s.wire_id,messageKind:s.message_kind,typed:s.typed};s.wire_id?n.set(s.wire_id,a):i.push(a)}for(const s of t){const a=n.get(s.wire_id);n.set(s.wire_id,{dir:s.dir,text:"",date:s.date,read:a?.read??s.dir==="out",wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:a?.replyTo??null,kind:"file",filename:s.filename,mime:s.mime,receipt:a?.receipt})}return[...i,...n.values()].sort((s,a)=>{const l=$x(s.date)-$x(a.date);return l===0?s.wireId.localeCompare(a.wireId):l})}function t4(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 n4(e,t){return[...e.contacts.contacts.map(i=>{const s=e.contacts.roots?.[i.container_id],a=ar(e,i.container_id),c=pS(a,t[i.container_id]??[]).at(-1),f=Ml(i);return{id:i.container_id,name:f,announcedName:i.name,initials:ld(f),when:c?Hj(c.date):"",activityAt:c?.date??"",last:c?.kind==="file"?eN(c.filename,c.mime):a?.preview??c?.text??"",unread:a?.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=Ml(i);return{id:`pending:${i.container_id}`,name:s,announcedName:i.name,initials:ld(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 r4(){return y.jsx(i4,{})}function i4(){const e=k.useRef(jA(of(window.location.pathname))).current,[t,n]=k.useReducer(av,e),[i,s]=k.useState(null),a=k.useRef(0),l=k.useRef(null),c=k.useRef(t),f=k.useRef(new TA),h=k.useRef(null),m=k.useRef(new Map),p=k.useRef(new Map),[v,w]=k.useState({}),S=k.useRef(v),[C,E]=k.useState(null),R=k.useRef(new Set),[A,T]=k.useState(null),P=k.useRef(A),O=k.useRef(!1),[D,K]=k.useState([]),[$,_]=k.useState(null),[M,Y]=k.useState(()=>localStorage.getItem(Vx)!=="0"),[B,ce]=k.useState(null),[Z,ee]=k.useState({supported:!1,offline:!navigator.onLine,updateAvailable:!1,registration:null}),[pe,xe]=k.useState({status:"unsupported",preview:"full"}),[Q,fe]=k.useState(!1),j=k.useRef(!1),[F,J]=k.useState(()=>window.location.hash.startsWith(Bx)),{toasts:N,push:te,dismiss:me,clear:ye}=Fz(),he=k.useCallback(W=>{c.current=av(c.current,W),n(W)},[]),Te=k.useCallback(W=>{O.current=W},[]);k.useEffect(()=>{c.current=t},[t]),P.current=A,S.current=v,k.useMemo(()=>(vv(Object.values(v).flat()),null),[v]),k.useEffect(()=>(document.documentElement.classList.toggle("theme-dark",M),()=>document.documentElement.classList.remove("theme-dark")),[M]);const ge=k.useCallback(W=>he({type:"error",message:e4(W)}),[he]),_e=k.useCallback(()=>{const W=c.current;return{visibility:document.visibilityState,appRoute:W.route.name==="chats"?"chats":"other",selectedContactCid:Ir(W),desktopLayout:h.current?.matches??window.innerWidth>=861,mobileDetailOpen:W.mobileDetailOpen,conversationCoveringDialogOpen:P.current!==null}},[]),He=k.useCallback(async(W,V=!0)=>{try{const q=await Xe.conversation(W);return he({type:"page",contactCid:W,page:q}),q}catch(q){return V&&ge(q),null}},[he,ge]),tt=k.useCallback(async(W,V=!0)=>{try{const q=await Xe.files(W);return vv(q.files),w(re=>({...re,[W]:q.files})),q.files}catch(q){return V&&ge(q),null}},[ge]);k.useEffect(()=>Qz({onUpdateAvailable:()=>ee(W=>({...W,updateAvailable:!0})),onStuck:W=>{Jz(W)}}),[]);const gt=k.useCallback(async()=>{const W=await Xe.contacts();return he({type:"contacts",contacts:{...W,pending:W.pending??[]}}),W},[he]),at=k.useCallback(async()=>{try{const[W,V,q]=await Promise.all([Xe.identity(),Xe.contacts(),Xe.buildInfo()]),re={...V,pending:V.pending??[]};return c.current.identity&&c.current.identity.cid!==W.cid&&(Qj(),S.current={},w({})),he({type:"snapshot",identity:W,contacts:re}),_(q),await Promise.all(re.contacts.flatMap(de=>[He(de.container_id,!1),tt(de.container_id,!1)])),Ir(c.current)}catch(W){return ge(W),null}},[he,tt,He,ge]),_t=k.useCallback(async W=>{await f.current.request(W,async()=>{EA(W,_e())&&(await Xe.markRead(W),await Promise.all([He(W),gt()]))}).catch(ge)},[_e,gt,He,ge]),ot=k.useCallback(async W=>{const V=++a.current;l.current?.abort();const q=new AbortController;l.current=q,s(null),ye(W),tt(W,!1);let re;try{re=await Xe.conversation(W,void 0,q.signal)}catch(Le){q.signal.aborted||ge(Le);return}if(q.signal.aborted||V!==a.current)return;he({type:"page",contactCid:W,page:re});const de=re.unread;let le=[...re.messages],Ne=re.nextBefore;const ut=new Set,kt=new Set(le.map(Le=>Le.wire_id).filter(Boolean)),$e=()=>le.filter(Le=>Le.dir==="in"&&!Le.read);for(;$e().length<de&&Ne&&!ut.has(Ne);){ut.add(Ne);let Le;try{Le=await Xe.conversation(W,Ne,q.signal)}catch{break}if(q.signal.aborted||V!==a.current)return;const $t=Le.messages.filter(fr=>!fr.wire_id||!kt.has(fr.wire_id));if(!$t.length&&Le.nextBefore===Ne)break;for(const fr of $t)fr.wire_id&&kt.add(fr.wire_id);le=[...$t,...le],he({type:"older_page",contactCid:W,page:Le,newer:re.messages}),Ne=Le.nextBefore}const Ye=$e()[0];Ye?.wire_id&&V===a.current&&!q.signal.aborted&&s({contactCid:W,wireId:Ye.wire_id,count:de}),await _t(W)},[ye,he,_t,tt,ge]),qe=k.useCallback(async(W,V,q="page")=>{const re=`page:${W}:${q}`,de=(m.current.get(re)??0)+1;m.current.set(re,de);for(const le of Ox){if(le&&await Fx(le),m.current.get(re)!==de)return;const Ne=await He(W,!1);if(Ne&&V(Ne))return}},[He]),At=k.useCallback(async(W,V)=>{const q=`file:${W}`,re=(m.current.get(q)??0)+1;m.current.set(q,re);for(const de of Ox)if(de&&await Fx(de),m.current.get(q)!==re||(await tt(W,!1))?.some(Ne=>Ne.wire_id===V))return},[tt]),hn=k.useRef(!1);k.useEffect(()=>{if(!F||!t.loaded)return;const W=decodeURIComponent(window.location.hash.slice(Bx.length)),V=Ir(c.current);if(!W||!V){J(!1);return}if(ar(c.current,V)?.messages.some(q=>q.wire_id===W)){J(!1);return}hn.current||(hn.current=!0,qe(V,q=>q.messages.some(re=>re.wire_id===W),`anchor:${W}`).catch(()=>{}).finally(()=>J(!1)))},[F,qe,t.loaded,t.pages]),k.useMemo(()=>(Gj({url:W=>Object.values(S.current).flat().find(q=>q.wire_id===W)?.available?Xe.mediaUrl(W):null,bytes:async W=>{if(!Object.values(S.current).flat().find(re=>re.wire_id===W)?.available)return null;const q=await fetch(Xe.mediaUrl(W),{cache:"no-store",credentials:"same-origin"});if(!q.ok)throw new Error(`Media request failed (HTTP ${q.status})`);return new Uint8Array(await q.arrayBuffer())},fetch:async W=>{const V=Object.values(S.current).flat().find(q=>q.wire_id===W);if(!V)throw new Error("Media record is unavailable");await Xe.fetchFiles([W]),await tt(V.contact_id)}}),null),[tt]),k.useEffect(()=>{let W;IA(q=>{ee(q),cv(q.registration).then(xe).catch(()=>xe(re=>({...re,status:"error"})))},{shouldDeferReload:()=>O.current||P.current!==null}).then(q=>{W=q}).catch(ge);const V=q=>{q.preventDefault(),ce(q)};return window.addEventListener("beforeinstallprompt",V),()=>{W?.(),window.removeEventListener("beforeinstallprompt",V)}},[ge]),k.useEffect(()=>BA(),[]),k.useEffect(()=>{if(!(!Z.registration||pe.status!=="on"))return CA({registration:Z.registration,identity:Xe.identity,onEvent:P0})},[pe.status,pe.bindingId,Z.registration]),k.useEffect(()=>{const W=()=>xe(V=>({...V,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,"",Nr()),h.current=window.matchMedia("(min-width: 861px)");const W=()=>{const le=of(window.location.pathname);l.current?.abort(),a.current+=1,s(null),he({type:"route",route:le}),j.current&&le.name==="chats"&&le.contactCid&&(j.current=!1,requestAnimationFrame(()=>document.querySelector("[data-contact-trigger]")?.focus({preventScroll:!0}))),le.name==="chats"&&le.contactCid&&ot(le.contactCid)},V=()=>{if(document.visibilityState!=="visible")return;const le=Ir(c.current);le&&_t(le),N0(),Z.registration&&cv(Z.registration).then(xe).catch(()=>xe(Ne=>({...Ne,status:"error"})))};window.addEventListener("popstate",W),document.addEventListener("visibilitychange",V);const q=le=>{const Ne=le.type==="sync_required"?`${le.type}:${le.reason}`:le.type==="receipt_received"?`${le.type}:${le.contact_id}:${le.kind}:${le.wire_ids.join(",")}`:`${le.type}:${le.contact_id}:${le.wire_id}`,ut=Date.now(),kt=p.current.get(Ne)??0;p.current.set(Ne,ut);for(const[$e,Ye]of p.current)ut-Ye>6e4&&p.current.delete($e);ut-kt<6e4||(async()=>{if(le.type==="sync_required"){await at();return}if(gt().catch(ge),le.type==="file_received"){await At(le.contact_id,le.wire_id);const $e=c.current.contacts.contacts.find(Ye=>Ye.container_id===le.contact_id);Ir(c.current)!==le.contact_id&&$e&&te(le.contact_id,Ml($e),"New file");return}if(le.type==="message_received"){const $e=c.current.contacts.contacts.find(Ye=>Ye.container_id===le.contact_id);await qe(le.contact_id,Ye=>Ye.messages.some(Le=>Le.wire_id===le.wire_id),`message:${le.wire_id}`),Ir(c.current)===le.contact_id?await _t(le.contact_id):$e&&te(le.contact_id,Ml($e),"New message");return}he({type:"receipt",contactCid:le.contact_id,kind:le.kind,wireIds:le.wire_ids}),await qe(le.contact_id,$e=>le.wire_ids.every(Ye=>{const Le=$e.messages.find($t=>$t.wire_id===Ye);return!!Le?.receipt&&zx[Le.receipt]>=zx[le.kind]}),`receipt:${le.wire_ids.join(",")}`)})().catch(ge)},re=wA(q),de=kA(q,le=>he({type:"connection",connection:le}));return at().then(le=>{le&&ot(le)}),()=>{de(),re(),window.removeEventListener("popstate",W),document.removeEventListener("visibilitychange",V)}},[qe,At,he,_t,ot,te,gt,at,ge,Z.registration]);const jt=(W,V,q)=>{window.history.pushState({oursMessenger:!0},"",V),he({type:"route",route:W,mobileDetailOpen:q})},Gt=async W=>{jt({name:"chats",contactCid:W},Nr(W),!0),await ot(W)},Fn=async W=>{const V=ar(c.current,W);if(!(!V?.nextBefore||R.current.has(W))){R.current.add(W),E(W);try{const q=await Xe.conversation(W,V.nextBefore);he({type:"older_page",contactCid:W,page:q,newer:V.messages})}catch(q){ge(q)}finally{R.current.delete(W),E(null)}}},Oe=Ir(t),yt=t.contacts.contacts.find(W=>W.container_id===Oe),En=k.useMemo(()=>n4(t,v),[t,v]),G=En.find(W=>W.id===Oe)??null,se=Oe?pS(ar(t,Oe),v[Oe]??[]):[],Pe=t.identity;k.useEffect(()=>{if(!t.loaded)return;const W=of(window.location.pathname),V=W.name==="chats"||W.name==="contact"?W.contactCid:null;!V||t.contacts.contacts.some(q=>q.container_id===V)||(window.history.replaceState({oursMessenger:!0},"",Nr()),i?.contactCid===V&&(l.current?.abort(),a.current+=1,s(null)))},[t.loaded,t.contacts.contacts,i]);const De=t.loaded?Oe&&!ar(t,Oe)||F?"updating":t.connection!=="live"?"connecting":null:"connecting",ze=async(W,V=pe.preview)=>{if(Z.registration){fe(!0),xe(q=>({...q,status:"repairing",preview:V}));try{xe(await(W==="enable"?j0(Z.registration,{preview:V}):W==="repair"?zA(Z.registration,V):VA(Z.registration,pe)))}catch(q){xe(re=>({...re,status:"error"})),ge(q)}finally{fe(!1)}}},lt=()=>{K([]),T("invite"),Xe.invites().then(K).catch(ge)};return t.route.name==="not_found"?y.jsxs("div",{className:"centered-screen",children:[y.jsx("h1",{children:"Page not found"}),y.jsx("button",{className:"btn primary",onClick:()=>jt({name:"chats",contactCid:null},Nr()),children:"Open chats"})]}):Pe?y.jsx("div",{className:M?"theme-dark":"",style:{height:"100%"},children:y.jsxs("div",{className:"app signal-app",children:[y.jsxs("main",{className:"section signal-stage"+(t.mobileDetailOpen?" show-detail":""),children:[y.jsx(Az,{contacts:En,roots:t4(t.contacts),selected:Oe,onSelect:W=>{W.startsWith("pending:")||Gt(W)},onInvite:lt,onSettings:()=>T("settings"),onApprovePending:async W=>{try{return await Xe.respondToIntroduction(W,"approve"),await at(),!0}catch(V){return ge(V),!1}},onRejectPending:async W=>{try{return await Xe.respondToIntroduction(W,"reject"),await at(),!0}catch(V){return ge(V),!1}}}),t.route.name==="contact"&&G?y.jsx(jz,{contact:G,messages:se,onBack:()=>{j.current=!0,RA(window.history.state)==="back"?window.history.back():(window.history.replaceState({oursMessenger:!0},"",Nr(G.id)),he({type:"route",route:{name:"chats",contactCid:G.id},mobileDetailOpen:!0}),requestAnimationFrame(()=>document.querySelector("[data-contact-trigger]")?.focus({preventScroll:!0})),j.current=!1)},onRename:W=>void Xe.renameContact(G.id,W).then(at).catch(ge),onRemove:()=>{confirm(`Remove “${yt?.name??"contact"}”?`)&&Xe.removeContact(G.id).then(()=>(window.history.replaceState({oursMessenger:!0},"",Nr()),he({type:"route",route:{name:"chats",contactCid:null},mobileDetailOpen:!1}),at())).catch(ge)},onOpenMessage:W=>{jt({name:"chats",contactCid:G.id},Nr(G.id),!0);let V=12;const q=()=>{const re=document.getElementById(`chat-message-${encodeURIComponent(W)}`),de=re?.closest(".messages");if((!re||!de||de.clientHeight<=0)&&V-- >0){requestAnimationFrame(q);return}if(!re||!de)return;const le=re.getBoundingClientRect(),Ne=de.getBoundingClientRect(),ut=de.scrollTop+le.top-Ne.top-Math.max(0,(de.clientHeight-le.height)/2),kt=Math.max(0,Math.min(ut,de.scrollHeight-de.clientHeight));de.scrollTo({top:kt,behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"})};requestAnimationFrame(q)},indexOffset:ar(t,G.id)?.hasMore?Math.max(1,(ar(t,G.id)?.total??se.length)-se.length):0,onSendText:async(W,V)=>{const q=await Xe.send(G.id,W,V);return await He(G.id,!1),q.wire_id??void 0},onSendFile:async(W,V)=>{await Xe.sendFile(G.id,new Blob([W.bytes],{type:W.mime}),W.filename,W.mime,V),await Promise.all([tt(G.id),He(G.id,!1)])}}):y.jsx(Mz,{contact:G,messages:se,syncing:De,unreadOpen:i?.contactCid===Oe?i:null,hiddenEarlier:ar(t,Oe??"")?.hasMore?Math.max(1,(ar(t,Oe??"")?.total??se.length)-se.length):0,onLoadEarlier:Oe&&C!==Oe?()=>void Fn(Oe):void 0,onBack:()=>{l.current?.abort(),a.current+=1,s(null),jt({name:"chats",contactCid:null},Nr(),!1)},onOpenContact:()=>{Oe&&jt({name:"contact",contactCid:Oe},PA(Oe),!0)},onDraftChange:Te,onSend:async(W,V,q)=>{if(!Oe)return;const re=Oe,de=await Xe.send(re,W,V,q);return he({type:"sent_message",contactCid:re,message:{dir:"out",text:W,date:new Date().toISOString(),read:!0,wire_id:de.wire_id??"",receipt:null,reply_to:V?{wire_id:V}:null}}),de.wire_id?qe(re,le=>le.messages.some(Ne=>Ne.wire_id===de.wire_id),`send:${de.wire_id}`):gt().catch(ge),de.wire_id??void 0},onLoadCommands:async(W,V)=>Xe.commands(W,V),onSendCommand:async(W,V,q,re,de,le)=>{const Ne=await Xe.sendCommand(W,V,q,re,de,le);return He(W,!1),Ne},onSendFile:async(W,V)=>{Oe&&(await Xe.sendFile(Oe,new Blob([W.bytes],{type:W.mime}),W.filename,W.mime,V),await Promise.all([tt(Oe),He(Oe,!1)]))},onFetchFile:async W=>{await Xe.fetchFiles([W]),Oe&&await tt(Oe)}},Oe??"no-conversation")]}),y.jsxs("div",{className:"app-banners",children:[Z.offline&&y.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:"Offline — reconnecting to the network…"}),t.connection!=="live"&&y.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:t.connection==="retrying"?"Live updates interrupted — reconnecting…":"Connecting to live updates…"}),Z.updateAvailable&&y.jsxs("div",{className:"banner info",children:[y.jsx("span",{role:"status","aria-live":"polite",children:"A new version is available."}),y.jsx("span",{className:"banner-actions",children:y.jsx("button",{className:"linkbtn",onClick:()=>{Z.registration&&lv(Z.registration)},children:"Restart now"})})]}),y.jsx(Vz,{items:N,onDismiss:me,onOpen:W=>void Gt(W)})]}),A==="invite"&&y.jsx(Uz,{identity:Pe,invites:D,onRefresh:async()=>K(await Xe.invites()),onCreate:async(W,V)=>(await Xe.createInvite(W,V)).blob,onAccept:async(W,V)=>{await Xe.addContact(W,V),await at()},onRevoke:async W=>{await Xe.revokeInvite(W)},onClose:()=>{T(null),at()}}),A==="settings"&&y.jsx(Wz,{identity:Pe,push:pe,workerSupported:Z.supported,busy:Q,offline:Z.offline,updateAvailable:Z.updateAvailable,build:$,dark:M,onToggleDark:()=>Y(W=>(localStorage.setItem(Vx,W?"0":"1"),!W)),onSaveBio:async W=>{await Xe.setBio(W),await at()},onPushAction:ze,onInstall:B?()=>void B.prompt().then(()=>ce(null)):void 0,onReloadUpdate:()=>{Z.registration&&lv(Z.registration)},onClose:()=>{P.current=null,T(null),Oe&&_t(Oe)}}),t.error&&y.jsxs("div",{className:"banner error",role:"alert","aria-live":"assertive",children:[t.error,y.jsx("button",{className:"linkbtn",onClick:()=>he({type:"error",message:null}),children:"dismiss"})]})]})}):y.jsx("div",{className:M?"theme-dark":"",style:{height:"100%"},children:y.jsx("div",{className:"centered-screen",children:y.jsx("p",{className:"muted",children:"Loading…"})})})}Zz();const mS=document.getElementById("root");if(!mS)throw new Error("missing #root");vC.createRoot(mS).render(y.jsx(mR,{reducedMotion:"user",children:y.jsx(r4,{})}));export{Mh as _,Vd as g};
|
|
326
|
-
//# sourceMappingURL=index-
|
|
325
|
+
`)}).join("")}function cz({children:e}){const t=k.isValidElement(e)?e:null,n=sS(t?.props.className);return y.jsxs("div",{className:"message-code-block","data-language":n||void 0,children:[n&&y.jsx("div",{className:"message-code-language",children:n}),y.jsx("pre",{children:e})]})}const fz=[eS],dz={a:({node:e,children:t,href:n,...i})=>{const s=oS(n);return s?y.jsx("a",{...i,href:s,target:"_blank",rel:"noopener noreferrer",children:t}):y.jsx("span",{className:"message-link-blocked",children:t})},img:({alt:e})=>y.jsxs("span",{className:"message-image-placeholder",children:["[image: ",e||"remote image blocked","]"]}),pre:cz,code:({node:e,className:t,children:n,...i})=>y.jsx("code",{className:t,"data-language":sS(t),...i,children:n})},Ex=k.memo(function({text:t,className:n="bubble-text message-markdown"}){return t.length>az?y.jsx("div",{className:`${n} message-markdown-plaintext`,"data-render-mode":"plaintext",children:t}):y.jsx("div",{className:n,"data-render-mode":"markdown",children:y.jsx(Zk,{remarkPlugins:fz,components:dz,urlTransform:i=>oS(i)??"",children:uz(t)})})}),hz=new Set(["type","title","description","default","enum","const","minimum","maximum","minLength","maxLength","pattern","properties","required","items","minItems","maxItems","additionalProperties"]),Tx=6,Px=64,Rx=256,Ax=256,jx=12,Nx=2048,Mx=64*1024;function aS(e){if(typeof e!="string")return"pattern must be a string";if(e.length>Rx)return`pattern exceeds ${Rx} characters`;if(!e.startsWith("^")||!e.endsWith("$"))return"pattern must be anchored with ^ and $";let t=!1,n=!1;for(let i=0;i<e.length;i++){const s=e[i];if(s==="\\"){if(++i>=e.length)return"pattern has invalid syntax";if(/\d/.test(e[i])||e[i]==="k")return"pattern backreferences are not supported";continue}if(t){s==="]"&&(t=!1);continue}if(s==="["){t=!0;continue}if("()?*+|".includes(s))return"pattern must use only bounded, non-grouped expressions";if(s==="{"){const a=/^\{(\d+)(?:,(\d+))?\}/.exec(e.slice(i));if(!a)return"pattern has an invalid or unbounded repetition";const l=Number(a[1]),c=Number(a[2]??a[1]);if(l>c||c>Ax)return`pattern repetition must not exceed ${Ax}`;if(l!==c){const f=e.slice(i+a[0].length);if(n||f!==""&&f!=="$")return"a variable pattern repetition is supported only once, at the end";n=!0}i+=a[0].length-1}}if(t)return"pattern has invalid syntax";try{new RegExp(e)}catch{return"pattern has invalid syntax"}return null}function Ld(e,t=0,n={value:0}){if(t>Tx)return`Schema depth exceeds ${Tx}`;if(n.value++,n.value>Px)return`Schema exceeds ${Px} controls`;const i=Object.keys(e).find(a=>!hz.has(a));if(i)return`Unsupported JSON Schema keyword: ${i}`;if(e.title!==void 0&&typeof e.title!="string")return"title must be a string";if(e.description!==void 0&&typeof e.description!="string")return"description must be a string";if(e.enum!==void 0&&(!Array.isArray(e.enum)||e.enum.length===0))return"enum must be a non-empty array";const s=e.type;if(s===void 0&&e.enum===void 0&&!Object.hasOwn(e,"const"))return"An explicit type, enum, or const is required";if(s!==void 0&&!["object","array","string","number","integer","boolean","null"].includes(String(s)))return`Unsupported JSON Schema type: ${String(s)}`;for(const a of["minimum","maximum"])if(e[a]!==void 0&&(typeof e[a]!="number"||!Number.isFinite(e[a])))return`${a} must be a finite number`;for(const a of["minLength","maxLength","minItems","maxItems"])if(e[a]!==void 0&&(typeof e[a]!="number"||!Number.isInteger(e[a])||e[a]<0))return`${a} must be a non-negative integer`;if((e.minimum!==void 0||e.maximum!==void 0)&&s!=="number"&&s!=="integer")return"minimum/maximum require a numeric type";if((e.minLength!==void 0||e.maxLength!==void 0)&&s!=="string")return"minLength/maxLength require string type";if(e.pattern!==void 0){if(s!=="string")return"pattern requires a string type";const a=aS(e.pattern);if(a)return a}if((e.minItems!==void 0||e.maxItems!==void 0)&&s!=="array")return"minItems/maxItems require array type";if(e.additionalProperties!==void 0){if(s!=="object")return"additionalProperties requires an object type";if(e.additionalProperties===!0)return"additionalProperties: true is not supported";if(e.additionalProperties!==!1)return e.additionalProperties&&typeof e.additionalProperties=="object"&&!Array.isArray(e.additionalProperties)?"Schema-valued additionalProperties is not supported":"additionalProperties must be false"}if(s==="object"){const a=e.properties;if(a!==void 0&&(!a||typeof a!="object"||Array.isArray(a)))return"properties must be an object";if(e.required!==void 0&&(!Array.isArray(e.required)||e.required.some(l=>typeof l!="string")))return"required must be an array of property names";for(const l of Object.values(a??{})){if(!l||typeof l!="object"||Array.isArray(l))return"property schema must be an object";const c=Ld(l,t+1,n);if(c)return c}}return s==="array"&&e.items!==void 0?!e.items||typeof e.items!="object"||Array.isArray(e.items)?"items must be one schema object":Ld(e.items,t+1,n):null}function Ol(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((s,a)=>Ol(s,t[a]));const n=Object.keys(e).sort(),i=Object.keys(t).sort();return n.length===i.length&&n.every((s,a)=>s===i[a]&&Ol(e[s],t[s]))}function pz(e,t){let n=0;const i=(a,l)=>{if(l>jx)return`${t} exceeds depth ${jx}`;if(n++,n>Nx)return`${t} exceeds ${Nx} JSON values`;if(a===null||typeof a!="object")return null;for(const c of Array.isArray(a)?a:Object.values(a)){const f=i(c,l+1);if(f)return f}return null},s=i(e,0);return s||(new TextEncoder().encode(JSON.stringify(e)).byteLength>Mx?`${t} exceeds ${Mx} UTF-8 bytes`:null)}function Od(e,t,n){if(Object.hasOwn(e,"const")&&!Ol(e.const,t))return`${n} must use the fixed value`;if(Array.isArray(e.enum)&&!e.enum.some(i=>Ol(i,t)))return`${n} is not an allowed value`;if(e.type==="null")return t===null?null:`${n} must be null`;if(e.type==="boolean")return typeof t=="boolean"?null:`${n} must be boolean`;if(e.type==="string"){if(typeof t!="string")return`${n} must be text`;if(typeof e.minLength=="number"&&t.length<e.minLength)return`${n} is too short`;if(typeof e.maxLength=="number"&&t.length>e.maxLength)return`${n} is too long`;if(e.pattern!==void 0){const i=aS(e.pattern);if(i)return`${n} cannot be validated safely: ${i}`;if(!new RegExp(e.pattern).test(t))return`${n} does not match the required format`}return null}if(e.type==="number"||e.type==="integer")return typeof t!="number"||!Number.isFinite(t)?`${n} must be a finite number`:e.type==="integer"&&!Number.isInteger(t)?`${n} must be an integer`:typeof e.minimum=="number"&&t<e.minimum?`${n} is below the minimum`:typeof e.maximum=="number"&&t>e.maximum?`${n} is above the maximum`:null;if(e.type==="array"){if(!Array.isArray(t))return`${n} must be an array`;if(typeof e.minItems=="number"&&t.length<e.minItems)return`${n} has too few items`;if(typeof e.maxItems=="number"&&t.length>e.maxItems)return`${n} has too many items`;if(e.items&&typeof e.items=="object"&&!Array.isArray(e.items))for(let i=0;i<t.length;i++){const s=Od(e.items,t[i],`${n}[${i}]`);if(s)return s}return null}if(e.type==="object"){if(!t||typeof t!="object"||Array.isArray(t))return`${n} must be an object`;const i=e.properties??{};for(const a of Object.keys(t))if(e.additionalProperties===!1&&!Object.hasOwn(i,a))return`${n}.${a||"(empty key)"} is not declared by the schema`;const s=Array.isArray(e.required)?e.required:[];for(const a of s)if(!Object.hasOwn(t,a))return`${n}.${a||"(empty key)"} is required`;for(const[a,l]of Object.entries(i)){if(!Object.hasOwn(t,a))continue;const c=Od(l,t[a],`${n}.${a||"(empty key)"}`);if(c)return c}}return null}function Fl(e,t,n="Arguments"){return pz(t,n)??Od(e,t,n)}function eo(e){if(Object.hasOwn(e,"const"))return e.const;if(e.default!==void 0)return e.default;if(Array.isArray(e.enum)&&e.enum.length)return e.enum[0];if(e.type==="object"){const t=Object.create(null),n=new Set(Array.isArray(e.required)?e.required.filter(i=>typeof i=="string"):[]);for(const[i,s]of Object.entries(e.properties??{})){const a=s;(n.has(i)||a.default!==void 0)&&(t[i]=eo(a))}return t}return e.type==="array"?[]:e.type==="boolean"?!1:e.type==="number"||e.type==="integer"?0:e.type==="null"?null:""}function Ix(e,t){return typeof e.title=="string"&&e.title?e.title:t||"(empty key)"}function Dx(e,t,n){const i=Object.create(null);for(const[s,a]of Object.entries(e))i[s]=a;return i[t]=n,i}function mz(e,t){const n=Object.create(null);for(const[i,s]of Object.entries(e))i!==t&&(n[i]=s);return n}function gz(e){const{schema:t,label:n,path:i,value:s,required:a,description:l,onChange:c,onValidityChange:f}=e,h=k.useId().replace(/[^a-zA-Z0-9_-]/g,""),p=`command-array-${i.replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"root"}-${h}-help`,[v,w]=k.useState(()=>JSON.stringify(s,null,2)),[S,C]=k.useState(null),E=k.useRef(JSON.stringify(s));k.useEffect(()=>{const A=JSON.stringify(s);A!==E.current&&(E.current=A,w(JSON.stringify(s,null,2)),C(null),f(i,null))},[f,i,s]),k.useEffect(()=>()=>f(i,null),[f,i]);const R=A=>{w(A);let T;try{T=JSON.parse(A)}catch{const O=`${n} must contain valid JSON`;C(O),f(i,O);return}if(!Array.isArray(T)){const O=`${n} must be a JSON array`;C(O),f(i,O);return}const P=Fl(t,T,n);C(P),f(i,P),E.current=JSON.stringify(T),c(T)};return y.jsxs("label",{className:"command-field",children:[y.jsxs("span",{children:[n,a?" *":""]}),y.jsx("textarea",{value:v,rows:3,"aria-describedby":p,"aria-invalid":S?"true":void 0,onChange:A=>R(A.target.value)}),y.jsx("small",{id:p,children:l??"JSON array"}),S&&y.jsx("span",{className:"command-field-error",role:"alert",children:S})]})}function yz(e){const{schema:t,label:n,path:i,value:s,required:a,description:l,numeric:c,onChange:f,onValidityChange:h}=e,m=Fl(t,s,n);return k.useEffect(()=>(h(i,m),()=>h(i,null)),[m,h,i]),y.jsxs("label",{className:"command-field",children:[y.jsxs("span",{children:[n,a?" *":""]}),y.jsx("input",{type:c?"number":"text",value:String(s??""),min:typeof t.minimum=="number"?t.minimum:void 0,max:typeof t.maximum=="number"?t.maximum:void 0,minLength:typeof t.minLength=="number"?t.minLength:void 0,maxLength:typeof t.maxLength=="number"?t.maxLength:void 0,step:t.type==="integer"?1:c?"any":void 0,required:a,"aria-invalid":m?"true":void 0,onChange:p=>f(c?Number(p.target.value):p.target.value)}),l&&y.jsx("small",{children:l}),m&&y.jsx("span",{className:"command-field-error",role:"alert",children:m})]})}function lS(e){const{schema:t,name:n,path:i,value:s,required:a,onChange:l,onValidityChange:c}=e,f=Ix(t,n),h=typeof t.description=="string"?t.description:void 0;if(Object.hasOwn(t,"const"))return y.jsxs("div",{className:"command-field",children:[y.jsxs("span",{children:[f,a?" *":""]}),y.jsxs("small",{children:["Fixed value: ",JSON.stringify(t.const)]})]});if(Array.isArray(t.enum))return y.jsxs("label",{className:"command-field",children:[y.jsxs("span",{children:[f,a?" *":""]}),y.jsx("select",{value:JSON.stringify(s),onChange:p=>l(JSON.parse(p.target.value)),children:t.enum.map((p,v)=>y.jsx("option",{value:JSON.stringify(p),children:String(p)},v))}),h&&y.jsx("small",{children:h})]});if(t.type==="object"){const p=s&&typeof s=="object"&&!Array.isArray(s)?s:{},v=new Set(Array.isArray(t.required)?t.required.filter(w=>typeof w=="string"):[]);return y.jsxs("fieldset",{className:"command-object",children:[y.jsx("legend",{children:f}),h&&y.jsx("p",{children:h}),Object.entries(t.properties??{}).map(([w,S])=>{const C=S,E=Object.hasOwn(p,w),R=Ix(C,w),A=`${i}.${w||"(empty key)"}`;return!E&&!v.has(w)?y.jsxs("button",{type:"button",className:"linkbtn command-property-add",onClick:()=>l(Dx(p,w,eo(C))),children:["Add ",R]},w):y.jsxs("div",{className:"command-property",children:[y.jsx(lS,{schema:C,name:w,path:A,value:E?p[w]:eo(C),required:v.has(w),onValidityChange:c,onChange:T=>l(Dx(p,w,T))}),!v.has(w)&&y.jsx("button",{type:"button",className:"linkbtn command-property-remove","aria-label":`Remove ${R}`,onClick:()=>l(mz(p,w)),children:"Remove"})]},w)})]})}if(t.type==="array")return y.jsx(gz,{schema:t,label:f,path:i,value:s,required:a,description:h,onChange:l,onValidityChange:c});if(t.type==="boolean")return y.jsxs("label",{className:"command-check",children:[y.jsx("input",{type:"checkbox",checked:s===!0,onChange:p=>l(p.target.checked)})," ",f]});if(t.type==="null")return y.jsxs("div",{className:"command-field",children:[y.jsx("span",{children:f}),y.jsx("small",{children:"Null value"})]});const m=t.type==="number"||t.type==="integer";return y.jsx(yz,{schema:t,label:f,path:i,value:s,required:a,description:h,numeric:m,onChange:l,onValidityChange:c})}function vz(e){const t=e.catalog.commands[0],[n,i]=k.useState(t?.name??""),s=e.catalog.commands.find(T=>T.name===n)??t,a=k.useMemo(()=>s?Ld(s.input_schema):null,[s]),[l,c]=k.useState(()=>t?eo(t.input_schema):null),[f,h]=k.useState(""),[m,p]=k.useState("idle"),[v,w]=k.useState({}),S=k.useRef(0),C=k.useCallback((T,P)=>{w(O=>{if(P===null){if(!Object.hasOwn(O,T))return O;const D={...O};return delete D[T],D}return O[T]===P?O:{...O,[T]:P}})},[]),E=T=>{const P=e.catalog.commands.find(O=>O.name===T);i(T),c(P?eo(P.input_schema):null),h(""),p("idle"),w({})},R=T=>{if(T.preventDefault(),!s||a||e.busy)return;const O=Object.values(v)[0]??Fl(s.input_schema,l);if(O){h(`Validation denied: ${O}`),p("error");return}const D=++S.current,K=s,$=l;c(eo(K.input_schema)),w({}),h(`Sending ${K.name}…`),p("pending"),e.onSend(K,$,crypto.randomUUID(),e.catalog.fingerprint).then(_=>{S.current===D&&(_.status==="failed"?(h(`${K.name} was refused before delivery.`),p("error")):_.status==="pending"?(h(`${K.name} delivery is pending.`),p("warning")):_.status==="indeterminate"||!_.wire_id?(h(`${K.name} delivery could not be confirmed.`),p("indeterminate")):(h(`${K.name} sent. Its result will appear in the conversation.`),p("success")))}).catch(()=>{S.current===D&&(h(`${K.name} could not be sent. You can try it again.`),p("error"))})},A=s&&!a?Fl(s.input_schema,l):null;return y.jsxs("form",{className:"command-panel","aria-label":"Send a typed command",onSubmit:R,onKeyDown:T=>{T.key==="Escape"&&e.onClose()},children:[y.jsxs("div",{className:"command-panel-head",children:[y.jsxs("div",{className:"command-panel-recipient",children:[y.jsxs("strong",{children:["Commands for ",e.recipientName]}),y.jsxs("span",{className:"mono",title:e.catalog.recipient_cid,children:[e.catalog.recipient_cid.slice(0,12),"…"]})]}),y.jsx("button",{type:"button",className:"linkbtn",onClick:e.onRefresh,children:"Refresh"}),y.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close commands",onClick:e.onClose,children:"×"})]}),e.catalog.commands.length===0?y.jsx("p",{role:"status",children:"This recipient does not advertise commands."}):y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"command-field",children:[y.jsx("span",{children:"Command"}),y.jsx("select",{autoFocus:!0,value:n,onChange:T=>E(T.target.value),children:e.catalog.commands.map(T=>y.jsx("option",{value:T.name,children:T.name},T.name))})]}),s?.description&&y.jsx("p",{children:s.description}),a?y.jsxs("div",{className:"banner error",role:"alert",children:["Cannot render this command safely: ",a]}):s&&y.jsx(lS,{schema:s.input_schema,name:"Arguments",path:"Arguments",value:l,onChange:c,onValidityChange:C}),s&&y.jsx("button",{className:"btn primary",disabled:!!a||e.busy||!!A||Object.keys(v).length>0,children:"Send command"}),y.jsx("div",{className:`command-status ${m}`,"data-state":m,role:"status","aria-live":"polite",children:f})]})]})}const os={type:"spring",stiffness:430,damping:38,mass:.72},_x=10,uS=56,xz=18,wz=650;function kz(e,t){return Math.abs(e)<_x&&Math.abs(t)<_x?"pending":Math.abs(e)>Math.abs(t)&&e>0?"drag":"reject"}function Sz(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 bz(e,t){const n=Sz(t);return n>=0&&(e>=uS||e>=xz&&n>=wz)}const Fd="ours.chats.listMode",hs="recent";function cS(){try{return globalThis.localStorage}catch{return}}function Cz(e=cS()){try{return e?.getItem(Fd)==="identity"?"identity":hs}catch{return hs}}function Ez(e,t=cS()){const n=e==="identity"?"identity":hs;try{return t?.setItem(Fd,n),t?.getItem(Fd)===n?n:hs}catch{return hs}}function Cs(e){return typeof e=="string"?e:""}function zl(e,t){const n=Cs(e),i=Cs(t),s=n.normalize().toLowerCase(),a=i.normalize().toLowerCase();return s<a?-1:s>a?1:n<i?-1:n>i?1:0}function Tz(e,t){const n=jl(Cs(t.activityAt))-jl(Cs(e.activityAt));if(n!==0)return n;const i=zl(e.name,t.name);return i!==0?i:zl(e.id,t.id)}function zd(e){return[...e].sort(Tz)}function Lx(e){return e.contacts.length>0?jl(Cs(e.contacts[0].activityAt)):0}function Pz(e,t){const n=new Map,i=[];for(const a of e){const l=a.root||(t?.[a.id]?a.id:null);if(!l){i.push(a);continue}const c=t?.[l]||{label:l,note:""};let f=n.get(l);f||(f={id:`root:${l}`,rootId:l,label:c.label,note:c.note,contacts:[]},n.set(l,f)),f.contacts.push(a)}const s=[...n.values()].map(a=>({...a,contacts:zd(a.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:zd(i)}),s.sort((a,l)=>{const c=Lx(l)-Lx(a);if(c!==0)return c;const f=zl(a.label,l.label);return f!==0?f:zl(a.id,l.id)})}const Rz=15e3;function jf(e){const{c:t,active:n,grouped:i}=e,[s,a]=k.useState(!1),l=async(h,m)=>{if(!(!h||s)){a(!0);try{const p=await h();requestAnimationFrame(()=>{p?document.getElementById("chat-list-title")?.focus():m.focus()})}finally{a(!1)}}},c=y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"contact-avatar","aria-hidden":!0,children:t.initials}),y.jsxs("span",{className:"contact-copy",children:[y.jsxs("span",{className:"contact-row-topline",children:[y.jsx("span",{className:"contact-name",children:t.name}),t.when&&y.jsx("span",{className:"contact-time",children:t.when})]}),y.jsxs("span",{className:"contact-row-bottomline",children:[y.jsx("span",{className:"contact-last",children:t.last}),t.status==="pending"&&y.jsx("span",{className:"chip",children:"pending approval"}),!!t.unread&&y.jsx("span",{className:"contact-unread",children:t.unread})]})]}),t.status==="pending"&&y.jsxs("span",{className:"pending-actions",role:"group","aria-label":`Decide whether to accept ${t.name}`,children:[y.jsx("button",{type:"button",className:"linkbtn",disabled:s,onClick:h=>void l(e.onApprove,h.currentTarget),children:"Approve"}),y.jsx("button",{type:"button",className:"linkbtn quiet",disabled:s,onClick:h=>void l(e.onReject,h.currentTarget),children:"Reject"})]}),n&&y.jsx(Ji.span,{className:"contact-active-glow",layoutId:"active-contact",transition:os})]}),f="contact-row"+(n?" active":"")+(i?" grouped":"")+(t.status==="pending"?" pending":"");return t.status==="pending"?y.jsx("div",{className:f,children:c}):y.jsx(Ji.button,{type:"button",className:f,onClick:e.onClick,children:c})}function Az(e){const{contacts:t,roots:n,selected:i}=e,[s,a]=k.useState(""),l=k.useRef(null),c=k.useRef(null),[f,h]=k.useState(()=>Cz()),m=_=>_.name.toLowerCase().includes(s.toLowerCase()),p=t.filter(_=>_.status!=="pending"&&m(_)),v=t.filter(_=>_.status==="pending"&&m(_)),w=zd(p),S=Pz(p,n),C=p.length===0&&v.length===0,E=_=>{h(Ez(_))},R=[{id:"recent",label:"Recent"},{id:"identity",label:"By identity"}],A=k.useRef(null),T=k.useRef({id:-1,x0:0,y0:0,mode:"idle"}),P=k.useRef(!1),O=(_,M)=>{const Y=T.current;if(Y.id!==_)return;const B=A.current;if(M&&Y.mode==="drag"&&B){const ce=parseFloat(B.style.getPropertyValue("--mode-drag-x"))||0,Z=Math.max(0,(B.clientWidth-8)/2);E(ce>=Z/2?"identity":"recent"),P.current=!0,window.setTimeout(()=>{P.current=!1},0)}T.current={id:-1,x0:0,y0:0,mode:"idle"},B?.hasPointerCapture?.(_)&&B.releasePointerCapture(_),B?.classList.remove("dragging"),B?.style.removeProperty("--mode-drag-x")},D=_=>{!_.isPrimary||T.current.id!==-1||(T.current={id:_.pointerId,x0:_.clientX,y0:_.clientY,mode:"pending"})},K=_=>{const M=T.current;if(M.id!==_.pointerId||M.mode==="idle")return;const Y=_.clientX-M.x0,B=_.clientY-M.y0;if(M.mode==="pending"){if(Math.abs(Y)<10&&Math.abs(B)<10)return;if(Math.abs(B)>Math.abs(Y)){O(_.pointerId,!1);return}M.mode="drag",_.currentTarget.setPointerCapture?.(_.pointerId),_.currentTarget.classList.add("dragging")}_.preventDefault();const ce=Math.max(0,(_.currentTarget.clientWidth-8)/2),Z=f==="identity"?ce:0;_.currentTarget.style.setProperty("--mode-drag-x",`${Math.min(ce,Math.max(0,Z+Y))}px`)},$=(_,M)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(_.key))return;_.preventDefault();const B=_.key==="Home"?"recent":_.key==="End"||M==="recent"?"identity":"recent";E(B),document.getElementById(`conversation-list-${B}`)?.focus()};return k.useLayoutEffect(()=>{const _=l.current,M=c.current;if(!_||!M)return;const Y=()=>_.style.setProperty("--list-bottom-chrome-height",`${M.getBoundingClientRect().height}px`);Y();const B=new ResizeObserver(Y);return B.observe(M),()=>{B.disconnect(),_.style.removeProperty("--list-bottom-chrome-height")}},[]),y.jsxs("div",{className:"listcol",ref:l,children:[y.jsxs("div",{className:"listcol-head",children:[y.jsxs("div",{className:"listcol-titlebar",children:[y.jsxs("h2",{id:"chat-list-title",className:"listcol-title messenger-lockup",tabIndex:-1,children:[y.jsx("span",{className:"messenger-brand-ours",children:"Ours"}),y.jsx("span",{className:"messenger-brand-product",children:"messenger"})]}),y.jsxs("div",{className:"listcol-actions",children:[y.jsx("button",{className:"btn icon-btn desktop-invite","aria-label":"Invite",title:"Invite",onClick:e.onInvite,children:y.jsx(ke,{name:"invite",size:18})}),y.jsx("button",{className:"icon-btn","aria-label":"Settings",title:"Settings",onClick:e.onSettings,children:y.jsx(ke,{name:"settings",size:18})})]})]}),y.jsx("div",{ref:A,className:"conversation-list-modes",role:"tablist","aria-label":"Conversation list layout","data-mode":f,onPointerDown:D,onPointerMove:K,onPointerUp:_=>O(_.pointerId,!0),onPointerCancel:_=>O(_.pointerId,!1),onLostPointerCapture:_=>O(_.pointerId,!1),children:R.map(_=>y.jsx("button",{id:`conversation-list-${_.id}`,type:"button",role:"tab","aria-selected":f===_.id,"aria-controls":"conversation-list-panel",tabIndex:f===_.id?0:-1,className:f===_.id?"active":"",onClick:M=>{if(P.current){M.preventDefault();return}E(_.id)},onKeyDown:M=>$(M,_.id),children:_.label},_.id))})]}),y.jsxs("div",{id:"conversation-list-panel",className:"listcol-scroll",role:"tabpanel","aria-labelledby":`conversation-list-${f}`,children:[f==="recent"&&w.length>0&&y.jsx("div",{className:"conversation-group",children:w.map(_=>y.jsx(jf,{c:_,active:i===_.id,onClick:()=>e.onSelect(_.id)},_.id))}),f==="identity"&&S.map(_=>y.jsxs("div",{children:[y.jsxs("div",{className:"group-label",title:_.note,children:[_.rootId&&y.jsx(ke,{name:"clusters"}),y.jsx("span",{children:_.label}),_.note&&y.jsxs("span",{className:"gl-note",children:["· ",_.note]})]}),y.jsx("div",{className:"conversation-group",children:_.contacts.map(M=>y.jsx(jf,{c:M,grouped:_.rootId!==null,active:i===M.id,onClick:()=>e.onSelect(M.id)},M.id))})]},_.id)),v.length>0&&y.jsxs("div",{children:[y.jsx("div",{className:"group-label",children:y.jsx("span",{children:"Pending"})}),y.jsx("div",{className:"conversation-group",children:v.map(_=>y.jsx(jf,{c:_,active:!1,onClick:()=>{},onApprove:()=>e.onApprovePending(_.id.slice(8)),onReject:()=>e.onRejectPending(_.id.slice(8))},_.id))})]}),C&&y.jsx("p",{className:"muted",style:{padding:"14px 10px",fontSize:"0.85rem"},children:"No contacts yet — share an invite to start."})]}),y.jsxs("div",{className:"list-bottom-chrome",ref:c,children:[y.jsxs("div",{className:"search adaptive-search",role:"search",children:[y.jsx("span",{className:"adaptive-search-icon","aria-hidden":!0,children:y.jsx(ke,{name:"search"})}),y.jsx("input",{className:"field",placeholder:"Search people, agents, apps…",value:s,onChange:_=>a(_.target.value),onKeyDown:_=>{_.key==="Escape"&&(_.preventDefault(),a(""))}})]}),y.jsx("button",{type:"button",className:"icon-btn list-bottom-invite","aria-label":"Invite",title:"Invite",onClick:e.onInvite,children:y.jsx(ke,{name:"invite",size:20})})]})]})}function jz(e){const[t,n]=k.useState(!1),[i,s]=k.useState(e.contact.name),[a,l]=k.useState(!1),[c,f]=k.useState(null),h=k.useRef(!1);k.useEffect(()=>{const p=v=>{v.key!=="Escape"||a||c||t||(v.preventDefault(),e.onBack())};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t,c,e.onBack,a]);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 y.jsxs("div",{className:"detail contact-screen",children:[y.jsxs("div",{className:"detail-head contact-screen-head",children:[y.jsx("button",{type:"button",className:"icon-btn detail-back contact-back","aria-label":"Back to conversation",onClick:e.onBack,children:y.jsx(ke,{name:"back"})}),y.jsx("strong",{children:"Contact"})]}),y.jsxs("div",{className:"contact-screen-scroll",children:[y.jsxs("section",{className:"contact-hero","aria-labelledby":"contact-screen-name",children:[y.jsx("div",{className:"avatar accent contact-avatar-large","aria-hidden":!0,children:e.contact.initials}),t?y.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))}}):y.jsx("h2",{id:"contact-screen-name",children:e.contact.name}),y.jsxs("p",{children:[y.jsx(ke,{name:"lock",size:13})," End-to-end encrypted connection"]})]}),y.jsxs("section",{className:"contact-action-group","aria-label":"Contact actions",children:[y.jsxs("button",{type:"button",onClick:()=>l(!0),children:[y.jsxs("span",{children:[y.jsx(ke,{name:"paperclip"}),"Shared photos, files, and links"]}),y.jsx(ke,{name:"chevron"})]}),y.jsxs("button",{type:"button",onClick:()=>{h.current=!1,s(e.contact.name),n(!0)},children:[y.jsxs("span",{children:[y.jsx(ke,{name:"edit"}),"Rename contact"]}),y.jsx(ke,{name:"chevron"})]})]}),y.jsxs("section",{className:"contact-identity","aria-labelledby":"contact-identity-title",children:[y.jsx("h3",{id:"contact-identity-title",children:"Verified identity"}),e.contact.roleId&&y.jsxs("p",{children:["Role ",y.jsx("strong",{children:e.contact.roleId})," of ",y.jsx("strong",{children:e.contact.rootName})]}),y.jsx("code",{children:e.contact.id}),y.jsxs("button",{type:"button",className:"btn sm",onClick:()=>void navigator.clipboard.writeText(e.contact.id),children:[y.jsx(ke,{name:"copy",size:14}),"Copy identity"]})]}),y.jsxs("button",{type:"button",className:"contact-remove",onClick:e.onRemove,children:[y.jsx(ke,{name:"trash"}),"Remove contact"]})]}),a&&y.jsx(XF,{messages:e.messages,indexOffset:e.indexOffset,onClose:()=>l(!1),onJump:e.onOpenMessage,onPreview:p=>{l(!1),f(p)}}),c&&(Ms(c.filename,c.mime)?y.jsx(nS,{rec:c,onClose:()=>f(null)}):y.jsx(tS,{rec:c,onClose:()=>f(null),onSendText:e.onSendText,onSendFile:e.onSendFile}))]})}const fS=e=>`chat-message-${encodeURIComponent(e)}`,dS=()=>typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function Nf(e){const{dir:t,canReply:n,onReply:i}=e,s=k.useRef(null),a=k.useRef(null),l=k.useRef(null),c=k.useRef(i);c.current=i;const f=t==="in"?1:-1,h=uS,m=84,p=()=>({id:-1,x0:0,y0:0,mode:"idle",armed:!1,distance:0,samples:[]}),v=k.useRef(p()),w=A=>{const T=a.current,P=l.current,O=dS();if(T&&(T.style.transform=A&&!O?`translateX(${A}px)`:""),P){const D=Math.min(1,Math.abs(A)/h);P.style.opacity=String(D),P.style.transform=O?"scale(1)":`scale(${.5+.5*D})`}},S=(A,T)=>{const P=v.current;if(P.id!==A)return;const O=T&&P.mode==="drag"&&bz(P.distance,P.samples);v.current=p(),a.current?.classList.remove("swiping"),l.current?.classList.remove("armed"),w(0);const D=s.current;D?.hasPointerCapture?.(A)&&D.releasePointerCapture(A),O&&c.current()};k.useEffect(()=>{const A=s.current;if(!A)return;const T=P=>S(P.pointerId,!1);return A.addEventListener("lostpointercapture",T),()=>{A.removeEventListener("lostpointercapture",T);const P=v.current.id;P!==-1&&S(P,!1)}},[]);const C=A=>{const T=A.target,P=window.getSelection?.();!n||!A.isPrimary||A.pointerType==="mouse"||A.pointerType==="pen"&&A.button!==0||v.current.id!==-1||P&&!P.isCollapsed||T.closest('a, button, input, textarea, select, [role="button"], audio, video, img, [draggable="true"], .filecard, .filecard-bubble, .image-bubble, .voice-bubble, .ours-message-file, .attachment')||(v.current={id:A.pointerId,x0:A.clientX,y0:A.clientY,mode:"maybe",armed:!1,distance:0,samples:[{x:A.clientX*f,time:A.timeStamp}]},w(0))},E=A=>{const T=v.current;if(T.id!==A.pointerId||T.mode==="idle")return;const P=A.clientX-T.x0,O=A.clientY-T.y0,D=window.getSelection?.();if(D&&!D.isCollapsed){S(A.pointerId,!1);return}if(T.mode==="maybe"){const Y=kz(P*f,O);if(Y==="pending")return;if(Y==="drag")T.mode="drag",A.currentTarget.setPointerCapture?.(A.pointerId),a.current?.classList.add("swiping");else{T.mode="idle";return}}A.preventDefault();const K=A.timeStamp;T.samples.push({x:A.clientX*f,time:K}),T.samples=T.samples.filter(Y=>K-Y.time<=120);let $=P*f;$<0&&($=0),$>h&&($=h+($-h)*.35),$=Math.min($,m),T.distance=$;const _=$*f,M=Math.abs(_)>=h;M!==T.armed&&(T.armed=M,l.current?.classList.toggle("armed",M),M&&navigator.vibrate?.(10)),w(_)},R=A=>{const T=v.current;T.id===A.pointerId&&T.mode==="drag"&&(T.samples.push({x:A.clientX*f,time:A.timeStamp}),T.distance=Math.max(0,(A.clientX-T.x0)*f),T.armed=T.distance>=h),S(A.pointerId,!0)};return y.jsxs("div",{ref:s,className:"msg-row "+(e.rowClass??t),style:n?{touchAction:"pan-y"}:void 0,onPointerDown:C,onPointerMove:E,onPointerUp:R,onPointerCancel:A=>S(A.pointerId,!1),onLostPointerCapture:A=>S(A.pointerId,!1),children:[n&&y.jsx("span",{className:"swipe-cue",ref:l,"aria-hidden":!0,children:y.jsx(ke,{name:"reply",size:16})}),y.jsx("div",{className:"bubble-wrap",ref:a,children:e.children}),e.after]})}const Nz=k.memo(function(t){const{messages:n,optimisticSend:i,sentKeys:s,hiddenEarlier:a,unreadWireId:l,roomLines:c,contactCid:f,contactName:h,onStartReply:m,onPreview:p,onFetchFile:v}=t,w=new Map;for(const P of n)P.wireId&&w.set(P.wireId,P);const S=P=>c.get(P)??null,C=P=>{if(P.dir==="out")return"You";const O=S(P);return O&&O.variant==="chat"?O.author:h},E=P=>{if(P.kind==="file")return P.mime?.startsWith("image/")?"Photo":ro(P.mime??"",P.filename??"")?"Voice message":P.filename||"File";const O=S(P);return O?O.text||$j(O):P.text},R=P=>{if(!P.replyTo)return null;const O=w.get(P.replyTo.wireId);return O?{author:C(O),text:E(O)}:{author:"",text:"Original message"}},A=P=>{P.wireId&&m({wireId:P.wireId,author:C(P),text:E(P)})},T=P=>{if(!P)return null;const O=S(P);return O?O.variant==="system"?"room:system":`room:chat:${O.author}${O.role}`:P.dir};return y.jsx(cR,{initial:!1,children:n.map((P,O)=>{const D=P===i?.message?i.key:P.wireId&&s.get(P.wireId)||P.wireId||`${P.date}-${a+O}`,K=fS(P.wireId||D),$=n[O-1],_=n[O+1],M=S(P),Y=T(P),B=!!$&&T($)===Y&&Y!=="room:system",ce=!!_&&T(_)===Y&&Y!=="room:system",Z=(P.dir==="out"?"out":"in")+(B?" cont-top":"")+(ce?" cont-bot":""),ee=P.wireId?y.jsx("button",{className:"msg-reply",title:"Reply",onClick:()=>A(P),children:y.jsx(ke,{name:"reply",size:15})}):null,pe=P.wireId===l?y.jsx("div",{id:`unread-${K}`,className:"unread-divider",role:"separator",children:y.jsx("span",{children:"Unread messages"})}):null;if(M&&M.variant==="system"){const Q=M.presentation??"system";return y.jsxs(Ji.div,{className:"message-motion",id:K,initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:os,children:[pe,y.jsxs("div",{className:`room-system room-${Q}-card`,role:"note",children:[M.label&&y.jsx("span",{className:"room-system-label",children:M.label}),M.roomName&&y.jsx("strong",{className:"room-card-name",children:M.roomName}),y.jsx(Ex,{text:M.text,className:"room-system-text message-markdown"}),!!M.details?.length&&y.jsx("ul",{className:"room-card-details","aria-label":"Room event details",children:M.details.map(fe=>y.jsx("li",{children:fe},fe))}),y.jsxs("span",{className:"room-card-provenance",children:[M.authoredBy&&y.jsx("span",{className:"room-card-author",children:M.authoredBy}),y.jsx("span",{className:"room-system-at",children:hi(P.date)})]})]})]},D)}if(P.kind==="file"){const Q=O0(P.wireId)??{id:P.wireId,dir:P.dir,filename:P.filename??"file",mime:P.mime??"application/octet-stream",size:0,date:P.date};return y.jsxs(Ji.div,{className:"message-motion",id:K,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:os,children:[pe,y.jsx(Nf,{dir:P.dir==="out"?"out":"in",rowClass:Z,canReply:!!P.wireId,onReply:()=>A(P),after:ee,children:y.jsx("div",{className:`ours-message ours-message-file ours-message--${P.dir}`,children:y.jsx(BD,{rec:Q,receipt:P.receipt,receiptless:P.receiptless,onPreview:p,onFetch:v})})})]},D)}if(P.typed){const Q=P.typed.kind==="command_result"&&P.replyTo?w.get(P.replyTo.wireId):void 0,fe=P.typed.kind==="command_result"&&P.dir==="in"&&P.peerCid===f&&Q?.dir==="out"&&Q.peerCid===f&&Q.typed?.kind==="command",j=P.typed.kind==="command_result"&&!P.typed.outcome.ok?P.typed.outcome.error.toLowerCase():"",F=P.typed.kind==="command"?P.dir==="out"?"Accepted · pending result":"Received command":P.typed.kind==="unknown"?"Safe failure":P.dir==="out"?"Result sent":fe?j==="validation_denied"||j==="validation_failed"?"Validation denied":j==="policy_denied"||j==="unauthorized"||j==="forbidden"?"Policy denied":P.typed.outcome.ok?"Completed":"Failed":"Unmatched result · safe failure",J=P.typed.kind==="command"?P.typed.command:P.typed.kind==="command_result"?`Result for ${fe&&Q?.typed?.kind==="command"?Q.typed.command:"unmatched command"}`:`Unsupported ${P.typed.wire_kind}`,N=P.typed.kind==="command"?P.typed.arguments:P.typed.kind==="command_result"?P.typed.outcome:{safe_failure:P.typed.malformed?"Malformed typed message":"Future typed message preserved"};return y.jsxs(Ji.div,{className:"message-motion",id:K,initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0},transition:os,children:[pe,y.jsx(Nf,{dir:P.dir,rowClass:Z,canReply:!!P.wireId,onReply:()=>A(P),after:ee,children:y.jsxs("div",{className:`ours-message typed-message ours-message--${P.dir}`,children:[y.jsx("div",{className:"typed-message-kind",children:P.typed.kind==="command"?"Command":P.typed.kind==="command_result"?"Result":"Typed message"}),y.jsx("strong",{children:J}),y.jsx("div",{className:"typed-message-state",role:"status",children:F}),y.jsx("pre",{children:JSON.stringify(N,null,2)}),y.jsxs("div",{className:"bubble-at",children:[hi(P.date),P.dir==="out"&&y.jsx(cd,{receipt:P.receipt,receiptless:P.receiptless})]})]})})]},D)}const xe=R(P);return y.jsxs(Ji.div,{className:"message-motion",id:K,initial:{opacity:0,y:12,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.98},transition:os,children:[pe,y.jsx(Nf,{dir:P.dir==="out"?"out":"in",rowClass:Z,canReply:!!P.wireId,onReply:()=>A(P),after:ee,children:y.jsxs("div",{className:`ours-message ours-message--${P.dir}`,children:[xe&&y.jsxs("div",{className:"quote",children:[xe.author&&y.jsx("span",{className:"quote-author",children:xe.author}),y.jsx("span",{className:"quote-text",children:xe.text})]}),M&&!B&&y.jsxs(y.Fragment,{children:[M.roomName&&y.jsx("div",{className:"room-message-room",children:M.roomName}),y.jsxs("div",{className:"room-author",children:[y.jsx("span",{className:"room-author-name",children:M.author}),M.role&&y.jsx("span",{className:"room-author-role",children:M.role})]})]}),y.jsx(Ex,{text:M?M.text:P.text}),y.jsxs("div",{className:"bubble-at",children:[hi(P.date),P.dir==="out"&&y.jsx(cd,{receipt:P.receipt,receiptless:P.receiptless})]})]})})]},D)})})});function Mz(e){const{contact:t,messages:n}=e,[i,s]=k.useState(""),[a,l]=k.useState(!1),[c,f]=k.useState(null),[h,m]=k.useState(null),[p,v]=k.useState(null),[w,S]=k.useState(null),[C,E]=k.useState(null),[R,A]=k.useState(!1),[T,P]=k.useState(!1),[O,D]=k.useState(!1),[K,$]=k.useState(null),[_,M]=k.useState(null),[Y,B]=k.useState(!1),[ce,Z]=k.useState(!1),ee=k.useRef(null),pe=k.useRef(null),xe=k.useRef(null),Q=k.useRef(null),fe=k.useRef(null),j=k.useRef(null),F=k.useRef(null),J=k.useRef(!1),N=k.useRef(null),te=k.useRef(!1),[me,ye]=k.useState(!1),[he,Te]=k.useState(0),ge=k.useRef(null),_e=k.useRef(!0),He=k.useRef(null),tt=k.useRef(0),gt=k.useRef(null),at=k.useRef(new Map),_t=k.useRef(0),ot=k.useRef(null),qe=k.useRef(null),At=k.useRef(0),hn=k.useRef(null),jt=k.useRef("");k.useLayoutEffect(()=>{const V=fe.current,q=j.current,re=F.current;if(!V||!q||!re)return;let de=-1,le=-1,Ne=null;const ut=()=>{const $e=Math.round(q.getBoundingClientRect().height),Ye=Math.round(re.getBoundingClientRect().height);if($e!==de&&(de=$e,V.style.setProperty("--conversation-head-height",`${$e}px`)),Ye!==le){const Le=_e.current;le=Ye,V.style.setProperty("--conversation-compose-height",`${Ye}px`),Le&&(Ne!==null&&cancelAnimationFrame(Ne),Ne=requestAnimationFrame(()=>{Ne=null;const $t=N.current;$t&&_e.current&&($t.scrollTop=Math.max(0,$t.scrollHeight-$t.clientHeight))}))}};ut();const kt=new ResizeObserver(ut);return kt.observe(q),kt.observe(re),()=>{kt.disconnect(),Ne!==null&&cancelAnimationFrame(Ne),V.style.removeProperty("--conversation-head-height"),V.style.removeProperty("--conversation-compose-height")}},[t?.id]),k.useEffect(()=>{s(""),m(null),v(null),f(null),S(null),E(null),A(!1),P(!1),D(!1),tt.current+=1,$(null),ee.current?.abort(),M(null),B(!1),Z(!1),at.current.clear(),ot.current=null,qe.current=null},[t?.id]);const Gt=async(V=!0,q=!0)=>{if(!t||!e.onLoadCommands)return;ee.current?.abort();const re=new AbortController;ee.current=re,Z(!0),m(null);try{const de=await e.onLoadCommands(t.id,re.signal);!re.signal.aborted&&de.recipient_cid===t.id?(M(de),de.commands.length===0?(B(!1),Y&&requestAnimationFrame(()=>Q.current?.focus({preventScroll:!0}))):V&&B(!0)):re.signal.aborted||(M(null),B(!1),q&&m("Command discovery was refused because the authenticated recipient changed."))}catch(de){re.signal.aborted||(M(null),B(!1),q&&m(de instanceof Al?`Command discovery failed: ${de.message}`:"Command discovery failed safely. The recipient may be offline or unsupported."))}finally{ee.current===re&&Z(!1)}};k.useEffect(()=>(Gt(!1,!1),()=>ee.current?.abort()),[t?.id]);const Fn=()=>{B(!1),pe.current?.focus()};k.useEffect(()=>{if(!p)return;const V=p.reply?.wireId;n.some(re=>re.kind!=="file"&&re.dir==="out"&&!!re.wireId&&!p.wireIds.has(re.wireId)&&re.text===p.text&&(re.replyTo?.wireId??void 0)===V)&&(v(null),m(null),s(re=>re===p.draft?"":re),S(re=>re===p.reply?null:re))},[n,p]);const Oe=!!c?.wireId&&n.some(V=>V.wireId===c.wireId),yt=k.useMemo(()=>c&&!Oe?[...n,c.message]:n,[n,c,Oe]);k.useEffect(()=>{Oe&&f(null)},[Oe]),k.useLayoutEffect(()=>{const V=Q.current;if(!V)return;i.startsWith(jt.current)||(V.style.height="0px");const re=V.scrollHeight,le=`${Math.max(44,Math.min(re,132))}px`;V.style.height!==le&&(V.style.height=le),V.style.overflowY=re>132?"auto":"hidden",jt.current=i},[i,t?.id]);const En=V=>{const q=N.current;if(!q)return;const re=Math.max(0,q.scrollHeight-q.clientHeight);if(Math.abs(q.scrollTop-re)<1){ot.current=null,qe.current=null;return}const de=V&&!dS();ot.current=de?re:null,qe.current=de?q.scrollTop:null,de?q.scrollTo({top:re,behavior:"smooth"}):q.scrollTop=re},G=()=>{ge.current===null&&(ge.current=requestAnimationFrame(()=>{ge.current=null;const V=N.current;if(!V)return;const q=V.scrollHeight-V.clientHeight-V.scrollTop>48;ye(q),q||Te(0)}))};k.useLayoutEffect(()=>{if(!t){He.current=null,_e.current=!0,At.current=0;return}const V=N.current;if(!V)return;const q=He.current!==t.id,re=At.current,de=yt.length!==re,le=yt.at(-1),Ne=le?le.wireId||`${le.date}:${le.text}`:null,ut=hn.current;if(At.current=yt.length,hn.current=Ne,!q&&!de&&ot.current===null&&(_e.current=V.scrollHeight-V.clientHeight-V.scrollTop<=48),q||_e.current)En(de&&!q&&He.current!==null),_e.current=!0;else if(de&&yt.length>re&&Ne!==ut){const kt=ut===null?-1:yt.findIndex($e=>($e.wireId||`${$e.date}:${$e.text}`)===ut);Te($e=>$e+Math.max(1,yt.length-Math.max(0,kt+1)))}He.current=t.id,G()},[t,yt.length]),k.useLayoutEffect(()=>{if(te.current||!e.unreadOpen||window.location.hash.startsWith("#chat-message-"))return;const V=N.current,q=document.getElementById(`unread-${fS(e.unreadOpen.wireId)}`);!V||!q||(V.scrollTop=Math.max(0,q.offsetTop-16),_e.current=!1,te.current=!0,G())},[e.unreadOpen,yt.length]),k.useLayoutEffect(()=>{const V=window.location.hash;if(!V.startsWith("#chat-message-"))return;const q=document.getElementById(V.slice(1));q&&(q.scrollIntoView({block:"center"}),_e.current=!1)},[t?.id,yt.length]),k.useLayoutEffect(()=>{const V=gt.current,q=N.current;if(V===null||!q)return;const re=requestAnimationFrame(()=>{gt.current===V&&(q.scrollTop=V.top+q.scrollHeight-V.height,gt.current=null)});return()=>cancelAnimationFrame(re)},[yt.length]),k.useEffect(()=>{const V=N.current;if(!V||typeof ResizeObserver>"u")return;const q=V.firstElementChild;if(!q)return;const re=new ResizeObserver(()=>{_e.current&&En(ot.current!==null),G()});return re.observe(q),re.observe(V),()=>{re.disconnect(),ge.current!==null&&cancelAnimationFrame(ge.current)}},[t?.id]);const se=async V=>{const q=++tt.current;m(null),D(!0);try{if(V.size>is&&iS(V.type,V.name)){const de=await sz(V,is);if(q!==tt.current)return;E({filename:de.filename,mime:de.mime,bytes:de.bytes,originalSize:de.originalSize});return}if(V.size>is){m(`"${V.name}" is ${Vr(V.size)} — files up to ${Vr(is)} can be sent.`);return}const re=await V.arrayBuffer();if(q!==tt.current)return;E({filename:V.name||"file",mime:V.type||"application/octet-stream",bytes:new Uint8Array(re)})}catch(re){q===tt.current&&m(`Photo optimization failed: ${re instanceof Error?re.message:String(re)}`)}finally{q===tt.current&&D(!1)}},Pe=()=>{!C||!e.onSendFile||T||(P(!0),e.onSendFile(C,w?.wireId).then(()=>{E(null),S(null)}).catch(V=>m(`File send failed: ${String(V)} — it was not delivered.`)).finally(()=>P(!1)))},De=e.onDraftChange;k.useEffect(()=>(De?.(i.trim().length>0||a),()=>De?.(!1)),[i,a,De]);const ze=k.useMemo(()=>{const V=new Map;for(const q of yt)V.set(q,q.kind==="file"?null:q.dir==="in"?_j(t?.announcedName??"",q.text):null);return V},[yt,t?.announcedName]);if(!t)return e.emptyOverride?y.jsx(y.Fragment,{children:e.emptyOverride}):y.jsx("div",{className:"detail",children:y.jsxs("div",{className:"detail-empty",children:[y.jsx(ke,{name:"chat"}),y.jsxs("div",{children:[y.jsx("div",{style:{fontWeight:650,color:"var(--text-2)"},children:"Select a conversation"}),y.jsx("div",{style:{fontSize:"0.85rem"},children:"Chat with people, agents and apps across ours."})]})]})});const lt=async()=>{const V=i,q=V.trim(),re=!!p&&V===p.draft&&(w?.wireId??void 0)===p.reply?.wireId;if(!q||J.current||re)return;p&&v(null),J.current=!0,l(!0),m(null);const de=w,le=de?.wireId,Ne=new AbortController;let ut=!1,kt=0;s(""),S(null);const $e=`optimistic-${++_t.current}`;f({key:$e,wireId:null,message:{dir:"out",text:q,date:new Date().toISOString(),read:!0,wireId:"",replyTo:le?{wireId:le}:null}});try{const Ye=await Promise.race([e.onSend(q,le,Ne.signal),new Promise((Le,$t)=>{kt=window.setTimeout(()=>{ut=!0,Ne.abort(),$t(new Error("send timeout"))},Rz)})]);Ye?(at.current.set(Ye,$e),f(Le=>Le?.key===$e?{...Le,wireId:Ye}:Le)):f(Le=>Le?.key===$e?null:Le),v(null)}catch(Ye){f(null),s(Le=>Le===""?V:Le),S(Le=>Le===null?de:Le),ut||!(Ye instanceof Al)?(v({draft:V,text:q,reply:de,wireIds:new Set(n.flatMap(Le=>Le.wireId?[Le.wireId]:[]))}),m(`${ut?"Send timed out":"Send connection was interrupted"} — delivery status is unknown. Check the conversation; edit the draft before sending again.`)):m(`Send failed: ${String(Ye)} — the message was not delivered.`)}finally{window.clearTimeout(kt),J.current=!1,l(!1)}},W=!!p&&i===p.draft&&(w?.wireId??void 0)===p.reply?.wireId;return y.jsxs("div",{className:"detail detail-chat",ref:fe,children:[y.jsx("div",{className:"detail-head",ref:j,children:y.jsxs("div",{className:"conv-peer",children:[y.jsx("button",{className:"icon-btn detail-back","aria-label":"Back to conversations",onClick:e.onBack,children:y.jsx(ke,{name:"back"})}),y.jsxs("div",{className:"conv-peer-status",children:[y.jsx("span",{className:"conv-peer-name",children:t.name}),e.syncing&&y.jsxs("div",{className:"conv-sync",role:"status","aria-live":"polite",children:[y.jsx("span",{className:"conv-sync-dot","aria-hidden":!0}),e.syncing==="connecting"?"Connecting…":"Updating…"]}),!e.syncing&&y.jsxs("span",{className:"conv-contact-status",children:[y.jsx(ke,{name:"lock",size:11}),"Encrypted connection"]})]}),y.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:y.jsx("span",{className:"conv-contact-initials","aria-hidden":!0,children:t.initials})})]})}),y.jsx("div",{className:"messages",ref:N,tabIndex:-1,"aria-label":"Conversation timeline",onScroll:V=>{const q=V.currentTarget,re=q.scrollHeight-q.clientHeight-q.scrollTop;if(ot.current!==null){const de=qe.current;if(de===null||q.scrollTop>=de-1){qe.current=q.scrollTop,re<=4&&(ot.current=null,qe.current=null);return}ot.current=null,qe.current=null}_e.current=re<=48,G()},onPointerDown:()=>{ot.current=null,qe.current=null},onTouchStart:()=>{ot.current=null,qe.current=null},onWheel:()=>{ot.current=null,qe.current=null},onDragOver:V=>{e.onSendFile&&V.preventDefault()},onDrop:V=>{if(!e.onSendFile)return;V.preventDefault();const q=V.dataTransfer.files?.[0];q&&se(q)},children:y.jsxs("div",{className:"messages-inner",children:[y.jsxs("div",{className:"e2e-note",children:[y.jsx(ke,{name:"lock"}),"End-to-end encrypted · the broker only sees ciphertext"]}),(e.hiddenEarlier??0)>0&&e.onLoadEarlier&&y.jsxs("button",{className:"btn sm chat-load-earlier",onClick:()=>{_e.current=!1;const V=N.current;gt.current=V?{height:V.scrollHeight,top:V.scrollTop}:null,e.onLoadEarlier?.()},children:["Load earlier messages (",e.hiddenEarlier," remaining)"]}),y.jsx(Nz,{messages:yt,optimisticSend:c,sentKeys:at.current,hiddenEarlier:e.hiddenEarlier??0,unreadWireId:e.unreadOpen?.wireId,roomLines:ze,contactCid:t.id,contactName:t.name,onStartReply:S,onPreview:$,onFetchFile:e.onFetchFile}),y.jsx("div",{className:"thread-end","aria-hidden":!0})]})},t.id),me&&y.jsxs("button",{type:"button",className:"jump-latest btn sm","aria-label":he?`Jump to latest, ${he} new messages`:"Jump to latest",onClick:V=>{const q=V.currentTarget===document.activeElement;Te(0),En(!0),q&&requestAnimationFrame(()=>N.current?.focus({preventScroll:!0}))},children:[y.jsx("span",{children:"Jump to latest"}),!!he&&y.jsx("span",{className:"jump-latest-count","aria-live":"polite",children:he})]}),h&&y.jsxs("div",{className:"banner error",role:"alert",children:[h,h.startsWith("Send failed:")&&y.jsx("span",{className:"banner-actions",children:y.jsx("button",{className:"linkbtn",onClick:()=>void lt(),children:"retry"})})]}),y.jsxs("div",{className:"composer-wrap",ref:F,children:[Y&&_&&e.onSendCommand&&y.jsx(vz,{catalog:_,recipientName:t.name,busy:ce,onRefresh:()=>void Gt(!0,!0),onClose:Fn,onSend:async(V,q,re,de)=>{if(!t||t.id!==_.recipient_cid)throw new Error("Recipient changed; refresh commands");return e.onSendCommand(t.id,V.name,q,re,de)}},`${_.recipient_cid}:${_.fingerprint}`),w&&y.jsxs("div",{className:"reply-bar",children:[y.jsx("div",{className:"reply-bar-line"}),y.jsxs("div",{className:"reply-bar-body",children:[y.jsxs("div",{className:"reply-bar-author",children:["Replying to ",w.author]}),y.jsx("div",{className:"reply-bar-text",children:w.text})]}),y.jsx("button",{className:"icon-btn",title:"Cancel reply",onClick:()=>S(null),children:y.jsx(ke,{name:"close",size:16})})]}),C&&y.jsx(D1,{att:C,sending:T,onSend:Pe,onDiscard:()=>E(null)}),O&&y.jsx("div",{className:"attachment-processing",role:"status",children:"Optimizing photo for secure delivery…"}),y.jsxs("div",{className:"composer"+(R?" recording":""),children:[e.onLoadCommands&&_&&_.commands.length>0&&y.jsx("button",{ref:pe,type:"button",className:"icon-btn composer-tool command-trigger",title:"Recipient commands","aria-label":"Recipient commands","aria-expanded":Y,disabled:ce,onClick:()=>Y?Fn():B(!0),children:y.jsx(ke,{name:"menu",size:19})}),e.onSendFile&&y.jsxs(y.Fragment,{children:[y.jsx("input",{ref:xe,type:"file",style:{display:"none"},onChange:V=>{const q=V.target.files?.[0];q&&se(q),V.target.value=""}}),y.jsx("button",{className:"icon-btn composer-tool",title:"Attach a file or photo",disabled:T||O||R,onClick:()=>xe.current?.click(),children:y.jsx(ke,{name:"paperclip",size:18})})]}),y.jsx("textarea",{ref:Q,className:"field",rows:1,placeholder:(w?"Reply to "+w.author:"Message "+t.name)+"…",value:i,"aria-busy":a,onChange:V=>s(V.target.value),onKeyDown:V=>{V.key==="Enter"?!(window.matchMedia("(pointer: coarse)").matches||window.innerWidth<=860)&&!V.shiftKey&&(V.preventDefault(),lt()):V.key==="Escape"&&S(null)}}),e.onSendFile&&!i.trim()&&!C&&!O&&!T?y.jsx(_1,{disabled:T||O||!!C,onReady:V=>{A(!1),E(V)},onError:V=>{A(!1),m(V)},onActiveChange:A},t.id):y.jsxs("button",{className:"btn primary","aria-label":"Send",onPointerDown:V=>{V.button===0&&document.activeElement===Q.current&&V.preventDefault()},onClick:()=>void lt(),disabled:a||W||!i.trim(),title:W?"Delivery status unknown — edit before sending again":void 0,children:[y.jsx(ke,{name:"send",size:16}),y.jsx("span",{className:"btn-label",children:"Send"})]})]})]}),K&&(Ms(K.filename,K.mime)?y.jsx(nS,{rec:K,onClose:()=>$(null)}):y.jsx(tS,{rec:K,onClose:()=>$(null),onSendText:e.onSend,onSendFile:e.onSendFile}))]})}const hS=3;function Iz(e,t,n=hS){return[t,...e.filter(i=>i.cid!==t.cid)].slice(0,n)}function Dz(e,t){return e.filter(n=>n.id!==t)}const _z=6e3,Lz=Iz,Oz=Dz;function Fz(){const[e,t]=k.useState([]),n=k.useRef(0),i=k.useCallback((l,c,f)=>{const h=Date.now(),m={id:`${l}:${h}:${n.current++}`,cid:l,name:c,preview:"",at:h};t(p=>Lz(p,m,hS))},[]),s=k.useCallback(l=>t(c=>Oz(c,l)),[]),a=k.useCallback(l=>t(c=>c.filter(f=>f.cid!==l)),[]);return{toasts:e,push:i,dismiss:s,clear:a}}function zz(e){const{item:t,onOpen:n,onDismiss:i}=e,[s,a]=k.useState(!1),[l,c]=k.useState(!1),f=s||l;return k.useEffect(()=>{if(f)return;const h=setTimeout(()=>i(t.id),_z);return()=>clearTimeout(h)},[t.id,f,i]),y.jsxs("div",{className:"banner msg",role:"status",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onFocus:()=>c(!0),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||c(!1)},children:[y.jsxs("button",{className:"msg-open",title:`Open the conversation with ${t.name}`,onClick:()=>n(t.cid),children:[y.jsx("span",{className:"avatar sm accent","aria-hidden":"true",children:ld(t.name)}),y.jsxs("span",{className:"msg-text",children:[y.jsx("strong",{className:"msg-name",children:t.name}),y.jsx("span",{className:"msg-preview",children:t.preview||"New message"})]})]}),y.jsx("button",{className:"icon-btn msg-close",title:"Dismiss","aria-label":`Dismiss the notification from ${t.name}`,onClick:()=>i(t.id),children:y.jsx(ke,{name:"close",size:15})})]})}function Vz(e){return y.jsx(y.Fragment,{children:e.items.map(t=>y.jsx(zz,{item:t,onOpen:e.onOpen,onDismiss:e.onDismiss},t.id))})}function Bz(e){const t=k.useRef(null),{text:n,size:i=240}=e;return k.useEffect(()=>{if(!t.current||!n)return;const s=t.current;Mh(()=>import("./browser-DinAcYN1.js").then(a=>a.b),[]).then(a=>{a.toCanvas(s,n,{width:i,margin:2,errorCorrectionLevel:"M",color:{dark:"#000000",light:"#ffffff"}})})},[n,i]),y.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"8px 0"},children:y.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 $z(e){const t=k.useRef(null),n=k.useRef(null),i=k.useRef(null),s=k.useRef(0),a=k.useRef(!0),[l,c]=k.useState("requesting"),[f,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"),R=()=>{if(a.current)if(S.readyState>=S.HAVE_ENOUGH_DATA){const A=S.videoWidth||320,T=S.videoHeight||240;C.width=A,C.height=T,E.drawImage(S,0,0,A,T);const P=E.getImageData(0,0,A,T);Mh(()=>import("./jsQR-D3MZZ4y1.js").then(O=>O.j),[]).then(O=>{const D=O.default,K=D(P.data,P.width,P.height,{inversionAttempts:"dontInvert"});if(K&&K.data&&a.current){m(),e.onDecode(K.data);return}a.current&&(s.current=requestAnimationFrame(R))})}else s.current=requestAnimationFrame(R)};s.current=requestAnimationFrame(R)},[m,e]);k.useEffect(()=>{if(a.current=!0,!navigator.mediaDevices?.getUserMedia){c("nocamera");return}return navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then(w=>{if(!a.current){w.getTracks().forEach(S=>S.stop());return}c("scanning"),p(w)}).catch(w=>{if(!a.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)))}),()=>{a.current=!1,m()}},[]);const v=()=>{m(),e.onClose()};return y.jsxs("div",{"data-testid":"qr-scanner",style:{display:"flex",flexDirection:"column",gap:12,padding:"12px 0"},children:[(l==="requesting"||l==="scanning")&&y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:l==="requesting"?"Requesting camera…":"Point your camera at the QR code."}),y.jsxs("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",background:"#000",minHeight:200},children:[y.jsx("canvas",{ref:n,"data-testid":"scanner-canvas",style:{display:"none"}}),y.jsx("video",{ref:t,"data-testid":"scanner-video",muted:!0,playsInline:!0,style:{width:"100%",display:"block",borderRadius:8}}),l==="scanning"&&y.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",display:"flex",alignItems:"center",justifyContent:"center"},children:y.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)"}})})]})]}),l==="denied"&&y.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[y.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[y.jsx(ke,{name:"shield",size:16}),y.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"Camera access denied"})]}),y.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."})]}),l==="nocamera"&&y.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[y.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"var(--text-2)"},children:[y.jsx(ke,{name:"close",size:16}),y.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:"No camera available"})]}),y.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.88rem"},children:"No camera was found on this device. Paste the invite text below instead."})]}),l==="error"&&y.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:y.jsxs("p",{style:{margin:0,fontSize:"0.85rem",color:"var(--danger, #e53)"},children:["Camera error: ",f||"unknown error",". Paste the invite text below instead."]})}),y.jsx("button",{className:"btn",style:{justifyContent:"center"},onClick:v,children:l==="scanning"?y.jsxs(y.Fragment,{children:[y.jsx(ke,{name:"close",size:14}),"Cancel scan"]}):y.jsxs(y.Fragment,{children:[y.jsx(ke,{name:"close",size:14}),"Close scanner"]})})]})}function Uz(e){const[t,n]=k.useState("generate"),[i,s]=k.useState("one_time"),[a,l]=k.useState(""),[c,f]=k.useState(null),[h,m]=k.useState("one_time"),[p,v]=k.useState(""),[w,S]=k.useState(""),[C,E]=k.useState(!1),[R,A]=k.useState(null),[T,P]=k.useState(null),[O,D]=k.useState(!1),[K,$]=k.useState(null),_=k.useRef(!1),M=async()=>{if(!_.current){_.current=!0,E(!0),P(null),A(null);try{m(i),f(await e.onCreate(i,i==="one_time"&&a.trim()||void 0))}catch(B){P(B instanceof Error?B.message:String(B))}finally{_.current=!1,E(!1)}}},Y=y.jsx(rS,{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 y.jsx(Ls,{title:t==="generate"?"Invite a contact":"Accept an invite",onClose:()=>{_.current||e.onClose()},tabs:Y,children:y.jsxs("div",{id:"invite-panel",role:"tabpanel","aria-labelledby":`invite-tab-${t}`,children:[t==="generate"&&!c&&y.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:13},children:[y.jsxs("p",{className:"muted","data-testid":"invite-identity",style:{margin:0,fontSize:"0.85rem"},children:["Creating as ",y.jsx("strong",{children:e.identity.name})," · ",y.jsxs("span",{className:"mono",children:["@",_0(e.identity.cid)]})]}),y.jsxs("div",{role:"radiogroup","aria-label":"Invite kind",style:{display:"flex",flexDirection:"column",gap:7},children:[y.jsxs("label",{children:[y.jsx("input",{type:"radio",name:"invite-kind",checked:i==="one_time",onChange:()=>s("one_time")})," One person (one time)"]}),y.jsxs("label",{children:[y.jsx("input",{type:"radio",name:"invite-kind",checked:i==="public",onChange:()=>s("public")})," Reusable public invite"]})]}),i==="one_time"?y.jsxs(y.Fragment,{children:[y.jsx("p",{className:"muted",style:{margin:0,fontSize:"0.9rem"},children:"Optionally name the person or agent this invite is for."}),y.jsx("input",{className:"field",value:a,onChange:B=>l(B.target.value),placeholder:"Their name (optional), e.g. Bob",maxLength:64})]}):y.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."}),y.jsx("button",{className:"btn primary",style:{justifyContent:"center"},disabled:C,onClick:()=>void M(),children:C?"Generating…":i==="public"?"Create public invite":"Generate invite"}),i==="public"&&y.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[y.jsx("h4",{style:{margin:0,fontSize:"0.9rem"},children:"Active reusable invites"}),e.invites.filter(B=>B.mode==="public").length===0&&y.jsx("p",{className:"muted",style:{margin:0},children:"None right now."}),e.invites.filter(B=>B.mode==="public").map(B=>y.jsxs("div",{"data-testid":"public-invite-row",style:{padding:"8px 10px",background:"var(--inset)",borderRadius:7},children:[y.jsx("span",{className:"mono",children:B.invite_id}),y.jsxs("p",{className:"muted",children:["Created ",B.created?qj(B.created):"unknown"," · Active until revoked · No expiry"]}),K===B.invite_id?y.jsxs("span",{children:[y.jsx("button",{className:"btn sm danger",onClick:()=>void e.onRevoke(B.invite_id).then(()=>($(null),e.onRefresh())).catch(ce=>P(String(ce))),children:"Confirm revoke"})," ",y.jsx("button",{className:"btn sm",onClick:()=>$(null),children:"Keep it"})]}):y.jsx("button",{className:"btn sm",onClick:()=>$(B.invite_id),children:"Revoke"})]},B.invite_id))]}),R&&y.jsx("p",{className:"muted",children:R}),T&&y.jsx("p",{className:"onb-error",children:T})]}),t==="generate"&&c&&y.jsxs(y.Fragment,{children:[y.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 ${a.trim()||"your contact"}. It can be redeemed once.`}),y.jsx("textarea",{className:"field mono","data-testid":"invite-result-text",readOnly:!0,rows:5,value:c,onFocus:B=>B.currentTarget.select()}),h==="one_time"&&y.jsx(Bz,{text:c}),y.jsxs("button",{className:"btn primary",onClick:()=>void navigator.clipboard.writeText(c).then(()=>A("Copied to clipboard.")),children:[y.jsx(ke,{name:"copy",size:15}),"Copy invite"]}),h==="public"&&y.jsx("button",{className:"btn","data-testid":"done-hide-invite",onClick:()=>{f(null),l(""),e.onRefresh()},children:"Done — hide invite"}),R&&y.jsx("p",{className:"muted",children:R})]}),t==="accept"&&y.jsxs("form",{style:{display:"flex",flexDirection:"column",gap:13},onSubmit:B=>{B.preventDefault(),!(!p.trim()||C)&&(E(!0),P(null),e.onAccept(p.trim(),w.trim()||void 0).then(()=>{A("Invite accepted — the contact will appear once the sender verifies your identity."),v(""),S("")}).catch(ce=>P(String(ce))).finally(()=>E(!1)))},children:[y.jsx("p",{className:"muted",children:"Paste the invite you received, or scan a QR code."}),O?y.jsx($z,{onDecode:B=>{v(B),D(!1)},onClose:()=>D(!1)}):y.jsxs("button",{type:"button",className:"btn",onClick:()=>D(!0),children:[y.jsx(ke,{name:"monitor",size:15}),"Scan QR code"]}),y.jsx("textarea",{className:"field mono","aria-label":"Invite",rows:5,value:p,onChange:B=>v(B.target.value),placeholder:"Paste invite text…"}),y.jsx("input",{className:"field",value:w,onChange:B=>S(B.target.value),placeholder:"Rename them (optional)",maxLength:64}),y.jsx("button",{className:"btn primary",type:"submit",disabled:C||!p.trim(),children:C?"Connecting…":"Add contact"}),R&&y.jsx("p",{className:"muted",children:R}),T&&y.jsx("p",{className:"onb-error",children:T})]})]})})}function Wz(e){const[t,n]=k.useState(e.identity.bio??""),[i,s]=k.useState(!1),[a,l]=k.useState(null),[c,f]=k.useState(e.push.preview),h=LA(),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 y.jsxs(Ls,{title:"Settings",onClose:e.onClose,wide:!0,children:[y.jsxs("div",{children:[y.jsx("span",{className:"lbl",children:"Display name"}),y.jsx("input",{className:"field",readOnly:!0,value:e.identity.name})]}),y.jsxs("div",{children:[y.jsx("span",{className:"lbl",children:"Your address"}),y.jsx("input",{className:"field mono",readOnly:!0,value:e.identity.cid,onFocus:p=>p.currentTarget.select()}),y.jsx("p",{className:"muted",children:"Your public address on ours. Share an invite to connect more easily."})]}),y.jsxs("div",{children:[y.jsx("span",{className:"lbl",children:"Public bio"}),y.jsx("textarea",{className:"field",rows:3,value:t,onChange:p=>{n(p.target.value),s(!1),l(null)}}),y.jsx("button",{className:"btn sm",onClick:()=>{l(null),e.onSaveBio(t).then(()=>s(!0)).catch(p=>l(String(p)))},children:i?"Saved":"Save bio"}),a&&y.jsx("p",{className:"onb-error",children:a})]}),y.jsxs("label",{style:{display:"flex",gap:9},children:[y.jsx("input",{type:"checkbox",checked:e.dark,onChange:e.onToggleDark})," Dark mode"]}),y.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[y.jsx("h4",{children:"Notifications"}),y.jsx("p",{className:e.push.status==="needs-permission"||e.push.status==="error"?"onb-error":"muted",children:m}),h&&h!==m&&y.jsx("p",{className:"muted","data-testid":"push-platform-guidance",children:h}),y.jsxs("fieldset",{style:{border:0,padding:0,margin:"12px 0"},children:[y.jsx("legend",{className:"lbl",children:"Lock-screen preview"}),y.jsxs("label",{style:{display:"block",marginTop:7},children:[y.jsx("input",{type:"radio",name:"push-preview",checked:c==="full",onChange:()=>f("full")})," Full — sender and message text or filename"]}),y.jsxs("label",{style:{display:"block",marginTop:7},children:[y.jsx("input",{type:"radio",name:"push-preview",checked:c==="private",onChange:()=>f("private")})," Private — generic content only"]})]}),y.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."}),y.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.push.status==="on"?y.jsxs(y.Fragment,{children:[y.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("disable",c),children:"Disable notifications"}),y.jsx("button",{className:"btn",disabled:e.busy,onClick:()=>void e.onPushAction("repair",c),children:"Repair"}),c!==e.push.preview&&y.jsx("button",{className:"btn primary",disabled:e.busy,onClick:()=>void e.onPushAction("enable",c),children:"Save preview"})]}):y.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"})})]}),y.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[y.jsx("h4",{children:"App status"}),y.jsx("p",{className:"muted",children:e.offline?"Offline — reconnecting. Message and identity data are never cached.":"Online."}),e.onInstall&&y.jsx("button",{className:"btn",onClick:e.onInstall,children:"Install app"}),e.updateAvailable&&y.jsx("button",{className:"btn primary",onClick:e.onReloadUpdate,children:"Reload to update"})]}),y.jsxs("div",{style:{borderTop:"1px solid var(--line)",paddingTop:16},children:[y.jsx("h4",{children:"Build"}),y.jsx("input",{className:"field mono",readOnly:!0,value:e.build?`${e.build.version} · ${e.build.sha}`:"Loading…"})]})]})}function Hz(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 qz="e1384f5556f308cc8436bcb777d7335f12b80ff1",Kz=15*6e4,Xz=6e4,Yz=Hz;async function Gz(){try{const e=await fetch("/version.json",{cache:"no-store"});return e.ok?await e.json():null}catch{return null}}function Qz(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 f=await Gz(),h=Yz(qz,f,t,Date.now(),Xz);h==="newer-available"?(e.onUpdateAvailable(),navigator.serviceWorker?.getRegistration().then(m=>m?.update())):h==="stuck"&&!i&&(i=!0,e.onStuck(f.sha))},a=setTimeout(()=>void s(),5e3),l=setInterval(()=>void s(),Kz),c=()=>{document.visibilityState==="visible"&&s()};return document.addEventListener("visibilitychange",c),()=>{clearTimeout(a),clearInterval(l),document.removeEventListener("visibilitychange",c),navigator.serviceWorker?.removeEventListener("controllerchange",n)}}async function Jz(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 Zz(){const e=new URL(location.href);e.searchParams.has("v")&&(e.searchParams.delete("v"),history.replaceState(null,"",e.pathname+e.search+e.hash))}const Ox=[0,100,400,1e3,3e3,6e3],Fx=e=>new Promise(t=>setTimeout(t,e)),zx={delivered:1,read:2},Vx="ours-dark-v3",Bx="#chat-message-",$x=jl,e4=e=>e instanceof Error&&e.message?e.message:"The request could not be completed.";function pS(e,t){const n=new Map,i=[];for(const s of e?.messages??[]){const a={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,peerCid:s.peer_cid,receipt:s.receipt??void 0,receiptless:s.dir==="out"&&!s.wire_id,messageKind:s.message_kind,typed:s.typed};s.wire_id?n.set(s.wire_id,a):i.push(a)}for(const s of t){const a=n.get(s.wire_id);n.set(s.wire_id,{dir:s.dir,text:"",date:s.date,read:a?.read??s.dir==="out",wireId:s.wire_id,replyTo:s.reply_to?{wireId:s.reply_to.wire_id}:a?.replyTo??null,kind:"file",filename:s.filename,mime:s.mime,receipt:a?.receipt})}return[...i,...n.values()].sort((s,a)=>{const l=$x(s.date)-$x(a.date);return l===0?s.wireId.localeCompare(a.wireId):l})}function t4(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 n4(e,t){return[...e.contacts.contacts.map(i=>{const s=e.contacts.roots?.[i.container_id],a=ar(e,i.container_id),c=pS(a,t[i.container_id]??[]).at(-1),f=Ml(i);return{id:i.container_id,name:f,announcedName:i.name,initials:ld(f),when:c?Hj(c.date):"",activityAt:c?.date??"",last:c?.kind==="file"?eN(c.filename,c.mime):a?.preview??c?.text??"",unread:a?.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=Ml(i);return{id:`pending:${i.container_id}`,name:s,announcedName:i.name,initials:ld(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 r4(){return y.jsx(i4,{})}function i4(){const e=k.useRef(jA(of(window.location.pathname))).current,[t,n]=k.useReducer(av,e),[i,s]=k.useState(null),a=k.useRef(0),l=k.useRef(null),c=k.useRef(t),f=k.useRef(new TA),h=k.useRef(null),m=k.useRef(new Map),p=k.useRef(new Map),[v,w]=k.useState({}),S=k.useRef(v),[C,E]=k.useState(null),R=k.useRef(new Set),[A,T]=k.useState(null),P=k.useRef(A),O=k.useRef(!1),[D,K]=k.useState([]),[$,_]=k.useState(null),[M,Y]=k.useState(()=>localStorage.getItem(Vx)!=="0"),[B,ce]=k.useState(null),[Z,ee]=k.useState({supported:!1,offline:!navigator.onLine,updateAvailable:!1,registration:null}),[pe,xe]=k.useState({status:"unsupported",preview:"full"}),[Q,fe]=k.useState(!1),j=k.useRef(!1),[F,J]=k.useState(()=>window.location.hash.startsWith(Bx)),{toasts:N,push:te,dismiss:me,clear:ye}=Fz(),he=k.useCallback(W=>{c.current=av(c.current,W),n(W)},[]),Te=k.useCallback(W=>{O.current=W},[]);k.useEffect(()=>{c.current=t},[t]),P.current=A,S.current=v,k.useMemo(()=>(vv(Object.values(v).flat()),null),[v]),k.useEffect(()=>(document.documentElement.classList.toggle("theme-dark",M),()=>document.documentElement.classList.remove("theme-dark")),[M]);const ge=k.useCallback(W=>he({type:"error",message:e4(W)}),[he]),_e=k.useCallback(()=>{const W=c.current;return{visibility:document.visibilityState,appRoute:W.route.name==="chats"?"chats":"other",selectedContactCid:Ir(W),desktopLayout:h.current?.matches??window.innerWidth>=861,mobileDetailOpen:W.mobileDetailOpen,conversationCoveringDialogOpen:P.current!==null}},[]),He=k.useCallback(async(W,V=!0)=>{try{const q=await Xe.conversation(W);return he({type:"page",contactCid:W,page:q}),q}catch(q){return V&&ge(q),null}},[he,ge]),tt=k.useCallback(async(W,V=!0)=>{try{const q=await Xe.files(W);return vv(q.files),w(re=>({...re,[W]:q.files})),q.files}catch(q){return V&&ge(q),null}},[ge]);k.useEffect(()=>Qz({onUpdateAvailable:()=>ee(W=>({...W,updateAvailable:!0})),onStuck:W=>{Jz(W)}}),[]);const gt=k.useCallback(async()=>{const W=await Xe.contacts();return he({type:"contacts",contacts:{...W,pending:W.pending??[]}}),W},[he]),at=k.useCallback(async()=>{try{const[W,V,q]=await Promise.all([Xe.identity(),Xe.contacts(),Xe.buildInfo()]),re={...V,pending:V.pending??[]};return c.current.identity&&c.current.identity.cid!==W.cid&&(Qj(),S.current={},w({})),he({type:"snapshot",identity:W,contacts:re}),_(q),await Promise.all(re.contacts.flatMap(de=>[He(de.container_id,!1),tt(de.container_id,!1)])),Ir(c.current)}catch(W){return ge(W),null}},[he,tt,He,ge]),_t=k.useCallback(async W=>{await f.current.request(W,async()=>{EA(W,_e())&&(await Xe.markRead(W),await Promise.all([He(W),gt()]))}).catch(ge)},[_e,gt,He,ge]),ot=k.useCallback(async W=>{const V=++a.current;l.current?.abort();const q=new AbortController;l.current=q,s(null),ye(W),tt(W,!1);let re;try{re=await Xe.conversation(W,void 0,q.signal)}catch(Le){q.signal.aborted||ge(Le);return}if(q.signal.aborted||V!==a.current)return;he({type:"page",contactCid:W,page:re});const de=re.unread;let le=[...re.messages],Ne=re.nextBefore;const ut=new Set,kt=new Set(le.map(Le=>Le.wire_id).filter(Boolean)),$e=()=>le.filter(Le=>Le.dir==="in"&&!Le.read);for(;$e().length<de&&Ne&&!ut.has(Ne);){ut.add(Ne);let Le;try{Le=await Xe.conversation(W,Ne,q.signal)}catch{break}if(q.signal.aborted||V!==a.current)return;const $t=Le.messages.filter(fr=>!fr.wire_id||!kt.has(fr.wire_id));if(!$t.length&&Le.nextBefore===Ne)break;for(const fr of $t)fr.wire_id&&kt.add(fr.wire_id);le=[...$t,...le],he({type:"older_page",contactCid:W,page:Le,newer:re.messages}),Ne=Le.nextBefore}const Ye=$e()[0];Ye?.wire_id&&V===a.current&&!q.signal.aborted&&s({contactCid:W,wireId:Ye.wire_id,count:de}),await _t(W)},[ye,he,_t,tt,ge]),qe=k.useCallback(async(W,V,q="page")=>{const re=`page:${W}:${q}`,de=(m.current.get(re)??0)+1;m.current.set(re,de);for(const le of Ox){if(le&&await Fx(le),m.current.get(re)!==de)return;const Ne=await He(W,!1);if(Ne&&V(Ne))return}},[He]),At=k.useCallback(async(W,V)=>{const q=`file:${W}`,re=(m.current.get(q)??0)+1;m.current.set(q,re);for(const de of Ox)if(de&&await Fx(de),m.current.get(q)!==re||(await tt(W,!1))?.some(Ne=>Ne.wire_id===V))return},[tt]),hn=k.useRef(!1);k.useEffect(()=>{if(!F||!t.loaded)return;const W=decodeURIComponent(window.location.hash.slice(Bx.length)),V=Ir(c.current);if(!W||!V){J(!1);return}if(ar(c.current,V)?.messages.some(q=>q.wire_id===W)){J(!1);return}hn.current||(hn.current=!0,qe(V,q=>q.messages.some(re=>re.wire_id===W),`anchor:${W}`).catch(()=>{}).finally(()=>J(!1)))},[F,qe,t.loaded,t.pages]),k.useMemo(()=>(Gj({url:W=>Object.values(S.current).flat().find(q=>q.wire_id===W)?.available?Xe.mediaUrl(W):null,bytes:async W=>{if(!Object.values(S.current).flat().find(re=>re.wire_id===W)?.available)return null;const q=await fetch(Xe.mediaUrl(W),{cache:"no-store",credentials:"same-origin"});if(!q.ok)throw new Error(`Media request failed (HTTP ${q.status})`);return new Uint8Array(await q.arrayBuffer())},fetch:async W=>{const V=Object.values(S.current).flat().find(q=>q.wire_id===W);if(!V)throw new Error("Media record is unavailable");await Xe.fetchFiles([W]),await tt(V.contact_id)}}),null),[tt]),k.useEffect(()=>{let W;IA(q=>{ee(q),cv(q.registration).then(xe).catch(()=>xe(re=>({...re,status:"error"})))},{shouldDeferReload:()=>O.current||P.current!==null}).then(q=>{W=q}).catch(ge);const V=q=>{q.preventDefault(),ce(q)};return window.addEventListener("beforeinstallprompt",V),()=>{W?.(),window.removeEventListener("beforeinstallprompt",V)}},[ge]),k.useEffect(()=>BA(),[]),k.useEffect(()=>{if(!(!Z.registration||pe.status!=="on"))return CA({registration:Z.registration,identity:Xe.identity,onEvent:P0})},[pe.status,pe.bindingId,Z.registration]),k.useEffect(()=>{const W=()=>xe(V=>({...V,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,"",Nr()),h.current=window.matchMedia("(min-width: 861px)");const W=()=>{const le=of(window.location.pathname);l.current?.abort(),a.current+=1,s(null),he({type:"route",route:le}),j.current&&le.name==="chats"&&le.contactCid&&(j.current=!1,requestAnimationFrame(()=>document.querySelector("[data-contact-trigger]")?.focus({preventScroll:!0}))),le.name==="chats"&&le.contactCid&&ot(le.contactCid)},V=()=>{if(document.visibilityState!=="visible")return;const le=Ir(c.current);le&&_t(le),N0(),Z.registration&&cv(Z.registration).then(xe).catch(()=>xe(Ne=>({...Ne,status:"error"})))};window.addEventListener("popstate",W),document.addEventListener("visibilitychange",V);const q=le=>{const Ne=le.type==="sync_required"?`${le.type}:${le.reason}`:le.type==="receipt_received"?`${le.type}:${le.contact_id}:${le.kind}:${le.wire_ids.join(",")}`:`${le.type}:${le.contact_id}:${le.wire_id}`,ut=Date.now(),kt=p.current.get(Ne)??0;p.current.set(Ne,ut);for(const[$e,Ye]of p.current)ut-Ye>6e4&&p.current.delete($e);ut-kt<6e4||(async()=>{if(le.type==="sync_required"){await at();return}if(gt().catch(ge),le.type==="file_received"){await At(le.contact_id,le.wire_id);const $e=c.current.contacts.contacts.find(Ye=>Ye.container_id===le.contact_id);Ir(c.current)!==le.contact_id&&$e&&te(le.contact_id,Ml($e),"New file");return}if(le.type==="message_received"){const $e=c.current.contacts.contacts.find(Ye=>Ye.container_id===le.contact_id);await qe(le.contact_id,Ye=>Ye.messages.some(Le=>Le.wire_id===le.wire_id),`message:${le.wire_id}`),Ir(c.current)===le.contact_id?await _t(le.contact_id):$e&&te(le.contact_id,Ml($e),"New message");return}he({type:"receipt",contactCid:le.contact_id,kind:le.kind,wireIds:le.wire_ids}),await qe(le.contact_id,$e=>le.wire_ids.every(Ye=>{const Le=$e.messages.find($t=>$t.wire_id===Ye);return!!Le?.receipt&&zx[Le.receipt]>=zx[le.kind]}),`receipt:${le.wire_ids.join(",")}`)})().catch(ge)},re=wA(q),de=kA(q,le=>he({type:"connection",connection:le}));return at().then(le=>{le&&ot(le)}),()=>{de(),re(),window.removeEventListener("popstate",W),document.removeEventListener("visibilitychange",V)}},[qe,At,he,_t,ot,te,gt,at,ge,Z.registration]);const jt=(W,V,q)=>{window.history.pushState({oursMessenger:!0},"",V),he({type:"route",route:W,mobileDetailOpen:q})},Gt=async W=>{jt({name:"chats",contactCid:W},Nr(W),!0),await ot(W)},Fn=async W=>{const V=ar(c.current,W);if(!(!V?.nextBefore||R.current.has(W))){R.current.add(W),E(W);try{const q=await Xe.conversation(W,V.nextBefore);he({type:"older_page",contactCid:W,page:q,newer:V.messages})}catch(q){ge(q)}finally{R.current.delete(W),E(null)}}},Oe=Ir(t),yt=t.contacts.contacts.find(W=>W.container_id===Oe),En=k.useMemo(()=>n4(t,v),[t,v]),G=En.find(W=>W.id===Oe)??null,se=Oe?pS(ar(t,Oe),v[Oe]??[]):[],Pe=t.identity;k.useEffect(()=>{if(!t.loaded)return;const W=of(window.location.pathname),V=W.name==="chats"||W.name==="contact"?W.contactCid:null;!V||t.contacts.contacts.some(q=>q.container_id===V)||(window.history.replaceState({oursMessenger:!0},"",Nr()),i?.contactCid===V&&(l.current?.abort(),a.current+=1,s(null)))},[t.loaded,t.contacts.contacts,i]);const De=t.loaded?Oe&&!ar(t,Oe)||F?"updating":t.connection!=="live"?"connecting":null:"connecting",ze=async(W,V=pe.preview)=>{if(Z.registration){fe(!0),xe(q=>({...q,status:"repairing",preview:V}));try{xe(await(W==="enable"?j0(Z.registration,{preview:V}):W==="repair"?zA(Z.registration,V):VA(Z.registration,pe)))}catch(q){xe(re=>({...re,status:"error"})),ge(q)}finally{fe(!1)}}},lt=()=>{K([]),T("invite"),Xe.invites().then(K).catch(ge)};return t.route.name==="not_found"?y.jsxs("div",{className:"centered-screen",children:[y.jsx("h1",{children:"Page not found"}),y.jsx("button",{className:"btn primary",onClick:()=>jt({name:"chats",contactCid:null},Nr()),children:"Open chats"})]}):Pe?y.jsx("div",{className:M?"theme-dark":"",style:{height:"100%"},children:y.jsxs("div",{className:"app signal-app",children:[y.jsxs("main",{className:"section signal-stage"+(t.mobileDetailOpen?" show-detail":""),children:[y.jsx(Az,{contacts:En,roots:t4(t.contacts),selected:Oe,onSelect:W=>{W.startsWith("pending:")||Gt(W)},onInvite:lt,onSettings:()=>T("settings"),onApprovePending:async W=>{try{return await Xe.respondToIntroduction(W,"approve"),await at(),!0}catch(V){return ge(V),!1}},onRejectPending:async W=>{try{return await Xe.respondToIntroduction(W,"reject"),await at(),!0}catch(V){return ge(V),!1}}}),t.route.name==="contact"&&G?y.jsx(jz,{contact:G,messages:se,onBack:()=>{j.current=!0,RA(window.history.state)==="back"?window.history.back():(window.history.replaceState({oursMessenger:!0},"",Nr(G.id)),he({type:"route",route:{name:"chats",contactCid:G.id},mobileDetailOpen:!0}),requestAnimationFrame(()=>document.querySelector("[data-contact-trigger]")?.focus({preventScroll:!0})),j.current=!1)},onRename:W=>void Xe.renameContact(G.id,W).then(at).catch(ge),onRemove:()=>{confirm(`Remove “${yt?.name??"contact"}”?`)&&Xe.removeContact(G.id).then(()=>(window.history.replaceState({oursMessenger:!0},"",Nr()),he({type:"route",route:{name:"chats",contactCid:null},mobileDetailOpen:!1}),at())).catch(ge)},onOpenMessage:W=>{jt({name:"chats",contactCid:G.id},Nr(G.id),!0);let V=12;const q=()=>{const re=document.getElementById(`chat-message-${encodeURIComponent(W)}`),de=re?.closest(".messages");if((!re||!de||de.clientHeight<=0)&&V-- >0){requestAnimationFrame(q);return}if(!re||!de)return;const le=re.getBoundingClientRect(),Ne=de.getBoundingClientRect(),ut=de.scrollTop+le.top-Ne.top-Math.max(0,(de.clientHeight-le.height)/2),kt=Math.max(0,Math.min(ut,de.scrollHeight-de.clientHeight));de.scrollTo({top:kt,behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"})};requestAnimationFrame(q)},indexOffset:ar(t,G.id)?.hasMore?Math.max(1,(ar(t,G.id)?.total??se.length)-se.length):0,onSendText:async(W,V)=>{const q=await Xe.send(G.id,W,V);return await He(G.id,!1),q.wire_id??void 0},onSendFile:async(W,V)=>{await Xe.sendFile(G.id,new Blob([W.bytes],{type:W.mime}),W.filename,W.mime,V),await Promise.all([tt(G.id),He(G.id,!1)])}}):y.jsx(Mz,{contact:G,messages:se,syncing:De,unreadOpen:i?.contactCid===Oe?i:null,hiddenEarlier:ar(t,Oe??"")?.hasMore?Math.max(1,(ar(t,Oe??"")?.total??se.length)-se.length):0,onLoadEarlier:Oe&&C!==Oe?()=>void Fn(Oe):void 0,onBack:()=>{l.current?.abort(),a.current+=1,s(null),jt({name:"chats",contactCid:null},Nr(),!1)},onOpenContact:()=>{Oe&&jt({name:"contact",contactCid:Oe},PA(Oe),!0)},onDraftChange:Te,onSend:async(W,V,q)=>{if(!Oe)return;const re=Oe,de=await Xe.send(re,W,V,q);return he({type:"sent_message",contactCid:re,message:{dir:"out",text:W,date:new Date().toISOString(),read:!0,wire_id:de.wire_id??"",receipt:null,reply_to:V?{wire_id:V}:null}}),de.wire_id?qe(re,le=>le.messages.some(Ne=>Ne.wire_id===de.wire_id),`send:${de.wire_id}`):gt().catch(ge),de.wire_id??void 0},onLoadCommands:async(W,V)=>Xe.commands(W,V),onSendCommand:async(W,V,q,re,de,le)=>{const Ne=await Xe.sendCommand(W,V,q,re,de,le);return He(W,!1),Ne},onSendFile:async(W,V)=>{Oe&&(await Xe.sendFile(Oe,new Blob([W.bytes],{type:W.mime}),W.filename,W.mime,V),await Promise.all([tt(Oe),He(Oe,!1)]))},onFetchFile:async W=>{await Xe.fetchFiles([W]),Oe&&await tt(Oe)}},Oe??"no-conversation")]}),y.jsxs("div",{className:"app-banners",children:[Z.offline&&y.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:"Offline — reconnecting to the network…"}),t.connection!=="live"&&y.jsx("div",{className:"banner warn",role:"status","aria-live":"polite",children:t.connection==="retrying"?"Live updates interrupted — reconnecting…":"Connecting to live updates…"}),Z.updateAvailable&&y.jsxs("div",{className:"banner info",children:[y.jsx("span",{role:"status","aria-live":"polite",children:"A new version is available."}),y.jsx("span",{className:"banner-actions",children:y.jsx("button",{className:"linkbtn",onClick:()=>{Z.registration&&lv(Z.registration)},children:"Restart now"})})]}),y.jsx(Vz,{items:N,onDismiss:me,onOpen:W=>void Gt(W)})]}),A==="invite"&&y.jsx(Uz,{identity:Pe,invites:D,onRefresh:async()=>K(await Xe.invites()),onCreate:async(W,V)=>(await Xe.createInvite(W,V)).blob,onAccept:async(W,V)=>{await Xe.addContact(W,V),await at()},onRevoke:async W=>{await Xe.revokeInvite(W)},onClose:()=>{T(null),at()}}),A==="settings"&&y.jsx(Wz,{identity:Pe,push:pe,workerSupported:Z.supported,busy:Q,offline:Z.offline,updateAvailable:Z.updateAvailable,build:$,dark:M,onToggleDark:()=>Y(W=>(localStorage.setItem(Vx,W?"0":"1"),!W)),onSaveBio:async W=>{await Xe.setBio(W),await at()},onPushAction:ze,onInstall:B?()=>void B.prompt().then(()=>ce(null)):void 0,onReloadUpdate:()=>{Z.registration&&lv(Z.registration)},onClose:()=>{P.current=null,T(null),Oe&&_t(Oe)}}),t.error&&y.jsxs("div",{className:"banner error",role:"alert","aria-live":"assertive",children:[t.error,y.jsx("button",{className:"linkbtn",onClick:()=>he({type:"error",message:null}),children:"dismiss"})]})]})}):y.jsx("div",{className:M?"theme-dark":"",style:{height:"100%"},children:y.jsx("div",{className:"centered-screen",children:y.jsx("p",{className:"muted",children:"Loading…"})})})}Zz();const mS=document.getElementById("root");if(!mS)throw new Error("missing #root");vC.createRoot(mS).render(y.jsx(mR,{reducedMotion:"user",children:y.jsx(r4,{})}));export{Mh as _,Vd as g};
|
|
326
|
+
//# sourceMappingURL=index-hasCROMp.js.map
|