@agimon-ai/po-cloudflare 0.0.2-alpha.76 → 0.0.2-alpha.78
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-BlHIxC2J.js → approval-DRipNxVh.js} +4 -0
- package/dist/{approvalSession-UtzXVEB4.js → approvalSession-DPQQRkG4.js} +2 -2
- package/dist/assets/assets/{CodeEditorView-CaFk98Ji.js → CodeEditorView-CwDhkcuX.js} +2 -2
- package/dist/assets/assets/{abnfDiagram-WEYOIA3C-gzdpxFaJ.js → abnfDiagram-WEYOIA3C-x7ICShZ-.js} +2 -2
- package/dist/assets/assets/{architecture-WOLXFQ4H-TugrtWoO.js → architecture-WOLXFQ4H-BbNcuwIa.js} +1 -1
- package/dist/assets/assets/{architectureDiagram-ZHVYKT53-Xy_pnmaH.js → architectureDiagram-ZHVYKT53-BaKFNXDN.js} +2 -2
- package/dist/assets/assets/{blockDiagram-RJAE7QA3-pH1-jWYL.js → blockDiagram-RJAE7QA3-BpBDuUhc.js} +2 -2
- package/dist/assets/assets/{c4Diagram-XDPPPE54-CWmWk7y2.js → c4Diagram-XDPPPE54-CH1AYBxk.js} +2 -2
- package/dist/assets/assets/channel-DUu4-rZu.js +2 -0
- package/dist/assets/assets/{chunk-2E7WHVMD-C2O60zos.js → chunk-2E7WHVMD-zuvalEA0.js} +2 -2
- package/dist/assets/assets/{chunk-4EMNKR2T-CEHzGYY0.js → chunk-4EMNKR2T-Y1aujIa_.js} +2 -2
- package/dist/assets/assets/{chunk-55XCU76K-CjyzuqJm.js → chunk-55XCU76K-Cj_usw4a.js} +2 -2
- package/dist/assets/assets/{chunk-7S6XSTFO-Db8_vjDs.js → chunk-7S6XSTFO-CNv4j2oa.js} +2 -2
- package/dist/assets/assets/{chunk-AQDTSKZB-92c_fipW.js → chunk-AQDTSKZB-BgiafkbC.js} +2 -2
- package/dist/assets/assets/{chunk-DSNLSHJZ-DFGW_rzV.js → chunk-DSNLSHJZ-CEqk3yOv.js} +2 -2
- package/dist/assets/assets/{chunk-HAGFOTED-Cpx79XgA.js → chunk-HAGFOTED-w6XwPptZ.js} +2 -2
- package/dist/assets/assets/{chunk-HNE4Q36P-cz6K5cWs.js → chunk-HNE4Q36P-Du2F5NKF.js} +2 -2
- package/dist/assets/assets/{chunk-NQOKRVIF-Bhj8Cnrq.js → chunk-NQOKRVIF-e7LK2NBD.js} +2 -2
- package/dist/assets/assets/{chunk-UHW7PFBP-DugRZU3d.js → chunk-UHW7PFBP-CV1yEqMO.js} +2 -2
- package/dist/assets/assets/{chunk-VQ5W62QI-CFXU98Td.js → chunk-VQ5W62QI-Dz5nQ93K.js} +2 -2
- package/dist/assets/assets/{chunk-WQQL4CDK-BDYjxxgH.js → chunk-WQQL4CDK-CR_tliyN.js} +2 -2
- package/dist/assets/assets/chunk-XXDRQBXY-KxRgluI2.js +2 -0
- package/dist/assets/assets/{chunk-YZO67HFG-Bw3Zv3ms.js → chunk-YZO67HFG-DFykz1uM.js} +2 -2
- package/dist/assets/assets/{chunk-ZAUX2LTX-reWd5PI6.js → chunk-ZAUX2LTX-C-HZEj8t.js} +2 -2
- package/dist/assets/assets/{chunk-ZCHMQSOR-RCmNKJ0K.js → chunk-ZCHMQSOR-DhOusRJf.js} +2 -2
- package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-DOBOI7kO.js → classDiagram-v2-4MYWR3UA-CODBKWcv.js} +2 -2
- package/dist/assets/assets/{cose-bilkent-JH36ORCC-Dnga9ThU.js → cose-bilkent-JH36ORCC-CQBDxRkG.js} +2 -2
- package/dist/assets/assets/{cynefin-EF2NZ3EQ-mbxppeTd.js → cynefin-EF2NZ3EQ-BqEZr_DI.js} +1 -1
- package/dist/assets/assets/{cynefinDiagram-WF24UDRP-D5uSCW7P.js → cynefinDiagram-WF24UDRP-CAFtVFnZ.js} +2 -2
- package/dist/assets/assets/{dagre-NK4GIZVX-D3Utujwv.js → dagre-NK4GIZVX-6EbIcHjw.js} +2 -2
- package/dist/assets/assets/{diagram-CBK3MWTC-Bg8QfzPb.js → diagram-CBK3MWTC-DxOPl4wX.js} +2 -2
- package/dist/assets/assets/{diagram-I5XIIV2D-NjETU96V.js → diagram-I5XIIV2D-Dn-nrQn0.js} +2 -2
- package/dist/assets/assets/{diagram-ODIL2UCW-BRY10xxY.js → diagram-ODIL2UCW-Df9GeJiZ.js} +2 -2
- package/dist/assets/assets/{diagram-PFBEJUXE-CO5Nfc2a.js → diagram-PFBEJUXE-CzsqYRcB.js} +2 -2
- package/dist/assets/assets/{diagram-RJA3I4VV-jxuLnXXk.js → diagram-RJA3I4VV-Chxf9kLz.js} +2 -2
- package/dist/assets/assets/{diagram-TYUNFSNR-B-dUsynt.js → diagram-TYUNFSNR-DsSL0naA.js} +2 -2
- package/dist/assets/assets/{dist-Bsp48Zck.js → dist-1eIdTf5S.js} +2 -2
- package/dist/assets/assets/{dist-JCg255PN.js → dist-B7Fq62ue.js} +2 -2
- package/dist/assets/assets/{dist-DtWJqHVb.js → dist-C-zBeZYG.js} +2 -2
- package/dist/assets/assets/{dist-BMmgMuDM.js → dist-CNPkFbM6.js} +2 -2
- package/dist/assets/assets/{dist-lOIB9DJk.js → dist-DHBIyPPx.js} +2 -2
- package/dist/assets/assets/{dist-9C1WeAys.js → dist-DR6uuD7b.js} +2 -2
- package/dist/assets/assets/{dist-C8son2cz.js → dist-Dul31jTx.js} +2 -2
- package/dist/assets/assets/{dist-CXebcDwS.js → dist-dedZfm22.js} +2 -2
- package/dist/assets/assets/{dist-CUuM0eUM.js → dist-zUhlfRuY.js} +2 -2
- package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-KNVNlIfc.js → ebnfDiagram-V4P3TTPT-fUIcNhqL.js} +2 -2
- package/dist/assets/assets/{elk-QONTBCTQ-DsX7hxD1.js → elk-QONTBCTQ-BtFtt9dx.js} +2 -2
- package/dist/assets/assets/{erDiagram-KYQIGQAA-pjQN44eX.js → erDiagram-KYQIGQAA-8nTQgw_u.js} +2 -2
- package/dist/assets/assets/{eventmodeling-K75KTNOO-BCKz9w4V.js → eventmodeling-K75KTNOO-u--ksfW0.js} +1 -1
- package/dist/assets/assets/flowDiagram-IUGLLWBU-U-4ltU4o.js +1 -0
- package/dist/assets/assets/{ganttDiagram-R7GPNTJY-CeuiGYpW.js → ganttDiagram-R7GPNTJY-CWqNS4bm.js} +2 -2
- package/dist/assets/assets/{gitGraph-VSP46ZUC-BsN0Vwsr.js → gitGraph-VSP46ZUC-Dy9xUPnQ.js} +1 -1
- package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-ZIMBu3bo.js → gitGraphDiagram-PDYL7XHY-D9OwLXxL.js} +2 -2
- package/dist/assets/assets/{index-fYkh5qQp.js → index-Blt5rLZT.js} +90 -90
- package/dist/assets/assets/{info-OHQRW6UA-CJmrVYr6.js → info-OHQRW6UA-ByFo5VxO.js} +1 -1
- package/dist/assets/assets/{infoDiagram-MVDRKAX5-BsAIEQmU.js → infoDiagram-MVDRKAX5-DkV7tUak.js} +2 -2
- package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-BX_86A9r.js → ishikawaDiagram-HPEHV2GE-D62xVlJr.js} +2 -2
- package/dist/assets/assets/{journeyDiagram-BOSHW7O7-DVGI0WoP.js → journeyDiagram-BOSHW7O7-CmGrCQyD.js} +2 -2
- package/dist/assets/assets/{kanban-definition-FNSA4HC5-4RLBwWbL.js → kanban-definition-FNSA4HC5-CQ-96zcl.js} +2 -2
- package/dist/assets/assets/{line-BL8hbik-.js → line-LyW2S8xe.js} +2 -2
- package/dist/assets/assets/{linear-BWVrkBYc.js → linear-Df5iFoGG.js} +2 -2
- package/dist/assets/assets/{mermaid-parser.core-CMk5l3Wp.js → mermaid-parser.core-DwGEOVKN.js} +4 -4
- package/dist/assets/assets/{mermaid.core-DZuf73R_.js → mermaid.core-UZa2JDq1.js} +5 -5
- package/dist/assets/assets/{mindmap-definition-6OY57UG3-CPuk1tgo.js → mindmap-definition-6OY57UG3-DXZpBkD7.js} +2 -2
- package/dist/assets/assets/{packet-JDAUHWVQ-pVue6YBL.js → packet-JDAUHWVQ-DVu5opyp.js} +1 -1
- package/dist/assets/assets/{pegDiagram-ECIUJNBX-B8Ly6ehm.js → pegDiagram-ECIUJNBX-D2PGrJQR.js} +2 -2
- package/dist/assets/assets/{pie-XZMESJXO-DXAHc3bX.js → pie-XZMESJXO-CoJXcSM1.js} +1 -1
- package/dist/assets/assets/{pieDiagram-GNMPY74T-9nVo6xZM.js → pieDiagram-GNMPY74T-DlPni3lE.js} +2 -2
- package/dist/assets/assets/{quadrantDiagram-D57K4MC3-DbBqshQw.js → quadrantDiagram-D57K4MC3-tDWbeX9Y.js} +2 -2
- package/dist/assets/assets/{radar-ABXABTNO-CKPxbvS6.js → radar-ABXABTNO-CiE-yXqS.js} +1 -1
- package/dist/assets/assets/{railroad-I3PHUGI6-CULlMjWr.js → railroad-I3PHUGI6-Bt5352hi.js} +1 -1
- package/dist/assets/assets/{railroad-abnf-LNEFI6M7-BRjXoZsa.js → railroad-abnf-LNEFI6M7-BJH5rnqj.js} +1 -1
- package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-CD_uPeUF.js → railroad-ebnf-DWYD2UWJ-C0KftBWL.js} +1 -1
- package/dist/assets/assets/{railroad-peg-JR7BVNR7-Cv-b3SRa.js → railroad-peg-JR7BVNR7-CRa7U91X.js} +1 -1
- package/dist/assets/assets/{railroadDiagram-Y72NRBL7-DJ77wAhA.js → railroadDiagram-Y72NRBL7-fOs3RTR8.js} +2 -2
- package/dist/assets/assets/{requirementDiagram-EQYSW5RA-R7PFvkp-.js → requirementDiagram-EQYSW5RA-SvE7rYXk.js} +2 -2
- package/dist/assets/assets/{sankeyDiagram-SY24JHO5-DR2gLc8z.js → sankeyDiagram-SY24JHO5-nqR9ZUs4.js} +2 -2
- package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-TwEQL0yK.js → sequenceDiagram-BLEHNHQU-CgEFMQSq.js} +2 -2
- package/dist/assets/assets/{src-Cv8dmcJt.js → src-B4g3Iold.js} +2 -2
- package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-ShloXczl.js → stateDiagram-v2-A6IESKWZ-C2jH_xDT.js} +2 -2
- package/dist/assets/assets/{swimlanes-B3ENRKFQ-D17E07lx.js → swimlanes-B3ENRKFQ-Dbf1mXvK.js} +2 -2
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-Bc5KGsMc.js +9 -0
- package/dist/assets/assets/{timeline-definition-JXYKGLGB-BEvN2l_s.js → timeline-definition-JXYKGLGB-4u-pC3xz.js} +2 -2
- package/dist/assets/assets/{treeView-D4JQ5SDB-B0QcYOKz.js → treeView-D4JQ5SDB-CZmVi5-J.js} +1 -1
- package/dist/assets/assets/{treemap-SAJKECNS-CIGIJniE.js → treemap-SAJKECNS-BajhrENS.js} +1 -1
- package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-DbS-GLv8.js → usecaseDiagram-WPOLBNNX-J1gh4d5h.js} +2 -2
- package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-CEkmUNoT.js → vennDiagram-Q3Y3IDCW-CIRtS6C5.js} +2 -2
- package/dist/assets/assets/{wardley-7MLQ67FV-D9b-h7oE.js → wardley-7MLQ67FV-DjBwbtAb.js} +1 -1
- package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-BoWIYn_M.js → wardleyDiagram-IVAIDKWA-Cui7ZUN1.js} +2 -2
- package/dist/assets/assets/{webpack-rEg3nylj.js → webpack-FJjN4adW.js} +2 -2
- package/dist/assets/assets/{xychartDiagram-4URNHDU4-xJdWE_nx.js → xychartDiagram-4URNHDU4-I-UzMoDZ.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-C0B3uAoC.js +1 -0
- package/dist/assets/plugins/compositions.json +1 -1
- package/dist/assets/plugins/slots/{approval.09e72f36-B4Y8Wjzl.js → approval.dd60ec90-gfcirIrD.js} +1 -1
- package/dist/assets/plugins/slots/{artifacts.50b639bb-5Kf50LM1.js → artifacts.a078f1a5-B5YmdqFC.js} +1 -1
- package/dist/assets/plugins/slots/{author.ea449ace-BUAjd0RY.js → author.b2063a1b-QDThbn6B.js} +3 -3
- package/dist/assets/plugins/slots/{autocompact.6f428144-DUwf4L4s.js → autocompact.86aeccf4-DxTuE9o-.js} +1 -1
- package/dist/assets/plugins/slots/{backdrop-bamboo.6e4c928d-CT9PXrny.js → backdrop-bamboo.1a7d88ef-BfruoASs.js} +1 -1
- package/dist/assets/plugins/slots/{browse.fa1f1a50-ClrBioNv.js → browse.4b750f64-LwBuFuNb.js} +1 -1
- package/dist/assets/plugins/slots/{builtin-tools.75108f21-DmtavYBT.js → builtin-tools.0a7f0b8e-Cy2eN76-.js} +1 -1
- package/dist/assets/plugins/slots/{calendar.d8b70190-DmudDrcG.js → calendar.76ad65fa-CihobxD6.js} +1 -1
- package/dist/assets/plugins/slots/{codemode.c58fb583-BkVR1X2Y.js → codemode.ff16ac06-Dbjm7Efq.js} +1 -1
- package/dist/assets/plugins/slots/{domain.753f9f92-Bv-dlY79.js → domain.3ddea842-CJa-EzBA.js} +1 -1
- package/dist/assets/plugins/slots/{edit.804fec90-mJXCIk4G.js → edit.c5b0b072-Bp0bQ3N2.js} +1 -1
- package/dist/assets/plugins/slots/{files.66ffc636-CCRW8t1-.js → files.8ffcdcc0-re8nr2oz.js} +1 -1
- package/dist/assets/plugins/slots/{goal.45dffa01-q_Zh5QxW.js → goal.4524e2bf-C5mGe79a.js} +1 -1
- package/dist/assets/plugins/slots/{grep.98262cff-CTDwtVaK.js → grep.95f470b3-ClgsMgtm.js} +1 -1
- package/dist/assets/plugins/slots/{help.5fbd20f7-BBw7NYJI.js → help.dfbc8216-BGywkUKZ.js} +1 -1
- package/dist/assets/plugins/slots/{log.cb964209-BLY7IzD1.js → log.19bda339-6jMYUtlN.js} +1 -1
- package/dist/assets/plugins/slots/{mcp.82cc1ff5-5yoTabz8.js → mcp.ffbe405a-BnDP_LDU.js} +1 -1
- package/dist/assets/plugins/slots/{plan.3852ba52-DmdaEVVw.js → plan.2879a6ae-BXxVUfMI.js} +1 -1
- package/dist/assets/plugins/slots/{profile.ab16dcec-DOw3MhWl.js → profile.176710dd-Bc4Rwfhz.js} +1 -1
- package/dist/assets/plugins/slots/{prompts.ae48c07a-DQVmTxFZ.js → prompts.2c187969-CIBsOkp9.js} +1 -1
- package/dist/assets/plugins/slots/{read.4560591a-Bun0fKn1.js → read.1629d556-D-NY0ZCv.js} +1 -1
- package/dist/assets/plugins/slots/{runner.6e494d59-BDtBIqmQ.js → runner.962030e5-CCUVliK7.js} +1 -1
- package/dist/assets/plugins/slots/{scaffold.d87a6ee0-DZOiNwOS.js → scaffold.14b5f76b-DW44NU9X.js} +1 -1
- package/dist/assets/plugins/slots/{session-mcp.2be84084-DQpF2DkA.js → session-mcp.51089b63-Im-iuHcn.js} +1 -1
- package/dist/assets/plugins/slots/{sessions.6f47cb4c-y61JDvak.js → sessions.fc763f42-CL0PHuD4.js} +1 -1
- package/dist/assets/plugins/slots/{skill.62a0a1b3-C-mkriRv.js → skill.f5396fde-DHDfhNXW.js} +1 -1
- package/dist/assets/plugins/slots/{space.65a27e5a-Cr1HSI_z.js → space.d7bddb51-DFHblvL5.js} +1 -1
- package/dist/assets/plugins/slots/{subagents.8bb9992c-CrpR1Jhi.js → subagents.24539507-Db6YnHJd.js} +1 -1
- package/dist/assets/plugins/slots/{template-advanced.59f3f98a-CSuMHJ9x.js → template-advanced.292533fb-DyvcGxNV.js} +1 -1
- package/dist/assets/plugins/slots/{template-desktop.0f0b8491-C2ZheI0_.js → template-desktop.a1ef756c-5EQH-r7P.js} +1 -1
- package/dist/assets/plugins/slots/{template-elegant.0e3b0acf-Cq5Y_6VL.js → template-elegant.ceb23ac7-CrmEUE6V.js} +1 -1
- package/dist/assets/plugins/slots/{vault.3cbfcdc3-ZKO66wy8.js → vault.57fd9047-9cm8PfeP.js} +1 -1
- package/dist/assets/plugins/slots/{voice.a952113d-CsdoPA4G.js → voice.76006b18-BSC2gHHY.js} +1 -1
- package/dist/assets/plugins/slots/{web-search.65013836-C7W5RyLj.js → web-search.b025dda1-BMe5RM8K.js} +1 -1
- package/dist/assets/plugins/slots/{workflows.cbc5c5c0-BLNlHcfa.js → workflows.1fd6a554-CzFPuLnU.js} +1 -1
- package/dist/browser-BYWSPAEE.js +897 -0
- package/dist/{exports-Ct56PRB9.js → exports-BnHiOfC6.js} +1 -1
- package/dist/{index.edge-BRaAhap2.js → index.edge-By7eSfpp.js} +2 -2
- package/dist/sealedChannel-BeWNTWys.js +27 -0
- package/dist/{server-B3U0W7zD.js → server-1yS_uE-G.js} +1 -1
- package/dist/{server-CcKKktvn.js → server-B1kdSQrK.js} +1 -1
- package/dist/{server-fYfb0gN8.js → server-B3tod9fX.js} +3 -3
- package/dist/{server-BlbuM_IJ.js → server-BCuQ5v6n.js} +2 -2
- package/dist/{server-DAFM6HnJ.js → server-BGHoSIRR.js} +3 -3
- package/dist/{server-BUBijhBb.js → server-BN4AdrfM.js} +3 -3
- package/dist/{server-BSpJMYLb.js → server-Bl6gkrM7.js} +1 -1
- package/dist/{server-BPS6xFya.js → server-Bp5B4707.js} +1 -1
- package/dist/{server-D6-_DT9g.js → server-C-LM-7Mp.js} +1 -1
- package/dist/{server-CaFzaibK.js → server-Ca3X3h6Q.js} +1 -1
- package/dist/{server-CLRgSPVY.js → server-Cdrr9D-D.js} +1 -1
- package/dist/{server-BJssIIpm.js → server-Cj-2V-Z6.js} +1 -1
- package/dist/{server-Dnvp2U6V.js → server-CkEwZP4t.js} +1 -1
- package/dist/{server-DPG7BH6w.js → server-CodZPkK3.js} +1 -1
- package/dist/{server-7-DnO2Ww.js → server-CuKy4B95.js} +230 -117
- package/dist/{server-Dl3sng3O.js → server-D467psm_.js} +1 -1
- package/dist/{server-BUgDdcRW.js → server-DHAcLeIr.js} +1 -1
- package/dist/{server-HIbQWBba.js → server-DLZgrjI9.js} +9 -7
- package/dist/{server-BeAYfrzJ.js → server-DqEJjOJZ.js} +1 -1
- package/dist/{server-CKQwNrO8.js → server-DvXlixQN.js} +1 -1
- package/dist/{server-CMov-S5-.js → server-EyLWvUXw.js} +1 -1
- package/dist/{server-DMbdJzSQ.js → server-RF5gqssS.js} +1 -1
- package/dist/{server-BLcw1z6S.js → server-pp-NQWAR.js} +1 -1
- package/dist/{server-BqvkcVLn.js → server-rKR_yimq.js} +1 -1
- package/dist/{server-OzzJbeaS.js → server-sbfI6TAL.js} +2 -2
- package/dist/{type-DppaYz6F.js → type-1FxIJmfz.js} +2 -26
- package/dist/worker.js +80525 -80817
- package/package.json +49 -49
- package/dist/assets/assets/channel-CJxh7kPr.js +0 -2
- package/dist/assets/assets/chunk-XXDRQBXY-B7vCmBOn.js +0 -2
- package/dist/assets/assets/flowDiagram-IUGLLWBU-BU7xmb8h.js +0 -1
- package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-i6-zDqZm.js +0 -9
- package/dist/assets/plugins/chunks/po-web-runtime-CQ9hLtG-.js +0 -1
- package/dist/browser-ks_k-6KA.js +0 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ba as e,Or as t,qa as n}from"../chunks/po-web-runtime-
|
|
1
|
+
import{Ba as e,Or as t,qa as n}from"../chunks/po-web-runtime-C0B3uAoC.js";var r={1:{ratio:.5,capTokens:2e5},2:{ratio:.75,capTokens:5e5},3:{ratio:.95,capTokens:8e5}},i=`autocompact`,a=[`modes`,i],o=`thresholds`,s=`inherit the session model`,c=`inherit`,l=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],u=[`true`,`false`],d={id:i,label:`autocompact`,detail:`the model that writes checkpoint summaries, and when each compaction pass fires`,order:40,fields:[{id:`enabled`,label:`enabled`,keyPath:[...a,`enabled`],placeholder:`on`,detail:`off leaves compaction to Pi. unset is on.`,options:u},{id:`model`,label:`summarization model`,keyPath:[...a,`model`],placeholder:s,detail:`model that writes the checkpoint summaries.`,models:!0},{id:`thinking`,label:`summarization thinking`,keyPath:[...a,`thinking`],placeholder:c,detail:`thinking level appended to the summarization model.`,options:l},{id:`thresholds.pass1`,label:`pass 1 threshold`,keyPath:[...a,o,`pass1`],placeholder:String(r[1].ratio),detail:`fraction of the remaining context window at which the first pass fires.`},{id:`thresholds.pass2`,label:`pass 2 threshold`,keyPath:[...a,o,`pass2`],placeholder:String(r[2].ratio),detail:`second pass. a value below pass 1 is raised back to it.`},{id:`thresholds.pass3`,label:`pass 3 threshold`,keyPath:[...a,o,`pass3`],placeholder:String(r[3].ratio),detail:`last pass before Pi compacts natively. a value below pass 2 is raised back to it.`}].map(e=>({id:e.id,label:e.label,kind:e.models===!0||e.options!==void 0?`select`:`text`,keyPath:e.keyPath,detail:e.detail,placeholder:e.placeholder,...e.models===!0?{optionsFrom:`models`}:{},...e.options===void 0?{}:{options:e.options.map(e=>({value:e,label:e}))}}))},f=e({...d,icon:t}),p=e({...d,icon:t}),m=(e,t)=>t===void 0?void 0:{...e,...t},h=n({id:`autocompact`,packageName:`@agimon-ai/po-autocompact`,host:{get settingsSections(){return[m({id:`autocompact`},f)]}},workspace:{get settingsSections(){return[m({id:`autocompact`},p)]}}});export{h as webPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ht as e,It as t,Kt as n,Lt as r,ja as i,qa as a,qt as o}from"../chunks/po-web-runtime-
|
|
1
|
+
import{Ht as e,It as t,Kt as n,Lt as r,ja as i,qa as a,qt as o}from"../chunks/po-web-runtime-C0B3uAoC.js";var s=new URL(new URL(`../assets/day-bottom-left-5um-x02r-5um-x02r.webp`,import.meta.url).href,``+import.meta.url).href,c=new URL(new URL(`../assets/day-grain-CvEuNhlI-CvEuNhlI.webp`,import.meta.url).href,``+import.meta.url).href,l=new URL(new URL(`../assets/day-right-C9W-XtjV-C9W-XtjV.webp`,import.meta.url).href,``+import.meta.url).href,u=new URL(new URL(`../assets/day-top-left-B544Eq9J-B544Eq9J.webp`,import.meta.url).href,``+import.meta.url).href,d=new URL(new URL(`../assets/night-bottom-left-N03ST5Uz-N03ST5Uz.webp`,import.meta.url).href,``+import.meta.url).href,f=new URL(new URL(`../assets/night-grain-BY9q-tNN-BY9q-tNN.webp`,import.meta.url).href,``+import.meta.url).href,p=new URL(new URL(`../assets/night-right-C6Denrqj-C6Denrqj.webp`,import.meta.url).href,``+import.meta.url).href,m=new URL(new URL(`../assets/night-top-left-KOou6UxY-KOou6UxY.webp`,import.meta.url).href,``+import.meta.url).href,h={width:1585,height:992,cut:{x1:716,y:528,x2:772,blend:56}},g={day:{grain:c,right:l,topLeft:u,bottomLeft:s},night:{grain:f,right:p,topLeft:m,bottomLeft:d}},_=e=>`${(e/h.height*100).toFixed(3)}cqh`,v=e=>`${(e/h.height*100).toFixed(3)}%`;function y(){let{width:e,height:t,cut:n}=h;return{right:{aspectRatio:`${e-n.x1} / ${t}`},topLeft:{height:v(n.y),maxWidth:`calc(100% - ${_(e-n.x1)})`},bottomLeft:{height:v(t-n.y),maxWidth:`calc(100% - ${_(e-n.x2-n.blend)})`}}}var b=y(),x=[{left:`60%`,top:`64%`},{left:`73%`,top:`58%`},{left:`86%`,top:`70%`},{left:`55%`,top:`80%`}];function S({still:i=!1}){let a=n(null),[s,c]=o(!1);e(()=>{let e=a.current;if(!e)return;let t=()=>c(getComputedStyle(e).colorScheme.includes(`dark`));t();let n=new MutationObserver(t);return n.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`,`style`,`class`]}),()=>n.disconnect()},[]),e(()=>{let e=a.current;if(!e||i||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=Array.from(e.querySelectorAll(`[data-firefly]`),(e,t)=>e.animate([{opacity:.1,transform:`translate(0, 0)`},{opacity:.9,transform:`translate(${t%2?-6:6}px, -8px)`},{opacity:.1,transform:`translate(0, 0)`}],{duration:5200+t*1700,delay:-t*1300,iterations:1/0,easing:`ease-in-out`}));return()=>t.forEach(e=>e.cancel())},[s,i]);let l=s?g.night:g.day;return r(`div`,{ref:a,"aria-hidden":!0,"data-testid":`bamboo-backdrop`,className:`pointer-events-none absolute inset-0 overflow-hidden bg-po-deep select-none [container-type:size]`,children:[t(`img`,{src:l.grain,alt:``,draggable:!1,className:`absolute inset-0 size-full object-cover opacity-50 mix-blend-overlay`}),t(`img`,{src:l.topLeft,alt:``,draggable:!1,style:b.topLeft,className:`absolute top-0 left-0 w-auto object-contain object-left-top`}),t(`img`,{src:l.bottomLeft,alt:``,draggable:!1,style:b.bottomLeft,className:`absolute bottom-0 left-0 w-auto object-contain object-left-bottom`}),r(`div`,{style:b.right,className:`absolute right-0 bottom-0 h-full`,children:[t(`img`,{src:l.right,alt:``,draggable:!1,className:`size-full`}),s?x.map(e=>t(`span`,{"data-firefly":!0,style:e,className:`absolute size-1 rounded-full bg-po-yellow opacity-60 shadow-[0_0_6px_2px_var(--po-yellow)]`},e.left)):null]})]})}var C=i({data:{label:`Po bamboo`,description:`Po in the bamboo, painted in ink on silk.`},component:()=>t(S,{})}),w=(e,t)=>t===void 0?void 0:{...e,...t},T=a({id:`backdrop-bamboo`,packageName:`@agimon-ai/po-backdrop-bamboo`,host:{get fills(){return[w({slot:`backdrop`,id:`bamboo`},C)]}}});export{T as webPlugin};
|
package/dist/assets/plugins/slots/{browse.fa1f1a50-ClrBioNv.js → browse.4b750f64-LwBuFuNb.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$n as e,$r as t,An as n,Ba as r,Bn as i,Bt as a,Da as o,Di as s,En as c,Ft as l,Gi as u,Gn as d,Hi as f,Ht as p,It as m,Ka as h,Ki as g,Kt as _,Li as v,Lt as y,Ma as b,Nr as x,Pi as S,Pr as ee,Pt as te,Ra as ne,Ri as re,Ta as ie,Ti as ae,Wi as oe,Xi as se,Xn as ce,Xt as C,Yi as le,Zi as ue,Zn as de,_r as w,aa as fe,ea as pe,en as me,fr as T,gr as E,hr as D,ia as O,ja as he,la as ge,ln as _e,mr as ve,nr as ye,or as be,pr as xe,qa as Se,qi as Ce,qt as k,ra as A,rn as j,sa as M,ta as N,ti as we,tr as Te,ur as Ee,vr as P,ya as F,yr as I,za as De}from"../chunks/po-web-runtime-CQ9hLtG-.js";var L={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`}]}]},Oe=`/api/plugins/browse/profiles`,ke=`/api/plugins/browse/remote`,Ae=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`});function je(e){let{profiles:n,error:r,confirming:i,deleting:a,openMenu:o}=e;return y(`div`,{"data-testid":`browser-profiles`,className:`@container flex flex-col gap-3`,children:[r?m(`p`,{role:`alert`,className:`text-sm text-po-red`,children:r}):null,n===void 0?m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading profiles…`}):n.length===0?m(ge,{title:`No browser profiles yet`,description:`Po saves one when a task signs in to a site.`,className:`py-12`}):m(`ul`,{"aria-label":`Browser profiles`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @3xl:grid-cols-3`,children:n.map(n=>m(c,{asChild:!0,className:`flex min-w-0 items-start gap-3 py-3 pr-1 pl-3`,children:y(`li`,{"data-testid":`browser-profile-${n.name}`,"aria-busy":a===n.name,children:[m(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-po-deep`,children:m(F,{"aria-hidden":!0,className:`size-4 text-po-dim`})}),y(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[m(`span`,{className:`truncate text-base font-semibold text-po-hi`,children:n.name}),m(`span`,{className:`truncate text-sm text-po-dim`,children:a===n.name?`Deleting…`:n.lastUsedAt?`Last used ${Ae.format(new Date(n.lastUsedAt))}`:`Updated ${Ae.format(new Date(n.updatedAt))}`})]}),y(N,{modal:!1,defaultOpen:o===n.name,children:[m(M,{asChild:!0,children:m(t,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${n.name}`,disabled:a!==void 0,children:m(j,{className:`size-3.5`})})}),m(A,{align:`end`,children:y(O,{variant:`destructive`,onSelect:()=>e.onAskDelete?.(n.name),children:[m(we,{className:`size-3.5`}),`Delete profile`]})})]})]})},n.name))}),m(oe,{open:i!==void 0,onOpenChange:t=>t?void 0:e.onCancelDelete?.(),children:y(g,{children:[m(se,{children:y(ue,{children:[`Delete `,i,`?`]})}),m(u,{children:m(Ce,{children:`Its saved sign-ins, cookies and fingerprint are removed. Po signs in again the next time a task needs it.`})}),y(le,{children:[m(t,{onClick:e.onCancelDelete,children:`Keep profile`}),m(t,{variant:`danger-outline`,disabled:a!==void 0,onClick:()=>i===void 0?void 0:e.onConfirmDelete?.(i),children:`Delete profile`})]})]})})]})}async function Me(e,t){let n=await e.json().catch(()=>void 0);return typeof n?.error==`string`?n.error:t}function Ne({request:e,requestWithStepUp:t}){let[n,r]=k(),[i,o]=k(),[s,c]=k(),[l,u]=k(),d=a(async()=>{try{let t=await e(Oe);if(!t.ok)throw Error(await Me(t,`Po could not read your browser profiles.`));r((await t.json()).profiles),o(void 0)}catch(e){r(e=>e??[]),o(e instanceof Error?e.message:`Po could not read your browser profiles.`)}},[e]);p(()=>{d()},[d]);let f=async e=>{u(e);try{let n=await t(`${Oe}/${encodeURIComponent(e)}`,{method:`DELETE`});o(n.ok?void 0:await Me(n,`Po could not delete this profile.`))}catch(e){o(e instanceof Error?e.message:`Po could not delete this profile.`)}finally{c(void 0),u(void 0),await d()}};return m(je,{profiles:n,error:i,confirming:s,deleting:l,onAskDelete:c,onCancelDelete:()=>c(void 0),onConfirmDelete:e=>void f(e)})}var R=`__default`;function Pe({values:n,loading:r,saving:i,error:a,onChange:o,onRetry:s,profiles:c}){return y(`div`,{"data-testid":`browser-settings`,className:`flex min-w-0 flex-col gap-10`,children:[y(E,{children:[y(P,{children:[m(I,{children:`Engine`}),m(w,{children:`Applies to every workspace. Changes apply to the next browser Po opens.`})]}),a?y(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m(`p`,{role:`alert`,className:`text-sm text-po-red`,children:a}),m(t,{size:`sm`,variant:`ghost`,disabled:i,onClick:s,children:`Try again`})]}):null,m(be,{"aria-busy":r||i||void 0,children:L.fields.map(t=>{let a=t.id,s=n[a];return y(T,{"data-testid":`browser-setting-${a}`,changed:s!==void 0,className:`items-start`,children:[y(ve,{className:`gap-1`,children:[m(D,{className:`flex min-h-6 items-center`,children:t.label}),t.detail?m(xe,{children:t.detail}):null]}),y(ce,{value:s??R,disabled:r||i,onValueChange:e=>o?.(a,e===R?null:e),children:[m(Te,{"aria-label":t.label,className:`w-full text-sm sm:w-64`,children:m(ye,{placeholder:t.placeholder})}),y(de,{children:[m(e,{value:R,children:t.placeholder}),(t.options??[]).map(t=>m(e,{value:t.value,children:t.label},t.value))]})]})]},a)})}),i||r&&!a?m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:i?`Saving on your computer…`:`Loading browser settings…`}):null]}),y(E,{children:[y(P,{children:[m(I,{children:`Profiles`}),m(w,{children:`Each profile keeps its own sign-ins, cookies and fingerprint.`})]}),c]})]})}function Fe(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 Ie(e,t){return new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`,timeZone:t}).format(new Date(e))}function Le({status:e,loading:n,error:r,onRetry:a,timeZone:o}){let s=e?Math.min(e.usedSeconds,e.limitSeconds):0,c=e!==void 0&&e.usedSeconds>=e.limitSeconds,l=e?Ie(e.resetsAt,o):``,u=e?Math.round(e.idleSeconds/60):0;return y(`div`,{"data-testid":`remote-browser-settings`,className:`flex min-w-0 flex-col gap-10`,children:[y(E,{children:[y(P,{children:[m(I,{children:`Today`}),m(w,{children:`Po Cloud runs the browser for you. Every session on this account shares one daily allowance.`})]}),r?y(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m(`p`,{role:`alert`,className:`text-sm text-po-red`,children:r}),m(t,{size:`sm`,variant:`ghost`,onClick:a,children:`Try again`})]}):null,e&&!e.enabled?m(Ee,{children:`The browser is turned off on this host, so Po does web tasks without one.`}):null,y(be,{"aria-busy":n||void 0,children:[y(T,{"data-testid":`remote-browser-time`,className:`items-start`,children:[y(ve,{className:`gap-2`,children:[m(D,{children:`Browser time`}),m(xe,{children:e?`Resets at ${l} (${e.resetsAt.slice(11,16)} UTC).`:`Resets every day.`}),m(i,{"aria-label":`Browser time used today`,value:e&&e.limitSeconds>0?s/e.limitSeconds*100:0})]}),m(`span`,{className:`shrink-0 text-base font-semibold tabular-nums text-po-hi`,children:e?`${Fe(s)} of ${Fe(e.limitSeconds)}`:`…`})]}),y(T,{"data-testid":`remote-browser-open`,className:`items-start`,children:[y(ve,{className:`gap-1`,children:[m(D,{children:`Open now`}),m(xe,{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.`})]}),m(`span`,{className:`shrink-0 text-base font-semibold tabular-nums text-po-hi`,children:e?`${e.open} of ${e.openLimit}`:`…`})]})]}),c?y(`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,n&&!r?m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading browser use…`}):null]}),y(E,{children:[y(P,{children:[m(I,{children:`Sign-ins`}),m(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.`})]}),m(Ee,{children:`Saved browser profiles are not available on Po Cloud yet.`})]})]})}var Re=`/api/settings`,ze=`/api/settings/value`,Be=`The request did not reach Po on your computer.`;function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Ve(e){let t=await e.json().catch(()=>void 0);if(!e.ok)return{ok:!1,error:z(t)&&typeof t.error==`string`?t.error:`Po answered ${e.status}.`};if(!z(t)||!z(t.values)||!z(t.hashes)||typeof t.hashes.host!=`string`)return{ok:!1,error:`Po answered with no configuration.`};let n={};for(let e of L.fields){let r=t.values[e.keyPath.join(`.`)];z(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 B(e){let t=new URLSearchParams({repoRoot:``});for(let e of L.fields)t.append(`key`,e.keyPath.join(`.`));try{return await Ve(await e(`${Re}?${t.toString()}`))}catch{return{ok:!1,error:Be}}}async function He(e,t,n,r){let i=L.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(ze,{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 B(e):await Ve(t)}catch{return{ok:!1,error:Be}}}function Ue({request:e,requestWithStepUp:t}){let[n,r]=k(),[i,o]=k(!0),[s,c]=k(!1),[l,u]=k(),d=_(!1),f=_(!1),m=a(async()=>{o(!0);let t=await B(e);d.current&&(t.ok?(r(t.config),u(void 0)):(r(void 0),u(t.error)),o(!1))},[e]);p(()=>(d.current=!0,m(),()=>{d.current=!1}),[m]);let h=async(a,o)=>{if(f.current||i||!n)return;f.current=!0,c(!0),u(void 0);let s=await He(t,a,o,n.hash);if(d.current){if(s.ok)r(s.config);else{if(s.conflict){let t=await B(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 m(),onChange:(e,t)=>void h(e,t)}}function We(e){return m(Pe,{...Ue(e),profiles:m(Ne,{...e})})}function Ge(e){let{request:t}=e,[n,r]=k({kind:`checking`}),i=a(async()=>{try{let e=await t(ke);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 p(()=>{i()},[i]),n.kind===`local`?m(We,{...e}):n.kind===`checking`?m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading browser settings…`}):m(Le,{status:n.status,error:n.error,onRetry:()=>void i()})}var Ke=De({label:`Browser`,detail:`The browser Po uses for web tasks, and how long your sign-ins last.`,order:L.order,icon:C,component:Ge}),qe=r({...L,icon:C}),Je={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 Ye(e){return e.sessionId===null?void 0:e.slotData?.(Je)?.[0]?.data}var Xe=`browse_activity`,Ze=`browse`;function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Qe=new Set([`active`,`idle`,`asleep`,`crashed`]);function $e(e){return V(e)&&typeof e.id==`string`&&typeof e.title==`string`&&typeof e.url==`string`&&typeof e.current==`boolean`&&typeof e.lastAccessedAt==`number`}function et(e){return!V(e)||typeof e.id!=`string`||typeof e.name!=`string`||!Qe.has(e.state)||e.window!==`headed`&&e.window!==`headless`||typeof e.lastUsedAt!=`number`||!Array.isArray(e.tabs)?null:{...e,tabs:e.tabs.filter($e)}}function tt(e){return!V(e)||!Array.isArray(e.identities)?null:{identities:e.identities.map(et).filter(e=>e!==null)}}function nt(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function rt(e){return V(e)?e.state===`ok`&&typeof e.src==`string`&&e.src.startsWith(`data:image/`)?{state:`ok`,src:e.src,...nt(e.seq)?{seq:e.seq}:{}}:e.state===`unchanged`&&nt(e.seq)?{state:`unchanged`,seq:e.seq}:e.state===`closed`||e.state===`timeout`?{state:e.state}:{state:`error`}:{state:`error`}}function it(e){return V(e)&&e.ok===!0&&typeof e.path==`string`&&e.path!==``?{ok:!0,path:e.path}:V(e)&&e.ok===!1&&typeof e.message==`string`?{ok:!1,message:e.message}:{ok:!1,message:`Po could not take the snapshot.`}}function at(e,t,n){if(!(V(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 ot({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 st(e){return`${e} ${e===1?`tab`:`tabs`}`}function ct(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 H({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=ne({identities:[],hidden:[],pending:0});function W(e){return te(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:Xe,parse:tt,reduce:(e,{identities:t})=>({...e,identities:t,...e.pending===0?{hidden:[]}:{}})}),G=b(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:Ze,method:t,input:n}):Promise.reject(Error(`The browser view is not connected.`))}async function ht(e,t,n){try{return rt(await K(e,`frame`,n===void 0?{tabId:t}:{tabId:t,since:n}))}catch{return{state:`error`}}}async function gt(e,t){try{return it(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 at(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:H(e)};let r=Math.max(0,t-n),i=r<Z?X:r<Q?Z:Q;return{text:H({...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 y(`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:[y(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[m(`span`,{className:`shrink-0 truncate text-base font-semibold text-po-hi`,children:e.name}),m(`span`,{className:`text-xs text-po-faint`,children:`›`}),m(`span`,{className:`min-w-0 truncate text-base text-po-text`,children:t.title}),m(x,{tone:c?`running`:`neutral`,"data-testid":`browser-live-state`,children:l}),m(`span`,{className:`ml-auto shrink-0 text-sm text-po-dim`,children:`View only`}),o===void 0?null:m(wt,{state:o,disabled:i||!f,onSnapshot:s})]}),y(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-po-border`,children:[y(`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?m(_e,{"aria-label":`Secure connection`,className:`size-3 shrink-0 text-po-dim`}):m(F,{"aria-label":`Not secure`,className:`size-3 shrink-0 text-po-dim`}),m(`span`,{"data-testid":`browser-live-url`,className:`min-w-0 flex-1 truncate font-mono text-sm text-po-text`,children:t.url})]}),m(`div`,{className:`relative min-h-0 flex-1 bg-po-bg ${i?`opacity-50 grayscale`:``}`,children:n?m(`img`,{src:n,alt:`Live view of ${t.title}`,className:`absolute inset-0 size-full object-contain object-top`}):r||m(`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`})})]}),m(`span`,{"data-testid":`browser-live-footer`,className:`truncate text-sm text-po-dim`,children:u})]})}function wt({state:e,disabled:n,onSnapshot:r}){return y(`span`,{className:`flex shrink-0 items-center gap-2`,children:[typeof e==`object`?m(`span`,{role:`alert`,className:`max-w-48 truncate text-sm text-po-red`,title:e.error,children:e.error}):null,m(t,{size:`xs`,variant:`outline`,"data-testid":`browser-live-snapshot`,disabled:n,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=>m(kt,{...e,opened:n}),retainComposer:!0,composerContext:e=>Et(e,n)}}function Ot(){let[e,t]=k(()=>typeof document>`u`||!document.hidden);return p(()=>{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]=k(),[c,l]=k(!1),[u,d]=k(),f=i.gone||a||c,h=Ot(),g=n.tab.id;p(()=>{if(t!==null&&!f&&h)return xt(e=>ht(t,g,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,g,f,h]);let v=_(!0);p(()=>(v.current=!0,()=>{v.current=!1}),[]);let[y,b]=k(`idle`),x=Ye(e),S=async()=>{if(x===void 0||t===null||y===`taking`)return;b(`taking`);let e=await St(gt,{sessionId:t,tabId:g,identity:n.identity.id,url:i.tab.url},x,r);v.current&&b(e)},ee=lt(u,i.tab.current);return m(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:y,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?m(ge,{"data-testid":`browsers-panel`,title:`No browser yet`,description:`Po opens one when a task needs the web.`,className:`py-12`}):y(`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:[m(`p`,{className:`text-sm text-po-dim`,children:ct(t)}),n?m(`p`,{role:`alert`,className:`text-sm text-po-red`,children:n}):null,t.map(t=>m(Mt,{...e,identity:t},t.id))]})}function Mt(e){let{identity:n,busy:r,canShowWindow:i=!0,openMenu:a}=e,{state:o,tabs:s}=n,c=r?.[n.id],u=o===`active`||o===`idle`,f=o!==`crashed`&&c===void 0,p=n.profile!==!1;return y(`section`,{"aria-label":n.name,"data-testid":`browsers-identity-${n.id}`,"data-state":o,className:`flex flex-col gap-3`,children:[y(`header`,{className:`flex min-w-0 items-center gap-2`,children:[m(pe,{tone:At[o],pulse:o===`active`||c!==void 0}),m(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-po-hi`,children:n.name}),y(`span`,{className:`min-w-0 flex-1 truncate text-sm ${o===`crashed`?`text-po-red`:`text-po-dim`}`,children:[c??H(n),u?` · ${n.window===`headed`?`Window shown`:`No window`}`:``]}),f?y(N,{modal:!1,defaultOpen:a===`identity:${n.id}`,children:[m(M,{asChild:!0,children:m(t,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${n.name}`,children:m(j,{className:`size-3.5`})})}),y(A,{align:`end`,children:[p?o===`asleep`?y(O,{onSelect:()=>e.onWake?.(n.id),children:[m(d,{className:`size-3.5`}),`Wake up`]}):y(l,{children:[i?y(O,{onSelect:()=>e.onToggleWindow?.(n.id,n.window===`headed`?`headless`:`headed`),children:[m(C,{className:`size-3.5`}),n.window===`headed`?`Hide window`:`Show window`]}):null,y(O,{onSelect:()=>e.onSleep?.(n.id),children:[m(ee,{className:`size-3.5`}),`Put to sleep`]})]}):null,p?m(fe,{}):null,y(O,{onSelect:()=>e.onCloseBrowser?.(n.id),children:[m(S,{className:`size-3.5`}),`Close browser`]})]})]}):null]}),s.length>0?m(`ul`,{"aria-label":`Tabs in ${n.name}`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @4xl:grid-cols-3`,children:s.map(t=>m(Nt,{...e,tab:t},t.id))}):null]})}function Nt(e){let{identity:r,tab:i,renderFrame:a,openMenu:o}=e,s=r.state===`asleep`,u=r.state===`active`&&i.current,d=()=>e.onWatch?.(r.id,i.id),p=e=>{e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d())},h=a?.(r,i);return m(c,{asChild:!0,className:`flex min-w-0 flex-col focus-within:border-po-green`,children:y(`li`,{"data-testid":`browsers-tab-${i.id}`,"data-current":i.current,children:[s?null:y(`div`,{role:`button`,tabIndex:0,title:`Watch this tab live`,onClick:d,onKeyDown:p,className:`relative aspect-video cursor-pointer overflow-hidden bg-po-deep outline-none`,children:[h??y(`span`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-1 text-sm text-po-dim`,children:[m(F,{"aria-hidden":!0,className:`size-5 text-po-faint`}),`Waiting for the first frame`]}),u?m(`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]}),y(`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:[y(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[m(`span`,{className:`truncate text-base ${i.current?`font-semibold text-po-hi`:`text-po-text`}`,children:i.title}),m(`span`,{className:`truncate text-sm text-po-dim`,children:Y(i.url)})]}),y(N,{modal:!1,defaultOpen:o===`tab:${i.id}`,children:[m(M,{asChild:!0,children:m(t,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${i.title}`,children:m(j,{className:`size-3.5`})})}),y(A,{align:`end`,children:[s?null:y(l,{children:[y(O,{onSelect:d,children:[m(n,{className:`size-3.5`}),`Watch live`]}),e.onSnapshot?y(O,{onSelect:()=>e.onSnapshot?.(r.id,i.id),children:[m(me,{className:`size-3.5`}),`Snapshot to Author`]}):null]}),y(O,{onSelect:()=>e.onCopyUrl?.(i.url),children:[m(f,{className:`size-3.5`}),`Copy URL`]}),s?null:y(l,{children:[m(fe,{}),y(O,{onSelect:()=>e.onCloseTab?.(r.id,i.id),children:[m(S,{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]=k();return p(()=>xt(n=>ht(e,t,n),e=>{e.state===`ok`&&r(e.src)}),[e,t]),n===void 0?void 0:m(`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]=k(),o=Ye(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 m(jt,{identities:ot(r).map(e=>yt(e)),renderFrame:(e,n)=>t===null||e.state===`asleep`?void 0:m(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=ie({keys:`g b`,icon:F,activeSource:ft,marksBackgroundWork:!1,order:45,transientTab:Pt}),Rt=o(pt),zt={active:`green`,idle:`neutral`,asleep:`muted`,crashed:`red`};function Bt({identities:e,onOpenTab:n,onCloseTab:r,onCloseBrowser:i,onCloseAsleep:a,error:o}){if(e.length===0)return m(`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=ct(e);return y(`div`,{"data-testid":`activity-browser-identities`,className:`flex flex-col gap-1`,children:[m(`p`,{"data-testid":`activity-summary-browser`,className:`px-1 pb-1 text-sm text-po-dim`,children:c}),o?m(`p`,{role:`alert`,className:`px-1 pb-1 text-sm text-po-red`,children:o}):null,m(`ul`,{className:`flex flex-col`,children:e.map(e=>m(Vt,{identity:e,onOpenTab:n,onCloseTab:r,onCloseBrowser:i},e.id))}),s.length>1&&a?y(t,{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:e,onOpenTab:n,onCloseTab:r,onCloseBrowser:i}){let{state:a,tabs:o}=e,[c,l]=k(a===`active`),u=a===`asleep`;return m(`li`,{"data-testid":`activity-browser-${e.id}`,"data-state":a,className:`group/row`,children:y(v,{open:c,onOpenChange:l,children:[y(`div`,{className:`flex items-start gap-1 rounded-md hover:bg-po-deep/60`,children:[y(t,{variant:`ghost`,size:`card`,"aria-expanded":o.length>0?c:void 0,title:e.name,onClick:()=>l(!c),className:`min-w-0 flex-1 gap-0.5 px-1.5 py-1.5 hover:bg-transparent`,children:[y(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[m(pe,{tone:zt[a],pulse:a===`active`}),m(`span`,{className:`min-w-0 flex-1 truncate text-base font-semibold text-po-hi`,children:e.name}),o.length>0&&!c?m(`span`,{className:`shrink-0 text-sm text-po-dim`,children:st(o.length)}):null,o.length>0?c?m(ae,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-po-dim`}):m(s,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-po-faint`}):null]}),m(`span`,{className:`pl-3.5 text-sm ${a===`crashed`?`text-po-red`:`truncate text-po-dim`}`,children:m(Ut,{identity:e})})]}),a!==`crashed`&&i?y(N,{modal:!1,children:[m(M,{asChild:!0,children:m(t,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${e.name}`,className:`mt-1.5 mr-1 opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100`,children:m(j,{className:`size-3.5`})})}),m(A,{align:`end`,children:y(O,{onSelect:()=>i(e.id),children:[m(S,{className:`size-3.5`}),`Close browser`]})})]}):null]}),m(re,{children:m(`ul`,{"aria-label":`Tabs in ${e.name}`,className:`flex flex-col gap-0.5 pt-0.5 pb-1.5 pl-4`,children:o.map(i=>u?m(`li`,{className:`flex items-center gap-2 px-1.5 py-1.5`,children:m(Ht,{tab:i,here:!1})},i.id):y(`li`,{className:`group/tab flex items-center gap-1 rounded-md hover:bg-po-deep`,children:[m(t,{variant:`ghost`,size:`card`,"data-testid":`activity-browser-tab-${i.id}`,"data-current":i.current,"aria-current":i.current?`true`:void 0,title:`Watch this tab live`,onClick:()=>n?.(e.id,i.id),className:`min-w-0 flex-1 flex-row items-center gap-2 px-1.5 py-1.5 hover:bg-transparent`,children:m(Ht,{tab:i,here:i.current&&a===`active`})}),r?m(t,{variant:`ghost`,size:`icon`,"aria-label":`Close ${i.title}`,onClick:()=>r(e.id,i.id),className:`mr-1 opacity-0 group-hover/tab:opacity-100 focus-visible:opacity-100`,children:m(S,{className:`size-3.5`})}):null]},i.id))})})]})})}function Ht({tab:e,here:t}){return y(l,{children:[m(`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)}),y(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[m(`span`,{className:`truncate text-base ${e.current?`font-semibold text-po-hi`:`text-po-text`}`,children:e.title}),m(`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=_(null);return p(()=>{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]),m(`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 m(Bt,{identities:ot(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=he({component:Gt}),qt=h(mt),$=(e,t)=>t===void 0?void 0:{...e,...t},Jt=Se({id:`browse`,packageName:`@agimon-ai/po-browse`,host:{get settingsPanels(){return[$({id:`browser`},Ke)]}},workspace:{get settingsSections(){return[$({id:`browser-control`},qe)]}},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
|
+
import{$n as e,$r as t,An as n,Ba as r,Bn as i,Bt as a,Da as o,Di as s,En as c,Ft as l,Gi as u,Gn as d,Hi as f,Ht as p,It as m,Ka as h,Ki as g,Kt as _,Li as v,Lt as y,Ma as b,Nr as x,Pi as S,Pr as ee,Pt as te,Ra as ne,Ri as re,Ta as ie,Ti as ae,Wi as oe,Xi as se,Xn as ce,Xt as C,Yi as le,Zi as ue,Zn as de,_r as w,aa as fe,ea as pe,en as me,fr as T,gr as E,hr as D,ia as O,ja as he,la as ge,ln as _e,mr as ve,nr as ye,or as be,pr as xe,qa as Se,qi as Ce,qt as k,ra as A,rn as j,sa as M,ta as N,ti as we,tr as Te,ur as Ee,vr as P,ya as F,yr as I,za as De}from"../chunks/po-web-runtime-C0B3uAoC.js";var L={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`}]}]},Oe=`/api/plugins/browse/profiles`,ke=`/api/plugins/browse/remote`,Ae=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`});function je(e){let{profiles:n,error:r,confirming:i,deleting:a,openMenu:o}=e;return y(`div`,{"data-testid":`browser-profiles`,className:`@container flex flex-col gap-3`,children:[r?m(`p`,{role:`alert`,className:`text-sm text-po-red`,children:r}):null,n===void 0?m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading profiles…`}):n.length===0?m(ge,{title:`No browser profiles yet`,description:`Po saves one when a task signs in to a site.`,className:`py-12`}):m(`ul`,{"aria-label":`Browser profiles`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @3xl:grid-cols-3`,children:n.map(n=>m(c,{asChild:!0,className:`flex min-w-0 items-start gap-3 py-3 pr-1 pl-3`,children:y(`li`,{"data-testid":`browser-profile-${n.name}`,"aria-busy":a===n.name,children:[m(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-po-deep`,children:m(F,{"aria-hidden":!0,className:`size-4 text-po-dim`})}),y(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[m(`span`,{className:`truncate text-base font-semibold text-po-hi`,children:n.name}),m(`span`,{className:`truncate text-sm text-po-dim`,children:a===n.name?`Deleting…`:n.lastUsedAt?`Last used ${Ae.format(new Date(n.lastUsedAt))}`:`Updated ${Ae.format(new Date(n.updatedAt))}`})]}),y(N,{modal:!1,defaultOpen:o===n.name,children:[m(M,{asChild:!0,children:m(t,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${n.name}`,disabled:a!==void 0,children:m(j,{className:`size-3.5`})})}),m(A,{align:`end`,children:y(O,{variant:`destructive`,onSelect:()=>e.onAskDelete?.(n.name),children:[m(we,{className:`size-3.5`}),`Delete profile`]})})]})]})},n.name))}),m(oe,{open:i!==void 0,onOpenChange:t=>t?void 0:e.onCancelDelete?.(),children:y(g,{children:[m(se,{children:y(ue,{children:[`Delete `,i,`?`]})}),m(u,{children:m(Ce,{children:`Its saved sign-ins, cookies and fingerprint are removed. Po signs in again the next time a task needs it.`})}),y(le,{children:[m(t,{onClick:e.onCancelDelete,children:`Keep profile`}),m(t,{variant:`danger-outline`,disabled:a!==void 0,onClick:()=>i===void 0?void 0:e.onConfirmDelete?.(i),children:`Delete profile`})]})]})})]})}async function Me(e,t){let n=await e.json().catch(()=>void 0);return typeof n?.error==`string`?n.error:t}function Ne({request:e,requestWithStepUp:t}){let[n,r]=k(),[i,o]=k(),[s,c]=k(),[l,u]=k(),d=a(async()=>{try{let t=await e(Oe);if(!t.ok)throw Error(await Me(t,`Po could not read your browser profiles.`));r((await t.json()).profiles),o(void 0)}catch(e){r(e=>e??[]),o(e instanceof Error?e.message:`Po could not read your browser profiles.`)}},[e]);p(()=>{d()},[d]);let f=async e=>{u(e);try{let n=await t(`${Oe}/${encodeURIComponent(e)}`,{method:`DELETE`});o(n.ok?void 0:await Me(n,`Po could not delete this profile.`))}catch(e){o(e instanceof Error?e.message:`Po could not delete this profile.`)}finally{c(void 0),u(void 0),await d()}};return m(je,{profiles:n,error:i,confirming:s,deleting:l,onAskDelete:c,onCancelDelete:()=>c(void 0),onConfirmDelete:e=>void f(e)})}var R=`__default`;function Pe({values:n,loading:r,saving:i,error:a,onChange:o,onRetry:s,profiles:c}){return y(`div`,{"data-testid":`browser-settings`,className:`flex min-w-0 flex-col gap-10`,children:[y(E,{children:[y(P,{children:[m(I,{children:`Engine`}),m(w,{children:`Applies to every workspace. Changes apply to the next browser Po opens.`})]}),a?y(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m(`p`,{role:`alert`,className:`text-sm text-po-red`,children:a}),m(t,{size:`sm`,variant:`ghost`,disabled:i,onClick:s,children:`Try again`})]}):null,m(be,{"aria-busy":r||i||void 0,children:L.fields.map(t=>{let a=t.id,s=n[a];return y(T,{"data-testid":`browser-setting-${a}`,changed:s!==void 0,className:`items-start`,children:[y(ve,{className:`gap-1`,children:[m(D,{className:`flex min-h-6 items-center`,children:t.label}),t.detail?m(xe,{children:t.detail}):null]}),y(ce,{value:s??R,disabled:r||i,onValueChange:e=>o?.(a,e===R?null:e),children:[m(Te,{"aria-label":t.label,className:`w-full text-sm sm:w-64`,children:m(ye,{placeholder:t.placeholder})}),y(de,{children:[m(e,{value:R,children:t.placeholder}),(t.options??[]).map(t=>m(e,{value:t.value,children:t.label},t.value))]})]})]},a)})}),i||r&&!a?m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:i?`Saving on your computer…`:`Loading browser settings…`}):null]}),y(E,{children:[y(P,{children:[m(I,{children:`Profiles`}),m(w,{children:`Each profile keeps its own sign-ins, cookies and fingerprint.`})]}),c]})]})}function Fe(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 Ie(e,t){return new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`,timeZone:t}).format(new Date(e))}function Le({status:e,loading:n,error:r,onRetry:a,timeZone:o}){let s=e?Math.min(e.usedSeconds,e.limitSeconds):0,c=e!==void 0&&e.usedSeconds>=e.limitSeconds,l=e?Ie(e.resetsAt,o):``,u=e?Math.round(e.idleSeconds/60):0;return y(`div`,{"data-testid":`remote-browser-settings`,className:`flex min-w-0 flex-col gap-10`,children:[y(E,{children:[y(P,{children:[m(I,{children:`Today`}),m(w,{children:`Po Cloud runs the browser for you. Every session on this account shares one daily allowance.`})]}),r?y(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m(`p`,{role:`alert`,className:`text-sm text-po-red`,children:r}),m(t,{size:`sm`,variant:`ghost`,onClick:a,children:`Try again`})]}):null,e&&!e.enabled?m(Ee,{children:`The browser is turned off on this host, so Po does web tasks without one.`}):null,y(be,{"aria-busy":n||void 0,children:[y(T,{"data-testid":`remote-browser-time`,className:`items-start`,children:[y(ve,{className:`gap-2`,children:[m(D,{children:`Browser time`}),m(xe,{children:e?`Resets at ${l} (${e.resetsAt.slice(11,16)} UTC).`:`Resets every day.`}),m(i,{"aria-label":`Browser time used today`,value:e&&e.limitSeconds>0?s/e.limitSeconds*100:0})]}),m(`span`,{className:`shrink-0 text-base font-semibold tabular-nums text-po-hi`,children:e?`${Fe(s)} of ${Fe(e.limitSeconds)}`:`…`})]}),y(T,{"data-testid":`remote-browser-open`,className:`items-start`,children:[y(ve,{className:`gap-1`,children:[m(D,{children:`Open now`}),m(xe,{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.`})]}),m(`span`,{className:`shrink-0 text-base font-semibold tabular-nums text-po-hi`,children:e?`${e.open} of ${e.openLimit}`:`…`})]})]}),c?y(`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,n&&!r?m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading browser use…`}):null]}),y(E,{children:[y(P,{children:[m(I,{children:`Sign-ins`}),m(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.`})]}),m(Ee,{children:`Saved browser profiles are not available on Po Cloud yet.`})]})]})}var Re=`/api/settings`,ze=`/api/settings/value`,Be=`The request did not reach Po on your computer.`;function z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Ve(e){let t=await e.json().catch(()=>void 0);if(!e.ok)return{ok:!1,error:z(t)&&typeof t.error==`string`?t.error:`Po answered ${e.status}.`};if(!z(t)||!z(t.values)||!z(t.hashes)||typeof t.hashes.host!=`string`)return{ok:!1,error:`Po answered with no configuration.`};let n={};for(let e of L.fields){let r=t.values[e.keyPath.join(`.`)];z(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 B(e){let t=new URLSearchParams({repoRoot:``});for(let e of L.fields)t.append(`key`,e.keyPath.join(`.`));try{return await Ve(await e(`${Re}?${t.toString()}`))}catch{return{ok:!1,error:Be}}}async function He(e,t,n,r){let i=L.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(ze,{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 B(e):await Ve(t)}catch{return{ok:!1,error:Be}}}function Ue({request:e,requestWithStepUp:t}){let[n,r]=k(),[i,o]=k(!0),[s,c]=k(!1),[l,u]=k(),d=_(!1),f=_(!1),m=a(async()=>{o(!0);let t=await B(e);d.current&&(t.ok?(r(t.config),u(void 0)):(r(void 0),u(t.error)),o(!1))},[e]);p(()=>(d.current=!0,m(),()=>{d.current=!1}),[m]);let h=async(a,o)=>{if(f.current||i||!n)return;f.current=!0,c(!0),u(void 0);let s=await He(t,a,o,n.hash);if(d.current){if(s.ok)r(s.config);else{if(s.conflict){let t=await B(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 m(),onChange:(e,t)=>void h(e,t)}}function We(e){return m(Pe,{...Ue(e),profiles:m(Ne,{...e})})}function Ge(e){let{request:t}=e,[n,r]=k({kind:`checking`}),i=a(async()=>{try{let e=await t(ke);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 p(()=>{i()},[i]),n.kind===`local`?m(We,{...e}):n.kind===`checking`?m(`p`,{role:`status`,className:`text-sm text-po-dim`,children:`Loading browser settings…`}):m(Le,{status:n.status,error:n.error,onRetry:()=>void i()})}var Ke=De({label:`Browser`,detail:`The browser Po uses for web tasks, and how long your sign-ins last.`,order:L.order,icon:C,component:Ge}),qe=r({...L,icon:C}),Je={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 Ye(e){return e.sessionId===null?void 0:e.slotData?.(Je)?.[0]?.data}var Xe=`browse_activity`,Ze=`browse`;function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Qe=new Set([`active`,`idle`,`asleep`,`crashed`]);function $e(e){return V(e)&&typeof e.id==`string`&&typeof e.title==`string`&&typeof e.url==`string`&&typeof e.current==`boolean`&&typeof e.lastAccessedAt==`number`}function et(e){return!V(e)||typeof e.id!=`string`||typeof e.name!=`string`||!Qe.has(e.state)||e.window!==`headed`&&e.window!==`headless`||typeof e.lastUsedAt!=`number`||!Array.isArray(e.tabs)?null:{...e,tabs:e.tabs.filter($e)}}function tt(e){return!V(e)||!Array.isArray(e.identities)?null:{identities:e.identities.map(et).filter(e=>e!==null)}}function nt(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function rt(e){return V(e)?e.state===`ok`&&typeof e.src==`string`&&e.src.startsWith(`data:image/`)?{state:`ok`,src:e.src,...nt(e.seq)?{seq:e.seq}:{}}:e.state===`unchanged`&&nt(e.seq)?{state:`unchanged`,seq:e.seq}:e.state===`closed`||e.state===`timeout`?{state:e.state}:{state:`error`}:{state:`error`}}function it(e){return V(e)&&e.ok===!0&&typeof e.path==`string`&&e.path!==``?{ok:!0,path:e.path}:V(e)&&e.ok===!1&&typeof e.message==`string`?{ok:!1,message:e.message}:{ok:!1,message:`Po could not take the snapshot.`}}function at(e,t,n){if(!(V(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 ot({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 st(e){return`${e} ${e===1?`tab`:`tabs`}`}function ct(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 H({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=ne({identities:[],hidden:[],pending:0});function W(e){return te(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:Xe,parse:tt,reduce:(e,{identities:t})=>({...e,identities:t,...e.pending===0?{hidden:[]}:{}})}),G=b(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:Ze,method:t,input:n}):Promise.reject(Error(`The browser view is not connected.`))}async function ht(e,t,n){try{return rt(await K(e,`frame`,n===void 0?{tabId:t}:{tabId:t,since:n}))}catch{return{state:`error`}}}async function gt(e,t){try{return it(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 at(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:H(e)};let r=Math.max(0,t-n),i=r<Z?X:r<Q?Z:Q;return{text:H({...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 y(`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:[y(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[m(`span`,{className:`shrink-0 truncate text-base font-semibold text-po-hi`,children:e.name}),m(`span`,{className:`text-xs text-po-faint`,children:`›`}),m(`span`,{className:`min-w-0 truncate text-base text-po-text`,children:t.title}),m(x,{tone:c?`running`:`neutral`,"data-testid":`browser-live-state`,children:l}),m(`span`,{className:`ml-auto shrink-0 text-sm text-po-dim`,children:`View only`}),o===void 0?null:m(wt,{state:o,disabled:i||!f,onSnapshot:s})]}),y(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-po-border`,children:[y(`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?m(_e,{"aria-label":`Secure connection`,className:`size-3 shrink-0 text-po-dim`}):m(F,{"aria-label":`Not secure`,className:`size-3 shrink-0 text-po-dim`}),m(`span`,{"data-testid":`browser-live-url`,className:`min-w-0 flex-1 truncate font-mono text-sm text-po-text`,children:t.url})]}),m(`div`,{className:`relative min-h-0 flex-1 bg-po-bg ${i?`opacity-50 grayscale`:``}`,children:n?m(`img`,{src:n,alt:`Live view of ${t.title}`,className:`absolute inset-0 size-full object-contain object-top`}):r||m(`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`})})]}),m(`span`,{"data-testid":`browser-live-footer`,className:`truncate text-sm text-po-dim`,children:u})]})}function wt({state:e,disabled:n,onSnapshot:r}){return y(`span`,{className:`flex shrink-0 items-center gap-2`,children:[typeof e==`object`?m(`span`,{role:`alert`,className:`max-w-48 truncate text-sm text-po-red`,title:e.error,children:e.error}):null,m(t,{size:`xs`,variant:`outline`,"data-testid":`browser-live-snapshot`,disabled:n,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=>m(kt,{...e,opened:n}),retainComposer:!0,composerContext:e=>Et(e,n)}}function Ot(){let[e,t]=k(()=>typeof document>`u`||!document.hidden);return p(()=>{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]=k(),[c,l]=k(!1),[u,d]=k(),f=i.gone||a||c,h=Ot(),g=n.tab.id;p(()=>{if(t!==null&&!f&&h)return xt(e=>ht(t,g,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,g,f,h]);let v=_(!0);p(()=>(v.current=!0,()=>{v.current=!1}),[]);let[y,b]=k(`idle`),x=Ye(e),S=async()=>{if(x===void 0||t===null||y===`taking`)return;b(`taking`);let e=await St(gt,{sessionId:t,tabId:g,identity:n.identity.id,url:i.tab.url},x,r);v.current&&b(e)},ee=lt(u,i.tab.current);return m(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:y,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?m(ge,{"data-testid":`browsers-panel`,title:`No browser yet`,description:`Po opens one when a task needs the web.`,className:`py-12`}):y(`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:[m(`p`,{className:`text-sm text-po-dim`,children:ct(t)}),n?m(`p`,{role:`alert`,className:`text-sm text-po-red`,children:n}):null,t.map(t=>m(Mt,{...e,identity:t},t.id))]})}function Mt(e){let{identity:n,busy:r,canShowWindow:i=!0,openMenu:a}=e,{state:o,tabs:s}=n,c=r?.[n.id],u=o===`active`||o===`idle`,f=o!==`crashed`&&c===void 0,p=n.profile!==!1;return y(`section`,{"aria-label":n.name,"data-testid":`browsers-identity-${n.id}`,"data-state":o,className:`flex flex-col gap-3`,children:[y(`header`,{className:`flex min-w-0 items-center gap-2`,children:[m(pe,{tone:At[o],pulse:o===`active`||c!==void 0}),m(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-po-hi`,children:n.name}),y(`span`,{className:`min-w-0 flex-1 truncate text-sm ${o===`crashed`?`text-po-red`:`text-po-dim`}`,children:[c??H(n),u?` · ${n.window===`headed`?`Window shown`:`No window`}`:``]}),f?y(N,{modal:!1,defaultOpen:a===`identity:${n.id}`,children:[m(M,{asChild:!0,children:m(t,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${n.name}`,children:m(j,{className:`size-3.5`})})}),y(A,{align:`end`,children:[p?o===`asleep`?y(O,{onSelect:()=>e.onWake?.(n.id),children:[m(d,{className:`size-3.5`}),`Wake up`]}):y(l,{children:[i?y(O,{onSelect:()=>e.onToggleWindow?.(n.id,n.window===`headed`?`headless`:`headed`),children:[m(C,{className:`size-3.5`}),n.window===`headed`?`Hide window`:`Show window`]}):null,y(O,{onSelect:()=>e.onSleep?.(n.id),children:[m(ee,{className:`size-3.5`}),`Put to sleep`]})]}):null,p?m(fe,{}):null,y(O,{onSelect:()=>e.onCloseBrowser?.(n.id),children:[m(S,{className:`size-3.5`}),`Close browser`]})]})]}):null]}),s.length>0?m(`ul`,{"aria-label":`Tabs in ${n.name}`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @4xl:grid-cols-3`,children:s.map(t=>m(Nt,{...e,tab:t},t.id))}):null]})}function Nt(e){let{identity:r,tab:i,renderFrame:a,openMenu:o}=e,s=r.state===`asleep`,u=r.state===`active`&&i.current,d=()=>e.onWatch?.(r.id,i.id),p=e=>{e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d())},h=a?.(r,i);return m(c,{asChild:!0,className:`flex min-w-0 flex-col focus-within:border-po-green`,children:y(`li`,{"data-testid":`browsers-tab-${i.id}`,"data-current":i.current,children:[s?null:y(`div`,{role:`button`,tabIndex:0,title:`Watch this tab live`,onClick:d,onKeyDown:p,className:`relative aspect-video cursor-pointer overflow-hidden bg-po-deep outline-none`,children:[h??y(`span`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-1 text-sm text-po-dim`,children:[m(F,{"aria-hidden":!0,className:`size-5 text-po-faint`}),`Waiting for the first frame`]}),u?m(`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]}),y(`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:[y(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[m(`span`,{className:`truncate text-base ${i.current?`font-semibold text-po-hi`:`text-po-text`}`,children:i.title}),m(`span`,{className:`truncate text-sm text-po-dim`,children:Y(i.url)})]}),y(N,{modal:!1,defaultOpen:o===`tab:${i.id}`,children:[m(M,{asChild:!0,children:m(t,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${i.title}`,children:m(j,{className:`size-3.5`})})}),y(A,{align:`end`,children:[s?null:y(l,{children:[y(O,{onSelect:d,children:[m(n,{className:`size-3.5`}),`Watch live`]}),e.onSnapshot?y(O,{onSelect:()=>e.onSnapshot?.(r.id,i.id),children:[m(me,{className:`size-3.5`}),`Snapshot to Author`]}):null]}),y(O,{onSelect:()=>e.onCopyUrl?.(i.url),children:[m(f,{className:`size-3.5`}),`Copy URL`]}),s?null:y(l,{children:[m(fe,{}),y(O,{onSelect:()=>e.onCloseTab?.(r.id,i.id),children:[m(S,{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]=k();return p(()=>xt(n=>ht(e,t,n),e=>{e.state===`ok`&&r(e.src)}),[e,t]),n===void 0?void 0:m(`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]=k(),o=Ye(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 m(jt,{identities:ot(r).map(e=>yt(e)),renderFrame:(e,n)=>t===null||e.state===`asleep`?void 0:m(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=ie({keys:`g b`,icon:F,activeSource:ft,marksBackgroundWork:!1,order:45,transientTab:Pt}),Rt=o(pt),zt={active:`green`,idle:`neutral`,asleep:`muted`,crashed:`red`};function Bt({identities:e,onOpenTab:n,onCloseTab:r,onCloseBrowser:i,onCloseAsleep:a,error:o}){if(e.length===0)return m(`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=ct(e);return y(`div`,{"data-testid":`activity-browser-identities`,className:`flex flex-col gap-1`,children:[m(`p`,{"data-testid":`activity-summary-browser`,className:`px-1 pb-1 text-sm text-po-dim`,children:c}),o?m(`p`,{role:`alert`,className:`px-1 pb-1 text-sm text-po-red`,children:o}):null,m(`ul`,{className:`flex flex-col`,children:e.map(e=>m(Vt,{identity:e,onOpenTab:n,onCloseTab:r,onCloseBrowser:i},e.id))}),s.length>1&&a?y(t,{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:e,onOpenTab:n,onCloseTab:r,onCloseBrowser:i}){let{state:a,tabs:o}=e,[c,l]=k(a===`active`),u=a===`asleep`;return m(`li`,{"data-testid":`activity-browser-${e.id}`,"data-state":a,className:`group/row`,children:y(v,{open:c,onOpenChange:l,children:[y(`div`,{className:`flex items-start gap-1 rounded-md hover:bg-po-deep/60`,children:[y(t,{variant:`ghost`,size:`card`,"aria-expanded":o.length>0?c:void 0,title:e.name,onClick:()=>l(!c),className:`min-w-0 flex-1 gap-0.5 px-1.5 py-1.5 hover:bg-transparent`,children:[y(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[m(pe,{tone:zt[a],pulse:a===`active`}),m(`span`,{className:`min-w-0 flex-1 truncate text-base font-semibold text-po-hi`,children:e.name}),o.length>0&&!c?m(`span`,{className:`shrink-0 text-sm text-po-dim`,children:st(o.length)}):null,o.length>0?c?m(ae,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-po-dim`}):m(s,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-po-faint`}):null]}),m(`span`,{className:`pl-3.5 text-sm ${a===`crashed`?`text-po-red`:`truncate text-po-dim`}`,children:m(Ut,{identity:e})})]}),a!==`crashed`&&i?y(N,{modal:!1,children:[m(M,{asChild:!0,children:m(t,{variant:`ghost`,size:`icon`,"aria-label":`Manage ${e.name}`,className:`mt-1.5 mr-1 opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100`,children:m(j,{className:`size-3.5`})})}),m(A,{align:`end`,children:y(O,{onSelect:()=>i(e.id),children:[m(S,{className:`size-3.5`}),`Close browser`]})})]}):null]}),m(re,{children:m(`ul`,{"aria-label":`Tabs in ${e.name}`,className:`flex flex-col gap-0.5 pt-0.5 pb-1.5 pl-4`,children:o.map(i=>u?m(`li`,{className:`flex items-center gap-2 px-1.5 py-1.5`,children:m(Ht,{tab:i,here:!1})},i.id):y(`li`,{className:`group/tab flex items-center gap-1 rounded-md hover:bg-po-deep`,children:[m(t,{variant:`ghost`,size:`card`,"data-testid":`activity-browser-tab-${i.id}`,"data-current":i.current,"aria-current":i.current?`true`:void 0,title:`Watch this tab live`,onClick:()=>n?.(e.id,i.id),className:`min-w-0 flex-1 flex-row items-center gap-2 px-1.5 py-1.5 hover:bg-transparent`,children:m(Ht,{tab:i,here:i.current&&a===`active`})}),r?m(t,{variant:`ghost`,size:`icon`,"aria-label":`Close ${i.title}`,onClick:()=>r(e.id,i.id),className:`mr-1 opacity-0 group-hover/tab:opacity-100 focus-visible:opacity-100`,children:m(S,{className:`size-3.5`})}):null]},i.id))})})]})})}function Ht({tab:e,here:t}){return y(l,{children:[m(`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)}),y(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[m(`span`,{className:`truncate text-base ${e.current?`font-semibold text-po-hi`:`text-po-text`}`,children:e.title}),m(`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=_(null);return p(()=>{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]),m(`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 m(Bt,{identities:ot(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=he({component:Gt}),qt=h(mt),$=(e,t)=>t===void 0?void 0:{...e,...t},Jt=Se({id:`browse`,packageName:`@agimon-ai/po-browse`,host:{get settingsPanels(){return[$({id:`browser`},Ke)]}},workspace:{get settingsSections(){return[$({id:`browser-control`},qe)]}},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,4 +1,4 @@
|
|
|
1
|
-
import{Ft as e,It as t,Lr as n,Lt as r,Mi as i,Ni as a,Wa as o,Xr as s,_n as c,gn as l,hn as u,mn as d,qa as f}from"../chunks/po-web-runtime-
|
|
1
|
+
import{Ft as e,It as t,Lr as n,Lt as r,Mi as i,Ni as a,Wa as o,Xr as s,_n as c,gn as l,hn as u,mn as d,qa as f}from"../chunks/po-web-runtime-C0B3uAoC.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
2
|
`,`
|
|
3
3
|
`).split(`
|
|
4
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(`
|
package/dist/assets/plugins/slots/{calendar.d8b70190-DmudDrcG.js → calendar.76ad65fa-CihobxD6.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$n as e,$r as t,At as n,Br as r,Di as i,En as a,Ft as o,Gi as s,Gt as c,Hi as l,Hr as u,Ht as d,It as f,Ji as p,Jn as m,Jr as h,Jt as g,Ki as _,Kt as v,Lt as y,Nr as b,Pi as x,Sa as S,Ur as C,Vr as w,Wa as T,Wi as E,Xa as D,Xi as O,Xn as k,Ya as A,Yi as ee,Zi as j,Zn as M,_n as N,an as P,cr as F,di as I,eo as L,gn as R,hn as z,in as B,ja as V,jt as te,ka as ne,la as H,mn as re,nr as U,qa as ie,qt as W,rr as G,tn as K,to as ae,tr as q,vn as oe,wa as se}from"../chunks/po-web-runtime-CQ9hLtG-.js";var ce={list:{method:`GET`,path:`/events`,query:[`from`,`to`,`cursor`,`tz`,`status`,`workspace`,`kind`,`q`,`limit`],response:void 0},create:{method:`POST`,path:`/events`,response:void 0},update:{method:`PATCH`,path:`/events/:id`,response:void 0},cancel:{method:`DELETE`,path:`/events/:id`,response:void 0},pause:{method:`POST`,path:`/events/:id/pause`,response:void 0},resume:{method:`POST`,path:`/events/:id/resume`,response:void 0},runNow:{method:`POST`,path:`/events/:id/run-now`,response:void 0},ask:{method:`POST`,path:`/events/:id/ask`,response:void 0},history:{method:`GET`,path:`/events/:id/history`,query:[`cursor`],response:void 0},targets:{method:`GET`,path:`/targets`,response:void 0}},J=[`host`,`workspace`,`session`],Y=se(ce,{scopes:J,basePath:`calendar`,transport:(e,t)=>n.fetch(e,t),sessionAddress:L});function le(){let e=A(`calendar`);return g(t=>ae(e,t),()=>D(e))}var X={query:``,workspace:`all`,status:`open`,kind:`all`};function ue({query:e,workspace:t,status:n,kind:r}){return{...e.trim()?{q:e.trim()}:{},...t===`all`?{}:{workspace:t},...n===`all`?{}:{status:n},...r===`all`?{}:{kind:r}}}function de(e,t){return e===void 0?void 0:t?.workspaces.find(t=>t.id===e)?.name??e}function fe(e,t){return e.owner.level===`global`?`Global`:`${e.owner.level===`workspace`?`Workspace`:`Session`} · ${de(e.owner.workspaceId,t)}`}function pe(e){return(e?.workspaces??[]).map(({id:e,name:t})=>({id:e,name:t})).sort((e,t)=>e.name.localeCompare(t.name))}function me(e,t){let n=new Date(t);n.setHours(0,0,0,0);let r=[];for(let t of e){let e=new Date(t.projectedDueAt??t.nextDueAt??t.updatedAt);e.setHours(0,0,0,0);let i=Math.round((e.getTime()-n.getTime())/864e5),a=i===0?`Today`:i===1?`Tomorrow`:e.toLocaleDateString(void 0,{weekday:`long`,day:`numeric`,month:`long`}),o=r.at(-1);o?.label===a?o.events.push(t):r.push({label:a,events:[t]})}return r}function he(e,t,n){let r=t.map(()=>[]);for(let i of e)for(let e of i.occurrences??(i.projectedDueAt===void 0?[]:[i.projectedDueAt])){let a=t.filter(t=>t<=e).length-1;a>=0&&e<n&&r[a].push({...i,projectedDueAt:e})}for(let e of r)e.sort((e,t)=>e.projectedDueAt-t.projectedDueAt);return r}function ge(e,t,n){let r=new Date(`${e}T${t}:00Z`).getTime();if(!Number.isFinite(r))throw Error(`Choose a valid date and time.`);let i=new Intl.DateTimeFormat(`sv-SE`,{timeZone:n,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),a=r;for(let e=0;e<4;e++){let e=r-new Date(i.format(new Date(a)).replace(` `,`T`)+`Z`).getTime();if(e===0)return a;a+=e}throw Error(`This time does not exist in that timezone. Choose another time.`)}function _e(e,t){let n=new Date(e);n.setDate(n.getDate()+t);let r=new Date(n);return r.setDate(r.getDate()+1),{from:n.getTime(),to:r.getTime()}}function ve(e){return{from:e,to:e+5184e6}}function ye(e,t){let n=new Date(t).getMonth(),r=new Date(t);r.setHours(0,0,0,0),e===`month`&&r.setDate(1),r.setDate(r.getDate()-(r.getDay()+6)%7);let i=[];do i.push(r.getTime()),r.setDate(r.getDate()+1);while(e===`month`?r.getMonth()===n||r.getDay()!==1:i.length<7);return{days:i,from:i[0],to:r.getTime()}}function be(e,t,n,r){if(n===0)return r;let i=new Date(t);return e===`month`?i.setMonth(i.getMonth()+n,1):i.setDate(i.getDate()+n*7),i.getTime()}function xe(e,t){let n=t.indexOf(`/`);return n<0||e.startsWith(t.slice(0,n+1))?e:t.slice(0,n+1)+e}function Se(e,t,n){return t.level===`global`?e.host:t.level===`workspace`?e.workspace(xe(t.workspaceId,n)):e.session(xe(t.sessionId,n))}function Ce(e,t,n){if(!e.title.trim()||!n?.workflow&&!n?.action&&!e.prompt.trim())throw Error(`Add a title and prompt.`);let r;if(e.kind===`Interval`){let t=Number(e.seconds);if(!Number.isInteger(t)||t<30||t>3600)throw Error(`Choose an interval from 30 to 3,600 seconds.`);r={kind:`interval`,seconds:t}}else if(e.kind===`Cron`){if(!e.expr.trim())throw Error(`Add a cron expression.`);r={kind:`cron`,expr:e.expr,tz:e.tz}}else{let t=ge(e.date,e.time,e.tz);if(!Number.isFinite(t)||t<=Date.now())throw Error(`Choose a time in the future.`);r={kind:`once`,at:t,tz:e.tz}}let i;if(e.targetKind===`New session`){let n=t.workspaces.find(t=>t.id===e.targetId&&t.active);if(!n)throw Error(`Choose an active workspace.`);i={kind:`newSession`,workspaceId:n.id,cwd:n.path}}else{let n=t.sessions.find(t=>t.sessionId===e.targetId);if(!n)throw Error(`Choose an available session.`);i={kind:`existingSession`,sessionId:n.sessionId}}return n?.target.kind===i.kind&&(n.target.kind===`newSession`?n.target.workspaceId:n.target.sessionId)===e.targetId&&(i=n.target),{title:e.title.trim(),schedule:r,target:i,...n?.workflow?{workflow:n.workflow}:n?.action?{action:n.action}:{prompt:e.prompt.trim()},...n?.assignment?{assignment:n.assignment}:{}}}function we(e,t=Intl.DateTimeFormat().resolvedOptions().timeZone){let n=new Intl.DateTimeFormat(`sv-SE`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(new Date(e)),r=e=>n.find(t=>t.type===e)?.value??``;return{date:`${r(`year`)}-${r(`month`)}-${r(`day`)}`,time:`${r(`hour`)}:${r(`minute`)}`}}function Te(e){let t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(t.getDay()+6)%7),t.getTime()}function Ee(e){return{id:e.id,title:e.title,prompt:e.prompt??(e.workflow?`Runs workflow ${e.workflow.key}`:`Runs ${e.action?.launcherId??`an action`}`),time:new Date(e.projectedDueAt??e.nextDueAt??e.updatedAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}),schedule:e.schedule.kind===`interval`?`Every ${e.schedule.seconds} seconds`:e.schedule.kind===`cron`?e.schedule.expr:`Once`,target:e.target.kind===`existingSession`?e.target.sessionId:`New session`,owner:`${e.owner.level===`global`?`Global`:e.owner.level===`workspace`?`Workspace`:`Session`}${e.id.startsWith(`${e.homeHostId}/`)?` · ${e.homeHostId}`:``}`,source:e.source?.packageName,execution:e.workflow?`Workflow: ${e.workflow.key}`:e.action?`Action: ${e.action.launcherId}`:void 0,assignment:e.assignment?JSON.stringify(e.assignment):void 0,profile:e.assignment?.profile,status:e.status===`active`?`Scheduled`:e.status}}function De(e,t,n=`panel`,r,i,a=0,o,s=`Session`,l=Date.now,u=!1,f){let{from:p,to:m,tz:h}=r??{},g=JSON.stringify(i??{}),[_,y]=W(n===`page`?`Everything`:s),[b,x]=W(()=>Te(l())),[S,C]=W(()=>(new Date(l()).getDay()+6)%7),[w,T]=W([]),[E,D]=W(),[O,k]=W({total:0,matched:0,more:!1}),A=v({key:``,count:1}),ee=v(void 0),[j,M]=W(`loading`),[N,P]=W(),[F,I]=W(0),[L,R]=W(!1),z=v(!1),[B,V]=W(),[te,ne]=W(),[H,re]=W(),[U,ie]=W(),G=f===void 0?n===`page`||_===`Everything`?{level:`global`}:_===`Workspace`&&U&&U.level!==`global`?{level:`workspace`,workspaceId:U.workspaceId}:U:{level:`workspace`,workspaceId:f};d(()=>{let r=!0;return(async()=>{let i=n===`page`||f!==void 0?void 0:await e.session(t).targets();if(i&&!i.ok)throw Error(i.error||`Calendar could not load.`);if(!r)return;i&&ie(i.data.owner);let a=f===void 0?!i||_===`Everything`?{level:`global`}:_===`Workspace`&&i.data.owner.level!==`global`?{level:`workspace`,workspaceId:i.data.owner.workspaceId}:i.data.owner:{level:`workspace`,workspaceId:f},o=p!==void 0&&m!==void 0?{from:p,to:m,...h?{tz:h}:{}}:n!==`page`||u?_e(b,S):ve(l()),s=Se(e,a,t),c=await s.targets();if(!c.ok)throw Error(c.error||`Targets could not load.`);let d={...o,...JSON.parse(g)},v=async e=>{let t=await s.list({query:{...d,...e?{cursor:e}:{}}});if(!t.ok)throw Error(t.error||`Calendar could not load.`);return t.data},y=e=>{k({total:e.total,matched:e.matched,more:e.cursor!==void 0});let t=e.cursor;ee.current=t?async()=>{let e=await v(t);r&&(A.current.count+=1,T(t=>[...t,...e.events]),y(e))}:void 0},x=JSON.stringify([a,d]);A.current.key!==x&&(A.current={key:x,count:1});let C=await v(),w=[...C.events];for(let e=1;(n===`panel`||e<A.current.count)&&C.cursor&&r;e++){let e=C.cursor;if(C=await v(e),C.cursor===e)throw Error(`Calendar returned an invalid page.`);w.push(...C.events)}r&&(T(w),D(c.data),y(C),M(`populated`))})().catch(e=>{r&&(P(e instanceof Error?e.message:String(e)),M(`error`))}),()=>{r=!1}},[e,t,n,_,b,S,F,a,p,m,h,g,u,l,f]);async function K(e){if(!z.current){z.current=!0,R(!0),P(void 0);try{await e()}catch(e){P(e instanceof Error?e.message:String(e))}finally{z.current=!1,R(!1)}}}function ae(e){if(e?.source)return;re(void 0),P(void 0),V(e??`new`);let t=e?.schedule;ne({title:e?.title??``,prompt:e?.prompt??``,kind:t?.kind===`interval`?`Interval`:t?.kind===`cron`?`Cron`:`Once`,...we(t?.kind===`once`?t.at:Date.now()+36e5,t?.kind===`once`?t.tz:void 0),seconds:t?.kind===`interval`?String(t.seconds):`300`,expr:t?.kind===`cron`?t.expr:`0 9 * * 1-5`,tz:t&&t.kind!==`interval`?t.tz:Intl.DateTimeFormat().resolvedOptions().timeZone,targetKind:e?.target.kind===`existingSession`?`Existing session`:`New session`,targetId:e?.target.kind===`existingSession`?e.target.sessionId:e?.target.workspaceId??``})}function q(){M(`loading`),P(void 0),V(void 0),re(void 0),T([]),D(void 0)}let oe={busy:L||j===`loading`,scope:e=>{e!==_&&(q(),y(e))},day:e=>{e!==S&&q(),C(e)},week:e=>{q(),x(t=>{let n=new Date(t);return n.setDate(n.getDate()+e*7),n.getTime()})},today:()=>{q(),x(Te(l())),C((new Date(l()).getDay()+6)%7),I(e=>e+1)},create:()=>ae(),retry:()=>{q(),I(e=>e+1)},event(n,r){let i=w.find(e=>e.id===r);i&&(n===`edit`?ae(i):K(async()=>{let a=Se(e,G&&G.level!==`session`?G:i.owner,t);if(n===`history`){let n=await Se(e,G??i.owner,t).history({params:{id:r}});if(!n.ok)throw Error(n.error);re({event:i,items:n.data.occurrences,cursor:n.data.cursor});return}let o=await a[n===`pause`&&i.status===`paused`?`resume`:n]({params:{id:r}});if(!o.ok)throw Error(o.error||`Event could not be changed.`);q(),I(e=>e+1)}))}},se=c(()=>[...w].sort((e,t)=>(e.projectedDueAt??e.nextDueAt??e.updatedAt)-(t.projectedDueAt??t.nextDueAt??t.updatedAt)),[w]),ce={timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,workspace:U&&U.level!==`global`?U.workspaceId:`Workspace`,session:t,days:Array.from({length:7},(e,t)=>{let n=new Date(b);return n.setDate(n.getDate()+t),n.toLocaleDateString(void 0,{weekday:`short`,day:`numeric`})}),selectedDay:S,range:new Date(b).toLocaleDateString(void 0,{month:`long`,year:`numeric`}),events:se.map(Ee)},J=B&&B!==`new`?B.owner:G,Y=E&&J?{...E,workspaces:E.workspaces.filter(e=>J.level===`global`||e.id===J.workspaceId),sessions:E.sessions.filter(e=>J.level===`global`||(J.level===`session`?e.sessionId===J.sessionId:e.workspaceId===J.workspaceId))}:void 0,le=B&&te&&Y?{fields:te,execution:B===`new`?void 0:B.workflow?`Workflow: ${B.workflow.key}`:B.action?`Action: ${B.action.launcherId}`:void 0,assignment:B!==`new`&&B.assignment?JSON.stringify(B.assignment):void 0,busy:L,error:N,owner:B===`new`?G?.level===`global`?`Global`:_:B.owner.level===`global`?`Global`:B.owner.level===`workspace`?`Workspace`:`Session`,choices:te.targetKind===`New session`?Y.workspaces.filter(e=>e.active).map(e=>({id:e.id,name:e.name})):Y.sessions.map(e=>({id:e.sessionId,name:e.name+(e.asleep?` (asleep)`:``)})),set:(e,t)=>ne(n=>n&&{...n,[e]:t,...e===`targetKind`?{targetId:``}:{}}),close:()=>V(void 0),save:()=>{K(async()=>{if(!G)return;let n=Ce(te,Y,B===`new`?void 0:B),r=Se(e,B===`new`||G.level!==`session`?G:B.owner,t),i=B===`new`?await r.create({body:{...n,...o?{destinationHostId:o}:{}}}):await r.update({params:{id:B.id},body:n});if(!i.ok)throw Error(i.error||`Event could not be saved.`);V(void 0),q(),I(e=>e+1)})}}:void 0;return{data:ce,owner:G,events:se,total:O.total,matched:O.matched,more:O.more?()=>void K(async()=>await ee.current?.()):void 0,targets:E,actions:oe,state:j,error:N,editor:le,editing:B,history:H,busy:L,closeHistory:()=>re(void 0),moreHistory:()=>{K(async()=>{if(!H?.cursor)return;let n=await Se(e,G??H.event.owner,t).history({params:{id:H.event.id},query:{cursor:H.cursor}});if(!n.ok)throw Error(n.error);re({...H,items:[...H.items,...n.data.occurrences],cursor:n.data.cursor})})}}}function Oe(e){return e.projectedDueAt??e.nextDueAt??e.updatedAt}function ke(e,t){let n=new Date(e),r=n.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return n.toDateString()===t?r:`${n.toLocaleDateString(void 0,{weekday:`short`})} ${r}`}var Ae=3;function je({dueToday:e,rows:n,state:r,onOpen:o,bodyOnly:s=!1}){if(s)return y(`div`,{className:`flex flex-col gap-2`,children:[e>0?f(F,{tone:`magenta`,className:`self-start`,children:`${e} today`}):null,r===`loading`?f(`p`,{className:`text-sm text-po-dim`,children:`Loading events…`}):null,r===`error`?f(`p`,{className:`text-sm text-po-dim`,children:`Could not load events`}):null,r===`populated`&&n.length===0?f(`p`,{className:`text-base text-po-dim`,children:`Nothing scheduled.`}):null,n.length>0?f(`ul`,{className:`space-y-2`,children:n.map(e=>y(`li`,{className:`flex gap-3 text-base`,children:[f(`span`,{className:`w-16 shrink-0 text-sm text-po-dim tabular-nums`,children:e.at}),y(`span`,{className:`flex min-w-0 flex-col`,children:[f(`span`,{className:`break-words text-po-text`,children:e.title}),e.owner?f(`span`,{className:`truncate text-sm text-po-dim`,children:e.owner}):null]})]},e.id))}):null,o?f(t,{variant:`ghost`,size:`sm`,onClick:o,className:`-ml-2.5 self-start`,children:`Open Calendar`}):null]});let c=r===`populated`&&n.length===0?f(H,{title:`Nothing scheduled`,description:`Scheduled prompts and workflows will appear here.`}):y(`ul`,{className:`divide-y divide-po-border-soft`,children:[r===`loading`?f(`li`,{className:`px-4 py-3 text-sm text-po-dim`,children:`Loading events…`}):null,r===`error`?f(`li`,{className:`px-4 py-3 text-sm text-po-dim`,children:`Could not load events`}):null,n.map(e=>y(`li`,{className:`flex flex-col gap-0.5 px-4 py-2.5`,children:[f(`span`,{className:`truncate text-base text-po-text`,children:`${e.at} · ${e.title}`}),e.owner?f(`span`,{className:`truncate text-sm text-po-dim`,children:e.owner}):null]},e.id))]});return y(a,{"data-testid":`calendar-home-card`,className:`overflow-hidden`,children:[y(`button`,{type:`button`,onClick:o,disabled:o===void 0,"aria-label":`Open Calendar`,className:`flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-po-selected/40 disabled:cursor-default`,children:[f(I,{"aria-hidden":`true`,className:`size-5 text-po-dim`}),f(`span`,{className:`flex-1 text-base font-semibold text-po-hi`,children:`Calendar`}),e>0?f(F,{tone:`magenta`,children:`${e} today`}):null,f(i,{"aria-hidden":`true`,className:`size-4 text-po-faint`})]}),f(`div`,{className:`border-t border-po-border-soft`,children:c})]})}function Me(e){return f(Ne,{...e},e.workspaceId??`home`)}function Ne({openPage:e,workspaceId:t,bodyOnly:n=!1}){let r=De(Y,``,`page`,void 0,{status:`active`},le(),void 0,void 0,void 0,void 0,t),[i]=W(()=>new Date().toDateString());return f(je,{bodyOnly:n,dueToday:r.events.filter(e=>new Date(Oe(e)).toDateString()===i).length,rows:r.events.slice(0,Ae).map(e=>({id:e.id,at:ke(Oe(e),i),title:e.title,owner:fe(e,r.targets)})),state:r.state,...e?{onOpen:()=>e(`calendar`)}:{}})}var Pe=V({slot:`dashboard-tiles`,id:`calendar`,order:20,data:{version:1,title:`Coming up`,icon:I,size:`wide`,column:`side`,surfaces:[`home`,`workspace`]},component:e=>f(Me,{...e,bodyOnly:!0})}),Fe=V({slot:`home-apps`,id:`calendar`,data:{column:`main`},component:Me});function Ie({fixture:e,editor:n,initialLevel:i=`Session`,initialSchedule:a=`Once`,initialTarget:o=`New session`,invalid:s=!1,edit:c=!1}){let[l,d]=W(n?.owner??i),[p,m]=W(a),[g,_]=W(o),v=n?.fields.kind??p,b=n?.fields.targetKind??g;return y(`form`,{onSubmit:e=>{e.preventDefault(),n?.save()},"aria-label":`Event design target`,className:`mx-auto flex w-full max-w-lg flex-col gap-4 bg-po-panel p-5 font-sans text-base text-po-text`,children:[y(`header`,{children:[f(`h1`,{className:`text-xl font-semibold text-po-hi`,children:c?`Edit event`:`New event`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Scheduled work, handled by Po.`})]}),y(`div`,{className:`flex flex-col gap-1.5`,children:[f(P,{htmlFor:`event-title`,children:`Title`}),f(K,{id:`event-title`,defaultValue:n?void 0:`Prepare release notes`,value:n?.fields.title,onChange:e=>n?.set(`title`,e.target.value),required:!0})]}),n?.execution?y(`p`,{className:`text-sm text-po-dim`,children:[n.execution,` (read-only)`]}):y(`div`,{className:`flex flex-col gap-1.5`,children:[f(P,{htmlFor:`event-prompt`,children:`What should Po do?`}),f(h,{id:`event-prompt`,rows:3,defaultValue:n?void 0:`Review changes since the last release and draft concise release notes. Ask before publishing.`,value:n?.fields.prompt,onChange:e=>n?.set(`prompt`,e.target.value),required:!0})]}),n?.assignment?y(`p`,{className:`text-sm text-po-dim`,children:[`Agent setup (read-only): `,n.assignment]}):null,y(`fieldset`,{children:[f(`legend`,{className:`mb-2 font-medium text-po-hi`,children:`Belongs to`}),f(r,{value:l,onValueChange:d,children:f(u,{"aria-label":`Event owner level`,children:(n?[n.owner]:[`Session`,`Workspace`,`Global`]).map(e=>f(C,{value:e,children:e},e))})}),f(`p`,{className:`mt-2 text-sm text-po-dim`,children:l===`Session`?e.session:l===`Workspace`?`${e.workspace} workspace`:`Available across workspaces on this host`})]}),y(`fieldset`,{className:`flex flex-col gap-3`,children:[f(`legend`,{className:`mb-2 font-medium text-po-hi`,children:`Schedule`}),f(r,{value:v,onValueChange:e=>{m(e),n?.set(`kind`,e)},children:f(u,{"aria-label":`Schedule type`,children:[`Once`,`Interval`,`Cron`].map(e=>f(C,{value:e,children:e},e))})}),v===`Once`?y(`div`,{className:`grid grid-cols-2 gap-3`,children:[y(`div`,{children:[f(P,{htmlFor:`event-date`,children:`Date`}),f(K,{className:`mt-1 w-full`,id:`event-date`,type:`date`,defaultValue:n?void 0:`2026-10-22`,value:n?.fields.date,onChange:e=>n?.set(`date`,e.target.value),required:!0})]}),y(`div`,{children:[f(P,{htmlFor:`event-time`,children:`Time`}),f(K,{className:`mt-1 w-full`,id:`event-time`,type:`time`,defaultValue:n?void 0:`14:30`,value:n?.fields.time,onChange:e=>n?.set(`time`,e.target.value),required:!0})]})]}):v===`Interval`?y(`div`,{children:[f(P,{htmlFor:`event-interval`,children:`Every (seconds)`}),f(K,{className:`mt-1 w-full`,id:`event-interval`,type:`number`,min:30,max:3600,defaultValue:n?void 0:300,value:n?.fields.seconds,onChange:e=>n?.set(`seconds`,e.target.value)}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`30 to 3,600 seconds. First run starts now.`})]}):y(`div`,{children:[f(P,{htmlFor:`event-cron`,children:`Cron expression`}),f(K,{className:`mt-1 font-mono`,id:`event-cron`,defaultValue:n?void 0:`0 9 * * 1-5`,value:n?.fields.expr,onChange:e=>n?.set(`expr`,e.target.value)}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Every weekday at 09:00.`})]}),y(`div`,{children:[f(P,{htmlFor:`event-timezone`,children:`Timezone`}),f(K,{className:`mt-1 w-full`,id:`event-timezone`,defaultValue:n?void 0:e.timezone,value:n?.fields.tz,onChange:e=>n?.set(`tz`,e.target.value)})]}),s||n?.error?f(`p`,{role:`alert`,className:`text-sm text-po-red`,children:n?.error??`Choose a time in the future. Your event has not been saved.`}):null]}),y(`fieldset`,{children:[f(`legend`,{className:`mb-2 font-medium text-po-hi`,children:`Run in`}),f(r,{value:b,onValueChange:e=>{_(e),n?.set(`targetKind`,e)},children:f(u,{"aria-label":`Event target`,children:[`New session`,`Existing session`].map(e=>f(C,{value:e,children:e},e))})}),y(`div`,{className:`mt-3`,children:[f(P,{htmlFor:`event-target`,children:b===`New session`?`Workspace`:`Session`}),n?y(`select`,{"aria-label":`Event target`,className:`w-full rounded border border-po-border bg-po-panel p-2`,value:n.fields.targetId,onChange:e=>n.set(`targetId`,e.target.value),children:[f(`option`,{value:``,children:`Choose a target`}),n.choices.map(e=>f(`option`,{value:e.id,children:e.name},e.id))]}):f(t,{className:`mt-1 w-full justify-start`,id:`event-target`,children:b===`New session`?e.workspace:e.session})]}),f(`p`,{className:`mt-2 text-sm text-po-dim`,children:b===`New session`?`A fresh session each run. Workflow sessions stay open.`:`Po wakes this session if it is asleep, then delivers your prompt.`})]}),f(`p`,{className:`text-sm text-po-dim`,children:`If Po is offline, the missed run is skipped. No catch-up burst.`}),y(`footer`,{className:`flex justify-end gap-2 border-t border-po-border pt-4`,children:[f(t,{variant:`ghost`,onClick:()=>n?.close(),children:`Cancel`}),f(t,{type:`submit`,variant:`primary`,disabled:n?.busy,children:c?`Save changes`:`Schedule event`})]})]})}function Le({model:e,sessionId:n,openSession:r}){return y(o,{children:[e.error?f(`p`,{role:`alert`,className:`text-po-red`,children:e.error}):null,e.editor?f(E,{open:!0,onOpenChange:t=>{!t&&!e.busy&&e.editor?.close()},children:y(_,{className:`max-h-[90vh] overflow-y-auto`,"aria-describedby":void 0,children:[f(j,{className:`sr-only`,children:e.editing===`new`?`New event`:`Edit event`}),f(Ie,{fixture:e.data,editor:e.editor,edit:e.editing!==`new`})]})}):null,e.history?f(E,{open:!0,onOpenChange:t=>{t||e.closeHistory()},children:y(_,{"aria-describedby":void 0,children:[f(O,{dismissible:!0,closeLabel:`Close history`,children:y(j,{className:`min-w-0 truncate text-base`,children:[`History: `,e.history.event.title]})}),y(s,{children:[e.history.items.length===0?f(`p`,{className:`text-po-dim`,children:`No runs yet.`}):null,e.history.items.map(i=>y(`div`,{className:`flex flex-col gap-1 border-b border-po-border-soft pb-3 last:border-b-0`,children:[y(`p`,{children:[new Date(i.dueAt).toLocaleString(),` · `,i.state]}),i.error?f(`p`,{className:`text-sm text-po-dim`,children:i.error}):null,i.summary?f(`p`,{className:`text-sm text-po-dim`,children:i.summary}):null,i.workflowRun?y(`p`,{className:`break-words text-sm text-po-dim`,children:[`Workflow launch: `,JSON.stringify(i.workflowRun)]}):null,i.skippedCount?y(`p`,{className:`text-sm text-po-dim`,children:[`Skipped: `,i.skippedCount]}):null,i.sessionId&&r?f(t,{size:`sm`,variant:`secondary`,className:`self-start`,onClick:()=>{e.closeHistory(),r(xe(i.sessionId,n))},children:`Open run session`}):null]},i.id))]}),e.history.cursor?f(ee,{children:f(t,{disabled:e.busy,onClick:e.moreHistory,children:`More history`})}):null]})}):null]})}function Re(e,t){let n=e=>e.projectedDueAt??e.nextDueAt??e.updatedAt;return[...e.map(e=>({...e,place:`cloud`})),...t.map(e=>({...e,place:`local`}))].sort((e,t)=>n(e)-n(t))}function ze(e,t,n){return{...e,busy:e.busy||t.busy,create:()=>t.create(),retry:()=>{e.retry(),t.retry()},event:(r,i)=>(n(i)?t:e).event(r,i)}}var Be=[[`open`,`Active or paused`],[`active`,`Active`],[`paused`,`Paused`],[`done`,`Done`],[`cancelled`,`Cancelled`],[`all`,`Any status`]],Ve=[[`all`,`Any schedule`],[`once`,`Once`],[`interval`,`Interval`],[`cron`,`Cron`]],He=[[`month`,`Month`],[`week`,`Week`],[`agenda`,`Agenda`]],Ue=3;function We({label:t,value:n,options:r,onChange:i}){return y(k,{value:n,onValueChange:i,children:[f(q,{"aria-label":t,className:`h-8 min-w-0 md:w-44`,children:f(U,{})}),f(M,{children:r.map(([t,n])=>f(e,{value:t,children:n},t))})]})}var Ge=e=>e.charAt(0).toUpperCase()+e.slice(1);function Ke({event:e,open:n,onOpen:r}){return y(`li`,{className:`flex items-start gap-3`,children:[f(`span`,{className:`w-12 shrink-0 pt-2.5 font-mono text-sm text-po-dim`,children:e.time}),f(`div`,{className:`min-w-0 flex-1`,children:y(t,{size:`card`,variant:`subtle`,"aria-pressed":n,onClick:r,children:[y(`span`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[y(`span`,{className:`flex min-w-0 items-center gap-2`,children:[e.profile?f(p,{name:e.profile,size:`sm`}):null,f(`span`,{className:`font-semibold text-po-hi`,children:e.title})]}),f(b,{tone:e.status===`done`?`ok`:`neutral`,className:`text-po-dim`,children:Ge(e.status)})]}),y(`span`,{className:`text-sm text-po-dim`,children:[e.schedule,` · `,e.target]}),f(`span`,{className:`text-sm text-po-dim`,children:e.owner})]})})]})}function qe({event:e,when:n,back:r,actions:i,runs:a,onAsk:o,onBack:s}){let[c,u]=W(``),[d,p]=W(!1),[m,g]=W(``),[_,v]=W(`Copy event id`),x=()=>{(navigator.clipboard?.writeText(e.id)??Promise.reject(Error(`No clipboard`))).then(()=>v(`Event id copied`),()=>v(`Copy failed, select the id instead`))},S=e.status===`cancelled`||e.status===`done`,C=i?.busy||d,w=t=>{t.preventDefault(),o&&c.trim()&&!d&&(p(!0),g(``),o(e.id,c.trim()).then(()=>u(``),e=>g(e instanceof Error?e.message:String(e))).finally(()=>p(!1)))},T=[[`This run`,n],[`Schedule`,e.schedule],[`Runs in`,e.target],[`Owner`,e.owner],[`Agent`,e.profile],[`Runs`,e.execution],[`Managed by`,e.source]],E=a?.id===e.id?a:void 0;return y(`div`,{className:`flex flex-col gap-4`,children:[y(t,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:s,children:[f(B,{className:`size-4`,"aria-hidden":`true`}),r]}),y(`div`,{className:`flex flex-col gap-2`,children:[y(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`h2`,{className:`text-xl font-semibold text-po-hi`,children:e.title}),f(b,{tone:e.status===`done`?`ok`:`neutral`,className:`text-po-dim`,children:Ge(e.status)})]}),y(`div`,{className:`flex items-center gap-1 text-sm text-po-dim`,children:[`Event id`,f(`code`,{className:`rounded bg-po-panel px-1.5 py-0.5 font-mono text-po-text`,children:e.id}),f(t,{variant:`ghost`,size:`icon`,"aria-label":_,title:_,onClick:x,children:f(l,{className:`size-4`,"aria-hidden":`true`})})]})]}),f(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm`,children:T.map(([e,t])=>t?y(`div`,{className:`contents`,children:[f(`dt`,{className:`text-po-dim`,children:e}),f(`dd`,{className:`min-w-0 break-words text-po-text`,children:t})]},e):null)}),y(`section`,{"aria-label":`Prompt`,className:`flex flex-col gap-1`,children:[f(`h3`,{className:`font-semibold text-po-hi`,children:`Prompt`}),f(`p`,{className:`rounded bg-po-panel p-2 text-sm whitespace-pre-wrap`,children:e.prompt})]}),y(`section`,{"aria-label":`Recent runs`,className:`flex flex-col gap-1 text-sm`,children:[f(`h3`,{className:`text-base font-semibold text-po-hi`,children:`Recent runs`}),E?E.error?f(`p`,{className:`text-po-dim`,children:E.error}):E.items.length===0?f(`p`,{className:`text-po-dim`,children:`No runs yet`}):f(`ul`,{className:`flex flex-col gap-0.5`,children:E.items.map(e=>y(`li`,{children:[e.at,` · `,e.state,e.note?y(`span`,{className:`text-po-dim`,children:[` · `,e.note]}):null]},e.id))}):f(`p`,{className:`text-po-dim`,children:`Loading runs…`}),f(t,{variant:`link`,size:`xs`,className:`self-start px-0`,disabled:C,onClick:()=>i?.event(`history`,e.id),children:`View all history`})]}),o&&!S&&!e.source?y(`form`,{onSubmit:w,className:`flex flex-col gap-1`,children:[f(`label`,{htmlFor:`ask-${e.id}`,className:`font-semibold text-po-hi`,children:`Ask Po to change this event`}),y(`div`,{className:`relative`,children:[f(h,{id:`ask-${e.id}`,rows:3,maxLength:2e3,className:`w-full pr-10`,placeholder:`e.g. Move this to 10:00 and skip Fridays`,value:c,disabled:d,onChange:e=>u(e.target.value)}),f(t,{type:`submit`,variant:`primary`,size:`icon-md`,"aria-label":`Ask Po`,className:`absolute right-1.5 bottom-1.5 rounded-full`,disabled:C||!c.trim(),children:f(G,{className:`size-4`,"aria-hidden":`true`})})]}),f(`p`,{className:`text-sm text-po-dim`,role:m?`alert`:void 0,children:m||(d?`Starting a session…`:`Po changes this event in a new session and opens it for you.`)})]}):null,S?null:y(`div`,{className:`flex flex-wrap gap-2`,children:[f(t,{variant:`primary`,size:`sm`,disabled:C,onClick:()=>i?.event(`runNow`,e.id),children:`Run now`}),e.source?null:f(t,{size:`sm`,disabled:C,onClick:()=>i?.event(`edit`,e.id),children:`Edit`}),f(t,{size:`sm`,disabled:C,onClick:()=>i?.event(`pause`,e.id),children:e.status===`paused`?`Resume`:`Pause`}),f(t,{size:`sm`,variant:`ghost`,disabled:C,onClick:()=>i?.event(`cancel`,e.id),children:`Cancel event`})]})]})}function Je({mode:e,cells:n,open:r,onOpen:i,...a}){let[s,c]=W(``),l=n.find(e=>e.key===s)??n.find(e=>e.today)??n.find(e=>!e.outside)??n[0],u=(e,t=``)=>{c(e),i(t)},d=l?.events.find(e=>e.id===r);return y(`div`,{className:`flex min-h-0 flex-1 flex-col lg:flex-row`,children:[y(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[f(`div`,{className:`grid grid-cols-7 border-b border-po-border-soft`,"aria-hidden":`true`,children:n.slice(0,7).map(e=>f(`span`,{className:`py-2 text-center text-sm text-po-dim`,children:e.weekday},e.key))}),f(`div`,{className:`grid grid-cols-7`,children:n.map(n=>{let i=e===`month`?n.events.slice(0,Ue):n.events,a=n.events.length-i.length;return y(`section`,{"aria-label":n.label,className:`flex min-w-0 flex-col gap-1 border-r border-b border-po-border-soft p-1.5 ${e===`week`?`min-h-96`:`min-h-28`} ${n.key===l?.key?`bg-po-deep/50`:``}`,children:[f(`button`,{type:`button`,"aria-label":n.label,"aria-pressed":n.key===l?.key,onClick:()=>u(n.key),className:`flex size-6 cursor-pointer items-center justify-center rounded-full text-sm outline-none focus-visible:ring-2 focus-visible:ring-po-green/50 ${n.today?`bg-po-green font-semibold text-po-rail`:n.outside?`text-po-faint hover:bg-po-panel`:`text-po-hi hover:bg-po-panel`}`,children:n.day}),i.map(e=>y(t,{size:`card`,variant:`subtle`,"aria-pressed":n.key===l?.key&&e.id===r,className:`gap-0 bg-po-panel px-1.5 py-1 text-sm`,onClick:()=>u(n.key,e.id),children:[y(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5`,children:[f(`span`,{className:`shrink-0 font-mono text-po-dim`,children:e.time}),f(`span`,{className:`line-clamp-2 font-semibold break-words text-po-hi`,children:e.title})]}),y(`span`,{className:`flex min-w-0 items-center justify-between gap-1 text-po-dim`,children:[y(`span`,{className:`flex min-w-0 items-center gap-1`,children:[e.profile?f(p,{name:e.profile,size:`sm`}):null,f(`span`,{className:`truncate`,children:e.owner.split(` · `).at(-1)})]}),e.status===`Scheduled`?null:f(`span`,{className:`shrink-0`,children:Ge(e.status)})]})]},e.id)),a>0?y(t,{size:`xs`,variant:`ghost`,className:`self-start`,onClick:()=>u(n.key),children:[a,` more`]}):null]},n.key)})})]}),l?f(`aside`,{"aria-label":d?d.title:l.label,className:`flex min-h-0 flex-col gap-3 overflow-y-auto border-t border-po-border-soft px-4 py-3 lg:border-t-0 lg:border-l ${d?`lg:w-96`:`lg:w-80`}`,children:d?f(qe,{event:d,when:`${l.label}, ${d.time}`,back:`Back to ${l.label}`,onBack:()=>i(``),...a},d.id):y(o,{children:[y(`div`,{children:[f(`h2`,{className:`text-lg font-semibold text-po-hi`,children:l.label}),f(`p`,{className:`text-sm text-po-dim`,children:l.events.length===0?`Nothing scheduled`:`${l.events.length} scheduled ${l.events.length===1?`event`:`events`}`})]}),f(`ol`,{className:`flex flex-col gap-2`,children:l.events.map(e=>f(Ke,{event:e,open:!1,onOpen:()=>i(e.id)},e.id))})]})}):null]})}function Ye({days:e,total:n,matched:a=n,onMore:s,filters:c,workspaces:l,timezone:d,state:p=`populated`,mode:h=`agenda`,period:g,cells:_=[],actions:v,runs:b,onAsk:S,onOpen:T,onFilters:E,onMode:D,onMove:O,onClose:k,initialOpen:A=``,children:ee}){let[j,M]=W(A),N=e=>{M(e),e&&T?.(e)},P={actions:v,runs:b,onAsk:S},F=e.find(e=>e.events.some(e=>e.id===j)),I=F?.events.find(e=>e.id===j),L=h===`agenda`?e.reduce((e,t)=>e+t.events.length,0):new Set(_.flatMap(e=>e.events.map(e=>e.id))).size,R=c.query!==X.query||c.workspace!==X.workspace||c.status!==X.status||c.kind!==X.kind,z=e=>E?.({...c,...e});return y(`section`,{"aria-label":`Calendar`,className:`flex h-full min-h-0 w-full flex-col bg-po-rail font-sans text-base text-po-text`,children:[y(`header`,{className:`flex items-start justify-between gap-3 border-b border-po-border px-4 py-3`,children:[y(`div`,{className:`min-w-0`,children:[f(`h1`,{className:`text-xl font-semibold text-po-hi`,children:`Calendar`}),y(`p`,{className:`truncate text-sm text-po-dim`,children:[`All workspaces · Times in `,d]})]}),y(`div`,{className:`flex shrink-0 items-center gap-1`,children:[f(t,{variant:`primary`,disabled:v?.busy,onClick:()=>v?.create(),children:`New event`}),k?f(t,{variant:`ghost`,size:`icon`,"aria-label":`Close calendar`,onClick:k,children:f(x,{className:`size-4`})}):null]})]}),y(`div`,{className:`flex flex-col gap-2 border-b border-po-border-soft px-4 py-3 md:flex-row md:items-center`,children:[y(`div`,{className:`relative min-w-0 flex-1`,children:[f(m,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-po-faint`}),f(K,{type:`search`,"aria-label":`Search events`,className:`w-full pl-8`,placeholder:`Search events`,value:c.query,onChange:e=>z({query:e.target.value})})]}),y(`div`,{className:`grid grid-cols-3 gap-2 md:flex`,children:[f(We,{label:`Workspace`,value:c.workspace,options:[[`all`,`All workspaces`],...l.map(e=>[e.id,e.name])],onChange:e=>z({workspace:e})}),f(We,{label:`Status`,value:c.status,options:Be,onChange:e=>z({status:e})}),f(We,{label:`Schedule`,value:c.kind,options:Ve,onChange:e=>z({kind:e})})]})]}),y(r,{value:h,onValueChange:e=>D?.(e),className:`flex min-h-0 flex-1 flex-col`,children:[y(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-po-border-soft px-4 py-2`,children:[h===`agenda`?null:y(o,{children:[f(t,{variant:`ghost`,size:`icon-md`,"aria-label":`Previous ${h}`,onClick:()=>O?.(-1),children:f(i,{className:`size-4 rotate-180`})}),f(`h2`,{"aria-live":`polite`,className:`min-w-36 text-center text-lg font-semibold text-po-hi`,children:g}),f(t,{variant:`ghost`,size:`icon-md`,"aria-label":`Next ${h}`,onClick:()=>O?.(1),children:f(i,{className:`size-4`})}),f(t,{size:`sm`,variant:`subtle`,onClick:()=>O?.(0),children:`Today`})]}),y(`output`,{className:`text-sm text-po-dim`,children:[L,` of `,a,` `,a===1?`event`:`events`]}),s?f(t,{size:`sm`,variant:`subtle`,disabled:v?.busy,onClick:s,children:`Load more`}):null,R?f(t,{size:`sm`,variant:`ghost`,onClick:()=>E?.(X),children:`Clear filters`}):a<n?f(t,{size:`sm`,variant:`ghost`,onClick:()=>z({status:`all`}),children:`Show finished events`}):null,f(u,{"aria-label":`Calendar view`,className:`ml-auto`,children:He.map(([e,t])=>f(C,{value:e,children:t},e))})]}),y(w,{value:h,className:`flex min-h-0 flex-col`,children:[ee,p===`populated`&&h!==`agenda`?f(Je,{mode:h,cells:_,open:j,onOpen:N,...P},g):y(`div`,{className:`flex min-h-0 flex-1 flex-col lg:flex-row`,children:[f(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-3`,children:p===`loading`?f(`output`,{className:`py-6 text-po-dim`,children:`Loading your schedule…`}):p===`error`?y(`div`,{role:`alert`,className:`rounded border border-po-edge-red p-3`,children:[f(`p`,{className:`text-po-red`,children:`Calendar could not load.`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Your saved events are unchanged. Try again when the host is reachable.`}),f(t,{className:`mt-3`,variant:`outline`,onClick:()=>v?.retry(),children:`Try again`})]}):n===0?f(H,{title:`Nothing scheduled`,description:`Leave a prompt for later. Po will take it from here.`}):e.length===0?f(H,{title:`No events match`,description:R?`Try another search, or clear the filters.`:`Nothing is active or paused. Finished and cancelled events are hidden.`}):e.map(e=>y(`section`,{"aria-label":e.label,className:`flex flex-col gap-2`,children:[f(`h2`,{className:`text-sm font-semibold text-po-hi`,children:e.label}),f(`ol`,{className:`flex flex-col gap-2`,children:e.events.map(e=>f(Ke,{event:e,open:j===e.id,onOpen:()=>N(j===e.id?``:e.id)},e.id))})]},e.label))}),p===`populated`&&F&&I?f(`aside`,{"aria-label":I.title,className:`flex min-h-0 flex-col overflow-y-auto border-t border-po-border-soft px-4 py-3 lg:w-96 lg:border-t-0 lg:border-l`,children:f(qe,{event:I,when:`${F.label}, ${I.time}`,back:`Back to agenda`,onBack:()=>N(``),...P},I.id)}):null]})]})]}),f(`footer`,{className:`border-t border-po-border px-4 py-2 text-sm text-po-dim`,children:`Sleeping sessions wake for their event. Missed runs are skipped.`})]})}var Xe=3,Ze=e=>({id:e.id,at:new Date(e.dueAt).toLocaleString(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`}),state:e.state.charAt(0).toUpperCase()+e.state.slice(1),note:e.error??e.summary??(e.skippedCount?`${e.skippedCount} skipped`:void 0)});function Qe(e){return se(ce,{scopes:J,basePath:`calendar`,transport:(t,n)=>e?te(S).fetch(t,n):Promise.reject(Error(`This Po is not signed in to Po Cloud.`)),sessionAddress:L})}function $e({openSession:e,poCloud:t}){let[n]=W(Date.now),[r,i]=W(`month`),[a,o]=W(n),s=r===`agenda`?void 0:ye(r,a),l=Intl.DateTimeFormat().resolvedOptions().timeZone,[u,p]=W(X),[m,h]=W(u);d(()=>{let e=setTimeout(()=>h(u),250);return()=>clearTimeout(e)},[u]);let g=s&&{from:s.from,to:s.to,tz:l},_=le(),v=De(Y,``,`page`,g,ue(m),_),b=t!==void 0,x=c(()=>Qe(b),[b]),C=De(x,``,`page`,g,ue(m),_),w=b&&C.state===`populated`,T=b,E=w?Re(C.events,v.events):v.events.map(e=>({...e,place:`local`})),D=e=>w&&C.events.some(t=>t.id===e)?C:v,O=e=>D(e)===C?x:Y,[k,A]=W(``),[ee,j]=W();d(()=>{if(!k)return;let e=!0;return(w&&C.events.some(e=>e.id===k)?x:Y).host.history({params:{id:k}}).then(e=>{if(!e.ok)throw Error(e.error||`Runs could not load.`);return{id:k,items:e.data.occurrences.slice(0,Xe).map(Ze)}}).catch(e=>({id:k,items:[],error:e instanceof Error?e.message:String(e)})).then(t=>e&&j(t)),()=>{e=!1}},[k,v.events,C.events,w,x]);let M=e&&(async(t,n)=>{let r=D(t)===C,i=await O(t).host.ask({params:{id:t},body:{request:n}});if(!i.ok)throw Error(i.error||`Po could not start the change.`);e(r?`${S}/${i.data.sessionId}`:i.data.sessionId)}),N=e=>{let n=Ee(e),r=e.place===`cloud`?C.targets:v.targets,i=e.target.kind===`existingSession`?e.target.sessionId:void 0,a=r?.sessions.find(e=>e.sessionId===i)?.name,o=fe(e,r),s=e.place===`cloud`?t?.label:`This computer`;return{...n,target:a??n.target,owner:w?`${s} · ${o}`:o}},P=T?ze(v.actions,C.actions,e=>D(e)===C):v.actions,F=w&&(v.more||C.more)?()=>{v.more?.(),C.more?.()}:v.more,I=(e,t)=>new Date(e).toLocaleDateString(void 0,t),L=s?he(E,s.days,s.to).map((e,t)=>{let i=s.days[t];return{key:String(i),day:new Date(i).getDate(),label:I(i,{weekday:`long`,day:`numeric`,month:`long`}),weekday:I(i,{weekday:`short`}),outside:r===`month`&&new Date(i).getMonth()!==new Date(a).getMonth(),today:i<=n&&n<(s.days[t+1]??s.to),events:e.map(N)}}):void 0,R=s?r===`month`?I(a,{month:`long`,year:`numeric`}):`${I(s.from,{day:`numeric`,month:`short`})} to ${I(s.days.at(-1),{day:`numeric`,month:`short`,year:`numeric`})}`:void 0;return y(Ye,{days:s?[]:me(E,n).map(e=>({label:e.label,events:e.events.map(N)})),total:v.total+(w?C.total:0),matched:v.matched+(w?C.matched:0),onMore:F,filters:u,workspaces:[...w?pe(C.targets):[],...pe(v.targets)],timezone:v.data.timezone,state:w&&v.state===`error`?`populated`:v.state,mode:r,period:R,cells:L,actions:P,runs:ee,onOpen:A,onAsk:M,onFilters:p,onMode:i,onMove:e=>r!==`agenda`&&o(be(r,a,e,Date.now())),children:[f(Le,{model:v,sessionId:``,openSession:e}),T?f(Le,{model:C,sessionId:`${S}/`,openSession:e}):null,b&&C.state===`error`?y(`p`,{role:`alert`,className:`text-po-red`,children:[`Po Cloud events could not load. `,C.error]}):null]})}var et=V({slot:`page`,id:`calendar`,component:$e});function tt({openPage:e,activePageId:n}){let r=n===`calendar`;return f(`div`,{className:`px-3 pt-1 group-data-[rail=desktop]/rail:p-0 group-data-[rail=elegant]/rail:p-0`,children:y(t,{variant:`ghost`,size:`lg`,"data-testid":`calendar-open`,"aria-current":r?`page`:void 0,onClick:()=>e?.(`calendar`),className:r?`w-full justify-start gap-2.5 border border-po-edge-green bg-po-tint-green px-2 text-po-hi group-data-[rail=elegant]/rail:h-9 group-data-[rail=elegant]/rail:border-0 group-data-[rail=elegant]/rail:gap-3 group-data-[rail=elegant]/rail:text-base group-data-[rail=elegant]/rail:rounded-lg group-data-[rail=elegant]/rail:bg-po-panel group-data-[rail=elegant]/rail:px-2.5 group-data-[rail=elegant]/rail:font-medium group-data-[rail=desktop]/rail:h-auto group-data-[rail=desktop]/rail:gap-3 group-data-[rail=desktop]/rail:rounded-xl group-data-[rail=desktop]/rail:border-0 group-data-[rail=desktop]/rail:px-3 group-data-[rail=desktop]/rail:py-2 group-data-[rail=desktop]/rail:text-base group-data-[rail=desktop]/rail:font-medium group-data-[rail=desktop]/rail:text-po-hi group-data-[rail=desktop]/rail:bg-po-rail`:`w-full justify-start gap-2.5 border border-transparent px-2 text-po-text group-data-[rail=elegant]/rail:h-9 group-data-[rail=elegant]/rail:border-0 group-data-[rail=elegant]/rail:gap-3 group-data-[rail=elegant]/rail:text-base group-data-[rail=elegant]/rail:rounded-lg group-data-[rail=elegant]/rail:px-2.5 group-data-[rail=elegant]/rail:font-medium group-data-[rail=elegant]/rail:hover:bg-po-panel/50 group-data-[rail=desktop]/rail:h-auto group-data-[rail=desktop]/rail:gap-3 group-data-[rail=desktop]/rail:rounded-xl group-data-[rail=desktop]/rail:border-0 group-data-[rail=desktop]/rail:px-3 group-data-[rail=desktop]/rail:py-2 group-data-[rail=desktop]/rail:text-base group-data-[rail=desktop]/rail:font-medium group-data-[rail=desktop]/rail:text-po-hi group-data-[rail=desktop]/rail:hover:bg-po-rail`,children:[f(`span`,{className:`contents group-data-[rail=desktop]/rail:grid group-data-[rail=desktop]/rail:size-8 group-data-[rail=desktop]/rail:shrink-0 group-data-[rail=desktop]/rail:place-items-center group-data-[rail=desktop]/rail:rounded-lg group-data-[rail=desktop]/rail:bg-po-rail`,children:f(I,{"aria-hidden":`true`,className:r?`size-5 text-po-green group-data-[rail=elegant]/rail:size-4 group-data-[rail=desktop]/rail:size-4`:`size-5 text-po-dim group-data-[rail=elegant]/rail:size-4 group-data-[rail=desktop]/rail:size-4`})}),`Calendar`]})})}var nt=V({slot:`rail`,id:`calendar`,component:tt});function rt({event:e,actions:n}){let r=e.status===`cancelled`||e.status===`done`;return y(`div`,{className:`mt-2 flex flex-col gap-3 rounded border border-po-border bg-po-panel p-3`,children:[e.source?y(F,{tone:`neutral`,children:[`Managed by `,e.source]}):null,f(`p`,{children:e.prompt}),e.assignment?y(`p`,{className:`text-sm text-po-dim`,children:[`Agent setup: `,e.assignment]}):null,y(`p`,{className:`text-sm text-po-dim`,children:[`Target: `,e.target,`. `,r?`This event is ${e.status}.`:`Sleeping sessions wake automatically.`]}),y(`div`,{className:`flex flex-wrap gap-2`,children:[r?null:y(o,{children:[e.source?null:f(t,{size:`sm`,onClick:()=>n?.event(`edit`,e.id),disabled:n?.busy,children:`Edit event`}),f(t,{size:`sm`,onClick:()=>n?.event(`pause`,e.id),disabled:n?.busy,children:e.status===`paused`?`Resume`:`Pause`}),f(t,{size:`sm`,onClick:()=>n?.event(`runNow`,e.id),disabled:n?.busy,children:`Run now`})]}),f(t,{size:`sm`,onClick:()=>n?.event(`history`,e.id),disabled:n?.busy,children:`History`}),r?null:f(t,{size:`sm`,variant:`danger-outline`,disabled:n?.busy,onClick:()=>n?.event(`cancel`,e.id),children:`Cancel event`})]})]})}function it({fixture:e,actions:n,children:i,initialScope:a=`Session`,state:o=`populated`,detail:s=!1}){let[c,l]=W(a),[d,p]=W(`Thu 22`),m=n?e.days[e.selectedDay??0]:d,[h,g]=W(s?`reviews`:``),_=e.events.filter(e=>n||c===`Everything`||e.owner===`Session`||c===`Workspace`&&e.owner===`Workspace`);return y(`section`,{"aria-label":`Calendar design target`,className:`mx-auto flex min-h-screen w-full max-w-lg flex-col gap-4 border-x border-po-border bg-po-rail p-4 font-sans text-base text-po-text`,children:[y(`header`,{className:`flex items-start justify-between gap-3`,children:[y(`div`,{children:[f(`h1`,{className:`text-lg font-semibold text-po-hi`,children:`Calendar`}),f(`p`,{className:`text-sm text-po-dim`,children:`Po handles it, on your schedule.`})]}),f(t,{variant:`outline`,disabled:n?.busy,onClick:()=>n?.create(),children:`New event`})]}),y(r,{value:c,onValueChange:e=>{l(e),n?.scope(e)},children:[f(u,{"aria-label":`Calendar level`,children:[`Session`,`Workspace`,`Everything`].map(e=>f(C,{value:e,children:e},e))}),[`Session`,`Workspace`,`Everything`].map(t=>f(w,{value:t,className:`mt-2 text-sm text-po-dim`,children:t===`Session`?e.session:t===`Workspace`?`${e.workspace} workspace and its sessions`:`All workspaces and sessions on this host`},t))]}),y(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`h2`,{className:`font-semibold text-po-hi`,children:e.range??`19–25 October 2026`}),f(t,{size:`sm`,variant:`ghost`,onClick:()=>{p(`Thu 22`),n?.today()},children:`Today`})]}),n?y(`div`,{className:`flex justify-between`,children:[f(t,{onClick:()=>n?.week(-1),children:`Previous week`}),f(t,{onClick:()=>n?.week(1),children:`Next week`})]}):null,f(`div`,{className:`grid grid-cols-7 gap-1`,"aria-label":`Days this week`,children:e.days.map(r=>y(t,{"aria-pressed":m===r,variant:m===r?`primary`:`ghost`,className:`h-auto flex-col px-1 py-2`,onClick:()=>{p(r),n?.day(e.days.indexOf(r)),g(``)},children:[f(`span`,{className:`text-sm`,children:r.split(` `)[0]}),f(`span`,{children:r.split(` `)[1]})]},r))}),y(`div`,{children:[f(`h2`,{className:`font-semibold text-po-hi`,children:n?m:m===`Thu 22`?`Today · Thursday 22 October`:`${m} October`}),y(`p`,{className:`mt-1 text-sm text-po-dim`,children:[`Times in `,e.timezone]})]}),i,o===`loading`?f(`output`,{className:`py-6 text-po-dim`,children:`Loading your schedule…`}):o===`error`?y(`div`,{role:`alert`,className:`rounded border border-po-edge-red p-3`,children:[f(`p`,{className:`text-po-red`,children:`Calendar could not load.`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Your saved events are unchanged. Try again when the host is reachable.`}),f(t,{className:`mt-3`,variant:`outline`,onClick:()=>n?.retry(),children:`Try again`})]}):o===`denied`?f(H,{title:`This calendar is not available`,description:`You do not have permission to view this level. Your session calendar is still available.`}):o===`empty`||n&&_.length===0||!n&&m!==`Thu 22`?f(H,{title:`Nothing scheduled`,description:`Leave a prompt for later. Po will take it from here.`}):f(`ol`,{className:`flex flex-col gap-3`,children:_.map(r=>y(`li`,{className:`flex items-start gap-3`,children:[f(`span`,{className:`w-10 shrink-0 pt-3 text-sm text-po-dim`,children:r.time}),y(`div`,{className:`min-w-0 flex-1`,children:[y(t,{size:`card`,variant:`outline`,"aria-expanded":h===r.id,onClick:()=>g(h===r.id?``:r.id),children:[y(`span`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`span`,{className:`font-semibold text-po-hi`,children:r.title}),r.status===`Scheduled`?f(b,{tone:`neutral`,className:`text-po-dim`,children:o===`blocked`&&r.id===`reviews`?`Paused`:`Scheduled`}):f(b,{tone:n?r.status===`done`?`ok`:`neutral`:o===`failed`?`error`:`ok`,children:n?r.status:o===`failed`?`Failed`:`Handled`})]}),y(`span`,{className:`text-sm text-po-dim`,children:[r.schedule,` · `,r.target]}),y(`span`,{className:`text-sm text-po-dim`,children:[r.owner,r.owner===`Global`?``:` · ${e.workspace}`]})]}),h===r.id?f(rt,{event:r,actions:n}):null]})]},r.id))}),o===`skipped`?y(`aside`,{className:`rounded border border-po-border p-3`,children:[f(F,{tone:`neutral`,children:`Skipped`}),f(`p`,{className:`mt-2`,children:`The inbox check yesterday did not run while Po was offline.`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`No catch-up burst. Next run: tomorrow at 09:00.`})]}):null,o===`blocked`?y(`aside`,{className:`rounded border border-po-edge-magenta bg-po-tint-magenta p-3`,children:[f(`p`,{className:`font-semibold text-po-magenta`,children:`Pick a session, whenever you are ready`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`The target for “Review pull requests” is no longer available. This event is paused.`}),f(t,{className:`mt-3`,variant:`secondary`,children:`Choose session`})]}):null,o===`failed`?y(`aside`,{className:`rounded border border-po-edge-red p-3`,children:[f(`p`,{className:`font-semibold text-po-red`,children:`Inbox check failed`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Po could not reach the mail service. The next scheduled run is unchanged.`}),f(t,{className:`mt-3`,children:`View run`})]}):null,f(`footer`,{className:`mt-auto border-t border-po-border pt-3 text-sm text-po-dim`,children:`Sleeping sessions wake for their event. Missed runs are skipped.`})]})}function at(e){return e.sessionId?f(ot,{sessionId:e.sessionId,openSession:e.openSession},e.sessionId):null}function ot({sessionId:e,openSession:t}){let n=De(Y,e,`panel`,void 0,void 0,le());return f(it,{fixture:n.data,actions:n.actions,state:n.state,children:f(Le,{model:n,sessionId:e,openSession:t})})}var st=ne({id:`calendar`,label:`Calendar`,icon:I,order:40,panel:at}),ct=V({slot:`help.guides`,id:`Calendar`,order:20,data:{version:1,label:`Calendar`,guides:[{id:`schedule`,question:`How do I schedule a prompt?`,order:0,answer:`Ask Po to schedule a prompt for a time, then confirm the schedule. Calendar must be selected in your home default preset, and the server must stay running.`},{id:`repeat`,question:`Can Po run something on a repeat?`,order:1,answer:`Yes. Calendar supports intervals and cron schedules with a timezone. Intervals run immediately when created. Missed runs are skipped after downtime.`}]}}),lt=[`calendar_schedule`,`calendar_list`,`calendar_cancel`,`calendar_update`,`calendar_pause`,`calendar_resume`,`calendar_run_now`,`calendar_history`,`loop_start`,`loop_list`,`loop_stop`],ut={calendar_schedule:{outcome:`Scheduled`,tone:`ok`},calendar_update:{outcome:`Updated`,tone:`ok`},calendar_resume:{outcome:`Resumed`,tone:`ok`},calendar_run_now:{outcome:`Started now`,tone:`ok`,note:`This run does not change the schedule.`},calendar_cancel:{outcome:`Cancelled`,tone:`neutral`,note:`It will not run. Past runs stay in its history.`,quiet:!0},calendar_pause:{outcome:`Paused`,tone:`neutral`,note:`Nothing runs until it is resumed.`,quiet:!0}},dt={calendar_schedule:`Not scheduled`,calendar_update:`Not updated`,calendar_cancel:`Not cancelled`,calendar_pause:`Not paused`,calendar_resume:`Not resumed`,calendar_run_now:`Did not start`,calendar_list:`Could not list events`,calendar_history:`Could not read its history`,loop_start:`Not scheduled`,loop_list:`Could not list events`,loop_stop:`Not stopped`},ft={succeeded:{label:`Done`,tone:`ok`},failed:{label:`Failed`,tone:`error`},skipped:{label:`Skipped`,tone:`neutral`},blocked:{label:`Needs a session`,tone:`accent`},queued:{label:`Queued`,tone:`neutral`},running:{label:`Running`,tone:`running`},interrupted:{label:`Interrupted`,tone:`neutral`}};function Z(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Q(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function pt(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function mt(e,t){try{return new Intl.DateTimeFormat(void 0,{...t,...e?{timeZone:e}:{}})}catch{return new Intl.DateTimeFormat(void 0,t)}}function ht(e,t){return mt(t,{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e)}function gt(e,t){return mt(t,{weekday:`short`,day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`}).format(e)}function _t(e){let[t,n]=e%3600==0?[e/3600,`hour`]:e%60==0?[e/60,`minute`]:[e,`second`];return t===1?`Every ${n}`:`Every ${t} ${n}s`}function vt(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function yt(e,t){let n=Z(e.target),r=Q(Z(e.workflow)?.key),i=Q(Z(e.action)?.launcherId),a=Q(n?.cwd),o=n?.kind===`newSession`,s=o?`new session${a?` in ${vt(a)}`:``}`:t&&Q(n?.sessionId)&&n?.sessionId!==t?`another session`:`this session`;return r?`Workflow ${r} in ${o?`a `:``}${s}`:i?`Action ${i} in ${o?`a `:``}${s}`:o?`N${s.slice(1)}`:`Prompt in ${s}`}function bt(e,t,n={}){let r=Z(e),i=Z(r?.schedule),a=Q(r?.title);if(!r||!i||!a)return;let o=Q(i.tz),s=pt(r.nextDueAt),c,l=!1;if(i.kind===`once`&&pt(i.at)!==void 0)c=ht(i.at,o);else if(i.kind===`interval`&&pt(i.seconds)!==void 0)c=_t(i.seconds);else if(i.kind===`cron`&&Q(i.expr))c=i.expr,l=!0;else return;let u=r.status===`paused`?{label:`Paused`,tone:`neutral`}:r.status===`cancelled`?{label:`Cancelled`,tone:`neutral`}:r.status===`done`?{label:`Done`,tone:`ok`}:void 0;return{title:a,when:c,...l?{cron:l}:{},...o&&i.kind!==`interval`?{zone:o}:{},...n.next!==!1&&i.kind!==`once`&&s!==void 0&&r.status===`active`?{next:gt(s,o)}:{},runs:yt(r,t),...n.prompt!==!1&&Q(r.prompt)?{prompt:r.prompt}:{},...u?{status:u}:{}}}function xt(e){let t=e.result?.details;if(t==null)return e.output;try{return JSON.stringify(t,null,2)}catch{return e.output}}function St(e,t){return e===0?`No ${t}s`:`${e} ${t}${e===1?``:`s`}`}function Ct(e){let{toolName:t,args:n,sessionId:r}=e,i=e.result?.details,a=xt(e),o=Q(n.title)??Q(Z(n.patch)?.title)??Q(Z(n.input)?.prompt)??``;if(e.running)return{tone:`running`,summary:o,details:``};if(e.isError)return{tone:`error`,summary:o,failure:{heading:dt[t]??`Calendar call failed`,detail:Q(e.output)??`Calendar gave no reason.`},...t.endsWith(`_list`)||t===`calendar_history`?{}:{note:`Nothing was saved.`},details:``};let s={tone:`ok`,summary:o,note:`This result has no summary. The details below are what Calendar returned.`,details:a},c=ut[t];if(c){let e=bt(i,r,{next:!c.quiet,prompt:!c.quiet});if(!e)return s;let{status:t,...n}=e;return{tone:c.tone,outcome:c.outcome,summary:e.title,event:n,...c.note?{note:c.note}:{},details:a}}switch(t){case`calendar_list`:{if(!Array.isArray(i))return s;let e=i.map(e=>bt(e,r,{prompt:!1})).filter(e=>e!==void 0);return{tone:`ok`,summary:St(e.length,`event`),...e.length?{events:e}:{empty:`Nothing scheduled in this session yet.`},details:a}}case`calendar_history`:{let e=Z(i)?.occurrences;if(!Array.isArray(e))return s;let t=e.flatMap(e=>{let t=Z(e),n=pt(t?.dueAt);if(!t||n===void 0)return[];let r=ft[String(t.state)]??{label:String(t.state),tone:`neutral`},i=Q(t.summary)??Q(t.error);return[{when:gt(n),...r,...i?{note:i}:{}}]});return{tone:`ok`,summary:St(t.length,`run`),...t.length?{runs:t}:{empty:`It has not run yet.`},...Q(Z(i)?.cursor)?{note:`Older runs are on the next page.`}:{},details:a}}case`loop_start`:{let e=Z(n.input),t=Z(i),r=Q(e?.cron),o=pt(e?.intervalSeconds),c=Q(e?.timezone),l=Q(t?.label)??Q(e?.prompt)??`Recurring event`;return!r&&o===void 0?{...s,outcome:`Started`,summary:l}:{tone:`ok`,outcome:`Scheduled`,summary:l,event:{title:l,when:r??_t(o),...r?{cron:!0}:{},...r&&c?{zone:c}:{},runs:`Prompt in this session`,...Q(e?.prompt)?{prompt:e?.prompt}:{}},details:a}}case`loop_list`:{let e=Z(i)?.instances;if(!Array.isArray(e))return s;let t=e.flatMap(e=>{let t=Z(e),n=Q(t?.label)??Q(t?.launcherLabel);return!t||!n?[]:[{title:n,when:Q(t.launcherLabel)??`Recurring`,runs:`This session`,...t.state===`running`?{}:{status:{label:`Stopping`,tone:`neutral`}}}]});return{tone:`ok`,summary:St(t.length,`recurring event`),...t.length?{events:t}:{empty:`Nothing recurring in this session.`},details:a}}case`loop_stop`:{let e=Z(i)?.stopped;return typeof e==`boolean`?{tone:`neutral`,outcome:e?`Stopped`:`Not found`,summary:Q(n.instanceId)??``,note:e?`It will not run again.`:`Nothing was running under that id.`,details:a}:s}default:return s}}function wt({label:e,children:t}){return y(`div`,{className:`flex gap-3`,children:[f(`dt`,{className:`w-12 shrink-0 pt-px text-sm text-po-dim`,children:e}),f(`dd`,{className:`min-w-0 flex-1 break-words text-base text-po-text`,children:t})]})}function Tt({event:e}){return y(o,{children:[e.cron?f(`code`,{className:`font-mono text-po-text`,children:e.when}):e.when,e.zone?y(`span`,{className:`text-sm text-po-dim`,children:[` · `,e.zone]}):null]})}function Et({event:e}){return y(`div`,{className:`flex flex-col gap-3`,children:[y(`dl`,{className:`flex flex-col gap-1.5`,children:[f(wt,{label:`When`,children:f(Tt,{event:e})}),e.next?f(wt,{label:`Next`,children:e.next}):null,f(wt,{label:`Runs`,children:e.runs})]}),e.prompt?f(`p`,{className:`line-clamp-3 border-l-2 border-po-border-soft pl-3 text-base break-words text-po-text`,children:e.prompt}):null]})}function Dt({event:e}){return y(`li`,{className:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`,children:[y(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[f(`span`,{className:`truncate text-base font-semibold text-po-hi`,children:e.title}),y(`span`,{className:`text-sm break-words text-po-dim`,children:[f(Tt,{event:e}),e.next?` · Next ${e.next}`:null]})]}),e.status?f(b,{tone:e.status.tone,children:e.status.label}):null]})}function Ot({run:e}){return y(`li`,{className:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`,children:[y(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[f(`span`,{className:`text-base text-po-text`,children:e.when}),e.note?f(`span`,{className:`text-sm break-words text-po-dim`,children:e.note}):null]}),f(b,{tone:e.tone,children:e.label})]})}function kt({toolName:e,fixture:t,defaultExpanded:n=!1}){let r=t.details.split(`
|
|
1
|
+
import{$n as e,$r as t,At as n,Br as r,Di as i,En as a,Ft as o,Gi as s,Gt as c,Hi as l,Hr as u,Ht as d,It as f,Ji as p,Jn as m,Jr as h,Jt as g,Ki as _,Kt as v,Lt as y,Nr as b,Pi as x,Sa as S,Ur as C,Vr as w,Wa as T,Wi as E,Xa as D,Xi as O,Xn as k,Ya as A,Yi as ee,Zi as j,Zn as M,_n as N,an as P,cr as F,di as I,eo as L,gn as R,hn as z,in as B,ja as V,jt as te,ka as ne,la as H,mn as re,nr as U,qa as ie,qt as W,rr as G,tn as K,to as ae,tr as q,vn as oe,wa as se}from"../chunks/po-web-runtime-C0B3uAoC.js";var ce={list:{method:`GET`,path:`/events`,query:[`from`,`to`,`cursor`,`tz`,`status`,`workspace`,`kind`,`q`,`limit`],response:void 0},create:{method:`POST`,path:`/events`,response:void 0},update:{method:`PATCH`,path:`/events/:id`,response:void 0},cancel:{method:`DELETE`,path:`/events/:id`,response:void 0},pause:{method:`POST`,path:`/events/:id/pause`,response:void 0},resume:{method:`POST`,path:`/events/:id/resume`,response:void 0},runNow:{method:`POST`,path:`/events/:id/run-now`,response:void 0},ask:{method:`POST`,path:`/events/:id/ask`,response:void 0},history:{method:`GET`,path:`/events/:id/history`,query:[`cursor`],response:void 0},targets:{method:`GET`,path:`/targets`,response:void 0}},J=[`host`,`workspace`,`session`],Y=se(ce,{scopes:J,basePath:`calendar`,transport:(e,t)=>n.fetch(e,t),sessionAddress:L});function le(){let e=A(`calendar`);return g(t=>ae(e,t),()=>D(e))}var X={query:``,workspace:`all`,status:`open`,kind:`all`};function ue({query:e,workspace:t,status:n,kind:r}){return{...e.trim()?{q:e.trim()}:{},...t===`all`?{}:{workspace:t},...n===`all`?{}:{status:n},...r===`all`?{}:{kind:r}}}function de(e,t){return e===void 0?void 0:t?.workspaces.find(t=>t.id===e)?.name??e}function fe(e,t){return e.owner.level===`global`?`Global`:`${e.owner.level===`workspace`?`Workspace`:`Session`} · ${de(e.owner.workspaceId,t)}`}function pe(e){return(e?.workspaces??[]).map(({id:e,name:t})=>({id:e,name:t})).sort((e,t)=>e.name.localeCompare(t.name))}function me(e,t){let n=new Date(t);n.setHours(0,0,0,0);let r=[];for(let t of e){let e=new Date(t.projectedDueAt??t.nextDueAt??t.updatedAt);e.setHours(0,0,0,0);let i=Math.round((e.getTime()-n.getTime())/864e5),a=i===0?`Today`:i===1?`Tomorrow`:e.toLocaleDateString(void 0,{weekday:`long`,day:`numeric`,month:`long`}),o=r.at(-1);o?.label===a?o.events.push(t):r.push({label:a,events:[t]})}return r}function he(e,t,n){let r=t.map(()=>[]);for(let i of e)for(let e of i.occurrences??(i.projectedDueAt===void 0?[]:[i.projectedDueAt])){let a=t.filter(t=>t<=e).length-1;a>=0&&e<n&&r[a].push({...i,projectedDueAt:e})}for(let e of r)e.sort((e,t)=>e.projectedDueAt-t.projectedDueAt);return r}function ge(e,t,n){let r=new Date(`${e}T${t}:00Z`).getTime();if(!Number.isFinite(r))throw Error(`Choose a valid date and time.`);let i=new Intl.DateTimeFormat(`sv-SE`,{timeZone:n,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),a=r;for(let e=0;e<4;e++){let e=r-new Date(i.format(new Date(a)).replace(` `,`T`)+`Z`).getTime();if(e===0)return a;a+=e}throw Error(`This time does not exist in that timezone. Choose another time.`)}function _e(e,t){let n=new Date(e);n.setDate(n.getDate()+t);let r=new Date(n);return r.setDate(r.getDate()+1),{from:n.getTime(),to:r.getTime()}}function ve(e){return{from:e,to:e+5184e6}}function ye(e,t){let n=new Date(t).getMonth(),r=new Date(t);r.setHours(0,0,0,0),e===`month`&&r.setDate(1),r.setDate(r.getDate()-(r.getDay()+6)%7);let i=[];do i.push(r.getTime()),r.setDate(r.getDate()+1);while(e===`month`?r.getMonth()===n||r.getDay()!==1:i.length<7);return{days:i,from:i[0],to:r.getTime()}}function be(e,t,n,r){if(n===0)return r;let i=new Date(t);return e===`month`?i.setMonth(i.getMonth()+n,1):i.setDate(i.getDate()+n*7),i.getTime()}function xe(e,t){let n=t.indexOf(`/`);return n<0||e.startsWith(t.slice(0,n+1))?e:t.slice(0,n+1)+e}function Se(e,t,n){return t.level===`global`?e.host:t.level===`workspace`?e.workspace(xe(t.workspaceId,n)):e.session(xe(t.sessionId,n))}function Ce(e,t,n){if(!e.title.trim()||!n?.workflow&&!n?.action&&!e.prompt.trim())throw Error(`Add a title and prompt.`);let r;if(e.kind===`Interval`){let t=Number(e.seconds);if(!Number.isInteger(t)||t<30||t>3600)throw Error(`Choose an interval from 30 to 3,600 seconds.`);r={kind:`interval`,seconds:t}}else if(e.kind===`Cron`){if(!e.expr.trim())throw Error(`Add a cron expression.`);r={kind:`cron`,expr:e.expr,tz:e.tz}}else{let t=ge(e.date,e.time,e.tz);if(!Number.isFinite(t)||t<=Date.now())throw Error(`Choose a time in the future.`);r={kind:`once`,at:t,tz:e.tz}}let i;if(e.targetKind===`New session`){let n=t.workspaces.find(t=>t.id===e.targetId&&t.active);if(!n)throw Error(`Choose an active workspace.`);i={kind:`newSession`,workspaceId:n.id,cwd:n.path}}else{let n=t.sessions.find(t=>t.sessionId===e.targetId);if(!n)throw Error(`Choose an available session.`);i={kind:`existingSession`,sessionId:n.sessionId}}return n?.target.kind===i.kind&&(n.target.kind===`newSession`?n.target.workspaceId:n.target.sessionId)===e.targetId&&(i=n.target),{title:e.title.trim(),schedule:r,target:i,...n?.workflow?{workflow:n.workflow}:n?.action?{action:n.action}:{prompt:e.prompt.trim()},...n?.assignment?{assignment:n.assignment}:{}}}function we(e,t=Intl.DateTimeFormat().resolvedOptions().timeZone){let n=new Intl.DateTimeFormat(`sv-SE`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(new Date(e)),r=e=>n.find(t=>t.type===e)?.value??``;return{date:`${r(`year`)}-${r(`month`)}-${r(`day`)}`,time:`${r(`hour`)}:${r(`minute`)}`}}function Te(e){let t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(t.getDay()+6)%7),t.getTime()}function Ee(e){return{id:e.id,title:e.title,prompt:e.prompt??(e.workflow?`Runs workflow ${e.workflow.key}`:`Runs ${e.action?.launcherId??`an action`}`),time:new Date(e.projectedDueAt??e.nextDueAt??e.updatedAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}),schedule:e.schedule.kind===`interval`?`Every ${e.schedule.seconds} seconds`:e.schedule.kind===`cron`?e.schedule.expr:`Once`,target:e.target.kind===`existingSession`?e.target.sessionId:`New session`,owner:`${e.owner.level===`global`?`Global`:e.owner.level===`workspace`?`Workspace`:`Session`}${e.id.startsWith(`${e.homeHostId}/`)?` · ${e.homeHostId}`:``}`,source:e.source?.packageName,execution:e.workflow?`Workflow: ${e.workflow.key}`:e.action?`Action: ${e.action.launcherId}`:void 0,assignment:e.assignment?JSON.stringify(e.assignment):void 0,profile:e.assignment?.profile,status:e.status===`active`?`Scheduled`:e.status}}function De(e,t,n=`panel`,r,i,a=0,o,s=`Session`,l=Date.now,u=!1,f){let{from:p,to:m,tz:h}=r??{},g=JSON.stringify(i??{}),[_,y]=W(n===`page`?`Everything`:s),[b,x]=W(()=>Te(l())),[S,C]=W(()=>(new Date(l()).getDay()+6)%7),[w,T]=W([]),[E,D]=W(),[O,k]=W({total:0,matched:0,more:!1}),A=v({key:``,count:1}),ee=v(void 0),[j,M]=W(`loading`),[N,P]=W(),[F,I]=W(0),[L,R]=W(!1),z=v(!1),[B,V]=W(),[te,ne]=W(),[H,re]=W(),[U,ie]=W(),G=f===void 0?n===`page`||_===`Everything`?{level:`global`}:_===`Workspace`&&U&&U.level!==`global`?{level:`workspace`,workspaceId:U.workspaceId}:U:{level:`workspace`,workspaceId:f};d(()=>{let r=!0;return(async()=>{let i=n===`page`||f!==void 0?void 0:await e.session(t).targets();if(i&&!i.ok)throw Error(i.error||`Calendar could not load.`);if(!r)return;i&&ie(i.data.owner);let a=f===void 0?!i||_===`Everything`?{level:`global`}:_===`Workspace`&&i.data.owner.level!==`global`?{level:`workspace`,workspaceId:i.data.owner.workspaceId}:i.data.owner:{level:`workspace`,workspaceId:f},o=p!==void 0&&m!==void 0?{from:p,to:m,...h?{tz:h}:{}}:n!==`page`||u?_e(b,S):ve(l()),s=Se(e,a,t),c=await s.targets();if(!c.ok)throw Error(c.error||`Targets could not load.`);let d={...o,...JSON.parse(g)},v=async e=>{let t=await s.list({query:{...d,...e?{cursor:e}:{}}});if(!t.ok)throw Error(t.error||`Calendar could not load.`);return t.data},y=e=>{k({total:e.total,matched:e.matched,more:e.cursor!==void 0});let t=e.cursor;ee.current=t?async()=>{let e=await v(t);r&&(A.current.count+=1,T(t=>[...t,...e.events]),y(e))}:void 0},x=JSON.stringify([a,d]);A.current.key!==x&&(A.current={key:x,count:1});let C=await v(),w=[...C.events];for(let e=1;(n===`panel`||e<A.current.count)&&C.cursor&&r;e++){let e=C.cursor;if(C=await v(e),C.cursor===e)throw Error(`Calendar returned an invalid page.`);w.push(...C.events)}r&&(T(w),D(c.data),y(C),M(`populated`))})().catch(e=>{r&&(P(e instanceof Error?e.message:String(e)),M(`error`))}),()=>{r=!1}},[e,t,n,_,b,S,F,a,p,m,h,g,u,l,f]);async function K(e){if(!z.current){z.current=!0,R(!0),P(void 0);try{await e()}catch(e){P(e instanceof Error?e.message:String(e))}finally{z.current=!1,R(!1)}}}function ae(e){if(e?.source)return;re(void 0),P(void 0),V(e??`new`);let t=e?.schedule;ne({title:e?.title??``,prompt:e?.prompt??``,kind:t?.kind===`interval`?`Interval`:t?.kind===`cron`?`Cron`:`Once`,...we(t?.kind===`once`?t.at:Date.now()+36e5,t?.kind===`once`?t.tz:void 0),seconds:t?.kind===`interval`?String(t.seconds):`300`,expr:t?.kind===`cron`?t.expr:`0 9 * * 1-5`,tz:t&&t.kind!==`interval`?t.tz:Intl.DateTimeFormat().resolvedOptions().timeZone,targetKind:e?.target.kind===`existingSession`?`Existing session`:`New session`,targetId:e?.target.kind===`existingSession`?e.target.sessionId:e?.target.workspaceId??``})}function q(){M(`loading`),P(void 0),V(void 0),re(void 0),T([]),D(void 0)}let oe={busy:L||j===`loading`,scope:e=>{e!==_&&(q(),y(e))},day:e=>{e!==S&&q(),C(e)},week:e=>{q(),x(t=>{let n=new Date(t);return n.setDate(n.getDate()+e*7),n.getTime()})},today:()=>{q(),x(Te(l())),C((new Date(l()).getDay()+6)%7),I(e=>e+1)},create:()=>ae(),retry:()=>{q(),I(e=>e+1)},event(n,r){let i=w.find(e=>e.id===r);i&&(n===`edit`?ae(i):K(async()=>{let a=Se(e,G&&G.level!==`session`?G:i.owner,t);if(n===`history`){let n=await Se(e,G??i.owner,t).history({params:{id:r}});if(!n.ok)throw Error(n.error);re({event:i,items:n.data.occurrences,cursor:n.data.cursor});return}let o=await a[n===`pause`&&i.status===`paused`?`resume`:n]({params:{id:r}});if(!o.ok)throw Error(o.error||`Event could not be changed.`);q(),I(e=>e+1)}))}},se=c(()=>[...w].sort((e,t)=>(e.projectedDueAt??e.nextDueAt??e.updatedAt)-(t.projectedDueAt??t.nextDueAt??t.updatedAt)),[w]),ce={timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,workspace:U&&U.level!==`global`?U.workspaceId:`Workspace`,session:t,days:Array.from({length:7},(e,t)=>{let n=new Date(b);return n.setDate(n.getDate()+t),n.toLocaleDateString(void 0,{weekday:`short`,day:`numeric`})}),selectedDay:S,range:new Date(b).toLocaleDateString(void 0,{month:`long`,year:`numeric`}),events:se.map(Ee)},J=B&&B!==`new`?B.owner:G,Y=E&&J?{...E,workspaces:E.workspaces.filter(e=>J.level===`global`||e.id===J.workspaceId),sessions:E.sessions.filter(e=>J.level===`global`||(J.level===`session`?e.sessionId===J.sessionId:e.workspaceId===J.workspaceId))}:void 0,le=B&&te&&Y?{fields:te,execution:B===`new`?void 0:B.workflow?`Workflow: ${B.workflow.key}`:B.action?`Action: ${B.action.launcherId}`:void 0,assignment:B!==`new`&&B.assignment?JSON.stringify(B.assignment):void 0,busy:L,error:N,owner:B===`new`?G?.level===`global`?`Global`:_:B.owner.level===`global`?`Global`:B.owner.level===`workspace`?`Workspace`:`Session`,choices:te.targetKind===`New session`?Y.workspaces.filter(e=>e.active).map(e=>({id:e.id,name:e.name})):Y.sessions.map(e=>({id:e.sessionId,name:e.name+(e.asleep?` (asleep)`:``)})),set:(e,t)=>ne(n=>n&&{...n,[e]:t,...e===`targetKind`?{targetId:``}:{}}),close:()=>V(void 0),save:()=>{K(async()=>{if(!G)return;let n=Ce(te,Y,B===`new`?void 0:B),r=Se(e,B===`new`||G.level!==`session`?G:B.owner,t),i=B===`new`?await r.create({body:{...n,...o?{destinationHostId:o}:{}}}):await r.update({params:{id:B.id},body:n});if(!i.ok)throw Error(i.error||`Event could not be saved.`);V(void 0),q(),I(e=>e+1)})}}:void 0;return{data:ce,owner:G,events:se,total:O.total,matched:O.matched,more:O.more?()=>void K(async()=>await ee.current?.()):void 0,targets:E,actions:oe,state:j,error:N,editor:le,editing:B,history:H,busy:L,closeHistory:()=>re(void 0),moreHistory:()=>{K(async()=>{if(!H?.cursor)return;let n=await Se(e,G??H.event.owner,t).history({params:{id:H.event.id},query:{cursor:H.cursor}});if(!n.ok)throw Error(n.error);re({...H,items:[...H.items,...n.data.occurrences],cursor:n.data.cursor})})}}}function Oe(e){return e.projectedDueAt??e.nextDueAt??e.updatedAt}function ke(e,t){let n=new Date(e),r=n.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return n.toDateString()===t?r:`${n.toLocaleDateString(void 0,{weekday:`short`})} ${r}`}var Ae=3;function je({dueToday:e,rows:n,state:r,onOpen:o,bodyOnly:s=!1}){if(s)return y(`div`,{className:`flex flex-col gap-2`,children:[e>0?f(F,{tone:`magenta`,className:`self-start`,children:`${e} today`}):null,r===`loading`?f(`p`,{className:`text-sm text-po-dim`,children:`Loading events…`}):null,r===`error`?f(`p`,{className:`text-sm text-po-dim`,children:`Could not load events`}):null,r===`populated`&&n.length===0?f(`p`,{className:`text-base text-po-dim`,children:`Nothing scheduled.`}):null,n.length>0?f(`ul`,{className:`space-y-2`,children:n.map(e=>y(`li`,{className:`flex gap-3 text-base`,children:[f(`span`,{className:`w-16 shrink-0 text-sm text-po-dim tabular-nums`,children:e.at}),y(`span`,{className:`flex min-w-0 flex-col`,children:[f(`span`,{className:`break-words text-po-text`,children:e.title}),e.owner?f(`span`,{className:`truncate text-sm text-po-dim`,children:e.owner}):null]})]},e.id))}):null,o?f(t,{variant:`ghost`,size:`sm`,onClick:o,className:`-ml-2.5 self-start`,children:`Open Calendar`}):null]});let c=r===`populated`&&n.length===0?f(H,{title:`Nothing scheduled`,description:`Scheduled prompts and workflows will appear here.`}):y(`ul`,{className:`divide-y divide-po-border-soft`,children:[r===`loading`?f(`li`,{className:`px-4 py-3 text-sm text-po-dim`,children:`Loading events…`}):null,r===`error`?f(`li`,{className:`px-4 py-3 text-sm text-po-dim`,children:`Could not load events`}):null,n.map(e=>y(`li`,{className:`flex flex-col gap-0.5 px-4 py-2.5`,children:[f(`span`,{className:`truncate text-base text-po-text`,children:`${e.at} · ${e.title}`}),e.owner?f(`span`,{className:`truncate text-sm text-po-dim`,children:e.owner}):null]},e.id))]});return y(a,{"data-testid":`calendar-home-card`,className:`overflow-hidden`,children:[y(`button`,{type:`button`,onClick:o,disabled:o===void 0,"aria-label":`Open Calendar`,className:`flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-po-selected/40 disabled:cursor-default`,children:[f(I,{"aria-hidden":`true`,className:`size-5 text-po-dim`}),f(`span`,{className:`flex-1 text-base font-semibold text-po-hi`,children:`Calendar`}),e>0?f(F,{tone:`magenta`,children:`${e} today`}):null,f(i,{"aria-hidden":`true`,className:`size-4 text-po-faint`})]}),f(`div`,{className:`border-t border-po-border-soft`,children:c})]})}function Me(e){return f(Ne,{...e},e.workspaceId??`home`)}function Ne({openPage:e,workspaceId:t,bodyOnly:n=!1}){let r=De(Y,``,`page`,void 0,{status:`active`},le(),void 0,void 0,void 0,void 0,t),[i]=W(()=>new Date().toDateString());return f(je,{bodyOnly:n,dueToday:r.events.filter(e=>new Date(Oe(e)).toDateString()===i).length,rows:r.events.slice(0,Ae).map(e=>({id:e.id,at:ke(Oe(e),i),title:e.title,owner:fe(e,r.targets)})),state:r.state,...e?{onOpen:()=>e(`calendar`)}:{}})}var Pe=V({slot:`dashboard-tiles`,id:`calendar`,order:20,data:{version:1,title:`Coming up`,icon:I,size:`wide`,column:`side`,surfaces:[`home`,`workspace`]},component:e=>f(Me,{...e,bodyOnly:!0})}),Fe=V({slot:`home-apps`,id:`calendar`,data:{column:`main`},component:Me});function Ie({fixture:e,editor:n,initialLevel:i=`Session`,initialSchedule:a=`Once`,initialTarget:o=`New session`,invalid:s=!1,edit:c=!1}){let[l,d]=W(n?.owner??i),[p,m]=W(a),[g,_]=W(o),v=n?.fields.kind??p,b=n?.fields.targetKind??g;return y(`form`,{onSubmit:e=>{e.preventDefault(),n?.save()},"aria-label":`Event design target`,className:`mx-auto flex w-full max-w-lg flex-col gap-4 bg-po-panel p-5 font-sans text-base text-po-text`,children:[y(`header`,{children:[f(`h1`,{className:`text-xl font-semibold text-po-hi`,children:c?`Edit event`:`New event`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Scheduled work, handled by Po.`})]}),y(`div`,{className:`flex flex-col gap-1.5`,children:[f(P,{htmlFor:`event-title`,children:`Title`}),f(K,{id:`event-title`,defaultValue:n?void 0:`Prepare release notes`,value:n?.fields.title,onChange:e=>n?.set(`title`,e.target.value),required:!0})]}),n?.execution?y(`p`,{className:`text-sm text-po-dim`,children:[n.execution,` (read-only)`]}):y(`div`,{className:`flex flex-col gap-1.5`,children:[f(P,{htmlFor:`event-prompt`,children:`What should Po do?`}),f(h,{id:`event-prompt`,rows:3,defaultValue:n?void 0:`Review changes since the last release and draft concise release notes. Ask before publishing.`,value:n?.fields.prompt,onChange:e=>n?.set(`prompt`,e.target.value),required:!0})]}),n?.assignment?y(`p`,{className:`text-sm text-po-dim`,children:[`Agent setup (read-only): `,n.assignment]}):null,y(`fieldset`,{children:[f(`legend`,{className:`mb-2 font-medium text-po-hi`,children:`Belongs to`}),f(r,{value:l,onValueChange:d,children:f(u,{"aria-label":`Event owner level`,children:(n?[n.owner]:[`Session`,`Workspace`,`Global`]).map(e=>f(C,{value:e,children:e},e))})}),f(`p`,{className:`mt-2 text-sm text-po-dim`,children:l===`Session`?e.session:l===`Workspace`?`${e.workspace} workspace`:`Available across workspaces on this host`})]}),y(`fieldset`,{className:`flex flex-col gap-3`,children:[f(`legend`,{className:`mb-2 font-medium text-po-hi`,children:`Schedule`}),f(r,{value:v,onValueChange:e=>{m(e),n?.set(`kind`,e)},children:f(u,{"aria-label":`Schedule type`,children:[`Once`,`Interval`,`Cron`].map(e=>f(C,{value:e,children:e},e))})}),v===`Once`?y(`div`,{className:`grid grid-cols-2 gap-3`,children:[y(`div`,{children:[f(P,{htmlFor:`event-date`,children:`Date`}),f(K,{className:`mt-1 w-full`,id:`event-date`,type:`date`,defaultValue:n?void 0:`2026-10-22`,value:n?.fields.date,onChange:e=>n?.set(`date`,e.target.value),required:!0})]}),y(`div`,{children:[f(P,{htmlFor:`event-time`,children:`Time`}),f(K,{className:`mt-1 w-full`,id:`event-time`,type:`time`,defaultValue:n?void 0:`14:30`,value:n?.fields.time,onChange:e=>n?.set(`time`,e.target.value),required:!0})]})]}):v===`Interval`?y(`div`,{children:[f(P,{htmlFor:`event-interval`,children:`Every (seconds)`}),f(K,{className:`mt-1 w-full`,id:`event-interval`,type:`number`,min:30,max:3600,defaultValue:n?void 0:300,value:n?.fields.seconds,onChange:e=>n?.set(`seconds`,e.target.value)}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`30 to 3,600 seconds. First run starts now.`})]}):y(`div`,{children:[f(P,{htmlFor:`event-cron`,children:`Cron expression`}),f(K,{className:`mt-1 font-mono`,id:`event-cron`,defaultValue:n?void 0:`0 9 * * 1-5`,value:n?.fields.expr,onChange:e=>n?.set(`expr`,e.target.value)}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Every weekday at 09:00.`})]}),y(`div`,{children:[f(P,{htmlFor:`event-timezone`,children:`Timezone`}),f(K,{className:`mt-1 w-full`,id:`event-timezone`,defaultValue:n?void 0:e.timezone,value:n?.fields.tz,onChange:e=>n?.set(`tz`,e.target.value)})]}),s||n?.error?f(`p`,{role:`alert`,className:`text-sm text-po-red`,children:n?.error??`Choose a time in the future. Your event has not been saved.`}):null]}),y(`fieldset`,{children:[f(`legend`,{className:`mb-2 font-medium text-po-hi`,children:`Run in`}),f(r,{value:b,onValueChange:e=>{_(e),n?.set(`targetKind`,e)},children:f(u,{"aria-label":`Event target`,children:[`New session`,`Existing session`].map(e=>f(C,{value:e,children:e},e))})}),y(`div`,{className:`mt-3`,children:[f(P,{htmlFor:`event-target`,children:b===`New session`?`Workspace`:`Session`}),n?y(`select`,{"aria-label":`Event target`,className:`w-full rounded border border-po-border bg-po-panel p-2`,value:n.fields.targetId,onChange:e=>n.set(`targetId`,e.target.value),children:[f(`option`,{value:``,children:`Choose a target`}),n.choices.map(e=>f(`option`,{value:e.id,children:e.name},e.id))]}):f(t,{className:`mt-1 w-full justify-start`,id:`event-target`,children:b===`New session`?e.workspace:e.session})]}),f(`p`,{className:`mt-2 text-sm text-po-dim`,children:b===`New session`?`A fresh session each run. Workflow sessions stay open.`:`Po wakes this session if it is asleep, then delivers your prompt.`})]}),f(`p`,{className:`text-sm text-po-dim`,children:`If Po is offline, the missed run is skipped. No catch-up burst.`}),y(`footer`,{className:`flex justify-end gap-2 border-t border-po-border pt-4`,children:[f(t,{variant:`ghost`,onClick:()=>n?.close(),children:`Cancel`}),f(t,{type:`submit`,variant:`primary`,disabled:n?.busy,children:c?`Save changes`:`Schedule event`})]})]})}function Le({model:e,sessionId:n,openSession:r}){return y(o,{children:[e.error?f(`p`,{role:`alert`,className:`text-po-red`,children:e.error}):null,e.editor?f(E,{open:!0,onOpenChange:t=>{!t&&!e.busy&&e.editor?.close()},children:y(_,{className:`max-h-[90vh] overflow-y-auto`,"aria-describedby":void 0,children:[f(j,{className:`sr-only`,children:e.editing===`new`?`New event`:`Edit event`}),f(Ie,{fixture:e.data,editor:e.editor,edit:e.editing!==`new`})]})}):null,e.history?f(E,{open:!0,onOpenChange:t=>{t||e.closeHistory()},children:y(_,{"aria-describedby":void 0,children:[f(O,{dismissible:!0,closeLabel:`Close history`,children:y(j,{className:`min-w-0 truncate text-base`,children:[`History: `,e.history.event.title]})}),y(s,{children:[e.history.items.length===0?f(`p`,{className:`text-po-dim`,children:`No runs yet.`}):null,e.history.items.map(i=>y(`div`,{className:`flex flex-col gap-1 border-b border-po-border-soft pb-3 last:border-b-0`,children:[y(`p`,{children:[new Date(i.dueAt).toLocaleString(),` · `,i.state]}),i.error?f(`p`,{className:`text-sm text-po-dim`,children:i.error}):null,i.summary?f(`p`,{className:`text-sm text-po-dim`,children:i.summary}):null,i.workflowRun?y(`p`,{className:`break-words text-sm text-po-dim`,children:[`Workflow launch: `,JSON.stringify(i.workflowRun)]}):null,i.skippedCount?y(`p`,{className:`text-sm text-po-dim`,children:[`Skipped: `,i.skippedCount]}):null,i.sessionId&&r?f(t,{size:`sm`,variant:`secondary`,className:`self-start`,onClick:()=>{e.closeHistory(),r(xe(i.sessionId,n))},children:`Open run session`}):null]},i.id))]}),e.history.cursor?f(ee,{children:f(t,{disabled:e.busy,onClick:e.moreHistory,children:`More history`})}):null]})}):null]})}function Re(e,t){let n=e=>e.projectedDueAt??e.nextDueAt??e.updatedAt;return[...e.map(e=>({...e,place:`cloud`})),...t.map(e=>({...e,place:`local`}))].sort((e,t)=>n(e)-n(t))}function ze(e,t,n){return{...e,busy:e.busy||t.busy,create:()=>t.create(),retry:()=>{e.retry(),t.retry()},event:(r,i)=>(n(i)?t:e).event(r,i)}}var Be=[[`open`,`Active or paused`],[`active`,`Active`],[`paused`,`Paused`],[`done`,`Done`],[`cancelled`,`Cancelled`],[`all`,`Any status`]],Ve=[[`all`,`Any schedule`],[`once`,`Once`],[`interval`,`Interval`],[`cron`,`Cron`]],He=[[`month`,`Month`],[`week`,`Week`],[`agenda`,`Agenda`]],Ue=3;function We({label:t,value:n,options:r,onChange:i}){return y(k,{value:n,onValueChange:i,children:[f(q,{"aria-label":t,className:`h-8 min-w-0 md:w-44`,children:f(U,{})}),f(M,{children:r.map(([t,n])=>f(e,{value:t,children:n},t))})]})}var Ge=e=>e.charAt(0).toUpperCase()+e.slice(1);function Ke({event:e,open:n,onOpen:r}){return y(`li`,{className:`flex items-start gap-3`,children:[f(`span`,{className:`w-12 shrink-0 pt-2.5 font-mono text-sm text-po-dim`,children:e.time}),f(`div`,{className:`min-w-0 flex-1`,children:y(t,{size:`card`,variant:`subtle`,"aria-pressed":n,onClick:r,children:[y(`span`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[y(`span`,{className:`flex min-w-0 items-center gap-2`,children:[e.profile?f(p,{name:e.profile,size:`sm`}):null,f(`span`,{className:`font-semibold text-po-hi`,children:e.title})]}),f(b,{tone:e.status===`done`?`ok`:`neutral`,className:`text-po-dim`,children:Ge(e.status)})]}),y(`span`,{className:`text-sm text-po-dim`,children:[e.schedule,` · `,e.target]}),f(`span`,{className:`text-sm text-po-dim`,children:e.owner})]})})]})}function qe({event:e,when:n,back:r,actions:i,runs:a,onAsk:o,onBack:s}){let[c,u]=W(``),[d,p]=W(!1),[m,g]=W(``),[_,v]=W(`Copy event id`),x=()=>{(navigator.clipboard?.writeText(e.id)??Promise.reject(Error(`No clipboard`))).then(()=>v(`Event id copied`),()=>v(`Copy failed, select the id instead`))},S=e.status===`cancelled`||e.status===`done`,C=i?.busy||d,w=t=>{t.preventDefault(),o&&c.trim()&&!d&&(p(!0),g(``),o(e.id,c.trim()).then(()=>u(``),e=>g(e instanceof Error?e.message:String(e))).finally(()=>p(!1)))},T=[[`This run`,n],[`Schedule`,e.schedule],[`Runs in`,e.target],[`Owner`,e.owner],[`Agent`,e.profile],[`Runs`,e.execution],[`Managed by`,e.source]],E=a?.id===e.id?a:void 0;return y(`div`,{className:`flex flex-col gap-4`,children:[y(t,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:s,children:[f(B,{className:`size-4`,"aria-hidden":`true`}),r]}),y(`div`,{className:`flex flex-col gap-2`,children:[y(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`h2`,{className:`text-xl font-semibold text-po-hi`,children:e.title}),f(b,{tone:e.status===`done`?`ok`:`neutral`,className:`text-po-dim`,children:Ge(e.status)})]}),y(`div`,{className:`flex items-center gap-1 text-sm text-po-dim`,children:[`Event id`,f(`code`,{className:`rounded bg-po-panel px-1.5 py-0.5 font-mono text-po-text`,children:e.id}),f(t,{variant:`ghost`,size:`icon`,"aria-label":_,title:_,onClick:x,children:f(l,{className:`size-4`,"aria-hidden":`true`})})]})]}),f(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm`,children:T.map(([e,t])=>t?y(`div`,{className:`contents`,children:[f(`dt`,{className:`text-po-dim`,children:e}),f(`dd`,{className:`min-w-0 break-words text-po-text`,children:t})]},e):null)}),y(`section`,{"aria-label":`Prompt`,className:`flex flex-col gap-1`,children:[f(`h3`,{className:`font-semibold text-po-hi`,children:`Prompt`}),f(`p`,{className:`rounded bg-po-panel p-2 text-sm whitespace-pre-wrap`,children:e.prompt})]}),y(`section`,{"aria-label":`Recent runs`,className:`flex flex-col gap-1 text-sm`,children:[f(`h3`,{className:`text-base font-semibold text-po-hi`,children:`Recent runs`}),E?E.error?f(`p`,{className:`text-po-dim`,children:E.error}):E.items.length===0?f(`p`,{className:`text-po-dim`,children:`No runs yet`}):f(`ul`,{className:`flex flex-col gap-0.5`,children:E.items.map(e=>y(`li`,{children:[e.at,` · `,e.state,e.note?y(`span`,{className:`text-po-dim`,children:[` · `,e.note]}):null]},e.id))}):f(`p`,{className:`text-po-dim`,children:`Loading runs…`}),f(t,{variant:`link`,size:`xs`,className:`self-start px-0`,disabled:C,onClick:()=>i?.event(`history`,e.id),children:`View all history`})]}),o&&!S&&!e.source?y(`form`,{onSubmit:w,className:`flex flex-col gap-1`,children:[f(`label`,{htmlFor:`ask-${e.id}`,className:`font-semibold text-po-hi`,children:`Ask Po to change this event`}),y(`div`,{className:`relative`,children:[f(h,{id:`ask-${e.id}`,rows:3,maxLength:2e3,className:`w-full pr-10`,placeholder:`e.g. Move this to 10:00 and skip Fridays`,value:c,disabled:d,onChange:e=>u(e.target.value)}),f(t,{type:`submit`,variant:`primary`,size:`icon-md`,"aria-label":`Ask Po`,className:`absolute right-1.5 bottom-1.5 rounded-full`,disabled:C||!c.trim(),children:f(G,{className:`size-4`,"aria-hidden":`true`})})]}),f(`p`,{className:`text-sm text-po-dim`,role:m?`alert`:void 0,children:m||(d?`Starting a session…`:`Po changes this event in a new session and opens it for you.`)})]}):null,S?null:y(`div`,{className:`flex flex-wrap gap-2`,children:[f(t,{variant:`primary`,size:`sm`,disabled:C,onClick:()=>i?.event(`runNow`,e.id),children:`Run now`}),e.source?null:f(t,{size:`sm`,disabled:C,onClick:()=>i?.event(`edit`,e.id),children:`Edit`}),f(t,{size:`sm`,disabled:C,onClick:()=>i?.event(`pause`,e.id),children:e.status===`paused`?`Resume`:`Pause`}),f(t,{size:`sm`,variant:`ghost`,disabled:C,onClick:()=>i?.event(`cancel`,e.id),children:`Cancel event`})]})]})}function Je({mode:e,cells:n,open:r,onOpen:i,...a}){let[s,c]=W(``),l=n.find(e=>e.key===s)??n.find(e=>e.today)??n.find(e=>!e.outside)??n[0],u=(e,t=``)=>{c(e),i(t)},d=l?.events.find(e=>e.id===r);return y(`div`,{className:`flex min-h-0 flex-1 flex-col lg:flex-row`,children:[y(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[f(`div`,{className:`grid grid-cols-7 border-b border-po-border-soft`,"aria-hidden":`true`,children:n.slice(0,7).map(e=>f(`span`,{className:`py-2 text-center text-sm text-po-dim`,children:e.weekday},e.key))}),f(`div`,{className:`grid grid-cols-7`,children:n.map(n=>{let i=e===`month`?n.events.slice(0,Ue):n.events,a=n.events.length-i.length;return y(`section`,{"aria-label":n.label,className:`flex min-w-0 flex-col gap-1 border-r border-b border-po-border-soft p-1.5 ${e===`week`?`min-h-96`:`min-h-28`} ${n.key===l?.key?`bg-po-deep/50`:``}`,children:[f(`button`,{type:`button`,"aria-label":n.label,"aria-pressed":n.key===l?.key,onClick:()=>u(n.key),className:`flex size-6 cursor-pointer items-center justify-center rounded-full text-sm outline-none focus-visible:ring-2 focus-visible:ring-po-green/50 ${n.today?`bg-po-green font-semibold text-po-rail`:n.outside?`text-po-faint hover:bg-po-panel`:`text-po-hi hover:bg-po-panel`}`,children:n.day}),i.map(e=>y(t,{size:`card`,variant:`subtle`,"aria-pressed":n.key===l?.key&&e.id===r,className:`gap-0 bg-po-panel px-1.5 py-1 text-sm`,onClick:()=>u(n.key,e.id),children:[y(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5`,children:[f(`span`,{className:`shrink-0 font-mono text-po-dim`,children:e.time}),f(`span`,{className:`line-clamp-2 font-semibold break-words text-po-hi`,children:e.title})]}),y(`span`,{className:`flex min-w-0 items-center justify-between gap-1 text-po-dim`,children:[y(`span`,{className:`flex min-w-0 items-center gap-1`,children:[e.profile?f(p,{name:e.profile,size:`sm`}):null,f(`span`,{className:`truncate`,children:e.owner.split(` · `).at(-1)})]}),e.status===`Scheduled`?null:f(`span`,{className:`shrink-0`,children:Ge(e.status)})]})]},e.id)),a>0?y(t,{size:`xs`,variant:`ghost`,className:`self-start`,onClick:()=>u(n.key),children:[a,` more`]}):null]},n.key)})})]}),l?f(`aside`,{"aria-label":d?d.title:l.label,className:`flex min-h-0 flex-col gap-3 overflow-y-auto border-t border-po-border-soft px-4 py-3 lg:border-t-0 lg:border-l ${d?`lg:w-96`:`lg:w-80`}`,children:d?f(qe,{event:d,when:`${l.label}, ${d.time}`,back:`Back to ${l.label}`,onBack:()=>i(``),...a},d.id):y(o,{children:[y(`div`,{children:[f(`h2`,{className:`text-lg font-semibold text-po-hi`,children:l.label}),f(`p`,{className:`text-sm text-po-dim`,children:l.events.length===0?`Nothing scheduled`:`${l.events.length} scheduled ${l.events.length===1?`event`:`events`}`})]}),f(`ol`,{className:`flex flex-col gap-2`,children:l.events.map(e=>f(Ke,{event:e,open:!1,onOpen:()=>i(e.id)},e.id))})]})}):null]})}function Ye({days:e,total:n,matched:a=n,onMore:s,filters:c,workspaces:l,timezone:d,state:p=`populated`,mode:h=`agenda`,period:g,cells:_=[],actions:v,runs:b,onAsk:S,onOpen:T,onFilters:E,onMode:D,onMove:O,onClose:k,initialOpen:A=``,children:ee}){let[j,M]=W(A),N=e=>{M(e),e&&T?.(e)},P={actions:v,runs:b,onAsk:S},F=e.find(e=>e.events.some(e=>e.id===j)),I=F?.events.find(e=>e.id===j),L=h===`agenda`?e.reduce((e,t)=>e+t.events.length,0):new Set(_.flatMap(e=>e.events.map(e=>e.id))).size,R=c.query!==X.query||c.workspace!==X.workspace||c.status!==X.status||c.kind!==X.kind,z=e=>E?.({...c,...e});return y(`section`,{"aria-label":`Calendar`,className:`flex h-full min-h-0 w-full flex-col bg-po-rail font-sans text-base text-po-text`,children:[y(`header`,{className:`flex items-start justify-between gap-3 border-b border-po-border px-4 py-3`,children:[y(`div`,{className:`min-w-0`,children:[f(`h1`,{className:`text-xl font-semibold text-po-hi`,children:`Calendar`}),y(`p`,{className:`truncate text-sm text-po-dim`,children:[`All workspaces · Times in `,d]})]}),y(`div`,{className:`flex shrink-0 items-center gap-1`,children:[f(t,{variant:`primary`,disabled:v?.busy,onClick:()=>v?.create(),children:`New event`}),k?f(t,{variant:`ghost`,size:`icon`,"aria-label":`Close calendar`,onClick:k,children:f(x,{className:`size-4`})}):null]})]}),y(`div`,{className:`flex flex-col gap-2 border-b border-po-border-soft px-4 py-3 md:flex-row md:items-center`,children:[y(`div`,{className:`relative min-w-0 flex-1`,children:[f(m,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-po-faint`}),f(K,{type:`search`,"aria-label":`Search events`,className:`w-full pl-8`,placeholder:`Search events`,value:c.query,onChange:e=>z({query:e.target.value})})]}),y(`div`,{className:`grid grid-cols-3 gap-2 md:flex`,children:[f(We,{label:`Workspace`,value:c.workspace,options:[[`all`,`All workspaces`],...l.map(e=>[e.id,e.name])],onChange:e=>z({workspace:e})}),f(We,{label:`Status`,value:c.status,options:Be,onChange:e=>z({status:e})}),f(We,{label:`Schedule`,value:c.kind,options:Ve,onChange:e=>z({kind:e})})]})]}),y(r,{value:h,onValueChange:e=>D?.(e),className:`flex min-h-0 flex-1 flex-col`,children:[y(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-po-border-soft px-4 py-2`,children:[h===`agenda`?null:y(o,{children:[f(t,{variant:`ghost`,size:`icon-md`,"aria-label":`Previous ${h}`,onClick:()=>O?.(-1),children:f(i,{className:`size-4 rotate-180`})}),f(`h2`,{"aria-live":`polite`,className:`min-w-36 text-center text-lg font-semibold text-po-hi`,children:g}),f(t,{variant:`ghost`,size:`icon-md`,"aria-label":`Next ${h}`,onClick:()=>O?.(1),children:f(i,{className:`size-4`})}),f(t,{size:`sm`,variant:`subtle`,onClick:()=>O?.(0),children:`Today`})]}),y(`output`,{className:`text-sm text-po-dim`,children:[L,` of `,a,` `,a===1?`event`:`events`]}),s?f(t,{size:`sm`,variant:`subtle`,disabled:v?.busy,onClick:s,children:`Load more`}):null,R?f(t,{size:`sm`,variant:`ghost`,onClick:()=>E?.(X),children:`Clear filters`}):a<n?f(t,{size:`sm`,variant:`ghost`,onClick:()=>z({status:`all`}),children:`Show finished events`}):null,f(u,{"aria-label":`Calendar view`,className:`ml-auto`,children:He.map(([e,t])=>f(C,{value:e,children:t},e))})]}),y(w,{value:h,className:`flex min-h-0 flex-col`,children:[ee,p===`populated`&&h!==`agenda`?f(Je,{mode:h,cells:_,open:j,onOpen:N,...P},g):y(`div`,{className:`flex min-h-0 flex-1 flex-col lg:flex-row`,children:[f(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-3`,children:p===`loading`?f(`output`,{className:`py-6 text-po-dim`,children:`Loading your schedule…`}):p===`error`?y(`div`,{role:`alert`,className:`rounded border border-po-edge-red p-3`,children:[f(`p`,{className:`text-po-red`,children:`Calendar could not load.`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Your saved events are unchanged. Try again when the host is reachable.`}),f(t,{className:`mt-3`,variant:`outline`,onClick:()=>v?.retry(),children:`Try again`})]}):n===0?f(H,{title:`Nothing scheduled`,description:`Leave a prompt for later. Po will take it from here.`}):e.length===0?f(H,{title:`No events match`,description:R?`Try another search, or clear the filters.`:`Nothing is active or paused. Finished and cancelled events are hidden.`}):e.map(e=>y(`section`,{"aria-label":e.label,className:`flex flex-col gap-2`,children:[f(`h2`,{className:`text-sm font-semibold text-po-hi`,children:e.label}),f(`ol`,{className:`flex flex-col gap-2`,children:e.events.map(e=>f(Ke,{event:e,open:j===e.id,onOpen:()=>N(j===e.id?``:e.id)},e.id))})]},e.label))}),p===`populated`&&F&&I?f(`aside`,{"aria-label":I.title,className:`flex min-h-0 flex-col overflow-y-auto border-t border-po-border-soft px-4 py-3 lg:w-96 lg:border-t-0 lg:border-l`,children:f(qe,{event:I,when:`${F.label}, ${I.time}`,back:`Back to agenda`,onBack:()=>N(``),...P},I.id)}):null]})]})]}),f(`footer`,{className:`border-t border-po-border px-4 py-2 text-sm text-po-dim`,children:`Sleeping sessions wake for their event. Missed runs are skipped.`})]})}var Xe=3,Ze=e=>({id:e.id,at:new Date(e.dueAt).toLocaleString(void 0,{weekday:`short`,day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`}),state:e.state.charAt(0).toUpperCase()+e.state.slice(1),note:e.error??e.summary??(e.skippedCount?`${e.skippedCount} skipped`:void 0)});function Qe(e){return se(ce,{scopes:J,basePath:`calendar`,transport:(t,n)=>e?te(S).fetch(t,n):Promise.reject(Error(`This Po is not signed in to Po Cloud.`)),sessionAddress:L})}function $e({openSession:e,poCloud:t}){let[n]=W(Date.now),[r,i]=W(`month`),[a,o]=W(n),s=r===`agenda`?void 0:ye(r,a),l=Intl.DateTimeFormat().resolvedOptions().timeZone,[u,p]=W(X),[m,h]=W(u);d(()=>{let e=setTimeout(()=>h(u),250);return()=>clearTimeout(e)},[u]);let g=s&&{from:s.from,to:s.to,tz:l},_=le(),v=De(Y,``,`page`,g,ue(m),_),b=t!==void 0,x=c(()=>Qe(b),[b]),C=De(x,``,`page`,g,ue(m),_),w=b&&C.state===`populated`,T=b,E=w?Re(C.events,v.events):v.events.map(e=>({...e,place:`local`})),D=e=>w&&C.events.some(t=>t.id===e)?C:v,O=e=>D(e)===C?x:Y,[k,A]=W(``),[ee,j]=W();d(()=>{if(!k)return;let e=!0;return(w&&C.events.some(e=>e.id===k)?x:Y).host.history({params:{id:k}}).then(e=>{if(!e.ok)throw Error(e.error||`Runs could not load.`);return{id:k,items:e.data.occurrences.slice(0,Xe).map(Ze)}}).catch(e=>({id:k,items:[],error:e instanceof Error?e.message:String(e)})).then(t=>e&&j(t)),()=>{e=!1}},[k,v.events,C.events,w,x]);let M=e&&(async(t,n)=>{let r=D(t)===C,i=await O(t).host.ask({params:{id:t},body:{request:n}});if(!i.ok)throw Error(i.error||`Po could not start the change.`);e(r?`${S}/${i.data.sessionId}`:i.data.sessionId)}),N=e=>{let n=Ee(e),r=e.place===`cloud`?C.targets:v.targets,i=e.target.kind===`existingSession`?e.target.sessionId:void 0,a=r?.sessions.find(e=>e.sessionId===i)?.name,o=fe(e,r),s=e.place===`cloud`?t?.label:`This computer`;return{...n,target:a??n.target,owner:w?`${s} · ${o}`:o}},P=T?ze(v.actions,C.actions,e=>D(e)===C):v.actions,F=w&&(v.more||C.more)?()=>{v.more?.(),C.more?.()}:v.more,I=(e,t)=>new Date(e).toLocaleDateString(void 0,t),L=s?he(E,s.days,s.to).map((e,t)=>{let i=s.days[t];return{key:String(i),day:new Date(i).getDate(),label:I(i,{weekday:`long`,day:`numeric`,month:`long`}),weekday:I(i,{weekday:`short`}),outside:r===`month`&&new Date(i).getMonth()!==new Date(a).getMonth(),today:i<=n&&n<(s.days[t+1]??s.to),events:e.map(N)}}):void 0,R=s?r===`month`?I(a,{month:`long`,year:`numeric`}):`${I(s.from,{day:`numeric`,month:`short`})} to ${I(s.days.at(-1),{day:`numeric`,month:`short`,year:`numeric`})}`:void 0;return y(Ye,{days:s?[]:me(E,n).map(e=>({label:e.label,events:e.events.map(N)})),total:v.total+(w?C.total:0),matched:v.matched+(w?C.matched:0),onMore:F,filters:u,workspaces:[...w?pe(C.targets):[],...pe(v.targets)],timezone:v.data.timezone,state:w&&v.state===`error`?`populated`:v.state,mode:r,period:R,cells:L,actions:P,runs:ee,onOpen:A,onAsk:M,onFilters:p,onMode:i,onMove:e=>r!==`agenda`&&o(be(r,a,e,Date.now())),children:[f(Le,{model:v,sessionId:``,openSession:e}),T?f(Le,{model:C,sessionId:`${S}/`,openSession:e}):null,b&&C.state===`error`?y(`p`,{role:`alert`,className:`text-po-red`,children:[`Po Cloud events could not load. `,C.error]}):null]})}var et=V({slot:`page`,id:`calendar`,component:$e});function tt({openPage:e,activePageId:n}){let r=n===`calendar`;return f(`div`,{className:`px-3 pt-1 group-data-[rail=desktop]/rail:p-0 group-data-[rail=elegant]/rail:p-0`,children:y(t,{variant:`ghost`,size:`lg`,"data-testid":`calendar-open`,"aria-current":r?`page`:void 0,onClick:()=>e?.(`calendar`),className:r?`w-full justify-start gap-2.5 border border-po-edge-green bg-po-tint-green px-2 text-po-hi group-data-[rail=elegant]/rail:h-9 group-data-[rail=elegant]/rail:border-0 group-data-[rail=elegant]/rail:gap-3 group-data-[rail=elegant]/rail:text-base group-data-[rail=elegant]/rail:rounded-lg group-data-[rail=elegant]/rail:bg-po-panel group-data-[rail=elegant]/rail:px-2.5 group-data-[rail=elegant]/rail:font-medium group-data-[rail=desktop]/rail:h-auto group-data-[rail=desktop]/rail:gap-3 group-data-[rail=desktop]/rail:rounded-xl group-data-[rail=desktop]/rail:border-0 group-data-[rail=desktop]/rail:px-3 group-data-[rail=desktop]/rail:py-2 group-data-[rail=desktop]/rail:text-base group-data-[rail=desktop]/rail:font-medium group-data-[rail=desktop]/rail:text-po-hi group-data-[rail=desktop]/rail:bg-po-rail`:`w-full justify-start gap-2.5 border border-transparent px-2 text-po-text group-data-[rail=elegant]/rail:h-9 group-data-[rail=elegant]/rail:border-0 group-data-[rail=elegant]/rail:gap-3 group-data-[rail=elegant]/rail:text-base group-data-[rail=elegant]/rail:rounded-lg group-data-[rail=elegant]/rail:px-2.5 group-data-[rail=elegant]/rail:font-medium group-data-[rail=elegant]/rail:hover:bg-po-panel/50 group-data-[rail=desktop]/rail:h-auto group-data-[rail=desktop]/rail:gap-3 group-data-[rail=desktop]/rail:rounded-xl group-data-[rail=desktop]/rail:border-0 group-data-[rail=desktop]/rail:px-3 group-data-[rail=desktop]/rail:py-2 group-data-[rail=desktop]/rail:text-base group-data-[rail=desktop]/rail:font-medium group-data-[rail=desktop]/rail:text-po-hi group-data-[rail=desktop]/rail:hover:bg-po-rail`,children:[f(`span`,{className:`contents group-data-[rail=desktop]/rail:grid group-data-[rail=desktop]/rail:size-8 group-data-[rail=desktop]/rail:shrink-0 group-data-[rail=desktop]/rail:place-items-center group-data-[rail=desktop]/rail:rounded-lg group-data-[rail=desktop]/rail:bg-po-rail`,children:f(I,{"aria-hidden":`true`,className:r?`size-5 text-po-green group-data-[rail=elegant]/rail:size-4 group-data-[rail=desktop]/rail:size-4`:`size-5 text-po-dim group-data-[rail=elegant]/rail:size-4 group-data-[rail=desktop]/rail:size-4`})}),`Calendar`]})})}var nt=V({slot:`rail`,id:`calendar`,component:tt});function rt({event:e,actions:n}){let r=e.status===`cancelled`||e.status===`done`;return y(`div`,{className:`mt-2 flex flex-col gap-3 rounded border border-po-border bg-po-panel p-3`,children:[e.source?y(F,{tone:`neutral`,children:[`Managed by `,e.source]}):null,f(`p`,{children:e.prompt}),e.assignment?y(`p`,{className:`text-sm text-po-dim`,children:[`Agent setup: `,e.assignment]}):null,y(`p`,{className:`text-sm text-po-dim`,children:[`Target: `,e.target,`. `,r?`This event is ${e.status}.`:`Sleeping sessions wake automatically.`]}),y(`div`,{className:`flex flex-wrap gap-2`,children:[r?null:y(o,{children:[e.source?null:f(t,{size:`sm`,onClick:()=>n?.event(`edit`,e.id),disabled:n?.busy,children:`Edit event`}),f(t,{size:`sm`,onClick:()=>n?.event(`pause`,e.id),disabled:n?.busy,children:e.status===`paused`?`Resume`:`Pause`}),f(t,{size:`sm`,onClick:()=>n?.event(`runNow`,e.id),disabled:n?.busy,children:`Run now`})]}),f(t,{size:`sm`,onClick:()=>n?.event(`history`,e.id),disabled:n?.busy,children:`History`}),r?null:f(t,{size:`sm`,variant:`danger-outline`,disabled:n?.busy,onClick:()=>n?.event(`cancel`,e.id),children:`Cancel event`})]})]})}function it({fixture:e,actions:n,children:i,initialScope:a=`Session`,state:o=`populated`,detail:s=!1}){let[c,l]=W(a),[d,p]=W(`Thu 22`),m=n?e.days[e.selectedDay??0]:d,[h,g]=W(s?`reviews`:``),_=e.events.filter(e=>n||c===`Everything`||e.owner===`Session`||c===`Workspace`&&e.owner===`Workspace`);return y(`section`,{"aria-label":`Calendar design target`,className:`mx-auto flex min-h-screen w-full max-w-lg flex-col gap-4 border-x border-po-border bg-po-rail p-4 font-sans text-base text-po-text`,children:[y(`header`,{className:`flex items-start justify-between gap-3`,children:[y(`div`,{children:[f(`h1`,{className:`text-lg font-semibold text-po-hi`,children:`Calendar`}),f(`p`,{className:`text-sm text-po-dim`,children:`Po handles it, on your schedule.`})]}),f(t,{variant:`outline`,disabled:n?.busy,onClick:()=>n?.create(),children:`New event`})]}),y(r,{value:c,onValueChange:e=>{l(e),n?.scope(e)},children:[f(u,{"aria-label":`Calendar level`,children:[`Session`,`Workspace`,`Everything`].map(e=>f(C,{value:e,children:e},e))}),[`Session`,`Workspace`,`Everything`].map(t=>f(w,{value:t,className:`mt-2 text-sm text-po-dim`,children:t===`Session`?e.session:t===`Workspace`?`${e.workspace} workspace and its sessions`:`All workspaces and sessions on this host`},t))]}),y(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`h2`,{className:`font-semibold text-po-hi`,children:e.range??`19–25 October 2026`}),f(t,{size:`sm`,variant:`ghost`,onClick:()=>{p(`Thu 22`),n?.today()},children:`Today`})]}),n?y(`div`,{className:`flex justify-between`,children:[f(t,{onClick:()=>n?.week(-1),children:`Previous week`}),f(t,{onClick:()=>n?.week(1),children:`Next week`})]}):null,f(`div`,{className:`grid grid-cols-7 gap-1`,"aria-label":`Days this week`,children:e.days.map(r=>y(t,{"aria-pressed":m===r,variant:m===r?`primary`:`ghost`,className:`h-auto flex-col px-1 py-2`,onClick:()=>{p(r),n?.day(e.days.indexOf(r)),g(``)},children:[f(`span`,{className:`text-sm`,children:r.split(` `)[0]}),f(`span`,{children:r.split(` `)[1]})]},r))}),y(`div`,{children:[f(`h2`,{className:`font-semibold text-po-hi`,children:n?m:m===`Thu 22`?`Today · Thursday 22 October`:`${m} October`}),y(`p`,{className:`mt-1 text-sm text-po-dim`,children:[`Times in `,e.timezone]})]}),i,o===`loading`?f(`output`,{className:`py-6 text-po-dim`,children:`Loading your schedule…`}):o===`error`?y(`div`,{role:`alert`,className:`rounded border border-po-edge-red p-3`,children:[f(`p`,{className:`text-po-red`,children:`Calendar could not load.`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Your saved events are unchanged. Try again when the host is reachable.`}),f(t,{className:`mt-3`,variant:`outline`,onClick:()=>n?.retry(),children:`Try again`})]}):o===`denied`?f(H,{title:`This calendar is not available`,description:`You do not have permission to view this level. Your session calendar is still available.`}):o===`empty`||n&&_.length===0||!n&&m!==`Thu 22`?f(H,{title:`Nothing scheduled`,description:`Leave a prompt for later. Po will take it from here.`}):f(`ol`,{className:`flex flex-col gap-3`,children:_.map(r=>y(`li`,{className:`flex items-start gap-3`,children:[f(`span`,{className:`w-10 shrink-0 pt-3 text-sm text-po-dim`,children:r.time}),y(`div`,{className:`min-w-0 flex-1`,children:[y(t,{size:`card`,variant:`outline`,"aria-expanded":h===r.id,onClick:()=>g(h===r.id?``:r.id),children:[y(`span`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`span`,{className:`font-semibold text-po-hi`,children:r.title}),r.status===`Scheduled`?f(b,{tone:`neutral`,className:`text-po-dim`,children:o===`blocked`&&r.id===`reviews`?`Paused`:`Scheduled`}):f(b,{tone:n?r.status===`done`?`ok`:`neutral`:o===`failed`?`error`:`ok`,children:n?r.status:o===`failed`?`Failed`:`Handled`})]}),y(`span`,{className:`text-sm text-po-dim`,children:[r.schedule,` · `,r.target]}),y(`span`,{className:`text-sm text-po-dim`,children:[r.owner,r.owner===`Global`?``:` · ${e.workspace}`]})]}),h===r.id?f(rt,{event:r,actions:n}):null]})]},r.id))}),o===`skipped`?y(`aside`,{className:`rounded border border-po-border p-3`,children:[f(F,{tone:`neutral`,children:`Skipped`}),f(`p`,{className:`mt-2`,children:`The inbox check yesterday did not run while Po was offline.`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`No catch-up burst. Next run: tomorrow at 09:00.`})]}):null,o===`blocked`?y(`aside`,{className:`rounded border border-po-edge-magenta bg-po-tint-magenta p-3`,children:[f(`p`,{className:`font-semibold text-po-magenta`,children:`Pick a session, whenever you are ready`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`The target for “Review pull requests” is no longer available. This event is paused.`}),f(t,{className:`mt-3`,variant:`secondary`,children:`Choose session`})]}):null,o===`failed`?y(`aside`,{className:`rounded border border-po-edge-red p-3`,children:[f(`p`,{className:`font-semibold text-po-red`,children:`Inbox check failed`}),f(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Po could not reach the mail service. The next scheduled run is unchanged.`}),f(t,{className:`mt-3`,children:`View run`})]}):null,f(`footer`,{className:`mt-auto border-t border-po-border pt-3 text-sm text-po-dim`,children:`Sleeping sessions wake for their event. Missed runs are skipped.`})]})}function at(e){return e.sessionId?f(ot,{sessionId:e.sessionId,openSession:e.openSession},e.sessionId):null}function ot({sessionId:e,openSession:t}){let n=De(Y,e,`panel`,void 0,void 0,le());return f(it,{fixture:n.data,actions:n.actions,state:n.state,children:f(Le,{model:n,sessionId:e,openSession:t})})}var st=ne({id:`calendar`,label:`Calendar`,icon:I,order:40,panel:at}),ct=V({slot:`help.guides`,id:`Calendar`,order:20,data:{version:1,label:`Calendar`,guides:[{id:`schedule`,question:`How do I schedule a prompt?`,order:0,answer:`Ask Po to schedule a prompt for a time, then confirm the schedule. Calendar must be selected in your home default preset, and the server must stay running.`},{id:`repeat`,question:`Can Po run something on a repeat?`,order:1,answer:`Yes. Calendar supports intervals and cron schedules with a timezone. Intervals run immediately when created. Missed runs are skipped after downtime.`}]}}),lt=[`calendar_schedule`,`calendar_list`,`calendar_cancel`,`calendar_update`,`calendar_pause`,`calendar_resume`,`calendar_run_now`,`calendar_history`,`loop_start`,`loop_list`,`loop_stop`],ut={calendar_schedule:{outcome:`Scheduled`,tone:`ok`},calendar_update:{outcome:`Updated`,tone:`ok`},calendar_resume:{outcome:`Resumed`,tone:`ok`},calendar_run_now:{outcome:`Started now`,tone:`ok`,note:`This run does not change the schedule.`},calendar_cancel:{outcome:`Cancelled`,tone:`neutral`,note:`It will not run. Past runs stay in its history.`,quiet:!0},calendar_pause:{outcome:`Paused`,tone:`neutral`,note:`Nothing runs until it is resumed.`,quiet:!0}},dt={calendar_schedule:`Not scheduled`,calendar_update:`Not updated`,calendar_cancel:`Not cancelled`,calendar_pause:`Not paused`,calendar_resume:`Not resumed`,calendar_run_now:`Did not start`,calendar_list:`Could not list events`,calendar_history:`Could not read its history`,loop_start:`Not scheduled`,loop_list:`Could not list events`,loop_stop:`Not stopped`},ft={succeeded:{label:`Done`,tone:`ok`},failed:{label:`Failed`,tone:`error`},skipped:{label:`Skipped`,tone:`neutral`},blocked:{label:`Needs a session`,tone:`accent`},queued:{label:`Queued`,tone:`neutral`},running:{label:`Running`,tone:`running`},interrupted:{label:`Interrupted`,tone:`neutral`}};function Z(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Q(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function pt(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function mt(e,t){try{return new Intl.DateTimeFormat(void 0,{...t,...e?{timeZone:e}:{}})}catch{return new Intl.DateTimeFormat(void 0,t)}}function ht(e,t){return mt(t,{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e)}function gt(e,t){return mt(t,{weekday:`short`,day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`}).format(e)}function _t(e){let[t,n]=e%3600==0?[e/3600,`hour`]:e%60==0?[e/60,`minute`]:[e,`second`];return t===1?`Every ${n}`:`Every ${t} ${n}s`}function vt(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function yt(e,t){let n=Z(e.target),r=Q(Z(e.workflow)?.key),i=Q(Z(e.action)?.launcherId),a=Q(n?.cwd),o=n?.kind===`newSession`,s=o?`new session${a?` in ${vt(a)}`:``}`:t&&Q(n?.sessionId)&&n?.sessionId!==t?`another session`:`this session`;return r?`Workflow ${r} in ${o?`a `:``}${s}`:i?`Action ${i} in ${o?`a `:``}${s}`:o?`N${s.slice(1)}`:`Prompt in ${s}`}function bt(e,t,n={}){let r=Z(e),i=Z(r?.schedule),a=Q(r?.title);if(!r||!i||!a)return;let o=Q(i.tz),s=pt(r.nextDueAt),c,l=!1;if(i.kind===`once`&&pt(i.at)!==void 0)c=ht(i.at,o);else if(i.kind===`interval`&&pt(i.seconds)!==void 0)c=_t(i.seconds);else if(i.kind===`cron`&&Q(i.expr))c=i.expr,l=!0;else return;let u=r.status===`paused`?{label:`Paused`,tone:`neutral`}:r.status===`cancelled`?{label:`Cancelled`,tone:`neutral`}:r.status===`done`?{label:`Done`,tone:`ok`}:void 0;return{title:a,when:c,...l?{cron:l}:{},...o&&i.kind!==`interval`?{zone:o}:{},...n.next!==!1&&i.kind!==`once`&&s!==void 0&&r.status===`active`?{next:gt(s,o)}:{},runs:yt(r,t),...n.prompt!==!1&&Q(r.prompt)?{prompt:r.prompt}:{},...u?{status:u}:{}}}function xt(e){let t=e.result?.details;if(t==null)return e.output;try{return JSON.stringify(t,null,2)}catch{return e.output}}function St(e,t){return e===0?`No ${t}s`:`${e} ${t}${e===1?``:`s`}`}function Ct(e){let{toolName:t,args:n,sessionId:r}=e,i=e.result?.details,a=xt(e),o=Q(n.title)??Q(Z(n.patch)?.title)??Q(Z(n.input)?.prompt)??``;if(e.running)return{tone:`running`,summary:o,details:``};if(e.isError)return{tone:`error`,summary:o,failure:{heading:dt[t]??`Calendar call failed`,detail:Q(e.output)??`Calendar gave no reason.`},...t.endsWith(`_list`)||t===`calendar_history`?{}:{note:`Nothing was saved.`},details:``};let s={tone:`ok`,summary:o,note:`This result has no summary. The details below are what Calendar returned.`,details:a},c=ut[t];if(c){let e=bt(i,r,{next:!c.quiet,prompt:!c.quiet});if(!e)return s;let{status:t,...n}=e;return{tone:c.tone,outcome:c.outcome,summary:e.title,event:n,...c.note?{note:c.note}:{},details:a}}switch(t){case`calendar_list`:{if(!Array.isArray(i))return s;let e=i.map(e=>bt(e,r,{prompt:!1})).filter(e=>e!==void 0);return{tone:`ok`,summary:St(e.length,`event`),...e.length?{events:e}:{empty:`Nothing scheduled in this session yet.`},details:a}}case`calendar_history`:{let e=Z(i)?.occurrences;if(!Array.isArray(e))return s;let t=e.flatMap(e=>{let t=Z(e),n=pt(t?.dueAt);if(!t||n===void 0)return[];let r=ft[String(t.state)]??{label:String(t.state),tone:`neutral`},i=Q(t.summary)??Q(t.error);return[{when:gt(n),...r,...i?{note:i}:{}}]});return{tone:`ok`,summary:St(t.length,`run`),...t.length?{runs:t}:{empty:`It has not run yet.`},...Q(Z(i)?.cursor)?{note:`Older runs are on the next page.`}:{},details:a}}case`loop_start`:{let e=Z(n.input),t=Z(i),r=Q(e?.cron),o=pt(e?.intervalSeconds),c=Q(e?.timezone),l=Q(t?.label)??Q(e?.prompt)??`Recurring event`;return!r&&o===void 0?{...s,outcome:`Started`,summary:l}:{tone:`ok`,outcome:`Scheduled`,summary:l,event:{title:l,when:r??_t(o),...r?{cron:!0}:{},...r&&c?{zone:c}:{},runs:`Prompt in this session`,...Q(e?.prompt)?{prompt:e?.prompt}:{}},details:a}}case`loop_list`:{let e=Z(i)?.instances;if(!Array.isArray(e))return s;let t=e.flatMap(e=>{let t=Z(e),n=Q(t?.label)??Q(t?.launcherLabel);return!t||!n?[]:[{title:n,when:Q(t.launcherLabel)??`Recurring`,runs:`This session`,...t.state===`running`?{}:{status:{label:`Stopping`,tone:`neutral`}}}]});return{tone:`ok`,summary:St(t.length,`recurring event`),...t.length?{events:t}:{empty:`Nothing recurring in this session.`},details:a}}case`loop_stop`:{let e=Z(i)?.stopped;return typeof e==`boolean`?{tone:`neutral`,outcome:e?`Stopped`:`Not found`,summary:Q(n.instanceId)??``,note:e?`It will not run again.`:`Nothing was running under that id.`,details:a}:s}default:return s}}function wt({label:e,children:t}){return y(`div`,{className:`flex gap-3`,children:[f(`dt`,{className:`w-12 shrink-0 pt-px text-sm text-po-dim`,children:e}),f(`dd`,{className:`min-w-0 flex-1 break-words text-base text-po-text`,children:t})]})}function Tt({event:e}){return y(o,{children:[e.cron?f(`code`,{className:`font-mono text-po-text`,children:e.when}):e.when,e.zone?y(`span`,{className:`text-sm text-po-dim`,children:[` · `,e.zone]}):null]})}function Et({event:e}){return y(`div`,{className:`flex flex-col gap-3`,children:[y(`dl`,{className:`flex flex-col gap-1.5`,children:[f(wt,{label:`When`,children:f(Tt,{event:e})}),e.next?f(wt,{label:`Next`,children:e.next}):null,f(wt,{label:`Runs`,children:e.runs})]}),e.prompt?f(`p`,{className:`line-clamp-3 border-l-2 border-po-border-soft pl-3 text-base break-words text-po-text`,children:e.prompt}):null]})}function Dt({event:e}){return y(`li`,{className:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`,children:[y(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[f(`span`,{className:`truncate text-base font-semibold text-po-hi`,children:e.title}),y(`span`,{className:`text-sm break-words text-po-dim`,children:[f(Tt,{event:e}),e.next?` · Next ${e.next}`:null]})]}),e.status?f(b,{tone:e.status.tone,children:e.status.label}):null]})}function Ot({run:e}){return y(`li`,{className:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`,children:[y(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[f(`span`,{className:`text-base text-po-text`,children:e.when}),e.note?f(`span`,{className:`text-sm break-words text-po-dim`,children:e.note}):null]}),f(b,{tone:e.tone,children:e.label})]})}function kt({toolName:e,fixture:t,defaultExpanded:n=!1}){let r=t.details.split(`
|
|
2
2
|
`).map(e=>({text:e,tone:`text`}));return f(re,{tone:t.tone,expandable:t.details!==``,defaultExpanded:n,children:({expanded:n})=>y(o,{children:[f(R,{title:e,badge:t.outcome,children:f(`span`,{className:`min-w-0 truncate text-po-text`,children:t.summary})}),y(z,{className:`flex flex-col gap-3`,children:[t.failure?y(`div`,{className:`flex flex-col gap-1`,children:[f(`p`,{className:`text-base font-semibold text-po-red`,children:t.failure.heading}),f(`p`,{className:`text-sm break-words text-po-dim`,children:t.failure.detail})]}):null,t.event?f(Et,{event:t.event}):null,t.events?.length?f(`ol`,{className:`flex flex-col divide-y divide-po-border-soft`,children:t.events.map(e=>f(Dt,{event:e},`${e.title}-${e.when}`))}):null,t.runs?.length?f(`ol`,{className:`flex flex-col divide-y divide-po-border-soft`,children:t.runs.map(e=>f(Ot,{run:e},e.when))}):null,t.empty?f(`p`,{className:`text-base text-po-dim`,children:t.empty}):null,t.tone===`running`?f(N,{tone:`running`,children:`Saving to your calendar`}):null,t.note?f(`p`,{className:`text-sm text-po-dim`,children:t.note}):null,t.details?y(`div`,{className:`flex flex-col gap-3 border-t border-po-border-soft pt-3`,children:[f(N,{expands:!0,glyph:n?`⌄`:`›`,className:`text-sm text-po-dim`,children:n?`Hide details`:`Show details`}),n?f(oe,{lines:r}):null]}):null]})]})})}function At(e){return f(kt,{toolName:e.toolName,fixture:Ct(e)})}var jt=T({tools:[...lt],message:At}),$=(e,t)=>t===void 0?void 0:{...e,...t},Mt=ie({id:`calendar`,packageName:`@agimon-ai/po-calendar`,host:{get fills(){return[$({slot:`dashboard-tiles`,id:`calendar`},Pe),$({slot:`home-apps`,id:`calendar`},Fe),$({slot:`page`,id:`calendar`},et),$({slot:`rail`,id:`calendar`},nt)]}},session:{get dockFaces(){return[$({id:`calendar`},st)]},get fills(){return[$({slot:`help.guides`,id:`calendar`},ct)]},get toolRenderers(){return[$({tools:[`calendar`]},jt)]}}});export{Mt as webPlugin};
|
package/dist/assets/plugins/slots/{codemode.c58fb583-BkVR1X2Y.js → codemode.ff16ac06-Dbjm7Efq.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$r as e,Da as t,Fi as n,Ft as r,It as i,Lt as a,Mi as o,Pt as s,Ra as c,Wa as l,_n as u,ea as d,gn as f,hn as p,ja as m,mn as h,qa as g,ri as _,sn as v,un as y,xi as b}from"../chunks/po-web-runtime-
|
|
1
|
+
import{$r as e,Da as t,Fi as n,Ft as r,It as i,Lt as a,Mi as o,Pt as s,Ra as c,Wa as l,_n as u,ea as d,gn as f,hn as p,ja as m,mn as h,qa as g,ri as _,sn as v,un as y,xi as b}from"../chunks/po-web-runtime-C0B3uAoC.js";var x=`codemode_background`,S=`background-scripts-stop`,C={scripts:[],stopRequested:[]};function w(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&typeof t.label==`string`&&typeof t.startedAt==`string`&&(t.status===`running`||t.status===`reporting`)}function ee(e){if(typeof e!=`object`||!e)return null;let t=e.scripts;return Array.isArray(t)?{scripts:t.filter(w)}:null}function te(e,t){let n=new Set(t.scripts.filter(e=>e.status===`running`).map(e=>e.id));return{...t,stopRequested:e.stopRequested.filter(e=>n.has(e))}}function ne(e,t){return{...e,stopRequested:[...e.stopRequested.filter(e=>e!==t),t]}}var T=c(C);function E(e,t,n){e(t,{type:`prompt`,message:`/${S} ${n}`}),T.update(t,e=>ne(e,n))}var D=T.channel({channel:x,parse:ee,reduce:te}),O=t(D);function k({sessionId:t,sendSessionFrame:n}){let r=s(T.store,e=>T.select(e,t));return r.scripts.length===0?null:i(`div`,{"data-testid":`activity-background-scripts`,className:`flex flex-col gap-0.5`,children:r.scripts.map(o=>{let s=r.stopRequested.includes(o.id);return a(`div`,{"data-testid":`activity-background-script-${o.id}`,className:`flex min-w-0 flex-col gap-0.5 rounded-md px-1 py-1`,children:[a(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[i(d,{tone:`yellow`,pulse:o.status===`running`}),i(`span`,{className:`min-w-0 flex-1 truncate text-base font-semibold text-po-hi`,children:`Background script`}),o.status===`reporting`?i(`span`,{className:`shrink-0 text-sm text-po-dim`,children:`finishing…`}):i(v,{label:`up`,since:Date.parse(o.startedAt),className:`shrink-0 text-sm text-po-dim`}),t!==null&&o.status===`running`?i(e,{variant:s?`outline`:`danger-outline`,size:`xs`,"data-testid":`activity-background-script-stop-${o.id}`,"aria-disabled":s,title:s?`stop requested; the script reports its own end`:`stop this background script`,className:`px-1.5`,onClick:()=>{s||E(n,t,o.id)},children:s?`stopping…`:`stop`}):null]}),i(`span`,{className:`truncate pl-3 font-mono text-sm text-po-dim`,children:o.label})]},o.id)})})}var A=m({order:1100,component:k}),j=`exec`,M=`discover`,N=120,P=160,re=50,ie=/^image\/(?:png|jpeg|webp|gif)$/u,ae=/^Saved as (\S+) \((.+)\)$/u,F=/^(?:#{1,6} |```)/mu;function I(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function L(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function R(e){return typeof e.code==`string`?e.code:``}function z(e){let t=R(e).split(`
|
|
2
2
|
`).map(e=>e.trim()).find(e=>e!==``);return t===void 0?`script`:L(t.replace(/^\/\/+\s*/u,``),N)}function B(e){let t=I(e);if(t===void 0||typeof t.name!=`string`||t.name===``)return;let n=I(t.result);return{name:t.name,args:I(t.args)??{},ok:t.ok!==!1,ms:typeof t.ms==`number`&&Number.isFinite(t.ms)&&t.ms>=0?Math.round(t.ms):0,...typeof t.tool==`string`&&t.tool!==``?{tool:t.tool}:{},...typeof t.error==`string`&&t.error!==``?{error:t.error}:{},...n!==void 0&&Array.isArray(n.content)?{result:{content:n.content,details:n.details}}:{}}}function V(e){let t=I(e)?.calls;return Array.isArray(t)?t.slice(0,re).map(B).filter(e=>e!==void 0):[]}function H(e){return L(Object.entries(e).map(([e,t])=>`${e}: ${typeof t==`string`?t:JSON.stringify(t)??String(t)}`).join(` · `),P)}function U(e){let t;try{t=JSON.parse(e)}catch{return e.split(`
|
|
3
3
|
`).join(` `)}let n=I(t);return n!==void 0&&Object.keys(n).length>0?H(n):L(JSON.stringify(t),P)}function W(e){if(e===null)return{lines:[],images:[]};let t,n=[],r=[];for(let i of e.content){let e=I(i);if(e?.type===`text`&&typeof e.text==`string`){let r=ae.exec(e.text.trim());r?.[1]!==void 0&&r[2]!==void 0?t={id:r[1],path:r[2]}:n.push(e.text)}else e?.type===`image`&&typeof e.data==`string`&&typeof e.mimeType==`string`&&ie.test(e.mimeType)&&r.push({mimeType:e.mimeType,data:e.data})}let i=n.join(`
|
|
4
4
|
`).replaceAll(`\r
|