@agimon-ai/po-cloudflare 0.0.2-alpha.74 → 0.0.2-alpha.76
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/{approval-DXPV7Vm5.js → approval-BlHIxC2J.js} +18 -5
- package/dist/{approvalPrompt-CBaxjb_g.js → approvalPrompt-w2k884MA.js} +25 -3
- package/dist/{approvalSession-C9bg7tPo.js → approvalSession-UtzXVEB4.js} +6 -4
- package/dist/assets/assets/{CodeEditorView-CfrVwzvL.js → CodeEditorView-CaFk98Ji.js} +2 -2
- package/dist/assets/assets/{abnfDiagram-WEYOIA3C-B80H4Cm4.js → abnfDiagram-WEYOIA3C-gzdpxFaJ.js} +2 -2
- package/dist/assets/assets/{architecture-WOLXFQ4H-Dr4hXaql.js → architecture-WOLXFQ4H-TugrtWoO.js} +1 -1
- package/dist/assets/assets/{architectureDiagram-ZHVYKT53-DWyt7oXu.js → architectureDiagram-ZHVYKT53-Xy_pnmaH.js} +2 -2
- package/dist/assets/assets/{blockDiagram-RJAE7QA3-OxNTLdmi.js → blockDiagram-RJAE7QA3-pH1-jWYL.js} +2 -2
- package/dist/assets/assets/{c4Diagram-XDPPPE54-B4YtcH0s.js → c4Diagram-XDPPPE54-CWmWk7y2.js} +2 -2
- package/dist/assets/assets/channel-CJxh7kPr.js +2 -0
- package/dist/assets/assets/{chunk-2E7WHVMD-CD6FFMOX.js → chunk-2E7WHVMD-C2O60zos.js} +2 -2
- package/dist/assets/assets/{chunk-4EMNKR2T-CEIoX5oo.js → chunk-4EMNKR2T-CEHzGYY0.js} +2 -2
- package/dist/assets/assets/{chunk-55XCU76K-CD3t0IJi.js → chunk-55XCU76K-CjyzuqJm.js} +2 -2
- package/dist/assets/assets/{chunk-7S6XSTFO-Cyt75UCF.js → chunk-7S6XSTFO-Db8_vjDs.js} +2 -2
- package/dist/assets/assets/{chunk-AQDTSKZB-DRtqYBj9.js → chunk-AQDTSKZB-92c_fipW.js} +2 -2
- package/dist/assets/assets/{chunk-DSNLSHJZ-C8Fx2F8s.js → chunk-DSNLSHJZ-DFGW_rzV.js} +2 -2
- package/dist/assets/assets/{chunk-HAGFOTED-wOLWRRnd.js → chunk-HAGFOTED-Cpx79XgA.js} +2 -2
- package/dist/assets/assets/{chunk-HNE4Q36P-CurJg4Hf.js → chunk-HNE4Q36P-cz6K5cWs.js} +2 -2
- package/dist/assets/assets/{chunk-NQOKRVIF-Dzcc5nOG.js → chunk-NQOKRVIF-Bhj8Cnrq.js} +2 -2
- package/dist/assets/assets/{chunk-UHW7PFBP-B_ULFf2h.js → chunk-UHW7PFBP-DugRZU3d.js} +2 -2
- package/dist/assets/assets/{chunk-VQ5W62QI-DH0VY4_p.js → chunk-VQ5W62QI-CFXU98Td.js} +2 -2
- package/dist/assets/assets/{chunk-WQQL4CDK-DNxfLyXM.js → chunk-WQQL4CDK-BDYjxxgH.js} +2 -2
- package/dist/assets/assets/chunk-XXDRQBXY-B7vCmBOn.js +2 -0
- package/dist/assets/assets/{chunk-YZO67HFG-COuMUh9U.js → chunk-YZO67HFG-Bw3Zv3ms.js} +2 -2
- package/dist/assets/assets/{chunk-ZAUX2LTX-BJrCnubF.js → chunk-ZAUX2LTX-reWd5PI6.js} +2 -2
- package/dist/assets/assets/{chunk-ZCHMQSOR-D1lFKPtk.js → chunk-ZCHMQSOR-RCmNKJ0K.js} +2 -2
- package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-DfZIbyVL.js → classDiagram-v2-4MYWR3UA-DOBOI7kO.js} +2 -2
- package/dist/assets/assets/{cose-bilkent-JH36ORCC-CpGhv9_S.js → cose-bilkent-JH36ORCC-Dnga9ThU.js} +2 -2
- package/dist/assets/assets/{cynefin-EF2NZ3EQ-Cxdc6nQl.js → cynefin-EF2NZ3EQ-mbxppeTd.js} +1 -1
- package/dist/assets/assets/{cynefinDiagram-WF24UDRP-qoj0w3lp.js → cynefinDiagram-WF24UDRP-D5uSCW7P.js} +2 -2
- package/dist/assets/assets/{dagre-NK4GIZVX-DL6QbNDS.js → dagre-NK4GIZVX-D3Utujwv.js} +2 -2
- package/dist/assets/assets/{diagram-CBK3MWTC-CJB3jq1_.js → diagram-CBK3MWTC-Bg8QfzPb.js} +2 -2
- package/dist/assets/assets/{diagram-I5XIIV2D-4cPOxCxF.js → diagram-I5XIIV2D-NjETU96V.js} +2 -2
- package/dist/assets/assets/{diagram-ODIL2UCW-BG3-jAxE.js → diagram-ODIL2UCW-BRY10xxY.js} +2 -2
- package/dist/assets/assets/{diagram-PFBEJUXE-Bx8dFaXj.js → diagram-PFBEJUXE-CO5Nfc2a.js} +2 -2
- package/dist/assets/assets/{diagram-RJA3I4VV-CUUHND91.js → diagram-RJA3I4VV-jxuLnXXk.js} +2 -2
- package/dist/assets/assets/{diagram-TYUNFSNR-BDMoN-kr.js → diagram-TYUNFSNR-B-dUsynt.js} +2 -2
- package/dist/assets/assets/{dist-5AxNm-uy.js → dist-9C1WeAys.js} +2 -2
- package/dist/assets/assets/{dist-BjI0b36Z.js → dist-BMmgMuDM.js} +2 -2
- package/dist/assets/assets/{dist-9_Rmyj2I.js → dist-Bsp48Zck.js} +2 -2
- package/dist/assets/assets/{dist-BE3CLKv4.js → dist-C8son2cz.js} +2 -2
- package/dist/assets/assets/{dist-CjCWP21A.js → dist-CUuM0eUM.js} +2 -2
- package/dist/assets/assets/{dist-BfNCu-7x.js → dist-CXebcDwS.js} +2 -2
- package/dist/assets/assets/{dist-Ccxb9U1G.js → dist-DtWJqHVb.js} +2 -2
- package/dist/assets/assets/{dist-CM7b5P9a.js → dist-JCg255PN.js} +2 -2
- package/dist/assets/assets/{dist-DSTAktnR.js → dist-lOIB9DJk.js} +2 -2
- package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-BivOMXZb.js → ebnfDiagram-V4P3TTPT-KNVNlIfc.js} +2 -2
- package/dist/assets/assets/{elk-QONTBCTQ-CrJ1Qpy_.js → elk-QONTBCTQ-DsX7hxD1.js} +2 -2
- package/dist/assets/assets/{erDiagram-KYQIGQAA-w9Bqp4sV.js → erDiagram-KYQIGQAA-pjQN44eX.js} +2 -2
- package/dist/assets/assets/{eventmodeling-K75KTNOO-CBjFM3kV.js → eventmodeling-K75KTNOO-BCKz9w4V.js} +1 -1
- package/dist/assets/assets/flowDiagram-IUGLLWBU-BU7xmb8h.js +1 -0
- package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CsWtGaqD.js → ganttDiagram-R7GPNTJY-CeuiGYpW.js} +2 -2
- package/dist/assets/assets/{gitGraph-VSP46ZUC-DsBSV9_h.js → gitGraph-VSP46ZUC-BsN0Vwsr.js} +1 -1
- package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-D5GxuYHW.js → gitGraphDiagram-PDYL7XHY-ZIMBu3bo.js} +2 -2
- package/dist/assets/assets/{index-DWDYnZsq.js → index-fYkh5qQp.js} +86 -86
- package/dist/assets/assets/{info-OHQRW6UA-C7x5dSJu.js → info-OHQRW6UA-CJmrVYr6.js} +1 -1
- package/dist/assets/assets/{infoDiagram-MVDRKAX5-CwpI-uAa.js → infoDiagram-MVDRKAX5-BsAIEQmU.js} +2 -2
- package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-DAa7J5G6.js → ishikawaDiagram-HPEHV2GE-BX_86A9r.js} +2 -2
- package/dist/assets/assets/{journeyDiagram-BOSHW7O7-BmiZnxE_.js → journeyDiagram-BOSHW7O7-DVGI0WoP.js} +2 -2
- package/dist/assets/assets/{kanban-definition-FNSA4HC5-DUR_mA3L.js → kanban-definition-FNSA4HC5-4RLBwWbL.js} +2 -2
- package/dist/assets/assets/{line-DHY49wSg.js → line-BL8hbik-.js} +2 -2
- package/dist/assets/assets/{linear-pTo-a9xT.js → linear-BWVrkBYc.js} +2 -2
- package/dist/assets/assets/{mermaid-parser.core-DMg3hN3T.js → mermaid-parser.core-CMk5l3Wp.js} +4 -4
- package/dist/assets/assets/{mermaid.core-DKtPCltA.js → mermaid.core-DZuf73R_.js} +5 -5
- package/dist/assets/assets/{mindmap-definition-6OY57UG3-DwTkFbnV.js → mindmap-definition-6OY57UG3-CPuk1tgo.js} +2 -2
- package/dist/assets/assets/{packet-JDAUHWVQ-Tu9TrQ1x.js → packet-JDAUHWVQ-pVue6YBL.js} +1 -1
- package/dist/assets/assets/{pegDiagram-ECIUJNBX-B7My4tsz.js → pegDiagram-ECIUJNBX-B8Ly6ehm.js} +2 -2
- package/dist/assets/assets/{pie-XZMESJXO-QPQm5Gdx.js → pie-XZMESJXO-DXAHc3bX.js} +1 -1
- package/dist/assets/assets/{pieDiagram-GNMPY74T-Bv-zAD_z.js → pieDiagram-GNMPY74T-9nVo6xZM.js} +2 -2
- package/dist/assets/assets/{quadrantDiagram-D57K4MC3-HTjoGQPd.js → quadrantDiagram-D57K4MC3-DbBqshQw.js} +2 -2
- package/dist/assets/assets/{radar-ABXABTNO-LDBlEoFo.js → radar-ABXABTNO-CKPxbvS6.js} +1 -1
- package/dist/assets/assets/{railroad-I3PHUGI6-Dy3_ymgZ.js → railroad-I3PHUGI6-CULlMjWr.js} +1 -1
- package/dist/assets/assets/{railroad-abnf-LNEFI6M7-QLVvYs6e.js → railroad-abnf-LNEFI6M7-BRjXoZsa.js} +1 -1
- package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CFRlv9a8.js → railroad-ebnf-DWYD2UWJ-CD_uPeUF.js} +1 -1
- package/dist/assets/assets/{railroad-peg-JR7BVNR7-BOlq3d9c.js → railroad-peg-JR7BVNR7-Cv-b3SRa.js} +1 -1
- package/dist/assets/assets/{railroadDiagram-Y72NRBL7-Chg32HoU.js → railroadDiagram-Y72NRBL7-DJ77wAhA.js} +2 -2
- package/dist/assets/assets/{requirementDiagram-EQYSW5RA-VenIs_eg.js → requirementDiagram-EQYSW5RA-R7PFvkp-.js} +2 -2
- package/dist/assets/assets/{sankeyDiagram-SY24JHO5-BdByqMKF.js → sankeyDiagram-SY24JHO5-DR2gLc8z.js} +2 -2
- package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-D3Do4GJE.js → sequenceDiagram-BLEHNHQU-TwEQL0yK.js} +2 -2
- package/dist/assets/assets/{src-DmfN-DA-.js → src-Cv8dmcJt.js} +2 -2
- package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-CZkRbPlf.js → stateDiagram-v2-A6IESKWZ-ShloXczl.js} +2 -2
- package/dist/assets/assets/{swimlanes-B3ENRKFQ-DRTdF9AF.js → swimlanes-B3ENRKFQ-D17E07lx.js} +2 -2
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-i6-zDqZm.js +9 -0
- package/dist/assets/assets/{timeline-definition-JXYKGLGB-BVcuws_M.js → timeline-definition-JXYKGLGB-BEvN2l_s.js} +2 -2
- package/dist/assets/assets/{treeView-D4JQ5SDB-BLtOJGqO.js → treeView-D4JQ5SDB-B0QcYOKz.js} +1 -1
- package/dist/assets/assets/{treemap-SAJKECNS-Dn3BWJ4v.js → treemap-SAJKECNS-CIGIJniE.js} +1 -1
- package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-CBExIKDY.js → usecaseDiagram-WPOLBNNX-DbS-GLv8.js} +2 -2
- package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-C6FIx2L4.js → vennDiagram-Q3Y3IDCW-CEkmUNoT.js} +2 -2
- package/dist/assets/assets/{wardley-7MLQ67FV-Cjj2xSBp.js → wardley-7MLQ67FV-D9b-h7oE.js} +1 -1
- package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-sQPCBCFK.js → wardleyDiagram-IVAIDKWA-BoWIYn_M.js} +2 -2
- package/dist/assets/assets/{webpack-DDCA0aDL.js → webpack-rEg3nylj.js} +2 -2
- package/dist/assets/assets/{xychartDiagram-4URNHDU4-bZ4rifSw.js → xychartDiagram-4URNHDU4-xJdWE_nx.js} +2 -2
- package/dist/assets/bundle-asset-policy.json +1 -1
- package/dist/assets/index.html +1 -1
- package/dist/assets/plugins/chunks/po-web-runtime-CQ9hLtG-.js +1 -0
- package/dist/assets/plugins/compositions.json +1 -1
- package/dist/assets/plugins/slots/approval.09e72f36-B4Y8Wjzl.js +2 -0
- package/dist/assets/plugins/slots/artifacts.50b639bb-5Kf50LM1.js +1 -0
- package/dist/assets/plugins/slots/author.ea449ace-BUAjd0RY.js +93 -0
- package/dist/assets/plugins/slots/{autocompact.ec8f713f-CDZpN7I7.js → autocompact.6f428144-DUwf4L4s.js} +1 -1
- package/dist/assets/plugins/slots/{backdrop-bamboo.1a4d85e9-qbifuMc6.js → backdrop-bamboo.6e4c928d-CT9PXrny.js} +1 -1
- package/dist/assets/plugins/slots/browse.fa1f1a50-ClrBioNv.js +1 -0
- package/dist/assets/plugins/slots/builtin-tools.75108f21-DmtavYBT.js +7 -0
- package/dist/assets/plugins/slots/calendar.d8b70190-DmudDrcG.js +2 -0
- package/dist/assets/plugins/slots/codemode.c58fb583-BkVR1X2Y.js +11 -0
- package/dist/assets/plugins/slots/domain.753f9f92-Bv-dlY79.js +1 -0
- package/dist/assets/plugins/slots/edit.804fec90-mJXCIk4G.js +7 -0
- package/dist/assets/plugins/slots/files.66ffc636-CCRW8t1-.js +2 -0
- package/dist/assets/plugins/slots/goal.45dffa01-q_Zh5QxW.js +1 -0
- package/dist/assets/plugins/slots/grep.98262cff-CTDwtVaK.js +1 -0
- package/dist/assets/plugins/slots/help.5fbd20f7-BBw7NYJI.js +3 -0
- package/dist/assets/plugins/slots/{log.07fd59a4-BRPa3cVs.js → log.cb964209-BLY7IzD1.js} +4 -4
- package/dist/assets/plugins/slots/mcp.82cc1ff5-5yoTabz8.js +55 -0
- package/dist/assets/plugins/slots/plan.3852ba52-DmdaEVVw.js +3 -0
- package/dist/assets/plugins/slots/profile.ab16dcec-DOw3MhWl.js +1 -0
- package/dist/assets/plugins/slots/prompts.ae48c07a-DQVmTxFZ.js +38 -0
- package/dist/assets/plugins/slots/read.4560591a-Bun0fKn1.js +1 -0
- package/dist/assets/plugins/slots/runner.6e494d59-BDtBIqmQ.js +9 -0
- package/dist/assets/plugins/slots/scaffold.d87a6ee0-DZOiNwOS.js +1 -0
- package/dist/assets/plugins/slots/session-mcp.2be84084-DQpF2DkA.js +2 -0
- package/dist/assets/plugins/slots/sessions.6f47cb4c-y61JDvak.js +1 -0
- package/dist/assets/plugins/slots/skill.62a0a1b3-C-mkriRv.js +4 -0
- package/dist/assets/plugins/slots/{space.056e8bbc-fbLHc-DX.js → space.65a27e5a-Cr1HSI_z.js} +1 -1
- package/dist/assets/plugins/slots/subagents.8bb9992c-CrpR1Jhi.js +7 -0
- package/dist/assets/plugins/slots/template-advanced.59f3f98a-CSuMHJ9x.js +1 -0
- package/dist/assets/plugins/slots/template-desktop.0f0b8491-C2ZheI0_.js +7 -0
- package/dist/assets/plugins/slots/template-elegant.0e3b0acf-Cq5Y_6VL.js +1 -0
- package/dist/assets/plugins/slots/vault.3cbfcdc3-ZKO66wy8.js +1 -0
- package/dist/assets/plugins/slots/voice.a952113d-CsdoPA4G.js +1 -0
- package/dist/assets/plugins/slots/{web-search.f6292793-NVh9fdvE.js → web-search.65013836-C7W5RyLj.js} +1 -1
- package/dist/assets/plugins/slots/workflows.cbc5c5c0-BLNlHcfa.js +16 -0
- package/dist/assets/pwa/sw.js +5 -5
- package/dist/{calendarSetup-CI3AACVo.js → calendarSetup-Do-hM0Li.js} +1 -1
- package/dist/{exports-CBp_9dVk.js → exports-t_BpzyPr.js} +1 -1
- package/dist/{index.edge-kJrIbDzE.js → index.edge-BRaAhap2.js} +1 -1
- package/dist/{profileSources-D1rymC97.js → profileSources-DIlA86Qk.js} +1 -1
- package/dist/{server-BcPD_6a2.js → server-2xgrdxY_.js} +2 -2
- package/dist/{server-B51reaJ9.js → server-7-DnO2Ww.js} +5 -4
- package/dist/{server-DebdjWjz.js → server-B3U0W7zD.js} +1 -1
- package/dist/{server-B3jB3q_h.js → server-BJssIIpm.js} +1 -1
- package/dist/{server-NKqdiQ5G.js → server-BLcw1z6S.js} +1 -1
- package/dist/{server-Byk0FT6E.js → server-BPS6xFya.js} +1 -1
- package/dist/{server-DLDK_aeG.js → server-BSpJMYLb.js} +2 -2
- package/dist/{server-BsjwqF7J.js → server-BUBijhBb.js} +2 -2
- package/dist/{server-CUGzeCH4.js → server-BUgDdcRW.js} +1 -1
- package/dist/{server-EYARWKpG.js → server-BeAYfrzJ.js} +1 -1
- package/dist/{server-DEKg8AVN.js → server-BlbuM_IJ.js} +2 -2
- package/dist/{server-_vSe9bTM.js → server-BqvkcVLn.js} +1 -1
- package/dist/{server-Dosi6o2W.js → server-CKQwNrO8.js} +4 -4
- package/dist/{server-B20agHjD.js → server-CLRgSPVY.js} +1 -1
- package/dist/{server-DYKXGQVY.js → server-CMov-S5-.js} +1 -1
- package/dist/{server-BsEMLlTz.js → server-CaFzaibK.js} +1 -1
- package/dist/{server-wQHKuB2m.js → server-CcKKktvn.js} +1 -1
- package/dist/{server-dBNqYUdX.js → server-D6-_DT9g.js} +1 -1
- package/dist/{server-vZL2icDV.js → server-DAFM6HnJ.js} +2 -2
- package/dist/{server-DI6YhDI5.js → server-DMbdJzSQ.js} +2 -2
- package/dist/{server-C-HBjWRo.js → server-DNpneoqA.js} +1 -1
- package/dist/{server-hJ4tYEt4.js → server-DPG7BH6w.js} +5 -5
- package/dist/{server-CpbBJ9ZU.js → server-DeFqeFTs.js} +1 -1
- package/dist/{server-BD_tbxwG.js → server-Dl3sng3O.js} +2 -2
- package/dist/{server-CqDWkfdL.js → server-Dnvp2U6V.js} +3 -3
- package/dist/{server-CQmb0lYL.js → server-HIbQWBba.js} +36 -17
- package/dist/{server-CAipGCpQ.js → server-OzzJbeaS.js} +2 -2
- package/dist/{server-DmqO6gBs.js → server-fYfb0gN8.js} +16 -8
- package/dist/{sessionConfig-UMlgu98q.js → sessionConfig-BYow7MOB.js} +1 -1
- package/dist/{web-B2sdV-F2.js → web-CLiZJpHK.js} +1 -1
- package/dist/worker.js +208 -130
- package/package.json +49 -49
- package/dist/assets/assets/channel-bXj00dGj.js +0 -2
- package/dist/assets/assets/chunk-XXDRQBXY-B2bMWgN9.js +0 -2
- package/dist/assets/assets/flowDiagram-IUGLLWBU-C6Fnfgm0.js +0 -1
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-BYr_4JUb.js +0 -9
- package/dist/assets/plugins/chunks/po-web-runtime-D8FIos2q.js +0 -1
- package/dist/assets/plugins/slots/approval.3e4ea6e4-DxS_uibk.js +0 -2
- package/dist/assets/plugins/slots/artifacts.84980c32-Cp37TAkd.js +0 -1
- package/dist/assets/plugins/slots/author.8eca1a3d-Ds9Y-tjN.js +0 -93
- package/dist/assets/plugins/slots/browse.61a8907a-CVYvo1M5.js +0 -1
- package/dist/assets/plugins/slots/builtin-tools.16ef5e25-Cq1ljoL-.js +0 -7
- package/dist/assets/plugins/slots/calendar.d337fc49-BBjpOs1v.js +0 -2
- package/dist/assets/plugins/slots/codemode.5f359b9c-DOR6OR7R.js +0 -11
- package/dist/assets/plugins/slots/domain.832848c8-CJrXxig9.js +0 -1
- package/dist/assets/plugins/slots/edit.7c802139-BFF7_xN9.js +0 -7
- package/dist/assets/plugins/slots/files.364f16c9-CzOlZrRm.js +0 -2
- package/dist/assets/plugins/slots/goal.a97b169d-BtQBp3sw.js +0 -1
- package/dist/assets/plugins/slots/grep.d8bf9f57-9bUDfjyT.js +0 -1
- package/dist/assets/plugins/slots/help.5c78c071-B4-y6gYK.js +0 -3
- package/dist/assets/plugins/slots/mcp.ea8b6aa2-CFtzPkPC.js +0 -55
- package/dist/assets/plugins/slots/plan.7b30f8d8-CH59Ff49.js +0 -3
- package/dist/assets/plugins/slots/profile.63bc3ae6-0e9fWWyE.js +0 -1
- package/dist/assets/plugins/slots/prompts.9d9b47cc-BTqYnBX5.js +0 -38
- package/dist/assets/plugins/slots/read.926c024f-C7fMXDEH.js +0 -1
- package/dist/assets/plugins/slots/runner.5393fa6c-CqrpqhW9.js +0 -9
- package/dist/assets/plugins/slots/scaffold.686222eb-9qY5gkYW.js +0 -1
- package/dist/assets/plugins/slots/session-mcp.8eb68fc9-Cf0cqopp.js +0 -2
- package/dist/assets/plugins/slots/sessions.8e378a3b-B1_eqPJQ.js +0 -1
- package/dist/assets/plugins/slots/skill.56c1cc07-D-SKX8iw.js +0 -4
- package/dist/assets/plugins/slots/subagents.31fc045b-Cm_YMEnn.js +0 -7
- package/dist/assets/plugins/slots/template-advanced.9e8350fe-L0WOM4JT.js +0 -1
- package/dist/assets/plugins/slots/template-desktop.69a46f62-By9BZlaL.js +0 -7
- package/dist/assets/plugins/slots/template-elegant.381f6acb-El05x7HK.js +0 -1
- package/dist/assets/plugins/slots/vault.587549ba-DpU_65Wy.js +0 -1
- package/dist/assets/plugins/slots/voice.9c687181-CvcuL__m.js +0 -1
- package/dist/assets/plugins/slots/workflows.8a13baad-OLKSY9PE.js +0 -16
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import{$i as e,$r as t,Aa as n,Ai as r,At as i,Ba as a,Bt as o,Cr as s,Da as c,Er as l,Ft as u,Ga as d,Ha as f,Ht as p,Ia as m,Ii as h,It as g,Kt as _,Lt as v,Mi as y,Mr as b,Nr as x,Oa as S,Pt as C,Qa as w,Sa as T,Sr as E,Ta as D,Tr as O,Wa as ee,Wt as te,_n as k,br as ne,da as re,eo as ie,fi as ae,fn as oe,gn as A,hn as j,jr as M,ka as N,kt as P,mn as F,qt as I,sa as se,ta as ce,ti as le,ui as L,un as ue,vn as de,wa as fe,xa as pe,xi as me,xr as he}from"../chunks/po-web-runtime-D8FIos2q.js";var ge={slot:`author.media-review`,description:`Provide the viewer action that opens an image or diagram from Markdown for annotation and feedback.`,parse:e=>{if(typeof e!=`object`||!e)return null;let t=e;return t.version===1&&typeof t.panel==`function`?t:null}},_e=`author_webmcp`,ve={text:`author.viewport.text`,media:`author.viewport.media`},ye=new P(0);function be(){return ye.setState(e=>e+1),`a${ye.state.toString(36)}_`}function xe(e){if(e.id.trim()===``)throw Error(`Author profile id must not be empty`);if(e.tools.length>15)throw Error(`Author profiles may expose at most 15 tools`);let t=new Set;for(let n of e.tools){if(!/^[a-z][a-z0-9_]{0,29}$/.test(n.name))throw Error(`Invalid Author tool name: ${n.name}`);if(t.has(n.name))throw Error(`Duplicate Author tool name: ${n.name}`);t.add(n.name)}}function Se(e,t){return e.name===t.name&&e.description===t.description&&JSON.stringify(e.inputSchema)===JSON.stringify(t.inputSchema)}function Ce(){return Error(`Author viewport catalog is stale`)}function we(e,t){let n=new AbortController,r=()=>n.abort(e.reason),i=()=>n.abort(t.reason);return e.aborted?r():t.aborted?i():(e.addEventListener(`abort`,r,{once:!0}),t.addEventListener(`abort`,i,{once:!0})),{signal:n.signal,release:()=>{e.removeEventListener(`abort`,r),t.removeEventListener(`abort`,i)}}}var Te=class{#e;#t=be();#n;#r;#i;#a=0;#o=!1;constructor(e){this.#e=e}async replaceProfiles(e){if(this.#o)throw Error(`Author runtime is disposed`);for(let t of e)xe(t);let t=new Map(e.map(e=>[e.id,e])),n=e.flatMap(e=>e.tools);if(new Set(n.map(e=>e.name)).size!==n.length)throw Error(`Author tool names must be unique across trusted profiles`);let r=this.#n??(await this.#e.acquireModelContext?.())?.modelContext;if(r===void 0)throw Error(`Model Context is unavailable`);this.#n=r;let i=new Map(n.map((e,t)=>[e.name,`${this.#t}${t.toString(36)}`])),a=++this.#a,o=new AbortController,s={generation:a,controller:o,profiles:t,registrations:i},c=Ce();this.#i?.controller.abort(c),this.#r?.controller.abort(c),this.#i=s,this.#r=void 0;let l=()=>{if(o.signal.aborted||this.#o||this.#r?.generation!==a)throw Ce()};try{await Promise.all(n.map(async e=>r.registerTool({name:i.get(e.name),description:e.description,inputSchema:e.inputSchema,execute:async(t,n)=>{l();let r=JSON.parse(t);l();let i=we(o.signal,n.signal);try{let t=await e.execute(r,i.signal);return l(),t}finally{i.release()}}},{signal:o.signal})));let e=await r.getTools();if(!n.every(t=>e.some(e=>Se(e,{...t,name:i.get(t.name)}))))throw Error(`Model Context did not confirm the Author catalog`);if(this.#o||a!==this.#a||this.#i!==s)throw Ce();this.#i=void 0,this.#r=s}catch(e){throw o.abort(e),this.#i===s&&(this.#i=void 0),e}return()=>{this.#r?.generation===a&&(o.abort(Ce()),this.#r=void 0,this.#a+=1)}}async execute(e,t,n){let r=this.#n;if(r===void 0||this.#r===void 0)throw Error(`Author catalog is not registered`);let i=this.#r.registrations.get(e);if(i===void 0)throw Error(`Unknown Author capability: ${e}`);return r.executeTool(i,JSON.stringify(t),{signal:n})}dispose(){this.#o||(this.#o=!0,this.#a+=1,this.#i?.controller.abort(Error(`Author runtime disposed`)),this.#r?.controller.abort(Error(`Author runtime disposed`)),this.#i=void 0,this.#r=void 0)}},R=(e,t)=>`${e}\n${t}`,Ee=1e4,De=new P({}),Oe=(e,t)=>{De.state[e]!==t&&De.setState(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r})},ke=new Set([`author_describe_grid`,`author_resolve_grid_cell`,`author_add_grid_note`]),Ae=e=>e.map(e=>({...e,tools:e.tools.filter(e=>!ke.has(e.name))})),je=class{#e;#t;#n=new Map;#r=new Map;#i=0;#a=!1;#o;constructor(e,t){this.#e=e,this.#t=t,this.#o=e.onHubConnected(()=>{for(let e of this.#n.values())e.ownerToken=void 0,e.catalogToken=void 0,this.#u(e)})}async open(e,t,n){if(this.#a)throw Error(`Author browser bridge is disposed`);await this.#s({sessionId:e,alias:t,profiles:Ae(n)})}async#s(e){let{sessionId:t,alias:n}=e,r=e.focus?.profiles??e.profiles,i=R(t,n);if(this.#a||this.#n.has(i))return;let a=this.#r.get(i);if(a!==void 0)return await a.promise;let o=new Te(this.#e),s=++this.#i,c;c=(async()=>{let a;try{a=await o.replaceProfiles(r)}catch(e){if(this.#a||this.#r.get(i)?.promise!==c)return;throw e}if(this.#a||this.#n.has(i)||this.#r.get(i)?.promise!==c){a(),o.dispose();return}let l={sessionId:t,alias:n,generation:s,profiles:r,intent:e,runtime:o,release:a,pending:new Map,replacementId:0};this.#n.set(i,l);let u=e.focus?.profiles??e.profiles;u===r?this.#u(l):await this.#l(l,u)})(),this.#r.set(i,{promise:c,runtime:o,intent:e});try{await c}finally{this.#r.get(i)?.promise===c&&this.#r.delete(i)}}async focus(e,t,n){await this.open(e,t,n);let r=R(e,t),i=this.#n.get(r),a=i?.intent??this.#r.get(r)?.intent;if(a===void 0)return()=>void 0;let o={profiles:n};return a.focus=o,i!==void 0&&await this.#l(i,n),()=>{if(a.focus!==o)return;a.focus=void 0;let e=this.#n.get(r);e?.intent===a&&this.#l(e,a.profiles)}}drop(e,t){for(let[n,r]of this.#r)r.intent.sessionId!==e||t!==void 0&&r.intent.alias!==t||(this.#r.delete(n),r.runtime.dispose());for(let n of this.#n.values())n.sessionId!==e||t!==void 0&&n.alias!==t||this.#c(n)}canvases(e,t){this.#t?.(this.#e,e,t);let n=new Set(t.map(e=>e.alias)),r=new Set;for(let{intent:t}of[...this.#r.values(),...this.#n.values()])t.sessionId===e&&!n.has(t.alias)&&r.add(t.alias);for(let t of r)this.drop(e,t)}apply(e,t){if(t.alias===void 0)return;let n=this.#n.get(R(e,t.alias));if(n===void 0)return;if(t.kind===`rejected`){Oe(R(e,t.alias),t.reason),clearTimeout(n.leaseTimer),n.leaseTimer=setTimeout(()=>this.#u(n),Ee);return}if(t.generation!==n.generation||t.ownerToken!==n.ownerToken&&n.ownerToken!==void 0)return;if(t.kind===`accepted`){Oe(R(e,t.alias),void 0),n.ownerToken=t.ownerToken,clearTimeout(n.leaseTimer),n.leaseTimer=setTimeout(()=>this.#u(n),Math.max(1e3,Math.floor(t.leaseMs/2))),t.catalogToken===void 0?this.#d(n):n.catalogToken=t.catalogToken;return}if(t.catalogToken!==n.catalogToken)return;if(t.kind===`cancel`){n.pending.get(t.requestId)?.abort(Error(`Author tool request cancelled`));return}if(t.kind!==`request`||n.pending.has(t.requestId))return;let r=new AbortController;n.pending.set(t.requestId,r),n.runtime.execute(t.name,t.arguments,r.signal).then(e=>{this.#m(n,t.requestId,r)&&(r.signal.aborted?this.#f(n,t.requestId):this.#p(n,{kind:`result`,alias:n.alias,generation:n.generation,ownerToken:n.ownerToken,catalogToken:n.catalogToken,requestId:t.requestId,result:e}))}).catch(e=>{if(this.#m(n,t.requestId,r)){if(r.signal.aborted)this.#f(n,t.requestId);else{let r=e instanceof Error?e.message:String(e),i=/^([A-Z][A-Z_]+):/u.exec(r)?.[1]??`AUTHOR_TOOL_ERROR`;this.#p(n,{kind:`result`,alias:n.alias,generation:n.generation,ownerToken:n.ownerToken,catalogToken:n.catalogToken,requestId:t.requestId,result:{error:{code:i,message:r}}})}}}).finally(()=>{n.pending.get(t.requestId)===r&&n.pending.delete(t.requestId)})}activeView(e){let t=[...this.#n.values()].filter(t=>t.sessionId===e&&t.catalogToken);return t.length>0?{activation:`active`,capabilityCount:t.reduce((e,t)=>e+t.profiles.reduce((e,t)=>e+t.tools.length,0),0)}:{activation:`inactive`,capabilityCount:0}}dispose(){if(!this.#a){this.#a=!0,this.#o();for(let e of this.#n.values())this.#c(e);for(let e of this.#r.values())e.runtime.dispose();this.#r.clear()}}#c(e){this.#n.delete(R(e.sessionId,e.alias)),Oe(R(e.sessionId,e.alias),void 0),this.#h(e),e.runtime.dispose()}async#l(e,t){let n=R(e.sessionId,e.alias);if(this.#a||this.#n.get(n)!==e)return;this.#h(e);let r=e.generation,i=++e.replacementId,a;try{a=await e.runtime.replaceProfiles(t)}catch(t){if(e.replacementId!==i||this.#n.get(n)!==e)return;throw t}this.#a||this.#n.get(n)!==e||e.generation!==r||e.replacementId!==i?a():(e.release=a,e.profiles=t,this.#u(e))}#u(e){this.#n.get(R(e.sessionId,e.alias))===e&&this.#p(e,{kind:`register`,alias:e.alias,generation:e.generation})}#d(e){this.#p(e,{kind:`catalog`,alias:e.alias,generation:e.generation,ownerToken:e.ownerToken,tools:e.profiles.flatMap(e=>e.tools.map(e=>({name:e.name,label:e.label??e.name,description:e.description,inputSchema:e.inputSchema})))})}#f(e,t){this.#p(e,{kind:`cancelled`,alias:e.alias,generation:e.generation,ownerToken:e.ownerToken,catalogToken:e.catalogToken,requestId:t})}#p(e,t){let n=this.#e.mount?.scope===`session`?this.#e.mount.workspaceId:void 0,r=n?{scope:`workspace`,workspaceId:n}:{scope:`host`};this.#e.invokeServerMethod({mount:r,service:`author.bridge`,method:`send`,input:{sessionId:e.sessionId.slice(e.sessionId.indexOf(`/`)+1),message:t}}).catch(n=>console.warn(`Author canvas '${e.alias}' could not send '${t.kind}': ${n instanceof Error?n.message:String(n)}`))}#m(e,t,n){return this.#n.get(R(e.sessionId,e.alias))===e&&e.pending.get(t)===n}#h(e){clearTimeout(e.leaseTimer),e.leaseTimer=void 0,this.#p(e,{kind:`release`,alias:e.alias,generation:e.generation}),e.release();for(let t of e.pending.values())t.abort(Error(`Author viewport changed`));e.pending.clear(),e.ownerToken=void 0,e.catalogToken=void 0,e.generation=++this.#i}},Me=`global`,Ne=new P(new Map),Pe=new P(new Map),Fe=e=>Ne.state.get(e)??Ne.state.get(Me);function Ie(e,t){let n=e.mount?.scope===`session`?e.mount.sessionId:Me;Ne.state.get(n)?.dispose();let r=new je(e,t);Ne.setState(e=>new Map(e).set(n,r));for(let[e,t]of Pe.state)(n===Me||n===e)&&r.canvases(e,t);return()=>{Ne.state.get(n)===r&&(r.dispose(),Ne.setState(e=>{let t=new Map(e);return t.delete(n),t}))}}async function Le(e,t,n){await Fe(e)?.open(e,t,n)}async function Re(e,t,n=`default`){return await Fe(e)?.focus(e,n,t)??(()=>void 0)}function ze(e,t){t.kind===`canvases`?(Pe.setState(n=>new Map(n).set(e,t.canvases)),Fe(e)?.canvases(e,t.canvases)):Fe(e)?.apply(e,t)}function Be(e,t){t===void 0&&Pe.state.has(e)&&Pe.setState(t=>{let n=new Map(t);return n.delete(e),n}),Fe(e)?.drop(e,t)}function Ve(e){return Fe(e)?.activeView(e)??{activation:`inactive`,capabilityCount:0}}var He=`ABCDEFGH`;function Ue(e){let t=e.trim().toUpperCase();if(!/^[A-H][1-8]$/u.test(t))throw Error(`Invalid Author grid cell '${e}'. Expected A1 through H8.`);return{cell:t,column:He.indexOf(t[0]),row:Number(t[1])-1}}var We=new Map,Ge=n({sessions:{}});function Ke(e,t){let n=Ge.store.state.sessions[e],r={...t,geometryToken:crypto.randomUUID(),snapshotId:n?.documentPath===t.documentPath&&n.revision===t.revision&&n.sourceSha256===t.sourceSha256?n.snapshotId:crypto.randomUUID(),updatedAt:Date.now()};return Ge.update(t=>({...t,sessions:{...t.sessions,[e]:r}})),r}function qe(e){return Ge.store.state.sessions[e]}function Je(e){Ge.update(t=>{if(t.sessions[e]===void 0)return t;let n={...t.sessions};return delete n[e],{...t,sessions:n}})}function Ye(e,t){return We.set(e,t),()=>{We.get(e)===t&&We.delete(e)}}function Xe(e,t){let n=qe(e),r=n===void 0?void 0:We.get(e)?.(t,n);if(r===void 0)throw Error(`AMBIGUOUS_GRID: The grid cell does not resolve to one visible native document target.`);return r}function Ze(e,t,n){let r=qe(e);if(r===void 0||r.geometryToken!==n)throw Error(`STALE_GRID: The Author grid geometry changed. Describe the grid again.`);let i=Ue(t),a=1/8,o=1/8,s={x:i.column*a,y:i.row*o,width:a,height:o};return{...i,rect:s,center:{x:s.x+a/2,y:s.y+o/2},evidence:{cell:i.cell,geometryToken:r.geometryToken,snapshotId:r.snapshotId}}}var Qe=[{format:`bold`,label:`Bold`,glyph:`B`},{format:`heading`,label:`Heading`,glyph:`H`},{format:`link`,label:`Link`,glyph:`↗`},{format:`list`,label:`List`,glyph:`≡`}],$e=/^#{1,6} /,et=/^(?:[-*+]|\d+[.)]) /;function tt(e,t,n,r){if(r===`bold`){let r=e.slice(t,n);if(r.length>=4&&r.startsWith(`**`)&&r.endsWith(`**`))return{from:t,to:n,insert:r.slice(2,-2),select:{from:t,to:n-4}};if(t>=2&&e.slice(t-2,t)===`**`&&e.slice(n,n+2)===`**`)return{from:t-2,to:n+2,insert:r,select:{from:t-2,to:n-2}};let i=r||`bold text`;return{from:t,to:n,insert:`**${i}**`,select:{from:t+2,to:t+2+i.length}}}if(r===`link`){let r=e.slice(t,n)||`link text`,i=t+r.length+3;return{from:t,to:n,insert:`[${r}](https://)`,select:{from:i,to:i+8}}}let i=e.lastIndexOf(`
|
|
2
|
-
`,t-1)+1,a=n>t&&e[n-1]===`
|
|
3
|
-
`?n-1:n,o=e.indexOf(`
|
|
4
|
-
`,Math.max(a,i)),s=o===-1?e.length:o,c=r===`heading`?$e:et,l=r===`heading`?`## `:`- `,u=e.slice(i,s).split(`
|
|
5
|
-
`),d=u.filter(e=>e.trim()!==``),f=d.length>0&&d.every(e=>c.test(e)),p=u.map(e=>e.trim()===``?e:f?e.replace(c,``):l+e.replace($e,``).replace(et,``)).join(`
|
|
6
|
-
`);return{from:i,to:s,insert:p,select:{from:i,to:i+p.length}}}function nt(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e[a]===t[a];)a+=1;let o=0;for(;o<i-a&&e[e.length-1-o]===t[t.length-1-o];)o+=1;let s=e.length-o,c=t.length-e.length,l=n<a?n:n>=s?n+c:a,u=r<=a?r:r>=s?r+c:t.length-o;return{start:l,end:Math.max(l,u)}}function rt(e,t){let n=0;return t.map(t=>{if(t.trim()===``)return;let r=e.indexOf(t,n),i=t.trimStart().split(`
|
|
7
|
-
`)[0],a=r===-1?e.indexOf(i,n):r;if(a!==-1)return n=a+(r===-1?i.length:t.length),a})}function it(e,t){return e.slice(0,t).split(`
|
|
8
|
-
`).length}var at=new Set([`COMPLETE`,`FAILED`,`CANCELLED`,`UNTRACKED`]),ot={generation:0,annotationsByDocument:{},toolsByDocument:{},requests:[]};function z(e){let t=[],n=e.trim().replaceAll(`\\`,`/`);for(let e of n.split(`/`))e!==``&&e!==`.`&&(e===`..`?t.pop():t.push(e));return`${n.startsWith(`/`)?`/`:``}${t.join(`/`)}`}function B(e,t){return`${e}\n${z(t)}`}var V=n({documents:{},sessions:{}});function H(e,t){if(e!==null)return V.store.state.documents[B(e,t)]}function U(e){return e===null?ot:V.store.state.sessions[e]??ot}var st=Object.freeze({revision:0,stale:!1,candidate:void 0,candidateText:``,annotations:Object.freeze([]),updatedAt:0});function W(e,t,n=V.store.state){if(e===null)return st;let r=n.documents[B(e,t)],i=n.sessions[e]?.annotationsByDocument[z(t)];return r!==void 0&&i!==void 0&&!i.stale&&i.revision===r.version&&i.sourceSha256===r.sourceSha256?i:st}function ct(e){V.update(t=>{let n=t.sessions;for(let r of e){let e=z(r.documentPath);if(e===``)continue;let i=n[r.sessionId]??ot,a=i.annotationsByDocument[e];if(a!==void 0&&a.updatedAt>=r.collection.updatedAt)continue;let o=t.documents[B(r.sessionId,e)],s=r.collection.stale||o!==void 0&&(o.version!==r.collection.revision||o.sourceSha256!==r.collection.sourceSha256),c=zt({...r.collection,stale:s});n={...n,[r.sessionId]:{...i,annotationsByDocument:{...i.annotationsByDocument,[e]:c}}}}return n===t.sessions?t:{...t,sessions:n}})}function lt(e,t){let n=z(t.path);if(n===``)throw Error(`Author document path must not be empty`);let r=B(e,n),i=[],a;return V.update(o=>{let s=o.documents[r],c=s?.sourceSha256!==void 0&&t.sourceSha256!==void 0&&s.sourceSha256!==t.sourceSha256,l=c?s.version+1:s?.version??0;a={...t,path:n,annotations:c?[]:s?.annotations??[],revisions:c?[]:s?.revisions??[],saveRequest:s?.saveRequest??0,version:l,savedVersion:c?l:s?.savedVersion??0,...c||s?.crop===void 0?{}:{crop:s.crop}};let u=o.sessions[e],d=o.sessions;if(c&&u!==void 0){let r=u.annotationsByDocument[n];r?.candidate?.thumbnailUrl!==void 0&&i.push(r.candidate.thumbnailUrl),i.push(...(r?.annotations??[]).flatMap(e=>e.thumbnailUrl===void 0?[]:[e.thumbnailUrl]));let a=Date.now(),o=Nt(r,a);d={...d,[e]:{...u,annotationsByDocument:{...u.annotationsByDocument,...o&&{[n]:o}},requests:u.requests.map(e=>t.kind!==`story-preview`&&e.documentPath===n&&[`REQUESTED`,`CHANGING`,`CHANGED`].includes(e.status)?{...e,status:`FAILED`,currentOperation:void 0,error:`The document source changed before the request completed.`,updatedAt:a}:e)}}}return{documents:{...o.documents,[r]:a},sessions:d}}),i.forEach(Bt),a}function ut(e,t){let n=0;return q(e,e=>{n=e.generation+1;let r={path:z(t),generation:n,focusedAt:Date.now()};return{...e,generation:n,focusedDocument:r,focusClaims:[...e.focusClaims??[],r]}}),n}function dt(e,t){q(e,e=>{let n=e.focusClaims??[];if(!n.some(e=>e.generation===t))return e;let r=n.filter(e=>e.generation!==t);return{...e,focusedDocument:r.at(-1),focusClaims:r}})}function ft(e,t,n){let r=z(t),i=U(e).focusedDocument;return i?.path!==r||W(e,r).candidate||!Number.isFinite(n)||n<0||H(e,r)?.kind!==`video`?!1:(G(e,r,`select`),q(e,e=>({...e,videoSeekRequest:{path:r,generation:i.generation,timeSeconds:n,sequence:(e.videoSeekRequest?.sequence??0)+1}})),!0)}function pt(e,t,n){let r=z(t);q(e,e=>{let t={...e.previewSelections};return n===void 0?delete t[r]:t[r]={...n},{...e,previewSelections:t}})}function G(e,t,n){let r=z(t);q(e,e=>({...e,toolsByDocument:{...e.toolsByDocument,[r]:n}}))}function mt(e,t,n){let r=H(e,t);if(r===void 0||z(n.documentPath)!==z(t))throw Error(`The Author selection does not belong to the document.`);if(r.version!==n.revision||r.sourceSha256!==n.sourceSha256)throw Error(`The Author selection is stale for the document.`)}function ht(e,t,n){n!==void 0&&mt(e,t,n);let r=W(e,t).candidate?.thumbnailUrl;Ft(e,t,e=>({...e,candidate:n&&jt(n)})),r!==void 0&&r!==n?.thumbnailUrl&&Bt(r)}function gt(e,t,n){if(new TextEncoder().encode(n).byteLength>2048)throw Error(`Author candidate text must not exceed 2 KiB.`);Ft(e,t,e=>({...e,candidateText:n}))}function _t(e,t,n){let r=W(e,t).candidate;if(r===void 0)throw Error(`Select a document annotation before adding a comment.`);let i=crypto.randomUUID();return vt(e,{...r,id:i,comment:n,version:1}),Ft(e,t,e=>({...e,candidate:void 0,candidateText:``})),i}function vt(e,t){if(t.comment.trim()===``)throw Error(`Every Author annotation requires a comment.`);mt(e,t.documentPath,t),Ft(e,t.documentPath,e=>{if(e.annotations.length>=16)throw Error(`Author requests support at most 16 annotations.`);if(e.annotations.some(e=>e.id===t.id))throw Error(`Author annotation '${t.id}' already exists.`);return{...e,annotations:[...e.annotations,Mt({...t,version:t.version??1})]}})}function yt(e,t,n,r){let i;Ft(e,t,e=>{let t=e.annotations.find(e=>e.id===n);return t===void 0||r!==void 0&&(t.version??1)!==r?e:(i=t.thumbnailUrl,{...e,annotations:e.annotations.filter(e=>e.id!==n)})}),i!==void 0&&Bt(i)}function bt(e,t){if(t.requestText.trim()===``)throw Error(`An Author request requires verbatim request text.`);if(t.regions.length===0||t.regions.some(e=>e.comment.trim()===``))throw Error(`An Author request requires at least one commented region.`);q(e,e=>{if(e.requests.some(e=>e.id===t.id))throw Error(`Author request '${t.id}' already exists.`);return{...e,requests:Rt([...e.requests,Lt(t)])}})}function xt(e,t,n){q(e,e=>({...e,requests:Rt(e.requests.map(e=>e.id===t?Lt(n(e)):e))}))}function St(e,t,n){K(e,t,e=>{if(e.content===n)return e;let t=e.version+1;return{...e,content:n,version:t,revisions:[...e.revisions,{revision:t,content:n}]}})}function Ct(e,t,n,r){K(e,t,e=>{let t=e.fragments?.find(e=>e.id===n);if(t===void 0||t.text===r)return e;let i=e.version+1;return{...e,fragments:e.fragments?.map(e=>e.id===n?{...e,text:r}:e),version:i,revisions:[...e.revisions,{revision:i,content:r}]}})}function wt(e,t,n){K(e,t,e=>({...e,annotations:[...e.annotations,n]}))}function Tt(e,t,n){K(e,t,e=>{let t=e.version+1;return{...e,...n===void 0?{crop:void 0}:{crop:n},version:t,revisions:[...e.revisions,{revision:t,content:JSON.stringify(n??null)}]}})}function Et(e,t){K(e,t,e=>({...e,saveRequest:e.saveRequest+1,savingVersion:e.version}))}function Dt(e,t,n){K(e,t,e=>e.savingVersion===n?{...e,savingVersion:void 0}:e)}function Ot(e,t,n,r,i){K(e,t,e=>r<e.savedVersion?e:{...e,sourceSha256:n,savedVersion:r,savingVersion:e.savingVersion===r?void 0:e.savingVersion,originalFragments:i?.map(e=>({...e})),...e.version===r?{crop:void 0}:{},revisions:e.revisions.filter(e=>e.revision>r)});let a=Date.now();q(e,e=>({...e,requests:Rt(e.requests.map(e=>e.documentPath===z(t)&&e.status===`CHANGED`&&e.revision<=r?{...e,status:`COMPLETE`,currentOperation:void 0,updatedAt:a}:e))}))}function kt(e){let t=`${e}\n`,n=V.store.state.sessions[e];for(let e of Object.values(n?.annotationsByDocument??{}))e.candidate?.thumbnailUrl!==void 0&&Bt(e.candidate.thumbnailUrl),e.annotations.forEach(e=>{e.thumbnailUrl!==void 0&&Bt(e.thumbnailUrl)});V.update(n=>{let r={...n.sessions};return delete r[e],{documents:Object.fromEntries(Object.entries(n.documents).filter(([e])=>!e.startsWith(t))),sessions:r}})}function At(e,t,n){K(e,t,e=>({...e,storyPreview:structuredClone(n)}))}function K(e,t,n){let r=B(e,t),i=[];V.update(t=>{let a=t.documents[r];if(a===void 0)return t;let o=n(a),s=t.sessions[e],c=a.version!==o.version||a.sourceSha256!==o.sourceSha256,l=c?s?.annotationsByDocument[a.path]:void 0,u=l&&Pt(l,a,o),d=u===void 0?l:void 0;d!==void 0&&(d.candidate?.thumbnailUrl!==void 0&&i.push(d.candidate.thumbnailUrl),i.push(...d.annotations.flatMap(e=>e.thumbnailUrl===void 0?[]:[e.thumbnailUrl])));let f=u??(c?Nt(d,Date.now()):void 0),p=c&&s!==void 0?{...t.sessions,[e]:{...s,annotationsByDocument:{...s.annotationsByDocument,...f&&{[a.path]:f}}}}:t.sessions;return{documents:{...t.documents,[r]:o},sessions:p}}),i.forEach(Bt)}function q(e,t){V.update(n=>{let r=n.sessions[e]??ot,i=t(r);return i===r?n:{...n,sessions:{...n.sessions,[e]:i}}})}function jt(e){let t=`rect`in e.anchor?{...e.anchor,rect:{...e.anchor.rect}}:`point`in e.anchor?{...e.anchor,point:{...e.anchor.point}}:{...e.anchor};return{...e,anchor:t,viewport:{...e.viewport},stroke:e.stroke?.map(e=>({...e})),voiceGrid:e.voiceGrid&&{...e.voiceGrid}}}function Mt(e){return jt(e)}function Nt(e,t){if(e!==void 0)return{...e,stale:!0,candidate:e.candidate&&{...jt(e.candidate),thumbnailUrl:void 0},annotations:e.annotations.map(e=>({...Mt(e),thumbnailUrl:void 0})),updatedAt:t}}function Pt(e,t,n){if(e.stale||e.revision!==t.version||e.sourceSha256!==t.sourceSha256||t.content===void 0||n.content===void 0||[...e.annotations,...e.candidate?[e.candidate]:[]].some(e=>e.anchor.kind!==`text-range`))return;let r=n.content,i=e=>{let i=e.anchor,{start:a,end:o}=nt(t.content,r,i.startOffset,i.endOffset);return{...jt(e),revision:n.version,sourceSha256:n.sourceSha256,quote:r.slice(a,o),anchor:{...i,startOffset:a,endOffset:o,startLine:it(r,a),endLine:it(r,o)}}};return{...e,revision:n.version,sourceSha256:n.sourceSha256,candidate:e.candidate&&i(e.candidate),annotations:e.annotations.map(i),updatedAt:Date.now()}}function Ft(e,t,n){let r=z(t),i=H(e,r);i!==void 0&&q(e,t=>{let a=W(e,r),o=a===st?{...st,revision:i.version,sourceSha256:i.sourceSha256}:a,s=n(o);return s===o?t:{...t,annotationsByDocument:{...t.annotationsByDocument,[r]:{...s,stale:!1,updatedAt:Date.now()}}}})}function It(e){if(e===void 0)return;let t=new TextEncoder;if(t.encode(e).byteLength<=16384)return e;let n=e.length;for(;n>0&&t.encode(e.slice(0,n)).byteLength>16384;)n-=256;return e.slice(0,n)}function Lt(e){return{...e,before:It(e.before),after:It(e.after),regions:e.regions.map(Mt),pendingRegions:e.pendingRegions?.map(Mt)}}function Rt(e){let t=[...e],n=()=>new TextEncoder().encode(JSON.stringify(t)).byteLength;for(;t.length>100||n()>524288;){let e=t.findIndex(e=>at.has(e.status));if(e<0)throw Error(`Author request history is full while active requests are still running.`);t.splice(e,1)}return t}function zt(e){let t=e=>{let t=jt(e),n=Reflect.get(t,`version`),r=`id`in t?{...t,version:typeof n==`number`?n:1}:t;if(r.thumbnailUrl!==void 0||r.evidence===void 0)return r;try{return{...r,thumbnailUrl:URL.createObjectURL(r.evidence)}}catch{return r}};return{...e,candidate:e.candidate&&t(e.candidate),annotations:e.annotations.map(t)}}function Bt(e){if(e.startsWith(`blob:`))try{URL.revokeObjectURL(e)}catch(e){console.warn(`Author could not release a thumbnail: ${e instanceof Error?e.message:String(e)}`)}}function Vt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ht(e){return Vt(e)?(e.activation===`active`||e.activation===`inactive`)&&Number.isSafeInteger(e.capabilityCount)&&e.capabilityCount>=0?e:typeof e.kind==`string`?e.kind===`rejected`?typeof e.reason==`string`?e:null:e.kind===`canvases`?Array.isArray(e.canvases)&&e.canvases.every(e=>Vt(e)&&typeof e.alias==`string`&&typeof e.path==`string`)?e:null:!Number.isSafeInteger(e.generation)||typeof e.ownerToken!=`string`?null:e.kind===`accepted`?typeof e.leaseMs==`number`&&(e.catalogToken===void 0||typeof e.catalogToken==`string`)?e:null:(e.kind===`request`||e.kind===`cancel`)&&typeof e.catalogToken==`string`&&typeof e.requestId==`string`&&(e.kind===`cancel`||typeof e.name==`string`&&Vt(e.arguments))?e:null:null:null}var Ut=m({activation:`inactive`,capabilityCount:0}),Wt=D({channel:_e,parse:Ht,apply(e,t){`activation`in t?Ut.update(e,()=>t):(ze(e,t),Ut.update(e,()=>Ve(e)))},drop(e){Je(e),Be(e),kt(e),Ut.drop(e)}});function Gt(e){return e[`po-voice`]?.trimStart().startsWith(`voice auto:`)===!0}function Kt({sessionId:e,document:t,visible:n}){let r=_(null);return p(()=>{let i=r.current?.parentElement;if(!n||i==null){Je(e);return}let a=()=>{let n=i.getBoundingClientRect();Ke(e,{documentPath:t.path,revision:t.version,sourceSha256:t.sourceSha256,viewport:{width:n.width,height:n.height,originX:n.left,originY:n.top,scrollX:i.scrollLeft,scrollY:i.scrollTop,zoom:window.devicePixelRatio}})};a();let o=new ResizeObserver(a);return o.observe(i),i.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`focus`,a),()=>{o.disconnect(),i.removeEventListener(`scroll`,a,!0),window.removeEventListener(`focus`,a),Je(e)}},[t.path,t.sourceSha256,t.version,e,n]),n?g(`div`,{ref:r,"data-testid":`author-grid`,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-20 grid grid-cols-8 grid-rows-8`,children:Array.from({length:64},(e,t)=>{let n=t%8,r=Math.floor(t/8);return g(`div`,{className:`relative border border-po-red/25`,children:v(`span`,{className:`absolute left-1 top-0.5 rounded bg-po-deep/80 px-1 text-2xs font-semibold text-po-red`,children:[He[n],r+1]})},t)})}):null}var J=new P({}),qt=new P({}),Jt=new P({}),Yt=(e,t)=>J.state[B(e,t)];function Xt(e){return Array.isArray(e)&&e.length>=2&&e.length<=128&&e.every(e=>typeof e==`object`&&!!e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1)&&e.some(t=>t.x!==e[0]?.x||t.y!==e[0]?.y)}function Zt(e){if(!Xt(e))return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x)),i=Math.max(...e.map(e=>e.y)),a=Math.max(0,Math.min(t,.999)),o=Math.max(0,Math.min(n,.999));return{x:a,y:o,width:Math.min(1-a,Math.max(r-a,.001)),height:Math.min(1-o,Math.max(i-o,.001))}}function Qt(e,t){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))return e;let n={x:Math.max(0,Math.min(1,t.x)),y:Math.max(0,Math.min(1,t.y))};if(e.length>=128)return e;let r=e.at(-1);return r?.x===n.x&&r.y===n.y?e:[...e,n]}function $t(e,t){let n=e.right-e.left,r=e.bottom-e.top;if(![...Object.values(e),...Object.values(t)].every(Number.isFinite)||n<=0||r<=0)return null;let i=Math.max(e.left,Math.min(t.left,t.right)),a=Math.min(e.right,Math.max(t.left,t.right)),o=Math.max(e.top,Math.min(t.top,t.bottom)),s=Math.min(e.bottom,Math.max(t.top,t.bottom));return a<=i||s<=o?null:{x:(i-e.left)/n,y:(o-e.top)/r,width:(a-i)/n,height:(s-o)/r}}var en=1600,tn=65536,nn=4096,rn=[`#ff5f57`,`#00c2ff`,`#ffd166`,`#b388ff`,`#4ade80`,`#ff8c42`,`#f472b6`,`#2dd4bf`,`#a3e635`,`#60a5fa`,`#e879f9`,`#facc15`,`#34d399`,`#fb7185`,`#818cf8`,`#22d3ee`];function an(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<128?1:e<2048?2:e<65536?3:4}return t}function on(e){return JSON.parse(JSON.stringify(e))}function sn(e,t){if(an(e)<=t)return e;let n=0,r=e.length;for(;n<r;){let i=Math.ceil((n+r)/2);an(e.slice(0,i))<=t?n=i:r=i-1}return e.slice(0,n)}function cn(e,t,n,r,i){if(r.length===0||r.length>16)throw Error(`Capture requires between 1 and 16 regions.`);if(n.kind===`story-preview`&&n.storyPreview===void 0)throw Error(`Story preview capture requires source provenance.`);let a={version:1,captureId:e,capturedAt:t,document:{path:n.path,...i===void 0?{}:{alias:i},kind:n.kind,revision:n.version,...n.sourceSha256===void 0?{}:{sourceSha256:n.sourceSha256},...n.storyPreview===void 0?{}:{storyPreview:on(n.storyPreview)},...n.imageArtifact===void 0?{}:{imageArtifact:{...n.imageArtifact}},...n.markdownMedia===void 0?{}:{markdownMedia:{...n.markdownMedia}}},regions:r.map((e,t)=>{if(e.documentPath!==n.path||e.revision!==n.version||e.sourceSha256!==n.sourceSha256)throw Error(`Region ${String(t+1)} is stale for the focused document.`);if(e.stroke!==void 0&&(!Xt(e.stroke)||!(`rect`in e.anchor)||e.mode!==`region`))throw Error(`Region ${String(t+1)} has invalid feedback stroke geometry.`);if(e.comment.trim()===``)throw Error(`Region ${String(t+1)} requires a comment.`);if(an(e.comment)>2048)throw Error(`Region ${String(t+1)} comment exceeds 2 KiB.`);return{id:e.id,ordinal:t+1,comment:e.comment,version:e.version??1,mode:e.mode??(`point`in e.anchor?`point`:`region`),...e.quote===void 0?{}:{quote:sn(e.quote,nn)},anchor:on(e.anchor),...e.stroke===void 0?{}:{stroke:e.stroke.map(e=>({...e}))},viewport:{...e.viewport},...e.voiceGrid===void 0?{}:{voiceGrid:{...e.voiceGrid}}}})};if(an(JSON.stringify(a))>65536)throw Error(`Author capture packet exceeds 64 KiB.`);return a}function Y(e){return`${String(Math.round(e*1e3)/10)}%`}function ln(e){return`x ${Y(e.x)}, y ${Y(e.y)}, w ${Y(e.width)}, h ${Y(e.height)}`}function un(e,t,n){let r=`Author document: ${e}${t===void 0?``:` (canvas ${t})`}`,i=n.map((e,t)=>`(${t+1}) ${e.comment.slice(0,1e3)} [${dn(e.anchor)}]`);return sn([r,...i.length===0?[]:[`Unsent annotations (not yet submitted):`,...i]].join(`
|
|
9
|
-
`),tn)}function dn(e){switch(e.kind){case`text-range`:return e.startLine===e.endLine?`line ${String(e.startLine)}`:`lines ${String(e.startLine)}-${String(e.endLine)}`;case`cell`:return`${e.sheet===void 0?``:`${e.sheet}!`}${e.location}`;case`slide-element`:return`slide ${String(e.slide)}: ${e.location}`;case`image-rect`:return`image ${ln(e.rect)}`;case`pdf-page-rect`:return`page ${String(e.page)}, ${ln(e.rect)}`;case`video-time-rect`:return`time ${e.timeSeconds.toFixed(3)}s${e.frame===void 0?``:`, frame ${String(e.frame)}`}, ${ln(e.rect)}`;case`story-preview-rect`:return`story preview ${ln(e.rect)}`;case`image-point`:return`image point x ${Y(e.point.x)}, y ${Y(e.point.y)}`;case`pdf-page-point`:return`page ${String(e.page)}, point x ${Y(e.point.x)}, y ${Y(e.point.y)}`;case`video-time-point`:return`time ${e.timeSeconds.toFixed(3)}s, point x ${Y(e.point.x)}, y ${Y(e.point.y)}`;case`story-preview-point`:return`story preview point x ${Y(e.point.x)}, y ${Y(e.point.y)}`;case`html-rect`:return`rendered page ${e.element===void 0?``:`${e.element.selector}, `}${ln(e.rect)}`;case`html-point`:return`rendered page ${e.element===void 0?``:`${e.element.selector}, `}point x ${Y(e.point.x)}, y ${Y(e.point.y)}`}}function fn(e){let t=e.document.storyPreview;if(t===void 0)return;let n=t.sources.map(e=>`- ${e.path} (sha256 ${e.sha256})`).join(`
|
|
10
|
-
`);return[`Story preview source (edit these sources, never the generated preview artifact):`,`Project: ${t.projectPath}`,`Story: ${t.storyPath}#${t.storyExport}`,`Build revision: ${t.buildRevision}`,`Viewport: ${String(t.viewport.width)}x${String(t.viewport.height)}`,`Sources:`,n,`After editing the underlying story or component source, rebuild the preview before treating it as visually verified.`].join(`
|
|
11
|
-
`)}function pn(e){return e.startsWith(`artifact:`)?`${e} (relative to the session artifact folder)`:e}function mn(e){let t=e.document.markdownMedia;if(t===void 0)return;let n=[t.kind===`mermaid`?`Reviewed a mermaid diagram rendered from Markdown. Change the diagram by editing its source.`:`Reviewed an image shown in rendered Markdown. Change it by editing or regenerating its source file.`];return t.sourcePath!==void 0&&n.push(`Source image: ${pn(t.sourcePath)}`),t.documentPath!==void 0&&n.push(`Embedded in document: ${pn(t.documentPath)}`),t.documentPath===void 0&&t.sourcePath===void 0&&n.push(`Embedded in a conversation message, not a file.`),t.mermaidSource!==void 0&&n.push(`Mermaid source:`,"```mermaid",t.mermaidSource,"```"),n.join(`
|
|
12
|
-
`)}function hn(e){let t=JSON.stringify(e);if(an(t)>65536)throw Error(`Author capture packet exceeds 64 KiB.`);let n=e.regions.map(e=>`(${String(e.ordinal)}) ${e.comment} [${dn(e.anchor)}]\nregionId: ${JSON.stringify(e.id)}${e.quote?`\nQuoted text: ${e.quote}`:``}`).join(`
|
|
13
|
-
|
|
14
|
-
`),r=e.document.imageArtifact,i=r===void 0?mn(e)??fn(e)??(e.document.kind===`html`?`Annotations mark the rendered page. Locations are relative to the visible frame; the selector and quoted text name the marked element. Change the page by editing this HTML source.`:void 0):[`Generated image feedback: preserve the original image; generate a new refinement only when requested.`,`Original artifact: ${r.id} (session ${r.sessionId})`,`Original canonical path: ${r.originalPath}`,`Original SHA-256: ${r.sourceSha256}`,`For imagegen refinement use referenced_image_paths: ${JSON.stringify([r.originalPath])}`].join(`
|
|
15
|
-
`),a=i===void 0?n:`${i}\n\nAnnotations:\n${n}`,o=JSON.stringify({expectedRevision:e.document.revision,expectedSourceSha256:e.document.sourceSha256});return{kind:`author-capture`,source:`author`,id:e.captureId,label:`${e.regions.length} annotation${e.regions.length===1?``:`s`} · ${e.document.path}`,content:`Author document: ${e.document.path}${e.document.alias===void 0?``:` (canvas ${e.document.alias})`}\nMutation fences: ${o}\n${a}`,metadata:t}}function gn(e){let t=Number.parseInt(e.slice(1,3),16),n=Number.parseInt(e.slice(3,5),16),r=Number.parseInt(e.slice(5,7),16);return t*299+n*587+r*114>=15e4?`#101216`:`#ffffff`}function _n(e,t,n){return new Promise((r,i)=>{e.toBlob(e=>e===null?i(Error(`Unable to capture viewport`)):r(e),t,n)})}async function vn(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}function yn(e){if(e?.aborted===!0)throw e.reason}async function bn(e){let t=`image/png`,n=await _n(e,t);for(let r of[.9,.75,.6,.45,.3]){if(n.size<=2097152)break;t=`image/jpeg`,n=await _n(e,t,r)}if(n.size>2097152)throw Error(`Viewport capture exceeds 2 MiB`);return{data:await vn(n),mimeType:t}}function xn(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(Error(`Unable to load a region capture.`)),r.src=e})}function Sn(e){return{async capture(t){if(yn(t),e.length===0||e.length>16)throw Error(`Capture requires between 1 and 16 regions.`);let n=[];for(let r of e){let e=r.thumbnailUrl===void 0?void 0:await xn(r.thumbnailUrl);yn(t);let i=e?.naturalWidth??r.viewport.width,a=e?.naturalHeight??r.viewport.height;if(!Number.isFinite(i)||!Number.isFinite(a)||i<=0||a<=0)throw Error(`Image is not ready to capture`);n.push({region:r,image:e,width:i,height:a})}let r=Math.min(en,Math.max(...n.map(e=>e.width))),i=n.reduce((e,t)=>e+t.height*r/t.width,0),a=Math.min(1,en/Math.max(r,i)),o=document.createElement(`canvas`);o.width=Math.max(1,Math.round(r*a)),o.height=Math.max(1,Math.round(i*a));let s=o.getContext(`2d`);if(s===null)throw Error(`Canvas is unavailable`);s.scale(a,a),s.fillStyle=`#101216`,s.fillRect(0,0,r,i);let c=0;for(let[e,{region:i,image:o,width:l,height:u}]of n.entries()){let n=rn[e%rn.length];yn(t);let d=u*r/l,f=r,p=d,m=c,h=0,g=m;if(o!==void 0){if(s.drawImage(o,0,m,f,p),i.stroke!==void 0){if(!Xt(i.stroke))throw Error(`Invalid feedback stroke geometry.`);s.beginPath(),i.stroke.forEach((e,t)=>{let n=0+e.x*f,r=m+e.y*p;t===0?s.moveTo(n,r):s.lineTo(n,r)}),s.strokeStyle=n,s.lineWidth=Math.max(3,Math.min(f,p)/150),s.lineCap=`round`,s.lineJoin=`round`,s.stroke(),h=0+i.stroke[0].x*f,g=m+i.stroke[0].y*p}else if(`rect`in i.anchor){let e=i.anchor.rect,t=0+e.x*f,r=m+e.y*p,a=e.width*f,o=e.height*p;s.fillStyle=`rgba(8,10,13,0.62)`,s.fillRect(0,m,f,Math.max(0,r-m)),s.fillRect(0,r+o,f,Math.max(0,m+p-r-o)),s.fillRect(0,r,Math.max(0,t-0),o),s.fillRect(t+a,r,Math.max(0,0+f-t-a),o),s.strokeStyle=n,s.lineWidth=3,s.strokeRect(t,r,a,o),h=t,g=r}else if(`point`in i.anchor){let e=0+i.anchor.point.x*f,t=m+i.anchor.point.y*p,r=Math.max(6,Math.min(14,Math.min(f,p)/12));s.beginPath(),s.arc(e,t,r,0,Math.PI*2),s.fillStyle=n,s.fill(),s.strokeStyle=gn(n),s.lineWidth=2,s.stroke(),h=e+r,g=t-r}}let _=String(e+1),v=Math.min(1/a,p/36);s.font=`bold ${String(24*v)}px monospace`;let y=s.measureText(_).width+12*v;y>f&&(v*=f/y),s.font=`bold ${String(24*v)}px monospace`,s.textBaseline=`top`;let b=6*v,x=Math.min(f,s.measureText(_).width+b*2),S=36*v;h=Math.max(0,Math.min(h,0+f-x)),g=Math.max(m,Math.min(g,m+p-S)),s.fillStyle=n,s.fillRect(h,g,x,S),s.fillStyle=gn(n),s.fillText(_,h+b,g+b),c+=d}return yn(t),bn(o)}}}function Cn({sessionId:e,path:n,drafts:r}){let[i,a]=I(),o=()=>{try{_t(e,n,r.candidateText),a(void 0)}catch(e){a(e instanceof Error?e.message:String(e))}};if(!r.candidate&&r.annotations.length===0)return null;let s=r.candidate?.mode===`point`?`point`:`region`;return v(`section`,{className:`space-y-2`,"data-testid":`author-region-drafts`,children:[r.candidate?v(u,{children:[v(`h3`,{className:`text-base font-semibold text-po-hi`,children:[`Current `,s]}),v(`p`,{className:`text-base text-po-dim sm:text-sm`,children:[`Add feedback to keep this `,s,` as an unsent annotation.`]}),r.candidate.quote?g(`blockquote`,{className:`line-clamp-3 border-l-2 border-po-edge-magenta pl-2 text-base text-po-text sm:text-sm`,children:r.candidate.quote}):null,r.candidate.anchor.kind===`video-time-rect`||r.candidate.anchor.kind===`video-time-point`?v(`p`,{className:`text-base text-po-dim sm:text-sm`,children:[`Frame at `,r.candidate.anchor.timeSeconds.toFixed(3),`s`]}):null,g(`textarea`,{"aria-label":`Annotation comment`,value:r.candidateText,onChange:t=>gt(e,n,t.target.value),placeholder:`What should change here?`,rows:3,className:`min-h-24 w-full resize-y rounded-md border border-po-border-soft bg-po-panel p-3 text-lg leading-normal text-po-text placeholder:text-po-dim focus:border-po-green focus:outline-none sm:text-base`}),v(`div`,{className:`flex flex-wrap gap-2`,children:[g(t,{className:`min-h-11 min-w-11 text-base [@media(pointer:fine)]:min-h-8 sm:text-sm`,variant:`outline`,onClick:o,disabled:!r.candidate||!r.candidateText.trim()||r.annotations.length>=16,children:`add annotation`}),g(t,{variant:`ghost`,className:`min-h-11 min-w-11 text-base [@media(pointer:fine)]:min-h-8 sm:text-sm`,onClick:()=>{ht(e,n,void 0),gt(e,n,``),a(void 0)},children:`Discard annotation`})]})]}):null,i?g(`output`,{className:`block text-base text-po-red`,children:i}):null,r.annotations.length>0?v(`h3`,{className:`text-sm text-po-dim`,children:[`Unsent annotations (`,r.annotations.length,`)`]}):null,g(`ol`,{className:`space-y-2`,children:r.annotations.map((i,a)=>v(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border border-po-border-soft bg-po-panel py-1 pl-3 pr-1 text-base leading-normal text-po-text`,children:[g(`span`,{"aria-hidden":`true`,className:`flex h-6 min-w-6 shrink-0 items-center justify-center rounded-full bg-po-magenta px-1 text-sm font-semibold text-po-rail`,children:a+1}),v(`span`,{className:`min-w-0 flex-1 break-words py-1`,children:[v(`span`,{className:`sr-only`,children:[`(`,a+1,`) `]}),i.comment,g(`span`,{className:`line-clamp-2 block text-sm text-po-dim`,children:i.quote?`“${i.quote}”`:i.mode===`point`?`Point`:`Region`})]}),i.anchor.kind===`video-time-rect`||i.anchor.kind===`video-time-point`?v(t,{variant:`outline`,className:`min-h-11 min-w-11 text-base [@media(pointer:fine)]:min-h-8 sm:text-sm`,disabled:r.candidate!==void 0,onClick:()=>{(i.anchor.kind===`video-time-rect`||i.anchor.kind===`video-time-point`)&&ft(e,n,i.anchor.timeSeconds)},children:[`Go to `,i.anchor.timeSeconds.toFixed(3),`s`]}):null,g(t,{className:`min-h-11 min-w-11 text-base [@media(pointer:fine)]:min-h-8 sm:text-sm`,variant:`ghost`,"aria-label":`Remove annotation ${a+1}`,onClick:()=>yt(e,n,i.id),children:g(le,{"aria-hidden":`true`,className:`size-4`})})]},i.id))})]})}function wn({sessionId:e,document:n,drafts:r,submitCapture:i}){let[a,o]=I(),[s,c]=I(!1);return v(`div`,{className:`space-y-3`,children:[g(Cn,{sessionId:e,path:n.path,drafts:r}),r.annotations.length>0?g(t,{className:`min-h-11 min-w-11 w-full text-base`,size:`lg`,variant:`primary`,"data-testid":`author-attach-capture`,disabled:s||r.candidate!==void 0||i===void 0,onClick:async()=>{if(!(s||r.candidate||i===void 0)){c(!0),o(`Submitting annotations…`);try{let t=cn(crypto.randomUUID(),Date.now(),n,r.annotations,Yt(e,n.path));await i({...await Sn(r.annotations).capture(),context:hn(t)}),o(`Request submitted. You can keep annotating here.`)}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}},children:s?`Submitting…`:`Submit ${r.annotations.length} annotation${r.annotations.length===1?``:`s`}`}):null,i===void 0?g(`output`,{className:`text-sm text-po-red`,children:`Submission unavailable. Reload to update the app.`}):null,a?g(`output`,{className:`block text-sm text-po-dim`,children:a}):null]})}var Tn={REQUESTED:`Request queued`,CHANGING:`Agent working`,CHANGED:`Change ready`,COMPLETE:`Request completed`,FAILED:`Request failed`,CANCELLED:`Request cancelled`,UNTRACKED:`Sent, not tracked`};function En(e){let t=e.search(/(?:^|\s+)Referenced context "/u);return e.slice(0,t<0?void 0:t).replace(/^Please address the attached feedback\.\s*Request ID: \S+\s*/u,``).trim()}function Dn(e){return e.replaceAll(`\\`,`/`).split(`/`).at(-1)||e}function On(e){switch(e.kind){case`text-range`:return e.startLine===e.endLine?`Line ${e.startLine}`:`Lines ${e.startLine}–${e.endLine}`;case`cell`:return[e.sheet,e.location].filter(Boolean).join(` · `);case`slide-element`:return`Slide ${e.slide} · ${e.location}`;case`image-rect`:return`Image region`;case`pdf-page-rect`:return`Page ${e.page}`;case`video-time-rect`:return`Video ${Math.floor(e.timeSeconds/60)}:${Math.floor(e.timeSeconds%60).toString().padStart(2,`0`)}`;case`story-preview-rect`:return`${e.preview.storyPath}#${e.preview.storyExport}`;case`image-point`:return`Image point`;case`pdf-page-point`:return`Page ${e.page} point`;case`video-time-point`:return`Video ${Math.floor(e.timeSeconds/60)}:${Math.floor(e.timeSeconds%60).toString().padStart(2,`0`)} point`;case`story-preview-point`:return`${e.preview.storyPath}#${e.preview.storyExport} point`;case`html-rect`:return e.element===void 0?`Page region`:`Page · ${e.element.tag}`;case`html-point`:return e.element===void 0?`Page point`:`Page · ${e.element.tag} point`}}function kn(e){let t=e.regions.length,n=e.pendingRegions?.length;return e.status===`CHANGING`&&e.currentOperation===`Agent is working on this request`?`Processing request`:e.status===`CHANGING`&&n!==void 0?`${t-n} of ${t} annotations applied`:e.status===`CHANGED`?`Changes applied · awaiting save`:e.status===`COMPLETE`?`Agent finished processing this request`:e.status===`FAILED`?`Stopped with an error`:e.status===`CANCELLED`?`Stopped before completion`:e.status===`UNTRACKED`?`Sent to the agent · see its session for the outcome`:`${t} annotation${t===1?``:`s`} queued`}var An={REQUESTED:`border-po-border-soft bg-po-bg text-po-dim`,CHANGING:`border-po-edge-green bg-po-tint-green text-po-green`,CHANGED:`border-po-edge-green bg-po-tint-green text-po-green`,COMPLETE:`border-po-edge-green bg-po-tint-green text-po-green`,FAILED:`border-po-edge-red bg-po-tint-red text-po-red`,CANCELLED:`border-po-border-soft bg-po-bg text-po-dim`,UNTRACKED:`border-po-border-soft bg-po-bg text-po-dim`},jn={REQUESTED:`neutral`,CHANGING:`ok`,CHANGED:`ok`,COMPLETE:`ok`,FAILED:`error`,CANCELLED:`neutral`,UNTRACKED:`neutral`};function Mn({request:e,prominent:t=!1}){let n=En(e.requestText);return v(`article`,{"data-testid":t?`author-active-request`:void 0,className:`space-y-3 rounded-md border border-po-border-soft bg-po-panel p-3`,children:[v(`header`,{className:`flex gap-3 border-b border-po-border-soft pb-3`,children:[g(M,{"aria-hidden":`true`,className:`mt-1 size-4 shrink-0 text-po-green`}),v(`div`,{className:`min-w-0 flex-1`,children:[g(`p`,{className:`text-lg font-semibold text-po-hi`,children:`Document context`}),g(`p`,{className:`mt-1 truncate text-base font-semibold text-po-hi`,children:Dn(e.documentPath)}),g(x,{tone:jn[e.status],className:`mt-2 whitespace-normal`,children:kn(e)})]})]}),g(`section`,{"aria-label":`Request locations`,className:`rounded-md border border-po-border-soft bg-po-bg p-3`,children:g(`ol`,{className:`space-y-3`,children:e.regions.map((t,n)=>v(`li`,{className:`space-y-2`,children:[v(`p`,{className:`text-sm font-medium text-po-magenta`,children:[`Where · `,e.regions.length>1?`${n+1} · `:``,Dn(e.documentPath),` / `,On(t.anchor),` · rev `,e.revision]}),t.quote?v(`blockquote`,{className:`line-clamp-3 text-base italic leading-relaxed text-po-text`,children:[`“`,t.quote,`”`]}):null,g(`p`,{className:`text-base leading-relaxed text-po-dim`,children:t.comment})]},t.id))})}),v(`section`,{"data-testid":t?`author-operation-card`:void 0,className:`rounded-md border p-3 ${An[e.status]}`,children:[v(`p`,{className:`text-sm font-semibold`,children:[`●`,` `,e.status===`CHANGING`?`Working`:e.status===`COMPLETE`?`Completed`:e.status===`FAILED`?`Error`:Tn[e.status]]}),g(`p`,{className:`mt-2 text-base leading-relaxed text-po-hi`,children:e.currentOperation||Tn[e.status]}),e.error?g(`p`,{className:`mt-2 text-sm leading-relaxed text-po-red`,children:e.error}):null,e.before!==void 0||e.after!==void 0?v(`details`,{className:`mt-2 border-t border-current/20 pt-2 text-base text-po-dim`,children:[g(`summary`,{className:`cursor-pointer select-none`,children:`change preview`}),e.before===void 0?null:v(`pre`,{className:`mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words font-mono`,children:[`before: `,e.before]}),e.after===void 0?null:v(`pre`,{className:`mt-2 max-h-28 overflow-auto whitespace-pre-wrap break-words font-mono`,children:[`after: `,e.after]})]}):null]}),v(`section`,{className:`space-y-2`,children:[g(`p`,{className:`text-base font-semibold text-po-hi`,children:`Request · how to change`}),g(`div`,{className:`rounded-md border border-po-border-soft bg-po-bg p-3`,children:g(`p`,{className:`whitespace-pre-wrap text-base leading-relaxed text-po-text`,children:n||`No additional instruction.`})})]})]})}function Nn({requests:e}){let t=e.at(-1),n=e.slice(0,-1).reverse();return v(`section`,{"data-testid":`author-request-history`,className:`space-y-3`,children:[g(`h3`,{className:`text-lg font-semibold text-po-hi`,children:`Author`}),t===void 0?g(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:`No requests or changes yet.`}):g(Mn,{request:t,prominent:!0}),n.length>0?v(`details`,{className:`border-t border-po-border-soft pt-3`,"data-testid":`author-earlier-requests`,children:[v(`summary`,{className:`cursor-pointer select-none text-base font-medium text-po-dim`,children:[`Earlier requests (`,n.length,`)`]}),g(`ol`,{className:`mt-3 space-y-5`,children:n.map(e=>g(`li`,{children:g(Mn,{request:e})},e.id))})]}):null]})}function Pn(e,t){return`h-auto min-h-11 min-w-11 flex-col gap-1 rounded-md px-1 py-2 text-base [@media(pointer:fine)]:min-h-8 ${e?t?`border-po-edge-magenta bg-po-tint-magenta font-semibold text-po-magenta hover:text-po-magenta`:`border-po-edge-green bg-po-tint-green font-semibold text-po-green hover:text-po-green`:`border-po-border-soft bg-po-panel text-po-dim`}`}function Fn({sessionId:e,path:n,kind:r,activeTool:i}){let a=r===`markdown`||r===`text`,o=[...[`image`,`pdf`,`video`,`story-preview`].includes(r)?[{label:`Pan`,glyph:`✋`,action:()=>G(e,n,i===`pan`?`select`:`pan`),active:i===`pan`,annotates:!1}]:[],...[`image`,`pdf`,`video`,`story-preview`,`html`].includes(r)?[{label:`Draw`,glyph:`✎`,action:()=>G(e,n,i===`draw`?`select`:`draw`),active:i===`draw`,annotates:!0}]:[],{label:`Region`,glyph:`⌗`,action:()=>G(e,n,i===`mark`?`select`:`mark`),active:i===`mark`,annotates:!0},{label:`Comment`,glyph:`●`,action:()=>G(e,n,i===`comment`?`select`:`comment`),active:i===`comment`,annotates:!0}];return v(`section`,{"data-testid":`author-tool-palette`,className:`space-y-2`,children:[g(`h3`,{className:`sr-only`,children:`Tools`}),g(`div`,{className:`grid grid-cols-4 gap-1.5`,children:o.map(e=>v(t,{size:`md`,variant:`outline`,"aria-label":e.label===`Region`?`mark region`:e.label,"aria-pressed":e.active,onClick:e.action,className:Pn(e.active===!0,e.annotates===!0),children:[g(`span`,{"aria-hidden":`true`,className:`text-lg leading-none`,children:e.glyph}),g(`span`,{className:`text-sm`,children:e.label})]},e.label))}),g(`p`,{className:`text-base leading-normal text-po-dim sm:text-sm`,children:i===`draw`?`Draw a location mark, then enter feedback text. Marks never edit the source.`:i===`pan`?v(u,{children:[g(`span`,{className:`[@media(pointer:coarse)]:hidden`,children:`Drag to pan; pinch to zoom. Use Fit to reset the view.`}),g(`span`,{className:`hidden [@media(pointer:coarse)]:inline`,children:`Pinch to zoom. Drag to move. Double-tap to reset.`})]}):i===`mark`?a?`Drag over the passage you want to mark. Choose Region again to stop.`:`Drag over the document to mark a region.`:i===`comment`?a?`Click a paragraph or line to comment on it. Choose Comment again to stop.`:`Click the document to place a comment pin.`:a?`Select text to comment on it, or choose Region or Comment.`:`Choose Region to drag an area, or Comment to place a point.`})]})}function In({sessionId:e,submitCapture:t,statuses:n,renderSlot:r,renderSessionActivity:i}){let a=C(V.store,t=>{if(e===null)return[];let n=`${e}\n`;return Object.entries(t.documents).filter(([e])=>e.startsWith(n)).map(([,e])=>e)}),o=C(V.store,t=>e===null?void 0:t.sessions[e]),s=C(Ge.store,t=>e===null?void 0:t.sessions[e]),c=a.find(e=>e.path===o?.focusedDocument?.path),l=o?.focusedDocument?.path,d=(o?.requests??[]).filter(e=>l===void 0||e.documentPath===l),f=C(V.store,t=>W(e,l??``,t)),p=e!==null&&l!==void 0&&d.some(e=>e.status===`REQUESTED`||e.status===`CHANGING`)?i?.()??null:null;return v(`section`,{"data-testid":`author-panel`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[g(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:v(`div`,{className:`flex flex-col gap-3`,children:[g(`div`,{"data-testid":`author-preview-providers`,className:`empty:hidden`,children:r(`author.preview-provider`)}),e!==null&&o!==void 0&&c!==void 0?v(u,{children:[g(Fn,{sessionId:e,path:c.path,kind:c.kind,activeTool:o.toolsByDocument[z(c.path)]??`select`}),g(`h2`,{className:`border-t border-po-border-soft pt-3 text-lg font-semibold text-po-hi`,children:`Annotations`}),v(`p`,{className:`text-base leading-normal text-po-dim sm:text-sm`,children:[c.kind===`markdown`||c.kind===`text`?`Select text or mark a passage, add feedback, then submit here.`:`Drag a region or place a point, add feedback, then submit here.`,` `,`Requests queue while the agent is working.`]}),c.kind===`video`?g(`p`,{className:`text-base text-po-dim sm:text-sm`,children:`Annotations reference video frames. They do not save changes to the source video.`}):null,Gt(n)&&s!==void 0?v(`div`,{"data-testid":`author-grid-snapshot`,className:`rounded border border-po-red/40 bg-po-red/5 p-2 text-base text-po-dim`,children:[g(`strong`,{className:`text-po-red`,children:`VOICE GRID A1–H8`}),v(`p`,{className:`mt-1 truncate`,children:[`token `,s.geometryToken]})]}):null,g(`div`,{className:`max-sm:hidden`,children:g(wn,{sessionId:e,document:c,drafts:f,submitCapture:t},c.path)})]}):null,g(`div`,{className:c===void 0?void 0:`border-t border-po-border-soft pt-3`,children:g(Nn,{requests:d})})]})}),p===null?null:g(`footer`,{"data-testid":`author-session-activity`,className:`shrink-0 border-t border-po-border bg-po-rail p-3`,children:p})]})}var Ln=c({id:`authoring`,label:`Author`,icon:se,order:30,panel:In,visibility:{subscribe(e){let t=V.store.subscribe(e);return()=>t.unsubscribe()},isVisible(e){return e!==null&&V.store.state.sessions[e]?.focusedDocument!==void 0}}}),Rn=fe({state:{method:`GET`,path:`/state`,response:pe()},bridgeRegister:{method:`POST`,path:`/bridge/register`},bridgeCatalog:{method:`POST`,path:`/bridge/catalog`},bridgeNext:{method:`POST`,path:`/bridge/next`},bridgeResult:{method:`POST`,path:`/bridge/result`},bridgeCancelled:{method:`POST`,path:`/bridge/cancelled`},bridgeDisconnect:{method:`POST`,path:`/bridge/disconnect`},bridgeClose:{method:`POST`,path:`/bridge/close`},bridgeDescribe:{method:`GET`,path:`/bridge/describe`,query:[`alias`]},bridgeInvoke:{method:`POST`,path:`/bridge/invoke`},documentsOpen:{method:`POST`,path:`/documents/open`,query:[`session`],response:pe()},documentsPreflight:{method:`POST`,path:`/documents/preflight`,query:[`session`],response:pe()},documentsSerialize:{method:`POST`,path:`/documents/serialize`,query:[`session`],response:pe()},file:{method:`GET`,path:`/file`,query:[`path`],raw:!0},fileWrite:{method:`PUT`,path:`/file`,query:[`path`],raw:!0}}),zn=T(Rn,{scopes:[`session`],basePath:`author`,transport:(e,t)=>i.fetch(e,t),sessionAddress:w}),Bn=`author-file-`,Vn=`artifact:`,Hn=/^[a-z][a-z0-9-]{0,31}$/u,Un=/^[a-z][a-z0-9_]{0,29}$/u,Wn=15;function Gn(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.name==`string`&&Un.test(t.name)&&(t.label===void 0||typeof t.label==`string`)&&typeof t.description==`string`&&typeof t.inputSchema==`object`&&t.inputSchema!==null&&!Array.isArray(t.inputSchema)&&typeof t.execute==`function`}function Kn(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.version!==1||typeof t.type!=`string`||!Hn.test(t.type)||typeof t.match!=`function`)return null;let n=t.tools;return!Array.isArray(n)||n.length>Wn||!n.every(Gn)||new Set(n.map(e=>e.name)).size!==n.length?null:t}var qn={slot:`author.canvas-type`,description:`Add browser tools for a canvas type a plugin registers through po/author.`,parse:Kn};function Jn(e){if(typeof e!=`object`||!e)return null;let t=e;return t.watchFocusedPath!==void 0&&typeof t.watchFocusedPath!=`function`||t.createImageTab!==void 0&&typeof t.createImageTab!=`function`?null:t.version===1&&typeof t.createTab==`function`?t:null}function Yn(e){if(typeof e!=`object`||!e)return null;let t=e;return t.version!==1||typeof t.label!=`string`||t.label.trim()===``||t.detail!==void 0&&typeof t.detail!=`string`||typeof t.createTab!=`function`||t.supportsSource!==void 0&&typeof t.supportsSource!=`function`||t.embeddedPanel!==void 0&&typeof t.embeddedPanel!=`function`?null:t}var Xn={slot:`author.preview-action`,description:`Offer preview launchers or embedded preview panels for Author's focused source.`,parse:Yn},Zn=new P({}),Qn=new P({});function $n(e,t){let n=t.map(e=>e.data),r=Zn.state[e]??[];r.length===n.length&&r.every((e,t)=>e===n[t])||Zn.setState(t=>({...t,[e]:n}))}function er(e){return Zn.state[e]??[]}function tr(e,t){return e.find(e=>{try{return e.match(t)===!0}catch(t){return Qn.state[e.type]!==!0&&(Qn.setState(t=>({...t,[e.type]:!0})),console.warn(`Author canvas type '${e.type}' failed to match a path: ${String(t)}`)),!1}})}var nr=`session`,rr=new Set([`avif`,`bmp`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]),ir=new Set([`m4v`,`mov`,`mp4`,`webm`]);function ar(e){let t=e.toLowerCase();if(t.endsWith(`.slides.md`))return`markdown-slides`;if(t.endsWith(`.csv`))return`csv`;if(t.endsWith(`.pptx`))return`pptx`;if(t.endsWith(`.xlsx`))return`xlsx`}function or(e){return/\.(?:mmd|mermaid)$/iu.test(e)}function sr(e){let t=e.toLowerCase();if(/\.stories\.(?:js|jsx|ts|tsx)$/u.test(t))return`story-preview`;let n=ar(e);if(n===`markdown-slides`)return`slides`;if(n!==void 0)return n;let r=t.split(`.`).at(-1)??``;return r===`md`||or(t)?`markdown`:rr.has(r)?`image`:ir.has(r)?`video`:r===`pdf`?`pdf`:r===`html`||r===`htm`?`html`:[`txt`,`json`,`yaml`,`yml`,`xml`,`css`,`js`,`ts`,`tsx`,`jsx`].includes(r)?`text`:`opaque`}async function cr(e,t,n,r,i,a){if(n.startsWith(`artifact:`))throw Error(`Artifacts are read-only.`);if(!/^[a-f0-9]{64}$/.test(i))throw Error(`This Author view has no valid source digest.`);let o=await e(t,{method:`PUT`,headers:{"Content-Type":`application/octet-stream`,"X-Expected-SHA256":i},body:r,signal:a});if(o.status===409)throw Error(`This file changed elsewhere. Keep your edits and reopen it before saving.`);if(!o.ok)throw Error(`Author save failed (${String(o.status)})`);let s=o.headers.get(`X-File-SHA256`);if(s===null||!/^[a-f0-9]{64}$/.test(s))throw Error(`Author save returned an invalid digest.`);return s}function lr(e,t){return t.startsWith(`artifact:`)?fr.session(e).content.url({query:{path:t.slice(9)}}):zn.session(e).file.url({query:{path:t}})}function ur(e,t){let n=e.startsWith(Vn),r=n?e.slice(9):e;if(t.startsWith(`/`)){if(n)throw Error(`Artifact images must use a relative path.`);return t}let i=r.split(`/`).slice(0,-1);for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e!==`..`)i.push(e);else if(i.length===0||i.at(-1)===``)throw Error(`The image is outside this folder.`);else i.pop()}return`${n?Vn:``}${i.join(`/`)}`}function dr(e){let t=e.startsWith(`artifact:`)?e.slice(9):e;return t.split(`/`).at(-1)??t}var fr=T({content:{method:`GET`,path:`/content`,query:[`path`],raw:!0}},{scopes:[`session`],basePath:`artifacts`,transport:(e,t)=>i.fetch(e,t),sessionAddress:w});async function pr(e,t,n,r){let i=await e({body:n,query:{[nr]:t},...r===void 0?{}:{signal:r}});if(!i.ok)throw Error(i.error===``?`Author document API failed (${i.status})`:i.error);return i.data}async function mr(e,t,n){let r=sr(t),a=lr(e,t),o=await i.fetch(a,{signal:n});if(!o.ok)throw Error(`Author could not open ${t} (${o.status})`);let s=o.headers.get(`X-File-SHA256`)??void 0,c=ar(t);if(c!==void 0){let i=await pr(zn.session(e).documentsOpen,e,{path:t,format:c},n);if(!(`fragments`in i)||!Array.isArray(i.fragments))throw Error(`Author returned an invalid structured document.`);let a=i.manifest?.sourceDigest;if(s!==void 0&&a!==void 0&&s!==a)throw Error(`Document source changed while opening. Reopen the document.`);let o=c===`csv`?xr(i.manifest?.metadata):void 0;return{path:t,kind:r,title:dr(t),structuredFormat:c,fragments:i.fragments,...o===void 0?{}:{csvDialect:o},originalFragments:i.fragments.map(e=>({...e})),...s===void 0?{}:{sourceSha256:s}}}let l=r===`image`||r===`video`||r===`pdf`||r===`opaque`?a:void 0,u=r===`text`||r===`markdown`||r===`story-preview`||r===`html`?await o.text():void 0;return{path:t,kind:r,title:dr(t),...u===void 0?{}:{content:u},...l===void 0?{}:{mediaUrl:l},...s===void 0?{}:{sourceSha256:s}}}function hr(e){let t=new Map((e.originalFragments??[]).map(e=>[e.id,e.text]));return(e.fragments??[]).filter(e=>!e.readOnly&&t.get(e.id)!==e.text).map(e=>({fragmentId:e.id,replacement:e.text}))}function gr(e){if(!/^(?:[A-Za-z\d+/]{4})*(?:[A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/.test(e))throw Error(`Invalid serialized document bytes.`);let t=atob(e);return Uint8Array.from(t,e=>e.charCodeAt(0))}function _r(e){let t=e.split(`.`).at(-1)?.toLowerCase();if(t===`png`)return`image/png`;if(t===`jpg`||t===`jpeg`)return`image/jpeg`;if(t===`webp`)return`image/webp`}async function vr(e,t){let{crop:n,mediaUrl:r}=e;if(n===void 0||r===void 0)throw Error(`This Author image has no crop source.`);let a=_r(e.path);if(a===void 0)throw Error(`This image format cannot preserve its encoding after crop.`);let o=await i.fetch(r,{signal:t,cache:`no-store`});if(!o.ok)throw Error(`Author could not read the image before saving (${o.status})`);let s=await createImageBitmap(await o.blob());try{let e=Math.round(n.x*s.width),t=Math.round(n.y*s.height),r=Math.max(1,Math.round(n.width*s.width)),i=Math.max(1,Math.round(n.height*s.height)),o=window.document.createElement(`canvas`);o.width=r,o.height=i;let c=o.getContext(`2d`);if(c===null)throw Error(`Canvas is unavailable for image crop.`);c.drawImage(s,e,t,r,i,0,0,r,i);let l=await new Promise(e=>o.toBlob(e,a));if(l===null||l.type!==a)throw Error(`The browser cannot encode this cropped image format.`);return l}finally{s.close()}}async function yr(e,t,n){if(t.kind===`text`||t.kind===`markdown`||t.kind===`story-preview`||t.kind===`html`)return t.content??``;if(t.kind===`image`&&t.crop!==void 0)return await vr(t,n);if(t.structuredFormat===void 0)throw Error(`This Author view cannot be saved.`);let r=hr(t),i={path:t.path,format:t.structuredFormat,operations:r,...t.csvDialect===void 0?{}:{csvDialect:t.csvDialect}},a=await pr(zn.session(e).documentsPreflight,e,i,n);if(a.sourceDigest!==void 0&&a.sourceDigest!==t.sourceSha256)throw Error(`Document source changed before saving. Reopen the document.`);if(!a.accepted)throw Error(a.issues.map(e=>e.message).join(`
|
|
16
|
-
`)||`Author preflight rejected the edit.`);let o=await pr(zn.session(e).documentsSerialize,e,{...i,preflightDigest:a.digest},n);if(o.encoding!==`base64`)throw Error(`Author serialize returned an unsupported encoding.`);let s=gr(o.bytes);return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}async function br(e,t,n){if(t.path.startsWith(`artifact:`))throw Error(`Artifacts are read-only.`);if(t.sourceSha256===void 0)throw Error(`This Author view has no source digest.`);return await cr((e,t)=>i.fetch(e,t),zn.session(e).fileWrite.url({query:{path:t.path}}),t.path,await yr(e,t,n),t.sourceSha256,n)}function xr(e){if(e===void 0)return;let{delimiter:t,quote:n,recordDelimiter:r}=e;if(t!==`,`&&t!==`;`&&t!==` `&&t!==`|`||n!==`"`&&n!==`'`||r!==`
|
|
17
|
-
`&&r!==`\r
|
|
18
|
-
`)throw Error(`Author document API returned an invalid CSV dialect.`);return{delimiter:t,quote:n,recordDelimiter:r}}var Sr={type:`string`,minLength:1};function Cr(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Expected an object.`);return e}function wr(e,t){if(typeof e[t]!=`string`||e[t]===``)throw Error(`${t} must be a non-empty string.`);return e[t]}function Tr(e,t,n,r){if(H(e,t)===void 0)throw Error(`STALE_DOCUMENT: The focused Author document is no longer open.`);if(n===`pdf`||n===`video`||n===`opaque`)throw Error(`UNSUPPORTED_GRID: PDF and video coordinates are capture-only and require a visible native selection.`);return Xe(e,r)}function Er(e,t,n){let r=H(e,t);if(r===void 0)throw Error(`STALE_DOCUMENT: The Author document is no longer open.`);if(r.savingVersion!==void 0)throw Error(`SAVE_IN_PROGRESS: Wait for the current Author save to finish.`);let i=n.expectedRevision,a=wr(n,`expectedSourceSha256`);if(i!==r.version||a!==r.sourceSha256)throw Error(`STALE_DOCUMENT: The Author revision or source digest changed.`);let o=wr(n,`regionId`),s=U(e),c=W(e,t)?.annotations.find(e=>e.id===o)??s.requests.filter(e=>e.documentPath===t&&(e.status===`REQUESTED`||e.status===`CHANGING`)).flatMap(e=>e.pendingRegions??e.regions).find(e=>e.id===o);if(c===void 0||c.documentPath!==t)throw Error(`STALE_REGION: The resolved Author region is unavailable.`);if(c.stroke!==void 0)throw Error(`UNSUPPORTED_REGION: Freehand feedback cannot authorize a document mutation.`);if(c.revision!==r.version||c.sourceSha256!==r.sourceSha256)throw Error(`STALE_REGION: The resolved Author region no longer matches the document.`);return{document:r,region:c}}function Dr(e,t,n){return[{name:`author_describe_grid`,label:`Describe grid`,description:`Describe the current A1 through H8 grid and return its geometry token.`,inputSchema:{type:`object`,additionalProperties:!1,properties:{}},execute:async()=>{let n=qe(e),r=H(e,t);if(n===void 0||r===void 0||n.documentPath!==t||n.revision!==r.version)throw Error(`STALE_GRID: The visible Author grid is unavailable.`);return{columns:`A-H`,rows:`1-8`,...n}}},{name:`author_resolve_grid_cell`,label:`Resolve grid cell`,description:`Resolve one current grid cell to a native document anchor before mutation.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`cell`,`geometryToken`,`instruction`],properties:{cell:Sr,geometryToken:Sr,instruction:Sr}},execute:async r=>{let i=Cr(r),a=wr(i,`instruction`),o=Ze(e,wr(i,`cell`),wr(i,`geometryToken`)),s=qe(e),c=Tr(e,t,n,o),l=crypto.randomUUID(),u=Date.now(),d={id:l,documentPath:t,revision:s.revision,sourceSha256:s.sourceSha256,comment:a,...c,viewport:{...s.viewport},voiceGrid:o.evidence,createdAt:u};return vt(e,d),bt(e,{id:`voice:${l}`,documentPath:t,requestText:a,regions:[d],pendingRegions:[d],status:`REQUESTED`,createdAt:u,updatedAt:u,revision:s.revision,sourceSha256:s.sourceSha256}),{regionId:l,anchor:c.anchor,quote:c.quote,evidence:o.evidence}}}]}function Or(e,t){let n=e.filter(e=>e.id!==t.id);if(t.anchor.kind===`image-rect`&&n.length>0)throw Error(`UNSUPPORTED_REGION: A multi-region image request cannot apply more than one crop.`);if(t.anchor.kind===`text-range`){for(let e of n)if(e.anchor.kind===`text-range`&&!(e.anchor.endOffset<=t.anchor.startOffset||e.anchor.startOffset>=t.anchor.endOffset))throw Error(`AMBIGUOUS_REGION: Submitted text regions overlap and cannot be safely rebased.`)}}function kr(e,t){return e.slice(0,Math.max(0,t)).split(`
|
|
19
|
-
`).length}function Ar(e,t,n,r){return e.filter(e=>e.id!==t.id).map(e=>{if(t.anchor.kind!==`text-range`||e.anchor.kind!==`text-range`||r===void 0)return{...e,revision:n.revision};let i=(n.after?.length??0)-(n.before?.length??0),a=e.anchor.startOffset>=t.anchor.endOffset?i:0,o=e.anchor.startOffset+a,s=e.anchor.endOffset+a;return{...e,revision:n.revision,anchor:{...e.anchor,startOffset:o,endOffset:s,startLine:kr(r,o),endLine:kr(r,s)}}})}function jr(e,t,n){if(n===`pdf`||n===`video`||n===`opaque`)return;let r=n!==`image`;return{name:`author_apply_region`,label:`Apply region change`,description:`Apply a fenced mutation through a previously resolved native Author region.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`regionId`,`expectedRevision`,`expectedSourceSha256`,...r?[`replacement`]:[]],properties:{regionId:Sr,expectedRevision:{type:`integer`,minimum:0},expectedSourceSha256:Sr,...r?{replacement:{type:`string`}}:{}}},execute:async(n,r)=>{let i=Cr(n),a=wr(i,`regionId`),o=U(e).requests.find(e=>e.documentPath===t&&e.status===`REQUESTED`&&(e.pendingRegions??e.regions).some(e=>e.id===a));o!==void 0&&xt(e,o.id,e=>({...e,status:`CHANGING`,currentOperation:`validating native anchor`,updatedAt:Date.now()}));try{if(r.aborted)throw r.reason instanceof Error?r.reason:Error(`Author mutation cancelled.`);let{document:n,region:a}=Er(e,t,i),s=o?.pendingRegions??o?.regions??[a];Or(s,a),o!==void 0&&xt(e,o.id,e=>({...e,currentOperation:`mutating ${a.anchor.kind}`,updatedAt:Date.now()}));let c,l;if(a.anchor.kind===`text-range`){let r=typeof i.replacement==`string`?i.replacement:``,{startOffset:o,endOffset:s}=a.anchor,u=n.content??``,d=u.slice(o,s);l=u.slice(0,o)+r+u.slice(s),St(e,t,l),c={changed:!0,before:d,after:r,revision:n.version+1}}else if(a.anchor.kind===`cell`||a.anchor.kind===`slide-element`){let r=a.anchor.fragmentId,o=n.fragments?.find(e=>e.id===r);if(o===void 0||o.readOnly===!0)throw Error(`UNSUPPORTED_REGION: The native fragment is not editable.`);let s=typeof i.replacement==`string`?i.replacement:``;Ct(e,t,o.id,s),c={changed:!0,before:o.text,after:s,revision:n.version+1}}else if(a.anchor.kind===`image-rect`)Tt(e,t,a.anchor.rect),c={changed:!0,crop:a.anchor.rect,revision:n.version+1};else throw Error(`UNSUPPORTED_REGION: PDF, video and rendered HTML regions are capture-only.`);if(yt(e,t,a.id),o!==void 0){let t=Ar(s,a,c,l);xt(e,o.id,e=>({...e,status:t.length===0?`CHANGED`:`REQUESTED`,currentOperation:void 0,before:[e.before,c.before].filter(e=>e!==void 0).join(`
|
|
20
|
-
`)||void 0,after:[e.after,c.after??(c.crop===void 0?void 0:JSON.stringify(c.crop))].filter(e=>e!==void 0).join(`
|
|
21
|
-
`)||void 0,pendingRegions:t,revision:c.revision,updatedAt:Date.now()}))}return c}catch(t){throw o!==void 0&&xt(e,o.id,e=>({...e,status:r.aborted?`CANCELLED`:`FAILED`,currentOperation:void 0,error:r.aborted?`Author mutation cancelled.`:t instanceof Error?t.message:String(t),updatedAt:Date.now()})),t}}}}function Mr(e,t,n){let r=jr(e,t,n);return[...Dr(e,t,n),...r===void 0?[]:[r]]}function Nr(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Expected an object`);return e}function Pr(e,t){if(typeof e!=`string`)throw Error(`${t} must be a string`);return e}function Fr(e){let t=Nr(e);return{sessionId:Pr(t.sessionId,`sessionId`),path:Pr(t.path,`path`),value:t}}var Ir={sessionId:{type:`string`,minLength:1},path:{type:`string`,minLength:1}},Lr={id:ve.text,tools:[{name:`author_add_comment`,label:`Add comment`,description:`Add a local review comment to one open Author document.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`sessionId`,`path`,`body`],properties:{...Ir,body:{type:`string`},quote:{type:`string`}}},execute:async e=>{let{sessionId:t,path:n,value:r}=Fr(e),i=Pr(r.body,`body`);return wt(t,n,{id:`${Date.now()}:${i.length}`,kind:`comment`,body:i,...typeof r.quote==`string`?{quote:r.quote}:{}}),{added:!0}}},{name:`author_add_highlight`,label:`Add highlight`,description:`Highlight a line range in one open Author text document.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`sessionId`,`path`,`startLine`,`endLine`],properties:{...Ir,startLine:{type:`integer`,minimum:1},endLine:{type:`integer`,minimum:1}}},execute:async e=>{let{sessionId:t,path:n,value:r}=Fr(e);if(!Number.isSafeInteger(r.startLine)||!Number.isSafeInteger(r.endLine))throw Error(`Highlight lines must be integers`);let i=r.startLine,a=r.endLine;if(i<1||a<i)throw Error(`Invalid highlight range`);return wt(t,n,{id:`${Date.now()}:${i}:${a}`,kind:`highlight`,body:``,startLine:i,endLine:a}),{added:!0}}}]},Rr={id:ve.media,tools:[]};function zr(e,t,n){return{id:e.id,tools:e.tools.map(e=>{let r=e.inputSchema,{sessionId:i,path:a,...o}=Nr(r.properties),s=Array.isArray(r.required)?r.required.filter(e=>e!==`sessionId`&&e!==`path`):[];return{...e,inputSchema:{...r,properties:o,required:s},execute:async(r,i)=>await e.execute({...Nr(r),sessionId:t,path:n},i)}})}}function Br(e,t,n){return{id:`author.canvas-type.${e.type}`,tools:e.tools.map(e=>({name:e.name,...e.label===void 0?{}:{label:e.label},description:e.description,inputSchema:e.inputSchema,execute:async(r,i)=>await e.execute(r,i,{sessionId:t,path:n})}))}}function Vr(e,t,n,r=er(e)){let i=Hr(e,t,n),a=tr(r,t);return a===void 0?i:[...i,Br(a,e,t)]}function Hr(e,t,n){let r=n===`image`?[zr(Rr,e,t)]:n===`text`||n===`markdown`||n===`html`?[zr(Lr,e,t)]:[],i=Mr(e,t,n);return i.length===0?r:r.length===0?[{id:ve.media,tools:i}]:[{...r[0],tools:[...r[0].tools,...i]}]}var Ur=`po-author-html:`,Wr=512,Gr=600,Kr=/^(?:[a-z][a-z\d+.-]*:|\/\/|#)/iu,qr=/url\(\s*(['"]?)([^'")]+)\1\s*\)/gu,Jr=`(() => {
|
|
22
|
-
const prefix = ${JSON.stringify(Ur)};
|
|
23
|
-
const post = (message) => parent.postMessage(message, '*');
|
|
24
|
-
const view = () => ({ scrollX, scrollY, width: innerWidth, height: innerHeight });
|
|
25
|
-
const report = () => post({ type: prefix + 'view', ...view() });
|
|
26
|
-
addEventListener('scroll', report, { passive: true, capture: true });
|
|
27
|
-
addEventListener('resize', report);
|
|
28
|
-
addEventListener('load', report);
|
|
29
|
-
const selector = (element) => {
|
|
30
|
-
const parts = [];
|
|
31
|
-
for (let node = element; node && node.nodeType === 1 && parts.length < 6; node = node.parentElement) {
|
|
32
|
-
const tag = node.tagName.toLowerCase();
|
|
33
|
-
if (node.id) { parts.unshift(tag + '#' + CSS.escape(node.id)); break; }
|
|
34
|
-
const siblings = node.parentElement ? [...node.parentElement.children].filter((child) => child.tagName === node.tagName) : [];
|
|
35
|
-
parts.unshift(siblings.length > 1 ? tag + ':nth-of-type(' + (siblings.indexOf(node) + 1) + ')' : tag);
|
|
36
|
-
if (tag === 'body') break;
|
|
37
|
-
}
|
|
38
|
-
return parts.join(' > ');
|
|
39
|
-
};
|
|
40
|
-
const pick = (rect) => {
|
|
41
|
-
let element = document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2);
|
|
42
|
-
if (rect.width > 0 && rect.height > 0) {
|
|
43
|
-
while (element && element.parentElement && element !== document.body) {
|
|
44
|
-
const box = element.getBoundingClientRect();
|
|
45
|
-
if (box.left <= rect.x + 1 && box.top <= rect.y + 1 && box.right >= rect.x + rect.width - 1 && box.bottom >= rect.y + rect.height - 1) break;
|
|
46
|
-
element = element.parentElement;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return element;
|
|
50
|
-
};
|
|
51
|
-
const capture = async () => {
|
|
52
|
-
const width = innerWidth;
|
|
53
|
-
const height = innerHeight;
|
|
54
|
-
const root = document.documentElement;
|
|
55
|
-
const clone = root.cloneNode(true);
|
|
56
|
-
clone.querySelectorAll('script').forEach((script) => script.remove());
|
|
57
|
-
const markup = new XMLSerializer().serializeToString(clone);
|
|
58
|
-
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '">' +
|
|
59
|
-
'<foreignObject x="' + -scrollX + '" y="' + -scrollY + '" width="' + Math.max(width, root.scrollWidth) + '" height="' + Math.max(height, root.scrollHeight) + '">' +
|
|
60
|
-
markup + '</foreignObject></svg>';
|
|
61
|
-
const image = new Image();
|
|
62
|
-
image.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
|
|
63
|
-
await image.decode();
|
|
64
|
-
const scale = Math.min(1, 1600 / Math.max(width, height));
|
|
65
|
-
const canvas = document.createElement('canvas');
|
|
66
|
-
canvas.width = Math.max(1, Math.round(width * scale));
|
|
67
|
-
canvas.height = Math.max(1, Math.round(height * scale));
|
|
68
|
-
const context = canvas.getContext('2d');
|
|
69
|
-
context.fillStyle = getComputedStyle(document.body).backgroundColor || '#ffffff';
|
|
70
|
-
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
71
|
-
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
72
|
-
return canvas.toDataURL('image/png');
|
|
73
|
-
};
|
|
74
|
-
addEventListener('message', async (event) => {
|
|
75
|
-
const data = event.data;
|
|
76
|
-
if (event.source !== parent || !data || data.type !== prefix + 'inspect') return;
|
|
77
|
-
const element = pick(data.rect);
|
|
78
|
-
let image;
|
|
79
|
-
try { image = await capture(); } catch {}
|
|
80
|
-
post({
|
|
81
|
-
type: prefix + 'inspected',
|
|
82
|
-
id: data.id,
|
|
83
|
-
view: view(),
|
|
84
|
-
element: element ? { selector: selector(element), tag: element.tagName.toLowerCase() } : undefined,
|
|
85
|
-
quote: element ? (element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim() : undefined,
|
|
86
|
-
image,
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
})();`;function Yr(e){return typeof e==`number`&&Number.isFinite(e)}function Xr(e){if(typeof e!=`object`||!e)return;let{scrollX:t,scrollY:n,width:r,height:i}=e;if(!(!Yr(t)||!Yr(n)||!Yr(r)||!Yr(i)||r<=0||i<=0))return{scrollX:t,scrollY:n,width:r,height:i}}function Zr(e){if(typeof e!=`object`||!e)return;let t=e;if(t.type===`${Ur}view`){let e=Xr(t);return e===void 0?void 0:{type:`view`,...e}}if(t.type!==`${Ur}inspected`||!Yr(t.id))return;let n=Xr(t.view);if(n===void 0)return;let r=typeof t.element==`object`&&t.element!==null&&typeof t.element.selector==`string`&&typeof t.element.tag==`string`?{selector:t.element.selector.slice(0,Wr),tag:t.element.tag.slice(0,64)}:void 0,i=typeof t.quote==`string`&&t.quote!==``?t.quote.slice(0,Gr):void 0,a=typeof t.image==`string`&&t.image.length<=4194304&&/^data:image\/png;base64,[A-Za-z\d+/]+=*$/u.test(t.image)?t.image:void 0;return{type:`inspected`,id:t.id,view:n,...r===void 0?{}:{element:r},...i===void 0?{}:{quote:i},...a===void 0?{}:{image:a}}}function Qr(e,t){return{type:`${Ur}inspect`,id:e,rect:t}}function $r(e){let t=atob(e.slice(e.indexOf(`,`)+1));return new Blob([Uint8Array.from(t,e=>e.charCodeAt(0))],{type:`image/png`})}function ei(e,t){let n=t.trim();if(n===``||Kr.test(n))return;let r=n.split(/[?#]/u)[0];if(r!==``)try{return ur(e,decodeURIComponent(r))}catch{return}}async function ti(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return`data:${e.type||`application/octet-stream`};base64,${btoa(n)}`}function ni(e,t){let n=new Map,r=[],a=0,o=o=>{let s=n.get(o);return s===void 0&&(s=Promise.resolve().then(()=>i.fetch(lr(e,o),{signal:t,cache:`no-store`})).then(async e=>{if(!e.ok)return;let t=await e.blob();if(!(t.size>8388608||a+t.size>25165824))return a+=t.size,t}).catch(()=>{t.throwIfAborted()}),n.set(o,s)),s.then(e=>(e===void 0&&!r.includes(o)&&r.push(o),e))};return{load:o,inlineCss:async(e,t)=>(await Promise.all([...e.matchAll(qr)].map(async e=>{let n=ei(t,e[2]),r=n===void 0?void 0:await o(n);return[e[0],r===void 0?void 0:`url("${await ti(r)}")`]}))).reduce((e,[t,n])=>n===void 0?e:e.replace(t,n),e),missing:r}}async function ri(e,t,n,r){let i=new DOMParser().parseFromString(n,`text/html`),{load:a,inlineCss:o,missing:s}=ni(e,r),c=[];for(let e of i.querySelectorAll(`img[src], source[src], video[src], audio[src], track[src], video[poster], input[src], image[href]`))for(let n of[`src`,`poster`,`href`]){let r=e.getAttribute(n),i=r===null?void 0:ei(t,r);i!==void 0&&c.push(a(i).then(async t=>{t!==void 0&&e.setAttribute(n,await ti(t))}))}for(let e of i.querySelectorAll(`link[href]`)){let n=ei(t,e.getAttribute(`href`)??``);if(n===void 0)continue;let r=e.relList.contains(`stylesheet`);c.push(a(n).then(async t=>{if(t===void 0)return;if(!r){e.setAttribute(`href`,await ti(t));return}let a=i.createElement(`style`);a.textContent=await o(await t.text(),n),e.replaceWith(a)}))}for(let e of i.querySelectorAll(`script[src]`)){let n=ei(t,e.getAttribute(`src`)??``);n!==void 0&&c.push(a(n).then(async t=>{t!==void 0&&(e.removeAttribute(`src`),e.textContent=await t.text())}))}for(let e of i.querySelectorAll(`style`))c.push(o(e.textContent??``,t).then(t=>{e.textContent=t}));await Promise.all(c),r.throwIfAborted();let l=i.createElement(`script`);return l.textContent=Jr,i.head.prepend(l),{html:`${i.doctype===null?``:`<!doctype ${i.doctype.name}>`}${i.documentElement.outerHTML}`,missing:s}}async function ii(e,t,n){let a;if(n!==void 0)a=new Blob([Uint8Array.from(atob(n),e=>e.charCodeAt(0))],{type:`image/png`});else{let n=await i.fetch(e,{signal:t,cache:`no-store`});if(!n.ok)throw Error(`Author media could not be loaded (${n.status}).`);if(a=await n.blob(),a.type.startsWith(`image/svg+xml`)){let e=r(await a.text());return t.throwIfAborted(),{url:e,dispose(){}}}}t.throwIfAborted();let o=URL.createObjectURL(a),s=!1;return{url:o,dispose(){s||(s=!0,URL.revokeObjectURL(o))}}}function ai(e){let t=Math.max(0,Math.round((Number.isFinite(e)?e:0)*1e3));return`${String(Math.floor(t/6e4)).padStart(2,`0`)}:${String(Math.floor(t/1e3)%60).padStart(2,`0`)}.${String(t%1e3).padStart(3,`0`)}`}function oi({playback:e,ready:n,locked:r,marking:i,onSeek:a,onToggle:o,onAnnotate:s}){let[c,l]=I(``),u=e.duration,d=c.trim()===``||!Number.isFinite(Number(c))||Number(c)<0||Number(c)>u,f=`min-h-11 px-3 text-base [@media(pointer:fine)]:min-h-8 sm:text-sm`;return v(`section`,{"aria-label":`Video annotation controls`,className:`mt-2 space-y-2 rounded border border-po-border bg-po-panel p-2.5 text-base text-po-text sm:text-sm`,children:[v(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[v(`output`,{"aria-label":`Playback position`,className:`font-mono text-base tabular-nums`,children:[ai(e.currentTime),` / `,ai(u)]}),g(`span`,{className:`text-po-dim`,children:r?`Annotation draft: add or discard it before seeking.`:i?`Frame paused. Drag a region on the video.`:`Seek to a moment, then choose Annotate this frame.`})]}),g(`input`,{"aria-label":`Video timeline`,type:`range`,min:0,max:u||0,step:.001,value:Math.min(e.currentTime,u),disabled:r||u<=0,onChange:e=>a(Number(e.target.value)),className:`h-11 w-full cursor-pointer accent-po-blue [@media(pointer:fine)]:h-6`}),v(`div`,{className:`flex flex-wrap items-center gap-2`,children:[g(t,{className:f,disabled:r||u<=0,onClick:o,children:e.playing?`Pause`:`Play`}),g(t,{className:f,disabled:r||u<=0,onClick:()=>a(Math.max(0,e.currentTime-.1)),"aria-label":`Seek back 0.1 seconds`,children:`−0.1s`}),g(t,{className:f,disabled:r||u<=0,onClick:()=>a(Math.min(u,e.currentTime+.1)),"aria-label":`Seek forward 0.1 seconds`,children:`+0.1s`}),g(t,{variant:`primary`,className:f,disabled:r||!n,onClick:s,children:`Annotate this frame`}),v(`form`,{className:`flex flex-wrap items-center gap-2 sm:ml-auto`,onSubmit:e=>{e.preventDefault(),!d&&!r&&a(Number(c))},children:[g(`label`,{htmlFor:`author-video-seconds`,className:`text-po-dim`,children:`Go to seconds`}),g(`input`,{id:`author-video-seconds`,type:`number`,min:0,max:u,step:.001,value:c,onChange:e=>l(e.target.value),disabled:r||u<=0,placeholder:`1.250`,className:`h-11 w-24 rounded border border-po-border bg-po-deep px-2 text-lg [@media(pointer:fine)]:h-8 sm:text-sm`}),g(t,{type:`submit`,className:f,disabled:r||u<=0||d,children:`Go`})]})]})]})}var si=`pointer-events-none absolute border-2 border-po-magenta bg-po-magenta/10`,ci=`absolute -left-3 -top-3 flex h-6 min-w-6 items-center justify-center rounded-full border-2 border-po-panel bg-po-magenta px-1 text-sm font-semibold text-po-rail`,li=300,ui=12,di=1.5,fi=.1;function pi({sessionId:e,document:n,activeTool:r,displayedRegions:i,pendingCandidate:a=!1,seekRequest:o}){let s=_(null),c=_(null),l=_(null),u=_(null),d=_(void 0),f=_(new Map),m=_(void 0),h=_(void 0),y=_(null),b=_(void 0),x=_(void 0),[S,C]=I(1),w=(e,t)=>{let n=Math.min(8,Math.max(.25,e));if(n===S)return;let r=s.current?.getBoundingClientRect(),i=y.current?.getBoundingClientRect();if(r&&i&&i.width>0&&i.height>0){let e=t?.x??r.left+r.width/2,n=t?.y??r.top+r.height/2;b.current={x:e,y:n,fx:(e-i.left)/i.width,fy:(n-i.top)/i.height}}C(n)},T=()=>{b.current=void 0,C(1),s.current&&(s.current.scrollLeft=0,s.current.scrollTop=0)};te(()=>{let e=b.current;b.current=void 0;let t=s.current,n=y.current?.getBoundingClientRect();e&&t&&n&&(t.scrollLeft+=n.left+e.fx*n.width-e.x,t.scrollTop+=n.top+e.fy*n.height-e.y)},[S]);let[E,D]=I(),[O,ee]=I(),[k,ne]=I({playing:!1,currentTime:0,duration:0}),[re,ie]=I(!1),[ae,A]=I(),[j,M]=I(),[N,P]=I();p(()=>{d.current=void 0,f.current.clear(),h.current=void 0,m.current=void 0,x.current=void 0,D(void 0),A(void 0),b.current=void 0,C(1)},[n.path,n.version,n.sourceSha256,n.mediaUrl]),p(()=>{d.current=void 0,D(void 0),f.current.clear(),h.current=void 0,m.current=void 0,x.current=void 0},[r]);let F=N?.source===n.mediaUrl?N?.url:void 0;p(()=>{if(n.kind!==`pdf`||F===void 0)return;let e=s.current;if(e===null)return;let t=()=>{let t=e.querySelector(`canvas`),n=e.querySelector(`[data-testid="author-media"]`);if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a={left:(r.left-i.left)/S,top:(r.top-i.top)/S,width:r.width/S,height:r.height/S};ee(e=>e&&Object.keys(a).every(t=>Math.abs(e[t]-a[t])<.01)?e:a)},r=new ResizeObserver(t),i=new MutationObserver(()=>{let n=e.querySelector(`canvas`);n&&r.observe(n),t()});i.observe(e,{childList:!0,subtree:!0});let a=e.querySelector(`canvas`);return a&&r.observe(a),t(),()=>{r.disconnect(),i.disconnect()}},[n.kind,F,S]),p(()=>{if(n.mediaUrl===void 0)return;let e=n.mediaUrl,t=new AbortController,r;return M(void 0),ii(e,t.signal,n.imageData).then(n=>{t.signal.aborted?n.dispose():(r=()=>n.dispose(),P({source:e,url:n.url}))}).catch(e=>{t.signal.aborted||M(e instanceof Error?e.message:String(e))}),()=>{t.abort(),r?.()}},[n.mediaUrl,n.imageData]);let se=t=>{if(W(e,n.path).candidate||!Number.isFinite(t))return;let r=l.current;r&&(r.pause(),G(e,n.path,`select`),A(void 0),r.getState().currentTime!==t&&(ie(!1),r.seek(t)))};p(()=>{o?.path===n.path&&o.generation===U(e).focusedDocument?.generation&&se(o.timeSeconds)},[o]),p(()=>{!a&&d.current===void 0&&A(void 0)},[a]),p(()=>Ye(e,(e,t)=>{let r=c.current;if(n.kind!==`image`||r===null||r.naturalWidth===0||r.naturalHeight===0)return;let{originX:i=0,originY:a=0,width:o,height:s}=t.viewport,l={left:i+e.rect.x*o,top:a+e.rect.y*s,right:i+(e.rect.x+e.rect.width)*o,bottom:a+(e.rect.y+e.rect.height)*s},u=r.getBoundingClientRect(),d=Math.max(u.left,l.left),f=Math.max(u.top,l.top),p=Math.min(u.right,l.right),m=Math.min(u.bottom,l.bottom);if(!(p<=d||m<=f||u.width<=0||u.height<=0))return{anchor:{kind:`image-rect`,rect:{x:(d-u.left)/u.width,y:(f-u.top)/u.height,width:(p-d)/u.width,height:(m-f)/u.height},naturalWidth:r.naturalWidth,naturalHeight:r.naturalHeight}}}),[e,n.kind,n.path,n.version]);let ce=async t=>{let r=d.current;if(!r||r.pointerId!==t.pointerId||h.current!==void 0)return;d.current=void 0;let i=r.element.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let a={x:Math.min(1,Math.max(0,(t.clientX-i.left)/i.width)),y:Math.min(1,Math.max(0,(t.clientY-i.top)/i.height))},o=r.mode===`draw`?Qt(r.points,a):void 0,s=r.mode===`draw`?Zt(o??[]):r.mode===`mark`?$t(i,{left:r.x,top:r.y,right:t.clientX,bottom:t.clientY}):void 0;if(r.mode!==`comment`&&!s)return;D(void 0),A(r.mode===`draw`?void 0:r.mode===`mark`?{path:n.path,rect:s}:{path:n.path,point:a});let c=U(e).focusedDocument;if(!c||c.path!==n.path)return;let f,p=null,m;try{if(r.element instanceof HTMLImageElement){let e=r.element;if(!e.naturalWidth||!e.naturalHeight)throw Error(`Image is not ready.`);f=r.mode===`comment`?{kind:`image-point`,point:a,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight}:{kind:`image-rect`,rect:s,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight};let t=document.createElement(`canvas`),n=Math.min(1,1600/Math.max(e.naturalWidth,e.naturalHeight));t.width=Math.max(1,Math.round(e.naturalWidth*n)),t.height=Math.max(1,Math.round(e.naturalHeight*n));let i=t.getContext(`2d`);if(!i)throw Error(`Canvas is unavailable.`);i.drawImage(e,0,0,t.width,t.height),p=await new Promise(e=>t.toBlob(e,`image/png`))}else if(n.kind===`pdf`){let e=u.current?.getState();if(!e?.sourceWidth)throw Error(`PDF page is not ready.`);if(f=r.mode===`comment`?{kind:`pdf-page-point`,page:e.page,point:a}:{kind:`pdf-page-rect`,page:e.page,rect:s},p=await u.current.capturePage(),u.current?.getState().page!==e.page)return}else{let e=await l.current?.captureFrame();if(!e)throw Error(`Video frame is not ready.`);if(f=r.mode===`comment`?{kind:`video-time-point`,point:a,timeSeconds:e.timeSeconds,intrinsicWidth:e.width,intrinsicHeight:e.height}:{kind:`video-time-rect`,rect:s,timeSeconds:e.timeSeconds,intrinsicWidth:e.width,intrinsicHeight:e.height},p=e.blob,Math.abs((l.current?.getState().currentTime??-1)-e.timeSeconds)>fi||l.current?.isFrameReady()===!1)return}if(!p)throw Error(`Unable to capture selected media.`);if(U(e).focusedDocument?.generation!==c.generation)return;m=URL.createObjectURL(p),ht(e,n.path,{documentPath:n.path,revision:n.version,sourceSha256:n.sourceSha256,mode:r.mode===`comment`?`point`:`region`,anchor:f,...o===void 0?{}:{stroke:o},viewport:{width:i.width,height:i.height},thumbnailUrl:m,evidence:p,createdAt:Date.now()}),M(void 0)}catch(e){m&&URL.revokeObjectURL(m),M(e instanceof Error?e.message:String(e))}},le=(e,t)=>e===void 0?null:g(`svg`,{"data-testid":t===void 0?`author-media-stroke-selection`:`author-media-stroke`,"data-author-stroke":t,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 h-full w-full overflow-visible`,viewBox:`0 0 1000 1000`,preserveAspectRatio:`none`,children:g(`polyline`,{points:e.map(e=>`${String(e.x*1e3)},${String(e.y*1e3)}`).join(` `),fill:`none`,stroke:`currentColor`,strokeWidth:`5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-po-magenta`})}),L=ae?.path===n.path?ae.rect:void 0,ue=ae?.path===n.path?ae.point:void 0,de=L===void 0?null:g(`div`,{"data-testid":`author-media-selection`,className:`pointer-events-none absolute border-2 border-dashed border-po-magenta bg-po-magenta/10`,style:{left:`${L.x*100}%`,top:`${L.y*100}%`,width:`${L.width*100}%`,height:`${L.height*100}%`}}),fe=(e,t,n)=>g(`span`,{"data-author-point":e,"data-testid":e===void 0?`author-media-point-selection`:void 0,className:`pointer-events-none absolute z-10 flex h-6 min-w-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border-2 px-1 text-sm font-semibold ${e===void 0?`border-po-magenta bg-po-panel text-po-magenta`:`border-po-panel bg-po-magenta text-po-rail`}`,style:{left:`${String(t.x*100)}%`,top:`${String(t.y*100)}%`},children:e??`•`},n),pe=ue===void 0?null:fe(void 0,ue,`selection`);return v(`div`,{className:`flex min-h-0 flex-1 flex-col`,style:{cursor:r===`draw`||r===`mark`?`crosshair`:void 0},onPointerMove:e=>{if(f.current.has(e.pointerId)&&f.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),h.current!==void 0&&f.current.size>=2){let[e,t]=[...f.current.values()],n=Math.hypot(e.x-t.x,e.y-t.y);h.current.distance>0&&w(h.current.zoom*n/h.current.distance,{x:(e.x+t.x)/2,y:(e.y+t.y)/2});return}if(m.current!==void 0){Math.hypot(e.clientX-m.current.x,e.clientY-m.current.y)>ui&&(m.current.moved=!0,x.current=void 0);let t=s.current;t&&(t.scrollLeft=m.current.left+m.current.x-e.clientX,t.scrollTop=m.current.top+m.current.y-e.clientY);return}let t=d.current;if(t?.pointerId!==e.pointerId)return;if(t.mode===`draw`){let n=t.element.getBoundingClientRect();if(n.width<=0||n.height<=0)return;t.points=Qt(t.points,{x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}),D(t.points);return}if(t.mode!==`mark`)return;let r=$t(t.element.getBoundingClientRect(),{left:t.x,top:t.y,right:e.clientX,bottom:e.clientY});A(r===null?void 0:{path:n.path,rect:r})},onPointerDownCapture:e=>{if(e.button!==0)return;e.pointerType!==`touch`&&(x.current=void 0);let t=e.target;if(!(t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement))return;if(f.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),f.current.size===2){d.current=void 0,D(void 0),A(void 0),m.current=void 0,x.current=void 0;let[t,n]=[...f.current.values()];h.current={distance:Math.hypot(t.x-n.x,t.y-n.y),zoom:S},e.currentTarget.setPointerCapture(e.pointerId);return}if(r===`pan`||r===`select`&&e.pointerType===`touch`){let t=s.current;t&&(m.current={x:e.clientX,y:e.clientY,left:t.scrollLeft,top:t.scrollTop,pointerId:e.pointerId,at:performance.now(),moved:!1}),e.currentTarget.setPointerCapture(e.pointerId);return}if(r!==`mark`&&r!==`comment`&&r!==`draw`||a)return;if(e.preventDefault(),A(void 0),t instanceof HTMLVideoElement){if(l.current?.isFrameReady?.()===!1){M(`Wait for the selected frame to finish loading.`);return}l.current?.pause()}let n=t.getBoundingClientRect();d.current={x:e.clientX,y:e.clientY,pointerId:e.pointerId,mode:r,element:t,points:r===`draw`?[{x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}]:[]},e.currentTarget.setPointerCapture(e.pointerId)},onPointerUp:e=>{let t=m.current;if(e.pointerType===`touch`&&t?.pointerId===e.pointerId&&h.current===void 0&&f.current.size===1){let n=performance.now(),r=!t.moved&&n-t.at<=li&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=ui,i=x.current;r&&i&&n-i.at<=li&&Math.hypot(e.clientX-i.x,e.clientY-i.y)<=24?(T(),x.current=void 0):x.current=r?{x:e.clientX,y:e.clientY,at:n}:void 0}h.current===void 0&&m.current===void 0&&ce(e),f.current.delete(e.pointerId),m.current=void 0,f.current.size<2&&(h.current=void 0)},onPointerCancel:e=>{f.current.delete(e.pointerId),h.current=void 0,m.current=void 0,x.current=void 0,d.current=void 0,D(void 0),A(void 0)},onLostPointerCapture:()=>{(m.current!==void 0||h.current!==void 0)&&(x.current=void 0),d.current=void 0,m.current=void 0,D(void 0)},children:[g(`div`,{ref:s,className:`@container flex min-h-0 flex-1 flex-col overflow-auto bg-po-deep/50 p-6`,children:v(`div`,{className:`m-auto flex max-w-full flex-col items-center-safe gap-3`,children:[F===void 0?g(`p`,{className:`text-po-dim`,children:j===void 0?`Loading media...`:`Media unavailable.`}):n.kind===`image`?v(`div`,{ref:y,className:`relative w-max max-w-[100cqw] touch-auto shadow-sm ring-1 ring-po-border-soft [@media(pointer:coarse)]:touch-none`,style:{zoom:S,touchAction:r===`select`?void 0:`none`},children:[g(`img`,{ref:c,src:F,alt:n.path,draggable:!1,className:`block max-w-full`}),de,pe,le(E),i.flatMap(({ordinal:e,region:t})=>{if(t.stroke!==void 0)return[v(`div`,{className:`pointer-events-none absolute inset-0`,children:[le(t.stroke,e),fe(e,t.stroke[0],`label:${t.id}`)]},t.id)];if(t.anchor.kind===`image-point`)return[fe(e,t.anchor.point,t.id)];if(t.anchor.kind!==`image-rect`)return[];let{rect:n}=t.anchor;return[g(`div`,{"data-author-region":e,className:si,style:{left:`${String(n.x*100)}%`,top:`${String(n.y*100)}%`,width:`${String(n.width*100)}%`,height:`${String(n.height*100)}%`},children:g(`span`,{className:ci,children:e})},t.id)]})]}):v(`div`,{ref:y,className:`relative w-max max-w-[100cqw] touch-auto shadow-sm ring-1 ring-po-border-soft [@media(pointer:coarse)]:touch-none`,style:{zoom:S,touchAction:r===`select`?void 0:`none`},children:[g(oe,{src:F,path:n.path,kind:n.kind===`pdf`?`pdf`:n.kind===`video`?`video`:`download`,controllerRef:l,pdfControllerRef:u,"data-testid":`author-media`,videoControls:!1,onPlaybackStateChange:e=>{ne(e),ie(l.current?.isFrameReady()??!1),e.playing&&A(void 0)}}),v(`div`,{className:`pointer-events-none absolute`,style:n.kind===`pdf`?O===void 0?{display:`none`}:{left:O.left,top:O.top,width:O.width,height:O.height}:{inset:0},children:[de,pe,le(E),i.map(({ordinal:e,region:t})=>{if(t.stroke!==void 0){let r=t.anchor;return n.kind===`pdf`&&(r.kind!==`pdf-page-rect`||r.page!==u.current?.getState().page)||n.kind===`video`&&(r.kind!==`video-time-rect`||k.playing||Math.abs(r.timeSeconds-k.currentTime)>fi)?null:v(`div`,{className:`pointer-events-none absolute inset-0`,children:[le(t.stroke,e),fe(e,t.stroke[0],`label:${t.id}`)]},t.id)}if(n.kind===`pdf`){if(t.anchor.kind!==`pdf-page-point`&&t.anchor.kind!==`pdf-page-rect`||t.anchor.page!==u.current?.getState().page)return null;if(t.anchor.kind===`pdf-page-point`)return fe(e,t.anchor.point,t.id);let{rect:n}=t.anchor;return g(`div`,{"data-author-region":e,className:si,style:{left:`${String(n.x*100)}%`,top:`${String(n.y*100)}%`,width:`${String(n.width*100)}%`,height:`${String(n.height*100)}%`},children:g(`span`,{className:ci,children:e})},t.id)}if(n.kind!==`video`||k.playing)return null;if(t.anchor.kind===`video-time-point`&&Math.abs(t.anchor.timeSeconds-k.currentTime)<=fi)return fe(e,t.anchor.point,t.id);if(t.anchor.kind!==`video-time-rect`||Math.abs(t.anchor.timeSeconds-k.currentTime)>fi)return null;let{rect:r}=t.anchor;return g(`div`,{"data-author-region":e,className:si,style:{left:`${r.x*100}%`,top:`${r.y*100}%`,width:`${r.width*100}%`,height:`${r.height*100}%`},children:g(`span`,{className:ci,children:e})},t.id)})]})]}),n.kind===`video`?g(oi,{playback:k,ready:re,locked:a,marking:r===`mark`,onSeek:se,onToggle:()=>{G(e,n.path,`select`),A(void 0),k.playing?l.current?.pause():l.current?.play().catch(e=>M(String(e)))},onAnnotate:()=>{l.current?.pause(),G(e,n.path,`mark`)}}):null,j?g(`output`,{className:`text-base text-po-red`,children:j}):null]})}),v(`footer`,{className:`flex shrink-0 items-center gap-2 border-t border-po-border bg-po-bg px-3 py-1.5 [@media(pointer:coarse)]:sr-only [@media(pointer:coarse)]:focus-within:not-sr-only`,children:[v(`div`,{role:`group`,"aria-label":`Canvas zoom`,className:`flex items-center gap-2`,children:[v(`div`,{className:`flex items-center rounded-md border border-po-border`,children:[g(t,{size:`md`,variant:`ghost`,"aria-label":`Zoom out`,className:`min-h-11 min-w-11 rounded-r-none [@media(pointer:fine)]:min-h-8`,onClick:()=>w(S/di),children:`−`}),v(`output`,{className:`flex min-w-14 items-center justify-center self-stretch border-x border-po-border-soft text-sm tabular-nums text-po-text`,children:[Math.round(S*100),`%`]}),g(t,{size:`md`,variant:`ghost`,"aria-label":`Zoom in`,className:`min-h-11 min-w-11 rounded-l-none [@media(pointer:fine)]:min-h-8`,onClick:()=>w(S*di),children:`+`})]}),g(t,{size:`md`,variant:`outline`,"aria-label":`Fit canvas`,className:`min-h-11 [@media(pointer:fine)]:min-h-8`,onClick:T,children:`Fit`})]}),g(`span`,{className:`ml-auto text-sm text-po-dim first-letter:uppercase`,children:n.kind})]})]})}var mi=4e3;function hi({points:e,testId:t}){return g(`svg`,{"data-testid":t,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 h-full w-full overflow-visible`,viewBox:`0 0 1000 1000`,preserveAspectRatio:`none`,children:g(`polyline`,{points:e.map(e=>`${String(e.x*1e3)},${String(e.y*1e3)}`).join(` `),fill:`none`,stroke:`currentColor`,strokeWidth:`5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-po-magenta`})})}function gi({ordinal:e,left:t,top:n}){return g(`span`,{"data-author-point":e,"data-testid":e===void 0?`author-html-point-selection`:void 0,className:`pointer-events-none absolute z-10 flex h-6 min-w-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border-2 px-1 text-sm font-semibold ${e===void 0?`border-po-magenta bg-po-panel text-po-magenta`:`border-po-panel bg-po-magenta text-po-rail`}`,style:{left:t,top:n},children:e??`•`})}var X=e=>`${String(e*100)}%`;function _i({sessionId:e,document:t,activeTool:n,displayedRegions:r,pendingCandidate:i=!1}){let a=_(null),o=_(void 0),s=_(1),c=_(new Map),[l,u]=I(),[d,f]=I(),[m,h]=I(),[y,b]=I(),[x,S]=I(),C=(n===`mark`||n===`comment`||n===`draw`)&&!i;p(()=>{let n=new AbortController;return f(void 0),ri(e,t.path,t.content??``,n.signal).then(e=>{n.signal.aborted||u(e)}).catch(e=>{n.signal.aborted||f(e instanceof Error?e.message:String(e))}),()=>n.abort()},[e,t.path,t.content]),p(()=>{let e=c.current,t=t=>{if(a.current===null||t.source!==a.current.contentWindow)return;let n=Zr(t.data);if(n===void 0)return;if(n.type===`view`){let{type:e,...t}=n;h(t);return}let{type:r,...i}=n;h(i.view),e.get(i.id)?.(i),e.delete(i.id)};return window.addEventListener(`message`,t),()=>{window.removeEventListener(`message`,t);for(let t of e.values())t(void 0);e.clear()}},[]),p(()=>{o.current=void 0,S(void 0),i||b(void 0)},[n,i,t.version]);let w=e=>new Promise(t=>{let n=a.current?.contentWindow;if(n==null){t(void 0);return}let r=s.current++,i=setTimeout(()=>{c.current.delete(r),t(void 0)},mi);c.current.set(r,e=>{clearTimeout(i),t(e)}),n.postMessage(Qr(r,e),`*`)}),T=(e,t)=>({x:Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)),y:Math.min(1,Math.max(0,(e.clientY-t.top)/t.height))}),E=async n=>{let r=o.current;if(r===void 0||r.pointerId!==n.pointerId)return;o.current=void 0;let i=n.currentTarget.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let a=T(n,i),s=r.mode===`draw`?Qt(r.points,a):void 0,c=r.mode===`draw`?Zt(s??[]):r.mode===`mark`?$t(i,{left:r.x,top:r.y,right:n.clientX,bottom:n.clientY}):void 0;if(S(void 0),r.mode!==`comment`&&!c)return;b(r.mode===`draw`?void 0:r.mode===`mark`?{rect:c}:{point:a});let l=U(e).focusedDocument;if(!l||l.path!==t.path)return;let u=c??{...a,width:0,height:0},d=await w({x:u.x*i.width,y:u.y*i.height,width:u.width*i.width,height:u.height*i.height});if(U(e).focusedDocument?.generation!==l.generation)return;let f=d?.view??m??{scrollX:0,scrollY:0,width:i.width,height:i.height},p=d?.image===void 0?void 0:$r(d.image),h=d?.element;ht(e,t.path,{documentPath:t.path,revision:t.version,sourceSha256:t.sourceSha256,mode:r.mode===`comment`?`point`:`region`,anchor:r.mode===`comment`?{kind:`html-point`,point:a,...h===void 0?{}:{element:h}}:{kind:`html-rect`,rect:c,...h===void 0?{}:{element:h}},...d?.quote===void 0?{}:{quote:d.quote},...s===void 0?{}:{stroke:s},viewport:f,...p===void 0?{}:{evidence:p,thumbnailUrl:URL.createObjectURL(p)},createdAt:Date.now()})},D=e=>{let t=e.viewport,n=m?.width??t.width,r=m?.height??t.height;return{dx:((t.scrollX??0)-(m?.scrollX??t.scrollX??0))/n,dy:((t.scrollY??0)-(m?.scrollY??t.scrollY??0))/r,sx:t.width/n,sy:t.height/r}};return v(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v(`div`,{className:`relative flex min-h-0 flex-1 bg-po-deep/50`,children:[l===void 0?g(`p`,{className:`m-auto text-po-dim`,children:d===void 0?`Loading page...`:`Page unavailable.`}):g(`iframe`,{ref:a,"data-testid":`author-html-frame`,title:`Rendered ${t.path}`,sandbox:`allow-scripts`,srcDoc:l.html,className:`h-full w-full flex-1 border-0 bg-white`}),v(`div`,{"data-testid":`author-html-overlay`,className:`absolute inset-0 overflow-hidden`,style:{pointerEvents:C?`auto`:`none`,cursor:n===`mark`||n===`draw`?`crosshair`:void 0,touchAction:C?`none`:`auto`},onPointerDown:e=>{if(e.button!==0||!C||l===void 0)return;e.preventDefault(),b(void 0);let t=e.currentTarget.getBoundingClientRect();o.current={x:e.clientX,y:e.clientY,pointerId:e.pointerId,mode:n,points:n===`draw`?[T(e,t)]:[]},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{let t=o.current;if(t?.pointerId!==e.pointerId)return;let n=e.currentTarget.getBoundingClientRect();if(t.mode===`draw`)t.points=Qt(t.points,T(e,n)),S(t.points);else if(t.mode===`mark`){let r=$t(n,{left:t.x,top:t.y,right:e.clientX,bottom:e.clientY});b(r===null?void 0:{rect:r})}},onPointerUp:e=>void E(e),onPointerCancel:()=>{o.current=void 0,S(void 0),b(void 0)},children:[y?.rect===void 0?null:g(`div`,{"data-testid":`author-html-selection`,className:`pointer-events-none absolute border-2 border-dashed border-po-magenta bg-po-magenta/10`,style:{left:X(y.rect.x),top:X(y.rect.y),width:X(y.rect.width),height:X(y.rect.height)}}),y?.point===void 0?null:g(gi,{left:X(y.point.x),top:X(y.point.y)}),x===void 0?null:g(hi,{points:x,testId:`author-html-stroke-selection`}),r.map(({ordinal:e,region:t})=>{let{anchor:n}=t;if(n.kind!==`html-rect`&&n.kind!==`html-point`)return null;let{dx:r,dy:i,sx:a,sy:o}=D(t);return t.stroke===void 0?n.kind===`html-point`?g(gi,{ordinal:e,left:X(r+n.point.x*a),top:X(i+n.point.y*o)},t.id):g(`div`,{"data-author-region":e,className:si,style:{left:X(r+n.rect.x*a),top:X(i+n.rect.y*o),width:X(n.rect.width*a),height:X(n.rect.height*o)},children:g(`span`,{className:ci,children:e})},t.id):v(`div`,{className:`pointer-events-none absolute`,style:{left:X(r),top:X(i),width:X(a),height:X(o)},children:[g(hi,{points:t.stroke,testId:`author-html-stroke`}),g(gi,{ordinal:e,left:X(t.stroke[0].x),top:X(t.stroke[0].y)})]},t.id)})]})]}),d!==void 0||(l?.missing.length??0)>0?g(`footer`,{className:`shrink-0 border-t border-po-border bg-po-bg px-3 py-1.5 text-sm`,children:d===void 0?v(`span`,{className:`text-po-dim`,children:[`Not found: `,l?.missing.join(`, `)]}):g(`output`,{className:`text-po-red`,children:d})}):null]})}function vi({sessionId:e,document:n,displayedRegions:r}){p(()=>Ye(e,(e,t)=>{let{originX:r=0,originY:i=0,width:a,height:o}=t.viewport,s=window.document.elementFromPoint(r+e.center.x*a,i+e.center.y*o)?.closest(`[data-author-fragment]`)?.dataset.authorFragment,c=n.fragments?.find(e=>e.id===s);if(c===void 0||c.readOnly===!0)return;if(n.kind===`csv`||n.kind===`xlsx`)return{anchor:{kind:`cell`,fragmentId:c.id,location:c.location},quote:c.text};let l=Number(c.location.match(/(?:slide\s*|slides\/slide)(\d+)/u)?.[1]);if(Number.isSafeInteger(l))return{anchor:{kind:`slide-element`,fragmentId:c.id,location:c.location,slide:l},quote:c.text}}),[n.fragments,n.kind,n.version,e]);let i=new Map(r.flatMap(({ordinal:e,region:t})=>t.anchor.kind===`cell`||t.anchor.kind===`slide-element`?[[t.anchor.fragmentId,e]]:[])),a=n.kind===`csv`||n.kind===`xlsx`,o=new Map;for(let e of n.fragments??[]){let t=a?n.kind===`csv`?e.location.split(`,`)[0]:e.location.replace(/![A-Z]+(\d+)$/,`!row $1`):e.location,r=o.get(t)??[];r.push(e),o.set(t,r)}return v(`div`,{"data-testid":`author-structured`,className:`min-h-0 flex-1 space-y-3 overflow-auto p-4`,children:[a?null:g(`p`,{className:`text-sm text-po-dim`,children:`Slide text view, not a layout-faithful rendering.`}),[...o].map(([r,o])=>v(`section`,{className:`space-y-1`,children:[g(`h3`,{className:`text-sm text-po-dim`,children:r}),g(`div`,{className:a?`flex gap-1`:`space-y-2`,children:o.map(r=>v(`div`,{"data-author-fragment":r.id,"data-author-region":i.get(r.id),className:`${a?`w-40 shrink-0`:``} relative rounded ${i.has(r.id)?`ring-1 ring-po-yellow`:``}`,children:[i.has(r.id)?g(`span`,{className:`absolute -left-1 -top-1 z-10 flex h-4 min-w-4 items-center justify-center rounded-full bg-po-yellow px-1 text-2xs font-semibold text-po-deep`,children:i.get(r.id)}):null,v(t,{size:`xs`,variant:`ghost`,onClick:t=>{let i=t.currentTarget.getBoundingClientRect(),o=Number(r.location.match(/(?:slide\s*|slides\/slide)(\d+)/)?.[1]);(a||Number.isSafeInteger(o))&&ht(e,n.path,{documentPath:n.path,revision:n.version,sourceSha256:n.sourceSha256,quote:r.text,anchor:a?{kind:`cell`,fragmentId:r.id,location:r.location}:{kind:`slide-element`,fragmentId:r.id,location:r.location,slide:o},viewport:{width:i.width,height:i.height},createdAt:Date.now()})},children:[`mark `,r.location]}),g(`textarea`,{"aria-label":r.location,value:r.text,readOnly:r.readOnly===!0,className:`w-full rounded border border-po-border bg-po-deep p-2 text-base text-po-text`,onChange:t=>Ct(e,n.path,r.id,t.target.value)})]},r.id))})]},r))]})}function yi({open:e,onOpenChange:n,onFormat:r,onCloseAutoFocus:i,disabled:a=!1}){return g(ne,{open:e,onOpenChange:n,children:v(E,{className:`inset-x-0 bottom-0 top-auto max-h-[70dvh] w-full max-w-none rounded-t-lg border-t data-[state=open]:animate-none!`,onCloseAutoFocus:i,children:[g(O,{closeLabel:`Close formatting`,className:`[&_button]:relative [&_button]:before:absolute [&_button]:before:-inset-3`,children:g(l,{children:`Formatting`})}),v(he,{className:`pb-6`,children:[g(s,{children:`Choose how to format the selected text.`}),Qe.map(({format:e,label:n})=>g(t,{variant:`ghost`,className:`min-h-11 w-full justify-start text-base`,disabled:a,onClick:()=>r(e),children:n},e))]})]})})}var bi=`p,li,h1,h2,h3,h4,h5,h6,pre,blockquote,td,th`,xi=`po-author-note`,Si=`•`;function Ci(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.parentElement?.closest(`svg,button,[aria-hidden="true"]`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),n=[];for(let e=t.nextNode();e!==null;e=t.nextNode())n.push(e);return n}function wi(e,t,n){let r=Ci(e),i=rt(t,r.map(e=>e.data)),a,o;return r.forEach((e,r)=>{let s=i[r];s!==void 0&&n.intersectsNode(e)&&(a??=s+(e===n.startContainer?n.startOffset:0),o=Math.min(t.length,s+(e===n.endContainer?n.endOffset:e.data.length)))}),a===void 0||o===void 0||o<=a?void 0:{from:a,to:o}}function Ti(e,t,n,r){let i=Ci(e),a=rt(t,i.map(e=>e.data)),o,s;if(i.forEach((e,t)=>{let i=a[t];i===void 0||i+e.data.length<=n||i>=r||(o??={run:e,offset:Math.max(0,n-i)},s={run:e,offset:Math.min(e.data.length,r-i)})}),o===void 0||s===void 0)return;let c=e.ownerDocument.createRange();return c.setStart(o.run,o.offset),c.setEnd(s.run,s.offset),c}function Ei(e,t){let n=e.ownerDocument.createRange(),r=Ci(e).filter(e=>(n.selectNodeContents(e),[...n.getClientRects()].some(e=>e.right>t.left&&e.left<t.right&&e.bottom>t.top&&e.top<t.bottom))),i=r[0],a=r.at(-1);if(i!==void 0&&a!==void 0)return n.setStart(i,0),n.setEnd(a,a.data.length),n}function Di({sessionId:e,document:n,preview:r,activeTool:i=`select`,displayedRegions:a,candidate:s,renderMediaReview:c}){let l=_(null),u=_(null),d=_(null),f=_({from:0,to:0}),[m,y]=I(),[b,x]=I(),[S,C]=I([]),[w,T]=I(!1),E=_(void 0),D=_(void 0),O=!r&&n.kind===`markdown`&&!or(n.path);p(()=>{E.current=void 0,D.current=void 0,T(!1)},[e,n.path,O]);let ee=[...a.flatMap(({ordinal:e,region:t})=>t.anchor.kind===`text-range`?[{label:String(e),from:t.anchor.startOffset,to:t.anchor.endOffset}]:[]),...s?.anchor.kind===`text-range`?[{label:Si,from:s.anchor.startOffset,to:s.anchor.endOffset}]:[]],te=JSON.stringify(ee);p(()=>Ye(e,(e,t)=>{if(r||u.current===null)return;let{originX:n=0,originY:i=0,width:a,height:o}=t.viewport,s=u.current.resolveViewportRegion({left:n+e.rect.x*a,top:i+e.rect.y*o,right:n+(e.rect.x+e.rect.width)*a,bottom:i+(e.rect.y+e.rect.height)*o});if(s!==null&&s.from!==s.to)return{anchor:{kind:`text-range`,startOffset:s.from,endOffset:s.to,startLine:s.startLine,endLine:s.endLine},quote:s.text}}),[r,e]),p(()=>{u.current?.setMarkedRanges(JSON.parse(te))},[te]),p(()=>{let e=d.current,t=e?.parentElement;if(!r||!e||!t)return;let i=()=>{let r=n.content??``,i=JSON.parse(te).flatMap(t=>{let n=Ti(e,r,t.from,t.to);return n===void 0?[]:[{label:t.label,range:n}]});typeof CSS<`u`&&`highlights`in CSS&&CSS.highlights.set(xi,new Highlight(...i.map(({range:e})=>e)));let a=t.getBoundingClientRect();C(i.map(({label:e,range:t})=>{let n=t.getClientRects()[0]??t.getBoundingClientRect();return{label:e,left:n.left-a.left,top:n.top-a.top}}))};i();let a=typeof ResizeObserver>`u`?void 0:new ResizeObserver(i);return a?.observe(e),()=>{a?.disconnect(),typeof CSS<`u`&&`highlights`in CSS&&CSS.highlights.delete(xi)}},[r,te,n.content]);let k=(n.content??``).split(`
|
|
90
|
-
`).length,ne=o(async t=>{let r=ur(n.path,t);return{...await ii(lr(e,r),new AbortController().signal),path:r}},[e,n.path]),re=(t,r=f.current)=>{let i=H(e,n.path);if(!i||u.current===null)return;let{from:a,to:o}=r,s=tt(i.content??``,a,o,t);u.current.applyEdits([{from:s.from,to:s.to,insert:s.insert}]),u.current.revealAndSelect(s.select),u.current.focus()},ie=()=>{let t=H(e,n.path);!t||u.current===null?x(`The editor is still loading. Try formatting again.`):E.current={...f.current,content:t.content??``,path:t.path,sessionId:e}},ae=t=>{t.preventDefault();let r=E.current,i=D.current;if(E.current=void 0,D.current=void 0,!r||r.sessionId!==e||r.path!==n.path)return;let a=H(e,n.path);if(i!==void 0){if((a?.content??``)!==r.content){x(`Text changed while formatting was open. Select it again.`),u.current?.focus();return}re(i,r)}else(a?.content??``)===r.content&&u.current?.revealAndSelect(r),u.current?.focus()},oe=(t,r,i)=>{let a=H(e,n.path),o=l.current?.getBoundingClientRect();if(!a||!o)return;if(t===void 0||t.to<=t.from){x(i);return}let s=a.content??``;x(void 0),ht(e,n.path,{documentPath:a.path,revision:a.version,sourceSha256:a.sourceSha256,mode:r,quote:s.slice(t.from,t.to),anchor:{kind:`text-range`,startOffset:t.from,endOffset:t.to,startLine:it(s,t.from),endLine:it(s,t.to)},viewport:{width:o.width,height:o.height},createdAt:Date.now()})},A=(t,r)=>{d.current!==null&&oe(wi(d.current,H(e,n.path)?.content??``,t),r,`That part of the page has no source text to mark. Press Edit to select it in the source.`)},j=()=>{if(i!==`select`||d.current===null)return;let e=window.getSelection();if(e===null||e.isCollapsed||e.rangeCount===0)return;let t=e.getRangeAt(0);d.current.contains(t.commonAncestorContainer)&&A(t,`region`)},M=i===`mark`||i===`comment`,N=(e,t)=>{let n=e.currentTarget.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top;return{...t,left:Math.min(t.x,r),top:Math.min(t.y,i),width:Math.abs(r-t.x),height:Math.abs(i-t.y)}},P=(t,r)=>{let a=H(e,n.path)?.content??``;if(u.current===null)return;if(i===`comment`){let e=u.current.resolveViewportRegion({left:t.clientX,top:t.clientY,right:t.clientX,bottom:t.clientY}),n=e===null?0:a.lastIndexOf(`
|
|
91
|
-
`,e.from-1)+1,r=e===null?-1:a.indexOf(`
|
|
92
|
-
`,e.from);oe(e===null?void 0:{from:n,to:r===-1?a.length:r},`point`,`Click a line with text to comment on it.`);return}let o=N(t,r);if(o.width<4&&o.height<4)return;let s=t.currentTarget.getBoundingClientRect(),c=u.current.resolveViewportRegion({left:s.left+o.left,top:s.top+o.top,right:s.left+o.left+o.width,bottom:s.top+o.top+o.height});oe(c===null?void 0:{from:c.from,to:c.to},`region`,`Drag over some text to mark it.`)},F=M?g(`div`,{"data-testid":`author-text-overlay`,className:`absolute inset-0 z-10 touch-none ${i===`mark`?`cursor-crosshair`:`cursor-pointer`}`,onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;y({pointerId:e.pointerId,x:n,y:r,left:n,top:r,width:0,height:0}),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{i===`mark`&&m?.pointerId===e.pointerId&&y(N(e,m))},onPointerUp:e=>{let t=m;if(y(void 0),t===void 0||t.pointerId!==e.pointerId)return;if(!r){P(e,t);return}if(d.current===null)return;if(i===`comment`){let t=window.document.elementsFromPoint(e.clientX,e.clientY).find(e=>d.current?.contains(e)&&e.closest(bi)!==null)?.closest(bi);if(!t)return;let n=window.document.createRange();n.selectNodeContents(t),A(n,`point`);return}let n=N(e,t);if(n.width<4||n.height<4)return;let a=e.currentTarget.getBoundingClientRect(),o=Ei(d.current,new DOMRect(a.left+n.left,a.top+n.top,n.width,n.height));o===void 0?x(`Drag over some text to mark it.`):A(o,`region`)},onPointerCancel:()=>y(void 0),onWheel:e=>r?void 0:l.current?.querySelector(`.cm-scroller`)?.scrollBy({left:e.deltaX,top:e.deltaY}),children:m===void 0||i!==`mark`?null:g(`div`,{"data-testid":`author-text-selection`,className:`pointer-events-none absolute border-2 border-dashed border-po-magenta bg-po-magenta/10`,style:{left:m.left,top:m.top,width:m.width,height:m.height}})}):null;return v(`div`,{ref:l,className:`flex min-h-0 flex-1 flex-col`,children:[O?v(`div`,{role:`toolbar`,"aria-label":`Format Markdown`,"data-testid":`author-format-toolbar`,className:`hidden shrink-0 items-center gap-1 border-b border-po-border bg-po-bg px-3 py-1.5 [@media(pointer:fine)]:flex`,children:[Qe.map(({format:e,label:n,glyph:r})=>v(t,{size:`sm`,variant:`ghost`,"aria-label":n,title:n,className:`min-h-11 gap-1.5 [@media(pointer:fine)]:min-h-8`,onMouseDown:e=>e.preventDefault(),onClick:()=>re(e),children:[g(`span`,{"aria-hidden":`true`,className:`font-semibold`,children:r}),g(`span`,{className:`text-sm`,children:n})]},e)),g(`span`,{className:`ml-auto truncate text-sm text-po-dim`,children:`Select text, then format it.`})]}):null,O?v(`div`,{className:`shrink-0 border-b border-po-border bg-po-bg px-3 py-1.5 [@media(pointer:fine)]:hidden`,children:[g(t,{variant:`outline`,className:`min-h-11`,"aria-label":`Formatting`,"aria-haspopup":`dialog`,"aria-expanded":w,onPointerDown:ie,onClick:()=>{E.current||ie(),E.current&&T(!0)},children:`Formatting`}),g(yi,{open:w,onOpenChange:T,onFormat:e=>{D.current===void 0&&(D.current=e,T(!1))},onCloseAutoFocus:ae})]}):null,r?g(`div`,{"data-testid":`author-markdown`,className:`min-h-0 flex-1 overflow-auto bg-po-deep/50 p-6`,children:v(`div`,{className:`relative mx-auto min-h-full max-w-3xl`,children:[g(`article`,{ref:d,onPointerUp:j,onKeyUp:j,className:`min-h-full rounded-md bg-po-panel px-6 py-8 sm:px-10 text-lg leading-relaxed text-po-text shadow-sm ring-1 ring-po-border-soft [&::highlight(po-author-note)]:bg-po-tint-magenta [&_*::highlight(po-author-note)]:bg-po-tint-magenta`,children:g(ue,{text:or(n.path)?`\`\`\`\`mermaid\n${n.content??``}\n\`\`\`\``:n.content??``,loadImage:ne,documentPath:n.path,renderMediaReview:c})}),S.map((e,t)=>g(`span`,{"aria-hidden":`true`,"data-author-region":e.label,className:`pointer-events-none absolute z-10 flex h-6 min-w-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border-2 px-1 text-sm font-semibold ${e.label===Si?`border-po-magenta bg-po-panel text-po-magenta`:`border-po-panel bg-po-magenta text-po-rail`}`,style:{left:e.left,top:e.top},children:e.label},`${e.label}-${String(t)}`)),F]})}):v(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[g(h,{value:n.content??``,path:n.path,"data-testid":`author-editor`,controllerRef:u,className:`min-h-0 flex-1`,onChange:t=>St(e,n.path,t),onSelect:t=>{f.current={from:t.from,to:t.to};let r=H(e,n.path),i=l.current?.getBoundingClientRect();r&&i&&t.from!==t.to&&ht(e,n.path,{documentPath:r.path,revision:r.version,sourceSha256:r.sourceSha256,quote:t.text,anchor:{kind:`text-range`,startOffset:t.from,endOffset:t.to,startLine:t.startLine,endLine:t.endLine},viewport:{width:i.width,height:i.height},createdAt:Date.now()})}}),F]}),b===void 0?null:g(`output`,{className:`shrink-0 border-t border-po-border bg-po-bg px-4 py-1.5 text-sm text-po-dim`,children:b}),v(`footer`,{className:`flex shrink-0 items-center gap-2 border-t border-po-border bg-po-bg px-4 py-1.5 text-sm text-po-dim`,children:[g(`span`,{className:`first-letter:uppercase`,children:n.kind}),g(`span`,{"aria-hidden":`true`,children:`·`}),v(`span`,{children:[k,` line`,k===1?``:`s`]})]})]})}var Oi={select:`↖`,pan:`✋`,mark:`⌗`,comment:`●`,draw:`✎`},ki=new Map,Ai=new Map,ji=new Map,Mi=e=>e instanceof Error?e.message:String(e);function Ni(e,t){zn.session(e).bridgeClose({body:{alias:t}}).then(e=>{e.ok||console.warn(`Author canvas '${t}' did not close: ${e.error}`)}).catch(e=>console.warn(`Author canvas '${t}' did not close: ${Mi(e)}`))}function Pi(e){let t=2166136261;for(let n of z(e))t=Math.imul(t^n.charCodeAt(0),16777619);return`${Bn}${(t>>>0).toString(36)}`}function Fi(e){return(e?.annotations??[]).map((e,t)=>({ordinal:t+1,region:e}))}function Ii(n){let{sessionId:r,statuses:i}=n,a=C(qt,e=>r===null?n.path:e[B(r,n.path)]??n.path),o=C(J,e=>n.alias??(r===null?void 0:e[B(r,n.path)])),s=C(Jt,e=>r===null?void 0:e[B(r,n.path)]),c=C(V.store,e=>r===null?void 0:e.documents[B(r,a)]),l=C(V.store,e=>r===null?void 0:e.sessions[r]),u=C(V.store,e=>W(r,a,e)),d=l?.toolsByDocument[z(a)]??`select`,[f,m]=I(!0),[h,_]=I(),y=l?.previewSelections?.[z(n.path)]??l?.previewSelections?.[z(a)],[b,x]=I(y!==void 0),[S,w]=I(!1);p(()=>{y!==void 0&&x(!0)},[y]);let T=c?.kind,E=c===void 0?void 0:{path:c.path,kind:c.kind,hasUnsavedChanges:c.version!==c.savedVersion,revision:c.savedVersion,sourceSha256:c.sourceSha256,...y===void 0?{}:{preview:y}},D=(E===void 0?void 0:(n.slotData?.(Xn)??[]).find(({data:e})=>e.embeddedPanel!==void 0&&(e.supportsSource===void 0||e.supportsSource(E))))?.data.embeddedPanel;p(()=>{if(r===null)return;let e=ut(r,a);return()=>dt(r,e)},[a,r]);let O=n.slotData?.(qn);if(p(()=>{r!==null&&O!==void 0&&$n(r,O)},[O,r]),p(()=>{if(T===void 0||r===null||o===void 0)return;let e=Vr(r,a,T),t,n=!1;return Re(r,e,o).then(e=>{n?e():t=e}),()=>{n=!0,t?.()}},[o,T,a,r]),p(()=>{T===`html`&&d===`draw`&&w(!1)},[d,T]),c===void 0||r===null)return g(`p`,{className:`p-4 text-sm text-po-dim`,children:s??h??`Loading document...`});let ee=async()=>{let e=c.version,t=c.fragments;Et(r,a),_(`saving`);try{let n=await br(r,c);Ot(r,a,n,e,t),_(`saved`)}catch(t){Dt(r,a,e),_(t instanceof Error?t.message:String(t))}},te=Gt(i),k=Fi(u),ne=k.flatMap(({ordinal:e,region:t})=>t.anchor.kind===`story-preview-rect`?[{ordinal:e,mode:`region`,point:t.anchor.rect,rect:t.anchor.rect,stroke:t.stroke}]:t.anchor.kind===`story-preview-point`?[{ordinal:e,mode:`point`,point:t.anchor.point}]:[]),ie=g(Di,{sessionId:r,document:c,preview:c.kind===`markdown`&&f&&!te,activeTool:d,displayedRegions:k,candidate:u.candidate,renderMediaReview:me(n)}),ae=c.kind===`html`&&!S?g(_i,{sessionId:r,document:c,activeTool:d,displayedRegions:k,pendingCandidate:u.candidate!==void 0},c.path):c.kind===`text`||c.kind===`markdown`||c.kind===`story-preview`||c.kind===`html`?ie:c.structuredFormat===void 0?g(pi,{sessionId:r,document:c,activeTool:d,displayedRegions:k,pendingCandidate:u.candidate!==void 0,seekRequest:l?.videoSeekRequest},c.path):g(vi,{sessionId:r,document:c,displayedRegions:k});return v(`section`,{"data-testid":`author-document`,className:`flex min-h-0 flex-1 flex-col`,children:[v(`header`,{className:`flex items-center gap-2 border-b border-po-border bg-po-bg px-4 py-2`,children:[g(re,{"aria-hidden":`true`,className:`size-4 shrink-0 text-po-dim`}),v(`strong`,{className:`min-w-0 truncate text-base font-medium text-po-hi`,children:[o===void 0?``:`${o} · `,c.title??g(`span`,{className:`font-mono`,children:c.path})]}),g(`span`,{className:`min-w-0 flex-1`,children:c.version===c.savedVersion?null:v(`span`,{className:`inline-flex items-center gap-1.5 text-sm text-po-dim`,children:[g(e,{tone:`green`,size:`md`}),`unsaved`]})}),D!==void 0&&E!==void 0?g(t,{size:`xs`,variant:b?`primary`:`outline`,"data-testid":`author-story-preview-toggle`,"aria-pressed":b,"aria-label":b?`show story source`:`show story preview`,onClick:()=>x(!b),children:b?`Source`:`Preview`}):null,c.kind===`markdown`?g(t,{size:`sm`,variant:`outline`,className:`min-h-11 [@media(pointer:fine)]:min-h-8`,"data-testid":`author-markdown-toggle`,onClick:()=>m(!f),children:g(`span`,{className:`first-letter:uppercase`,children:f?`edit`:`preview`})}):null,c.kind===`html`?g(t,{size:`sm`,variant:`outline`,className:`min-h-11 [@media(pointer:fine)]:min-h-8`,"data-testid":`author-html-toggle`,"aria-pressed":S,onClick:()=>w(!S),children:S?`Preview`:`Source`}):null,c.kind===`video`?g(`span`,{className:`text-base text-po-dim`,children:`Video feedback`}):g(t,{className:`min-h-11 px-4 text-base [@media(pointer:fine)]:min-h-8`,variant:`outline`,"data-testid":`author-save`,disabled:c.revisions.length===0||c.savingVersion!==void 0,onClick:()=>void ee(),children:b&&E?.hasUnsavedChanges?`Save & refresh`:`Save`})]}),h===void 0?null:g(`output`,{className:`px-4 py-1 text-sm text-po-dim`,children:h}),[`image`,`pdf`,`video`,`story-preview`,`html`].includes(c.kind)?g(`nav`,{"aria-label":`Author canvas tools`,className:`flex shrink-0 gap-1.5 overflow-x-auto border-b border-po-border bg-po-bg px-3 py-2 sm:hidden`,children:[`select`,`pan`,`mark`,`comment`,`draw`].map(e=>v(t,{size:`md`,variant:`outline`,className:`min-w-16 shrink-0 ${Pn(d===e,e!==`select`&&e!==`pan`)}`,"aria-label":`${e} tool`,"aria-pressed":d===e,onClick:()=>G(r,c.path,e),children:[g(`span`,{"aria-hidden":`true`,className:`text-lg leading-none`,children:Oi[e]}),g(`span`,{className:`text-sm first-letter:uppercase`,children:e})]},e))}):null,v(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[b&&D!==void 0&&E!==void 0?g(D,{...n,source:E,activeTool:d===`crop`?`select`:d,displayedAnnotations:ne,pendingCandidate:u.candidate!==void 0,onAnnotationCandidate:e=>{At(r,c.path,e.preview),ht(r,c.path,{documentPath:c.path,revision:c.version,sourceSha256:c.sourceSha256,mode:e.mode,stroke:e.stroke,anchor:e.mode===`region`&&e.rect!==void 0?{kind:`story-preview-rect`,rect:e.rect,preview:e.preview}:{kind:`story-preview-point`,point:e.point,preview:e.preview},viewport:e.preview.viewport,evidence:e.evidence,thumbnailUrl:e.thumbnailUrl,createdAt:Date.now()})}}):ae,b&&D!==void 0&&E!==void 0?null:g(Kt,{sessionId:r,document:c,visible:te})]}),[`image`,`pdf`,`video`,`story-preview`,`html`].includes(c.kind)?g(`div`,{className:`max-h-56 shrink-0 overflow-y-auto border-t border-po-border bg-po-bg p-3 sm:hidden`,children:g(wn,{sessionId:r,document:c,drafts:u,submitCapture:n.submitCapture})}):null]})}var Li={version:1,watchFocusedPath(e,t){let n=V.store.state.sessions[e]?.focusedDocument?.path;t(n);let r=V.store.subscribe(()=>{let r=V.store.state.sessions[e]?.focusedDocument?.path;r!==n&&(n=r,t(n))});return()=>r.unsubscribe()},createTab({sessionId:e,path:t,preview:n}){let r=z(t);if(e.trim()===``||r===``||t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.replaceAll(`\\`,`/`).split(`/`).includes(`..`))throw Error(`Author source opening requires a session and a repository-relative path.`);if(n!==void 0&&(typeof n.appPath!=`string`||n.appPath.trim()===``||typeof n.storyExport!=`string`||!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n.storyExport)||n.snapshot!==void 0&&typeof n.snapshot!=`boolean`))throw Error(`Author preview requires a project and an exact story export.`);let i=qt.state[B(e,r)]??r,a=`${e}\n`,o=(Object.entries(qt.state).find(([e,t])=>e.startsWith(a)&&t===i)?.[0])?.slice(a.length)??r;return pt(e,o,n),i!==o&&pt(e,i,n),Ri(o,J.state[B(e,o)])}};function Ri(e,t){let n=z(e);return{id:Pi(n),label:t===void 0?dr(n):`${t} · ${dr(n)}`,retainComposer:!0,composerAside:!0,asideFace:`authoring`,composerContext(e){let t=B(e,n),r=qt.state[t]??n,i=J.state[t],a=dr(r);return{kind:`author-document`,source:`author`,id:r,label:i===void 0?a:`${i} · ${a}`,content:un(r,i,W(e,r).annotations)}},onOpen(e){let r=B(e,n),i=new AbortController;ki.set(r,i),ji.delete(r),Jt.setState(e=>{let t={...e};return delete t[r],t}),(async()=>{let a=await zn.session(e).documentsOpen({body:{path:n,...t===void 0?{}:{alias:t}},query:{session:e},signal:i.signal});if(!a.ok)throw Error(a.error);if(!(`alias`in a.data)||typeof a.data.alias!=`string`)throw Error(`The Author canvas did not return an alias. Reopen the document.`);let o=a.data,s=o.alias;if(i.signal.aborted||ki.get(r)!==i){(Ai.get(`${e}\n${s}`)?.size??0)===0&&Ni(e,s);return}J.setState(t=>({...t,[r]:s,[B(e,o.path)]:s})),qt.setState(e=>({...e,[r]:o.path}));let c=`${e}\n${s}`,l=Ai.get(c)??new Set;l.add(r),Ai.set(c,l);let u=B(e,o.path);if(V.store.state.documents[u]===void 0){let t=await mr(e,o.path,i.signal);if(i.signal.aborted||ki.get(r)!==i)return;lt(e,t)}let d=V.store.state.documents[u];d!==void 0&&!i.signal.aborted&&await Le(e,s,Vr(e,o.path,d.kind))})().catch(e=>{!i.signal.aborted&&ki.get(r)===i&&Jt.setState(t=>({...t,[r]:e instanceof Error?e.message:String(e)}))}).finally(()=>{ki.get(r)===i&&ki.delete(r),ji.get(r)===i&&ji.delete(r)})},onClose(e){let r=B(e,n),i=qt.state[r]??n;G(e,i,`select`),pt(e,n,void 0),i!==n&&pt(e,i,void 0);let a=ki.get(r);ki.delete(r);let o=J.state[r]??(a===void 0?t:void 0);if(o===void 0){a!==void 0&&ji.set(r,a);return}a?.abort();let s=Ai.get(`${e}\n${o}`);s?.delete(r),s!==void 0&&s.size===0&&Ai.delete(`${e}\n${o}`);let c=s===void 0||s.size===0;c&&Be(e,o),J.setState(e=>{let t={...e};return delete t[r],t}),qt.setState(e=>{let t={...e};return delete t[r],t}),Jt.setState(e=>{let t={...e};return delete t[r],t}),c&&Ni(e,o)},panel:e=>g(Ii,{...e,path:n})}}var zi=(e,t,n)=>{if(e.openSessionTab===void 0||e.closeSessionTab===void 0)return;let r=`${t}\n`,i=new Set(n.map(e=>e.alias));for(let[n,a]of Ai)if(n.startsWith(r)&&!i.has(n.slice(r.length)))for(let n of a)e.closeSessionTab(t,Pi(n.slice(r.length)));for(let{alias:i,path:a}of n)(Ai.get(`${r}${i}`)?.size??0)>0||ji.has(B(t,z(a)))||e.openSessionTab(t,Ri(a,i))},Bi=S({requiredMode:`author`,subscribe(e){let t=V.store.subscribe(e);return()=>t.unsubscribe()},fingerprint(e){if(e===null)return``;let t=`${e}\n`;return Object.keys(V.store.state.documents).filter(e=>e.startsWith(t)).sort().join(`
|
|
93
|
-
`)},resolve(e,t){if(e===null)return;let n=z(t.replace(/:\d+(?::\d+)?$/,``));return V.store.state.documents[B(e,n)]===void 0?void 0:Ri(n,J.state[B(e,n)])},openPath(e,t){if(e===null)return;let n=z(t);return n===``?void 0:Ri(n,J.state[B(e,n)])}}),Vi=N({slot:`author.open-source`,id:`author`,data:Li}),Hi=N({slot:`help.guides`,id:`Author`,order:40,data:{version:1,label:`Author`,guides:[{id:`review`,question:`How do I review a document with Po?`,order:0,answer:`Open a document in an Author canvas to annotate it or give image feedback. Messages from its file tab include the document as context.`},{id:`agent`,question:`Can Po use a document I open?`,order:1,answer:`Po can open and use any document canvas you open, with the same canvas tools you see.`}]}}),Ui=20971520,Wi=[137,80,78,71,13,10,26,10];async function Gi(e,t,n){if(e.sessionId!==t||e.mimeType!==`image/png`||!/^[a-zA-Z0-9_-]+$/u.test(t)||e.id.length===0||e.originalPath.length===0||!/^[a-f0-9]{64}$/u.test(e.sourceSha256))throw Error(`Image feedback requires a verified artifact from the active session.`);if(e.data.length>Math.ceil(Ui/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(e.data))throw Error(`Image feedback PNG exceeds the size limit or is invalid.`);let r=atob(e.data),i=Uint8Array.from(r,e=>e.charCodeAt(0));if(i.length>Ui||Wi.some((e,t)=>i[t]!==e))throw Error(`Image feedback requires PNG bytes.`);n.throwIfAborted();let a=new Uint8Array(await crypto.subtle.digest(`SHA-256`,i)),o=Array.from(a,e=>e.toString(16).padStart(2,`0`)).join(``);if(n.throwIfAborted(),o!==e.sourceSha256)throw Error(`Image feedback source digest does not match.`);return{path:`image-artifact/${encodeURIComponent(e.id)}/${o}.png`,kind:`image`,title:`Generated image feedback`,sourceSha256:o,imageData:e.data,mediaUrl:`image-artifact:${o}`,imageArtifact:{id:e.id,sessionId:t,originalPath:e.originalPath,sourceSha256:o}}}function Ki({target:e,sessionId:t,submitCapture:n}){let r=t===e.sessionId,[i,a]=I(),[o,s]=I();p(()=>{if(a(void 0),s(void 0),!r||t===null)return;let n=new AbortController,i;return Gi(e,t,n.signal).then(e=>{n.signal.aborted||(a(lt(t,e)),i=ut(t,e.path))}).catch(e=>{n.signal.aborted||s(e instanceof Error?e.message:String(e))}),()=>{n.abort(),i!==void 0&&dt(t,i)}},[r,t,e]);let c=C(V.store,e=>W(t,i?.path??``,e)),l=C(V.store,e=>t===null?`select`:e.sessions[t]?.toolsByDocument[i?.path??``]??`select`);if(!r||t===null)return null;if(o)return g(`output`,{children:o});if(!i||i.imageArtifact?.id!==e.id||i.sourceSha256!==e.sourceSha256)return g(`output`,{children:`Loading image feedback…`});let u=c.annotations.map((e,t)=>({ordinal:t+1,region:e}));return v(`section`,{className:`flex min-h-0 flex-col gap-3`,"data-testid":`author-image-feedback`,children:[g(`p`,{className:`text-sm text-po-dim`,children:`Original preserved. Submit annotations to request a new refinement.`}),g(`div`,{className:`sm:hidden`,children:g(Fn,{sessionId:t,path:i.path,kind:`image`,activeTool:l})}),g(pi,{sessionId:t,document:i,activeTool:l,displayedRegions:u,pendingCandidate:c.candidate!==void 0}),g(`div`,{className:`sm:hidden`,children:g(wn,{sessionId:t,document:i,drafts:c,submitCapture:n})})]})}var qi=N({slot:`author.image-feedback`,id:`image-feedback`,data:{version:1,panel:Ki}}),Ji=4096,Yi=8192;function Xi(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}async function Zi(e,t){let n=new Image;if(n.src=await ae(e.url,t),await n.decode(),t.throwIfAborted(),n.naturalWidth===0||n.naturalHeight===0)throw Error(`This picture has no size to annotate.`);let r=Math.min(1,Ji/Math.max(n.naturalWidth,n.naturalHeight)),i=document.createElement(`canvas`);i.width=Math.max(1,Math.round(n.naturalWidth*r)),i.height=Math.max(1,Math.round(n.naturalHeight*r));let a=i.getContext(`2d`);if(a===null)throw Error(`Canvas is unavailable.`);a.drawImage(n,0,0,i.width,i.height);let o;try{o=await new Promise(e=>i.toBlob(e,`image/png`))}catch{throw Error(`This picture comes from another site and cannot be annotated.`)}if(o===null)throw Error(`This picture could not be prepared for annotation.`);let s=new Uint8Array(await o.arrayBuffer()),c=new Uint8Array(await crypto.subtle.digest(`SHA-256`,s));t.throwIfAborted();let l=Array.from(c,e=>e.toString(16).padStart(2,`0`)).join(``);return{path:`markdown-media/${l}.png`,kind:`image`,title:e.title,sourceSha256:l,imageData:Xi(s),mediaUrl:`markdown-media:${l}`,markdownMedia:{kind:e.kind,...e.sourcePath===void 0?{}:{sourcePath:e.sourcePath},...e.documentPath===void 0?{}:{documentPath:e.documentPath},...e.mermaidSource===void 0?{}:{mermaidSource:e.mermaidSource.slice(0,Yi)}}}}function Qi(e){let{media:n,sessionId:r,openTransientTab:i}=e,[a,o]=I(!1),[s,c]=I();return r===null?null:v(u,{children:[s?v(`output`,{role:`alert`,title:s,className:`flex min-w-0 items-center gap-1.5 text-sm text-po-red`,children:[g(ce,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),v(`span`,{className:`truncate`,children:[`Couldn't open in Author: `,s]})]}):null,v(t,{size:`sm`,variant:`outline`,disabled:a,"aria-busy":a,"aria-label":`Open ${n.title} in Author`,className:`shrink-0 gap-1.5`,onClick:()=>{o(!0),c(void 0),Zi(n,new AbortController().signal).then(t=>{lt(r,t),e.onClose(),i($i(t.path,n.title))}).catch(e=>{c(e instanceof Error?e.message:String(e)),o(!1)})},children:[a?g(b,{label:`Opening in Author`,className:`size-3.5`}):g(se,{"aria-hidden":!0,className:`size-3.5`}),a?`Opening…`:`Open in Author`]})]})}function $i(e,t){return{id:`author-media-${e}`,label:t,panel:t=>g(ea,{...t,path:e})}}function ea({sessionId:e,submitCapture:t,path:n}){let r=C(V.store,t=>e===null?void 0:t.documents[B(e,n)]);p(()=>{if(e===null)return;let t=ut(e,n);return()=>dt(e,t)},[n,e]);let i=C(V.store,t=>W(e,n,t)),a=C(V.store,t=>e===null?`select`:t.sessions[e]?.toolsByDocument[n]??`select`);if(e===null)return g(`output`,{className:`p-4 text-po-dim`,children:`Open a session to review this picture.`});if(!r)return g(`output`,{className:`p-4 text-po-dim`,children:`This picture is no longer loaded. Open it again.`});let o=i.annotations.map((e,t)=>({ordinal:t+1,region:e}));return v(`section`,{"data-testid":`author-media-review`,className:`flex min-h-0 flex-1 flex-col`,children:[g(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:g(pi,{sessionId:e,document:r,activeTool:a,displayedRegions:o,pendingCandidate:i.candidate!==void 0})}),g(`div`,{className:`max-h-56 shrink-0 overflow-y-auto border-t border-po-border bg-po-bg p-3 sm:hidden`,children:g(wn,{sessionId:e,document:r,drafts:i,submitCapture:t})})]})}var ta=N({slot:`author.media-review`,id:`media-review`,data:{version:1,panel:Qi}}),na=`po-author-annotations`,ra=`documents`,ia=1;function Z(e){return typeof e==`object`&&!!e}function Q(e){return typeof e==`number`&&Number.isFinite(e)}function aa(e){return Z(e)&&Q(e.x)&&Q(e.y)&&e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1}function oa(e){return aa(e)&&Z(e)&&Q(e.width)&&Q(e.height)&&e.width>0&&e.height>0&&Q(e.x)&&Q(e.y)&&e.x+e.width<=1&&e.y+e.height<=1}function sa(e){return e===void 0||Z(e)&&typeof e.selector==`string`&&typeof e.tag==`string`}function ca(e){if(!Z(e)||typeof e.kind!=`string`)return!1;switch(e.kind){case`text-range`:return Q(e.startOffset)&&Q(e.endOffset)&&Q(e.startLine)&&Q(e.endLine);case`cell`:return typeof e.fragmentId==`string`&&typeof e.location==`string`;case`slide-element`:return typeof e.fragmentId==`string`&&Q(e.slide)&&typeof e.location==`string`;case`image-rect`:return oa(e.rect)&&Q(e.naturalWidth)&&Q(e.naturalHeight);case`pdf-page-rect`:return Q(e.page)&&oa(e.rect);case`video-time-rect`:return Q(e.timeSeconds)&&oa(e.rect);case`story-preview-rect`:return oa(e.rect)&&Z(e.preview);case`image-point`:return aa(e.point)&&Q(e.naturalWidth)&&Q(e.naturalHeight);case`pdf-page-point`:return Q(e.page)&&aa(e.point);case`video-time-point`:return Q(e.timeSeconds)&&aa(e.point);case`story-preview-point`:return aa(e.point)&&Z(e.preview);case`html-rect`:return oa(e.rect)&&sa(e.element);case`html-point`:return aa(e.point)&&sa(e.element);default:return!1}}function la(e){return e===void 0||typeof Blob<`u`&&e instanceof Blob&&e.size<=8388608}function ua(e){return Z(e)?typeof e.documentPath==`string`&&z(e.documentPath)!==``&&Q(e.revision)&&(e.sourceSha256===void 0||typeof e.sourceSha256==`string`)&&(e.mode===void 0||e.mode===`region`||e.mode===`point`)&&ca(e.anchor)&&(e.stroke===void 0||Xt(e.stroke)&&`rect`in e.anchor&&e.mode===`region`)&&Z(e.viewport)&&Q(e.viewport.width)&&Q(e.viewport.height)&&Q(e.createdAt)&&la(e.evidence):!1}function da(e){return ua(e)&&Z(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.comment==`string`&&e.comment.trim()!==``&&(e.version===void 0||Number.isInteger(e.version)&&e.version>=1)}function fa(e){return new TextEncoder().encode(e).byteLength}function pa(e){if(!Z(e)||e.version!==ia||typeof e.key!=`string`||typeof e.sessionId!=`string`||e.sessionId===``||typeof e.documentPath!=`string`)return;let t=z(e.documentPath);if(t===``||e.key!==`${e.sessionId}\n${t}`||!Z(e.collection))return;let n=e.collection;if(!(!Q(n.revision)||n.sourceSha256!==void 0&&typeof n.sourceSha256!=`string`||typeof n.stale!=`boolean`||typeof n.candidateText!=`string`||fa(n.candidateText)>2048||!Array.isArray(n.annotations)||n.annotations.length>16||!n.annotations.every(da)||n.candidate!==void 0&&!ua(n.candidate)||!Q(n.updatedAt)))return e}function ma(e){let{thumbnailUrl:t,...n}=e;return{...n,...e.stroke===void 0?{}:{stroke:e.stroke.map(e=>({...e}))}}}function ha(){let e=[];for(let[t,n]of Object.entries(V.store.state.sessions))for(let[r,i]of Object.entries(n.annotationsByDocument))(i.annotations.length!==0||i.candidate!==void 0||i.candidateText!==``)&&e.push({key:`${t}\n${r}`,version:ia,sessionId:t,documentPath:r,collection:{...i,candidate:i.candidate&&ma(i.candidate),annotations:i.annotations.map(ma)}});return e.sort((e,t)=>t.collection.updatedAt-e.collection.updatedAt).slice(0,100)}var ga=class{#e;#t=Promise.resolve();constructor(e){this.#e=new Promise((t,n)=>{let r=e.open(na,1);r.onupgradeneeded=()=>{r.result.objectStoreNames.contains(ra)||r.result.createObjectStore(ra,{keyPath:`key`})},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error??Error(`Unable to open Author annotation storage.`))})}async load(){let e=await this.#e;return await new Promise((t,n)=>{let r=e.transaction(ra,`readonly`).objectStore(ra).getAll();r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error??Error(`Unable to read Author annotations.`))})}replace(e){let t=async()=>{let t=await this.#e;await new Promise((n,r)=>{let i=t.transaction(ra,`readwrite`),a=i.objectStore(ra);a.clear(),e.forEach(e=>a.put(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error??Error(`Unable to write Author annotations.`)),i.onabort=()=>r(i.error??Error(`Author annotation write was aborted.`))})};return this.#t=this.#t.catch(()=>void 0).then(t),this.#t}async close(){try{await this.#t}finally{(await this.#e).close()}}};function _a(e){let t=typeof indexedDB>`u`?void 0:indexedDB;if(e===void 0&&t===void 0)return async()=>void 0;let n=e??new ga(t),r=!1,i=!1,a=!1,o=V.store.subscribe(()=>{i?n.replace(ha()).catch(()=>void 0):a=!0});return n.load().then(e=>{if(r)return;let t=e.map(pa).filter(e=>e!==void 0).sort((e,t)=>t.collection.updatedAt-e.collection.updatedAt).slice(0,100);ct(t),i=!0,(a||t.length>0)&&n.replace(ha()).catch(()=>void 0)}).catch(()=>{r||(i=!0,a&&n.replace(ha()).catch(()=>void 0))}),async()=>{r=!0,o.unsubscribe(),await n.close()}}function va(e){try{let t=JSON.parse(e);return t.version!==1||typeof t.captureId!=`string`||typeof t.capturedAt!=`number`||typeof t.document?.path!=`string`||typeof t.document.revision!=`number`||!Array.isArray(t.regions)||t.regions.length===0||t.regions.length>16||t.regions.some(e=>e.stroke!==void 0&&(!Xt(e.stroke)||e.mode!==`region`||!(`rect`in e.anchor)))?void 0:t}catch{return}}function ya(e){for(let t of e.contextItems){if(t.source!==`author`||t.kind!==`author-capture`)continue;let n=va(t.metadata??t.content);if(n===void 0||n.captureId!==t.id||U(e.sessionId).requests.some(e=>e.captureId===n.captureId))continue;let r=n.regions.map(e=>({id:e.id,documentPath:n.document.path,revision:n.document.revision,sourceSha256:n.document.sourceSha256,comment:e.comment,version:e.version??1,mode:e.mode,quote:e.quote,anchor:structuredClone(e.anchor),...e.stroke===void 0?{}:{stroke:e.stroke.map(e=>({...e}))},viewport:{...e.viewport},voiceGrid:e.voiceGrid&&{...e.voiceGrid},createdAt:n.capturedAt}));bt(e.sessionId,{id:crypto.randomUUID(),captureId:n.captureId,documentPath:n.document.path,requestText:e.message,regions:r,pendingRegions:r,status:`REQUESTED`,createdAt:e.submittedAt,updatedAt:e.submittedAt,revision:n.document.revision,sourceSha256:n.document.sourceSha256});for(let t of n.regions)yt(e.sessionId,n.document.path,t.id,t.version??1)}}function ba(e){let t=U(e.sessionId).requests.find(t=>t.captureId===e.captureId);t===void 0||[`COMPLETE`,`FAILED`,`CANCELLED`,`UNTRACKED`].includes(t.status)||e.status!==`queued`&&xt(e.sessionId,t.id,t=>({...t,status:e.status===`working`?`CHANGING`:e.status===`completed`?`COMPLETE`:e.status===`untracked`?`UNTRACKED`:`FAILED`,currentOperation:e.status===`working`?`Agent is working on this request`:void 0,pendingRegions:e.status===`completed`?[]:t.pendingRegions,error:e.status===`error`?e.error||`Request execution failed.`:void 0,updatedAt:Date.now()}))}function xa(e){let t=Ie(e,zi),n=_a(),r=e.onComposerSubmitted?.(ya)??(()=>void 0),i=e.onCaptureStatus?.(ba)??(()=>void 0);return async()=>{r(),i(),t(),await n().catch(()=>void 0)}}var Sa=ee(xa),Ca=a(qn);function wa(e){if(typeof e!=`object`||!e)return null;let t=e;return t.version===1&&typeof t.panel==`function`?t:null}var Ta=a({slot:`author.image-feedback`,description:`Provide an annotation and feedback panel for an image artifact admitted by Author.`,parse:wa}),Ea=a(ge),Da=a({slot:`author.open-source`,description:`Offer an action that opens a source file in an Author canvas or transient tab.`,parse:Jn}),Oa=a(Xn),ka=a({description:`Render preview launch controls in Author. The provider owns its preview tab and lifecycle.`});function Aa(e){return``}function ja(e){return e===null?[]:ie(e.content).map(e=>({text:e,tone:`dim`}))}function Ma({toolName:e,args:t,result:n,running:r,isError:i}){let a=ja(n),o=L(a,8,!1);return g(F,{tone:y({running:r,isError:i}),expandable:o.hidden>0,children:({expanded:n})=>{let r=n?L(a,8,!0):o;return v(u,{children:[g(A,{title:e,children:g(`span`,{"data-testid":`tool-call-${e}`,className:`min-w-0 flex-1 truncate text-po-text`,children:Aa(t)})}),r.shown.length>0?v(j,{"data-testid":`tool-result-${e}`,className:`flex flex-col gap-1`,children:[g(de,{lines:r.shown}),r.hidden>0?v(k,{expands:!0,children:[r.hidden,` more line(s)`]}):null]}):null]})}})}var Na=f({tools:[`describe_author_tools`],message:Ma});function Pa(e,t,n,r){let i=Ri(e,r);t(i),n(i.id)}function Fa(e){if(typeof e?.details==`object`&&e.details!==null&&`path`in e.details)return typeof e.details.path==`string`?e.details.path:void 0}function Ia({args:e,result:n,running:r,isError:i,output:a,openTransientTab:o,openTab:s}){let c=Fa(n),l=!r&&!i&&n!==null&&c===void 0,d=i?(a??``).trim().split(/\r?\n/u).filter(Boolean).slice(0,4).map(e=>({text:e,tone:`error`})):[],f=typeof e.path==`string`?e.path:`document`,p=typeof n?.details==`object`&&n.details!==null&&`alias`in n.details&&typeof n.details.alias==`string`?n.details.alias:void 0;return g(F,{tone:y({running:r,isError:i||l}),children:()=>v(u,{children:[g(A,{title:`open_authoring_file`,children:g(`span`,{"data-testid":`tool-call-open_authoring_file`,className:`min-w-0 flex-1 truncate text-po-text`,children:p===void 0?f:`${p} · ${f}`})}),!i||d.length>0?v(j,{"data-testid":`tool-result-open_authoring_file`,className:`flex flex-col gap-1`,children:[d.length>0?g(de,{lines:d}):null,i?null:g(k,{tone:l?`error`:r?`running`:void 0,children:r?`validating`:l?`unavailable`:c===void 0?`waiting`:`ready`}),!r&&!i&&c!==void 0?g(t,{size:`xs`,variant:`outline`,"data-testid":`author-open-file`,onClick:()=>Pa(c,o,s,p),children:`open in Author`}):null]}):null]})})}var La=f({tools:[`open_authoring_file`],message:Ia,completionTab:({result:e})=>{let t=Fa(e),n=e?.details;return t===void 0?void 0:Ri(t,typeof n?.alias==`string`?n.alias:void 0)}});function Ra(e){return typeof e.name==`string`?e.name:``}function za(e){return e===null?[]:ie(e.content).map(e=>({text:e,tone:`dim`}))}function Ba({toolName:e,args:t,result:n,running:r,isError:i}){let a=za(n),o=L(a,8,!1);return g(F,{tone:y({running:r,isError:i}),expandable:o.hidden>0,children:({expanded:n})=>{let r=n?L(a,8,!0):o;return v(u,{children:[g(A,{title:e,children:g(`span`,{"data-testid":`tool-call-${e}`,className:`min-w-0 flex-1 truncate text-po-text`,children:Ra(t)})}),r.shown.length>0?v(j,{"data-testid":`tool-result-${e}`,className:`flex flex-col gap-1`,children:[g(de,{lines:r.shown}),r.hidden>0?v(k,{expands:!0,children:[r.hidden,` more line(s)`]}):null]}):null]})}})}var Va=f({tools:[`use_author_tools`],message:Ba}),$=(e,t)=>t===void 0?void 0:{...e,...t},Ha=d({id:`author`,packageName:`@agimon-ai/po-author`,session:{get channels(){return[$({channel:`author_webmcp`},Wt)]},get dockFaces(){return[$({id:`authoring`},Ln)]},get fileLinks(){return Bi},get fills(){return[$({slot:`author.open-source`,id:`author`},Vi),$({slot:`help.guides`,id:`author`},Hi),$({slot:`author.image-feedback`,id:`image-feedback`},qi),$({slot:`author.media-review`,id:`media-review`},ta)]},get slots(){return[$({slot:`author.canvas-type`},Ca),$({slot:`author.image-feedback`},Ta),$({slot:`author.media-review`},Ea),$({slot:`author.open-source`},Da),$({slot:`author.preview-action`},Oa),$({slot:`author.preview-provider`},ka)]},get start(){return Sa},get toolRenderers(){return[$({tools:[`describe_author_tools`]},Na),$({tools:[`open_authoring_file`]},La),$({tools:[`use_author_tools`]},Va)]}}});export{Ha as webPlugin};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$i as e,$n as t,$r as n,Aa as r,An as i,Bn as a,Bt as o,Ca as s,Di as c,En as l,Ft as u,Ga as d,Gi as f,Gn as p,Hi as m,Ht as h,Ia as g,It as _,Ki as v,Kt as y,La as b,Li as x,Lt as S,Nr as ee,Pi as C,Pr as te,Pt as ne,Ra as re,Ri as ie,Ta as ae,Ti as oe,Wa as se,Wi as ce,Xi as le,Xn as ue,Xt as de,Yi as fe,Zi as pe,Zn as me,_r as w,ca as he,ea as T,en as ge,fr as E,gr as D,hr as _e,ia as ve,ka as ye,ln as be,mr as O,na as k,nr as xe,oa as A,or as Se,pr as j,qi as Ce,qt as M,ra as N,rn as P,ti as we,tr as Te,ur as Ee,va as F,vr as I,yr as L}from"../chunks/po-web-runtime-D8FIos2q.js";var R={id:`browser-control`,label:`browser control`,detail:`choose which browser Po opens for web tasks, and what happens if it cannot start`,order:50,fields:[{id:`engine`,label:`Browser engine`,kind:`select`,keyPath:[`browse`,`engine`],placeholder:`Default (Playwright Chromium)`,detail:`CloakBrowser gives each profile its own steady fingerprint. Changes apply to the next browser Po opens.`,options:[{value:`cloak`,label:`CloakBrowser`},{value:`chrome-for-testing`,label:`Chrome for Testing`}]},{id:`fallback`,label:`If CloakBrowser can't start`,kind:`select`,keyPath:[`browse`,`fallback`],placeholder:`Default (stop and show the error)`,detail:`Chrome for Testing works without fingerprint protection. Po says so each time it falls back.`,options:[{value:`chrome-for-testing`,label:`Use Chrome for Testing`}]}]},De=`/api/plugins/browse/profiles`,Oe=`/api/plugins/browse/remote`,ke=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`});function Ae(e){let{profiles:t,error:r,confirming:i,deleting:a,openMenu:o}=e;return S(`div`,{"data-testid":`browser-profiles`,className:`@container flex flex-col gap-3`,children:[r?_(`p`,{role:`alert`,className:`text-sm text-po-red`,children:r}):null,t===void 0?_(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading profiles…`}):t.length===0?_(he,{title:`No browser profiles yet`,description:`Po saves one when a task signs in to a site.`,className:`py-12`}):_(`ul`,{"aria-label":`Browser profiles`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @3xl:grid-cols-3`,children:t.map(t=>_(l,{asChild:!0,className:`flex min-w-0 items-start gap-3 py-3 pr-1 pl-3`,children:S(`li`,{"data-testid":`browser-profile-${t.name}`,"aria-busy":a===t.name,children:[_(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-po-deep`,children:_(F,{"aria-hidden":!0,className:`size-4 text-po-dim`})}),S(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[_(`span`,{className:`truncate text-base font-semibold text-po-hi`,children:t.name}),_(`span`,{className:`truncate text-sm text-po-dim`,children:a===t.name?`Deleting…`:t.lastUsedAt?`Last used ${ke.format(new Date(t.lastUsedAt))}`:`Updated ${ke.format(new Date(t.updatedAt))}`})]}),S(T,{modal:!1,defaultOpen:o===t.name,children:[_(A,{asChild:!0,children:_(n,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${t.name}`,disabled:a!==void 0,children:_(P,{className:`size-3.5`})})}),_(k,{align:`end`,children:S(N,{variant:`destructive`,onSelect:()=>e.onAskDelete?.(t.name),children:[_(we,{className:`size-3.5`}),`Delete profile`]})})]})]})},t.name))}),_(ce,{open:i!==void 0,onOpenChange:t=>t?void 0:e.onCancelDelete?.(),children:S(v,{children:[_(le,{children:S(pe,{children:[`Delete `,i,`?`]})}),_(f,{children:_(Ce,{children:`Its saved sign-ins, cookies and fingerprint are removed. Po signs in again the next time a task needs it.`})}),S(fe,{children:[_(n,{onClick:e.onCancelDelete,children:`Keep profile`}),_(n,{variant:`danger-outline`,disabled:a!==void 0,onClick:()=>i===void 0?void 0:e.onConfirmDelete?.(i),children:`Delete profile`})]})]})})]})}async function je(e,t){let n=await e.json().catch(()=>void 0);return typeof n?.error==`string`?n.error:t}function Me({request:e,requestWithStepUp:t}){let[n,r]=M(),[i,a]=M(),[s,c]=M(),[l,u]=M(),d=o(async()=>{try{let t=await e(De);if(!t.ok)throw Error(await je(t,`Po could not read your browser profiles.`));r((await t.json()).profiles),a(void 0)}catch(e){r(e=>e??[]),a(e instanceof Error?e.message:`Po could not read your browser profiles.`)}},[e]);h(()=>{d()},[d]);let f=async e=>{u(e);try{let n=await t(`${De}/${encodeURIComponent(e)}`,{method:`DELETE`});a(n.ok?void 0:await je(n,`Po could not delete this profile.`))}catch(e){a(e instanceof Error?e.message:`Po could not delete this profile.`)}finally{c(void 0),u(void 0),await d()}};return _(Ae,{profiles:n,error:i,confirming:s,deleting:l,onAskDelete:c,onCancelDelete:()=>c(void 0),onConfirmDelete:e=>void f(e)})}var z=`__default`;function Ne({values:e,loading:r,saving:i,error:a,onChange:o,onRetry:s,profiles:c}){return S(`div`,{"data-testid":`browser-settings`,className:`flex min-w-0 flex-col gap-10`,children:[S(D,{children:[S(I,{children:[_(L,{children:`Engine`}),_(w,{children:`Applies to every workspace. Changes apply to the next browser Po opens.`})]}),a?S(`div`,{className:`flex flex-wrap items-center gap-2`,children:[_(`p`,{role:`alert`,className:`text-sm text-po-red`,children:a}),_(n,{size:`sm`,variant:`ghost`,disabled:i,onClick:s,children:`Try again`})]}):null,_(Se,{"aria-busy":r||i||void 0,children:R.fields.map(n=>{let a=n.id,s=e[a];return S(E,{"data-testid":`browser-setting-${a}`,changed:s!==void 0,className:`items-start`,children:[S(O,{className:`gap-1`,children:[_(_e,{className:`flex min-h-6 items-center`,children:n.label}),n.detail?_(j,{children:n.detail}):null]}),S(ue,{value:s??z,disabled:r||i,onValueChange:e=>o?.(a,e===z?null:e),children:[_(Te,{"aria-label":n.label,className:`w-full text-sm sm:w-64`,children:_(xe,{placeholder:n.placeholder})}),S(me,{children:[_(t,{value:z,children:n.placeholder}),(n.options??[]).map(e=>_(t,{value:e.value,children:e.label},e.value))]})]})]},a)})}),i||r&&!a?_(`p`,{role:`status`,className:`text-sm text-po-dim`,children:i?`Saving on your computer…`:`Loading browser settings…`}):null]}),S(D,{children:[S(I,{children:[_(L,{children:`Profiles`}),_(w,{children:`Each profile keeps its own sign-ins, cookies and fingerprint.`})]}),c]})]})}function Pe(e){let t=Math.round(e/60);if(t<60)return`${t} min`;let n=t%60;return n===0?`${Math.floor(t/60)} h`:`${Math.floor(t/60)} h ${n} min`}function Fe(e,t){return new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`,timeZone:t}).format(new Date(e))}function Ie({status:e,loading:t,error:r,onRetry:i,timeZone:o}){let s=e?Math.min(e.usedSeconds,e.limitSeconds):0,c=e!==void 0&&e.usedSeconds>=e.limitSeconds,l=e?Fe(e.resetsAt,o):``,u=e?Math.round(e.idleSeconds/60):0;return S(`div`,{"data-testid":`remote-browser-settings`,className:`flex min-w-0 flex-col gap-10`,children:[S(D,{children:[S(I,{children:[_(L,{children:`Today`}),_(w,{children:`Po Cloud runs the browser for you. Every session on this account shares one daily allowance.`})]}),r?S(`div`,{className:`flex flex-wrap items-center gap-2`,children:[_(`p`,{role:`alert`,className:`text-sm text-po-red`,children:r}),_(n,{size:`sm`,variant:`ghost`,onClick:i,children:`Try again`})]}):null,e&&!e.enabled?_(Ee,{children:`The browser is turned off on this host, so Po does web tasks without one.`}):null,S(Se,{"aria-busy":t||void 0,children:[S(E,{"data-testid":`remote-browser-time`,className:`items-start`,children:[S(O,{className:`gap-2`,children:[_(_e,{children:`Browser time`}),_(j,{children:e?`Resets at ${l} (${e.resetsAt.slice(11,16)} UTC).`:`Resets every day.`}),_(a,{"aria-label":`Browser time used today`,value:e&&e.limitSeconds>0?s/e.limitSeconds*100:0})]}),_(`span`,{className:`shrink-0 text-base font-semibold tabular-nums text-po-hi`,children:e?`${Pe(s)} of ${Pe(e.limitSeconds)}`:`…`})]}),S(E,{"data-testid":`remote-browser-open`,className:`items-start`,children:[S(O,{className:`gap-1`,children:[_(_e,{children:`Open now`}),_(j,{children:e?`Each session opens its own browser. It closes ${u} ${u===1?`minute`:`minutes`} after Po last uses it, and that time counts too.`:`Each session opens its own browser.`})]}),_(`span`,{className:`shrink-0 text-base font-semibold tabular-nums text-po-hi`,children:e?`${e.open} of ${e.openLimit}`:`…`})]})]}),c?S(`p`,{role:`status`,"data-testid":`remote-browser-used-up`,className:`text-sm text-po-text`,children:[`Today's browser time is used up. Po can browse again at `,l,`.`]}):null,t&&!r?_(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading browser use…`}):null]}),S(D,{children:[S(I,{children:[_(L,{children:`Sign-ins`}),_(w,{children:`A session's browser keeps its tabs and sign-ins while it is open. Once it closes they are gone, and you sign in again the next time a site needs it.`})]}),_(Ee,{children:`Saved browser profiles are not available on Po Cloud yet.`})]})]})}var Le=`/api/settings`,Re=`/api/settings/value`,ze=`The request did not reach Po on your computer.`;function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Be(e){let t=await e.json().catch(()=>void 0);if(!e.ok)return{ok:!1,error:B(t)&&typeof t.error==`string`?t.error:`Po answered ${e.status}.`};if(!B(t)||!B(t.values)||!B(t.hashes)||typeof t.hashes.host!=`string`)return{ok:!1,error:`Po answered with no configuration.`};let n={};for(let e of R.fields){let r=t.values[e.keyPath.join(`.`)];B(r)&&typeof r.value==`string`&&r.origin!=="default"&&(n[e.id]=r.value)}return{ok:!0,config:{values:n,hash:t.hashes.host}}}async function V(e){let t=new URLSearchParams({repoRoot:``});for(let e of R.fields)t.append(`key`,e.keyPath.join(`.`));try{return await Be(await e(`${Le}?${t.toString()}`))}catch{return{ok:!1,error:ze}}}async function Ve(e,t,n,r){let i=R.fields.find(e=>e.id===t);if(!i||n!==null&&!i.options?.some(e=>e.value===n))return{ok:!1,error:`Choose one of the browser settings offered.`};try{let t=await e(Re,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({repoRoot:``,scope:`host`,keyPath:i.keyPath,value:n,expectedHash:r})});return t.status===409?{ok:!1,conflict:!0,error:`The settings changed on your computer. Try again.`}:t.ok?await V(e):await Be(t)}catch{return{ok:!1,error:ze}}}function He({request:e,requestWithStepUp:t}){let[n,r]=M(),[i,a]=M(!0),[s,c]=M(!1),[l,u]=M(),d=y(!1),f=y(!1),p=o(async()=>{a(!0);let t=await V(e);d.current&&(t.ok?(r(t.config),u(void 0)):(r(void 0),u(t.error)),a(!1))},[e]);h(()=>(d.current=!0,p(),()=>{d.current=!1}),[p]);let m=async(a,o)=>{if(f.current||i||!n)return;f.current=!0,c(!0),u(void 0);let s=await Ve(t,a,o,n.hash);if(d.current){if(s.ok)r(s.config);else{if(s.conflict){let t=await V(e);if(!d.current)return;r(t.ok?t.config:void 0)}u(s.error)}f.current=!1,c(!1)}};return{values:n?.values??{},loading:i||!n,saving:s,error:l,onRetry:()=>void p(),onChange:(e,t)=>void m(e,t)}}function Ue(e){return _(Ne,{...He(e),profiles:_(Me,{...e})})}function We(e){let{request:t}=e,[n,r]=M({kind:`checking`}),i=o(async()=>{try{let e=await t(Oe);e.status===404?r({kind:`local`}):e.ok?r({kind:`remote`,status:await e.json()}):r({kind:`remote`,error:`Po could not read today's browser use.`})}catch{r(e=>e.kind===`remote`?{...e,error:`Po could not read today's browser use.`}:{kind:`local`})}},[t]);return h(()=>{i()},[i]),n.kind===`local`?_(Ue,{...e}):n.kind===`checking`?_(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading browser settings…`}):_(Ie,{status:n.status,error:n.error,onRetry:()=>void i()})}var Ge=b({label:`Browser`,detail:`The browser Po uses for web tasks, and how long your sign-ins last.`,order:R.order,icon:de,component:We}),Ke=re({...R,icon:de}),qe={slot:`author.open-source`,parse(e){if(typeof e!=`object`||!e)return null;let t=e;return t.version===1&&typeof t.createTab==`function`?t:null}};function Je(e){return e.sessionId===null?void 0:e.slotData?.(qe)?.[0]?.data}var Ye=`browse_activity`,Xe=`browse`;function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ze=new Set([`active`,`idle`,`asleep`,`crashed`]);function Qe(e){return H(e)&&typeof e.id==`string`&&typeof e.title==`string`&&typeof e.url==`string`&&typeof e.current==`boolean`&&typeof e.lastAccessedAt==`number`}function $e(e){return!H(e)||typeof e.id!=`string`||typeof e.name!=`string`||!Ze.has(e.state)||e.window!==`headed`&&e.window!==`headless`||typeof e.lastUsedAt!=`number`||!Array.isArray(e.tabs)?null:{...e,tabs:e.tabs.filter(Qe)}}function et(e){return!H(e)||!Array.isArray(e.identities)?null:{identities:e.identities.map($e).filter(e=>e!==null)}}function tt(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function nt(e){return H(e)?e.state===`ok`&&typeof e.src==`string`&&e.src.startsWith(`data:image/`)?{state:`ok`,src:e.src,...tt(e.seq)?{seq:e.seq}:{}}:e.state===`unchanged`&&tt(e.seq)?{state:`unchanged`,seq:e.seq}:e.state===`closed`||e.state===`timeout`?{state:e.state}:{state:`error`}:{state:`error`}}function rt(e){return H(e)&&e.ok===!0&&typeof e.path==`string`&&e.path!==``?{ok:!0,path:e.path}:H(e)&&e.ok===!1&&typeof e.message==`string`?{ok:!1,message:e.message}:{ok:!1,message:`Po could not take the snapshot.`}}function it(e,t,n){if(!(H(e)&&e.closed===t.length))return n.length>1?`Po could not close these browsers.`:n.length===1?`Po could not close this browser.`:t.length===1?`Po could not close this tab.`:`Po could not close every tab.`}function at({identities:e,hidden:t}){return t.length===0?e:e.filter(e=>!t.includes(`identity:${e.id}`)).map(e=>({...e,tabs:e.tabs.filter(e=>!t.includes(`tab:${e.id}`))}))}function ot(e){return`${e} ${e===1?`tab`:`tabs`}`}function st(e){let t=t=>e.filter(e=>e.state===t).length;return[t(`active`)>0?`${t(`active`)} working`:``,t(`idle`)>0?`${t(`idle`)} open`:``,t(`asleep`)>0?`${t(`asleep`)} asleep`:``,t(`crashed`)>0?`${t(`crashed`)} closed unexpectedly`:``].filter(Boolean).join(`, `)}function ct({state:e,tabs:t,activity:n,lastUsed:r}){return e===`active`?n??`Working`:e===`asleep`&&t.length>0?`Asleep ${r}, keeps ${t[0]?.title}${t.length>1?` and ${t.length-1} more`:``}`:e===`idle`?`Open and waiting, used ${r}`:e===`asleep`?`Asleep ${r}`:`Closed unexpectedly. Po reopens it the next time a task needs it.`}function lt(e,t){return e===`timeout`?t?`The browser is slow to answer. The last frame stays here.`:`Po is on another tab`:e===`error`?`Po could not reach this browser. Trying again.`:void 0}function ut(e,t,n,r){let i=!n&&e.state===`active`&&t.current;return{live:i,badge:n?`Closed`:i?`Po is working`:`Watching`,footer:n?`This tab is closed. The last frame stays here.`:r??(i?e.activity??`Po is working here`:`Po is not on this tab right now`)}}var U=g({identities:[],hidden:[],pending:0});function W(e){return ne(U.store,t=>U.select(t,e))}function dt(e,t,n){let r=U.select(U.store.state,e).identities.find(e=>e.id===t);return r&&{identity:r,tab:r.tabs.find(e=>e.id===n)}}var ft={subscribe(e){let t=U.store.subscribe(e);return()=>t.unsubscribe()},isActive(e){return U.select(U.store.state,e).identities.some(e=>e.state===`active`)}},pt=U.channel({channel:Ye,parse:et,reduce:(e,{identities:t})=>({...e,identities:t,...e.pending===0?{hidden:[]}:{}})}),G=r(void 0);function mt(e){let t=t=>e.invokeServerMethod(t);return G.update(()=>t),()=>G.update(e=>e===t?void 0:e)}function K(e,t,n){let r=G.store.state;return r?r({mount:{scope:`session`,sessionId:e},service:Xe,method:t,input:n}):Promise.reject(Error(`The browser view is not connected.`))}async function ht(e,t,n){try{return nt(await K(e,`frame`,n===void 0?{tabId:t}:{tabId:t,since:n}))}catch{return{state:`error`}}}async function gt(e,t){try{return rt(await K(e,`snapshot`,t))}catch(e){return{ok:!1,message:e instanceof Error?e.message:`Po could not take the snapshot.`}}}async function q(e,{tabIds:t,identityIds:n=[]}){if(t.length===0&&n.length===0)return;let r=[...t.map(e=>`tab:${e}`),...n.map(e=>`identity:${e}`)];U.update(e,e=>({...e,hidden:[...e.hidden,...r],pending:e.pending+1,error:void 0}));let i=await _t(e,t,n);return U.update(e,e=>({...e,pending:e.pending-1,...i===void 0?{}:{error:i,hidden:e.hidden.filter(e=>!r.includes(e))}})),i}async function _t(e,t,n){let r;try{r=await K(e,`close`,n.length>0?{tabIds:[...t],identityIds:[...n]}:{tabIds:[...t]})}catch{}return it(r,t,n)}async function J(e,t,n){let{method:r,profileName:i}=t,a=t=>U.update(e,e=>{let{[i]:n,...r}=e.busy??{};return{...e,busy:t===void 0?r:{...r,[i]:t}}});a(n),U.update(e,e=>({...e,error:void 0}));let o;try{o=await K(e,r,r===`sleep`?{profileName:i}:{profileName:i,headless:t.headless,urls:[...t.urls]})}catch{}let s=typeof o==`object`&&!!o&&o.ok===!0,c=s?void 0:o?.message;a(void 0),s||U.update(e,e=>({...e,error:typeof c==`string`?c:`Po could not reach this browser.`}))}function Y(e){try{return new URL(e).host}catch{return e}}var X=6e4,Z=60*X,Q=24*Z;function vt(e,t){let n=Math.max(0,t-e);return n<X?`just now`:n<Z?`${Math.floor(n/X)} min ago`:n<Q?`${Math.floor(n/Z)} h ago`:`${Math.floor(n/Q)} d ago`}function yt(e,t=Date.now()){return{id:e.id,name:e.name,state:e.state,window:e.window,...e.profile===void 0?{}:{profile:e.profile},lastUsed:vt(e.lastUsedAt,t),lastUsedAt:e.lastUsedAt,tabs:e.tabs.map(({id:e,title:t,url:n,current:r})=>({id:e,title:t,url:n,current:r}))}}function bt(e,t){let n=e.lastUsedAt;if(n===void 0||e.state!==`idle`&&e.state!==`asleep`)return{text:ct(e)};let r=Math.max(0,t-n),i=r<Z?X:r<Q?Z:Q;return{text:ct({...e,lastUsed:vt(n,t)}),nextMs:t<n?n-t+X:i-r%i}}function xt(e,t){let n=!1,r,i,a=async()=>{let o=await e(i);n||(o.state===`ok`&&(i=o.seq),t(o),o.state!==`closed`&&(r=setTimeout(()=>void a(),500)))};return a(),()=>{n=!0,clearTimeout(r)}}async function St(e,t,n,r){let i=await e(t.sessionId,{tabId:t.tabId,identity:t.identity,host:Y(t.url)});if(!i.ok)return{error:i.message};try{return r(n.createTab({sessionId:t.sessionId,path:i.path})),`idle`}catch(e){return{error:e instanceof Error?e.message:`Author could not open the snapshot.`}}}function Ct({identity:e,tab:t,frameSrc:n,frame:r,closed:i=!1,stale:a,snapshot:o,onSnapshot:s}){let{live:c,badge:l,footer:u}=ut(e,t,i,a),d=t.url.startsWith(`https://`),f=n!==void 0||r!==void 0;return S(`section`,{"data-testid":`browser-live-view`,"data-closed":i,"aria-label":`${t.title}, live view`,className:`flex min-h-0 flex-1 flex-col gap-3 px-[26px] py-[18px]`,children:[S(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[_(`span`,{className:`shrink-0 truncate text-base font-semibold text-po-hi`,children:e.name}),_(`span`,{className:`text-xs text-po-faint`,children:`›`}),_(`span`,{className:`min-w-0 truncate text-base text-po-text`,children:t.title}),_(ee,{tone:c?`running`:`neutral`,"data-testid":`browser-live-state`,children:l}),_(`span`,{className:`ml-auto shrink-0 text-sm text-po-dim`,children:`View only`}),o===void 0?null:_(wt,{state:o,disabled:i||!f,onSnapshot:s})]}),S(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-po-border`,children:[S(`div`,{className:`flex min-w-0 items-center gap-1.5 border-b border-po-border bg-po-panel px-3 py-1.5`,children:[d?_(be,{"aria-label":`Secure connection`,className:`size-3 shrink-0 text-po-dim`}):_(F,{"aria-label":`Not secure`,className:`size-3 shrink-0 text-po-dim`}),_(`span`,{"data-testid":`browser-live-url`,className:`min-w-0 flex-1 truncate font-mono text-sm text-po-text`,children:t.url})]}),_(`div`,{className:`relative min-h-0 flex-1 bg-po-bg ${i?`opacity-50 grayscale`:``}`,children:n?_(`img`,{src:n,alt:`Live view of ${t.title}`,className:`absolute inset-0 size-full object-contain object-top`}):r||_(`span`,{className:`absolute inset-0 flex items-center justify-center text-sm text-po-dim`,children:i?`This tab closed before the first frame`:`Waiting for the first frame`})})]}),_(`span`,{"data-testid":`browser-live-footer`,className:`truncate text-sm text-po-dim`,children:u})]})}function wt({state:e,disabled:t,onSnapshot:r}){return S(`span`,{className:`flex shrink-0 items-center gap-2`,children:[typeof e==`object`?_(`span`,{role:`alert`,className:`max-w-48 truncate text-sm text-po-red`,title:e.error,children:e.error}):null,_(n,{size:`xs`,variant:`outline`,"data-testid":`browser-live-snapshot`,disabled:t,loading:e===`taking`,loadingLabel:`Taking snapshot`,onClick:r,children:`Snapshot to Author`})]})}function Tt(e,t){let n=dt(e,t.identity.id,t.tab.id);return n?.tab?{identity:n.identity,tab:n.tab,gone:!1}:{identity:n?.identity??t.identity,tab:t.tab,gone:!0}}function Et(e,t){let{identity:n,tab:r}=Tt(e,t);return{kind:`browser-tab`,source:`po-browse`,id:`${t.identity.id}/${t.tab.id}`,label:`${n.name} · ${r.title}`,content:`The person is watching browser identity "${n.name}", tab "${r.title}" at ${r.url}.`}}function Dt(e,t){let n={identity:e,tab:t};return{id:`browse-live-${e.id}-${t.id}`.replace(/[^\w-]+/g,`-`),label:`${e.name} › ${t.title}`,panel:e=>_(kt,{...e,opened:n}),retainComposer:!0,composerContext:e=>Et(e,n)}}function Ot(){let[e,t]=M(()=>typeof document>`u`||!document.hidden);return h(()=>{let e=()=>t(!document.hidden);return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e}function kt(e){let{sessionId:t,opened:n,openTransientTab:r}=e;W(t);let i=Tt(t,n),a=i.identity.state===`asleep`||i.identity.state===`crashed`,[o,s]=M(),[c,l]=M(!1),[u,d]=M(),f=i.gone||a||c,p=Ot(),m=n.tab.id;h(()=>{if(t!==null&&!f&&p)return xt(e=>ht(t,m,e),e=>{e.state===`ok`?(s(e.src),d(void 0)):e.state===`unchanged`?d(void 0):e.state===`closed`?l(!0):d(e.state)})},[t,m,f,p]);let g=y(!0);h(()=>(g.current=!0,()=>{g.current=!1}),[]);let[v,b]=M(`idle`),x=Je(e),S=async()=>{if(x===void 0||t===null||v===`taking`)return;b(`taking`);let e=await St(gt,{sessionId:t,tabId:m,identity:n.identity.id,url:i.tab.url},x,r);g.current&&b(e)},ee=lt(u,i.tab.current);return _(Ct,{identity:yt(i.identity,Date.now()),tab:{id:i.tab.id,title:i.tab.title,url:i.tab.url,current:i.tab.current},frameSrc:o,closed:f,stale:ee,snapshot:x===void 0?void 0:v,onSnapshot:()=>void S()})}var At={active:`green`,idle:`neutral`,asleep:`muted`,crashed:`red`};function jt(e){let{identities:t,error:n}=e;return t.length===0?_(he,{"data-testid":`browsers-panel`,title:`No browser yet`,description:`Po opens one when a task needs the web.`,className:`py-12`}):S(`div`,{"data-testid":`browsers-panel`,className:`@container flex min-w-0 flex-1 flex-col gap-6 overflow-y-auto px-6 py-4`,children:[_(`p`,{className:`text-sm text-po-dim`,children:st(t)}),n?_(`p`,{role:`alert`,className:`text-sm text-po-red`,children:n}):null,t.map(t=>_(Mt,{...e,identity:t},t.id))]})}function Mt(t){let{identity:r,busy:i,canShowWindow:a=!0,openMenu:o}=t,{state:s,tabs:c}=r,l=i?.[r.id],d=s===`active`||s===`idle`,f=s!==`crashed`&&l===void 0,m=r.profile!==!1;return S(`section`,{"aria-label":r.name,"data-testid":`browsers-identity-${r.id}`,"data-state":s,className:`flex flex-col gap-3`,children:[S(`header`,{className:`flex min-w-0 items-center gap-2`,children:[_(e,{tone:At[s],pulse:s===`active`||l!==void 0}),_(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-po-hi`,children:r.name}),S(`span`,{className:`min-w-0 flex-1 truncate text-sm ${s===`crashed`?`text-po-red`:`text-po-dim`}`,children:[l??ct(r),d?` · ${r.window===`headed`?`Window shown`:`No window`}`:``]}),f?S(T,{modal:!1,defaultOpen:o===`identity:${r.id}`,children:[_(A,{asChild:!0,children:_(n,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${r.name}`,children:_(P,{className:`size-3.5`})})}),S(k,{align:`end`,children:[m?s===`asleep`?S(N,{onSelect:()=>t.onWake?.(r.id),children:[_(p,{className:`size-3.5`}),`Wake up`]}):S(u,{children:[a?S(N,{onSelect:()=>t.onToggleWindow?.(r.id,r.window===`headed`?`headless`:`headed`),children:[_(de,{className:`size-3.5`}),r.window===`headed`?`Hide window`:`Show window`]}):null,S(N,{onSelect:()=>t.onSleep?.(r.id),children:[_(te,{className:`size-3.5`}),`Put to sleep`]})]}):null,m?_(ve,{}):null,S(N,{onSelect:()=>t.onCloseBrowser?.(r.id),children:[_(C,{className:`size-3.5`}),`Close browser`]})]})]}):null]}),c.length>0?_(`ul`,{"aria-label":`Tabs in ${r.name}`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @4xl:grid-cols-3`,children:c.map(e=>_(Nt,{...t,tab:e},e.id))}):null]})}function Nt(e){let{identity:t,tab:r,renderFrame:a,openMenu:o}=e,s=t.state===`asleep`,c=t.state===`active`&&r.current,d=()=>e.onWatch?.(t.id,r.id),f=e=>{e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d())},p=a?.(t,r);return _(l,{asChild:!0,className:`flex min-w-0 flex-col focus-within:border-po-green`,children:S(`li`,{"data-testid":`browsers-tab-${r.id}`,"data-current":r.current,children:[s?null:S(`div`,{role:`button`,tabIndex:0,title:`Watch this tab live`,onClick:d,onKeyDown:f,className:`relative aspect-video cursor-pointer overflow-hidden bg-po-deep outline-none`,children:[p??S(`span`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-1 text-sm text-po-dim`,children:[_(F,{"aria-hidden":!0,className:`size-5 text-po-faint`}),`Waiting for the first frame`]}),c?_(`span`,{className:`absolute top-2 left-2 rounded-xs bg-po-tint-green px-1.5 py-0.5 text-sm font-semibold text-po-green`,children:`Po is here`}):null]}),S(`div`,{className:`flex min-w-0 items-center gap-2 py-1.5 pr-1 pl-3 ${s?``:`border-t border-po-border-soft`}`,children:[S(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[_(`span`,{className:`truncate text-base ${r.current?`font-semibold text-po-hi`:`text-po-text`}`,children:r.title}),_(`span`,{className:`truncate text-sm text-po-dim`,children:Y(r.url)})]}),S(T,{modal:!1,defaultOpen:o===`tab:${r.id}`,children:[_(A,{asChild:!0,children:_(n,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${r.title}`,children:_(P,{className:`size-3.5`})})}),S(k,{align:`end`,children:[s?null:S(u,{children:[S(N,{onSelect:d,children:[_(i,{className:`size-3.5`}),`Watch live`]}),e.onSnapshot?S(N,{onSelect:()=>e.onSnapshot?.(t.id,r.id),children:[_(ge,{className:`size-3.5`}),`Snapshot to Author`]}):null]}),S(N,{onSelect:()=>e.onCopyUrl?.(r.url),children:[_(m,{className:`size-3.5`}),`Copy URL`]}),s?null:S(u,{children:[_(ve,{}),S(N,{onSelect:()=>e.onCloseTab?.(t.id,r.id),children:[_(C,{className:`size-3.5`}),`Close tab`]})]})]})]})]})]})})}function Pt(){return{id:`browse-browsers`,label:`Browsers`,panel:It}}function Ft({sessionId:e,tabId:t}){let[n,r]=M();return h(()=>xt(n=>ht(e,t,n),e=>{e.state===`ok`&&r(e.src)}),[e,t]),n===void 0?void 0:_(`img`,{src:n,alt:``,className:`absolute inset-0 size-full object-cover object-top`})}function It(e){let{sessionId:t,openTransientTab:n}=e,r=W(t),[i,a]=M(),o=Je(e),s=e=>r.identities.find(t=>t.id===e),c=e=>{let t=s(e);return t&&t.state!==`asleep`?t.tabs.map(e=>e.id):[]};return _(jt,{identities:at(r).map(e=>yt(e)),renderFrame:(e,n)=>t===null||e.state===`asleep`?void 0:_(Ft,{sessionId:t,tabId:n.id},n.id),busy:r.busy,error:i??r.error,onWatch:(e,t)=>{let r=s(e),i=r?.tabs.find(e=>e.id===t);r&&i&&n(Dt(r,i))},onSnapshot:o===void 0||t===null?void 0:(e,r)=>{let i=s(e)?.tabs.find(e=>e.id===r);i&&(a(void 0),St(gt,{sessionId:t,tabId:r,identity:e,url:i.url},o,n).then(e=>{e!==`idle`&&a(e.error)}))},onCopyUrl:e=>{a(void 0),navigator.clipboard.writeText(e).catch(()=>a(`Po could not copy the URL.`))},onCloseTab:(e,n)=>t&&void q(t,{tabIds:[n]}),onCloseBrowser:e=>t&&void q(t,{tabIds:c(e),identityIds:[e]}),onSleep:e=>t&&void J(t,{method:`sleep`,profileName:e},`Going to sleep`),onWake:e=>{let n=s(e);t&&n&&J(t,{method:`relaunch`,profileName:e,headless:n.window===`headless`,urls:n.tabs.map(e=>e.url).filter(e=>/^https?:\/\//.test(e))},`Waking up`)},onToggleWindow:(e,n)=>t&&void J(t,{method:`relaunch`,profileName:e,headless:n===`headless`,urls:[]},`Reopening, pages reload`)})}var Lt=s({keys:`g b`,icon:F,activeSource:ft,marksBackgroundWork:!1,order:45,transientTab:Pt}),Rt=ae(pt),zt={active:`green`,idle:`neutral`,asleep:`muted`,crashed:`red`};function Bt({identities:e,onOpenTab:t,onCloseTab:r,onCloseBrowser:i,onCloseAsleep:a,error:o}){if(e.length===0)return _(`p`,{"data-testid":`activity-summary-browser`,className:`px-1 text-sm text-po-dim`,children:`No browser yet. Po opens one when a task needs the web.`});let s=e.filter(e=>e.state===`asleep`),c=st(e);return S(`div`,{"data-testid":`activity-browser-identities`,className:`flex flex-col gap-1`,children:[_(`p`,{"data-testid":`activity-summary-browser`,className:`px-1 pb-1 text-sm text-po-dim`,children:c}),o?_(`p`,{role:`alert`,className:`px-1 pb-1 text-sm text-po-red`,children:o}):null,_(`ul`,{className:`flex flex-col`,children:e.map(e=>_(Vt,{identity:e,onOpenTab:t,onCloseTab:r,onCloseBrowser:i},e.id))}),s.length>1&&a?S(n,{variant:`ghost`,size:`sm`,className:`mt-1 self-start`,onClick:()=>a(s.map(e=>e.id)),children:[`Close `,s.length,` asleep browsers`]}):null]})}function Vt({identity:t,onOpenTab:r,onCloseTab:i,onCloseBrowser:a}){let{state:o,tabs:s}=t,[l,u]=M(o===`active`),d=o===`asleep`;return _(`li`,{"data-testid":`activity-browser-${t.id}`,"data-state":o,className:`group/row`,children:S(x,{open:l,onOpenChange:u,children:[S(`div`,{className:`flex items-start gap-1 rounded-md hover:bg-po-deep/60`,children:[S(n,{variant:`ghost`,size:`card`,"aria-expanded":s.length>0?l:void 0,title:t.name,onClick:()=>u(!l),className:`min-w-0 flex-1 gap-0.5 px-1.5 py-1.5 hover:bg-transparent`,children:[S(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[_(e,{tone:zt[o],pulse:o===`active`}),_(`span`,{className:`min-w-0 flex-1 truncate text-base font-semibold text-po-hi`,children:t.name}),s.length>0&&!l?_(`span`,{className:`shrink-0 text-sm text-po-dim`,children:ot(s.length)}):null,s.length>0?l?_(oe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-po-dim`}):_(c,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-po-faint`}):null]}),_(`span`,{className:`pl-3.5 text-sm ${o===`crashed`?`text-po-red`:`truncate text-po-dim`}`,children:_(Ut,{identity:t})})]}),o!==`crashed`&&a?S(T,{modal:!1,children:[_(A,{asChild:!0,children:_(n,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${t.name}`,className:`mt-1.5 mr-1 opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100`,children:_(P,{className:`size-3.5`})})}),_(k,{align:`end`,children:S(N,{onSelect:()=>a(t.id),children:[_(C,{className:`size-3.5`}),`Close browser`]})})]}):null]}),_(ie,{children:_(`ul`,{"aria-label":`Tabs in ${t.name}`,className:`flex flex-col gap-0.5 pt-0.5 pb-1.5 pl-4`,children:s.map(e=>d?_(`li`,{className:`flex items-center gap-2 px-1.5 py-1.5`,children:_(Ht,{tab:e,here:!1})},e.id):S(`li`,{className:`group/tab flex items-center gap-1 rounded-md hover:bg-po-deep`,children:[_(n,{variant:`ghost`,size:`card`,"data-testid":`activity-browser-tab-${e.id}`,"data-current":e.current,"aria-current":e.current?`true`:void 0,title:`Watch this tab live`,onClick:()=>r?.(t.id,e.id),className:`min-w-0 flex-1 flex-row items-center gap-2 px-1.5 py-1.5 hover:bg-transparent`,children:_(Ht,{tab:e,here:e.current&&o===`active`})}),i?_(n,{variant:`ghost`,size:`icon`,"aria-label":`Close ${e.title}`,onClick:()=>i(t.id,e.id),className:`mr-1 opacity-0 group-hover/tab:opacity-100 focus-visible:opacity-100`,children:_(C,{className:`size-3.5`})}):null]},e.id))})})]})})}function Ht({tab:e,here:t}){return S(u,{children:[_(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center rounded-xs text-2xs font-semibold uppercase ${t?`bg-po-tint-green text-po-green`:`bg-po-deep text-po-dim`}`,children:e.title.charAt(0)}),S(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[_(`span`,{className:`truncate text-base ${e.current?`font-semibold text-po-hi`:`text-po-text`}`,children:e.title}),_(`span`,{className:`truncate text-sm text-po-dim`,children:t?`Po is here · ${Y(e.url)}`:Y(e.url)})]})]})}function Ut({identity:e}){let t=y(null);return h(()=>{let n,r=()=>{let{text:i,nextMs:a}=bt(e,Date.now());t.current?.firstChild&&(t.current.firstChild.nodeValue=i),a!==void 0&&(n=setTimeout(r,a))};return r(),()=>clearTimeout(n)},[e]),_(`span`,{ref:t,children:bt(e,Date.now()).text})}function Wt(e,t,n,r){let i=e.find(e=>e.id===t),a=i?.tabs.find(e=>e.id===n);i&&a&&r(Dt(i,a))}function Gt({sessionId:e,openTransientTab:t}){let n=W(e),{identities:r}=n,i=e=>r.find(t=>t.id===e&&t.state!==`asleep`)?.tabs.map(e=>e.id)??[];return _(Bt,{identities:at(n).map(e=>yt(e)),error:n.error,onOpenTab:(e,n)=>Wt(r,e,n,t),onCloseTab:(t,n)=>e&&void q(e,{tabIds:[n]}),onCloseBrowser:t=>e&&void q(e,{tabIds:i(t),identityIds:[t]}),onCloseAsleep:t=>e&&void q(e,{tabIds:[],identityIds:t})})}var Kt=ye({component:Gt}),qt=se(mt),$=(e,t)=>t===void 0?void 0:{...e,...t},Jt=d({id:`browse`,packageName:`@agimon-ai/po-browse`,host:{get settingsPanels(){return[$({id:`browser`},Ge)]}},workspace:{get settingsSections(){return[$({id:`browser-control`},Ke)]}},session:{get activityGroups(){return[$({name:`browser`},Lt)]},get channels(){return[$({channel:`browse_activity`},Rt)]},get fills(){return[$({slot:`activity.browser`,id:`browser`},Kt)]},get start(){return qt}}});export{Jt as webPlugin};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{Ft as e,Ga as t,Ha as n,It as r,Lr as i,Lt as a,Mi as o,Ni as s,Xr as c,_n as l,gn as u,hn as d,mn as f}from"../chunks/po-web-runtime-D8FIos2q.js";var p=51200,m=1024;function h(e){return e.filter(e=>e!==void 0&&e.length>0)}function g(e,t){return typeof e==`number`&&Number.isFinite(e)?`${e} ${t}`:void 0}function _(e){return typeof e==`string`&&e.length>0?e:`.`}function v(e){return e<m?`${e}B`:e<m*m?`${(e/m).toFixed(1)}KB`:`${(e/(m*m)).toFixed(1)}MB`}function y(e,t){let n=typeof e.content==`string`?e.content:``,r=typeof e.path==`string`?e.path:``,i=`${n.length.toLocaleString(`en-US`)} chars`;if(n.length===0)return{path:r,size:i,preview:[],hidden:0,gutter:1};let a=n.replaceAll(` `,` `).replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`).split(`
|
|
4
|
-
`);for(;a.at(-1)===``;)a.pop();let o=t?a:a.slice(0,10);return{path:r,size:i,preview:o.map((e,t)=>({number:t+1,text:e})),hidden:a.length-o.length,gutter:String(o.length).length}}function b(e){return{primary:typeof e.pattern==`string`?e.pattern:``,details:h([_(e.path),g(e.limit,`results`)])}}function x(e){return{primary:_(e.path),details:h([g(e.limit,`entries`)])}}function S(e){let t=e.replace(/\/$/,``).lastIndexOf(`/`);return t<0?{name:e,folder:``}:{name:e.slice(t+1),folder:e.slice(0,t)}}function C(e,t){return e===null?t:e.content.flatMap(e=>{let t=typeof e==`object`&&e?e:{};return t.type===`text`&&typeof t.text==`string`?[t.text]:[]}).join(`
|
|
5
|
-
`)}function w(e,t,n,r,i){let a=C(e,t).trim(),o=a.length===0?[]:a.split(`
|
|
6
|
-
`),s=n?o:o.slice(0,20),c=typeof e?.details==`object`&&e.details!==null?e.details:{},l=c[r],u=typeof c.truncation==`object`&&c.truncation!==null?c.truncation:void 0,d=[];return typeof l==`number`&&l>0&&d.push(`${l} ${i} limit`),u?.truncated===!0&&d.push(`${v(typeof u.maxBytes==`number`?u.maxBytes:p)} limit`),{lines:s,hidden:o.length-s.length,truncated:d.length>0?`[Truncated: ${d.join(`, `)}]`:void 0}}function T({tool:e,limitKey:t,limitUnit:n,expanded:i,props:o}){let{result:s,output:c,running:u,isError:f}=o;if(f)return r(d,{"data-testid":`tool-result-${e}`,className:`flex flex-col`,children:r(`span`,{className:`whitespace-pre-wrap break-words text-po-red`,children:C(s,c)})});if(s===null)return u?r(d,{"data-testid":`tool-result-${e}`,children:r(l,{tone:`running`,children:`running`})}):null;let p=w(s,c,i,t,n);return p.lines.length===0&&p.truncated===void 0?null:a(d,{"data-testid":`tool-result-${e}`,className:`flex flex-col font-mono`,children:[p.lines.map((e,t)=>{let n=S(e);return a(`span`,{title:e,className:`flex min-w-0 items-baseline gap-2`,children:[r(`span`,{className:`max-w-full shrink-0 truncate text-po-text`,children:n.name}),n.folder.length>0?r(`span`,{className:`min-w-0 truncate text-po-dim`,children:n.folder}):null]},`${String(t)}-${e}`)}),p.hidden>0?a(l,{expands:!0,children:[p.hidden,` more lines`]}):null,p.truncated===void 0?null:r(`span`,{className:`text-po-yellow`,children:p.truncated})]})}var E=`resultLimitReached`,D=`results`;function O(t){let n=b(t.args);return r(f,{tone:o({running:t.running,isError:t.isError}),expandable:!0,children:({expanded:i})=>a(e,{children:[r(u,{title:`find`,children:a(`span`,{"data-testid":`tool-call-find`,className:`flex min-w-0 flex-1 items-center gap-2`,children:[r(`span`,{className:`truncate text-po-text`,children:n.primary}),n.details.length>0?a(`span`,{className:`shrink-0 text-po-faint`,children:[`· `,n.details.join(` · `)]}):null]})}),i?r(T,{tool:`find`,limitKey:E,limitUnit:D,expanded:!0,props:t}):null]})})}var k=n({message:O}),A=`entryLimitReached`,j=`entries`;function M(t){let n=x(t.args);return r(f,{tone:o({running:t.running,isError:t.isError}),expandable:!0,children:({expanded:i})=>a(e,{children:[r(u,{title:`ls`,children:a(`span`,{"data-testid":`tool-call-ls`,className:`flex min-w-0 flex-1 items-center gap-2`,children:[r(`span`,{className:`truncate text-po-text`,children:n.primary}),n.details.length>0?a(`span`,{className:`shrink-0 text-po-faint`,children:[`· `,n.details.join(` · `)]}):null]})}),i?r(T,{tool:`ls`,limitKey:A,limitUnit:j,expanded:!0,props:t}):null]})})}var N=n({message:M});function P({view:t,path:n}){let o=s(t.preview.map(e=>e.text).join(`
|
|
7
|
-
`),{path:n});return r(e,{children:t.preview.map((e,n)=>a(`span`,{className:`flex gap-2`,children:[r(`span`,{className:`shrink-0 text-right text-po-faint`,style:{width:`${String(t.gutter)}ch`},children:e.number}),r(i,{spans:o?.[n],text:e.text,className:`min-w-0 whitespace-pre-wrap break-words text-po-text`})]},e.number))})}function F({args:t,result:n,output:i,running:s,isError:p,fileTabFor:m,openTransientTab:h}){let g=y(t,!1),_=m(g.path);return r(f,{tone:o({running:s,isError:p}),expandable:!0,children:({expanded:o})=>{let f=o?y(t,!0):g;return a(e,{children:[r(u,{title:`write`,children:a(`span`,{"data-testid":`tool-call-write`,className:`flex min-w-0 flex-1 items-center gap-2`,children:[r(c,{path:f.path,..._===void 0?{}:{onOpen:()=>h(_)}}),a(`span`,{className:`shrink-0 text-po-faint`,children:[`· `,f.size]})]})}),o?p?r(d,{"data-testid":`tool-result-write`,className:`flex flex-col`,children:r(`span`,{className:`whitespace-pre-wrap break-words text-po-red`,children:C(n,i)})}):f.preview.length===0?s?r(d,{"data-testid":`tool-result-write`,children:r(l,{tone:`running`,children:`running`})}):null:a(d,{"data-testid":`tool-result-write`,className:`flex flex-col font-mono`,children:[r(P,{view:f,path:f.path}),f.hidden>0?a(l,{expands:!0,children:[f.hidden,` more lines`]}):null,s?r(l,{tone:`running`,children:`running`}):null]}):null]})}})}var I=n({message:F}),L=(e,t)=>t===void 0?void 0:{...e,...t},R=t({id:`builtin-tools`,packageName:`@agimon-ai/po-ui`,session:{get toolRenderers(){return[L({tools:[`find`]},k),L({tools:[`ls`]},N),L({tools:[`write`]},I)]}}});export{R as webPlugin};
|