decocms 4.17.2 → 4.18.0
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/client/assets/{AlertCircle-DdrwwZMq.js → AlertCircle-Cq24_c-o.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-jXBy9ipz.js → ArrowUpRight-ClwqpF9i.js} +1 -1
- package/dist/client/assets/{CheckCircle-3ZOkMXIL.js → CheckCircle-PV8cYNfz.js} +1 -1
- package/dist/client/assets/{ChevronDown-CLx4-WM1.js → ChevronDown-BcFakGFK.js} +1 -1
- package/dist/client/assets/{ChevronRight-jYKilAXW.js → ChevronRight-Bc7TkKo_.js} +1 -1
- package/dist/client/assets/{ChevronUp-BGt4chTY.js → ChevronUp-CAyCvjRf.js} +1 -1
- package/dist/client/assets/{DotsVertical-CqrNmdxL.js → DotsVertical-BZ79m9bZ.js} +1 -1
- package/dist/client/assets/{Eye-o5yQXJvl.js → Eye-CVTjrdPN.js} +1 -1
- package/dist/client/assets/{FilterLines-CDGBU4Yu.js → FilterLines-Dn-zRhq9.js} +1 -1
- package/dist/client/assets/{Globe01-CcG20jKe.js → Globe01-CINX7XLh.js} +1 -1
- package/dist/client/assets/{Globe04-Cv_V-Fs_.js → Globe04-BacMVcAF.js} +1 -1
- package/dist/client/assets/{HardDrive-BSIK0u4A.js → HardDrive-CfVRvrF-.js} +1 -1
- package/dist/client/assets/{Key01-DgIKoZGo.js → Key01-awLJepSc.js} +1 -1
- package/dist/client/assets/{LayoutLeft-Ck3c6EbZ.js → LayoutLeft-Bgn0Zg5G.js} +1 -1
- package/dist/client/assets/{LinkExternal01-C4RHyT_k.js → LinkExternal01-D60A4jNL.js} +1 -1
- package/dist/client/assets/{Monitor01-CWIDsYmm.js → Monitor01-oM90habT.js} +1 -1
- package/dist/client/assets/{Palette-BFwjtSY1.js → Palette-mFlZKLgw.js} +1 -1
- package/dist/client/assets/{Play-DqQKGu-U.js → Play-B2PQHuS4.js} +1 -1
- package/dist/client/assets/{Plus-DZiClNST.js → Plus-BDlCzerf.js} +1 -1
- package/dist/client/assets/{SearchLg-CaS6w27I.js → SearchLg-fYAuFx6T.js} +1 -1
- package/dist/client/assets/{SearchMd-CYoVQBZq.js → SearchMd-CrBda7dI.js} +1 -1
- package/dist/client/assets/{Settings02-C-6P9tLl.js → Settings02-C2Ys_yfp.js} +1 -1
- package/dist/client/assets/{Shield01-B3rvsBtl.js → Shield01-xKplN1D6.js} +1 -1
- package/dist/client/assets/{Star01-CkOKT_Ec.js → Star01-D-DX_VQ8.js} +1 -1
- package/dist/client/assets/{Stars01-sPe6wVRL.js → Stars01-BT514mww.js} +1 -1
- package/dist/client/assets/{Stars02-YL1S7hw5.js → Stars02-CvZNhXpQ.js} +1 -1
- package/dist/client/assets/{Sun-CX24eczl.js → Sun-BHmSueFc.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-1JfD3pEr.js → SwitchHorizontal01--w7jw1gn.js} +1 -1
- package/dist/client/assets/{Tool01-84S8urW1.js → Tool01-CYQXbAs9.js} +1 -1
- package/dist/client/assets/{Trash01-oru1b8W8.js → Trash01-CxMlDi9l.js} +1 -1
- package/dist/client/assets/{Upload01-Cou_1dwr.js → Upload01-DgQHfPA4.js} +1 -1
- package/dist/client/assets/{User01-BL-jdznB.js → User01-DJgqKWol.js} +1 -1
- package/dist/client/assets/{Users01-CvViXbMH.js → Users01-D_J5vhl7.js} +1 -1
- package/dist/client/assets/{Users03-B-JAgn9g.js → Users03-D7afztXh.js} +1 -1
- package/dist/client/assets/{X-D1xM7jXL.js → X-RECo41yg.js} +1 -1
- package/dist/client/assets/{XCircle-D1ibZ16t.js → XCircle-BhV8maG9.js} +1 -1
- package/dist/client/assets/{XClose-D0Zu_lRC.js → XClose-DNorGtW0.js} +1 -1
- package/dist/client/assets/{Zap-Bo8lb0F-.js → Zap-BqYKiBDY.js} +1 -1
- package/dist/client/assets/{ZapSquare-B4AjMOPu.js → ZapSquare-EaCsR4ke.js} +1 -1
- package/dist/client/assets/{ZoomOut-DfCeUHFX.js → ZoomOut-Dox0RGO8.js} +1 -1
- package/dist/client/assets/{access-gate-CRTZfiyx.js → access-gate-BqzkpTGs.js} +1 -1
- package/dist/client/assets/{add-section-modal-t6NTp3dt.js → add-section-modal-D8dP-fUX.js} +1 -1
- package/dist/client/assets/{agent-capabilities-BDCwG9Eh.js → agent-capabilities-BOrZcw_f.js} +1 -1
- package/dist/client/assets/{agent-icon-C1BWispo.js → agent-icon-BtQxKV8a.js} +1 -1
- package/dist/client/assets/agents-list-rt-kO67C.js +4 -0
- package/dist/client/assets/{ai-providers-D8gEIycW.js → ai-providers-D7u6tgs7.js} +1 -1
- package/dist/client/assets/{alert-DAyg3TSF.js → alert-DOHmFwqn.js} +1 -1
- package/dist/client/assets/{alert-dialog-ha1v59qY.js → alert-dialog-Bxo_MYXk.js} +1 -1
- package/dist/client/assets/{app-editor-3RKJRSU7.js → app-editor-BKBuOXj4.js} +1 -1
- package/dist/client/assets/{auth-ou2428Bw.js → auth-CoT0O1Wo.js} +1 -1
- package/dist/client/assets/{auth-catchall-B-EHVfUd.js → auth-catchall-ChVzL55k.js} +1 -1
- package/dist/client/assets/{auth-entry-BFuuwZkf.js → auth-entry-Db3UMJC5.js} +1 -1
- package/dist/client/assets/{auth-split-layout-lfv3bwPm.js → auth-split-layout-cO2rT7g9.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-B3lWqExf.js → authenticate-and-persist-oauth-DGhgmpvt.js} +1 -1
- package/dist/client/assets/{automation-list-row-DUKMiAFn.js → automation-list-row-jcSA7dBx.js} +1 -1
- package/dist/client/assets/{automation-runs-HEfBB2IO.js → automation-runs-BaCQBHoa.js} +1 -1
- package/dist/client/assets/{automations-DcVo9aht.js → automations-CaKdnRJs.js} +1 -1
- package/dist/client/assets/{avatar-tYV7Xj5e.js → avatar-AaGlLABb.js} +1 -1
- package/dist/client/assets/{badge-DjU6bfHE.js → badge-C8xW1-Ny.js} +1 -1
- package/dist/client/assets/{block-document-CYnqjTQ5.js → block-document-OGoLVzGT.js} +2 -2
- package/dist/client/assets/{brand-context-D5KhJzF5.js → brand-context-DFabWIkO.js} +1 -1
- package/dist/client/assets/{breadcrumb-C_jNPElt.js → breadcrumb-Brp587yT.js} +1 -1
- package/dist/client/assets/{buckets-Bi6Dz7dc.js → buckets-DpneL_2_.js} +1 -1
- package/dist/client/assets/{bulk-category-panel-CQyTVuMJ.js → bulk-category-panel-CyzC_SX4.js} +1 -1
- package/dist/client/assets/{capability-load-error-B4T1DTOe.js → capability-load-error-BQZI9LLJ.js} +1 -1
- package/dist/client/assets/{card-BcWpe7XA.js → card-B9yAYcf2.js} +1 -1
- package/dist/client/assets/{category-editor-CHiWWzkP.js → category-editor-CZFJWDUa.js} +1 -1
- package/dist/client/assets/{chat-context-BXvC8snN.js → chat-context-Bd0ASrBV.js} +1 -1
- package/dist/client/assets/{checkbox-BGLrFwOD.js → checkbox-ChtxvVCl.js} +1 -1
- package/dist/client/assets/{cli-auth-success-SPj5zX1c.js → cli-auth-success-v9Qf_Z1z.js} +1 -1
- package/dist/client/assets/collection-detail-Ct0q9TWA.js +1 -0
- package/dist/client/assets/{collection-display-button-AdaNOeng.js → collection-display-button-ghx1fRrz.js} +1 -1
- package/dist/client/assets/{collection-search-BWPhJb0W.js → collection-search-qo9IZJLR.js} +1 -1
- package/dist/client/assets/collection-table-wrapper-D06hXFYs.js +1 -0
- package/dist/client/assets/{collection-tabs-LbK97vzL.js → collection-tabs-D8PDp1vW.js} +1 -1
- package/dist/client/assets/{command-BrahLBH2.js → command-DOtqEIF_.js} +1 -1
- package/dist/client/assets/{commerce-onboarding-BY8ZIbvj.js → commerce-onboarding-CQvkKr_A.js} +1 -1
- package/dist/client/assets/{connect-desktop-dialog-wN68EGmx.js → connect-desktop-dialog-BdgVHbLH.js} +1 -1
- package/dist/client/assets/{connection-card-CS0ZRcyq.js → connection-card-CrD4DNgk.js} +1 -1
- package/dist/client/assets/{connection-detail-6cGe5AzW.js → connection-detail-DgPAS7XR.js} +1 -1
- package/dist/client/assets/{connection-form-helpers--RFzi4SS.js → connection-form-helpers-OWEpNePK.js} +1 -1
- package/dist/client/assets/{connections-BM_4XV1f.js → connections-CEmlAedS.js} +1 -1
- package/dist/client/assets/{decopilot-DitDP2XU.js → decopilot-DsMsc6aJ.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-DrXwOdO1.js → decopilot-sse-pool-BJzLmyeL.js} +1 -1
- package/dist/client/assets/{dialog-DaSKz7DM.js → dialog-B1eqTnf8.js} +1 -1
- package/dist/client/assets/{domain-settings-BssGRdmx.js → domain-settings-nPsYb5Fu.js} +1 -1
- package/dist/client/assets/{drawer-DdiW0TLs.js → drawer-HScIqfkZ.js} +1 -1
- package/dist/client/assets/{dropdown-menu-5pJpeeqf.js → dropdown-menu-BQUhOJKy.js} +1 -1
- package/dist/client/assets/{empty-state-B08-kVr_.js → empty-state-Dy6CNQJG.js} +1 -1
- package/dist/client/assets/{extract-connection-data-X711B5tE.js → extract-connection-data-MlduhWsI.js} +1 -1
- package/dist/client/assets/{file-explorer-CXo4_clT.js → file-explorer-CZAYIvIV.js} +2 -2
- package/dist/client/assets/{file-type-icon-Cm6D0wrz.js → file-type-icon-Bhag_euH.js} +1 -1
- package/dist/client/assets/{files-K9oI8c_-.js → files-uKwT7dMn.js} +1 -1
- package/dist/client/assets/{form-D1efg8C-.js → form-UVWmiPtA.js} +1 -1
- package/dist/client/assets/{general-BSA7tAJi.js → general-BT7ritMF.js} +1 -1
- package/dist/client/assets/github-repo-picker-Hp8ibQdT.js +1 -0
- package/dist/client/assets/{hooks-BgBnOJ3c.js → hooks-BkWjlB2G.js} +1 -1
- package/dist/client/assets/{index-C3i4LyhT.js → index-B1vu2Nbj.js} +1 -1
- package/dist/client/assets/{index-D9Jl2teh.js → index-BCQZbPeH.js} +3 -3
- package/dist/client/assets/{index-YOEpEUyS.js → index-BeAkwX8F.js} +1 -1
- package/dist/client/assets/{index-D3ZbfB7L.js → index-BspaoAFJ.js} +1 -1
- package/dist/client/assets/{index-DikJYrmI.js → index-C0RJqF7u.js} +1 -1
- package/dist/client/assets/{index-Da2BgJQV.js → index-CEZz0ndn.js} +1 -1
- package/dist/client/assets/{index-B96RsdAE.js → index-Cfi3HlHz.js} +1 -1
- package/dist/client/assets/index-Cnn6tTYH.css +1 -0
- package/dist/client/assets/{index-YqfRemtU.js → index-Cv2lqoTf.js} +5 -5
- package/dist/client/assets/{index-BtaxzVR0.js → index-D92tuiTs.js} +1 -1
- package/dist/client/assets/{index-cif87MVR.js → index-DihMtjYK.js} +1 -1
- package/dist/client/assets/{index-pn1YPMKj.js → index-Dutd3Lw0.js} +1 -1
- package/dist/client/assets/{index-qfheH9Xc.js → index-Fhr28YR7.js} +3 -3
- package/dist/client/assets/index-Q1C-CIMU.js +1 -0
- package/dist/client/assets/{index-redirect-DdgddsNH.js → index-redirect-Cx_VgwfS.js} +1 -1
- package/dist/client/assets/{input-c3bkJxBD.js → input-pJMroKkw.js} +1 -1
- package/dist/client/assets/{integration-icon-DsTjAPrY.js → integration-icon-GqCugUan.js} +1 -1
- package/dist/client/assets/invite-member-dialog-CGySt3ln.js +3 -0
- package/dist/client/assets/{label-C-M0DX5a.js → label-e8ipDDuV.js} +1 -1
- package/dist/client/assets/{library-tab-D1dP6e2l.js → library-tab-xtxwrwsE.js} +1 -1
- package/dist/client/assets/{login-DMQTn7wh.js → login-D36YSbZ3.js} +1 -1
- package/dist/client/assets/{mcp-oauth-D8P2QaWG.js → mcp-oauth-DJ_D41xa.js} +1 -1
- package/dist/client/assets/members-vbnJ5HeT.js +1 -0
- package/dist/client/assets/{monaco-editor-Bn7nTC-y.js → monaco-editor-Bb0hmy-d.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-D2SCaVP_.js → monitoring-stats-row-BZRgcvhm.js} +1 -1
- package/dist/client/assets/{oauth-callback-arRRISlw.js → oauth-callback-DZYBu4eK.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-BrGx-toi.js → oauth-callback-ai-provider-Chg0Gwp5.js} +1 -1
- package/dist/client/assets/{onboarding-DfQssXGo.js → onboarding-DSFSSRFr.js} +1 -1
- package/dist/client/assets/{org-install-CAxOgyNR.js → org-install-DU4NcQb8.js} +1 -1
- package/dist/client/assets/{org-layout-C7RcAVm5.js → org-layout-CL__RtH7.js} +1 -1
- package/dist/client/assets/{organization-choice-aXwHBCUC.js → organization-choice-DuHbEnTg.js} +1 -1
- package/dist/client/assets/{page-seo-form-DTBhJgv0.js → page-seo-form-1MoU83LY.js} +1 -1
- package/dist/client/assets/page-seo-sheet-CLjhJXuO.js +1 -0
- package/dist/client/assets/{popover-DvGqLTJl.js → popover-BGYh0Vqy.js} +1 -1
- package/dist/client/assets/{post-editor-C-KR7OSD.js → post-editor-DoDFq7TS.js} +1 -1
- package/dist/client/assets/{primitives-Cbyyj3A3.js → primitives-LBvlK-aq.js} +1 -1
- package/dist/client/assets/{profile-eglAZx5J.js → profile-Dlqn0aYZ.js} +1 -1
- package/dist/client/assets/project-app-view-8w9_fvMi.js +1 -0
- package/dist/client/assets/record-editor-bXa5q0xQ.js +1 -0
- package/dist/client/assets/registry-BtF4LOFK.js +2 -0
- package/dist/client/assets/{registry-layout-hOf6zsxt.js → registry-layout-BYhrrdCJ.js} +1 -1
- package/dist/client/assets/{require-capability-XNz95caz.js → require-capability-U2maMAuO.js} +1 -1
- package/dist/client/assets/{required-auth-layout-CrFETKOt.js → required-auth-layout-C3UaWiTo.js} +1 -1
- package/dist/client/assets/{reset-password-DvMp7JEU.js → reset-password-C5cZQH7Y.js} +1 -1
- package/dist/client/assets/roles-Dra-Wfd-.js +1 -0
- package/dist/client/assets/{scroll-area-Bkg-mZA1.js → scroll-area-B0ntssfk.js} +1 -1
- package/dist/client/assets/{search-input-Csys3Koh.js → search-input-gVylns9Q.js} +1 -1
- package/dist/client/assets/{secrets-Bc04lDOi.js → secrets-D4L1pS60.js} +1 -1
- package/dist/client/assets/{sections-editor-DMIuM8hP.js → sections-editor-DGa1wmN5.js} +2 -2
- package/dist/client/assets/{select-CyjV0F4C.js → select-Bz_zhsne.js} +1 -1
- package/dist/client/assets/{select-model-DkNEmCB-.js → select-model-Dws7vIv0.js} +1 -1
- package/dist/client/assets/{seo-editor-CXv7fPuW.js → seo-editor-B6-szxCN.js} +1 -1
- package/dist/client/assets/{settings-layout-CqQSdUJ1.js → settings-layout-BIS898tZ.js} +1 -1
- package/dist/client/assets/{settings-section-CWGTzuvV.js → settings-section-BpxmEjXY.js} +1 -1
- package/dist/client/assets/{sheet-DuOoVZUG.js → sheet--GPTCkBV.js} +1 -1
- package/dist/client/assets/{shell-controls-_ERLWSRt.js → shell-controls-ly_2AJ45.js} +1 -1
- package/dist/client/assets/{shell-layout-DbD_tkNz.js → shell-layout-C_sGpxte.js} +1 -1
- package/dist/client/assets/{sidebar-Dk_5AbOf.js → sidebar-B6jtm1Ue.js} +1 -1
- package/dist/client/assets/{skeleton-erh5yXDG.js → skeleton-BuwUIpX4.js} +1 -1
- package/dist/client/assets/{sso-CA0aW0DE.js → sso-ydNnegVz.js} +1 -1
- package/dist/client/assets/{store-fNZRBFZQ.js → store-BxzPtxNS.js} +1 -1
- package/dist/client/assets/store-registry-C85lAMR7.js +2 -0
- package/dist/client/assets/{studio-tools-BaSvhr-J.js → studio-tools-C5AidOwh.js} +1 -1
- package/dist/client/assets/{switch-BHo8xs7D.js → switch--S_O_q8e.js} +1 -1
- package/dist/client/assets/{table-7NpUUPTt.js → table-Bn2PjNfj.js} +1 -1
- package/dist/client/assets/{tabs-MyyL-fGu.js → tabs-DLPd0DvT.js} +1 -1
- package/dist/client/assets/{task-row-CSJH3BP-.js → task-row-CrBNUNWV.js} +1 -1
- package/dist/client/assets/{task-status-CcNy4g07.js → task-status-Dt9iGaeJ.js} +1 -1
- package/dist/client/assets/{textarea-DE7i4Gz-.js → textarea-CjWp7xSP.js} +1 -1
- package/dist/client/assets/{toggle-group-BPcVs9aZ.js → toggle-group-ClY9GDOR.js} +1 -1
- package/dist/client/assets/{toolbar-DO76WyPk.js → toolbar-DOmN7mkS.js} +1 -1
- package/dist/client/assets/{toolbar-icon-button-CRc66nZ-.js → toolbar-icon-button-C8FxUmEM.js} +1 -1
- package/dist/client/assets/{tools-list-Bq5PisM1.js → tools-list-MDGz8nvX.js} +1 -1
- package/dist/client/assets/{tooltip-CBYM2iV5.js → tooltip-KzEPH1eR.js} +1 -1
- package/dist/client/assets/{types-BxTesI-C.js → types-B364N4aW.js} +1 -1
- package/dist/client/assets/{use-ai-providers-BLBRqrOl.js → use-ai-providers-Dq5k2aGK.js} +1 -1
- package/dist/client/assets/{use-automations-5UyPQOVR.js → use-automations-CzG9IQfm.js} +1 -1
- package/dist/client/assets/{use-capability-BOo3wKB9.js → use-capability-BJ4aG-VL.js} +1 -1
- package/dist/client/assets/{use-clock-tick-DpMHy-Ay.js → use-clock-tick-DyaHUns-.js} +1 -1
- package/dist/client/assets/{use-collections-CQf58LpF.js → use-collections-D1lQ_xC2.js} +1 -1
- package/dist/client/assets/{use-connection-BuG3o_JE.js → use-connection-iaNqg2f9.js} +1 -1
- package/dist/client/assets/{use-copy-jWg55WQ8.js → use-copy-D2sA2mMs.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-LuXF-lyt.js → use-create-virtual-mcp-qQdCtTI0.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-BlFX0cfT.js → use-debounced-autosave-jPoGEcl_.js} +1 -1
- package/dist/client/assets/{use-debounced-value-Df6CEQAw.js → use-debounced-value-CrPySguN.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-uI4wGrsY.js → use-decopilot-events-C_YXHznB.js} +1 -1
- package/dist/client/assets/{use-delete-connection-UF4lOt5V.js → use-delete-connection-BFjaOGmE.js} +1 -1
- package/dist/client/assets/{use-file-configs-Bs9D0249.js → use-file-configs-DT_kH366.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-DlYly1rf.js → use-infinite-scroll-n6K3XvYN.js} +1 -1
- package/dist/client/assets/{use-join-requests-B315-fOS.js → use-join-requests-ClpMRY-2.js} +1 -1
- package/dist/client/assets/{use-mcp-client-CpnbLiac.js → use-mcp-client-BBa18C66.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-B5dgZtuY.js → use-mcp-prompts-BJlX80Yp.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-DpNh0INt.js → use-mcp-tools-BRnTJmjH.js} +1 -1
- package/dist/client/assets/{use-members-BRjOC4BL.js → use-members-Ng06RoGr.js} +1 -1
- package/dist/client/assets/{use-mobile-BnJF8Qa_.js → use-mobile-fVP68LM8.js} +1 -1
- package/dist/client/assets/use-navigate-to-agent-C6SA_K8C.js +1 -0
- package/dist/client/assets/{use-org-auth-client-DmjZpfi2.js → use-org-auth-client-rKt5ss-n.js} +1 -1
- package/dist/client/assets/{use-org-sso-B_xa25Ag.js → use-org-sso-Cs-tarFI.js} +1 -1
- package/dist/client/assets/use-organization-roles-BbGAZb76.js +1 -0
- package/dist/client/assets/{use-organization-settings-DtUUny9s.js → use-organization-settings-DRcl_3Dg.js} +1 -1
- package/dist/client/assets/{use-registry-connections-CLetM4Ks.js → use-registry-connections-DYKN0CFv.js} +1 -1
- package/dist/client/assets/{use-secrets-CuFzitLe.js → use-secrets-3i5_T1Ig.js} +1 -1
- package/dist/client/assets/{use-status-sounds-4tbPTgQW.js → use-status-sounds-CmPdHuAg.js} +1 -1
- package/dist/client/assets/{use-view-mode-C2fVP0l9.js → use-view-mode-CxyCyyqP.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-OVYXqA3Z.js → use-virtual-mcp-CrBCSZ6B.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-_DQrdP-B.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-CkKiinpE.js +1 -0
- package/dist/client/assets/{useSuspenseQueries-g4R4jK3t.js → useSuspenseQueries-DqkS_kYg.js} +1 -1
- package/dist/client/assets/{variant-calendar-amJKLF4x.js → variant-calendar-D86dGqBT.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-DGsaaoN8.js → view-mode-toggle-C2i_xBD9.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +979 -653
- package/dist/server/server.js +264 -264
- package/package.json +1 -1
- package/dist/client/assets/agents-list-D2wP1uld.js +0 -1
- package/dist/client/assets/collection-detail-ClK5ckvV.js +0 -1
- package/dist/client/assets/github-repo-picker-CXt90kMG.js +0 -1
- package/dist/client/assets/import-from-deco-dialog-P6TRPQ14.js +0 -4
- package/dist/client/assets/index-8NfBTjo_.js +0 -1
- package/dist/client/assets/index-DmMZ0-sF.css +0 -1
- package/dist/client/assets/members-B3Jf-1QZ.js +0 -3
- package/dist/client/assets/page-seo-sheet-DSFzu1g0.js +0 -1
- package/dist/client/assets/project-app-view-BZfBTk7X.js +0 -1
- package/dist/client/assets/record-editor-lkwoQjs9.js +0 -1
- package/dist/client/assets/registry-_cXAc0hk.js +0 -2
- package/dist/client/assets/roles-HzDtUpXH.js +0 -1
- package/dist/client/assets/store-registry-Bfou8ECl.js +0 -2
- package/dist/client/assets/use-navigate-to-agent-CI_L2BEy.js +0 -1
- package/dist/client/assets/use-organization-roles-BO6fS6vf.js +0 -1
- package/dist/client/assets/useInfiniteQuery-CgWnzkKu.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-DtkXwhfE.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as kt,r as g,ak as Mi,ai as Oi,c as z,G as Ce,l as Y,j as r,E as Li,t as ue,o as pt,aw as Fi,s as St,ax as ys,L as _r,B as ie,p as Er,n as Tr,ay as $i,az as zi,I as It,a1 as Bi,aA as Ut,aB as Ls,b as ht,d as ws,v as X,aC as Ui,W as Pr,V as Ki,D as qi,aD as Yi,a as _n,aE as Hi,aF as Mr,aG as Qi,aH as Xe,aI as Wn,ae as At,aJ as Wi,aK as Gn,aL as Gi,aM as Xi,aN as Ji,aO as Zi,q as ea,K as Je,aP as ta,aQ as na,aR as sa,aS as ra,aT as Or,aU as qt,k as oa,i as Yt,z as ia,C as aa,a2 as Lr,a3 as Ve}from"./index-qfheH9Xc.js";import{a as Fr,n as la}from"./SwitchHorizontal01-1JfD3pEr.js";import{b as ut,u as Dt,S as ds,c as En,a as $r,f as zr,s as ca,g as da,h as ua,i as fa,j as Br,A as Va,k as ma,l as pa}from"./chat-context-BXvC8snN.js";import{j as Ur,s as Tn,g as ct,P as vn,k as js,t as ha,l as ga,M as xa,m as va,n as bn,o as Kr,p as ba,D as ya,q as wa,r as ja,v as Nt,w as Aa,d as Ca,x as Sa,y as As,z as Na,F as ka,i as Ia,E as Da,c as Ra,A as _a,B as Ea,H as Ta,I as Pa,J as Fs}from"./scroll-area-Bkg-mZA1.js";import{c as us,a as Ue,b as Ke,T as qe}from"./tooltip-CBYM2iV5.js";import{c as Rt,a as _t,d as Et,e as Tt,b as Pn,D as Ma}from"./dialog-DaSKz7DM.js";import{c as qr,b as Yr,a as Hr,D as Qr,d as Oa,e as La,f as Fa}from"./drawer-DdiW0TLs.js";import{C as Wr}from"./collection-search-BWPhJb0W.js";import{u as Gr}from"./use-mobile-BnJF8Qa_.js";import{a as Mn,u as gt,S as Xr,i as $s}from"./use-mcp-client-CpnbLiac.js";import{u as $a,g as On,l as fs}from"./use-mcp-prompts-B5dgZtuY.js";import{t as Ln}from"./ChevronDown-CLx4-WM1.js";import{i as yt}from"./X-D1xM7jXL.js";import{t as za,z as Ba,b as Ua,w as Ka,A as qa}from"./hooks-BgBnOJ3c.js";import{K as Ya,i as Ha}from"./shell-layout-DbD_tkNz.js";import{a as Qa,u as Wa}from"./use-virtual-mcp-OVYXqA3Z.js";import{n as Jr}from"./ZapSquare-B4AjMOPu.js";import{i as Vt}from"./ChevronUp-BGt4chTY.js";import{s as Ht}from"./Star01-CkOKT_Ec.js";import{a as Zr}from"./Tool01-84S8urW1.js";import{ae as Fn,x as Ga,a6 as eo,af as Xa,A as to,f as mn,g as Ja,a8 as Za,ag as el,C as tl,ah as no,aa as nl,ai as sl,aj as rl,c as so}from"./agent-icon-C1BWispo.js";import{i as ol}from"./Upload01-Cou_1dwr.js";import{i as ro}from"./AlertCircle-DdrwwZMq.js";import{a as il}from"./Eye-o5yQXJvl.js";import{a as Xt,b as Ee,d as Te,e as Pe,F as $e,c as Ge}from"./form-D1efg8C-.js";import{b as oo,d as io,c as wt,S as ao,a as lo}from"./select-CyjV0F4C.js";import{b as al}from"./Settings02-C-6P9tLl.js";import{i as co,t as Vs,b as ll,n as pn,c as Xn}from"./XCircle-D1ibZ16t.js";import{b as cl,c as dl}from"./tabs-MyyL-fGu.js";import{a as uo,T as yn}from"./toggle-group-BPcVs9aZ.js";import{I as tt}from"./input-c3bkJxBD.js";import{u as fo,a as ul,g as fl}from"./agent-capabilities-BDCwG9Eh.js";import{u as Vo}from"./studio-tools-BaSvhr-J.js";import{i as Cs}from"./Monitor01-CWIDsYmm.js";import{u as mo,C as Vl,a as po,b as ho}from"./connect-desktop-dialog-wN68EGmx.js";import{s as go}from"./XClose-D0Zu_lRC.js";import{m as $n,i as ml,g as xo,a as pl,N as hl}from"./decopilot-DitDP2XU.js";import{P as Ss,a as Ns,b as ks}from"./popover-DvGqLTJl.js";import{e as zs,a as Bs,g as gl,b as xl,C as vl,c as bl,d as yl}from"./command-BrahLBH2.js";import{u as wl}from"./useInfiniteQuery-CgWnzkKu.js";import{t as jl}from"./Stars01-sPe6wVRL.js";import{q as Al,r as Cl,s as Sl,t as Nl,S as kl,B as Il}from"./index-YOEpEUyS.js";import{D as Dl,a as Rl,b as _l,c as at,d as Us,e as Ks,f as qs,j as El,i as Tl}from"./dropdown-menu-5pJpeeqf.js";import{s as ms}from"./Plus-DZiClNST.js";import{p as Pl,q as Ml}from"./question-004-sINsf4GQ.js";import{g as Ol}from"./connection-slug-eyAPH6o3.js";import{u as vo,a as bo,g as Ll,C as Jn}from"./connection-card-CS0ZRcyq.js";import{C as Fl}from"./collection-tabs-LbK97vzL.js";import{a as $l,b as zl,e as Bl,g as Ul}from"./extract-connection-data-X711B5tE.js";import{T as Kl}from"./textarea-DE7i4Gz-.js";import{b as yo}from"./use-connection-BuG3o_JE.js";import{c as ql,i as ln,a as Ys,E as Yl,p as Hl,b as Ql,d as Wl}from"./connection-form-helpers--RFzi4SS.js";import{u as Hs}from"./use-infinite-scroll-DlYly1rf.js";import{a as Zn}from"./authenticate-and-persist-oauth-B3lWqExf.js";import{B as cn}from"./badge-DjU6bfHE.js";import{u as Gl}from"./useSuspenseInfiniteQuery-DtkXwhfE.js";import{i as Xl}from"./ChevronRight-jYKilAXW.js";import{k as Jl}from"./tab-id-DPNwWMUY.js";function Zl(t,e){const n=kt(e);return ec({filters:{...t,status:"pending"}},n).length}function Qs(t,e){return t.findAll(e.filters).map(n=>e.select?e.select(n):n.state)}function ec(t={},e){const n=kt(e).getMutationCache(),s=g.useRef(t),o=g.useRef(null);return o.current===null&&(o.current=Qs(n,t)),g.useEffect(()=>{s.current=t}),g.useSyncExternalStore(g.useCallback(i=>n.subscribe(()=>{const a=Mi(o.current,Qs(n,s.current));o.current!==a&&(o.current=a,Oi.schedule(i))}),[n]),()=>o.current,()=>o.current)}const Ws=3,wo="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",tc="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function jo(t){const e=z.c(46),{item:n,onSelect:s,isLoading:o,isDisabled:i,variant:a}=t,c=a===void 0?"pill":a,{prompt:d}=n;let u;if(e[0]!==d._meta||e[1]!==d.name||e[2]!==d.title){const b=ct(d._meta);u=d.title??js(d.name,b),e[0]=d._meta,e[1]=d.name,e[2]=d.title,e[3]=u}else u=e[3];const f=u,l=d.description||null;if(c==="card"){let b;e[4]!==s||e[5]!==d?(b=()=>s(d),e[4]=s,e[5]=d,e[6]=b):b=e[6];const A=i||o,j=o&&"bg-accent/40",I=(i||o)&&"cursor-not-allowed opacity-50";let D;e[7]!==j||e[8]!==I?(D=Y(tc,"hover:bg-accent/60 text-foreground",j,I),e[7]=j,e[8]=I,e[9]=D):D=e[9];let _;e[10]!==f?(_=r.jsx("span",{className:"font-medium truncate capitalize",children:f}),e[10]=f,e[11]=_):_=e[11];let R;e[12]!==o?(R=o&&r.jsx(ds,{size:"xs"}),e[12]=o,e[13]=R):R=e[13];let k;e[14]!==_||e[15]!==R?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[_,R]}),e[14]=_,e[15]=R,e[16]=k):k=e[16];let M;e[17]!==l?(M=l&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:l}),e[17]=l,e[18]=M):M=e[18];let E;return e[19]!==k||e[20]!==M||e[21]!==b||e[22]!==A||e[23]!==D?(E=r.jsxs("button",{type:"button",onClick:b,disabled:A,className:D,children:[k,M]}),e[19]=k,e[20]=M,e[21]=b,e[22]=A,e[23]=D,e[24]=E):E=e[24],E}let V;e[25]!==s||e[26]!==d?(V=()=>s(d),e[25]=s,e[26]=d,e[27]=V):V=e[27];const m=i||o,v=o&&"bg-muted/50",p=(i||o)&&"cursor-not-allowed opacity-50";let h;e[28]!==v||e[29]!==p?(h=Y(wo,"hover:bg-muted/70 hover:text-foreground",v,p),e[28]=v,e[29]=p,e[30]=h):h=e[30];let y;e[31]!==f?(y=r.jsx("span",{className:"capitalize",children:f}),e[31]=f,e[32]=y):y=e[32];let x;e[33]!==o?(x=o&&r.jsx(ds,{size:"xs"}),e[33]=o,e[34]=x):x=e[34];let w;e[35]!==V||e[36]!==m||e[37]!==h||e[38]!==y||e[39]!==x?(w=r.jsx(Ue,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:V,disabled:m,className:h,children:[y,x]})}),e[35]=V,e[36]=m,e[37]=h,e[38]=y,e[39]=x,e[40]=w):w=e[40];const S=l??f;let N;e[41]!==S?(N=r.jsx(Ke,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:S})}),e[41]=S,e[42]=N):N=e[42];let C;return e[43]!==w||e[44]!==N?(C=r.jsxs(qe,{delayDuration:400,children:[w,N]}),e[43]=w,e[44]=N,e[45]=C):C=e[45],C}function nc(t){const e=z.c(41),{items:n,open:s,onOpenChange:o,onSelect:i,loadingPrompt:a}=t,[c,d]=g.useState(""),u=!!a;let f;e[0]!==n||e[1]!==c?(f=c.trim()?n.filter(A=>{const j=c.toLowerCase();return A.prompt.name.toLowerCase().includes(j)||(A.prompt.title??"").toLowerCase().includes(j)||(A.prompt.description??"").toLowerCase().includes(j)}):n,e[0]=n,e[1]=c,e[2]=f):f=e[2];const l=f,V=Gr();let m;e[3]!==l.length||e[4]!==c?(m=l.length===0&&r.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",c,"”"]}),e[3]=l.length,e[4]=c,e[5]=m):m=e[5];let v;if(e[6]!==l||e[7]!==u||e[8]!==a?.name||e[9]!==o||e[10]!==i){let A;e[12]!==u||e[13]!==a?.name||e[14]!==o||e[15]!==i?(A=j=>r.jsx(jo,{item:j,variant:"card",onSelect:I=>{o(!1),i(I)},isLoading:a?.name===j.prompt.name,isDisabled:u&&a?.name!==j.prompt.name},j.prompt.name),e[12]=u,e[13]=a?.name,e[14]=o,e[15]=i,e[16]=A):A=e[16],v=l.map(A),e[6]=l,e[7]=u,e[8]=a?.name,e[9]=o,e[10]=i,e[11]=v}else v=e[11];let p;e[17]!==m||e[18]!==v?(p=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,v]})}),e[17]=m,e[18]=v,e[19]=p):p=e[19];const h=p;let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=A=>{A.key==="Escape"&&d("")},e[20]=y):y=e[20];let x;e[21]!==c?(x=r.jsx(Wr,{value:c,onChange:d,placeholder:"Search prompts...",onKeyDown:y}),e[21]=c,e[22]=x):x=e[22];const w=x;if(V){let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(qr,{className:"sr-only",children:r.jsx(Yr,{children:"All prompts"})}),e[23]=A):A=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=j):j=e[24];let I;e[25]!==h||e[26]!==w?(I=r.jsxs(Hr,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[A,j,w,h]}),e[25]=h,e[26]=w,e[27]=I):I=e[27];let D;return e[28]!==o||e[29]!==s||e[30]!==I?(D=r.jsx(us,{delayDuration:400,children:r.jsx(Qr,{open:s,onOpenChange:o,children:I})}),e[28]=o,e[29]=s,e[30]=I,e[31]=D):D=e[31],D}let S;e[32]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Rt,{className:"sr-only",children:r.jsx(_t,{children:"All prompts"})}),e[32]=S):S=e[32];let N;e[33]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=N):N=e[33];let C;e[34]!==h||e[35]!==w?(C=r.jsxs(Et,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[S,N,w,h]}),e[34]=h,e[35]=w,e[36]=C):C=e[36];let b;return e[37]!==o||e[38]!==s||e[39]!==C?(b=r.jsx(us,{delayDuration:400,children:r.jsx(Tt,{open:s,onOpenChange:o,children:C})}),e[37]=o,e[38]=s,e[39]=C,e[40]=b):b=e[40],b}function sc(t){const e=z.c(29),{items:n,onSelect:s,loadingPrompt:o,className:i}=t,[a,c]=g.useState(!1);if(n.length===0)return null;let d,u,f;if(e[0]!==n||e[1]!==o||e[2]!==s){const y=n.slice(0,Ws);let x;e[6]!==n?(x=n.slice(Ws),e[6]=n,e[7]=x):x=e[7],d=x,u=!!o;let w;e[8]!==u||e[9]!==o?.name||e[10]!==s?(w=S=>r.jsx(jo,{item:S,onSelect:s,isLoading:o?.name===S.prompt.name,isDisabled:u&&o?.name!==S.prompt.name},S.prompt.name),e[8]=u,e[9]=o?.name,e[10]=s,e[11]=w):w=e[11],f=y.map(w),e[0]=n,e[1]=o,e[2]=s,e[3]=d,e[4]=u,e[5]=f}else d=e[3],u=e[4],f=e[5];const l=f;let V;e[12]!==i?(V=Y("w-full flex flex-wrap gap-2 justify-center",i),e[12]=i,e[13]=V):V=e[13];let m;e[14]!==d.length||e[15]!==u?(m=d.length>0&&r.jsxs("button",{type:"button",disabled:u,onClick:()=>c(!0),className:Y(wo,"hover:bg-muted/70 hover:text-foreground",u&&"opacity-50 cursor-not-allowed"),children:["+",d.length," more"]}),e[14]=d.length,e[15]=u,e[16]=m):m=e[16];let v;e[17]!==l||e[18]!==V||e[19]!==m?(v=r.jsxs("div",{className:V,children:[l,m]}),e[17]=l,e[18]=V,e[19]=m,e[20]=v):v=e[20];let p;e[21]!==n||e[22]!==o||e[23]!==a||e[24]!==s?(p=r.jsx(nc,{items:n,open:a,onOpenChange:c,onSelect:s,loadingPrompt:o}),e[21]=n,e[22]=o,e[23]=a,e[24]=s,e[25]=p):p=e[25];let h;return e[26]!==v||e[27]!==p?(h=r.jsxs(us,{delayDuration:400,children:[v,p]}),e[26]=v,e[27]=p,e[28]=h):h=e[28],h}function rc(){return null}function oc(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function ic(t){const e=z.c(30),{connectionId:n}=t,{sendMessage:s}=Dt(),{org:o}=Ce();let i;e[0]!==n||e[1]!==o.id||e[2]!==o.slug?(i={connectionId:n,orgId:o.id,orgSlug:o.slug},e[0]=n,e[1]=o.id,e[2]=o.slug,e[3]=i):i=e[3];const a=gt(i);let c;e[4]!==a?(c={client:a,staleTime:6e4},e[4]=a,e[5]=c):c=e[5];const{data:d}=$a(c);let u;e[6]!==d?.prompts?(u=d?.prompts??[],e[6]=d?.prompts,e[7]=u):u=e[7];const f=u;let l;e[8]!==f?(l=f.map(ac),e[8]=f,e[9]=l):l=e[9];const V=l;let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m={stage:"idle"},e[10]=m):m=e[10];const[v,p]=g.useReducer(oc,m),[h,y]=g.useState(null);let x;e[11]!==a||e[12]!==s?(x=async(R,k)=>{if(!a){ue.error("MCP client not available"),p({type:"RESET"});return}try{const M=await On(a,R.name,k);p({type:"RESET"});const E={type:"doc",content:[{type:"paragraph",content:[Ur({id:R.name,name:Tn(R.name,ct(R._meta)),metadata:M.messages,char:"/",kind:"prompt",args:k}),{type:"text",text:" "}]}]};await s(E)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),ue.error("Failed to load prompt. Please try again."),p({type:"RESET"})}},e[11]=a,e[12]=s,e[13]=x):x=e[13];const w=x;let S;e[14]!==w?(S=async R=>{if(R.arguments&&R.arguments.length>0){p({type:"SELECT_PROMPT",prompt:R}),y(R);return}p({type:"START_LOADING",prompt:R}),await w(R)},e[14]=w,e[15]=S):S=e[15];const N=S;let C;e[16]!==h||e[17]!==w?(C=async R=>{h&&(p({type:"START_LOADING",prompt:h,arguments:R}),y(null),await w(h,R))},e[16]=h,e[17]=w,e[18]=C):C=e[18];const b=C;if(V.length===0)return null;const A=v.stage==="loading"?v.prompt:null;let j;e[19]!==N||e[20]!==V||e[21]!==A?(j=r.jsx(sc,{items:V,onSelect:N,loadingPrompt:A}),e[19]=N,e[20]=V,e[21]=A,e[22]=j):j=e[22];let I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{y(null),p({type:"RESET"})},e[23]=I):I=e[23];let D;e[24]!==h||e[25]!==b?(D=r.jsx(vn,{prompt:h,setPrompt:I,onSubmit:b}),e[24]=h,e[25]=b,e[26]=D):D=e[26];let _;return e[27]!==j||e[28]!==D?(_=r.jsxs(r.Fragment,{children:[j,D]}),e[27]=j,e[28]=D,e[29]=_):_=e[29],_}function ac(t){return{prompt:t}}function lc(t){const e=z.c(13),{className:n}=t,{selectedVirtualMcp:s}=ut(),{org:o}=Ce();let i;e[0]!==o.id?(i=Mn(o.id),e[0]=o.id,e[1]=i):i=e[1];const a=i.id,c=s?.id??a;let d;e[2]!==n?(d=Y("w-full @container",n),e[2]=n,e[3]=d):d=e[3];const u=c??"default";let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(rc,{}),e[4]=f):f=e[4];let l;e[5]!==c?(l=r.jsx(ic,{connectionId:c}),e[5]=c,e[6]=l):l=e[6];let V;e[7]!==u||e[8]!==l?(V=r.jsx(Li,{fallback:null,children:r.jsx(g.Suspense,{fallback:f,children:l},u)}),e[7]=u,e[8]=l,e[9]=V):V=e[9];let m;return e[10]!==d||e[11]!==V?(m=r.jsx("div",{className:d,children:V}),e[10]=d,e[11]=V,e[12]=m):m=e[12],m}const es="cubic-bezier(0.645, 0.045, 0.355, 1)",cc=44,dc={default:"",error:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-destructive/5 after:pointer-events-none after:-z-10",warning:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-amber-500/5 after:pointer-events-none after:-z-10"},uc={default:"border-border",error:"border-destructive/30",warning:"border-amber-500/30"},fc={default:"text-muted-foreground",error:"text-destructive",warning:"text-amber-600 dark:text-amber-500"};function dt(t){const e=z.c(61),{icon:n,label:s,count:o,title:i,footerLeft:a,footerRight:c,children:d,defaultExpanded:u,variant:f,onClose:l}=t,V=f===void 0?"default":f,[m,v]=g.useState(u),[p,h]=g.useState(!1);let y;e[0]!==l?(y=()=>{h(!0),l?.()},e[0]=l,e[1]=y):y=e[1];const x=y;if(p)return null;const w=uc[V],S=dc[V];let N;e[2]!==w||e[3]!==S?(N=Y("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",w,S),e[2]=w,e[3]=S,e[4]=N):N=e[4];let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=()=>v(Vc),e[5]=C):C=e[5];const b=m&&"rounded-b-none",A=!m&&"rounded-b-xl";let j;e[6]!==b||e[7]!==A?(j=Y("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",b,A),e[6]=b,e[7]=A,e[8]=j):j=e[8];const I=fc[V];let D;e[9]!==I?(D=Y("shrink-0",I),e[9]=I,e[10]=D):D=e[10];let _;e[11]!==n||e[12]!==D?(_=r.jsx("span",{className:D,children:n}),e[11]=n,e[12]=D,e[13]=_):_=e[13];let R;e[14]!==s?(R=r.jsx("span",{className:"flex-1 min-w-0 truncate",children:s}),e[14]=s,e[15]=R):R=e[15];let k;e[16]!==o?(k=o?r.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:o}):null,e[16]=o,e[17]=k):k=e[17];const M=m?"rotate(180deg)":"rotate(0deg)";let E;e[18]!==M?(E=r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:r.jsx(Ln,{size:16,style:{transform:M,transition:`transform 180ms ${es}`}})}),e[18]=M,e[19]=E):E=e[19];let P,T;e[20]!==x?(P=te=>{te.stopPropagation(),x()},T=te=>{(te.key==="Enter"||te.key===" ")&&(te.preventDefault(),te.stopPropagation(),x())},e[20]=x,e[21]=P,e[22]=T):(P=e[21],T=e[22]);let L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(yt,{size:16}),e[23]=L):L=e[23];let U;e[24]!==P||e[25]!==T?(U=r.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":"Close",title:"Close",onClick:P,onKeyDown:T,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center justify-center -mr-1 ml-1 p-1 rounded-md hover:bg-accent",children:L}),e[24]=P,e[25]=T,e[26]=U):U=e[26];let $;e[27]!==m||e[28]!==_||e[29]!==R||e[30]!==k||e[31]!==E||e[32]!==U||e[33]!==j?($=r.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":m,onClick:C,className:j,children:[_,R,k,E,U]}),e[27]=m,e[28]=_,e[29]=R,e[30]=k,e[31]=E,e[32]=U,e[33]=j,e[34]=$):$=e[34];const B=m?"1fr":"0fr";let K;e[35]!==B?(K={display:"grid",gridTemplateRows:B,transition:`grid-template-rows 180ms ${es}`},e[35]=B,e[36]=K):K=e[36];let H;e[37]===Symbol.for("react.memo_cache_sentinel")?(H={overflow:"hidden",minHeight:0},e[37]=H):H=e[37];const O=m?1:0;let F;e[38]!==O?(F={opacity:O,transition:`opacity 120ms ${es}`},e[38]=O,e[39]=F):F=e[39];let J;e[40]!==i?(J=i?r.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:i})}):r.jsx("div",{className:"border-t border-dashed border-border/60"}),e[40]=i,e[41]=J):J=e[41];let Q;e[42]!==d||e[43]!==i?(Q=d?r.jsx("div",{className:Y("overflow-clip pb-4",!i&&"pt-4"),children:d}):null,e[42]=d,e[43]=i,e[44]=Q):Q=e[44];let Z;e[45]!==a||e[46]!==c?(Z=a||c?r.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:a}),r.jsx("div",{className:"flex items-center gap-2",children:c})]})}):null,e[45]=a,e[46]=c,e[47]=Z):Z=e[47];let q;e[48]!==F||e[49]!==J||e[50]!==Q||e[51]!==Z?(q=r.jsx("div",{style:H,children:r.jsxs("div",{style:F,children:[J,Q,Z]})}),e[48]=F,e[49]=J,e[50]=Q,e[51]=Z,e[52]=q):q=e[52];let se;e[53]!==K||e[54]!==q?(se=r.jsx("div",{"data-testid":"collapsible-highlight-body",style:K,children:q}),e[53]=K,e[54]=q,e[55]=se):se=e[55];let ee;return e[56]!==$||e[57]!==se||e[58]!==N||e[59]!==V?(ee=r.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":V,className:N,children:[$,se]}),e[56]=$,e[57]=se,e[58]=N,e[59]=V,e[60]=ee):ee=e[60],ee}function Vc(t){return!t}const mc=pt({content:St().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:ys(["pending","in_progress","completed"]),activeForm:St().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),Ao=pt({todos:Fi(mc)}),pc="Plan and track multi-step work. Call with the FULL todo list every time — this replaces the prior list. Call at the start of every multi-step request. Skip only for true one-shots (a single tool call or a direct answer). Mark exactly one todo `in_progress` at a time. Flip a todo to `in_progress` before starting it and to `completed` the moment it finishes — do not batch completions. Your prior tool-call inputs are your current state — read your last call to see where you are.";za({description:pc,inputSchema:Ba(Ao),execute:async({todos:t})=>({ok:!0,count:t.length})});const hc="tool-todo_write",gc=new Set(["input-available","output-available"]);function Co(t){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n.role!=="assistant")continue;const s=n.parts;if(Array.isArray(s))for(let o=s.length-1;o>=0;o--){const i=s[o];if(i.type!==hc||typeof i.state!="string"||!gc.has(i.state))continue;const a=Ao.safeParse(i.input);if(a.success)return a.data.todos}}return[]}function So(t){const e=[];for(const n of t)if("state"in n&&n.state==="approval-requested"&&"approval"in n&&n.approval?.id&&"toolCallId"in n&&n.toolCallId){const s="toolName"in n&&typeof n.toolName=="string"?n.toolName:n.type.startsWith("tool-")?n.type.replace("tool-",""):"Tool";e.push({approvalId:n.approval.id,toolCallId:n.toolCallId,toolName:s,friendlyName:ha(ga(s)),input:n.input})}return e}function No(t){const e=[];for(const n of t)if("type"in n&&n.type==="tool-propose_plan"&&"state"in n&&n.state==="input-available"&&"toolCallId"in n&&"input"in n){const s=n.input;e.push({toolCallId:n.toolCallId,plan:s.plan,state:n.state})}return e}function xc(t){return t?t.message.startsWith("[CREDITS]"):!1}const vc={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1};function bc(t){const{messages:e,error:n,finishReason:s,isStreaming:o,isWaitingForApprovals:i}=t;if(!o&&n&&xc(n))return{...vc,isCreditExhausted:!0};const a=e.at(-1),c=a?.role==="assistant"?a.parts:[],d=c,f=!!d.filter(w=>w.type==="tool-user_ask").filter(w=>w.state!=="output-available").length,l=No(c),V=So(d),m=Co(e),v=!o&&!!n,p=V.length>0||o&&i,h=l.length>0,x=!o&&!!s&&s!=="stop"&&!(s==="tool-calls"&&(f||p||h))&&!v;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:v,showWarning:x,hasApprovals:p,hasPlans:h,isWaitingForUserInput:f}}function ko(){const t=z.c(6),{messages:e,error:n,finishReason:s,isStreaming:o,isWaitingForApprovals:i}=Dt(),a=n??null,c=s??null;let d;return t[0]!==o||t[1]!==i||t[2]!==e||t[3]!==a||t[4]!==c?(d=bc({messages:e,error:a,finishReason:c,isStreaming:o,isWaitingForApprovals:i}),t[0]=o,t[1]=i,t[2]=e,t[3]=a,t[4]=c,t[5]=d):d=t[5],d}function yc(){const t=ko();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function Io(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(n=>n.type==="hardBreak"||n.type==="text"&&(!n.text||n.text.trim()==="")):!1)}const wc="__home__";function Is(t,e){return _r.chatDraft(t,e)}function jc(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object"||typeof e.updatedAt!="number")return null;const n=e.tiptapDoc;return!n||typeof n!="object"||n.type!=="doc"||!Array.isArray(n.content)?null:n}function Ac(t,e,n,s,o){const i=Is(e,n);if(Io(s)){t.removeItem(i);return}const a={tiptapDoc:s,updatedAt:Date.now()},c=JSON.stringify(a);try{t.setItem(i,c)}catch(d){if(Sc(d)){const u=new TextEncoder().encode(c).byteLength;o?.onQuotaExceeded?.({docSizeBytes:u});return}throw d}}function Gs(t,e,n){const s=Is(e,n),o=t.getItem(s),i=jc(o);return o!==null&&i===null&&t.removeItem(s),i}function Cc(t,e,n){t.removeItem(Is(e,n))}function Sc(t){if(!t||typeof t!="object")return!1;const e=t.name;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"}function Nc(t){const e=z.c(21),{current:n,total:s,onPrev:o,onNext:i}=t;if(s<=1)return null;const a=n===0,c=n===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let d;e[0]!==c?(d=Y("p-0.5 rounded transition-colors",c),e[0]=c,e[1]=d):d=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(al,{size:14}),e[2]=u):u=e[2];let f;e[3]!==o||e[4]!==a||e[5]!==d?(f=r.jsx("button",{type:"button",onClick:o,disabled:a,className:d,"aria-label":"Previous question",children:u}),e[3]=o,e[4]=a,e[5]=d,e[6]=f):f=e[6];const l=n+1;let V;e[7]!==l||e[8]!==s?(V=r.jsxs("span",{className:"tabular-nums text-xs",children:[l," of ",s]}),e[7]=l,e[8]=s,e[9]=V):V=e[9];const m=n===s-1,v=n===s-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let p;e[10]!==v?(p=Y("p-0.5 rounded transition-colors",v),e[10]=v,e[11]=p):p=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(co,{size:14}),e[12]=h):h=e[12];let y;e[13]!==i||e[14]!==p||e[15]!==m?(y=r.jsx("button",{type:"button",onClick:i,disabled:m,className:p,"aria-label":"Next question",children:h}),e[13]=i,e[14]=p,e[15]=m,e[16]=y):y=e[16];let x;return e[17]!==y||e[18]!==f||e[19]!==V?(x=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[f,V,y]}),e[17]=y,e[18]=f,e[19]=V,e[20]=x):x=e[20],x}function Do(t){const e=z.c(8),{currentIndex:n,total:s,onPrev:o,onNext:i,extraLeft:a}=t;let c;e[0]!==n||e[1]!==i||e[2]!==o||e[3]!==s?(c=r.jsx(Nc,{current:n,total:s,onPrev:o,onNext:i}),e[0]=n,e[1]=i,e[2]=o,e[3]=s,e[4]=c):c=e[4];let d;return e[5]!==a||e[6]!==c?(d=r.jsxs("div",{className:"flex items-center gap-2",children:[c,a]}),e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function kc(t){const e=z.c(17),{isStreaming:n,isAllAnswered:s,isCurrentAnswered:o,onAdvanceOrSubmit:i,submitLabel:a,nextLabel:c}=t,f=s?a===void 0?"Submit":a:c===void 0?"Next":c,l=s?n:!o,V=l?s?"Waiting for the assistant to finish…":"Answer this item to continue":null;let m;e[0]!==l||e[1]!==i?(m=()=>{l||i()},e[0]=l,e[1]=i,e[2]=m):m=e[2];const v=l&&"opacity-50 cursor-not-allowed";let p;e[3]!==v?(p=Y("h-7 px-2.5 text-xs",v),e[3]=v,e[4]=p):p=e[4];let h;e[5]!==l||e[6]!==f||e[7]!==m||e[8]!==p?(h=r.jsx(ie,{type:"button",size:"sm","aria-disabled":l,onClick:m,className:p,children:f}),e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h):h=e[9];const y=h;if(!V)return y;let x;e[10]!==y?(x=r.jsx(Ue,{asChild:!0,children:y}),e[10]=y,e[11]=x):x=e[11];let w;e[12]!==V?(w=r.jsx(Ke,{children:V}),e[12]=V,e[13]=w):w=e[13];let S;return e[14]!==x||e[15]!==w?(S=r.jsxs(qe,{children:[x,w]}),e[14]=x,e[15]=w,e[16]=S):S=e[16],S}function Ro(t,e,n){return t.findIndex(s=>e(s)===n)}function Xs(t,e,n,s){return t.length===0?!1:t.every(o=>s(n[e(o)]))}function Js(t,e,n,s,o){if(t.length===0)return null;const i=Ro(t,e,o);for(let a=1;a<=t.length;a++){const c=t[(i+a)%t.length];if(!c)continue;const d=e(c);if(d!==o&&!s(n[d]))return d}return null}function Ic(t){return!t.isStreaming&&t.allAnswered}function _o(t){const{parts:e,partKey:n,schema:s,defaultValues:o,isStreaming:i,hasAnswer:a,onSubmit:c}=t,d=e[0]?n(e[0]):"",[u,f]=g.useState(d),[l,V]=g.useState(!1),m=Er({resolver:Tr(s),defaultValues:o}),v=m.watch(),p=Ro(e,n,u),h=p>=0?e[p]:void 0,y=a(v[u]),x=Xs(e,n,v,a),w=Ic({isStreaming:i,allAnswered:x}),S=()=>{if(p>0){const D=e[p-1];D&&f(n(D))}},N=()=>{if(p>=0&&p<e.length-1){const D=e[p+1];D&&f(n(D))}},C=()=>{const D=m.getValues(),_=Js(e,n,D,a,u);_&&f(_)},b=()=>{m.handleSubmit(D=>{const _=D;for(const R of e)c(R,_[n(R)])})()},A=g.useRef(b);A.current=b;const j=()=>{w&&(V(!1),A.current())},I=()=>{const D=m.getValues();if(Xs(e,n,D,a)){if(i){V(!0);return}V(!1),A.current()}else{const _=Js(e,n,D,a,u);_&&f(_)}};return g.useEffect(()=>{if(l&&!i){if(!x){V(!1);return}V(!1),A.current()}},[l,i,x]),{form:m,activeKey:u,setActiveKey:f,currentIndex:p,currentPart:h,isCurrentAnswered:y,isAllAnswered:x,canSubmit:w,goPrev:S,goNext:N,advanceToNextUnanswered:C,submit:j,submitOrAdvance:I}}const Eo="User denied this tool call, give other alternatives.";function To(t){const e=z.c(9),{onYolo:n}=t,[s,o]=It();let i;e[0]!==n||e[1]!==s||e[2]!==o?(i=f=>{const l=f,V=s.toolApprovalLevel??"readonly";o({...s,toolApprovalLevel:l}),l==="auto"&&n(V)},e[0]=n,e[1]=s,e[2]=o,e[3]=i):i=e[3];const a=i;let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(ao,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:Rc,children:r.jsx(lo,{})}),e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(oo,{children:Ut.map(Dc)}),e[5]=d):d=e[5];let u;return e[6]!==a||e[7]!==s.toolApprovalLevel?(u=r.jsxs(io,{value:s.toolApprovalLevel,onValueChange:a,children:[c,d]}),e[6]=a,e[7]=s.toolApprovalLevel,e[8]=u):u=e[8],u}function Dc(t){return r.jsx(wt,{value:t.value,children:t.label},t.value)}function Rc(t){return t.stopPropagation()}function Po(t){const e=z.c(5),{input:n}=t;if(n==null){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=i):i=e[0],i}let s;try{let i;e[1]!==n?(i=JSON.stringify(n,null,2),e[1]=n,e[2]=i):i=e[2],s=i}catch{s=String(n)}let o;return e[3]!==s?(o=r.jsx("div",{className:"px-4",children:r.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:s})}),e[3]=s,e[4]=o):o=e[4],o}function _c(t){const e=z.c(28),{approval:n,onRespond:s}=t,[o]=It(),i=o.toolApprovalLevel??"readonly";let a;e[0]!==n.approvalId||e[1]!==i||e[2]!==s?(a=()=>s(n.approvalId,!1,Eo,i),e[0]=n.approvalId,e[1]=i,e[2]=s,e[3]=a):a=e[3];const c=a;let d;e[4]!==n.approvalId||e[5]!==i||e[6]!==s?(d=()=>s(n.approvalId,!0,void 0,i),e[4]=n.approvalId,e[5]=i,e[6]=s,e[7]=d):d=e[7];const u=d;let f;e[8]!==n.approvalId||e[9]!==s?(f=N=>s(n.approvalId,!0,void 0,N),e[8]=n.approvalId,e[9]=s,e[10]=f):f=e[10];const l=f;let V;e[11]!==l?(V=r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(To,{onYolo:l})}),e[11]=l,e[12]=V):V=e[12];const m=V;let v;e[13]!==c?(v=r.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:c,children:"Deny"}),e[13]=c,e[14]=v):v=e[14];let p;e[15]!==u?(p=r.jsx(ie,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:u,children:"Accept"}),e[15]=u,e[16]=p):p=e[16];let h;e[17]!==v||e[18]!==p?(h=r.jsxs(r.Fragment,{children:[v,p]}),e[17]=v,e[18]=p,e[19]=h):h=e[19];const y=h;let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Fn,{size:14}),e[20]=x):x=e[20];let w;e[21]!==n.input?(w=r.jsx(Po,{input:n.input}),e[21]=n.input,e[22]=w):w=e[22];let S;return e[23]!==n.friendlyName||e[24]!==m||e[25]!==y||e[26]!==w?(S=r.jsx(dt,{icon:x,label:"Approval needed",title:n.friendlyName,defaultExpanded:!0,footerLeft:m,footerRight:y,children:w}),e[23]=n.friendlyName,e[24]=m,e[25]=y,e[26]=w,e[27]=S):S=e[27],S}const Ec=$i(St(),pt({approved:zi().optional(),levelOverride:ys(["auto","readonly"]).optional()}));function Tc(t){const e=z.c(42),{approvals:n,isStreaming:s,onRespond:o}=t,[i]=It(),a=i.toolApprovalLevel??"readonly";let c;e[0]!==n?(c=Object.fromEntries(n.map(Oc)),e[0]=n,e[1]=c):c=e[1];const d=c;let u;e[2]!==a||e[3]!==o?(u=(I,D)=>{const _=D;typeof _?.approved=="boolean"&&o(I.approvalId,_.approved,_.approved===!1?Eo:void 0,_.levelOverride??a)},e[2]=a,e[3]=o,e[4]=u):u=e[4];let f;e[5]!==n||e[6]!==d||e[7]!==s||e[8]!==u?(f={parts:n,partKey:Mc,schema:Ec,defaultValues:d,isStreaming:s,hasAnswer:Pc,onSubmit:u},e[5]=n,e[6]=d,e[7]=s,e[8]=u,e[9]=f):f=e[9];const l=_o(f);let V;e[10]!==n||e[11]!==l?(V=I=>{l.form.reset(Object.fromEntries(n.map(D=>[D.approvalId,{approved:!0,levelOverride:I}]))),l.submitOrAdvance()},e[10]=n,e[11]=l,e[12]=V):V=e[12];const m=V,v=l.currentPart;let p;e[13]!==l?(p=I=>{I.preventDefault(),l.submit()},e[13]=l,e[14]=p):p=e[14];let h;e[15]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Fn,{size:14}),e[15]=h):h=e[15];const y=`${n.length} approvals pending`,x=v?.friendlyName??"";let w;e[16]!==m?(w=r.jsx(To,{onYolo:m}),e[16]=m,e[17]=w):w=e[17];let S;e[18]!==n.length||e[19]!==l.currentIndex||e[20]!==l.goNext||e[21]!==l.goPrev||e[22]!==w?(S=r.jsx(Do,{currentIndex:l.currentIndex,total:n.length,onPrev:l.goPrev,onNext:l.goNext,extraLeft:w}),e[18]=n.length,e[19]=l.currentIndex,e[20]=l.goNext,e[21]=l.goPrev,e[22]=w,e[23]=S):S=e[23];let N;e[24]!==v||e[25]!==l.form.control||e[26]!==l.submitOrAdvance?(N=v?r.jsx(Lc,{approvalId:v.approvalId,control:l.form.control,onChange:l.submitOrAdvance}):null,e[24]=v,e[25]=l.form.control,e[26]=l.submitOrAdvance,e[27]=N):N=e[27];let C;e[28]!==v?(C=v?r.jsx(Po,{input:v.input}):null,e[28]=v,e[29]=C):C=e[29];let b;e[30]!==S||e[31]!==N||e[32]!==C||e[33]!==y||e[34]!==x?(b=r.jsx(dt,{icon:h,label:y,title:x,defaultExpanded:!0,footerLeft:S,footerRight:N,children:C}),e[30]=S,e[31]=N,e[32]=C,e[33]=y,e[34]=x,e[35]=b):b=e[35];let A;e[36]!==b||e[37]!==p?(A=r.jsx("form",{onSubmit:p,children:b}),e[36]=b,e[37]=p,e[38]=A):A=e[38];let j;return e[39]!==l.form||e[40]!==A?(j=r.jsx(Xt,{...l.form,children:A}),e[39]=l.form,e[40]=A,e[41]=j):j=e[41],j}function Pc(t){return typeof t?.approved=="boolean"}function Mc(t){return t.approvalId}function Oc(t){return[t.approvalId,{approved:void 0}]}function Lc(t){const e=z.c(6),{approvalId:n,control:s,onChange:o}=t,i=`${n}.approved`;let a;e[0]!==o?(a=d=>{const{field:u}=d,f=u.value===!0,l=u.value===!1;return r.jsxs(r.Fragment,{children:[r.jsx(ie,{type:"button",variant:l?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{u.onChange(!1),o()},"aria-pressed":l,children:"Deny"}),r.jsx(ie,{type:"button",variant:f?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{u.onChange(!0),o()},"aria-pressed":f,children:"Accept"})]})},e[0]=o,e[1]=a):a=e[1];let c;return e[2]!==s||e[3]!==i||e[4]!==a?(c=r.jsx(Bi,{control:s,name:i,render:a}),e[2]=s,e[3]=i,e[4]=a,e[5]=c):c=e[5],c}function Fc(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[r.jsx(Fn,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function $c(t){const e=z.c(8),{approvals:n,isStreaming:s,onRespond:o}=t;if(s&&n.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Fc,{}),e[0]=a):a=e[0],a}if(n.length===0)return null;if(n.length===1){const a=n[0];if(!a)return null;let c;return e[1]!==o||e[2]!==a?(c=r.jsx(_c,{approval:a,onRespond:o}),e[1]=o,e[2]=a,e[3]=c):c=e[3],c}let i;return e[4]!==n||e[5]!==s||e[6]!==o?(i=r.jsx(Tc,{approvals:n,isStreaming:s,onRespond:o}),e[4]=n,e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zc(t){const e=z.c(16),{plan:n,onApprove:s,onDismiss:o}=t;let i;e[0]!==s||e[1]!==n.plan?(i=()=>{s(n.plan)},e[0]=s,e[1]=n.plan,e[2]=i):i=e[2];const a=i;let c;e[3]!==o?(c=r.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:o,children:"Keep iterating"}),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==a?(d=r.jsx(ie,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=d):d=e[6];let u;e[7]!==c||e[8]!==d?(u=r.jsxs(r.Fragment,{children:[c,d]}),e[7]=c,e[8]=d,e[9]=u):u=e[9];const f=u;let l;e[10]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ga,{size:14}),e[10]=l):l=e[10];let V;e[11]!==n.plan?(V=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(xa,{id:"plan-preview",part:{type:"text",text:n.plan}})})}),e[11]=n.plan,e[12]=V):V=e[12];let m;return e[13]!==f||e[14]!==V?(m=r.jsx(dt,{icon:l,label:"Plan ready",title:"Implementation Plan",defaultExpanded:!0,footerRight:f,children:V}),e[13]=f,e[14]=V,e[15]=m):m=e[15],m}function Bc(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[r.jsx(Vt,{className:"size-5 text-purple-500 shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function Uc(t){const e=z.c(7),{plans:n,isStreaming:s,onApprove:o,onDismiss:i}=t;if(s&&n.length===0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Bc,{}),e[0]=u):u=e[0],u}let a;e[1]!==n?(a=n.at(-1),e[1]=n,e[2]=a):a=e[2];const c=a;if(!c)return null;let d;return e[3]!==c||e[4]!==o||e[5]!==i?(d=r.jsx(zc,{plan:c,onApprove:o,onDismiss:i}),e[3]=c,e[4]=o,e[5]=i,e[6]=d):d=e[6],d}function Mo(t){return t?"response"in t?t.response:t.option??t.draft:""}const Zs=pt({response:St().min(1,"Response is required")}),Kc=pt({option:St().nullable(),draft:St()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),qc=pt({response:ys(["yes","no"])});function Yc(t){switch(t.type){case"text":return Zs;case"choice":return Kc;case"confirm":return qc;default:return Zs}}function Hc(t){const e={};for(const n of t)e[n.toolCallId]=Yc(n.input);return pt(e)}function Qc(t){const e=z.c(6),{control:n,name:s,placeholder:o}=t;let i;e[0]!==o?(i=c=>{const{field:d}=c,u=d.value??"";return r.jsxs(Ee,{children:[r.jsx(Te,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(eo,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...d,value:u,type:"text",placeholder:o||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),r.jsx(Pe,{})]})},e[0]=o,e[1]=i):i=e[1];let a;return e[2]!==n||e[3]!==s||e[4]!==i?(a=r.jsx($e,{control:n,name:s,render:i}),e[2]=n,e[3]=s,e[4]=i,e[5]=a):a=e[5],a}function Oo(t,e){const n=z.c(4);let s,o;n[0]!==t||n[1]!==e?(s=()=>{const i=a=>{const c=a.target.tagName;if(c==="INPUT"||c==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const d=Number.parseInt(a.key,10);d>=1&&d<=t&&(a.preventDefault(),e(d-1))};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},o=[t,e],n[0]=t,n[1]=e,n[2]=s,n[3]=o):(s=n[2],o=n[3]),g.useEffect(s,o)}function Wc(t){const e=z.c(40),{control:n,name:s,options:o}=t,i=`${s}.option`;let a;e[0]!==n||e[1]!==i?(a={control:n,name:i,defaultValue:null},e[0]=n,e[1]=i,e[2]=a):a=e[2];const{field:c}=Ls(a),d=`${s}.draft`;let u;e[3]!==n||e[4]!==d?(u={control:n,name:d,defaultValue:""},e[3]=n,e[4]=d,e[5]=u):u=e[5];const{field:f}=Ls(u),l=c.value,V=f.value??"";let m;if(e[6]!==c||e[7]!==o?(m=_=>{const R=o[_];R!=null&&c.onChange(R)},e[6]=c,e[7]=o,e[8]=m):m=e[8],Oo(o.length,m),o.length===0)return null;const v=l===null;let p;if(e[9]!==c||e[10]!==l||e[11]!==o){let _;e[13]!==c||e[14]!==l?(_=(R,k)=>{const M=l===R;return r.jsxs("button",{type:"button",onClick:()=>c.onChange(R),className:Y("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",M&&"bg-accent/50",!M&&"hover:bg-accent/30"),"aria-label":`Select ${R}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",M?"bg-chart-1 text-white":"bg-muted text-foreground"),children:k+1}),r.jsx("span",{className:"text-sm text-foreground truncate",children:R})]},`${k}-${R}`)},e[13]=c,e[14]=l,e[15]=_):_=e[15],p=o.map(_),e[9]=c,e[10]=l,e[11]=o,e[12]=p}else p=e[12];const h=v&&"bg-accent/50",y=!v&&"hover:bg-accent/30";let x;e[16]!==h||e[17]!==y?(x=Y("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",h,y),e[16]=h,e[17]=y,e[18]=x):x=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(eo,{size:16,className:"text-muted-foreground"})}),e[19]=w):w=e[19];const S=v?V:"";let N;e[20]!==f||e[21]!==c||e[22]!==l?(N=_=>{f.onChange(_.target.value),l!==null&&c.onChange(null)},e[20]=f,e[21]=c,e[22]=l,e[23]=N):N=e[23];let C;e[24]!==c||e[25]!==l?(C=()=>{l!==null&&c.onChange(null)},e[24]=c,e[25]=l,e[26]=C):C=e[26];let b;e[27]!==S||e[28]!==N||e[29]!==C?(b=r.jsx("input",{type:"text",value:S,onChange:N,onFocus:C,placeholder:"Something else...","aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[27]=S,e[28]=N,e[29]=C,e[30]=b):b=e[30];let A;e[31]!==b||e[32]!==x?(A=r.jsxs("label",{className:x,children:[w,b]}),e[31]=b,e[32]=x,e[33]=A):A=e[33];let j;e[34]!==A||e[35]!==p?(j=r.jsx(Te,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[p,A]})}),e[34]=A,e[35]=p,e[36]=j):j=e[36];let I;e[37]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Pe,{}),e[37]=I):I=e[37];let D;return e[38]!==j?(D=r.jsxs(Ee,{children:[j,I]}),e[38]=j,e[39]=D):D=e[39],D}function Gc(t){const e=z.c(6),{control:n,name:s}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["yes","no"],e[0]=o):o=e[0];const i=o,a=g.useRef(null);let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=f=>{a.current?.onChange(i[f]??"")},e[1]=c):c=e[1],Oo(i.length,c);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=f=>{const{field:l}=f;return a.current=l,r.jsxs(Ee,{children:[r.jsx(Te,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:i.map(V=>{const m=l.value===V;return r.jsxs("button",{type:"button",onClick:()=>l.onChange(V),className:Y("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${V}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:V==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:V})]},V)})})}),r.jsx(Pe,{})]})},e[2]=d):d=e[2];let u;return e[3]!==n||e[4]!==s?(u=r.jsx($e,{control:n,name:s,render:d}),e[3]=n,e[4]=s,e[5]=u):u=e[5],u}function er(t){const e=z.c(13),{input:n,control:s,toolCallId:o}=t;switch(n.type){case"text":{const i=`${o}.response`;let a;return e[0]!==s||e[1]!==n.default||e[2]!==i?(a=r.jsx(Qc,{control:s,name:i,placeholder:n.default}),e[0]=s,e[1]=n.default,e[2]=i,e[3]=a):a=e[3],a}case"choice":{let i;e[4]!==n.options?(i=n.options?.filter(Boolean)??[],e[4]=n.options,e[5]=i):i=e[5];const a=i;let c;return e[6]!==s||e[7]!==a||e[8]!==o?(c=r.jsx(Wc,{control:s,name:o,options:a}),e[6]=s,e[7]=a,e[8]=o,e[9]=c):c=e[9],c}case"confirm":{const i=`${o}.response`;let a;return e[10]!==s||e[11]!==i?(a=r.jsx(Gc,{control:s,name:i}),e[10]=s,e[11]=i,e[12]=a):a=e[12],a}default:return null}}function Xc(t){const e=z.c(71),{parts:n,isStreaming:s,onSubmit:o}=t;let i;e[0]!==n?(i=Hc(n.map(td)),e[0]=n,e[1]=i):i=e[1];const a=i;let c;e[2]!==n?(c=Object.fromEntries(n.map(ed)),e[2]=n,e[3]=c):c=e[3];const d=c;let u;e[4]!==o?(u=(P,T)=>{const L=Mo(T);L&&o(P,L)},e[4]=o,e[5]=u):u=e[5];let f;e[6]!==d||e[7]!==s||e[8]!==n||e[9]!==a||e[10]!==u?(f={parts:n,partKey:Zc,schema:a,defaultValues:d,isStreaming:s,hasAnswer:Jc,onSubmit:u},e[6]=d,e[7]=s,e[8]=n,e[9]=a,e[10]=u,e[11]=f):f=e[11];const l=_o(f),V=l.currentPart;let m;e[12]!==V||e[13]!==l?(m=()=>{const P=V;if(!P)return;const T=P.toolCallId;P.input?.type==="choice"?(l.form.setValue(`${T}.option`,null),l.form.setValue(`${T}.draft`,"user has skip this question")):l.form.setValue(`${T}.response`,"user has skip this question"),l.advanceToNextUnanswered()},e[12]=V,e[13]=l,e[14]=m):m=e[14];const v=m;let p;e[15]!==l.currentIndex||e[16]!==l.goNext||e[17]!==l.goPrev||e[18]!==n.length?(p=r.jsx(Do,{currentIndex:l.currentIndex,total:n.length,onPrev:l.goPrev,onNext:l.goNext}),e[15]=l.currentIndex,e[16]=l.goNext,e[17]=l.goPrev,e[18]=n.length,e[19]=p):p=e[19];const h=p;let y;e[20]!==v?(y=r.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:v,className:"h-7",children:"Skip"}),e[20]=v,e[21]=y):y=e[21];let x;e[22]!==l.isAllAnswered||e[23]!==l.isCurrentAnswered||e[24]!==l.submitOrAdvance||e[25]!==s?(x=r.jsx(kc,{isStreaming:s,isAllAnswered:l.isAllAnswered,isCurrentAnswered:l.isCurrentAnswered,onAdvanceOrSubmit:l.submitOrAdvance}),e[22]=l.isAllAnswered,e[23]=l.isCurrentAnswered,e[24]=l.submitOrAdvance,e[25]=s,e[26]=x):x=e[26];let w;e[27]!==y||e[28]!==x?(w=r.jsxs(r.Fragment,{children:[y,x]}),e[27]=y,e[28]=x,e[29]=w):w=e[29];const S=w;if(n.length===1){const P=n[0];if(!P?.input)return null;let T;e[30]!==l?(T=F=>{F.preventDefault(),l.submit()},e[30]=l,e[31]=T):T=e[31];let L;e[32]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Vs,{size:14}),e[32]=L):L=e[32];const U=P.input?.prompt??"Question",$=P.input;let B;e[33]!==l.form.control||e[34]!==P.toolCallId||e[35]!==$?(B=r.jsx(er,{input:$,control:l.form.control,toolCallId:P.toolCallId}),e[33]=l.form.control,e[34]=P.toolCallId,e[35]=$,e[36]=B):B=e[36];let K;e[37]!==S||e[38]!==U||e[39]!==B?(K=r.jsx(dt,{icon:L,label:"Question pending",title:U,defaultExpanded:!0,footerRight:S,children:B}),e[37]=S,e[38]=U,e[39]=B,e[40]=K):K=e[40];let H;e[41]!==T||e[42]!==K?(H=r.jsx("form",{onSubmit:T,autoComplete:"off",children:K}),e[41]=T,e[42]=K,e[43]=H):H=e[43];let O;return e[44]!==l.form||e[45]!==H?(O=r.jsx(Xt,{...l.form,children:H}),e[44]=l.form,e[45]=H,e[46]=O):O=e[46],O}const N=l.form;let C;e[47]!==l?(C=P=>{P.preventDefault(),l.submit()},e[47]=l,e[48]=C):C=e[48];let b;e[49]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Vs,{size:14}),e[49]=b):b=e[49];const A=`${l.currentIndex+1} of ${n.length}`,j=V?.input?.prompt??"Question",I=l.activeKey,D=l.setActiveKey;let _;if(e[50]!==l.form||e[51]!==n){let P;e[53]!==l.form?(P=T=>r.jsx(cl,{value:T.toolCallId,className:"mt-0",children:r.jsx(er,{input:T.input,control:l.form.control,toolCallId:T.toolCallId})},T.toolCallId),e[53]=l.form,e[54]=P):P=e[54],_=n.map(P),e[50]=l.form,e[51]=n,e[52]=_}else _=e[52];let R;e[55]!==l.activeKey||e[56]!==l.setActiveKey||e[57]!==_?(R=r.jsx(dl,{value:I,onValueChange:D,children:_}),e[55]=l.activeKey,e[56]=l.setActiveKey,e[57]=_,e[58]=R):R=e[58];let k;e[59]!==h||e[60]!==S||e[61]!==A||e[62]!==j||e[63]!==R?(k=r.jsx(dt,{icon:b,label:"Question pending",count:A,title:j,defaultExpanded:!0,footerLeft:h,footerRight:S,children:R}),e[59]=h,e[60]=S,e[61]=A,e[62]=j,e[63]=R,e[64]=k):k=e[64];let M;e[65]!==C||e[66]!==k?(M=r.jsx("form",{onSubmit:C,autoComplete:"off",children:k}),e[65]=C,e[66]=k,e[67]=M):M=e[67];let E;return e[68]!==l.form||e[69]!==M?(E=r.jsx(Xt,{...N,children:M}),e[68]=l.form,e[69]=M,e[70]=E):E=e[70],E}function Jc(t){return!!Mo(t)}function Zc(t){return t.toolCallId}function ed(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function td(t){return{toolCallId:t.toolCallId,input:t.input}}function nd(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[r.jsx(Vs,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Lo(t){const e=z.c(7),{userAskParts:n,isStreaming:s,onSubmit:o}=t;let i;e[0]!==n?(i=n.filter(sd),e[0]=n,e[1]=i):i=e[1];const a=i;if(a.length===0){if(s){let d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(nd,{}),e[2]=d):d=e[2],d}return null}let c;return e[3]!==s||e[4]!==o||e[5]!==a?(c=r.jsx(Xc,{parts:a,isStreaming:s,onSubmit:o}),e[3]=s,e[4]=o,e[5]=a,e[6]=c):c=e[6],c}function sd(t){return t.state==="input-available"}function rd(t){const e=t.filter(i=>i.status==="in_progress"),n=t.filter(i=>i.status==="completed").length,s=t.length;if(s>0&&n===s)return{icon:"completed",activity:"All done",progress:`${s}/${s}`};const[o]=e;return o&&e.length===1?{icon:"in_progress",activity:o.activeForm,progress:`${n}/${s} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${n}/${s} done`}:n>0?{icon:"pending",activity:`${s-n} pending`,progress:`${n}/${s} done`}:{icon:"pending",activity:`${s} todos`,progress:"not started"}}function od(){const t=z.c(21),{messages:e}=Dt();let n,s,o,i,a,c,d,u,f;if(t[0]!==e){f=Symbol.for("react.early_return_sentinel");e:{const m=Co(e);if(m.length===0){f=null;break e}const v=rd(m);n=dt,a=r.jsx(cd,{status:v.icon}),c=v.activity,d=v.progress,u=!1,s="todos-list",o="flex flex-col px-2 max-h-[40vh] overflow-y-auto",i=m.map(id)}t[0]=e,t[1]=n,t[2]=s,t[3]=o,t[4]=i,t[5]=a,t[6]=c,t[7]=d,t[8]=u,t[9]=f}else n=t[1],s=t[2],o=t[3],i=t[4],a=t[5],c=t[6],d=t[7],u=t[8],f=t[9];if(f!==Symbol.for("react.early_return_sentinel"))return f;let l;t[10]!==s||t[11]!==o||t[12]!==i?(l=r.jsx("ul",{"data-testid":s,className:o,children:i}),t[10]=s,t[11]=o,t[12]=i,t[13]=l):l=t[13];let V;return t[14]!==n||t[15]!==a||t[16]!==c||t[17]!==d||t[18]!==u||t[19]!==l?(V=r.jsx(n,{icon:a,label:c,count:d,defaultExpanded:u,children:l}),t[14]=n,t[15]=a,t[16]=c,t[17]=d,t[18]=u,t[19]=l,t[20]=V):V=t[20],V}function id(t,e){return r.jsx(ad,{todo:t},e)}function ad(t){const e=z.c(14),{todo:n}=t,s=n.status==="completed",i=n.status==="in_progress"?n.activeForm:n.content;let a;e[0]!==n.status?(a=r.jsx(ld,{status:n.status}),e[0]=n.status,e[1]=a):a=e[1];const c=s&&"text-muted-foreground";let d;e[2]!==c?(d=Y("relative text-sm leading-snug pt-px select-none",c),e[2]=c,e[3]=d):d=e[3];const u=s?"100%":"0%",f=s?"width 300ms ease 200ms":"width 150ms ease";let l;e[4]!==u||e[5]!==f?(l=r.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:u,transition:f}}),e[4]=u,e[5]=f,e[6]=l):l=e[6];let V;e[7]!==i||e[8]!==d||e[9]!==l?(V=r.jsxs("span",{className:d,children:[i,l]}),e[7]=i,e[8]=d,e[9]=l,e[10]=V):V=e[10];let m;return e[11]!==a||e[12]!==V?(m=r.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,V]}),e[11]=a,e[12]=V,e[13]=m):m=e[13],m}function ld(t){const e=z.c(4),{status:n}=t,s=n==="completed"?"true":void 0,o=n==="in_progress"?"true":void 0;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("svg",{viewBox:"0 0 21 21",children:r.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=i):i=e[0];let a;return e[1]!==s||e[2]!==o?(a=r.jsx("div",{className:"todo-cb mt-0.5","data-checked":s,"data-progress":o,"aria-hidden":"true",children:i}),e[1]=s,e[2]=o,e[3]=a):a=e[3],a}function cd(t){const e=z.c(3),{status:n}=t;if(n==="completed"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:r.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:r.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=o):o=e[0],o}if(n==="in_progress"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=o):o=e[1],o}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=s):s=e[2],s}const dd={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},ud=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Fo(t){const e=z.c(41),{onDismiss:n}=t,{org:s}=Ce(),o=ht(),{decoKeyId:i}=fo(),a=Vo(),[c,d]=g.useState(""),[u,f]=g.useState(!1),[l,V]=g.useState("usd"),m=l==="brl"?"R$":"$";let v,p;e[0]!==s.id?(v=()=>{X("credits_exhausted_shown",{organization_id:s.id})},p=[s.id],e[0]=s.id,e[1]=v,e[2]=p):(v=e[1],p=e[2]),g.useEffect(v,p);let h;e[3]!==l||e[4]!==a?(h=async P=>{const{url:T}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:P,currency:l});return T},e[3]=l,e[4]=a,e[5]=h):h=e[5];let y;e[6]!==n?(y=P=>{P&&window.open(P,"_blank","noopener,noreferrer"),n?.()},e[6]=n,e[7]=y):y=e[7];let x;e[8]!==h||e[9]!==y?(x={mutationFn:h,onSuccess:y,onError:md},e[8]=h,e[9]=y,e[10]=x):x=e[10];const{mutate:w,isPending:S}=ws(x),N=parseFloat(c),C=!isNaN(N)&&N>=1;let b;e[11]!==n?(b=P=>!P&&n?.(),e[11]=n,e[12]=b):b=e[12];let A;e[13]===Symbol.for("react.memo_cache_sentinel")?(A=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[13]=A):A=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:A.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[14]=j):j=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[j,r.jsxs(Rt,{className:"relative gap-4",children:[r.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),r.jsxs("div",{children:[r.jsx(_t,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),r.jsx(Pn,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[15]=I):I=e[15];let D;e[16]!==l||e[17]!==m||e[18]!==c||e[19]!==N||e[20]!==i||e[21]!==C||e[22]!==S||e[23]!==u||e[24]!==w?(D=i&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(uo,{type:"single",variant:"outline",size:"sm",value:l,onValueChange:P=>{P&&V(P)},children:[r.jsx(yn,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(yn,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:dd[l].map(P=>{const{dollars:T,label:L}=P;return r.jsxs("button",{type:"button",disabled:S,onClick:()=>{X("credits_topup_clicked",{amount_cents:T*100,currency:l,tier_label:L,source:"exhausted_banner"}),w(T*100)},className:Y("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,T]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:L})]},T)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),r.jsx(tt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:P=>d(P.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(ie,{className:"h-10",disabled:!C||S,onClick:()=>{X("credits_topup_clicked",{amount_cents:Math.round(N*100),currency:l,tier_label:"custom",source:"exhausted_banner"}),w(Math.round(N*100))},children:S?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>f(!0),children:"Enter custom amount"})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:ud.map(fd)})]}),e[16]=l,e[17]=m,e[18]=c,e[19]=N,e[20]=i,e[21]=C,e[22]=S,e[23]=u,e[24]=w,e[25]=D):D=e[25];let _;e[26]!==n?(_=r.jsx(ie,{variant:"ghost",size:"sm",onClick:n,children:"Dismiss"}),e[26]=n,e[27]=_):_=e[27];let R;e[28]!==o||e[29]!==n||e[30]!==s.slug?(R=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{o({to:"/$org/settings/ai-providers",params:{org:s.slug}}),n?.()},children:"Manage providers"}),e[28]=o,e[29]=n,e[30]=s.slug,e[31]=R):R=e[31];let k;e[32]!==_||e[33]!==R?(k=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[_,R]}),e[32]=_,e[33]=R,e[34]=k):k=e[34];let M;e[35]!==D||e[36]!==k?(M=r.jsxs(Et,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Vd,children:[I,D,k]}),e[35]=D,e[36]=k,e[37]=M):M=e[37];let E;return e[38]!==M||e[39]!==b?(E=r.jsx(Tt,{open:!0,onOpenChange:b,children:M}),e[38]=M,e[39]=b,e[40]=E):E=e[40],E}function fd(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(Vt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Vd(t){return t.preventDefault()}function md(t){ue.error(`Top-up failed: ${t.message}`)}function pd(){const t=z.c(5),e=En(),n=mo(),[s,o]=g.useState(!1);if(!(e?.lockedSandbox==="user-desktop")||!n.ready||n.online)return null;let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Cs,{size:14}),t[0]=a):a=t[0];let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(ie,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>o(!0),children:"Reconnect desktop"}),t[1]=c):c=t[1];let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(dt,{icon:a,label:"Your desktop is offline",title:"This chat runs on your desktop, which isn't connected right now.",defaultExpanded:!0,variant:"warning",footerRight:c,children:r.jsxs("p",{className:"mx-4 text-xs text-muted-foreground",children:["Run ",r.jsx("code",{className:"font-mono",children:"bunx decocms@latest link"})," in a terminal on that machine to bring it back. Messages you send while it's offline will fail."]})}),t[2]=d):d=t[2];let u;return t[3]!==s?(u=r.jsxs(r.Fragment,{children:[d,r.jsx(Vl,{open:s,onOpenChange:o})]}),t[3]=s,t[4]=u):u=t[4],u}function hd(t){const e=t.trim(),n=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),s=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),o=/failed to fetch|networkerror|load failed|offline/i.test(e),i=/timeout|timed out|aborted|deadline/i.test(e),a=e.length>240,c=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(c){const d=c[1]?.trim().replace(/\.$/,"");return{summary:d?`Your sandbox didn't finish starting up (${d}). Try again.`:"Your sandbox didn't finish starting up. Try again.",rawDetails:t}}return/link_unavailable|user_desktop_link_/i.test(e)?/user_desktop_link_capability_missing/i.test(e)?{summary:"Your desktop is connected, but the CLI this chat uses wasn't detected there. Install it and sign in on your desktop, then try again.",rawDetails:t}:{summary:"Your desktop is offline. Run `bunx decocms@latest link` in a terminal on it, then try again.",rawDetails:t}:s||n&&a?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:o?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:i?{summary:"That took longer than expected. Try again.",rawDetails:t}:n||a?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const gd={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function wn(t){const e=z.c(19),{variant:n,onDismiss:s}=t,o=n==="error",i=o?"Error occurred":"Response incomplete",a=o?ro:Pr,c=o?t.error.message:gd[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`;let d;e[0]!==o||e[1]!==c?(d=o?hd(c):{summary:c,rawDetails:null},e[0]=o,e[1]=c,e[2]=d):d=e[2];const{summary:u,rawDetails:f}=d;let l;e[3]!==a?(l=r.jsx(a,{size:14}),e[3]=a,e[4]=l):l=e[4];let V;e[5]!==o||e[6]!==t.onContinue||e[7]!==t.onFixInChat?(V=o?r.jsx(ie,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}):r.jsx(ie,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"}),e[5]=o,e[6]=t.onContinue,e[7]=t.onFixInChat,e[8]=V):V=e[8];let m;e[9]!==f?(m=f?r.jsxs("details",{className:"group mx-4",children:[r.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[r.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m4.5 3 3 3-3 3"})}),r.jsx("span",{className:"group-open:hidden",children:"Show technical details"}),r.jsx("span",{className:"hidden group-open:inline",children:"Hide technical details"})]}),r.jsxs("div",{className:"relative mt-2",children:[r.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(f).then(vd).catch(xd)},"aria-label":"Copy error details",title:"Copy",className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:r.jsx(il,{className:"size-3.5"})}),r.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:f})]})]}):null,e[9]=f,e[10]=m):m=e[10];let v;return e[11]!==i||e[12]!==s||e[13]!==u||e[14]!==l||e[15]!==V||e[16]!==m||e[17]!==n?(v=r.jsx(dt,{icon:l,label:i,title:u,defaultExpanded:!0,variant:n,onClose:s,footerRight:V,children:m}),e[11]=i,e[12]=s,e[13]=u,e[14]=l,e[15]=V,e[16]=m,e[17]=n,e[18]=v):v=e[18],v}function xd(){return ue.error("Could not copy")}function vd(){return ue.success("Copied to clipboard")}function zn(){const t=z.c(62),{error:e,clearError:n,finishReason:s,clearFinishReason:o,messages:i,isStreaming:a,submit:c,sendMessage:d}=Dt(),[u,f]=It(),{virtualMcpId:l,createTaskWithMessage:V}=$r(),{chatMode:m,simpleModeTier:v}=ut();let p;t[0]!==m||t[1]!==v||t[2]!==l?(p=G=>({tier:v,mode:m,toolApprovalLevel:G,agent:l?{id:l}:void 0}),t[0]=m,t[1]=v,t[2]=l,t[3]=p):p=t[3];const h=p;let y;t[4]!==u.toolApprovalLevel?(y=u.toolApprovalLevel??Ui(),t[4]=u.toolApprovalLevel,t[5]=y):y=t[5];const x=y,w=i.at(-1),S=w?.role==="assistant"?w.parts:[],N=S.filter(jd),C=No(S),b=So(S);let A;t[6]!==e||t[7]!==d?(A=()=>{if(e){const le={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};d(le)}},t[6]=e,t[7]=d,t[8]=A):A=t[8];const j=A;let I;t[9]!==d?(I=()=>{d({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[9]=d,t[10]=I):I=t[10];const D=I;let _;t[11]!==h||t[12]!==x||t[13]!==c?(_=(G,le)=>{c({kind:"toolOutput",toolCallId:G.toolCallId,output:{response:le}},h(x))},t[11]=h,t[12]=x,t[13]=c,t[14]=_):_=t[14];const R=_;let k;t[15]!==V||t[16]!==u||t[17]!==f||t[18]!==l?(k=G=>{f({...u,toolApprovalLevel:"auto"}),V({virtualMcpId:l,message:{parts:[{type:"text",text:`Implement this plan:
|
|
1
|
+
import{m as kt,r as g,ak as Mi,ai as Oi,c as z,G as Ce,l as Y,j as r,E as Li,t as ue,o as pt,aw as Fi,s as St,ax as ys,L as _r,B as ie,p as Er,n as Tr,ay as $i,az as zi,I as It,a1 as Bi,aA as Ut,aB as Ls,b as ht,d as ws,v as X,aC as Ui,W as Pr,V as Ki,D as qi,aD as Yi,a as _n,aE as Hi,aF as Mr,aG as Qi,aH as Xe,aI as Wn,ae as At,aJ as Wi,aK as Gn,aL as Gi,aM as Xi,aN as Ji,aO as Zi,q as ea,K as Je,aP as ta,aQ as na,aR as sa,aS as ra,aT as Or,aU as qt,k as oa,i as Yt,z as ia,C as aa,a2 as Lr,a3 as Ve}from"./index-Fhr28YR7.js";import{a as Fr,n as la}from"./SwitchHorizontal01--w7jw1gn.js";import{b as ut,u as Dt,S as ds,c as En,a as $r,f as zr,s as ca,g as da,h as ua,i as fa,j as Br,A as Va,k as ma,l as pa}from"./chat-context-Bd0ASrBV.js";import{j as Ur,s as Tn,g as ct,P as vn,k as js,t as ha,l as ga,M as xa,m as va,n as bn,o as Kr,p as ba,D as ya,q as wa,r as ja,v as Nt,w as Aa,d as Ca,x as Sa,y as As,z as Na,F as ka,i as Ia,E as Da,c as Ra,A as _a,B as Ea,H as Ta,I as Pa,J as Fs}from"./scroll-area-B0ntssfk.js";import{c as us,a as Ue,b as Ke,T as qe}from"./tooltip-KzEPH1eR.js";import{c as Rt,a as _t,d as Et,e as Tt,b as Pn,D as Ma}from"./dialog-B1eqTnf8.js";import{c as qr,b as Yr,a as Hr,D as Qr,d as Oa,e as La,f as Fa}from"./drawer-HScIqfkZ.js";import{C as Wr}from"./collection-search-qo9IZJLR.js";import{u as Gr}from"./use-mobile-fVP68LM8.js";import{a as Mn,u as gt,S as Xr,i as $s}from"./use-mcp-client-BBa18C66.js";import{u as $a,g as On,l as fs}from"./use-mcp-prompts-BJlX80Yp.js";import{t as Ln}from"./ChevronDown-BcFakGFK.js";import{i as yt}from"./X-RECo41yg.js";import{t as za,z as Ba,b as Ua,w as Ka,A as qa}from"./hooks-BkWjlB2G.js";import{K as Ya,i as Ha}from"./shell-layout-C_sGpxte.js";import{a as Qa,u as Wa}from"./use-virtual-mcp-CrBCSZ6B.js";import{n as Jr}from"./ZapSquare-EaCsR4ke.js";import{i as Vt}from"./ChevronUp-CAyCvjRf.js";import{s as Ht}from"./Star01-D-DX_VQ8.js";import{a as Zr}from"./Tool01-CYQXbAs9.js";import{af as Fn,y as Ga,a7 as eo,ag as Xa,A as to,g as mn,h as Ja,a9 as Za,ah as el,D as tl,ai as no,ab as nl,aj as sl,ak as rl,c as so}from"./agent-icon-BtQxKV8a.js";import{i as ol}from"./Upload01-DgQHfPA4.js";import{i as ro}from"./AlertCircle-Cq24_c-o.js";import{a as il}from"./Eye-CVTjrdPN.js";import{a as Xt,b as Ee,d as Te,e as Pe,F as $e,c as Ge}from"./form-UVWmiPtA.js";import{b as oo,d as io,c as wt,S as ao,a as lo}from"./select-Bz_zhsne.js";import{b as al}from"./Settings02-C2Ys_yfp.js";import{i as co,t as Vs,b as ll,n as pn,c as Xn}from"./XCircle-BhV8maG9.js";import{b as cl,c as dl}from"./tabs-DLPd0DvT.js";import{a as uo,T as yn}from"./toggle-group-ClY9GDOR.js";import{I as tt}from"./input-pJMroKkw.js";import{u as fo,a as ul,g as fl}from"./agent-capabilities-BOrZcw_f.js";import{u as Vo}from"./studio-tools-C5AidOwh.js";import{i as Cs}from"./Monitor01-oM90habT.js";import{u as mo,C as Vl,a as po,b as ho}from"./connect-desktop-dialog-BdgVHbLH.js";import{s as go}from"./XClose-DNorGtW0.js";import{m as $n,i as ml,g as xo,a as pl,N as hl}from"./decopilot-DsMsc6aJ.js";import{P as Ss,a as Ns,b as ks}from"./popover-BGYh0Vqy.js";import{e as zs,a as Bs,g as gl,b as xl,C as vl,c as bl,d as yl}from"./command-DOtqEIF_.js";import{u as wl}from"./useInfiniteQuery-_DQrdP-B.js";import{t as jl}from"./Stars01-BT514mww.js";import{q as Al,r as Cl,s as Sl,t as Nl,S as kl,B as Il}from"./index-BeAkwX8F.js";import{D as Dl,a as Rl,b as _l,c as at,d as Us,e as Ks,f as qs,j as El,i as Tl}from"./dropdown-menu-BQUhOJKy.js";import{s as ms}from"./Plus-BDlCzerf.js";import{p as Pl,q as Ml}from"./question-004-sINsf4GQ.js";import{g as Ol}from"./connection-slug-eyAPH6o3.js";import{u as vo,a as bo,g as Ll,C as Jn}from"./connection-card-CrD4DNgk.js";import{C as Fl}from"./collection-tabs-D8PDp1vW.js";import{a as $l,b as zl,e as Bl,g as Ul}from"./extract-connection-data-MlduhWsI.js";import{T as Kl}from"./textarea-CjWp7xSP.js";import{b as yo}from"./use-connection-iaNqg2f9.js";import{c as ql,i as ln,a as Ys,E as Yl,p as Hl,b as Ql,d as Wl}from"./connection-form-helpers-OWEpNePK.js";import{u as Hs}from"./use-infinite-scroll-n6K3XvYN.js";import{a as Zn}from"./authenticate-and-persist-oauth-DGhgmpvt.js";import{B as cn}from"./badge-C8xW1-Ny.js";import{u as Gl}from"./useSuspenseInfiniteQuery-CkKiinpE.js";import{i as Xl}from"./ChevronRight-Bc7TkKo_.js";import{k as Jl}from"./tab-id-DPNwWMUY.js";function Zl(t,e){const n=kt(e);return ec({filters:{...t,status:"pending"}},n).length}function Qs(t,e){return t.findAll(e.filters).map(n=>e.select?e.select(n):n.state)}function ec(t={},e){const n=kt(e).getMutationCache(),s=g.useRef(t),o=g.useRef(null);return o.current===null&&(o.current=Qs(n,t)),g.useEffect(()=>{s.current=t}),g.useSyncExternalStore(g.useCallback(i=>n.subscribe(()=>{const a=Mi(o.current,Qs(n,s.current));o.current!==a&&(o.current=a,Oi.schedule(i))}),[n]),()=>o.current,()=>o.current)}const Ws=3,wo="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",tc="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function jo(t){const e=z.c(46),{item:n,onSelect:s,isLoading:o,isDisabled:i,variant:a}=t,c=a===void 0?"pill":a,{prompt:d}=n;let u;if(e[0]!==d._meta||e[1]!==d.name||e[2]!==d.title){const b=ct(d._meta);u=d.title??js(d.name,b),e[0]=d._meta,e[1]=d.name,e[2]=d.title,e[3]=u}else u=e[3];const f=u,l=d.description||null;if(c==="card"){let b;e[4]!==s||e[5]!==d?(b=()=>s(d),e[4]=s,e[5]=d,e[6]=b):b=e[6];const A=i||o,j=o&&"bg-accent/40",I=(i||o)&&"cursor-not-allowed opacity-50";let D;e[7]!==j||e[8]!==I?(D=Y(tc,"hover:bg-accent/60 text-foreground",j,I),e[7]=j,e[8]=I,e[9]=D):D=e[9];let _;e[10]!==f?(_=r.jsx("span",{className:"font-medium truncate capitalize",children:f}),e[10]=f,e[11]=_):_=e[11];let R;e[12]!==o?(R=o&&r.jsx(ds,{size:"xs"}),e[12]=o,e[13]=R):R=e[13];let k;e[14]!==_||e[15]!==R?(k=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[_,R]}),e[14]=_,e[15]=R,e[16]=k):k=e[16];let M;e[17]!==l?(M=l&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:l}),e[17]=l,e[18]=M):M=e[18];let E;return e[19]!==k||e[20]!==M||e[21]!==b||e[22]!==A||e[23]!==D?(E=r.jsxs("button",{type:"button",onClick:b,disabled:A,className:D,children:[k,M]}),e[19]=k,e[20]=M,e[21]=b,e[22]=A,e[23]=D,e[24]=E):E=e[24],E}let V;e[25]!==s||e[26]!==d?(V=()=>s(d),e[25]=s,e[26]=d,e[27]=V):V=e[27];const m=i||o,v=o&&"bg-muted/50",p=(i||o)&&"cursor-not-allowed opacity-50";let h;e[28]!==v||e[29]!==p?(h=Y(wo,"hover:bg-muted/70 hover:text-foreground",v,p),e[28]=v,e[29]=p,e[30]=h):h=e[30];let y;e[31]!==f?(y=r.jsx("span",{className:"capitalize",children:f}),e[31]=f,e[32]=y):y=e[32];let x;e[33]!==o?(x=o&&r.jsx(ds,{size:"xs"}),e[33]=o,e[34]=x):x=e[34];let w;e[35]!==V||e[36]!==m||e[37]!==h||e[38]!==y||e[39]!==x?(w=r.jsx(Ue,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:V,disabled:m,className:h,children:[y,x]})}),e[35]=V,e[36]=m,e[37]=h,e[38]=y,e[39]=x,e[40]=w):w=e[40];const S=l??f;let N;e[41]!==S?(N=r.jsx(Ke,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:S})}),e[41]=S,e[42]=N):N=e[42];let C;return e[43]!==w||e[44]!==N?(C=r.jsxs(qe,{delayDuration:400,children:[w,N]}),e[43]=w,e[44]=N,e[45]=C):C=e[45],C}function nc(t){const e=z.c(41),{items:n,open:s,onOpenChange:o,onSelect:i,loadingPrompt:a}=t,[c,d]=g.useState(""),u=!!a;let f;e[0]!==n||e[1]!==c?(f=c.trim()?n.filter(A=>{const j=c.toLowerCase();return A.prompt.name.toLowerCase().includes(j)||(A.prompt.title??"").toLowerCase().includes(j)||(A.prompt.description??"").toLowerCase().includes(j)}):n,e[0]=n,e[1]=c,e[2]=f):f=e[2];const l=f,V=Gr();let m;e[3]!==l.length||e[4]!==c?(m=l.length===0&&r.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",c,"”"]}),e[3]=l.length,e[4]=c,e[5]=m):m=e[5];let v;if(e[6]!==l||e[7]!==u||e[8]!==a?.name||e[9]!==o||e[10]!==i){let A;e[12]!==u||e[13]!==a?.name||e[14]!==o||e[15]!==i?(A=j=>r.jsx(jo,{item:j,variant:"card",onSelect:I=>{o(!1),i(I)},isLoading:a?.name===j.prompt.name,isDisabled:u&&a?.name!==j.prompt.name},j.prompt.name),e[12]=u,e[13]=a?.name,e[14]=o,e[15]=i,e[16]=A):A=e[16],v=l.map(A),e[6]=l,e[7]=u,e[8]=a?.name,e[9]=o,e[10]=i,e[11]=v}else v=e[11];let p;e[17]!==m||e[18]!==v?(p=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,v]})}),e[17]=m,e[18]=v,e[19]=p):p=e[19];const h=p;let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=A=>{A.key==="Escape"&&d("")},e[20]=y):y=e[20];let x;e[21]!==c?(x=r.jsx(Wr,{value:c,onChange:d,placeholder:"Search prompts...",onKeyDown:y}),e[21]=c,e[22]=x):x=e[22];const w=x;if(V){let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(qr,{className:"sr-only",children:r.jsx(Yr,{children:"All prompts"})}),e[23]=A):A=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=j):j=e[24];let I;e[25]!==h||e[26]!==w?(I=r.jsxs(Hr,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[A,j,w,h]}),e[25]=h,e[26]=w,e[27]=I):I=e[27];let D;return e[28]!==o||e[29]!==s||e[30]!==I?(D=r.jsx(us,{delayDuration:400,children:r.jsx(Qr,{open:s,onOpenChange:o,children:I})}),e[28]=o,e[29]=s,e[30]=I,e[31]=D):D=e[31],D}let S;e[32]===Symbol.for("react.memo_cache_sentinel")?(S=r.jsx(Rt,{className:"sr-only",children:r.jsx(_t,{children:"All prompts"})}),e[32]=S):S=e[32];let N;e[33]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=N):N=e[33];let C;e[34]!==h||e[35]!==w?(C=r.jsxs(Et,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[S,N,w,h]}),e[34]=h,e[35]=w,e[36]=C):C=e[36];let b;return e[37]!==o||e[38]!==s||e[39]!==C?(b=r.jsx(us,{delayDuration:400,children:r.jsx(Tt,{open:s,onOpenChange:o,children:C})}),e[37]=o,e[38]=s,e[39]=C,e[40]=b):b=e[40],b}function sc(t){const e=z.c(29),{items:n,onSelect:s,loadingPrompt:o,className:i}=t,[a,c]=g.useState(!1);if(n.length===0)return null;let d,u,f;if(e[0]!==n||e[1]!==o||e[2]!==s){const y=n.slice(0,Ws);let x;e[6]!==n?(x=n.slice(Ws),e[6]=n,e[7]=x):x=e[7],d=x,u=!!o;let w;e[8]!==u||e[9]!==o?.name||e[10]!==s?(w=S=>r.jsx(jo,{item:S,onSelect:s,isLoading:o?.name===S.prompt.name,isDisabled:u&&o?.name!==S.prompt.name},S.prompt.name),e[8]=u,e[9]=o?.name,e[10]=s,e[11]=w):w=e[11],f=y.map(w),e[0]=n,e[1]=o,e[2]=s,e[3]=d,e[4]=u,e[5]=f}else d=e[3],u=e[4],f=e[5];const l=f;let V;e[12]!==i?(V=Y("w-full flex flex-wrap gap-2 justify-center",i),e[12]=i,e[13]=V):V=e[13];let m;e[14]!==d.length||e[15]!==u?(m=d.length>0&&r.jsxs("button",{type:"button",disabled:u,onClick:()=>c(!0),className:Y(wo,"hover:bg-muted/70 hover:text-foreground",u&&"opacity-50 cursor-not-allowed"),children:["+",d.length," more"]}),e[14]=d.length,e[15]=u,e[16]=m):m=e[16];let v;e[17]!==l||e[18]!==V||e[19]!==m?(v=r.jsxs("div",{className:V,children:[l,m]}),e[17]=l,e[18]=V,e[19]=m,e[20]=v):v=e[20];let p;e[21]!==n||e[22]!==o||e[23]!==a||e[24]!==s?(p=r.jsx(nc,{items:n,open:a,onOpenChange:c,onSelect:s,loadingPrompt:o}),e[21]=n,e[22]=o,e[23]=a,e[24]=s,e[25]=p):p=e[25];let h;return e[26]!==v||e[27]!==p?(h=r.jsxs(us,{delayDuration:400,children:[v,p]}),e[26]=v,e[27]=p,e[28]=h):h=e[28],h}function rc(){return null}function oc(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function ic(t){const e=z.c(30),{connectionId:n}=t,{sendMessage:s}=Dt(),{org:o}=Ce();let i;e[0]!==n||e[1]!==o.id||e[2]!==o.slug?(i={connectionId:n,orgId:o.id,orgSlug:o.slug},e[0]=n,e[1]=o.id,e[2]=o.slug,e[3]=i):i=e[3];const a=gt(i);let c;e[4]!==a?(c={client:a,staleTime:6e4},e[4]=a,e[5]=c):c=e[5];const{data:d}=$a(c);let u;e[6]!==d?.prompts?(u=d?.prompts??[],e[6]=d?.prompts,e[7]=u):u=e[7];const f=u;let l;e[8]!==f?(l=f.map(ac),e[8]=f,e[9]=l):l=e[9];const V=l;let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m={stage:"idle"},e[10]=m):m=e[10];const[v,p]=g.useReducer(oc,m),[h,y]=g.useState(null);let x;e[11]!==a||e[12]!==s?(x=async(R,k)=>{if(!a){ue.error("MCP client not available"),p({type:"RESET"});return}try{const M=await On(a,R.name,k);p({type:"RESET"});const E={type:"doc",content:[{type:"paragraph",content:[Ur({id:R.name,name:Tn(R.name,ct(R._meta)),metadata:M.messages,char:"/",kind:"prompt",args:k}),{type:"text",text:" "}]}]};await s(E)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),ue.error("Failed to load prompt. Please try again."),p({type:"RESET"})}},e[11]=a,e[12]=s,e[13]=x):x=e[13];const w=x;let S;e[14]!==w?(S=async R=>{if(R.arguments&&R.arguments.length>0){p({type:"SELECT_PROMPT",prompt:R}),y(R);return}p({type:"START_LOADING",prompt:R}),await w(R)},e[14]=w,e[15]=S):S=e[15];const N=S;let C;e[16]!==h||e[17]!==w?(C=async R=>{h&&(p({type:"START_LOADING",prompt:h,arguments:R}),y(null),await w(h,R))},e[16]=h,e[17]=w,e[18]=C):C=e[18];const b=C;if(V.length===0)return null;const A=v.stage==="loading"?v.prompt:null;let j;e[19]!==N||e[20]!==V||e[21]!==A?(j=r.jsx(sc,{items:V,onSelect:N,loadingPrompt:A}),e[19]=N,e[20]=V,e[21]=A,e[22]=j):j=e[22];let I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{y(null),p({type:"RESET"})},e[23]=I):I=e[23];let D;e[24]!==h||e[25]!==b?(D=r.jsx(vn,{prompt:h,setPrompt:I,onSubmit:b}),e[24]=h,e[25]=b,e[26]=D):D=e[26];let _;return e[27]!==j||e[28]!==D?(_=r.jsxs(r.Fragment,{children:[j,D]}),e[27]=j,e[28]=D,e[29]=_):_=e[29],_}function ac(t){return{prompt:t}}function lc(t){const e=z.c(13),{className:n}=t,{selectedVirtualMcp:s}=ut(),{org:o}=Ce();let i;e[0]!==o.id?(i=Mn(o.id),e[0]=o.id,e[1]=i):i=e[1];const a=i.id,c=s?.id??a;let d;e[2]!==n?(d=Y("w-full @container",n),e[2]=n,e[3]=d):d=e[3];const u=c??"default";let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(rc,{}),e[4]=f):f=e[4];let l;e[5]!==c?(l=r.jsx(ic,{connectionId:c}),e[5]=c,e[6]=l):l=e[6];let V;e[7]!==u||e[8]!==l?(V=r.jsx(Li,{fallback:null,children:r.jsx(g.Suspense,{fallback:f,children:l},u)}),e[7]=u,e[8]=l,e[9]=V):V=e[9];let m;return e[10]!==d||e[11]!==V?(m=r.jsx("div",{className:d,children:V}),e[10]=d,e[11]=V,e[12]=m):m=e[12],m}const es="cubic-bezier(0.645, 0.045, 0.355, 1)",cc=44,dc={default:"",error:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-destructive/5 after:pointer-events-none after:-z-10",warning:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-amber-500/5 after:pointer-events-none after:-z-10"},uc={default:"border-border",error:"border-destructive/30",warning:"border-amber-500/30"},fc={default:"text-muted-foreground",error:"text-destructive",warning:"text-amber-600 dark:text-amber-500"};function dt(t){const e=z.c(61),{icon:n,label:s,count:o,title:i,footerLeft:a,footerRight:c,children:d,defaultExpanded:u,variant:f,onClose:l}=t,V=f===void 0?"default":f,[m,v]=g.useState(u),[p,h]=g.useState(!1);let y;e[0]!==l?(y=()=>{h(!0),l?.()},e[0]=l,e[1]=y):y=e[1];const x=y;if(p)return null;const w=uc[V],S=dc[V];let N;e[2]!==w||e[3]!==S?(N=Y("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",w,S),e[2]=w,e[3]=S,e[4]=N):N=e[4];let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=()=>v(Vc),e[5]=C):C=e[5];const b=m&&"rounded-b-none",A=!m&&"rounded-b-xl";let j;e[6]!==b||e[7]!==A?(j=Y("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",b,A),e[6]=b,e[7]=A,e[8]=j):j=e[8];const I=fc[V];let D;e[9]!==I?(D=Y("shrink-0",I),e[9]=I,e[10]=D):D=e[10];let _;e[11]!==n||e[12]!==D?(_=r.jsx("span",{className:D,children:n}),e[11]=n,e[12]=D,e[13]=_):_=e[13];let R;e[14]!==s?(R=r.jsx("span",{className:"flex-1 min-w-0 truncate",children:s}),e[14]=s,e[15]=R):R=e[15];let k;e[16]!==o?(k=o?r.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:o}):null,e[16]=o,e[17]=k):k=e[17];const M=m?"rotate(180deg)":"rotate(0deg)";let E;e[18]!==M?(E=r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:r.jsx(Ln,{size:16,style:{transform:M,transition:`transform 180ms ${es}`}})}),e[18]=M,e[19]=E):E=e[19];let P,T;e[20]!==x?(P=te=>{te.stopPropagation(),x()},T=te=>{(te.key==="Enter"||te.key===" ")&&(te.preventDefault(),te.stopPropagation(),x())},e[20]=x,e[21]=P,e[22]=T):(P=e[21],T=e[22]);let L;e[23]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(yt,{size:16}),e[23]=L):L=e[23];let U;e[24]!==P||e[25]!==T?(U=r.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":"Close",title:"Close",onClick:P,onKeyDown:T,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center justify-center -mr-1 ml-1 p-1 rounded-md hover:bg-accent",children:L}),e[24]=P,e[25]=T,e[26]=U):U=e[26];let $;e[27]!==m||e[28]!==_||e[29]!==R||e[30]!==k||e[31]!==E||e[32]!==U||e[33]!==j?($=r.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":m,onClick:C,className:j,children:[_,R,k,E,U]}),e[27]=m,e[28]=_,e[29]=R,e[30]=k,e[31]=E,e[32]=U,e[33]=j,e[34]=$):$=e[34];const B=m?"1fr":"0fr";let K;e[35]!==B?(K={display:"grid",gridTemplateRows:B,transition:`grid-template-rows 180ms ${es}`},e[35]=B,e[36]=K):K=e[36];let H;e[37]===Symbol.for("react.memo_cache_sentinel")?(H={overflow:"hidden",minHeight:0},e[37]=H):H=e[37];const O=m?1:0;let F;e[38]!==O?(F={opacity:O,transition:`opacity 120ms ${es}`},e[38]=O,e[39]=F):F=e[39];let J;e[40]!==i?(J=i?r.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:i})}):r.jsx("div",{className:"border-t border-dashed border-border/60"}),e[40]=i,e[41]=J):J=e[41];let Q;e[42]!==d||e[43]!==i?(Q=d?r.jsx("div",{className:Y("overflow-clip pb-4",!i&&"pt-4"),children:d}):null,e[42]=d,e[43]=i,e[44]=Q):Q=e[44];let Z;e[45]!==a||e[46]!==c?(Z=a||c?r.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{children:a}),r.jsx("div",{className:"flex items-center gap-2",children:c})]})}):null,e[45]=a,e[46]=c,e[47]=Z):Z=e[47];let q;e[48]!==F||e[49]!==J||e[50]!==Q||e[51]!==Z?(q=r.jsx("div",{style:H,children:r.jsxs("div",{style:F,children:[J,Q,Z]})}),e[48]=F,e[49]=J,e[50]=Q,e[51]=Z,e[52]=q):q=e[52];let se;e[53]!==K||e[54]!==q?(se=r.jsx("div",{"data-testid":"collapsible-highlight-body",style:K,children:q}),e[53]=K,e[54]=q,e[55]=se):se=e[55];let ee;return e[56]!==$||e[57]!==se||e[58]!==N||e[59]!==V?(ee=r.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":V,className:N,children:[$,se]}),e[56]=$,e[57]=se,e[58]=N,e[59]=V,e[60]=ee):ee=e[60],ee}function Vc(t){return!t}const mc=pt({content:St().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:ys(["pending","in_progress","completed"]),activeForm:St().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),Ao=pt({todos:Fi(mc)}),pc="Plan and track multi-step work. Call with the FULL todo list every time — this replaces the prior list. Call at the start of every multi-step request. Skip only for true one-shots (a single tool call or a direct answer). Mark exactly one todo `in_progress` at a time. Flip a todo to `in_progress` before starting it and to `completed` the moment it finishes — do not batch completions. Your prior tool-call inputs are your current state — read your last call to see where you are.";za({description:pc,inputSchema:Ba(Ao),execute:async({todos:t})=>({ok:!0,count:t.length})});const hc="tool-todo_write",gc=new Set(["input-available","output-available"]);function Co(t){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n.role!=="assistant")continue;const s=n.parts;if(Array.isArray(s))for(let o=s.length-1;o>=0;o--){const i=s[o];if(i.type!==hc||typeof i.state!="string"||!gc.has(i.state))continue;const a=Ao.safeParse(i.input);if(a.success)return a.data.todos}}return[]}function So(t){const e=[];for(const n of t)if("state"in n&&n.state==="approval-requested"&&"approval"in n&&n.approval?.id&&"toolCallId"in n&&n.toolCallId){const s="toolName"in n&&typeof n.toolName=="string"?n.toolName:n.type.startsWith("tool-")?n.type.replace("tool-",""):"Tool";e.push({approvalId:n.approval.id,toolCallId:n.toolCallId,toolName:s,friendlyName:ha(ga(s)),input:n.input})}return e}function No(t){const e=[];for(const n of t)if("type"in n&&n.type==="tool-propose_plan"&&"state"in n&&n.state==="input-available"&&"toolCallId"in n&&"input"in n){const s=n.input;e.push({toolCallId:n.toolCallId,plan:s.plan,state:n.state})}return e}function xc(t){return t?t.message.startsWith("[CREDITS]"):!1}const vc={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1};function bc(t){const{messages:e,error:n,finishReason:s,isStreaming:o,isWaitingForApprovals:i}=t;if(!o&&n&&xc(n))return{...vc,isCreditExhausted:!0};const a=e.at(-1),c=a?.role==="assistant"?a.parts:[],d=c,f=!!d.filter(w=>w.type==="tool-user_ask").filter(w=>w.state!=="output-available").length,l=No(c),V=So(d),m=Co(e),v=!o&&!!n,p=V.length>0||o&&i,h=l.length>0,x=!o&&!!s&&s!=="stop"&&!(s==="tool-calls"&&(f||p||h))&&!v;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:v,showWarning:x,hasApprovals:p,hasPlans:h,isWaitingForUserInput:f}}function ko(){const t=z.c(6),{messages:e,error:n,finishReason:s,isStreaming:o,isWaitingForApprovals:i}=Dt(),a=n??null,c=s??null;let d;return t[0]!==o||t[1]!==i||t[2]!==e||t[3]!==a||t[4]!==c?(d=bc({messages:e,error:a,finishReason:c,isStreaming:o,isWaitingForApprovals:i}),t[0]=o,t[1]=i,t[2]=e,t[3]=a,t[4]=c,t[5]=d):d=t[5],d}function yc(){const t=ko();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function Io(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(n=>n.type==="hardBreak"||n.type==="text"&&(!n.text||n.text.trim()==="")):!1)}const wc="__home__";function Is(t,e){return _r.chatDraft(t,e)}function jc(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object"||typeof e.updatedAt!="number")return null;const n=e.tiptapDoc;return!n||typeof n!="object"||n.type!=="doc"||!Array.isArray(n.content)?null:n}function Ac(t,e,n,s,o){const i=Is(e,n);if(Io(s)){t.removeItem(i);return}const a={tiptapDoc:s,updatedAt:Date.now()},c=JSON.stringify(a);try{t.setItem(i,c)}catch(d){if(Sc(d)){const u=new TextEncoder().encode(c).byteLength;o?.onQuotaExceeded?.({docSizeBytes:u});return}throw d}}function Gs(t,e,n){const s=Is(e,n),o=t.getItem(s),i=jc(o);return o!==null&&i===null&&t.removeItem(s),i}function Cc(t,e,n){t.removeItem(Is(e,n))}function Sc(t){if(!t||typeof t!="object")return!1;const e=t.name;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"}function Nc(t){const e=z.c(21),{current:n,total:s,onPrev:o,onNext:i}=t;if(s<=1)return null;const a=n===0,c=n===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let d;e[0]!==c?(d=Y("p-0.5 rounded transition-colors",c),e[0]=c,e[1]=d):d=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(al,{size:14}),e[2]=u):u=e[2];let f;e[3]!==o||e[4]!==a||e[5]!==d?(f=r.jsx("button",{type:"button",onClick:o,disabled:a,className:d,"aria-label":"Previous question",children:u}),e[3]=o,e[4]=a,e[5]=d,e[6]=f):f=e[6];const l=n+1;let V;e[7]!==l||e[8]!==s?(V=r.jsxs("span",{className:"tabular-nums text-xs",children:[l," of ",s]}),e[7]=l,e[8]=s,e[9]=V):V=e[9];const m=n===s-1,v=n===s-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let p;e[10]!==v?(p=Y("p-0.5 rounded transition-colors",v),e[10]=v,e[11]=p):p=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(co,{size:14}),e[12]=h):h=e[12];let y;e[13]!==i||e[14]!==p||e[15]!==m?(y=r.jsx("button",{type:"button",onClick:i,disabled:m,className:p,"aria-label":"Next question",children:h}),e[13]=i,e[14]=p,e[15]=m,e[16]=y):y=e[16];let x;return e[17]!==y||e[18]!==f||e[19]!==V?(x=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[f,V,y]}),e[17]=y,e[18]=f,e[19]=V,e[20]=x):x=e[20],x}function Do(t){const e=z.c(8),{currentIndex:n,total:s,onPrev:o,onNext:i,extraLeft:a}=t;let c;e[0]!==n||e[1]!==i||e[2]!==o||e[3]!==s?(c=r.jsx(Nc,{current:n,total:s,onPrev:o,onNext:i}),e[0]=n,e[1]=i,e[2]=o,e[3]=s,e[4]=c):c=e[4];let d;return e[5]!==a||e[6]!==c?(d=r.jsxs("div",{className:"flex items-center gap-2",children:[c,a]}),e[5]=a,e[6]=c,e[7]=d):d=e[7],d}function kc(t){const e=z.c(17),{isStreaming:n,isAllAnswered:s,isCurrentAnswered:o,onAdvanceOrSubmit:i,submitLabel:a,nextLabel:c}=t,f=s?a===void 0?"Submit":a:c===void 0?"Next":c,l=s?n:!o,V=l?s?"Waiting for the assistant to finish…":"Answer this item to continue":null;let m;e[0]!==l||e[1]!==i?(m=()=>{l||i()},e[0]=l,e[1]=i,e[2]=m):m=e[2];const v=l&&"opacity-50 cursor-not-allowed";let p;e[3]!==v?(p=Y("h-7 px-2.5 text-xs",v),e[3]=v,e[4]=p):p=e[4];let h;e[5]!==l||e[6]!==f||e[7]!==m||e[8]!==p?(h=r.jsx(ie,{type:"button",size:"sm","aria-disabled":l,onClick:m,className:p,children:f}),e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h):h=e[9];const y=h;if(!V)return y;let x;e[10]!==y?(x=r.jsx(Ue,{asChild:!0,children:y}),e[10]=y,e[11]=x):x=e[11];let w;e[12]!==V?(w=r.jsx(Ke,{children:V}),e[12]=V,e[13]=w):w=e[13];let S;return e[14]!==x||e[15]!==w?(S=r.jsxs(qe,{children:[x,w]}),e[14]=x,e[15]=w,e[16]=S):S=e[16],S}function Ro(t,e,n){return t.findIndex(s=>e(s)===n)}function Xs(t,e,n,s){return t.length===0?!1:t.every(o=>s(n[e(o)]))}function Js(t,e,n,s,o){if(t.length===0)return null;const i=Ro(t,e,o);for(let a=1;a<=t.length;a++){const c=t[(i+a)%t.length];if(!c)continue;const d=e(c);if(d!==o&&!s(n[d]))return d}return null}function Ic(t){return!t.isStreaming&&t.allAnswered}function _o(t){const{parts:e,partKey:n,schema:s,defaultValues:o,isStreaming:i,hasAnswer:a,onSubmit:c}=t,d=e[0]?n(e[0]):"",[u,f]=g.useState(d),[l,V]=g.useState(!1),m=Er({resolver:Tr(s),defaultValues:o}),v=m.watch(),p=Ro(e,n,u),h=p>=0?e[p]:void 0,y=a(v[u]),x=Xs(e,n,v,a),w=Ic({isStreaming:i,allAnswered:x}),S=()=>{if(p>0){const D=e[p-1];D&&f(n(D))}},N=()=>{if(p>=0&&p<e.length-1){const D=e[p+1];D&&f(n(D))}},C=()=>{const D=m.getValues(),_=Js(e,n,D,a,u);_&&f(_)},b=()=>{m.handleSubmit(D=>{const _=D;for(const R of e)c(R,_[n(R)])})()},A=g.useRef(b);A.current=b;const j=()=>{w&&(V(!1),A.current())},I=()=>{const D=m.getValues();if(Xs(e,n,D,a)){if(i){V(!0);return}V(!1),A.current()}else{const _=Js(e,n,D,a,u);_&&f(_)}};return g.useEffect(()=>{if(l&&!i){if(!x){V(!1);return}V(!1),A.current()}},[l,i,x]),{form:m,activeKey:u,setActiveKey:f,currentIndex:p,currentPart:h,isCurrentAnswered:y,isAllAnswered:x,canSubmit:w,goPrev:S,goNext:N,advanceToNextUnanswered:C,submit:j,submitOrAdvance:I}}const Eo="User denied this tool call, give other alternatives.";function To(t){const e=z.c(9),{onYolo:n}=t,[s,o]=It();let i;e[0]!==n||e[1]!==s||e[2]!==o?(i=f=>{const l=f,V=s.toolApprovalLevel??"readonly";o({...s,toolApprovalLevel:l}),l==="auto"&&n(V)},e[0]=n,e[1]=s,e[2]=o,e[3]=i):i=e[3];const a=i;let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(ao,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:Rc,children:r.jsx(lo,{})}),e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(oo,{children:Ut.map(Dc)}),e[5]=d):d=e[5];let u;return e[6]!==a||e[7]!==s.toolApprovalLevel?(u=r.jsxs(io,{value:s.toolApprovalLevel,onValueChange:a,children:[c,d]}),e[6]=a,e[7]=s.toolApprovalLevel,e[8]=u):u=e[8],u}function Dc(t){return r.jsx(wt,{value:t.value,children:t.label},t.value)}function Rc(t){return t.stopPropagation()}function Po(t){const e=z.c(5),{input:n}=t;if(n==null){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=i):i=e[0],i}let s;try{let i;e[1]!==n?(i=JSON.stringify(n,null,2),e[1]=n,e[2]=i):i=e[2],s=i}catch{s=String(n)}let o;return e[3]!==s?(o=r.jsx("div",{className:"px-4",children:r.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:s})}),e[3]=s,e[4]=o):o=e[4],o}function _c(t){const e=z.c(28),{approval:n,onRespond:s}=t,[o]=It(),i=o.toolApprovalLevel??"readonly";let a;e[0]!==n.approvalId||e[1]!==i||e[2]!==s?(a=()=>s(n.approvalId,!1,Eo,i),e[0]=n.approvalId,e[1]=i,e[2]=s,e[3]=a):a=e[3];const c=a;let d;e[4]!==n.approvalId||e[5]!==i||e[6]!==s?(d=()=>s(n.approvalId,!0,void 0,i),e[4]=n.approvalId,e[5]=i,e[6]=s,e[7]=d):d=e[7];const u=d;let f;e[8]!==n.approvalId||e[9]!==s?(f=N=>s(n.approvalId,!0,void 0,N),e[8]=n.approvalId,e[9]=s,e[10]=f):f=e[10];const l=f;let V;e[11]!==l?(V=r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(To,{onYolo:l})}),e[11]=l,e[12]=V):V=e[12];const m=V;let v;e[13]!==c?(v=r.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:c,children:"Deny"}),e[13]=c,e[14]=v):v=e[14];let p;e[15]!==u?(p=r.jsx(ie,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:u,children:"Accept"}),e[15]=u,e[16]=p):p=e[16];let h;e[17]!==v||e[18]!==p?(h=r.jsxs(r.Fragment,{children:[v,p]}),e[17]=v,e[18]=p,e[19]=h):h=e[19];const y=h;let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Fn,{size:14}),e[20]=x):x=e[20];let w;e[21]!==n.input?(w=r.jsx(Po,{input:n.input}),e[21]=n.input,e[22]=w):w=e[22];let S;return e[23]!==n.friendlyName||e[24]!==m||e[25]!==y||e[26]!==w?(S=r.jsx(dt,{icon:x,label:"Approval needed",title:n.friendlyName,defaultExpanded:!0,footerLeft:m,footerRight:y,children:w}),e[23]=n.friendlyName,e[24]=m,e[25]=y,e[26]=w,e[27]=S):S=e[27],S}const Ec=$i(St(),pt({approved:zi().optional(),levelOverride:ys(["auto","readonly"]).optional()}));function Tc(t){const e=z.c(42),{approvals:n,isStreaming:s,onRespond:o}=t,[i]=It(),a=i.toolApprovalLevel??"readonly";let c;e[0]!==n?(c=Object.fromEntries(n.map(Oc)),e[0]=n,e[1]=c):c=e[1];const d=c;let u;e[2]!==a||e[3]!==o?(u=(I,D)=>{const _=D;typeof _?.approved=="boolean"&&o(I.approvalId,_.approved,_.approved===!1?Eo:void 0,_.levelOverride??a)},e[2]=a,e[3]=o,e[4]=u):u=e[4];let f;e[5]!==n||e[6]!==d||e[7]!==s||e[8]!==u?(f={parts:n,partKey:Mc,schema:Ec,defaultValues:d,isStreaming:s,hasAnswer:Pc,onSubmit:u},e[5]=n,e[6]=d,e[7]=s,e[8]=u,e[9]=f):f=e[9];const l=_o(f);let V;e[10]!==n||e[11]!==l?(V=I=>{l.form.reset(Object.fromEntries(n.map(D=>[D.approvalId,{approved:!0,levelOverride:I}]))),l.submitOrAdvance()},e[10]=n,e[11]=l,e[12]=V):V=e[12];const m=V,v=l.currentPart;let p;e[13]!==l?(p=I=>{I.preventDefault(),l.submit()},e[13]=l,e[14]=p):p=e[14];let h;e[15]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Fn,{size:14}),e[15]=h):h=e[15];const y=`${n.length} approvals pending`,x=v?.friendlyName??"";let w;e[16]!==m?(w=r.jsx(To,{onYolo:m}),e[16]=m,e[17]=w):w=e[17];let S;e[18]!==n.length||e[19]!==l.currentIndex||e[20]!==l.goNext||e[21]!==l.goPrev||e[22]!==w?(S=r.jsx(Do,{currentIndex:l.currentIndex,total:n.length,onPrev:l.goPrev,onNext:l.goNext,extraLeft:w}),e[18]=n.length,e[19]=l.currentIndex,e[20]=l.goNext,e[21]=l.goPrev,e[22]=w,e[23]=S):S=e[23];let N;e[24]!==v||e[25]!==l.form.control||e[26]!==l.submitOrAdvance?(N=v?r.jsx(Lc,{approvalId:v.approvalId,control:l.form.control,onChange:l.submitOrAdvance}):null,e[24]=v,e[25]=l.form.control,e[26]=l.submitOrAdvance,e[27]=N):N=e[27];let C;e[28]!==v?(C=v?r.jsx(Po,{input:v.input}):null,e[28]=v,e[29]=C):C=e[29];let b;e[30]!==S||e[31]!==N||e[32]!==C||e[33]!==y||e[34]!==x?(b=r.jsx(dt,{icon:h,label:y,title:x,defaultExpanded:!0,footerLeft:S,footerRight:N,children:C}),e[30]=S,e[31]=N,e[32]=C,e[33]=y,e[34]=x,e[35]=b):b=e[35];let A;e[36]!==b||e[37]!==p?(A=r.jsx("form",{onSubmit:p,children:b}),e[36]=b,e[37]=p,e[38]=A):A=e[38];let j;return e[39]!==l.form||e[40]!==A?(j=r.jsx(Xt,{...l.form,children:A}),e[39]=l.form,e[40]=A,e[41]=j):j=e[41],j}function Pc(t){return typeof t?.approved=="boolean"}function Mc(t){return t.approvalId}function Oc(t){return[t.approvalId,{approved:void 0}]}function Lc(t){const e=z.c(6),{approvalId:n,control:s,onChange:o}=t,i=`${n}.approved`;let a;e[0]!==o?(a=d=>{const{field:u}=d,f=u.value===!0,l=u.value===!1;return r.jsxs(r.Fragment,{children:[r.jsx(ie,{type:"button",variant:l?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{u.onChange(!1),o()},"aria-pressed":l,children:"Deny"}),r.jsx(ie,{type:"button",variant:f?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{u.onChange(!0),o()},"aria-pressed":f,children:"Accept"})]})},e[0]=o,e[1]=a):a=e[1];let c;return e[2]!==s||e[3]!==i||e[4]!==a?(c=r.jsx(Bi,{control:s,name:i,render:a}),e[2]=s,e[3]=i,e[4]=a,e[5]=c):c=e[5],c}function Fc(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[r.jsx(Fn,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function $c(t){const e=z.c(8),{approvals:n,isStreaming:s,onRespond:o}=t;if(s&&n.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Fc,{}),e[0]=a):a=e[0],a}if(n.length===0)return null;if(n.length===1){const a=n[0];if(!a)return null;let c;return e[1]!==o||e[2]!==a?(c=r.jsx(_c,{approval:a,onRespond:o}),e[1]=o,e[2]=a,e[3]=c):c=e[3],c}let i;return e[4]!==n||e[5]!==s||e[6]!==o?(i=r.jsx(Tc,{approvals:n,isStreaming:s,onRespond:o}),e[4]=n,e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function zc(t){const e=z.c(16),{plan:n,onApprove:s,onDismiss:o}=t;let i;e[0]!==s||e[1]!==n.plan?(i=()=>{s(n.plan)},e[0]=s,e[1]=n.plan,e[2]=i):i=e[2];const a=i;let c;e[3]!==o?(c=r.jsx(ie,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:o,children:"Keep iterating"}),e[3]=o,e[4]=c):c=e[4];let d;e[5]!==a?(d=r.jsx(ie,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=d):d=e[6];let u;e[7]!==c||e[8]!==d?(u=r.jsxs(r.Fragment,{children:[c,d]}),e[7]=c,e[8]=d,e[9]=u):u=e[9];const f=u;let l;e[10]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ga,{size:14}),e[10]=l):l=e[10];let V;e[11]!==n.plan?(V=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(xa,{id:"plan-preview",part:{type:"text",text:n.plan}})})}),e[11]=n.plan,e[12]=V):V=e[12];let m;return e[13]!==f||e[14]!==V?(m=r.jsx(dt,{icon:l,label:"Plan ready",title:"Implementation Plan",defaultExpanded:!0,footerRight:f,children:V}),e[13]=f,e[14]=V,e[15]=m):m=e[15],m}function Bc(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[r.jsx(Vt,{className:"size-5 text-purple-500 shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function Uc(t){const e=z.c(7),{plans:n,isStreaming:s,onApprove:o,onDismiss:i}=t;if(s&&n.length===0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Bc,{}),e[0]=u):u=e[0],u}let a;e[1]!==n?(a=n.at(-1),e[1]=n,e[2]=a):a=e[2];const c=a;if(!c)return null;let d;return e[3]!==c||e[4]!==o||e[5]!==i?(d=r.jsx(zc,{plan:c,onApprove:o,onDismiss:i}),e[3]=c,e[4]=o,e[5]=i,e[6]=d):d=e[6],d}function Mo(t){return t?"response"in t?t.response:t.option??t.draft:""}const Zs=pt({response:St().min(1,"Response is required")}),Kc=pt({option:St().nullable(),draft:St()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),qc=pt({response:ys(["yes","no"])});function Yc(t){switch(t.type){case"text":return Zs;case"choice":return Kc;case"confirm":return qc;default:return Zs}}function Hc(t){const e={};for(const n of t)e[n.toolCallId]=Yc(n.input);return pt(e)}function Qc(t){const e=z.c(6),{control:n,name:s,placeholder:o}=t;let i;e[0]!==o?(i=c=>{const{field:d}=c,u=d.value??"";return r.jsxs(Ee,{children:[r.jsx(Te,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(eo,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...d,value:u,type:"text",placeholder:o||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),r.jsx(Pe,{})]})},e[0]=o,e[1]=i):i=e[1];let a;return e[2]!==n||e[3]!==s||e[4]!==i?(a=r.jsx($e,{control:n,name:s,render:i}),e[2]=n,e[3]=s,e[4]=i,e[5]=a):a=e[5],a}function Oo(t,e){const n=z.c(4);let s,o;n[0]!==t||n[1]!==e?(s=()=>{const i=a=>{const c=a.target.tagName;if(c==="INPUT"||c==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const d=Number.parseInt(a.key,10);d>=1&&d<=t&&(a.preventDefault(),e(d-1))};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},o=[t,e],n[0]=t,n[1]=e,n[2]=s,n[3]=o):(s=n[2],o=n[3]),g.useEffect(s,o)}function Wc(t){const e=z.c(40),{control:n,name:s,options:o}=t,i=`${s}.option`;let a;e[0]!==n||e[1]!==i?(a={control:n,name:i,defaultValue:null},e[0]=n,e[1]=i,e[2]=a):a=e[2];const{field:c}=Ls(a),d=`${s}.draft`;let u;e[3]!==n||e[4]!==d?(u={control:n,name:d,defaultValue:""},e[3]=n,e[4]=d,e[5]=u):u=e[5];const{field:f}=Ls(u),l=c.value,V=f.value??"";let m;if(e[6]!==c||e[7]!==o?(m=_=>{const R=o[_];R!=null&&c.onChange(R)},e[6]=c,e[7]=o,e[8]=m):m=e[8],Oo(o.length,m),o.length===0)return null;const v=l===null;let p;if(e[9]!==c||e[10]!==l||e[11]!==o){let _;e[13]!==c||e[14]!==l?(_=(R,k)=>{const M=l===R;return r.jsxs("button",{type:"button",onClick:()=>c.onChange(R),className:Y("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",M&&"bg-accent/50",!M&&"hover:bg-accent/30"),"aria-label":`Select ${R}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",M?"bg-chart-1 text-white":"bg-muted text-foreground"),children:k+1}),r.jsx("span",{className:"text-sm text-foreground truncate",children:R})]},`${k}-${R}`)},e[13]=c,e[14]=l,e[15]=_):_=e[15],p=o.map(_),e[9]=c,e[10]=l,e[11]=o,e[12]=p}else p=e[12];const h=v&&"bg-accent/50",y=!v&&"hover:bg-accent/30";let x;e[16]!==h||e[17]!==y?(x=Y("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",h,y),e[16]=h,e[17]=y,e[18]=x):x=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx(eo,{size:16,className:"text-muted-foreground"})}),e[19]=w):w=e[19];const S=v?V:"";let N;e[20]!==f||e[21]!==c||e[22]!==l?(N=_=>{f.onChange(_.target.value),l!==null&&c.onChange(null)},e[20]=f,e[21]=c,e[22]=l,e[23]=N):N=e[23];let C;e[24]!==c||e[25]!==l?(C=()=>{l!==null&&c.onChange(null)},e[24]=c,e[25]=l,e[26]=C):C=e[26];let b;e[27]!==S||e[28]!==N||e[29]!==C?(b=r.jsx("input",{type:"text",value:S,onChange:N,onFocus:C,placeholder:"Something else...","aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[27]=S,e[28]=N,e[29]=C,e[30]=b):b=e[30];let A;e[31]!==b||e[32]!==x?(A=r.jsxs("label",{className:x,children:[w,b]}),e[31]=b,e[32]=x,e[33]=A):A=e[33];let j;e[34]!==A||e[35]!==p?(j=r.jsx(Te,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[p,A]})}),e[34]=A,e[35]=p,e[36]=j):j=e[36];let I;e[37]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(Pe,{}),e[37]=I):I=e[37];let D;return e[38]!==j?(D=r.jsxs(Ee,{children:[j,I]}),e[38]=j,e[39]=D):D=e[39],D}function Gc(t){const e=z.c(6),{control:n,name:s}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["yes","no"],e[0]=o):o=e[0];const i=o,a=g.useRef(null);let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=f=>{a.current?.onChange(i[f]??"")},e[1]=c):c=e[1],Oo(i.length,c);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=f=>{const{field:l}=f;return a.current=l,r.jsxs(Ee,{children:[r.jsx(Te,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:i.map(V=>{const m=l.value===V;return r.jsxs("button",{type:"button",onClick:()=>l.onChange(V),className:Y("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${V}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:V==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:V})]},V)})})}),r.jsx(Pe,{})]})},e[2]=d):d=e[2];let u;return e[3]!==n||e[4]!==s?(u=r.jsx($e,{control:n,name:s,render:d}),e[3]=n,e[4]=s,e[5]=u):u=e[5],u}function er(t){const e=z.c(13),{input:n,control:s,toolCallId:o}=t;switch(n.type){case"text":{const i=`${o}.response`;let a;return e[0]!==s||e[1]!==n.default||e[2]!==i?(a=r.jsx(Qc,{control:s,name:i,placeholder:n.default}),e[0]=s,e[1]=n.default,e[2]=i,e[3]=a):a=e[3],a}case"choice":{let i;e[4]!==n.options?(i=n.options?.filter(Boolean)??[],e[4]=n.options,e[5]=i):i=e[5];const a=i;let c;return e[6]!==s||e[7]!==a||e[8]!==o?(c=r.jsx(Wc,{control:s,name:o,options:a}),e[6]=s,e[7]=a,e[8]=o,e[9]=c):c=e[9],c}case"confirm":{const i=`${o}.response`;let a;return e[10]!==s||e[11]!==i?(a=r.jsx(Gc,{control:s,name:i}),e[10]=s,e[11]=i,e[12]=a):a=e[12],a}default:return null}}function Xc(t){const e=z.c(71),{parts:n,isStreaming:s,onSubmit:o}=t;let i;e[0]!==n?(i=Hc(n.map(td)),e[0]=n,e[1]=i):i=e[1];const a=i;let c;e[2]!==n?(c=Object.fromEntries(n.map(ed)),e[2]=n,e[3]=c):c=e[3];const d=c;let u;e[4]!==o?(u=(P,T)=>{const L=Mo(T);L&&o(P,L)},e[4]=o,e[5]=u):u=e[5];let f;e[6]!==d||e[7]!==s||e[8]!==n||e[9]!==a||e[10]!==u?(f={parts:n,partKey:Zc,schema:a,defaultValues:d,isStreaming:s,hasAnswer:Jc,onSubmit:u},e[6]=d,e[7]=s,e[8]=n,e[9]=a,e[10]=u,e[11]=f):f=e[11];const l=_o(f),V=l.currentPart;let m;e[12]!==V||e[13]!==l?(m=()=>{const P=V;if(!P)return;const T=P.toolCallId;P.input?.type==="choice"?(l.form.setValue(`${T}.option`,null),l.form.setValue(`${T}.draft`,"user has skip this question")):l.form.setValue(`${T}.response`,"user has skip this question"),l.advanceToNextUnanswered()},e[12]=V,e[13]=l,e[14]=m):m=e[14];const v=m;let p;e[15]!==l.currentIndex||e[16]!==l.goNext||e[17]!==l.goPrev||e[18]!==n.length?(p=r.jsx(Do,{currentIndex:l.currentIndex,total:n.length,onPrev:l.goPrev,onNext:l.goNext}),e[15]=l.currentIndex,e[16]=l.goNext,e[17]=l.goPrev,e[18]=n.length,e[19]=p):p=e[19];const h=p;let y;e[20]!==v?(y=r.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:v,className:"h-7",children:"Skip"}),e[20]=v,e[21]=y):y=e[21];let x;e[22]!==l.isAllAnswered||e[23]!==l.isCurrentAnswered||e[24]!==l.submitOrAdvance||e[25]!==s?(x=r.jsx(kc,{isStreaming:s,isAllAnswered:l.isAllAnswered,isCurrentAnswered:l.isCurrentAnswered,onAdvanceOrSubmit:l.submitOrAdvance}),e[22]=l.isAllAnswered,e[23]=l.isCurrentAnswered,e[24]=l.submitOrAdvance,e[25]=s,e[26]=x):x=e[26];let w;e[27]!==y||e[28]!==x?(w=r.jsxs(r.Fragment,{children:[y,x]}),e[27]=y,e[28]=x,e[29]=w):w=e[29];const S=w;if(n.length===1){const P=n[0];if(!P?.input)return null;let T;e[30]!==l?(T=F=>{F.preventDefault(),l.submit()},e[30]=l,e[31]=T):T=e[31];let L;e[32]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Vs,{size:14}),e[32]=L):L=e[32];const U=P.input?.prompt??"Question",$=P.input;let B;e[33]!==l.form.control||e[34]!==P.toolCallId||e[35]!==$?(B=r.jsx(er,{input:$,control:l.form.control,toolCallId:P.toolCallId}),e[33]=l.form.control,e[34]=P.toolCallId,e[35]=$,e[36]=B):B=e[36];let K;e[37]!==S||e[38]!==U||e[39]!==B?(K=r.jsx(dt,{icon:L,label:"Question pending",title:U,defaultExpanded:!0,footerRight:S,children:B}),e[37]=S,e[38]=U,e[39]=B,e[40]=K):K=e[40];let H;e[41]!==T||e[42]!==K?(H=r.jsx("form",{onSubmit:T,autoComplete:"off",children:K}),e[41]=T,e[42]=K,e[43]=H):H=e[43];let O;return e[44]!==l.form||e[45]!==H?(O=r.jsx(Xt,{...l.form,children:H}),e[44]=l.form,e[45]=H,e[46]=O):O=e[46],O}const N=l.form;let C;e[47]!==l?(C=P=>{P.preventDefault(),l.submit()},e[47]=l,e[48]=C):C=e[48];let b;e[49]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Vs,{size:14}),e[49]=b):b=e[49];const A=`${l.currentIndex+1} of ${n.length}`,j=V?.input?.prompt??"Question",I=l.activeKey,D=l.setActiveKey;let _;if(e[50]!==l.form||e[51]!==n){let P;e[53]!==l.form?(P=T=>r.jsx(cl,{value:T.toolCallId,className:"mt-0",children:r.jsx(er,{input:T.input,control:l.form.control,toolCallId:T.toolCallId})},T.toolCallId),e[53]=l.form,e[54]=P):P=e[54],_=n.map(P),e[50]=l.form,e[51]=n,e[52]=_}else _=e[52];let R;e[55]!==l.activeKey||e[56]!==l.setActiveKey||e[57]!==_?(R=r.jsx(dl,{value:I,onValueChange:D,children:_}),e[55]=l.activeKey,e[56]=l.setActiveKey,e[57]=_,e[58]=R):R=e[58];let k;e[59]!==h||e[60]!==S||e[61]!==A||e[62]!==j||e[63]!==R?(k=r.jsx(dt,{icon:b,label:"Question pending",count:A,title:j,defaultExpanded:!0,footerLeft:h,footerRight:S,children:R}),e[59]=h,e[60]=S,e[61]=A,e[62]=j,e[63]=R,e[64]=k):k=e[64];let M;e[65]!==C||e[66]!==k?(M=r.jsx("form",{onSubmit:C,autoComplete:"off",children:k}),e[65]=C,e[66]=k,e[67]=M):M=e[67];let E;return e[68]!==l.form||e[69]!==M?(E=r.jsx(Xt,{...N,children:M}),e[68]=l.form,e[69]=M,e[70]=E):E=e[70],E}function Jc(t){return!!Mo(t)}function Zc(t){return t.toolCallId}function ed(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function td(t){return{toolCallId:t.toolCallId,input:t.input}}function nd(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[r.jsx(Vs,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Lo(t){const e=z.c(7),{userAskParts:n,isStreaming:s,onSubmit:o}=t;let i;e[0]!==n?(i=n.filter(sd),e[0]=n,e[1]=i):i=e[1];const a=i;if(a.length===0){if(s){let d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(nd,{}),e[2]=d):d=e[2],d}return null}let c;return e[3]!==s||e[4]!==o||e[5]!==a?(c=r.jsx(Xc,{parts:a,isStreaming:s,onSubmit:o}),e[3]=s,e[4]=o,e[5]=a,e[6]=c):c=e[6],c}function sd(t){return t.state==="input-available"}function rd(t){const e=t.filter(i=>i.status==="in_progress"),n=t.filter(i=>i.status==="completed").length,s=t.length;if(s>0&&n===s)return{icon:"completed",activity:"All done",progress:`${s}/${s}`};const[o]=e;return o&&e.length===1?{icon:"in_progress",activity:o.activeForm,progress:`${n}/${s} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${n}/${s} done`}:n>0?{icon:"pending",activity:`${s-n} pending`,progress:`${n}/${s} done`}:{icon:"pending",activity:`${s} todos`,progress:"not started"}}function od(){const t=z.c(21),{messages:e}=Dt();let n,s,o,i,a,c,d,u,f;if(t[0]!==e){f=Symbol.for("react.early_return_sentinel");e:{const m=Co(e);if(m.length===0){f=null;break e}const v=rd(m);n=dt,a=r.jsx(cd,{status:v.icon}),c=v.activity,d=v.progress,u=!1,s="todos-list",o="flex flex-col px-2 max-h-[40vh] overflow-y-auto",i=m.map(id)}t[0]=e,t[1]=n,t[2]=s,t[3]=o,t[4]=i,t[5]=a,t[6]=c,t[7]=d,t[8]=u,t[9]=f}else n=t[1],s=t[2],o=t[3],i=t[4],a=t[5],c=t[6],d=t[7],u=t[8],f=t[9];if(f!==Symbol.for("react.early_return_sentinel"))return f;let l;t[10]!==s||t[11]!==o||t[12]!==i?(l=r.jsx("ul",{"data-testid":s,className:o,children:i}),t[10]=s,t[11]=o,t[12]=i,t[13]=l):l=t[13];let V;return t[14]!==n||t[15]!==a||t[16]!==c||t[17]!==d||t[18]!==u||t[19]!==l?(V=r.jsx(n,{icon:a,label:c,count:d,defaultExpanded:u,children:l}),t[14]=n,t[15]=a,t[16]=c,t[17]=d,t[18]=u,t[19]=l,t[20]=V):V=t[20],V}function id(t,e){return r.jsx(ad,{todo:t},e)}function ad(t){const e=z.c(14),{todo:n}=t,s=n.status==="completed",i=n.status==="in_progress"?n.activeForm:n.content;let a;e[0]!==n.status?(a=r.jsx(ld,{status:n.status}),e[0]=n.status,e[1]=a):a=e[1];const c=s&&"text-muted-foreground";let d;e[2]!==c?(d=Y("relative text-sm leading-snug pt-px select-none",c),e[2]=c,e[3]=d):d=e[3];const u=s?"100%":"0%",f=s?"width 300ms ease 200ms":"width 150ms ease";let l;e[4]!==u||e[5]!==f?(l=r.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:u,transition:f}}),e[4]=u,e[5]=f,e[6]=l):l=e[6];let V;e[7]!==i||e[8]!==d||e[9]!==l?(V=r.jsxs("span",{className:d,children:[i,l]}),e[7]=i,e[8]=d,e[9]=l,e[10]=V):V=e[10];let m;return e[11]!==a||e[12]!==V?(m=r.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,V]}),e[11]=a,e[12]=V,e[13]=m):m=e[13],m}function ld(t){const e=z.c(4),{status:n}=t,s=n==="completed"?"true":void 0,o=n==="in_progress"?"true":void 0;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("svg",{viewBox:"0 0 21 21",children:r.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=i):i=e[0];let a;return e[1]!==s||e[2]!==o?(a=r.jsx("div",{className:"todo-cb mt-0.5","data-checked":s,"data-progress":o,"aria-hidden":"true",children:i}),e[1]=s,e[2]=o,e[3]=a):a=e[3],a}function cd(t){const e=z.c(3),{status:n}=t;if(n==="completed"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:r.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:r.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=o):o=e[0],o}if(n==="in_progress"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=o):o=e[1],o}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=s):s=e[2],s}const dd={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},ud=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Fo(t){const e=z.c(41),{onDismiss:n}=t,{org:s}=Ce(),o=ht(),{decoKeyId:i}=fo(),a=Vo(),[c,d]=g.useState(""),[u,f]=g.useState(!1),[l,V]=g.useState("usd"),m=l==="brl"?"R$":"$";let v,p;e[0]!==s.id?(v=()=>{X("credits_exhausted_shown",{organization_id:s.id})},p=[s.id],e[0]=s.id,e[1]=v,e[2]=p):(v=e[1],p=e[2]),g.useEffect(v,p);let h;e[3]!==l||e[4]!==a?(h=async P=>{const{url:T}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:P,currency:l});return T},e[3]=l,e[4]=a,e[5]=h):h=e[5];let y;e[6]!==n?(y=P=>{P&&window.open(P,"_blank","noopener,noreferrer"),n?.()},e[6]=n,e[7]=y):y=e[7];let x;e[8]!==h||e[9]!==y?(x={mutationFn:h,onSuccess:y,onError:md},e[8]=h,e[9]=y,e[10]=x):x=e[10];const{mutate:w,isPending:S}=ws(x),N=parseFloat(c),C=!isNaN(N)&&N>=1;let b;e[11]!==n?(b=P=>!P&&n?.(),e[11]=n,e[12]=b):b=e[12];let A;e[13]===Symbol.for("react.memo_cache_sentinel")?(A=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[13]=A):A=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:A.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[14]=j):j=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[j,r.jsxs(Rt,{className:"relative gap-4",children:[r.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),r.jsxs("div",{children:[r.jsx(_t,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),r.jsx(Pn,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[15]=I):I=e[15];let D;e[16]!==l||e[17]!==m||e[18]!==c||e[19]!==N||e[20]!==i||e[21]!==C||e[22]!==S||e[23]!==u||e[24]!==w?(D=i&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(uo,{type:"single",variant:"outline",size:"sm",value:l,onValueChange:P=>{P&&V(P)},children:[r.jsx(yn,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(yn,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:dd[l].map(P=>{const{dollars:T,label:L}=P;return r.jsxs("button",{type:"button",disabled:S,onClick:()=>{X("credits_topup_clicked",{amount_cents:T*100,currency:l,tier_label:L,source:"exhausted_banner"}),w(T*100)},className:Y("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,T]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:L})]},T)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),r.jsx(tt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:P=>d(P.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(ie,{className:"h-10",disabled:!C||S,onClick:()=>{X("credits_topup_clicked",{amount_cents:Math.round(N*100),currency:l,tier_label:"custom",source:"exhausted_banner"}),w(Math.round(N*100))},children:S?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>f(!0),children:"Enter custom amount"})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:ud.map(fd)})]}),e[16]=l,e[17]=m,e[18]=c,e[19]=N,e[20]=i,e[21]=C,e[22]=S,e[23]=u,e[24]=w,e[25]=D):D=e[25];let _;e[26]!==n?(_=r.jsx(ie,{variant:"ghost",size:"sm",onClick:n,children:"Dismiss"}),e[26]=n,e[27]=_):_=e[27];let R;e[28]!==o||e[29]!==n||e[30]!==s.slug?(R=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{o({to:"/$org/settings/ai-providers",params:{org:s.slug}}),n?.()},children:"Manage providers"}),e[28]=o,e[29]=n,e[30]=s.slug,e[31]=R):R=e[31];let k;e[32]!==_||e[33]!==R?(k=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[_,R]}),e[32]=_,e[33]=R,e[34]=k):k=e[34];let M;e[35]!==D||e[36]!==k?(M=r.jsxs(Et,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Vd,children:[I,D,k]}),e[35]=D,e[36]=k,e[37]=M):M=e[37];let E;return e[38]!==M||e[39]!==b?(E=r.jsx(Tt,{open:!0,onOpenChange:b,children:M}),e[38]=M,e[39]=b,e[40]=E):E=e[40],E}function fd(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(Vt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Vd(t){return t.preventDefault()}function md(t){ue.error(`Top-up failed: ${t.message}`)}function pd(){const t=z.c(5),e=En(),n=mo(),[s,o]=g.useState(!1);if(!(e?.lockedSandbox==="user-desktop")||!n.ready||n.online)return null;let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(Cs,{size:14}),t[0]=a):a=t[0];let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(ie,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>o(!0),children:"Reconnect desktop"}),t[1]=c):c=t[1];let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(dt,{icon:a,label:"Your desktop is offline",title:"This chat runs on your desktop, which isn't connected right now.",defaultExpanded:!0,variant:"warning",footerRight:c,children:r.jsxs("p",{className:"mx-4 text-xs text-muted-foreground",children:["Run ",r.jsx("code",{className:"font-mono",children:"bunx decocms@latest link"})," in a terminal on that machine to bring it back. Messages you send while it's offline will fail."]})}),t[2]=d):d=t[2];let u;return t[3]!==s?(u=r.jsxs(r.Fragment,{children:[d,r.jsx(Vl,{open:s,onOpenChange:o})]}),t[3]=s,t[4]=u):u=t[4],u}function hd(t){const e=t.trim(),n=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),s=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),o=/failed to fetch|networkerror|load failed|offline/i.test(e),i=/timeout|timed out|aborted|deadline/i.test(e),a=e.length>240,c=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(c){const d=c[1]?.trim().replace(/\.$/,"");return{summary:d?`Your sandbox didn't finish starting up (${d}). Try again.`:"Your sandbox didn't finish starting up. Try again.",rawDetails:t}}return/link_unavailable|user_desktop_link_/i.test(e)?/user_desktop_link_capability_missing/i.test(e)?{summary:"Your desktop is connected, but the CLI this chat uses wasn't detected there. Install it and sign in on your desktop, then try again.",rawDetails:t}:{summary:"Your desktop is offline. Run `bunx decocms@latest link` in a terminal on it, then try again.",rawDetails:t}:s||n&&a?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:o?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:i?{summary:"That took longer than expected. Try again.",rawDetails:t}:n||a?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const gd={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function wn(t){const e=z.c(19),{variant:n,onDismiss:s}=t,o=n==="error",i=o?"Error occurred":"Response incomplete",a=o?ro:Pr,c=o?t.error.message:gd[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`;let d;e[0]!==o||e[1]!==c?(d=o?hd(c):{summary:c,rawDetails:null},e[0]=o,e[1]=c,e[2]=d):d=e[2];const{summary:u,rawDetails:f}=d;let l;e[3]!==a?(l=r.jsx(a,{size:14}),e[3]=a,e[4]=l):l=e[4];let V;e[5]!==o||e[6]!==t.onContinue||e[7]!==t.onFixInChat?(V=o?r.jsx(ie,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}):r.jsx(ie,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"}),e[5]=o,e[6]=t.onContinue,e[7]=t.onFixInChat,e[8]=V):V=e[8];let m;e[9]!==f?(m=f?r.jsxs("details",{className:"group mx-4",children:[r.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[r.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m4.5 3 3 3-3 3"})}),r.jsx("span",{className:"group-open:hidden",children:"Show technical details"}),r.jsx("span",{className:"hidden group-open:inline",children:"Hide technical details"})]}),r.jsxs("div",{className:"relative mt-2",children:[r.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(f).then(vd).catch(xd)},"aria-label":"Copy error details",title:"Copy",className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:r.jsx(il,{className:"size-3.5"})}),r.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:f})]})]}):null,e[9]=f,e[10]=m):m=e[10];let v;return e[11]!==i||e[12]!==s||e[13]!==u||e[14]!==l||e[15]!==V||e[16]!==m||e[17]!==n?(v=r.jsx(dt,{icon:l,label:i,title:u,defaultExpanded:!0,variant:n,onClose:s,footerRight:V,children:m}),e[11]=i,e[12]=s,e[13]=u,e[14]=l,e[15]=V,e[16]=m,e[17]=n,e[18]=v):v=e[18],v}function xd(){return ue.error("Could not copy")}function vd(){return ue.success("Copied to clipboard")}function zn(){const t=z.c(62),{error:e,clearError:n,finishReason:s,clearFinishReason:o,messages:i,isStreaming:a,submit:c,sendMessage:d}=Dt(),[u,f]=It(),{virtualMcpId:l,createTaskWithMessage:V}=$r(),{chatMode:m,simpleModeTier:v}=ut();let p;t[0]!==m||t[1]!==v||t[2]!==l?(p=G=>({tier:v,mode:m,toolApprovalLevel:G,agent:l?{id:l}:void 0}),t[0]=m,t[1]=v,t[2]=l,t[3]=p):p=t[3];const h=p;let y;t[4]!==u.toolApprovalLevel?(y=u.toolApprovalLevel??Ui(),t[4]=u.toolApprovalLevel,t[5]=y):y=t[5];const x=y,w=i.at(-1),S=w?.role==="assistant"?w.parts:[],N=S.filter(jd),C=No(S),b=So(S);let A;t[6]!==e||t[7]!==d?(A=()=>{if(e){const le={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};d(le)}},t[6]=e,t[7]=d,t[8]=A):A=t[8];const j=A;let I;t[9]!==d?(I=()=>{d({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[9]=d,t[10]=I):I=t[10];const D=I;let _;t[11]!==h||t[12]!==x||t[13]!==c?(_=(G,le)=>{c({kind:"toolOutput",toolCallId:G.toolCallId,output:{response:le}},h(x))},t[11]=h,t[12]=x,t[13]=c,t[14]=_):_=t[14];const R=_;let k;t[15]!==V||t[16]!==u||t[17]!==f||t[18]!==l?(k=G=>{f({...u,toolApprovalLevel:"auto"}),V({virtualMcpId:l,message:{parts:[{type:"text",text:`Implement this plan:
|
|
2
2
|
|
|
3
3
|
${G}`}]}})},t[15]=V,t[16]=u,t[17]=f,t[18]=l,t[19]=k):k=t[19];const M=k,E=wd;let P;t[20]!==h||t[21]!==c?(P=(G,le,ne,me)=>{c({kind:"approval",approvalId:G,approved:le,...ne?{reason:ne}:{}},h(me))},t[20]=h,t[21]=c,t[22]=P):P=t[22];const T=P,L=ko();if(L.isCreditExhausted){let G;return t[23]!==n?(G=r.jsx(Fo,{onDismiss:n}),t[23]=n,t[24]=G):G=t[24],G}const{showError:U,showWarning:$,hasApprovals:B}=L,K=N.map(yd).join("|"),H=C[0]?.toolCallId??"",O=b.map(bd).join("|");let F,J;t[25]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsx(od,{}),J=r.jsx(pd,{}),t[25]=F,t[26]=J):(F=t[25],J=t[26]);let Q;t[27]!==n||t[28]!==e||t[29]!==j||t[30]!==U?(Q=U&&r.jsx(wn,{variant:"error",error:e,onDismiss:n,onFixInChat:j}),t[27]=n,t[28]=e,t[29]=j,t[30]=U,t[31]=Q):Q=t[31];let Z;t[32]!==o||t[33]!==s||t[34]!==D||t[35]!==$?(Z=$&&r.jsx(wn,{variant:"warning",finishReason:s,onDismiss:o,onContinue:D}),t[32]=o,t[33]=s,t[34]=D,t[35]=$,t[36]=Z):Z=t[36];let q;t[37]!==O||t[38]!==T||t[39]!==B||t[40]!==a||t[41]!==b?(q=B&&r.jsx($c,{approvals:b,isStreaming:a,onRespond:T},O),t[37]=O,t[38]=T,t[39]=B,t[40]=a,t[41]=b,t[42]=q):q=t[42];let se;t[43]!==L.hasPlans||t[44]!==M||t[45]!==E||t[46]!==a||t[47]!==C||t[48]!==H?(se=L.hasPlans&&r.jsx(Uc,{plans:C,isStreaming:a,onApprove:M,onDismiss:E},H),t[43]=L.hasPlans,t[44]=M,t[45]=E,t[46]=a,t[47]=C,t[48]=H,t[49]=se):se=t[49];let ee;t[50]!==L.isWaitingForUserInput||t[51]!==R||t[52]!==a||t[53]!==K||t[54]!==N?(ee=L.isWaitingForUserInput&&r.jsx(Lo,{userAskParts:N,isStreaming:a,onSubmit:R},K),t[50]=L.isWaitingForUserInput,t[51]=R,t[52]=a,t[53]=K,t[54]=N,t[55]=ee):ee=t[55];let te;return t[56]!==Z||t[57]!==q||t[58]!==se||t[59]!==ee||t[60]!==Q?(te=r.jsxs("div",{className:"absolute bottom-full left-0 right-0",children:[F,J,Q,Z,q,se,ee]}),t[56]=Z,t[57]=q,t[58]=se,t[59]=ee,t[60]=Q,t[61]=te):te=t[61],te}function bd(t){return t.approvalId}function yd(t){return t.toolCallId}function wd(){document.querySelector("[data-chat-input]")?.focus()}function jd(t){return t.type==="tool-user_ask"}zn.Error=function(e){return r.jsx(wn,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};zn.Warning=function(e){return r.jsx(wn,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};zn.UserAskQuestion=Lo;function Ad(t){const e=z.c(12),{taskId:n}=t,s=zr(n),o=ca(s),i=da(),{stop:a,removeLocalMessage:c}=Dt();if(o.length===0)return null;let d;e[0]!==a?(d=()=>{a()},e[0]=a,e[1]=d):d=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Fr,{size:14}),e[2]=u):u=e[2];let f;e[3]!==d?(f=r.jsx(Ue,{asChild:!0,children:r.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,children:u})}),e[3]=d,e[4]=f):f=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Ke,{side:"top",children:r.jsx("p",{className:"text-xs",children:"Send now"})}),e[5]=l):l=e[5];let V;e[6]!==f?(V=r.jsxs(qe,{delayDuration:400,children:[f,l]}),e[6]=f,e[7]=V):V=e[7];let m;return e[8]!==i||e[9]!==c||e[10]!==n?(m=(v,p)=>r.jsxs("div",{className:"group/queuerow flex items-center gap-2 px-3 py-1.5",children:[r.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground dark:bg-background",children:p+1}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:v.text}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/queuerow:opacity-100",children:r.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",title:"Remove from queue",onClick:()=>{i.cancel(n,v.messageId).then(h=>{h&&(ua(n,v.messageId),c(v.messageId))})},children:r.jsx(go,{className:"size-3.5"})})})]},v.messageId),e[8]=i,e[9]=c,e[10]=n,e[11]=m):m=e[11],r.jsxs("div",{className:"mb-1 overflow-hidden rounded-2xl border border-border bg-card dark:bg-muted",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border py-1.5 pr-2 pl-3 text-xs text-muted-foreground",children:[r.jsxs("span",{children:[o.length," queued message",o.length>1?"s":""]}),V]}),o.map(m)]})}async function Cd(t,e,n){const s=await t.callTool({name:e,arguments:n});if(s.isError){const o=s.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(o)}return s}const $o=["SANDBOX_START"],dn=new Map,Sd=t=>`${t.virtualMcpId}::${t.branch??""}`,ts=new Set,Nd={mark:(t,e)=>ts.add(`${t}::${e}`),clear:(t,e)=>ts.delete(`${t}::${e}`),isStopped:(t,e)=>ts.has(`${t}::${e}`)};function kd(t){const e=kt();return ws({mutationKey:$o,mutationFn:async n=>{n.branch&&Nd.clear(n.virtualMcpId,n.branch);const s=Sd(n),o=dn.get(s);if(o)return o;const i=(async()=>(await Cd(t,"SANDBOX_START",n)).structuredContent)();dn.set(s,i);try{return await i}finally{dn.get(s)===i&&dn.delete(s)}},onSuccess:()=>{Ki(e)}})}function Eh(t,e){const n=z.c(3);let s;return n[0]!==e||n[1]!==t?(s={mutationKey:$o,predicate:i=>{if(!t)return!1;const a=i.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},n[0]=e,n[1]=t,n[2]=s):s=n[2],Zl(s)>0}function Id(){const t=z.c(11),e=mo(),n=qi();let s;t[0]!==e.capabilities||t[1]!==e.online?(s=e.online&&e.capabilities.includes("claude-code"),t[0]=e.capabilities,t[1]=e.online,t[2]=s):s=t[2];let o;t[3]!==e.capabilities||t[4]!==e.online?(o=e.online&&e.capabilities.includes("codex"),t[3]=e.capabilities,t[4]=e.online,t[5]=o):o=t[5];let i;return t[6]!==e.online||t[7]!==n.runtime.agentSandbox||t[8]!==s||t[9]!==o?(i={agentSandbox:n.runtime.agentSandbox,userDesktop:e.online,claudeCode:s,codex:o},t[6]=e.online,t[7]=n.runtime.agentSandbox,t[8]=s,t[9]=o,t[10]=i):i=t[10],i}const Dd={fast:{modelId:"claude-code:haiku",label:"Haiku 4.5"},smart:{modelId:"claude-code:sonnet",label:"Sonnet 5"},thinking:{modelId:"claude-code:opus-1m",label:"Opus 4.8 1M"}},Rd={fast:{modelId:"codex:gpt-5.6-luna",label:"GPT-5.6 Luna"},smart:{modelId:"codex:gpt-5.6-terra",label:"GPT-5.6 Terra"},thinking:{modelId:"codex:gpt-5.6-sol",label:"GPT-5.6 Sol"}};function _d(t){return t==="claude-code"?Dd:t==="codex"?Rd:null}function tr(t,e){return _d(t)?.[e]??null}const Ed={"cloud-decopilot":"decopilot","local-decopilot":"decopilot-desktop","local-claude-code":"claude-code-desktop","local-codex":"codex-desktop"},Td={decopilot:"cloud-decopilot","decopilot-desktop":"local-decopilot","claude-code-desktop":"local-claude-code","codex-desktop":"local-codex"};function Pd(t){return Ed[t]}function zo(t){return t===null?"cloud-decopilot":Td[t]}function Bo(){const t=z.c(2),{pendingAgentOption:e}=ut();let n;return t[0]!==e?(n=zo(e),t[0]=e,t[1]=n):n=t[1],n}function Md(){const t=z.c(2),{setPendingAgentOption:e}=ut();let n;return t[0]!==e?(n=s=>e(Pd(s)),t[0]=e,t[1]=n):n=t[1],n}function Od(){return ut().simpleModeTier}function Ld(){return ut().setSimpleModeTier}const Fd={fast:"Quicker responses",smart:"Balanced quality",thinking:"Deeper reasoning"};function $d(t,e){return t==="local-claude-code"?tr("claude-code",e)?.label??null:t==="local-codex"?tr("codex",e)?.label??null:Fd[e]}const zd={decopilot:"Decopilot","claude-code":"Claude Code",codex:"Codex"},Bd=Mn("").icon;function jn(t){const e=z.c(4),{compact:n}=t,o=(n===void 0?!1:n)?"size-3.5 rounded-sm":"size-4 rounded-sm";let i;e[0]!==o?(i=Y(o),e[0]=o,e[1]=i):i=e[1];let a;return e[2]!==i?(a=r.jsx(to,{icon:Bd,name:"Decopilot",size:"2xs",className:i}),e[2]=i,e[3]=a):a=e[3],a}const Ud={mode:"cloud-decopilot",label:"Decopilot",description:"Runs in an agent sandbox",group:"cloud",icon:r.jsx(jn,{}),isAvailable:t=>t.agentSandbox},Kd={mode:"local-decopilot",label:"Decopilot",description:"Runs on your desktop",group:"local",icon:r.jsx(jn,{}),isAvailable:t=>t.userDesktop},qd={mode:"local-claude-code",label:"Claude Code",description:"Runs via Claude Code CLI",group:"local",icon:r.jsx(po,{size:16}),isAvailable:t=>t.userDesktop&&t.claudeCode},Yd={mode:"local-codex",label:"Codex",description:"Runs via Codex CLI",group:"local",icon:r.jsx(ho,{size:16}),isAvailable:t=>t.userDesktop&&t.codex},nr=[Ud,Kd,qd,Yd];function Hd(t,e){return t==="claude-code"?"local-claude-code":t==="codex"?"local-codex":e==="user-desktop"?"local-decopilot":"cloud-decopilot"}function Qd({selectedMode:t,lockedHarness:e,lockedSandbox:n,isThreadLocked:s}){if(s&&e!=null){const o=fa(e,n);return o?zo(o):Hd(e,n)}return t}function Uo(t){return t==="local-decopilot"?{icon:r.jsx(jn,{compact:!0}),text:"Decopilot"}:t==="local-claude-code"?{icon:r.jsx(po,{size:14}),text:"Claude Code"}:t==="local-codex"?{icon:r.jsx(ho,{size:14}),text:"Codex"}:{icon:r.jsx(jn,{compact:!0}),text:"Decopilot"}}function Wd(t){const{text:e}=Uo(t);return{icon:t==="cloud-decopilot"?r.jsx(Xa,{size:14}):r.jsx(Cs,{size:14}),text:e}}function ns(t){return t==="cloud-decopilot"?"cloud":"desktop"}const Gd="text-muted-foreground hover:text-foreground text-xs transition-[gap] duration-200",Xd="text-success hover:text-success";function Jd(t){const e=z.c(91),{mode:n,availability:s,locked:o,lockedHarness:i,onSelect:a}=t,[c,d]=g.useState(!1);let u;e[0]!==o||e[1]!==n?(u=o?Uo(n):Wd(n),e[0]=o,e[1]=n,e[2]=u):u=e[2];const{icon:f,text:l}=u;let V;e[3]!==n?(V=ns(n),e[3]=n,e[4]=V):V=e[4];const m=`${l} on ${V}`,v=n!=="cloud-decopilot",p=i!=null,h=i?zd[i]:null;let y,x,w,S,N,C,b,A,j,I,D,_,R;if(e[5]!==s||e[6]!==h||e[7]!==f||e[8]!==v||e[9]!==m||e[10]!==o||e[11]!==n||e[12]!==a||e[13]!==c||e[14]!==p||e[15]!==l){let P;e[29]!==s?(P=ne=>ne.group==="cloud"&&ne.isAvailable(s),e[29]=s,e[30]=P):P=e[30];const T=nr.filter(P),L=nr.filter(Zd);let U;e[31]!==a?(U=ne=>{a(ne),d(!1)},e[31]=a,e[32]=U):U=e[32];const $=U;x=Ss,S=c,N=o?void 0:d;let B;e[33]!==h||e[34]!==m||e[35]!==n||e[36]!==p?(B=p&&h?`This chat is using ${h} on ${ns(n)}. Start a new chat to use a different runtime.`:m,e[33]=h,e[34]=m,e[35]=n,e[36]=p,e[37]=B):B=e[37];const K=o?"mode-picker-locked":"mode-picker",H=v&&Xd,O=o?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5";let F;e[38]!==H||e[39]!==O?(F=Y(Gd,H,"shrink min-w-0",O),e[38]=H,e[39]=O,e[40]=F):F=e[40];const J=!o&&"@[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100";let Q;e[41]!==J?(Q=Y("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0",J),e[41]=J,e[42]=Q):Q=e[42];let Z;e[43]!==Q||e[44]!==l?(Z=r.jsx("span",{className:Q,children:l}),e[43]=Q,e[44]=l,e[45]=Z):Z=e[45];let q;e[46]!==o?(q=!o&&r.jsx(Ln,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[46]=o,e[47]=q):q=e[47];let se;e[48]!==f||e[49]!==o||e[50]!==B||e[51]!==K||e[52]!==F||e[53]!==Z||e[54]!==q?(se=r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"inline-flex min-w-0 shrink",children:r.jsx(Ns,{asChild:!0,children:r.jsxs(ie,{type:"button",variant:"ghost",size:"default","aria-label":B,disabled:o,"data-testid":K,className:F,children:[f,Z,q]})})})}),e[48]=f,e[49]=o,e[50]=B,e[51]=K,e[52]=F,e[53]=Z,e[54]=q,e[55]=se):se=e[55];let ee;e[56]!==h||e[57]!==m||e[58]!==n||e[59]!==p?(ee=p&&h?`This chat is using ${h} on ${ns(n)}. Start a new chat to use a different runtime.`:m,e[56]=h,e[57]=m,e[58]=n,e[59]=p,e[60]=ee):ee=e[60];let te;e[61]!==ee?(te=r.jsx(Ke,{children:ee}),e[61]=ee,e[62]=te):te=e[62],e[63]!==se||e[64]!==te?(C=r.jsxs(qe,{children:[se,te]}),e[63]=se,e[64]=te,e[65]=C):C=e[65],y=ks,R="start",w="p-1 w-64",b="menu",A="flex flex-col",j=T.length>0&&r.jsx(sr,{title:"Cloud"});let G;e[66]!==$||e[67]!==n?(G=ne=>r.jsx(rr,{row:ne,active:n===ne.mode,onSelect:$},ne.mode),e[66]=$,e[67]=n,e[68]=G):G=e[68],I=T.map(G),D=L.length>0&&r.jsx(sr,{title:"Local",variant:"success",icon:r.jsx(Cs,{size:12,"data-testid":"local-section-desktop-icon"}),testId:"local-section-header"});let le;e[69]!==s||e[70]!==$||e[71]!==n?(le=ne=>{const me=ne.isAvailable(s);return r.jsx(rr,{row:ne,active:n===ne.mode,onSelect:$,unavailableHint:me?void 0:s.userDesktop?"Not detected on your desktop":"Desktop not detected"},ne.mode)},e[69]=s,e[70]=$,e[71]=n,e[72]=le):le=e[72],_=L.map(le),e[5]=s,e[6]=h,e[7]=f,e[8]=v,e[9]=m,e[10]=o,e[11]=n,e[12]=a,e[13]=c,e[14]=p,e[15]=l,e[16]=y,e[17]=x,e[18]=w,e[19]=S,e[20]=N,e[21]=C,e[22]=b,e[23]=A,e[24]=j,e[25]=I,e[26]=D,e[27]=_,e[28]=R}else y=e[16],x=e[17],w=e[18],S=e[19],N=e[20],C=e[21],b=e[22],A=e[23],j=e[24],I=e[25],D=e[26],_=e[27],R=e[28];let k;e[73]!==b||e[74]!==A||e[75]!==j||e[76]!==I||e[77]!==D||e[78]!==_?(k=r.jsxs("div",{role:b,className:A,children:[j,I,D,_]}),e[73]=b,e[74]=A,e[75]=j,e[76]=I,e[77]=D,e[78]=_,e[79]=k):k=e[79];let M;e[80]!==y||e[81]!==w||e[82]!==k||e[83]!==R?(M=r.jsx(y,{align:R,className:w,children:k}),e[80]=y,e[81]=w,e[82]=k,e[83]=R,e[84]=M):M=e[84];let E;return e[85]!==x||e[86]!==S||e[87]!==N||e[88]!==C||e[89]!==M?(E=r.jsxs(x,{open:S,onOpenChange:N,children:[C,M]}),e[85]=x,e[86]=S,e[87]=N,e[88]=C,e[89]=M,e[90]=E):E=e[90],E}function Zd(t){return t.group==="local"}function sr(t){const e=z.c(9),{title:n,variant:s,icon:o,testId:i}=t,c=(s===void 0?"muted":s)==="success"?"bg-success/10 text-success":"text-muted-foreground";let d;e[0]!==c?(d=Y("inline-flex w-fit items-center gap-2 mx-1 mt-2 mb-1 px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide",c),e[0]=c,e[1]=d):d=e[1];let u;e[2]!==n?(u=r.jsx("span",{children:n}),e[2]=n,e[3]=u):u=e[3];let f;return e[4]!==o||e[5]!==d||e[6]!==u||e[7]!==i?(f=r.jsxs("div",{"data-testid":i,className:d,children:[o,u]}),e[4]=o,e[5]=d,e[6]=u,e[7]=i,e[8]=f):f=e[8],f}function rr(t){const e=z.c(20),{row:n,active:s,onSelect:o,unavailableHint:i}=t;let a;e[0]!==o||e[1]!==n.mode?(a=()=>o(n.mode),e[0]=o,e[1]=n.mode,e[2]=a):a=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=Y("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),e[3]=c):c=e[3];let d;e[4]!==n.icon?(d=r.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:n.icon}),e[4]=n.icon,e[5]=d):d=e[5];let u;e[6]!==n.label?(u=r.jsx("div",{className:"text-sm",children:n.label}),e[6]=n.label,e[7]=u):u=e[7];const f=i??n.description;let l;e[8]!==f?(l=r.jsx("div",{className:"text-xs text-muted-foreground",children:f}),e[8]=f,e[9]=l):l=e[9];let V;e[10]!==u||e[11]!==l?(V=r.jsxs("div",{className:"flex-1",children:[u,l]}),e[10]=u,e[11]=l,e[12]=V):V=e[12];let m;e[13]!==s?(m=s&&r.jsx(Vt,{size:14,className:"text-foreground mt-0.5"}),e[13]=s,e[14]=m):m=e[14];let v;return e[15]!==a||e[16]!==d||e[17]!==V||e[18]!==m?(v=r.jsxs("button",{type:"button",role:"menuitem",onClick:a,className:c,children:[d,V,m]}),e[15]=a,e[16]=d,e[17]=V,e[18]=m,e[19]=v):v=e[19],v}function eu(t){const e=z.c(19),{locked:n,currentBranch:s,virtualMcpId:o}=t,i=Bo(),a=Md(),{org:c}=Ce();let d;e[0]!==c.id||e[1]!==c.slug?(d={connectionId:Xr,orgId:c.id,orgSlug:c.slug},e[0]=c.id,e[1]=c.slug,e[2]=d):d=e[2];const u=gt(d),f=kd(u),l=En(),V=l?.lockedHarness??null,m=l?.lockedSandbox??null,v=l?.isThreadLocked??!1,p=Id();let h;e[3]!==v||e[4]!==V||e[5]!==m||e[6]!==i?(h=Qd({selectedMode:i,lockedHarness:V,lockedSandbox:m,isThreadLocked:v}),e[3]=v,e[4]=V,e[5]=m,e[6]=i,e[7]=h):h=e[7];const y=h;let x;e[8]!==s||e[9]!==a||e[10]!==f||e[11]!==o?(x=N=>{a(N),X("agent_mode_selected",{mode:N}),s&&f.mutate({virtualMcpId:o,branch:s,sandboxProviderKind:N==="cloud-decopilot"?"agent-sandbox":"user-desktop"})},e[8]=s,e[9]=a,e[10]=f,e[11]=o,e[12]=x):x=e[12];const w=x;let S;return e[13]!==p||e[14]!==w||e[15]!==n||e[16]!==V||e[17]!==y?(S=r.jsx(r.Fragment,{children:r.jsx(Jd,{mode:y,availability:p,locked:n,lockedHarness:V,onSelect:w})}),e[13]=p,e[14]=w,e[15]=n,e[16]=V,e[17]=y,e[18]=S):S=e[18],S}function tu(t){return(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"user"}function nu(t){const e=tu(t),n=Date.now().toString(36).split("").reverse().join("");return`${e}-${n}`}const hn=100;function su(t,e,n){const s=e.trim().toLowerCase();return s?(t??[]).some(o=>o.branches.some(i=>typeof i.name=="string"&&!n.has(i.name)&&i.name.toLowerCase().includes(s))):!0}function ru(t,e){const n=e.trim().toLowerCase();return n?[...t].some(s=>s.toLowerCase().includes(n)):!0}function ou(t){const e=t;if(e.structuredContent)return e.structuredContent;const n=e.content?.find(s=>s.type==="text")?.text;if(n)try{return JSON.parse(n)}catch{return[]}return[]}function iu(t){const e=z.c(48),{orgId:n,orgSlug:s,userId:o,connectionId:i,sandboxMap:a,owner:c,repo:d,enabled:u}=t,f=u===void 0?!0:u,l=i??null;let V;e[0]!==n||e[1]!==s||e[2]!==l?(V={connectionId:l,orgId:n,orgSlug:s},e[0]=n,e[1]=s,e[2]=l,e[3]=V):V=e[3];const m=gt(V);let v;e[4]!==i||e[5]!==n||e[6]!==s||e[7]!==c||e[8]!==d?(v=Yi.githubBranches(n,s,i,c,d),e[4]=i,e[5]=n,e[6]=s,e[7]=c,e[8]=d,e[9]=v):v=e[9];const p=f&&!!i&&!!c&&!!d;let h;e[10]!==m||e[11]!==c||e[12]!==d?(h=async $=>{const{pageParam:B,signal:K}=$,H=Number(B),O=await m.callTool({name:"list_branches",arguments:{owner:c,repo:d,page:H,perPage:hn}},void 0,{signal:K}),F=ou(O);return{branches:Array.isArray(F)?F:F.branches??[],default_branch:Array.isArray(F)?null:F.default_branch??null,page:H}},e[10]=m,e[11]=c,e[12]=d,e[13]=h):h=e[13];let y;e[14]!==v||e[15]!==p||e[16]!==h?(y={queryKey:v,enabled:p,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:h,getNextPageParam:fu},e[14]=v,e[15]=p,e[16]=h,e[17]=y):y=e[17];const{data:x,isLoading:w,isError:S,hasNextPage:N,isFetchingNextPage:C,fetchNextPage:b}=wl(y);let A,j;e[18]!==a||e[19]!==o?(j=new Set(Object.keys(a?.[o]??{})),A=[...j].sort().map(uu),e[18]=a,e[19]=o,e[20]=A,e[21]=j):(A=e[20],j=e[21]);const I=A;let D;if(e[22]!==x?.pages){const $=new Map;for(const K of x?.pages??[])for(const H of K.branches)typeof H.name=="string"&&$.set(H.name,H);D=[...$.values()].filter(du),e[22]=x?.pages,e[23]=D}else D=e[23];let _;e[24]!==D||e[25]!==j?(_=D.filter($=>!j.has($.name)).map(cu),e[24]=D,e[25]=j,e[26]=_):_=e[26];const R=_;let k;e[27]!==x?.pages?(k=x?.pages.find(lu)?.default_branch??null,e[27]=x?.pages,e[28]=k):k=e[28];const M=k;let E;e[29]!==x?.pages||e[30]!==b||e[31]!==C||e[32]!==j?(E=async($,B)=>{const K=B===void 0?au:B;if(!K()||ru(j,$)||C)return;let H=x?.pages??[];for(;K()&&!su(H,$,j)&&(H.at(-1)?.branches.length??hn)>=hn;){const O=await b();if(!K())break;const F=O.data?.pages??H;if(F.length===H.length)break;H=F}},e[29]=x?.pages,e[30]=b,e[31]=C,e[32]=j,e[33]=E):E=e[33];const P=E,T=N??!1;let L;e[34]!==b||e[35]!==N||e[36]!==C?(L=()=>{N&&!C&&b()},e[34]=b,e[35]=N,e[36]=C,e[37]=L):L=e[37];let U;return e[38]!==M||e[39]!==P||e[40]!==S||e[41]!==C||e[42]!==w||e[43]!==R||e[44]!==T||e[45]!==L||e[46]!==I?(U={yours:I,others:R,defaultBase:M,isLoading:w,isError:S,hasMore:T,isFetchingMore:C,fetchMore:L,fetchUntilMatch:P},e[38]=M,e[39]=P,e[40]=S,e[41]=C,e[42]=w,e[43]=R,e[44]=T,e[45]=L,e[46]=I,e[47]=U):U=e[47],U}function au(){return!0}function lu(t){return t.default_branch}function cu(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function du(t){return typeof t.name=="string"}function uu(t){return{name:t,source:"yours"}}function fu(t){if(!(t.branches.length<hn))return t.page+1}function Vu(t){const e=z.c(85),{orgId:n,orgSlug:s,userId:o,userLabel:i,connectionId:a,owner:c,repo:d,sandboxMap:u,value:f,onChange:l,disabled:V,placement:m}=t,v=V===void 0?!1:V,h=(m===void 0?"chat":m)==="header",[y,x]=g.useState(!1),[w,S]=g.useState(""),[N,C]=g.useState(!1),b=g.useRef(0);let A;e[0]!==a||e[1]!==y||e[2]!==n||e[3]!==s||e[4]!==c||e[5]!==d||e[6]!==u||e[7]!==o?(A={orgId:n,orgSlug:s,userId:o,connectionId:a,sandboxMap:u,owner:c,repo:d,enabled:y},e[0]=a,e[1]=y,e[2]=n,e[3]=s,e[4]=c,e[5]=d,e[6]=u,e[7]=o,e[8]=A):A=e[8];const{yours:j,others:I,isLoading:D,isError:_,hasMore:R,isFetchingMore:k,fetchMore:M,fetchUntilMatch:E}=iu(A);let P;e[9]!==l?(P=ae=>{l(ae),x(!1)},e[9]=l,e[10]=P):P=e[10];const T=P,L=f??"Select branch…";let U;e[11]!==E?(U=ae=>{S(ae),b.current=b.current+1;const he=b.current,Ie=ae.trim();if(!Ie){C(!1);return}C(!0),E(Ie,()=>he===b.current).finally(()=>{he===b.current&&C(!1)})},e[11]=E,e[12]=U):U=e[12];const $=U;let B;e[13]!==M?(B=ae=>{const he=ae.currentTarget;he.scrollHeight-he.scrollTop-he.clientHeight<48&&M()},e[13]=M,e[14]=B):B=e[14];const K=B,H=v?void 0:x,O=h?"outline":"ghost",F=h?"sm":"default";let J;e[15]!==v||e[16]!==h?(J=Y("font-mono shrink min-w-0 max-w-[200px]",h?"gap-1.5 text-xs":Y("text-xs text-muted-foreground hover:text-foreground transition-[gap] duration-200",v?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5")),e[15]=v,e[16]=h,e[17]=J):J=e[17];let Q;e[18]===Symbol.for("react.memo_cache_sentinel")?(Q=r.jsx(mn,{className:"h-3.5 w-3.5 shrink-0"}),e[18]=Q):Q=e[18];const Z=h?"":"transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[200px] @[320px]/chat-bottom:opacity-100";let q;e[19]!==Z?(q=Y("min-w-0 truncate",Z),e[19]=Z,e[20]=q):q=e[20];let se;e[21]!==L||e[22]!==q?(se=r.jsx("span",{className:q,children:L}),e[21]=L,e[22]=q,e[23]=se):se=e[23];let ee;e[24]!==v||e[25]!==h?(ee=!v&&r.jsx(Ln,{size:12,className:Y("opacity-60 shrink-0",h?"":"hidden @[320px]/chat-bottom:inline-block")}),e[24]=v,e[25]=h,e[26]=ee):ee=e[26];let te;e[27]!==v||e[28]!==L||e[29]!==J||e[30]!==se||e[31]!==ee||e[32]!==O||e[33]!==F?(te=r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"inline-flex min-w-0 shrink",children:r.jsx(Ns,{asChild:!0,children:r.jsxs(ie,{variant:O,size:F,"aria-label":L,disabled:v,className:J,children:[Q,se,ee]})})})}),e[27]=v,e[28]=L,e[29]=J,e[30]=se,e[31]=ee,e[32]=O,e[33]=F,e[34]=te):te=e[34];let G;e[35]!==L?(G=r.jsx(Ke,{children:L}),e[35]=L,e[36]=G):G=e[36];let le;e[37]!==te||e[38]!==G?(le=r.jsxs(qe,{children:[te,G]}),e[37]=te,e[38]=G,e[39]=le):le=e[39];let ne;e[40]!==$||e[41]!==w?(ne=r.jsx(xl,{placeholder:"Search loaded branches…",value:w,onValueChange:$}),e[40]=$,e[41]=w,e[42]=ne):ne=e[42];let me;e[43]!==T||e[44]!==i?(me=r.jsx(ie,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>T(nu(i)),children:"New"}),e[43]=T,e[44]=i,e[45]=me):me=e[45];let pe;e[46]!==ne||e[47]!==me?(pe=r.jsxs("div",{className:"*:data-[slot=command-input-wrapper]:flex-1 *:data-[slot=command-input-wrapper]:border-b-0 flex items-center border-b pr-2",children:[ne,me]}),e[46]=ne,e[47]=me,e[48]=pe):pe=e[48];let re;e[49]!==_?(re=_&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[49]=_,e[50]=re):re=e[50];let de;e[51]!==R||e[52]!==_||e[53]!==D?(de=!_&&!D&&r.jsx(vl,{children:R?"Looking through more branches...":"No branches found."}),e[51]=R,e[52]=_,e[53]=D,e[54]=de):de=e[54];let we;e[55]!==T||e[56]!==j?(we=j.length>0&&r.jsx(zs,{heading:"Your branches",children:j.map(ae=>r.jsxs(Bs,{value:ae.name,onSelect:()=>T(ae.name),children:[r.jsx(mn,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:ae.name})]},ae.name))}),e[55]=T,e[56]=j,e[57]=we):we=e[57];let xe;e[58]!==I||e[59]!==T?(xe=I.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(gl,{}),r.jsx(zs,{heading:"Other branches in repo",children:I.map(ae=>r.jsxs(Bs,{value:ae.name,onSelect:()=>T(ae.name),children:[r.jsx(mn,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:ae.name}),ae.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",ae.author]})]},ae.name))})]}),e[58]=I,e[59]=T,e[60]=xe):xe=e[60];let ye;e[61]!==M||e[62]!==R||e[63]!==k||e[64]!==N?(ye=R&&r.jsx("div",{className:"border-t p-2",children:r.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:k,onClick:M,children:k||N?"Loading more…":"Load more branches"})}),e[61]=M,e[62]=R,e[63]=k,e[64]=N,e[65]=ye):ye=e[65];let ke;e[66]!==R||e[67]!==I.length?(ke=!R&&I.length>0&&r.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"}),e[66]=R,e[67]=I.length,e[68]=ke):ke=e[68];let Me;e[69]!==K||e[70]!==re||e[71]!==de||e[72]!==we||e[73]!==xe||e[74]!==ye||e[75]!==ke?(Me=r.jsxs(bl,{onScroll:K,children:[re,de,we,xe,ye,ke]}),e[69]=K,e[70]=re,e[71]=de,e[72]=we,e[73]=xe,e[74]=ye,e[75]=ke,e[76]=Me):Me=e[76];let Oe;e[77]!==pe||e[78]!==Me?(Oe=r.jsx(ks,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:r.jsxs(yl,{children:[pe,Me]})}),e[77]=pe,e[78]=Me,e[79]=Oe):Oe=e[79];let je;return e[80]!==y||e[81]!==le||e[82]!==Oe||e[83]!==H?(je=r.jsxs(Ss,{open:y,onOpenChange:H,children:[le,Oe]}),e[80]=y,e[81]=le,e[82]=Oe,e[83]=H,e[84]=je):je=e[84],je}function mu(t){const e=z.c(25);let n,s,o,i;e[0]!==t?({locked:n,placement:s,value:i,...o}=t,e[0]=t,e[1]=n,e[2]=s,e[3]=o,e[4]=i):(n=e[1],s=e[2],o=e[3],i=e[4]);const a=s==="header";if(n){const d=i??"(no branch)",u=a?"h-8 gap-1.5 border border-input bg-background px-2.5":"h-9 gap-0 px-2";let f;e[5]!==u?(f=Y("inline-flex items-center rounded-md font-mono text-xs","text-muted-foreground cursor-default min-w-0 max-w-[200px]",u),e[5]=u,e[6]=f):f=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(mn,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e[7]=l):l=e[7];const V=a?"":"max-w-0 opacity-0";let m;e[8]!==V?(m=Y("min-w-0 truncate",V),e[8]=V,e[9]=m):m=e[9];let v;e[10]!==d||e[11]!==m?(v=r.jsx("span",{className:m,children:d}),e[10]=d,e[11]=m,e[12]=v):v=e[12];let p;e[13]!==f||e[14]!==v?(p=r.jsx(Ue,{asChild:!0,children:r.jsxs("span",{"data-testid":"branch-picker-locked","aria-disabled":"true",className:f,children:[l,v]})}),e[13]=f,e[14]=v,e[15]=p):p=e[15];let h;e[16]!==d?(h=r.jsxs(Ke,{children:["This chat is using branch ",d,". Start a new chat to use a different branch."]}),e[16]=d,e[17]=h):h=e[17];let y;return e[18]!==p||e[19]!==h?(y=r.jsxs(qe,{children:[p,h]}),e[18]=p,e[19]=h,e[20]=y):y=e[20],y}let c;return e[21]!==s||e[22]!==o||e[23]!==i?(c=r.jsx(Vu,{...o,value:i,placement:s}),e[21]=s,e[22]=o,e[23]=i,e[24]=c):c=e[24],c}function pu(t){const e=z.c(3),{branchPill:n,modePicker:s}=t;if(!n&&!s)return null;let o;return e[0]!==n||e[1]!==s?(o=r.jsxs(r.Fragment,{children:[s,n]}),e[0]=n,e[1]=s,e[2]=o):o=e[2],o}function hu(t){const e=z.c(26),{virtualMcp:n,currentBranch:s}=t,o=Br(),i=En();let a;e[0]!==o?.messages||e[1]!==i?.isThreadLocked?(a=(o?.messages??[]).length>0||(i?.isThreadLocked??!1),e[0]=o?.messages,e[1]=i?.isThreadLocked,e[2]=a):a=e[2];const c=a,d=i?.setCurrentTaskBranch;let u;e[3]!==n?(u=ul(n),e[3]=n,e[4]=u):u=e[4];const f=u,l=f?.connectionId,{data:V}=_n.useSession(),m=V?.user?.id??"";let v;e[5]!==V?.user?.email||e[6]!==V?.user?.name?(v=V?.user?.name??V?.user?.email?.split("@")[0],e[5]=V?.user?.email,e[6]=V?.user?.name,e[7]=v):v=e[7];const p=v,{org:h}=Ce();let y;e[8]!==l||e[9]!==s||e[10]!==f||e[11]!==c||e[12]!==h||e[13]!==d||e[14]!==m||e[15]!==p||e[16]!==n?.id||e[17]!==n?.metadata?.sandboxMap?(y=f&&l?r.jsx(mu,{orgId:h.id,orgSlug:h.slug,userId:m,userLabel:p,virtualMcpId:n?.id??"",connectionId:l,owner:f.owner,repo:f.name,sandboxMap:n?.metadata?.sandboxMap,value:s,onChange:b=>{d&&d(b)},locked:c,placement:"chat"}):null,e[8]=l,e[9]=s,e[10]=f,e[11]=c,e[12]=h,e[13]=d,e[14]=m,e[15]=p,e[16]=n?.id,e[17]=n?.metadata?.sandboxMap,e[18]=y):y=e[18];const x=y,w=n?.id??"";let S;e[19]!==s||e[20]!==c||e[21]!==w?(S=r.jsx(eu,{locked:c,currentBranch:s,virtualMcpId:w}),e[19]=s,e[20]=c,e[21]=w,e[22]=S):S=e[22];const N=S;let C;return e[23]!==x||e[24]!==N?(C=r.jsx(pu,{branchPill:x,modePicker:N}),e[23]=x,e[24]=N,e[25]=C):C=e[25],C}const gu=["fast","smart","thinking"],zt={fast:"Fast",smart:"Smart",thinking:"Thinking"};function xu(t){const e=z.c(30),{tier:n,subtitleFor:s,iconFor:o,onSelect:i}=t,[a,c]=g.useState(!1);let d;e[0]!==i?(d=A=>{i(A),c(!1)},e[0]=i,e[1]=d):d=e[1];const u=d,f=zt[n];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=Y("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),e[2]=l):l=e[2];let V;e[3]!==o||e[4]!==n?(V=o?.(n),e[3]=o,e[4]=n,e[5]=V):V=e[5];let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=Y("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),e[6]=m):m=e[6];const v=zt[n];let p;e[7]!==v?(p=r.jsx("span",{className:m,children:v}),e[7]=v,e[8]=p):p=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(Ln,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[9]=h):h=e[9];let y;e[10]!==f||e[11]!==V||e[12]!==p?(y=r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"inline-flex min-w-0 shrink",children:r.jsx(Ns,{asChild:!0,children:r.jsxs(ie,{type:"button",variant:"ghost",size:"default","aria-label":f,className:l,children:[V,p,h]})})})}),e[10]=f,e[11]=V,e[12]=p,e[13]=y):y=e[13];const x=zt[n];let w;e[14]!==x?(w=r.jsx(Ke,{children:x}),e[14]=x,e[15]=w):w=e[15];let S;e[16]!==w||e[17]!==y?(S=r.jsxs(qe,{children:[y,w]}),e[16]=w,e[17]=y,e[18]=S):S=e[18];let N;e[19]!==u||e[20]!==o||e[21]!==s||e[22]!==n?(N=gu.map(A=>{const j=s(A),I=o?.(A),D=A===n;return r.jsxs("button",{type:"button",role:"menuitem","aria-label":zt[A],onClick:()=>u(A),className:Y("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),children:[I&&r.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:I}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-sm",children:zt[A]}),j&&r.jsx("div",{className:"text-xs text-muted-foreground",children:j})]}),D&&r.jsx(Vt,{size:14,className:"text-foreground mt-0.5"})]},A)}),e[19]=u,e[20]=o,e[21]=s,e[22]=n,e[23]=N):N=e[23];let C;e[24]!==N?(C=r.jsx(ks,{align:"end",className:"p-1 w-56",children:r.jsx("div",{role:"menu",className:"flex flex-col",children:N})}),e[24]=N,e[25]=C):C=e[25];let b;return e[26]!==a||e[27]!==S||e[28]!==C?(b=r.jsxs(Ss,{open:a,onOpenChange:c,children:[S,C]}),e[26]=a,e[27]=S,e[28]=C,e[29]=b):b=e[29],b}function vu(t){return t==="fast"?r.jsx(Ja,{size:16}):t==="thinking"?r.jsx(Za,{size:16}):r.jsx(jl,{size:16})}function bu(){const t=z.c(6),e=Od(),n=Ld(),s=Bo();let o;t[0]!==s?(o=c=>$d(s,c),t[0]=s,t[1]=o):o=t[1];const i=o;let a;return t[2]!==n||t[3]!==i||t[4]!==e?(a=r.jsx(xu,{tier:e,subtitleFor:i,iconFor:vu,onSelect:n}),t[2]=n,t[3]=i,t[4]=e,t[5]=a):a=t[5],a}async function Ds(t,e,n,s,o){if(!$n(e)){ue.error("Selected model does not support file uploads");return}const i=n.type||"application/octet-stream";if(!ml(i,e)){const c=xo(e),d=e?.title??"This model";o?o({fileName:n.name,modelName:d,accepted:c}):ue.error(`"${n.name}" can't be attached`,{description:`${d} accepts ${c}.`});return}const a=10*1024*1024;if(n.size>a){ue.error(`File "${n.name}" exceeds 10MB limit`);return}try{const c=new FileReader,d=new Promise((l,V)=>{c.onload=()=>{const m=c.result;if(typeof m!="string"){V(new Error("Failed to read file as data URL"));return}const v=m.includes(",")?m.split(",")[1]??m:m;l(v)},c.onerror=V});c.readAsDataURL(n);const u=await d,f={id:crypto.randomUUID(),name:n.name,mimeType:n.type||"application/octet-stream",size:n.size,data:u};va(t,{from:s,to:s},f)}catch(c){console.error("Failed to process file:",c),ue.error(`Failed to load file "${n.name}"`)}}function yu(t){const e=z.c(8),{editor:n,selectedModel:s,onUnsupportedFile:o}=t,i=g.useRef(ju);let a,c;e[0]!==n||e[1]!==o||e[2]!==s?(a=()=>{i.current=async(f,l)=>{await Ds(n,s,f,l,o)}},c=[n,s,o],e[0]=n,e[1]=o,e[2]=s,e[3]=a,e[4]=c):(a=e[3],c=e[4]),g.useEffect(a,c);let d,u;return e[5]!==n?(d=()=>{if(n?.isDestroyed)return;const f=new bn("fileDropHandler");n.state.plugins.find(m=>m.spec.key===f)&&n.unregisterPlugin(f);const V=new Kr({key:f,props:{handleDrop:(m,v,p,h)=>{if(h)return!1;const y=v.dataTransfer?.files;if(!y||y.length===0)return!1;v.preventDefault();const x=m.posAtCoords({left:v.clientX,top:v.clientY});if(!x)return!1;const w=Array.from(y),S=x.pos;for(const N of w)i.current?.(N,S);return!0},handlePaste:(m,v)=>{const p=v.clipboardData?.items;if(!p)return!1;const h=Array.from(p).filter(wu);if(h.length===0)return!1;v.preventDefault();const{from:y}=m.state.selection;for(const x of h){const w=x.getAsFile();w&&i.current?.(w,y)}return!0}}});return n.registerPlugin(V),()=>{n?.isDestroyed||n.unregisterPlugin(f)}},u=[n],e[5]=n,e[6]=d,e[7]=u):(d=e[6],u=e[7]),g.useEffect(d,u),null}function wu(t){return t.kind==="file"}function ju(){return Promise.resolve()}function Au(t){const e=z.c(26),{info:n,onClose:s}=t,o=n!==null;let i;e[0]!==s?(i=N=>!N&&s(),e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=a):a=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:a.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=c):c=e[3];let d,u;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:r.jsx(Pr,{size:18})}),u=r.jsx(_t,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=d,e[5]=u):(d=e[4],u=e[5]);const f=n?.fileName;let l;e[6]!==f?(l=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[c,r.jsxs(Rt,{className:"relative gap-4",children:[d,r.jsxs("div",{children:[u,r.jsxs(Pn,{className:"mt-1.5 text-sm leading-relaxed",children:[r.jsxs("span",{className:"font-medium text-foreground",children:["“",f,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=f,e[7]=l):l=e[7];const V=n?.modelName;let m;e[8]!==V?(m=r.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[V," accepts"]}),e[8]=V,e[9]=m):m=e[9];let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(el,{size:14,className:"text-muted-foreground"}),e[10]=v):v=e[10];const p=n?.accepted;let h;e[11]!==p?(h=r.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[v,r.jsx("span",{className:"capitalize",children:p})]}),e[11]=p,e[12]=h):h=e[12];let y;e[13]!==m||e[14]!==h?(y=r.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:r.jsxs("div",{className:"rounded-xl border border-border p-4",children:[m,h]})}),e[13]=m,e[14]=h,e[15]=y):y=e[15];let x;e[16]!==s?(x=r.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:r.jsx(ie,{onClick:s,children:"Got it"})}),e[16]=s,e[17]=x):x=e[17];let w;e[18]!==y||e[19]!==x||e[20]!==l?(w=r.jsxs(Et,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Cu,children:[l,y,x]}),e[18]=y,e[19]=x,e[20]=l,e[21]=w):w=e[21];let S;return e[22]!==o||e[23]!==w||e[24]!==i?(S=r.jsx(Tt,{open:o,onOpenChange:i,children:w}),e[22]=o,e[23]=w,e[24]=i,e[25]=S):S=e[25],S}function Cu(t){return t.preventDefault()}function Su(){const t=z.c(3),[e,n]=g.useState(null);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>n(null),t[0]=s):s=t[0];let o;return t[1]!==e?(o={unsupportedFile:e,onUnsupportedFile:n,clearUnsupportedFile:s},t[1]=e,t[2]=o):o=t[2],o}var Nu=ba;var ku=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],ps=ku.join(","),Ko=typeof Element>"u",Jt=Ko?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,An=!Ko&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},Cn=function(e,n){var s;n===void 0&&(n=!0);var o=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"inert"),i=o===""||o==="true",a=i||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):Cn(e.parentNode));return a},Iu=function(e){var n,s=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return s===""||s==="true"},Du=function(e,n,s){if(Cn(e))return[];var o=Array.prototype.slice.apply(e.querySelectorAll(ps));return n&&Jt.call(e,ps)&&o.unshift(e),o=o.filter(s),o},hs=function(e,n,s){for(var o=[],i=Array.from(e);i.length;){var a=i.shift();if(!Cn(a,!1))if(a.tagName==="SLOT"){var c=a.assignedElements(),d=c.length?c:a.children,u=hs(d,!0,s);s.flatten?o.push.apply(o,u):o.push({scopeParent:a,candidates:u})}else{var f=Jt.call(a,ps);f&&s.filter(a)&&(n||!e.includes(a))&&o.push(a);var l=a.shadowRoot||typeof s.getShadowRoot=="function"&&s.getShadowRoot(a),V=!Cn(l,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(a));if(l&&V){var m=hs(l===!0?a.children:l.children,!0,s);s.flatten?o.push.apply(o,m):o.push({scopeParent:a,candidates:m})}else i.unshift.apply(i,a.children)}}return o},qo=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Yo=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Iu(e))&&!qo(e)?0:e.tabIndex},Ru=function(e,n){var s=Yo(e);return s<0&&n&&!qo(e)?0:s},_u=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},Ho=function(e){return e.tagName==="INPUT"},Eu=function(e){return Ho(e)&&e.type==="hidden"},Tu=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(s){return s.tagName==="SUMMARY"});return n},Pu=function(e,n){for(var s=0;s<e.length;s++)if(e[s].checked&&e[s].form===n)return e[s]},Mu=function(e){if(!e.name)return!0;var n=e.form||An(e),s=function(c){return n.querySelectorAll('input[type="radio"][name="'+c+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=s(window.CSS.escape(e.name));else try{o=s(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var i=Pu(o,e.form);return!i||i===e},Ou=function(e){return Ho(e)&&e.type==="radio"},Lu=function(e){return Ou(e)&&!Mu(e)},Fu=function(e){var n,s=e&&An(e),o=(n=s)===null||n===void 0?void 0:n.host,i=!1;if(s&&s!==e){var a,c,d;for(i=!!((a=o)!==null&&a!==void 0&&(c=a.ownerDocument)!==null&&c!==void 0&&c.contains(o)||e!=null&&(d=e.ownerDocument)!==null&&d!==void 0&&d.contains(e));!i&&o;){var u,f,l;s=An(o),o=(u=s)===null||u===void 0?void 0:u.host,i=!!((f=o)!==null&&f!==void 0&&(l=f.ownerDocument)!==null&&l!==void 0&&l.contains(o))}}return i},or=function(e){var n=e.getBoundingClientRect(),s=n.width,o=n.height;return s===0&&o===0},$u=function(e,n){var s=n.displayCheck,o=n.getShadowRoot;if(s==="full-native"&&"checkVisibility"in e){var i=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!i}if(getComputedStyle(e).visibility==="hidden")return!0;var a=Jt.call(e,"details>summary:first-of-type"),c=a?e.parentElement:e;if(Jt.call(c,"details:not([open]) *"))return!0;if(!s||s==="full"||s==="full-native"||s==="legacy-full"){if(typeof o=="function"){for(var d=e;e;){var u=e.parentElement,f=An(e);if(u&&!u.shadowRoot&&o(u)===!0)return or(e);e.assignedSlot?e=e.assignedSlot:!u&&f!==e.ownerDocument?e=f.host:e=u}e=d}if(Fu(e))return!e.getClientRects().length;if(s!=="legacy-full")return!0}else if(s==="non-zero-area")return or(e);return!1},zu=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var s=0;s<n.children.length;s++){var o=n.children.item(s);if(o.tagName==="LEGEND")return Jt.call(n,"fieldset[disabled] *")?!0:!o.contains(e)}return!0}n=n.parentElement}return!1},Bu=function(e,n){return!(n.disabled||Eu(n)||$u(n,e)||Tu(n)||zu(n))},ir=function(e,n){return!(Lu(n)||Yo(n)<0||!Bu(e,n))},Uu=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Qo=function(e){var n=[],s=[];return e.forEach(function(o,i){var a=!!o.scopeParent,c=a?o.scopeParent:o,d=Ru(c,a),u=a?Qo(o.candidates):c;d===0?a?n.push.apply(n,u):n.push(c):s.push({documentOrder:i,tabIndex:d,item:o,isScope:a,content:u})}),s.sort(_u).reduce(function(o,i){return i.isScope?o.push.apply(o,i.content):o.push(i.content),o},[]).concat(n)},Wo=function(e,n){n=n||{};var s;return n.getShadowRoot?s=hs([e],n.includeContainer,{filter:ir.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:Uu}):s=Du(e,n.includeContainer,ir.bind(null,n)),Qo(s)};function Ku(){return/apple/i.test(navigator.vendor)}const ar="data-floating-ui-focusable";function qu(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function gs(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&Hi(n)){let s=e;for(;s;){if(t===s)return!0;s=s.parentNode||s.host}}return!1}function Bt(t){return"composedPath"in t?t.composedPath()[0]:t.target}function ss(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function Yu(t){return t.matches("html,body")}function Zt(t){return t?.ownerDocument||document}function Hu(t){return t?t.hasAttribute(ar)?t:t.querySelector("["+ar+"]")||t:null}function gn(t,e,n){return n===void 0&&(n=!0),t.filter(o=>{var i;return o.parentId===e&&(!n||((i=o.context)==null?void 0:i.open))}).flatMap(o=>[o,...gn(t,o.id,n)])}function Qu(t){return"nativeEvent"in t}var Wu=typeof document<"u",Gu=function(){},ft=Wu?g.useLayoutEffect:Gu;const Xu={...Mr},Ju=Xu.useInsertionEffect,Zu=Ju||(t=>t());function jt(t){const e=g.useRef(()=>{});return Zu(()=>{e.current=t}),g.useCallback(function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return e.current==null?void 0:e.current(...s)},[])}const Go=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Xo(t,e){const n=Wo(t,Go()),s=n.length;if(s===0)return;const o=qu(Zt(t)),i=n.indexOf(o),a=i===-1?e===1?0:s-1:i+e;return n[a]}function ef(t){return Xo(Zt(t).body,1)||t}function tf(t){return Xo(Zt(t).body,-1)||t}function rs(t,e){const n=e||t.currentTarget,s=t.relatedTarget;return!s||!gs(n,s)}function nf(t){Wo(t,Go()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function lr(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const s=n.dataset.tabindex;delete n.dataset.tabindex,s?n.setAttribute("tabindex",s):n.removeAttribute("tabindex")})}const sf="data-floating-ui-focusable",cr="active",dr="selected",rf={...Mr};let ur=!1,of=0;const fr=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+of++;function af(){const[t,e]=g.useState(()=>ur?fr():void 0);return ft(()=>{t==null&&e(fr())},[]),g.useEffect(()=>{ur=!0},[]),t}const lf=rf.useId,Rs=lf||af;function cf(){const t=new Map;return{emit(e,n){var s;(s=t.get(e))==null||s.forEach(o=>o(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var s;(s=t.get(e))==null||s.delete(n)}}}const df=g.createContext(null),uf=g.createContext(null),Jo=()=>{var t;return((t=g.useContext(df))==null?void 0:t.id)||null},Zo=()=>g.useContext(uf);function _s(t){return"data-floating-ui-"+t}const ff={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},Vr=g.forwardRef(function(e,n){const[s,o]=g.useState();ft(()=>{Ku()&&o("button")},[]);const i={ref:n,tabIndex:0,role:s,"aria-hidden":s?void 0:!0,[_s("focus-guard")]:"",style:ff};return r.jsx("span",{...e,...i})}),Vf={clipPath:"inset(50%)",position:"fixed",top:0,left:0},ei=g.createContext(null),mr=_s("portal");function mf(t){t===void 0&&(t={});const{id:e,root:n}=t,s=Rs(),o=hf(),[i,a]=g.useState(null),c=g.useRef(null);return ft(()=>()=>{i?.remove(),queueMicrotask(()=>{c.current=null})},[i]),ft(()=>{if(!s||c.current)return;const d=e?document.getElementById(e):null;if(!d)return;const u=document.createElement("div");u.id=s,u.setAttribute(mr,""),d.appendChild(u),c.current=u,a(u)},[e,s]),ft(()=>{if(n===null||!s||c.current)return;let d=n||o?.portalNode;d&&!Zi(d)&&(d=d.current),d=d||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,d.appendChild(u));const f=document.createElement("div");f.id=s,f.setAttribute(mr,""),d=u||d,d.appendChild(f),c.current=f,a(f)},[e,n,s,o]),i}function pf(t){const{children:e,id:n,root:s,preserveTabOrder:o=!0}=t,i=mf({id:n,root:s}),[a,c]=g.useState(null),d=g.useRef(null),u=g.useRef(null),f=g.useRef(null),l=g.useRef(null),V=a?.modal,m=a?.open,v=!!a&&!a.modal&&a.open&&o&&!!(s||i);return g.useEffect(()=>{if(!i||!o||V)return;function p(h){i&&rs(h)&&(h.type==="focusin"?lr:nf)(i)}return i.addEventListener("focusin",p,!0),i.addEventListener("focusout",p,!0),()=>{i.removeEventListener("focusin",p,!0),i.removeEventListener("focusout",p,!0)}},[i,o,V]),g.useEffect(()=>{i&&(m||lr(i))},[m,i]),r.jsxs(ei.Provider,{value:g.useMemo(()=>({preserveTabOrder:o,beforeOutsideRef:d,afterOutsideRef:u,beforeInsideRef:f,afterInsideRef:l,portalNode:i,setFocusManagerState:c}),[o,i]),children:[v&&i&&r.jsx(Vr,{"data-type":"outside",ref:d,onFocus:p=>{if(rs(p,i)){var h;(h=f.current)==null||h.focus()}else{const y=a?a.domReference:null,x=tf(y);x?.focus()}}}),v&&i&&r.jsx("span",{"aria-owns":i.id,style:Vf}),i&&At.createPortal(e,i),v&&i&&r.jsx(Vr,{"data-type":"outside",ref:u,onFocus:p=>{if(rs(p,i)){var h;(h=l.current)==null||h.focus()}else{const y=a?a.domReference:null,x=ef(y);x?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,p.nativeEvent,"focus-out")}}})]})}const hf=()=>g.useContext(ei),gf={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},xf={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},pr=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function vf(t,e){e===void 0&&(e={});const{open:n,onOpenChange:s,elements:o,dataRef:i}=t,{enabled:a=!0,escapeKey:c=!0,outsidePress:d=!0,outsidePressEvent:u="pointerdown",referencePress:f=!1,referencePressEvent:l="pointerdown",ancestorScroll:V=!1,bubbles:m,capture:v}=e,p=Zo(),h=jt(typeof d=="function"?d:()=>!1),y=typeof d=="function"?h:d,x=g.useRef(!1),{escapeKey:w,outsidePress:S}=pr(m),{escapeKey:N,outsidePress:C}=pr(v),b=g.useRef(!1),A=jt(k=>{var M;if(!n||!a||!c||k.key!=="Escape"||b.current)return;const E=(M=i.current.floatingContext)==null?void 0:M.nodeId,P=p?gn(p.nodesRef.current,E):[];if(!w&&(k.stopPropagation(),P.length>0)){let T=!0;if(P.forEach(L=>{var U;if((U=L.context)!=null&&U.open&&!L.context.dataRef.current.__escapeKeyBubbles){T=!1;return}}),!T)return}s(!1,Qu(k)?k.nativeEvent:k,"escape-key")}),j=jt(k=>{var M;const E=()=>{var P;A(k),(P=Bt(k))==null||P.removeEventListener("keydown",E)};(M=Bt(k))==null||M.addEventListener("keydown",E)}),I=jt(k=>{var M;const E=i.current.insideReactTree;i.current.insideReactTree=!1;const P=x.current;if(x.current=!1,u==="click"&&P||E||typeof y=="function"&&!y(k))return;const T=Bt(k),L="["+_s("inert")+"]",U=Zt(o.floating).querySelectorAll(L);let $=Xe(T)?T:null;for(;$&&!Gn($);){const O=Gi($);if(Gn(O)||!Xe(O))break;$=O}if(U.length&&Xe(T)&&!Yu(T)&&!gs(T,o.floating)&&Array.from(U).every(O=>!gs($,O)))return;if(Xi(T)&&R){const O=Gn(T),F=Ji(T),J=/auto|scroll/,Q=O||J.test(F.overflowX),Z=O||J.test(F.overflowY),q=Q&&T.clientWidth>0&&T.scrollWidth>T.clientWidth,se=Z&&T.clientHeight>0&&T.scrollHeight>T.clientHeight,ee=F.direction==="rtl",te=se&&(ee?k.offsetX<=T.offsetWidth-T.clientWidth:k.offsetX>T.clientWidth),G=q&&k.offsetY>T.clientHeight;if(te||G)return}const B=(M=i.current.floatingContext)==null?void 0:M.nodeId,K=p&&gn(p.nodesRef.current,B).some(O=>{var F;return ss(k,(F=O.context)==null?void 0:F.elements.floating)});if(ss(k,o.floating)||ss(k,o.domReference)||K)return;const H=p?gn(p.nodesRef.current,B):[];if(H.length>0){let O=!0;if(H.forEach(F=>{var J;if((J=F.context)!=null&&J.open&&!F.context.dataRef.current.__outsidePressBubbles){O=!1;return}}),!O)return}s(!1,k,"outside-press")}),D=jt(k=>{var M;const E=()=>{var P;I(k),(P=Bt(k))==null||P.removeEventListener(u,E)};(M=Bt(k))==null||M.addEventListener(u,E)});g.useEffect(()=>{if(!n||!a)return;i.current.__escapeKeyBubbles=w,i.current.__outsidePressBubbles=S;let k=-1;function M(U){s(!1,U,"ancestor-scroll")}function E(){window.clearTimeout(k),b.current=!0}function P(){k=window.setTimeout(()=>{b.current=!1},Wi()?5:0)}const T=Zt(o.floating);c&&(T.addEventListener("keydown",N?j:A,N),T.addEventListener("compositionstart",E),T.addEventListener("compositionend",P)),y&&T.addEventListener(u,C?D:I,C);let L=[];return V&&(Xe(o.domReference)&&(L=Wn(o.domReference)),Xe(o.floating)&&(L=L.concat(Wn(o.floating))),!Xe(o.reference)&&o.reference&&o.reference.contextElement&&(L=L.concat(Wn(o.reference.contextElement)))),L=L.filter(U=>{var $;return U!==(($=T.defaultView)==null?void 0:$.visualViewport)}),L.forEach(U=>{U.addEventListener("scroll",M,{passive:!0})}),()=>{c&&(T.removeEventListener("keydown",N?j:A,N),T.removeEventListener("compositionstart",E),T.removeEventListener("compositionend",P)),y&&T.removeEventListener(u,C?D:I,C),L.forEach(U=>{U.removeEventListener("scroll",M)}),window.clearTimeout(k)}},[i,o,c,y,u,n,s,V,a,w,S,A,N,j,I,C,D]),g.useEffect(()=>{i.current.insideReactTree=!1},[i,y,u]);const _=g.useMemo(()=>({onKeyDown:A,...f&&{[gf[l]]:k=>{s(!1,k.nativeEvent,"reference-press")},...l!=="click"&&{onClick(k){s(!1,k.nativeEvent,"reference-press")}}}}),[A,s,f,l]),R=g.useMemo(()=>{function k(M){M.button===0&&(x.current=!0)}return{onKeyDown:A,onMouseDown:k,onMouseUp:k,[xf[u]]:()=>{i.current.insideReactTree=!0}}},[A,u,i]);return g.useMemo(()=>a?{reference:_,floating:R}:{},[a,_,R])}function bf(t){const{open:e=!1,onOpenChange:n,elements:s}=t,o=Rs(),i=g.useRef({}),[a]=g.useState(()=>cf()),c=Jo()!=null,[d,u]=g.useState(s.reference),f=jt((m,v,p)=>{i.current.openEvent=m?v:void 0,a.emit("openchange",{open:m,event:v,reason:p,nested:c}),n?.(m,v,p)}),l=g.useMemo(()=>({setPositionReference:u}),[]),V=g.useMemo(()=>({reference:d||s.reference||null,floating:s.floating||null,domReference:s.reference}),[d,s.reference,s.floating]);return g.useMemo(()=>({dataRef:i,open:e,onOpenChange:f,elements:V,events:a,floatingId:o,refs:l}),[e,f,V,a,o,l])}function yf(t){t===void 0&&(t={});const{nodeId:e}=t,n=bf({...t,elements:{reference:null,floating:null,...t.elements}}),s=t.rootContext||n,o=s.elements,[i,a]=g.useState(null),[c,d]=g.useState(null),f=o?.domReference||i,l=g.useRef(null),V=Zo();ft(()=>{f&&(l.current=f)},[f]);const m=Qi({...t,elements:{...o,...c&&{reference:c}}}),v=g.useCallback(w=>{const S=Xe(w)?{getBoundingClientRect:()=>w.getBoundingClientRect(),getClientRects:()=>w.getClientRects(),contextElement:w}:w;d(S),m.refs.setReference(S)},[m.refs]),p=g.useCallback(w=>{(Xe(w)||w===null)&&(l.current=w,a(w)),(Xe(m.refs.reference.current)||m.refs.reference.current===null||w!==null&&!Xe(w))&&m.refs.setReference(w)},[m.refs]),h=g.useMemo(()=>({...m.refs,setReference:p,setPositionReference:v,domReference:l}),[m.refs,p,v]),y=g.useMemo(()=>({...m.elements,domReference:f}),[m.elements,f]),x=g.useMemo(()=>({...m,...s,refs:h,elements:y,nodeId:e}),[m,h,y,e,s]);return ft(()=>{s.dataRef.current.floatingContext=x;const w=V?.nodesRef.current.find(S=>S.id===e);w&&(w.context=x)}),g.useMemo(()=>({...m,context:x,refs:h,elements:y}),[m,h,y,x])}function os(t,e,n){const s=new Map,o=n==="item";let i=t;if(o&&t){const{[cr]:a,[dr]:c,...d}=t;i=d}return{...n==="floating"&&{tabIndex:-1,[sf]:""},...i,...e.map(a=>{const c=a?a[n]:null;return typeof c=="function"?t?c(t):null:c}).concat(t).reduce((a,c)=>(c&&Object.entries(c).forEach(d=>{let[u,f]=d;if(!(o&&[cr,dr].includes(u)))if(u.indexOf("on")===0){if(s.has(u)||s.set(u,[]),typeof f=="function"){var l;(l=s.get(u))==null||l.push(f),a[u]=function(){for(var V,m=arguments.length,v=new Array(m),p=0;p<m;p++)v[p]=arguments[p];return(V=s.get(u))==null?void 0:V.map(h=>h(...v)).find(h=>h!==void 0)}}}else a[u]=f}),a),{})}}function wf(t){t===void 0&&(t=[]);const e=t.map(c=>c?.reference),n=t.map(c=>c?.floating),s=t.map(c=>c?.item),o=g.useCallback(c=>os(c,t,"reference"),e),i=g.useCallback(c=>os(c,t,"floating"),n),a=g.useCallback(c=>os(c,t,"item"),s);return g.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:a}),[o,i,a])}const jf=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Af(t,e){var n,s;e===void 0&&(e={});const{open:o,elements:i,floatingId:a}=t,{enabled:c=!0,role:d="dialog"}=e,u=Rs(),f=((n=i.domReference)==null?void 0:n.id)||u,l=g.useMemo(()=>{var x;return((x=Hu(i.floating))==null?void 0:x.id)||a},[i.floating,a]),V=(s=jf.get(d))!=null?s:d,v=Jo()!=null,p=g.useMemo(()=>V==="tooltip"||d==="label"?{["aria-"+(d==="label"?"labelledby":"describedby")]:o?l:void 0}:{"aria-expanded":o?"true":"false","aria-haspopup":V==="alertdialog"?"dialog":V,"aria-controls":o?l:void 0,...V==="listbox"&&{role:"combobox"},...V==="menu"&&{id:f},...V==="menu"&&v&&{role:"menuitem"},...d==="select"&&{"aria-autocomplete":"none"},...d==="combobox"&&{"aria-autocomplete":"list"}},[V,l,v,o,f,d]),h=g.useMemo(()=>{const x={id:l,...V&&{role:V}};return V==="tooltip"||d==="label"?x:{...x,...V==="menu"&&{"aria-labelledby":f}}},[V,l,f,d]),y=g.useCallback(x=>{let{active:w,selected:S}=x;const N={role:"option",...w&&{id:l+"-fui-option"}};switch(d){case"select":case"combobox":return{...N,"aria-selected":S}}return{}},[l,d]);return g.useMemo(()=>c?{reference:p,floating:h,item:y}:{},[c,p,h,y])}function Cf(t){var e;const{char:n,allowSpaces:s,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:a,$position:c}=t,d=s&&!o,u=ja(n),f=new RegExp(`\\s${u}$`),l=a?"^":"",V=o?"":u,m=d?new RegExp(`${l}${u}.*?(?=\\s${V}|$)`,"gm"):new RegExp(`${l}(?:^)?${u}[^\\s${V}]*`,"gm"),v=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!v)return null;const p=c.pos-v.length,h=Array.from(v.matchAll(m)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const y=h.input.slice(Math.max(0,h.index-1),h.index),x=new RegExp(`^[${i?.join("")}\0]?$`).test(y);if(i!==null&&!x)return null;const w=p+h.index;let S=w+h[0].length;return d&&f.test(v.slice(S-1,S+1))&&(h[0]+=" ",S+=1),w<c.pos&&S>=c.pos?{range:{from:w,to:S},query:h[0].slice(n.length),text:h[0]}:null}var Sf=new bn("suggestion");function Nf({pluginKey:t=Sf,editor:e,char:n="@",allowSpaces:s=!1,allowToIncludeChar:o=!1,allowedPrefixes:i=[" "],startOfLine:a=!1,decorationTag:c="span",decorationClass:d="suggestion",decorationContent:u="",decorationEmptyClass:f="is-empty",command:l=()=>null,items:V=()=>[],render:m=()=>({}),allow:v=()=>!0,findSuggestionMatch:p=Cf,shouldShow:h}){let y;const x=m?.(),w=()=>{const b=e.state.selection.$anchor.pos,A=e.view.coordsAtPos(b),{top:j,right:I,bottom:D,left:_}=A;try{return new DOMRect(_,j,I-_,D-j)}catch{return null}},S=(b,A)=>A?()=>{const j=t.getState(e.state),I=j?.decorationId,D=b.dom.querySelector(`[data-decoration-id="${I}"]`);return D?.getBoundingClientRect()||null}:w;function N(b,A){var j;try{const D=t.getState(b.state),_=D?.decorationId?b.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`):null,R={editor:e,range:D?.range||{from:0,to:0},query:D?.query||null,text:D?.text||null,items:[],command:k=>l({editor:e,range:D?.range||{from:0,to:0},props:k}),decorationNode:_,clientRect:S(b,_)};(j=x?.onExit)==null||j.call(x,R)}catch{}const I=b.state.tr.setMeta(A,{exit:!0});b.dispatch(I)}const C=new Kr({key:t,view(){return{update:async(b,A)=>{var j,I,D,_,R,k,M;const E=(j=this.key)==null?void 0:j.getState(A),P=(I=this.key)==null?void 0:I.getState(b.state),T=E.active&&P.active&&E.range.from!==P.range.from,L=!E.active&&P.active,U=E.active&&!P.active,$=!L&&!U&&E.query!==P.query,B=L||T&&$,K=$||T,H=U||T&&$;if(!B&&!K&&!H)return;const O=H&&!B?E:P,F=b.dom.querySelector(`[data-decoration-id="${O.decorationId}"]`);y={editor:e,range:O.range,query:O.query,text:O.text,items:[],command:J=>l({editor:e,range:O.range,props:J}),decorationNode:F,clientRect:S(b,F)},B&&((D=x?.onBeforeStart)==null||D.call(x,y)),K&&((_=x?.onBeforeUpdate)==null||_.call(x,y)),(K||B)&&(y.items=await V({editor:e,query:O.query})),H&&((R=x?.onExit)==null||R.call(x,y)),K&&((k=x?.onUpdate)==null||k.call(x,y)),B&&((M=x?.onStart)==null||M.call(x,y))},destroy:()=>{var b;y&&((b=x?.onExit)==null||b.call(x,y))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(b,A,j,I){const{isEditable:D}=e,{composing:_}=e.view,{selection:R}=b,{empty:k,from:M}=R,E={...A},P=b.getMeta(t);if(P&&P.exit)return E.active=!1,E.decorationId=null,E.range={from:0,to:0},E.query=null,E.text=null,E;if(E.composing=_,D&&(k||e.view.composing)){(M<A.range.from||M>A.range.to)&&!_&&!A.composing&&(E.active=!1);const T=p({char:n,allowSpaces:s,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:a,$position:R.$from}),L=`id_${Math.floor(Math.random()*4294967295)}`;T&&v({editor:e,state:I,range:T.range,isActive:A.active})&&(!h||h({editor:e,range:T.range,query:T.query,text:T.text,transaction:b}))?(E.active=!0,E.decorationId=A.decorationId?A.decorationId:L,E.range=T.range,E.query=T.query,E.text=T.text):E.active=!1}else E.active=!1;return E.active||(E.decorationId=null,E.range={from:0,to:0},E.query=null,E.text=null),E}},props:{handleKeyDown(b,A){var j,I,D,_;const{active:R,range:k}=C.getState(b.state);if(!R)return!1;if(A.key==="Escape"||A.key==="Esc"){const E=C.getState(b.state),P=(j=y?.decorationNode)!=null?j:null,T=P??(E?.decorationId?b.dom.querySelector(`[data-decoration-id="${E.decorationId}"]`):null);if(((I=x?.onKeyDown)==null?void 0:I.call(x,{view:b,event:A,range:E.range}))||!1)return!0;const U={editor:e,range:E.range,query:E.query,text:E.text,items:[],command:$=>l({editor:e,range:E.range,props:$}),decorationNode:T,clientRect:T?()=>T.getBoundingClientRect()||null:null};return(D=x?.onExit)==null||D.call(x,U),N(b,t),!0}return((_=x?.onKeyDown)==null?void 0:_.call(x,{view:b,event:A,range:k}))||!1},decorations(b){const{active:A,range:j,decorationId:I,query:D}=C.getState(b);if(!A)return null;const _=!D?.length,R=[d];return _&&R.push(f),ya.create(b.doc,[wa.inline(j.from,j.to,{nodeName:c,class:R.join(" "),"data-decoration-id":I,"data-decoration-content":u})])}}});return C}function kf(t){const e=z.c(24),{editor:n,query:s,items:o,onSelect:i,onClose:a}=t,[c,d]=g.useState(0),u=g.useRef(o),f=g.useRef(c),l=g.useRef(i),V=g.useRef(a),m=g.useDeferredValue(s);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{d(0)},e[0]=v):v=e[0];let p;e[1]!==m?(p=[m],e[1]=m,e[2]=p):p=e[2],g.useEffect(v,p);let h,y;e[3]!==o.length||e[4]!==c?(h=()=>{c>=o.length&&o.length>0&&d(0)},y=[o.length,c],e[3]=o.length,e[4]=c,e[5]=h,e[6]=y):(h=e[5],y=e[6]),g.useEffect(h,y);let x,w;e[7]!==o?(x=()=>{u.current=o},w=[o],e[7]=o,e[8]=x,e[9]=w):(x=e[8],w=e[9]),g.useEffect(x,w);let S,N;e[10]!==c?(S=()=>{f.current=c},N=[c],e[10]=c,e[11]=S,e[12]=N):(S=e[11],N=e[12]),g.useEffect(S,N);let C,b;e[13]!==i?(b=()=>{l.current=i},C=[i],e[13]=i,e[14]=C,e[15]=b):(C=e[14],b=e[15]),g.useEffect(b,C);let A,j;e[16]!==a?(A=()=>{V.current=a},j=[a],e[16]=a,e[17]=A,e[18]=j):(A=e[17],j=e[18]),g.useEffect(A,j);let I,D;e[19]!==n?(I=()=>{if(n?.isDestroyed)return;let k;try{k=n.view.dom}catch{return}if(!k)return;const M=P=>{const T=u.current;if(!T.length)return!1;const L=()=>d($=>($+1)%T.length),U=()=>d($=>($-1+T.length)%T.length);switch(P.key){case"ArrowUp":return P.preventDefault(),U(),!0;case"ArrowDown":return P.preventDefault(),L(),!0;case"Tab":return P.preventDefault(),P.shiftKey?U():L(),!0;case"Home":return P.preventDefault(),d(0),!0;case"End":return P.preventDefault(),d(T.length-1),!0;case"Enter":{if(P.isComposing)return!1;P.preventDefault();const $=f.current;return $!==-1&&T[$]&&l.current?.(T[$],$),!0}case"Escape":return P.preventDefault(),V.current?.(),!0;default:return!1}},E=P=>{M(P)};return k.addEventListener("keydown",E,!0),()=>{k?.removeEventListener("keydown",E,!0)}},D=[n],e[19]=n,e[20]=I,e[21]=D):(I=e[20],D=e[21]),g.useEffect(I,D);const _=o.length?c:void 0;let R;return e[22]!==_?(R={selectedIndex:_,setSelectedIndex:d},e[22]=_,e[23]=R):R=e[23],R}function If(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const ti=g.createContext(void 0);function ni(){const t=g.useContext(ti);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function Df({editor:t,char:e,pluginKey:n,allow:s,onOpenChange:o}){const[i,a]=g.useReducer(If,{open:!1,element:null,query:"",range:null,selectedItem:null}),c=g.useRef(o);return c.current=o,g.useEffect(()=>{if(t?.isDestroyed)return;const d=n instanceof bn?n:new bn(n);t.state.plugins.find(l=>l.spec.key===d)&&t.unregisterPlugin(d);const f=Nf({pluginKey:d,editor:t,char:e,allow(l){const V=t.state.doc.resolve(l.range.from);for(let m=V.depth;m>0;m--)if(V.node(m).type.name==="image")return!1;return!(s&&!s(l))},command(){},render:()=>({onStart:l=>{a({type:"ON_START",payload:{element:l.decorationNode??null,query:l.query,range:l.range}}),c.current?.(!0)},onUpdate:l=>{a({type:"ON_UPDATE",payload:{element:l.decorationNode??null,query:l.query,range:l.range}})},onKeyDown:l=>l.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),c.current?.(!1)}}),items:()=>[]});return t.registerPlugin(f),()=>{t?.isDestroyed||t.unregisterPlugin(d)}},[t,n,e,a,s]),{state:i,dispatch:a}}function Rf({editor:t,queryKey:e,queryFn:n,onSelect:s}){const{state:o,dispatch:i}=ni(),a=g.useDeferredValue(o.query),{data:c}=ea({queryKey:Je.suggestionItems(e,o.open,a),queryFn:()=>o.open?n({query:a}):[]}),d=()=>{i({type:"ON_EXIT"})},u=async(l,V)=>{if(!(o.selectedItem!==null||!o.range)){i({type:"SET_SELECTED_ITEM",payload:l});try{const{view:m}=t,p=m.state.selection.$to.nodeAfter?.text?.startsWith(" "),h=o.range?{...o.range}:{from:0,to:0};p&&o.range&&(h.to+=1),await s({range:h,item:l})===!1?i({type:"SET_SELECTED_ITEM",payload:null}):d()}catch{d()}}},{selectedIndex:f}=kf({editor:t,query:a,items:c,onSelect:u,onClose:d});return{selectedItem:o.selectedItem,items:c,selectedIndex:f,close:d,onSelect:u}}function _f({children:t}){const{state:e,dispatch:n}=ni(),{open:s,element:o}=e,i=()=>{n({type:"ON_EXIT"})},{refs:a,floatingStyles:c,context:d}=yf({placement:"bottom-start",open:s,onOpenChange:V=>{V||i()},elements:{reference:o},middleware:[ta(10),na(),sa()],whileElementsMounted:ra}),u=vf(d,{outsidePress:V=>!(V.target instanceof Element&&V.target.closest(".ProseMirror"))}),f=Af(d,{role:"listbox"}),{getFloatingProps:l}=wf([u,f]);return s?r.jsx(pf,{children:r.jsx("div",{ref:a.setFloating,style:c,...l(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const Ef=t=>{const e=z.c(29),{item:n,isSelected:s,onSelect:o,isLoading:i,ref:a}=t;let c;if(e[0]!==n){const C=ct(n._meta);c=n.title||js(n.name,C),e[0]=n,e[1]=c}else c=e[1];const d=c,u=n.description||null,f=n.icon,l=s&&"bg-accent text-accent-foreground",V=i&&"pointer-events-none opacity-50";let m;e[2]!==l||e[3]!==V?(m=Y("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",l,V),e[2]=l,e[3]=V,e[4]=m):m=e[4];let v;e[5]!==f||e[6]!==d?(v=f!==void 0&&r.jsx(to,{icon:f,name:d,size:"xs",className:"mr-2"}),e[5]=f,e[6]=d,e[7]=v):v=e[7];let p;e[8]!==d?(p=r.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:d}),e[8]=d,e[9]=p):p=e[9];let h;e[10]!==i?(h=i&&r.jsx(ds,{size:"xs"}),e[10]=i,e[11]=h):h=e[11];let y;e[12]!==p||e[13]!==h?(y=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p,h]}),e[12]=p,e[13]=h,e[14]=y):y=e[14];let x;e[15]!==u?(x=u&&r.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:u}),e[15]=u,e[16]=x):x=e[16];let w;e[17]!==y||e[18]!==x?(w=r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[y,x]}),e[17]=y,e[18]=x,e[19]=w):w=e[19];let S;e[20]!==n.drillable?(S=n.drillable&&r.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=n.drillable,e[21]=S):S=e[21];let N;return e[22]!==o||e[23]!==a||e[24]!==w||e[25]!==S||e[26]!==m||e[27]!==v?(N=r.jsxs("div",{ref:a,onClick:o,className:m,children:[v,w,S]}),e[22]=o,e[23]=a,e[24]=w,e[25]=S,e[26]=m,e[27]=v,e[28]=N):N=e[28],N},Tf=t=>{const e=z.c(18),{editor:n,queryKey:s,queryFn:o,onSelect:i}=t;let a;e[0]!==n||e[1]!==i||e[2]!==o||e[3]!==s?(a={editor:n,queryKey:s,queryFn:o,onSelect:i},e[0]=n,e[1]=i,e[2]=o,e[3]=s,e[4]=a):a=e[4];const{items:c,selectedIndex:d,onSelect:u,selectedItem:f}=Rf(a);if(!c.length){let v;return e[5]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=v):v=e[5],v}let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=l):l=e[6];let V;if(e[7]!==u||e[8]!==c||e[9]!==d||e[10]!==f?.name){let v;e[12]!==u||e[13]!==d||e[14]!==f?.name?(v=(p,h)=>r.jsx(Ef,{item:p,isSelected:h===d,ref:h===d?Of:void 0,onSelect:()=>u(p,h),isLoading:f?.name===p.name},`${p.kind??"item"}:${p.name}`),e[12]=u,e[13]=d,e[14]=f?.name,e[15]=v):v=e[15],V=c.map(v),e[7]=u,e[8]=c,e[9]=d,e[10]=f?.name,e[11]=V}else V=e[11];let m;return e[16]!==V?(m=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:l,children:r.jsx("div",{className:"p-1",children:V})}),e[16]=V,e[17]=m):m=e[17],m};function Pf(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"p-1",children:[...Array(3)].map(Mf)}),t[0]=e):e=t[0],e}function Mf(t,e){return r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[r.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),r.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function si(t){const e=z.c(18),{editor:n,char:s,pluginKey:o,queryKey:i,queryFn:a,onSelect:c,allow:d,onOpenChange:u}=t;let f;e[0]!==d||e[1]!==s||e[2]!==n||e[3]!==u||e[4]!==o?(f={editor:n,char:s,pluginKey:o,allow:d,onOpenChange:u},e[0]=d,e[1]=s,e[2]=n,e[3]=u,e[4]=o,e[5]=f):f=e[5];const{state:l,dispatch:V}=Df(f);let m;e[6]!==V||e[7]!==l?(m={state:l,dispatch:V},e[6]=V,e[7]=l,e[8]=m):m=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Pf,{}),e[9]=v):v=e[9];let p;e[10]!==n||e[11]!==c||e[12]!==a||e[13]!==i?(p=r.jsx(_f,{children:r.jsx(g.Suspense,{fallback:v,children:r.jsx(Tf,{editor:n,queryKey:i,queryFn:a,onSelect:c})})}),e[10]=n,e[11]=c,e[12]=a,e[13]=i,e[14]=p):p=e[14];let h;return e[15]!==m||e[16]!==p?(h=r.jsx(ti.Provider,{value:m,children:p}),e[15]=m,e[16]=p,e[17]=h):h=e[17],h}function Of(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const Lf=[{name:"agents",title:"Agents",description:"Mention an agent to hand off work",kind:"category",drillable:!0},{name:"resources",title:"Resources",description:"Attach a resource as context",kind:"category",drillable:!0}],Ff=({editor:t,virtualMcpId:e})=>{const n=kt(),{org:s}=Ce(),o=Qa(),i=fl(o),a=gt({connectionId:e,orgId:s.id,orgSlug:s.slug}),c=Je.virtualMcpResources(e,s.id),[d,u]=g.useState("categories"),f=g.useRef(d);f.current=d;const l=g.useRef(null),V=g.useRef(!1),m=["at-mention",s.id,e??"default",d],v=async({item:y,range:x})=>{if(X("chat_picker_item_selected",{picker:"@",item_kind:y.kind,item_name:y.name}),y.kind!=="category"&&(V.current=!0),y.kind==="category")return u(y.name==="agents"?"agents":"resources"),!1;if(y.kind==="agent"&&y.agentId){Nt(t,x,{id:y.agentId,name:y.name,metadata:{agentId:y.agentId,title:y.name},char:"@"}),u("categories");return}if(y.kind==="resource"&&y.uri&&a){try{const w=await Or(a,y.uri);Nt(t,x,{id:y.uri,name:y.uri,metadata:w.contents,char:"@"})}catch(w){console.error("[at-mention] Failed to fetch resource:",w),ue.error("Failed to load resource. Please try again.")}u("categories");return}},p=async y=>{const{query:x}=y,w=f.current;if(w==="categories"){if(!x.trim())return Lf;const C=x.toLowerCase(),b=o.filter(j=>j.status==="active"&&(!j.id||!$s(j.id))&&!i.has(j.id)&&j.id!==e&&(j.title.toLowerCase().includes(C)||j.description?.toLowerCase().includes(C))).map(j=>({name:j.title,title:j.title,description:j.description??void 0,icon:j.icon??null,kind:"agent",agentId:j.id})),A=await(async()=>{if(!a)return[];let j=n.getQueryData(c);return j||(j=await n.fetchQuery({queryKey:c,queryFn:()=>qt(a),staleTime:6e4})),(j?.resources??[]).filter(I=>I.uri.toLowerCase().includes(C)||I.name?.toLowerCase().includes(C)||I.description?.toLowerCase().includes(C)).map(I=>({name:I.name??I.uri,title:I.name,description:I.description,kind:"resource",uri:I.uri}))})();return[...b,...A]}if(w==="agents"){let C=o.filter(b=>b.status==="active"&&(!b.id||!$s(b.id))&&!i.has(b.id)&&b.id!==e);if(x.trim()){const b=x.toLowerCase();C=C.filter(A=>A.title.toLowerCase().includes(b)||A.description?.toLowerCase().includes(b))}return C.map(b=>({name:b.title,title:b.title,description:b.description??void 0,icon:b.icon??null,kind:"agent",agentId:b.id}))}if(!a)return[];let S=n.getQueryData(c);S?n.fetchQuery({queryKey:c,queryFn:()=>qt(a),staleTime:6e4}).catch(()=>{}):S=await n.fetchQuery({queryKey:c,queryFn:()=>qt(a),staleTime:6e4});let N=S?.resources??[];if(x.trim()){const C=x.toLowerCase();N=N.filter(b=>b.uri.toLowerCase().includes(C)||b.name?.toLowerCase().includes(C)||b.description?.toLowerCase().includes(C))}return N.map(C=>({name:C.name??C.uri,title:C.name,description:C.description,kind:"resource",uri:C.uri}))},h=y=>{if(y)l.current=Date.now(),V.current=!1,X("chat_picker_opened",{picker:"@"});else{const x=l.current;X("chat_picker_closed",{picker:"@",outcome:V.current?"selected":"dismissed",duration_ms:x?Date.now()-x:null}),l.current=null,u("categories")}};return r.jsx(si,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:m,queryFn:p,onSelect:v,onOpenChange:h})};async function hr(t,e,n,s,o,i){try{const a=await On(n,s,i);Nt(t,e,{id:s,name:Tn(s,o),metadata:a.messages,char:"/",kind:"prompt",args:i})}catch(a){console.error("[slash] Failed to fetch prompt:",a),ue.error("Failed to load prompt. Please try again.")}}async function $f(t,e,n,s){try{const o=await Or(n,s);Nt(t,e,{id:s,name:s,metadata:o.contents,char:"/",kind:"resource"})}catch(o){console.error("[slash] Failed to fetch resource:",o),ue.error("Failed to load resource. Please try again.")}}async function zf(t,e,n,s){try{const{files:o,omittedPaths:i}=await Al(n,s.volume,s.path),a={sandboxPath:s.sandboxPath,files:o,omittedPaths:i};Nt(t,e,{id:s.id,name:s.name,metadata:a,char:"/",kind:"skill"})}catch(o){console.error("[slash] Failed to fetch skill:",o),ue.error("Failed to load skill. Please try again.")}}const Bf=({editor:t,virtualMcpId:e})=>{const n=kt(),{org:s}=Ce(),o=gt({connectionId:e,orgId:s.id,orgSlug:s.slug}),i=Je.virtualMcpPrompts(e,s.id),a=Je.virtualMcpResources(e,s.id),c=Je.slashSkills(s.id),d=["slash-mention",s.id,e??"default"],[u,f]=g.useState(null),[l,V]=g.useState(null),m=Aa(t);m&&(m.onEditChip=async N=>{if(o)try{const b=(await gr(n,i,o)).find(A=>A.name===N.promptId);if(!b?.arguments||b.arguments.length===0)return;V({...N,prompt:b})}catch(C){console.error("[slash] Failed to load prompt for editing:",C),ue.error("Failed to load prompt. Please try again.")}});const v=g.useRef(null),p=g.useRef(!1),h=async({item:N,range:C})=>{if(X("chat_picker_item_selected",{picker:"/",item_kind:N.kind,item_name:N.name}),p.current=!0,!!o)if(N.kind==="prompt"){if(N.arguments&&N.arguments.length>0){f({range:C,item:N});return}const b=ct(N._meta);await hr(t,C,o,N.name,b)}else N.kind==="skill"?N.skill&&await zf(t,C,s.slug,N.skill):N.uri&&await $f(t,C,o,N.uri)},y=async N=>{if(!u||!o)return;const{range:C,item:b}=u,A=ct(b._meta);await hr(t,C,o,b.name,A,N),f(null)},x=async N=>{if(!(!l||!o)){try{const C=await On(o,l.promptId,N),b=ct(l.prompt._meta);t.chain().focus().setNodeSelection(l.pos).deleteSelection().insertContentAt(l.pos,Ur({id:l.promptId,name:Tn(l.promptId,b),metadata:C.messages,char:"/",kind:"prompt",args:N})).run(),X("chat_picker_item_selected",{picker:"/edit",item_kind:"prompt",item_name:l.promptId})}catch(C){console.error("[slash] Failed to update prompt:",C),ue.error("Failed to update prompt. Please try again.")}V(null)}},w=async N=>{const{query:C}=N;if(!o)return[];const[b,A,j]=await Promise.all([gr(n,i,o),Kf(n,a,o),Uf(n,c,s.slug)]),I=C.trim().toLowerCase(),D=(b??[]).filter(k=>!I||k.name.toLowerCase().includes(I)||k.title?.toLowerCase().includes(I)||k.description?.toLowerCase().includes(I)).map(k=>({name:k.name,title:k.title,description:k.description,kind:"prompt",arguments:k.arguments,_meta:k._meta})),_=(A??[]).filter(k=>!I||k.uri.toLowerCase().includes(I)||k.name?.toLowerCase().includes(I)||k.description?.toLowerCase().includes(I)).map(k=>({name:k.name??k.uri,title:k.name,description:k.description,kind:"resource",uri:k.uri})),R=(j??[]).filter(k=>!I||k.name.toLowerCase().includes(I)||k.id.toLowerCase().includes(I)||k.description?.toLowerCase().includes(I)).map(k=>({name:k.name,title:k.name,description:k.description??void 0,kind:"skill",skill:k}));return[...D,..._,...R]},S=u?.item.kind==="prompt"?{name:u.item.name,title:u.item.title,arguments:u.item.arguments,description:u.item.description,_meta:u.item._meta}:null;return r.jsxs(r.Fragment,{children:[r.jsx(si,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:d,queryFn:w,onSelect:h,onOpenChange:N=>{if(N)v.current=Date.now(),p.current=!1,X("chat_picker_opened",{picker:"/"});else{const C=v.current;X("chat_picker_closed",{picker:"/",outcome:p.current?"selected":"dismissed",duration_ms:C?Date.now()-C:null}),v.current=null}}}),r.jsx(vn,{prompt:S,setPrompt:()=>f(null),onSubmit:y}),r.jsx(vn,{prompt:l?.prompt??null,setPrompt:()=>V(null),onSubmit:x,defaultValues:l?.args},l?`edit-${l.promptId}-${l.pos}`:"edit-idle")]})};async function gr(t,e,n){let s=t.getQueryData(e);return s?t.fetchQuery({queryKey:e,queryFn:()=>fs(n),staleTime:6e4}).catch(()=>{}):s=await t.fetchQuery({queryKey:e,queryFn:()=>fs(n),staleTime:6e4}),s?.prompts??[]}async function Uf(t,e,n){const s=t.getQueryData(e),o=()=>t.fetchQuery({queryKey:e,queryFn:()=>Cl(n),staleTime:6e4});return s?(o().catch(()=>{}),s):o().catch(()=>[])}async function Kf(t,e,n){let s=t.getQueryData(e);return s?t.fetchQuery({queryKey:e,queryFn:()=>qt(n),staleTime:6e4}).catch(()=>{}):s=await t.fetchQuery({queryKey:e,queryFn:()=>qt(n),staleTime:6e4}),s?.resources??[]}function qf(t){return[Ia.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),Nu.configure({placeholder:()=>t.current??"Ask anything, / for prompts & skills, @ for agents & resources...",showOnlyWhenEditable:!1}),Na,ka]}function Yf({tiptapDoc:t,setTiptapDoc:e,disabled:n=!1,enterToSubmit:s=!1,placeholder:o,onSubmit:i,children:a}){const c=g.useRef(i),d=g.useRef(e),u=g.useRef(s),f=g.useRef(o),l=Ca({extensions:qf(f),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(V,m)=>m.key==="Enter"&&!m.shiftKey&&u.current?(m.preventDefault(),c.current?.(),!0):!1},onUpdate:({editor:V})=>{d.current(V?.getJSON())}});return g.useEffect(()=>{l?.setEditable(!n)},[l,n]),g.useEffect(()=>{c.current=i},[i]),g.useEffect(()=>{d.current=e},[e]),g.useEffect(()=>{u.current=s},[s]),g.useEffect(()=>{f.current=o},[o]),g.useEffect(()=>{if(!l||l.isDestroyed)return;const V=JSON.stringify(l.getJSON()),m=JSON.stringify(t||{type:"doc",content:[]});V!==m&&l.commands.setContent(t||{type:"doc",content:[]})},[l,t]),r.jsx(Sa.Provider,{value:{editor:l},children:a})}function Hf(t){const e=z.c(26),{disabled:n,virtualMcpId:s,showFileUploader:o,selectedModel:i,onUnsupportedFile:a,ref:c,className:d}=t,u=n===void 0?!1:n,f=o===void 0?!1:o,{editor:l}=As();let V,m;if(e[0]!==l?(V=()=>({focus:()=>{l?.commands.focus()},clear:()=>{l?.commands.clearContent(!0)},appendText:A=>{if(!l)return;const j=l.state.doc.textContent.trim()==="";l.commands.focus("end"),j||l.commands.insertContent(" "),l.commands.insertContent(A)},syncVoiceText:(A,j)=>{if(l&&(l.commands.setContent(A||{type:"doc",content:[]}),j)){l.commands.focus("end");const I=l.state.doc.textContent.trim().length>0;l.commands.insertContent(I?" "+j:j)}},restoreContent:A=>{l&&l.commands.setContent(A||{type:"doc",content:[]})}}),m=[l],e[0]=l,e[1]=V,e[2]=m):(V=e[1],m=e[2]),g.useImperativeHandle(c??null,V,m),!l)return null;const v=u&&"cursor-not-allowed opacity-70",p=u&&"[&_.ProseMirror]:cursor-not-allowed";let h;e[3]!==d||e[4]!==v||e[5]!==p?(h=Y("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",d,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",v,p),e[3]=d,e[4]=v,e[5]=p,e[6]=h):h=e[6];let y;e[7]!==l||e[8]!==h?(y=r.jsx(Da,{editor:l,className:h}),e[7]=l,e[8]=h,e[9]=y):y=e[9];const x=s??null;let w;e[10]!==l||e[11]!==x?(w=r.jsx(g.Suspense,{fallback:null,children:r.jsx(Bf,{editor:l,virtualMcpId:x})}),e[10]=l,e[11]=x,e[12]=w):w=e[12];const S=s??null;let N;e[13]!==l||e[14]!==S?(N=r.jsx(g.Suspense,{fallback:null,children:r.jsx(Ff,{editor:l,virtualMcpId:S})}),e[13]=l,e[14]=S,e[15]=N):N=e[15];let C;e[16]!==l||e[17]!==a||e[18]!==i||e[19]!==f?(C=f&&i?r.jsx(yu,{editor:l,selectedModel:i,onUnsupportedFile:a}):null,e[16]=l,e[17]=a,e[18]=i,e[19]=f,e[20]=C):C=e[20];let b;return e[21]!==w||e[22]!==N||e[23]!==C||e[24]!==y?(b=r.jsxs(r.Fragment,{children:[y,w,N,C]}),e[21]=w,e[22]=N,e[23]=C,e[24]=y,e[25]=b):b=e[25],b}function ri(t){const e=z.c(3),[n]=It();let s;return e[0]!==n.enableSounds||e[1]!==t?(s=()=>{n.enableSounds&&Pl(t.dataUri).catch(i=>{console.warn(`[sound] ${t.name} playback failed:`,i)})},e[0]=n.enableSounds,e[1]=t,e[2]=s):s=e[2],s}const Qf={name:"switch-005",dataUri:"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0VAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABkAABU4ABMTEx0dHR0nJycnMTExMTs7OztERERETk5OTlhYWFhiYmJibGxsbHZ2dnZ/f39/iYmJiZOTk5OdnZ2dp6enp7GxsbG7u7u7xMTExM7Ozs7Y2NjY4uLi4uzs7Oz29vb2/////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBVYAAAAAAAAVOPCP8KUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAACEwDXvQRAAG8Ii93HtACUCAABAKCJwfaCEHwfeoEAQdEAYygIHBOCAIAgCAJh9QIOg+D5/ygPh/wfB8DuKAgCHyn9QPh/5SCDv+CEHAQdxOD4B27c39tbckkqYbBAYAN9bNJLB+aXAf5wQAKdzxfbmrVIRQ4xNx3HwnoDmLhfMhgJiiw/HREXNCHqjvHEPEG8QjBYlxQNepJAT0kC8ip6JzSWj1TasoG+iyycbf2Uil1ovf1f/oUtR1qP+s1WSBFKoAAU02BDjMhuP/7UsQEgws8bRpd8YABJYPeBf9wCGXTGxBYcw5AJFMFMAmQQAhGAxgLBgHIAMYAAALhgAchipbe/91aU1VV4zcZj1Vf1XgYCIMBNrsBAIGs9/Ue4i/xFPeqCqwViI9/UeLf///rOngdA3OPHFjmOBv+EQnGahgaZxVplmkAH5JadDTQlNCEuGNiWYbCCONWdUJg6HXNazFdu1T+VgaEpOP70exv7f2/4b/yH//2/4cqCX/zWRUrIw+IPNMNlDnjAXQas/I4AzmYifA0tMSCgQDF//tSxBCDSzzi3k/sQwEyCtjJ/rBZAk+Uqj1YhA5YMCAAMwgOUchTkK7OR7LbMl0W1H6SvzG0Q2ZzfKUhnmTobv9DNhS1v7P8h//8Gv8gTRt1jReZ7YEjmMQg9hhwwMycHooasFmZyjcZGBKJD+IwbMCQQLoi+IQXCcIoydKoilI2MWFS5uJdDEu2taRrYI2ZSqKY50pJLv2NfjUAAuQAMfqVQ/T3PDQgMJMeEZ45hJzY6MNoFMxqTj1zNGQKJjAxEsSCBgQJBSIL0mcKYQJfVAn/+1LEGwLKlEKrD3MiYcuMkVa/wABB8Vh6M1q1epbvXwWBURhkyEhWZ/////////////9gjZ/Wt4w+4MNMCpE4TBYQl4w1IHvMDdA2zBngBMwc8COMDhCpDAfgOAAgrBgNYU+YC0FBGAkAMpgWoSCYAGESGBGAKBgXgJOdiOJmMCmNwCYNDJhYRPykRCJhTBnEUzlsjv4UNLj/z97n3Mv/7z1nZqyitYAZIqErIwMwJAqEw0GAAMFptJMaqFwB8CQIWlhuhuDAwNjfuwrQFAYXCf/7UsQVAA+9PTP42gYRdiIu9zBwAPbFUCi0DAhgNcS+7cDwVgM05A9bUDeuQMyE/u3CygVISgZhpIau/9PhdQG2C9DpxZZJmn/dn/Psmt0EFm////l84ThUTopE4VD/9JkubOGasTvN30C20G21qgUCkVCoUCgPMywrPCGly27V5q5t24vl/8jSlSAPCxzNseNCw3oh3NGBu4BZJ5hv7DRSfR/+eWG7nA8IKh2Olv5iz3q5m3//Joxo3JqNyYkSuGt/k6D4DeoBOHmHdl0dkZYA//tSxAUAC4B1Z/2DADEcA17Z/uhI4Yoik/TrZo+ww7UtmpW4LDWu2IacoJKJJeTSM+ZmAYBEiU+ZnnAwCn1VVVV6JUJQVnioKhrgqdKgqGpUFeCp0sDR3ztQNREDRUFioKuxKCpYGQBlRIBk+aLwb8KblGQVDdphPYTUdBOGbVpAaTF6ZdjEV0iRUZRCYkA4oUQDx5zqDugtXvza/7fuNNvfZ+j9v+T/2f//J/4cAAOTpE5K4zksR9MfIB+TDcQTI4gNs1XKAzEFUrGkxABYEBb/+1LEEYNKrEjgT/TCwYYVmUX+mHoKgWhKU5Eiw9SFIRmppw+3fYo4siPhUFeexM8KgIO6wVuPDDy01qeRaVbw357//y3+o8M0pBNlNLCGBzGKwyYw2IIFOE1WNTjRM6x8MlA1AxDhUHTAkEiyKpnbWrLcaOBotBUKbk1pypcWDAIK00AhKLGkUco6q9VWvM53mcaq3tVa8zjTM/tX//EDP//////////XAAmrwAAPoKwcw0ShDCZD/BQlhzinxQdorsOuXTEIC01ZkJyu4k/qPP/7UsQUAEjkrrkvZaPBIRXUoe5QObfMhYKX9RVgTPqCSCaSCaSC0XVdV1f/////6IAlguuAJSiDRNloNBsZg+0+Ts8MMCn81WUTRAlIi+GHECD0y8AWDIqswYsxGOSKVV7MqOni8tkVOip0fZX/////9HrMCbAz2EHGS4GKAAiRAAAYAcDdKd4G6Z/nwYgJ0ZAIgZyC8aPAs/iPBhwMpWDQNARltNS5Y61v//9i8Yl4SkFkIGTkAc0UBrIYLPA4MYBEy+YLMRuY4nhTC3hZA68H//tSxCoAyQC6mY6CkWDJBIsBz/QUrgNmahSzcrYw0/HhfnMAZBojDsgTFkDR5MDkG/DZEbk2FCmowqdqv2TYABiJwqqYjaQRGZ1URZ1DhSsdiHX/GBu0QpzIBNSaLqZ0ARkwFARxMrpt/Eh47mbQAhhU6sisFUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LESoHHJCRaj/dmYAIAQAAQAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsSLg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsShg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",duration:.609,format:"mp3",license:"CC0",author:"Kenney"},Wf=Ya.togglePlanMode.keys.map(t=>t==="Shift"?"⇧":t).join(""),Gf=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function Xf(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1.5",children:Gf.map(Jf)}),t[0]=e):e=t[0],e}function Jf(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function Zf({disabled:t,onOpenConnections:e,virtualMcpId:n,selectedModel:s,isStreaming:o,onUnsupportedFile:i}){const[a,c]=g.useState(!1),d=ri(Qf),{org:u}=Ce(),{editor:f}=As(),l=g.useRef(null),V=$n(s),m=()=>{!V||o||(c(!1),l.current?.click())},v=async O=>{const F=O.target.files;if(!F||F.length===0||!f)return;const J=Array.from(F),{from:Q}=f.state.selection;try{for(const Z of J)await Ds(f,s??null,Z,Q,i)}finally{l.current&&(l.current.value="")}},p=gt({connectionId:n,orgId:u.id,orgSlug:u.slug}),h=Je.virtualMcpPrompts(n,u.id),{data:y,isLoading:x}=oa({queryKey:h,queryFn:()=>fs(p),staleTime:6e4,enabled:a&&!!p}),w=y?.prompts??[],[S,N]=g.useState(null),{chatMode:C,setChatMode:b}=ut(),[A,j]=It(),D=(Ut.find(O=>O.value===A.toolApprovalLevel)??Ut[0]).short,_=O=>{const F=Ut.find(J=>J.value===O);if(F){if(F.value===A.toolApprovalLevel){c(!1);return}d(),X("chat_approval_level_changed",{from_level:A.toolApprovalLevel,to_level:F.value,source:"tools_popover"}),j({...A,toolApprovalLevel:F.value}),c(!1)}},R=C==="plan",k=()=>{d();const O=R?"default":"plan";X("chat_mode_changed",{from_mode:C,to_mode:O,source:"tools_popover"}),b(O),c(!1)},M=()=>{e(),c(!1)},E=async(O,F)=>{if(!f||!p)return;const J=ct(O._meta),Q={from:f.state.selection.from,to:f.state.selection.to};try{const Z=await On(p,O.name,F);Nt(f,Q,{id:O.name,name:Tn(O.name,J),metadata:Z.messages,char:"/",kind:"prompt",args:F})}catch{ue.error("Failed to load prompt. Please try again.")}},P=async O=>{c(!1);const F=!!(O.arguments&&O.arguments.length>0);if(X("chat_prompt_inserted",{prompt_name:O.name,with_arguments:F}),F){N(O);return}await E(O)},T=async O=>{S&&(await E(S,O),N(null))},L=()=>{d();const O=C==="gen-image"?"default":"gen-image";X("chat_mode_changed",{from_mode:C,to_mode:O,source:"tools_popover"}),b(O),c(!1)},U=()=>{d();const O=C==="web-search"?"default":"web-search";X("chat_mode_changed",{from_mode:C,to_mode:O,source:"tools_popover"}),b(O),c(!1)},$=()=>{d();const O=C==="deep-research"?"default":"deep-research";X("chat_mode_changed",{from_mode:C,to_mode:O,source:"tools_popover"}),b(O),c(!1)},B=C==="gen-image",K=C==="web-search",H=C==="deep-research";return r.jsxs(r.Fragment,{children:[r.jsx("input",{ref:l,type:"file",multiple:!0,accept:pl(s??null),className:"hidden",onChange:v,disabled:o}),r.jsxs(Dl,{open:a,onOpenChange:O=>{O&&!a&&X("chat_tools_popover_opened",{chat_mode:C}),c(O)},children:[r.jsx(Rl,{asChild:!0,children:r.jsxs(ie,{type:"button",variant:"ghost",size:"default",disabled:t,title:"Tools","aria-label":"Tools",className:Y("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),children:[r.jsx(tl,{size:14}),r.jsx("span",{className:Y("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),children:"Tools"})]})}),r.jsxs(_l,{align:"start",className:"w-52 p-1.5 space-y-1",children:[V?r.jsxs(at,{onClick:m,disabled:o,children:[r.jsx(ms,{size:16}),r.jsx("span",{className:"flex-1",children:"Add file"})]}):r.jsxs(qe,{children:[r.jsx(Ue,{asChild:!0,children:r.jsxs(at,{"aria-disabled":"true",className:"opacity-50 cursor-not-allowed",onSelect:O=>O.preventDefault(),children:[r.jsx(ms,{size:16}),r.jsx("span",{className:"flex-1",children:"Add file"})]})}),r.jsx(Ke,{side:"right",children:"The selected model does not support reading files or images."})]}),r.jsxs(at,{onClick:k,className:Y(R&&"text-violet-600 dark:text-violet-400"),children:[r.jsx(Jr,{size:16,className:Y(R&&"text-violet-500")}),r.jsx("span",{className:"flex-1",children:"Plan mode"}),r.jsx("span",{className:Y("text-xs text-muted-foreground",R&&"text-violet-500 font-medium"),children:Wf})]}),r.jsxs(at,{onClick:L,className:Y(B&&"text-pink-600 dark:text-pink-400"),children:[r.jsx(Zr,{size:16,className:Y(B&&"text-pink-500")}),r.jsx("span",{className:"flex-1",children:"Create image"}),B&&r.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),r.jsxs(at,{onClick:U,className:Y(K&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(Ht,{size:16,className:Y(K&&"text-blue-500")}),r.jsx("span",{className:"flex-1",children:"Web search"}),K&&r.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),r.jsxs(at,{onClick:$,className:Y(H&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(no,{size:16,className:Y(H&&"text-blue-500")}),r.jsx("span",{className:"flex-1",children:"Deep research"}),H&&r.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),r.jsxs(Us,{children:[r.jsxs(Ks,{className:"gap-2",children:[r.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),r.jsx("span",{className:"flex-1",children:"Prompts"})]}),r.jsx(qs,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:x?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Yt,{size:14,className:"animate-spin"}),"Loading prompts…"]}):w.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):w.map(O=>r.jsxs(at,{onClick:()=>P(O),className:"flex flex-col items-start gap-0.5",children:[r.jsx("span",{className:"font-medium text-sm capitalize",children:O.title||js(O.name,ct(O._meta))}),O.description&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:O.description})]},O.name))})]}),r.jsxs(Us,{children:[r.jsxs(Ks,{className:"gap-2",children:[r.jsx(Fn,{size:16}),r.jsx("span",{className:"flex-1",children:"Approval"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:D})]}),r.jsx(qs,{className:"w-48 p-1.5",children:r.jsx(El,{value:A.toolApprovalLevel,onValueChange:_,children:Ut.map(O=>r.jsx(Tl,{value:O.value,children:O.label},O.value))})})]}),r.jsxs(at,{onClick:M,children:[r.jsx(ll,{size:16}),r.jsx("span",{className:"flex-1",children:"Connections"}),r.jsx(g.Suspense,{children:r.jsx(Xf,{})})]})]})]}),r.jsx(vn,{prompt:S,setPrompt:N,onSubmit:T})]})}function eV({open:t,onOpenChange:e,onCreated:n}){const{org:s}=Ce(),{data:o}=_n.useSession(),{stdioEnabled:i}=ia(),a=Gr(),c=yo(),d=vo(),f=bo(d,"").items,l=Er({resolver:Tr(ql),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),V=l.watch("ui_type"),m=l.watch("connection_url"),v=l.watch("npx_package"),p=ln({uiType:V,connectionUrl:m??"",npxPackage:v??""})??Ys({uiType:V,connectionUrl:m??"",registryItems:f}),h=b=>{const A=b.trim();if(!A)return;const j=!!l.formState.dirtyFields.title,I=!!l.formState.dirtyFields.description,D=!!l.formState.dirtyFields.env_vars,_=k=>{if(k&&(!j&&!l.getValues("title").trim()&&k.title&&l.setValue("title",k.title,{shouldDirty:!1}),!I&&!(l.getValues("description")??"").trim()&&k.description&&l.setValue("description",k.description,{shouldDirty:!1}),!D&&k.envVarKeys?.length)){const M=l.getValues("env_vars")??[],E=new Set(M.map(T=>T.key)),P=k.envVarKeys.filter(T=>!E.has(T));P.length>0&&l.setValue("env_vars",[...M,...P.map(T=>({key:T,value:""}))],{shouldDirty:!0})}},R=Hl(A);if(R&&i){l.setValue("ui_type","NPX",{shouldDirty:!0}),l.setValue("npx_package",R.packageName,{shouldDirty:!0}),l.setValue("connection_url","",{shouldDirty:!0}),l.setValue("connection_token",null,{shouldDirty:!0}),_(ln({uiType:"NPX",npxPackage:R.packageName}));return}if(A.startsWith("http://")||A.startsWith("https://")){const k=V==="HTTP"||V==="SSE"||V==="Websocket"?V:"HTTP";l.setValue("ui_type",k,{shouldDirty:!0}),l.setValue("connection_url",A,{shouldDirty:!0}),_(ln({uiType:k,connectionUrl:A})??Ys({uiType:k,connectionUrl:A,registryItems:f}));return}V==="NPX"&&_(ln({uiType:"NPX",npxPackage:A}))},y=b=>{b||l.reset(),e(b)},x=async b=>{let A,j=null,I=null,D=null;b.ui_type==="NPX"?(A="STDIO",j="",D=Ql(b.npx_package||"",b.env_vars||[])):b.ui_type==="STDIO"?(A="STDIO",j="",D=Wl(b.stdio_command||"",b.stdio_args||"",b.stdio_cwd,b.env_vars||[])):(A=b.ui_type,j=b.connection_url||"",I=b.connection_token||null);const _=$l("conn");try{await c.create.mutateAsync({id:_,title:b.title,description:b.description||null,connection_type:A,connection_url:j,connection_token:I,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:o?.user?.id||"system",organization_id:s.id,icon:b.icon??null,app_name:null,app_id:null,connection_headers:D,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),l.reset(),e(!1),n?.(_)}catch{ue.error("Failed to create connection")}},w="Create Connection",S="Create a custom connection in your organization. Fill in the details below.",N=l.formState.isSubmitting?"Saving...":"Create Connection",C=r.jsxs("div",{className:"grid gap-4",children:[r.jsx($e,{control:l.control,name:"ui_type",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:"Type *"}),r.jsxs(io,{value:b.value,onValueChange:b.onChange,children:[r.jsx(Te,{children:r.jsx(ao,{children:r.jsx(lo,{})})}),r.jsxs(oo,{children:[r.jsx(wt,{value:"HTTP",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ht,{className:"w-4 h-4"}),"HTTP"]})}),r.jsx(wt,{value:"SSE",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ht,{className:"w-4 h-4"}),"SSE"]})}),r.jsx(wt,{value:"Websocket",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ht,{className:"w-4 h-4"}),"Websocket"]})}),i&&r.jsxs(r.Fragment,{children:[r.jsx(wt,{value:"NPX",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(pn,{className:"w-4 h-4"}),"NPX Package"]})}),r.jsx(wt,{value:"STDIO",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(nl,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),r.jsx(Pe,{})]})}),V==="NPX"&&r.jsx($e,{control:l.control,name:"npx_package",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:"NPM Package *"}),r.jsx(Te,{children:r.jsx(tt,{placeholder:"@perplexity-ai/mcp-server",...b,value:b.value??"",onPaste:A=>{const j=A.clipboardData.getData("text");j&&(A.preventDefault(),l.setValue("npx_package",j.trim(),{shouldDirty:!0}),h(j))},onBlur:A=>{h(A.target.value),b.onBlur()}})}),r.jsx(Pe,{})]})}),V==="STDIO"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[r.jsx($e,{control:l.control,name:"stdio_command",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:"Command *"}),r.jsx(Te,{children:r.jsx(tt,{placeholder:"node, bun, python...",...b,value:b.value??""})}),r.jsx(Pe,{})]})}),r.jsx($e,{control:l.control,name:"stdio_args",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:"Arguments"}),r.jsx(Te,{children:r.jsx(tt,{placeholder:"arg1 arg2 --flag value",...b,value:b.value??""})}),r.jsx(Pe,{})]})})]}),r.jsx($e,{control:l.control,name:"stdio_cwd",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:"Working Directory"}),r.jsx(Te,{children:r.jsx(tt,{placeholder:"/path/to/project (optional)",...b,value:b.value??""})}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),r.jsx(Pe,{})]})})]}),(V==="NPX"||V==="STDIO")&&r.jsx($e,{control:l.control,name:"env_vars",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:"Environment Variables"}),r.jsx(Te,{children:r.jsx(Yl,{value:b.value??[],onChange:b.onChange})}),r.jsx(Pe,{})]})}),V!=="NPX"&&V!=="STDIO"&&r.jsxs(r.Fragment,{children:[r.jsx($e,{control:l.control,name:"connection_url",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:"URL *"}),r.jsx(Te,{children:r.jsx(tt,{placeholder:"https://example.com/mcp",...b,value:b.value??"",onPaste:A=>{const j=A.clipboardData.getData("text");j&&(A.preventDefault(),l.setValue("connection_url",j.trim(),{shouldDirty:!0}),h(j))},onBlur:A=>{h(A.target.value),b.onBlur()}})}),r.jsx(Pe,{})]})}),r.jsx($e,{control:l.control,name:"connection_token",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:p?.token?.label??"Token (optional)"}),r.jsx(Te,{children:r.jsx(tt,{type:"password",placeholder:p?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...b,value:b.value??""})}),p?.token?.helperText&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:[p.token.helperText,p.id==="github"&&r.jsxs(r.Fragment,{children:[" ","·"," ",r.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),r.jsx(Pe,{})]})})]}),r.jsx($e,{control:l.control,name:"title",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:"Name *"}),r.jsx(Te,{children:r.jsx(tt,{placeholder:"My Connection",...b})}),r.jsx(Pe,{})]})}),r.jsx($e,{control:l.control,name:"description",render:({field:b})=>r.jsxs(Ee,{children:[r.jsx(Ge,{children:"Description"}),r.jsx(Te,{children:r.jsx(Kl,{placeholder:"A brief description of this connection",rows:3,...b,value:b.value??""})}),r.jsx(Pe,{})]})})]});return a?r.jsx(Qr,{open:t,onOpenChange:y,children:r.jsxs(Hr,{className:"max-h-[90vh]",children:[r.jsx(qr,{className:"pb-2",children:r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex-1 text-left",children:[r.jsx(Yr,{children:w}),r.jsx(Oa,{className:"mt-1",children:S})]}),r.jsx(La,{asChild:!0,children:r.jsx(ie,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:r.jsx(go,{size:16})})})]})}),r.jsx(Xt,{...l,children:r.jsxs("form",{onSubmit:l.handleSubmit(x),children:[r.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:C}),r.jsx(Fa,{children:r.jsx(ie,{type:"submit",disabled:l.formState.isSubmitting,className:"w-full",children:N})})]})})]})}):r.jsx(Tt,{open:t,onOpenChange:y,children:r.jsxs(Et,{className:"sm:max-w-[525px]",children:[r.jsxs(Rt,{children:[r.jsx(_t,{children:w}),r.jsx(Pn,{children:S})]}),r.jsx(Xt,{...l,children:r.jsxs("form",{onSubmit:l.handleSubmit(x),children:[r.jsx("div",{className:"py-4",children:C}),r.jsxs(Ma,{children:[r.jsx(ie,{type:"button",variant:"outline",onClick:()=>y(!1),children:"Cancel"}),r.jsx(ie,{type:"submit",disabled:l.formState.isSubmitting,className:"min-w-40",children:N})]})]})})]})})}function tV(t){const e=z.c(73),{mode:n,agentId:s,addedConnectionIds:o,onAdd:i,onCloneAndAdd:a,onConnectAndAdd:c,connectingItemId:d,search:u,onCreateConnection:f,onBrowseNavigate:l,defaultTab:V}=t,m=n===void 0?"add":n,v=V===void 0?"connected":V,{org:p}=Ce(),h=g.useDeferredValue(u),y=u!==h,x=h.trim().toLowerCase();let w;e[0]!==v?(w=W=>W??v,e[0]=v,e[1]=w):w=e[1];const[S,N]=aa(_r.connectionsTab(p.slug)+(v==="all"?":home-modal":":agent-modal"),w);let C;e[2]!==S||e[3]!==N?(C=W=>{W!==S&&X("connections_dialog_tab_changed",{to_tab:W}),N(W)},e[2]=S,e[3]=N,e[4]=C):C=e[4];const b=C;let A;e[5]!==p.id||e[6]!==p.slug?(A={connectionId:Xr,orgId:p.id,orgSlug:p.slug},e[5]=p.id,e[6]=p.slug,e[7]=A):A=e[7];const j=gt(A);let I,D,_;if(e[8]!==j||e[9]!==h||e[10]!==p.id){_=h?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:h.trim()},{field:["description"],operator:"contains",value:h.trim()}]}:void 0;const W={..._&&{where:_},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},ce=JSON.stringify(W);D=Gl,I=Je.collectionListInfinite(j,p.id,"","CONNECTIONS",ce),e[8]=j,e[9]=h,e[10]=p.id,e[11]=I,e[12]=D,e[13]=_}else I=e[11],D=e[12],_=e[13];let R;e[14]!==j||e[15]!==_?(R=async W=>{const{pageParam:ce}=W,Le=ce===void 0?0:ce;return(await j.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{..._&&{where:_},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:Le}})).structuredContent},e[14]=j,e[15]=_,e[16]=R):R=e[16];let k;e[17]!==I||e[18]!==R?(k={queryKey:I,queryFn:R,initialPageParam:0,getNextPageParam:aV,staleTime:3e4},e[17]=I,e[18]=R,e[19]=k):k=e[19];const{data:M,fetchNextPage:E,hasNextPage:P,isFetchingNextPage:T}=D(k),L=M?.pages.flatMap(iV)??[],U=Ll(L),$=new Set(L.filter(oV).map(rV)),B=vo(),K=bo(B,h),H=Hs(K.loadMore,K.hasMore,K.isLoadingMore),O=Hs(E,P??!1,T),F=S==="all"||!!x,J=F?K.items.filter(W=>{const ce=zl(W);if(ce&&$.has(ce))return!1;if(!x)return!0;const Le=W._meta?.["mcp.mesh"];return[W.title,W.description,W.name,W.server?.title,W.server?.description,W.server?.name,Le?.friendly_name,Le?.friendlyName].filter(Boolean).join(" ").toLowerCase().includes(x)}):[],Q=J.filter(sV),Z=J.filter(nV);let q;e[20]!==o?(q=W=>W.some(ce=>o.has(ce.id)),e[20]=o,e[21]=q):q=e[21];const se=q;let ee;e[22]!==o||e[23]!==s||e[24]!==d||e[25]!==se||e[26]!==m||e[27]!==i||e[28]!==l||e[29]!==a?(ee=(W,ce,Le,nt,Be)=>{const vt=se(Be),st=Be.find(fe=>!o.has(fe.id)),Ne=Be[0];if(m==="browse"){const fe=Ol(Ne);return r.jsx(Jn,{connection:{title:ce,icon:Le,description:Be.length>1?`${Be.length} instances`:nt??void 0},fallbackIcon:r.jsx(pn,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsxs(cn,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(Vt,{size:11})," Connected"]}),onClick:()=>{X("connection_browse_clicked",{app_name:Ne.app_name??null,connection_id:Ne.id,instances_count:Be.length}),l?.(fe)}},W)}return r.jsx(Jn,{connection:{title:ce,icon:Le,description:nt},fallbackIcon:r.jsx(pn,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsxs("div",{className:"flex items-center gap-1.5",children:[vt&&r.jsxs(cn,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(Vt,{size:11})," Added"]}),r.jsx(ie,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:d!==null,onClick:fe=>{fe.stopPropagation(),st?(X("connection_add_clicked",{action:"use_existing",app_name:Ne.app_name??null,connection_id:st.id}),s&&X("agent_connection_attached",{agent_id:s,connection_id:st.id,app_name:Ne.app_name??null,mode:"existing"}),i(st.id)):(X("connection_add_clicked",{action:"clone",app_name:Ne.app_name??null,base_connection_id:Ne.id}),a(Ne))},children:"Add"})]})},W)},e[22]=o,e[23]=s,e[24]=d,e[25]=se,e[26]=m,e[27]=i,e[28]=l,e[29]=a,e[30]=ee):ee=e[30];const te=ee;let G;e[31]!==d||e[32]!==m||e[33]!==c?(G=W=>{const ce=W._meta?.["mcp.mesh"],Le=ce?.friendlyName||ce?.friendly_name||W.server?.title||W.title||W.server?.name||W.name||W.id||"",nt=W.server?.description||W.description||null,Be=W.server?.icons?.[0]?.src||Ul(W.server?.repository)||null,vt=ce?.official===!0,st=ce?.verified===!0,Ne=ce?.owner==="deco";return r.jsx(Jn,{connection:{title:Le,description:nt,icon:Be},fallbackIcon:r.jsx(pn,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsxs("div",{className:"flex items-center gap-1.5",children:[Ne&&r.jsxs(qe,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx("span",{className:"inline-flex items-center justify-center size-5 rounded-md bg-muted shrink-0",children:r.jsx("img",{src:"/logos/deco logo.svg",alt:"Made by Deco",className:"size-3"})})}),r.jsx(Ke,{children:"Built and maintained by Deco"})]}),!Ne&&vt&&r.jsxs(qe,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(cn,{variant:"outline",size:"icon",children:r.jsx(Xn,{})})}),r.jsx(Ke,{children:"Built and maintained by the official vendor"})]}),!Ne&&!vt&&st&&r.jsxs(qe,{children:[r.jsx(Ue,{asChild:!0,children:r.jsx(cn,{variant:"outline",size:"icon",children:r.jsx(Xn,{})})}),r.jsx(Ke,{children:"Verified by the Deco team"})]}),r.jsx(ie,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:d!==null,onClick:fe=>{fe.stopPropagation(),X("connection_add_clicked",{action:"connect_new",registry_item_id:W.id,app_name:ce?.friendlyName||W.server?.name||W.name||null}),c(W)},children:d===W.id?r.jsx(Yt,{size:14,className:"animate-spin"}):m==="browse"?"Connect":"Add"})]})},`catalog-${W.id}`)},e[31]=d,e[32]=m,e[33]=c,e[34]=G):G=e[34];const le=G,ne=!x&&r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[r.jsx(Fl,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:S,onTabChange:W=>b(W)}),r.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{X("connections_dialog_custom_clicked"),f()},children:[r.jsx(ms,{size:12}),"Custom Connection"]})]}),me=y&&"opacity-50 pointer-events-none";let pe;e[35]!==me?(pe=Y("flex-1 overflow-auto p-5 transition-opacity duration-150",me),e[35]=me,e[36]=pe):pe=e[36];const re="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let de;e[37]!==te?(de=W=>{if(W.type==="group")return te(W.key,W.title,W.icon,null,W.connections);const ce=W.connection;return te(ce.id,ce.title,ce.icon,ce.description??null,[ce])},e[37]=te,e[38]=de):de=e[38];const we=U.map(de);let xe;e[39]!==O?(xe=r.jsx("div",{ref:O,className:"col-span-full h-1"}),e[39]=O,e[40]=xe):xe=e[40];let ye;e[41]!==T?(ye=T&&r.jsx("div",{className:"col-span-full flex justify-center py-6",children:r.jsx(Yt,{size:24,className:"animate-spin text-muted-foreground"})}),e[41]=T,e[42]=ye):ye=e[42];const ke=F&&Q.length>0&&r.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[r.jsx(Xn,{size:13,className:"text-muted-foreground shrink-0"}),r.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),Me=F&&Q.map(le),Oe=F&&Z.length>0&&r.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[r.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),je=F&&Z.map(le);let ae;e[43]!==H||e[44]!==B||e[45]!==F?(ae=F&&B.length>0&&r.jsx("div",{ref:H,className:"col-span-full h-1"}),e[43]=H,e[44]=B,e[45]=F,e[46]=ae):ae=e[46];let he;e[47]!==K.isLoadingMore||e[48]!==F?(he=F&&K.isLoadingMore&&r.jsx("div",{className:"col-span-full flex justify-center py-6",children:r.jsx(Yt,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=K.isLoadingMore,e[48]=F,e[49]=he):he=e[49];let Ie;e[50]!==we||e[51]!==xe||e[52]!==ye||e[53]!==ke||e[54]!==Me||e[55]!==Oe||e[56]!==je||e[57]!==ae||e[58]!==he?(Ie=r.jsxs("div",{className:re,children:[we,xe,ye,ke,Me,Oe,je,ae,he]}),e[50]=we,e[51]=xe,e[52]=ye,e[53]=ke,e[54]=Me,e[55]=Oe,e[56]=je,e[57]=ae,e[58]=he,e[59]=Ie):Ie=e[59];let Ae;e[60]!==S||e[61]!==U.length||e[62]!==Z||e[63]!==u||e[64]!==Q?(Ae=U.length===0&&Q.length===0&&Z.length===0&&r.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:u?`No connections match "${u}"`:S==="connected"?"No connections yet":"No connections available"}),e[60]=S,e[61]=U.length,e[62]=Z,e[63]=u,e[64]=Q,e[65]=Ae):Ae=e[65];let Ze;e[66]!==pe||e[67]!==Ie||e[68]!==Ae?(Ze=r.jsxs("div",{className:pe,children:[Ie,Ae]}),e[66]=pe,e[67]=Ie,e[68]=Ae,e[69]=Ze):Ze=e[69];let xt;return e[70]!==ne||e[71]!==Ze?(xt=r.jsxs(r.Fragment,{children:[ne,Ze]}),e[70]=ne,e[71]=Ze,e[72]=xt):xt=e[72],xt}function nV(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function sV(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function rV(t){return t.app_name}function oV(t){return t.app_name}function iV(t){return t?.items??[]}function aV(t,e){if(t?.hasMore)return e.reduce(lV,0)}function lV(t,e){return t+(e?.items?.length??0)}function cV({open:t,onOpenChange:e,defaultTab:n,initialSearch:s="",...o}){const i=o.mode??"add",a="agentId"in o?o.agentId:void 0,c="addedConnectionIds"in o?o.addedConnectionIds??new Set:new Set,d="onAdd"in o&&o.onAdd?o.onAdd:j=>{},u=(j,I,D)=>{a&&X("agent_connection_attached",{agent_id:a,connection_id:j,app_name:I,mode:D})},[f,l]=g.useState(null),[V,m]=g.useState(s),[v,p]=g.useState(!1),{org:h}=Ce(),{data:y}=_n.useSession(),x=yo(),w=kt(),S=ht(),N=j=>{e(!1),S({to:"/$org/settings/connections/$appSlug",params:{org:h.slug,appSlug:j}})},C=()=>{w.invalidateQueries({predicate:j=>{const I=j.queryKey;return I[1]===h.id&&I[3]==="collection"&&I[4]==="CONNECTIONS"}})},b=async j=>{l(j.app_name??j.id);try{const D=`${j.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,R=(await x.create.mutateAsync({title:D,description:j.description??null,connection_type:j.connection_type,connection_url:j.connection_url??null,connection_token:null,icon:j.icon??null,app_name:j.app_name??null,app_id:j.app_id??null,connection_headers:j.connection_headers??null})).id,k=await Zn({connectionId:R,orgId:h.id,orgSlug:h.slug,persistFallback:M=>x.update.mutateAsync({id:R,data:{connection_token:M}}).then(()=>{})});if(k.ran&&!k.ok){X("connection_oauth_failed",{connection_id:R,flow:"clone",error:k.error??"no_token"}),ue.error(`Authentication failed: ${k.error??"no token received"}`),await x.delete.mutateAsync(R);return}if(k.ran){X("connection_oauth_succeeded",{connection_id:R,flow:"clone"});const M=new URL(`/api/${h.slug}/mcp/${R}`,window.location.origin);await w.invalidateQueries({queryKey:Je.isMCPAuthenticated(M.href,null)}),C()}u(R,j.app_name??null,"clone"),d(R)}catch(I){console.error("Failed to add connection:",I),ue.error("Failed to add connection")}finally{l(null)}},A=async j=>{if(!(!h||!y?.user?.id)){l(j.id);try{const I=Bl(j,h.id,y.user.id,{remoteIndex:0}),D=I.connection_type==="STDIO",_=!!I.connection_url,R=D&&I.connection_headers&&typeof I.connection_headers=="object"&&"command"in I.connection_headers;if(!_&&!R){ue.error("This MCP Server cannot be connected: no connection method available"),l(null);return}const{id:k}=await x.create.mutateAsync(I),M=await Zn({connectionId:k,orgId:h.id,orgSlug:h.slug,persistFallback:E=>x.update.mutateAsync({id:k,data:{connection_token:E}}).then(()=>{})});if(M.ran&&!M.ok){X("connection_oauth_failed",{connection_id:k,flow:"connect_new",error:M.error??"no_token"}),ue.warning("Couldn't sign in to this connection",{description:`It was added to your agent, but its sign-in setup looks off. You can try authenticating again later from the connection's settings. (${M.error??"no token received"})`}),u(k,I.app_name??null,"new"),d(k);return}if(M.ran){X("connection_oauth_succeeded",{connection_id:k,flow:"connect_new"});const E=new URL(`/api/${h.slug}/mcp/${k}`,window.location.origin);await w.invalidateQueries({queryKey:Je.isMCPAuthenticated(E.href,null)}),C(),ue.success("Connected and authenticated")}else ue.success("Connected");u(k,I.app_name??null,"new"),d(k)}catch(I){console.error("Failed to connect:",I),ue.error("Failed to connect")}finally{l(null)}}};return r.jsxs(Tt,{open:t,onOpenChange:e,children:[r.jsxs(Et,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[r.jsx(Rt,{className:"px-6 pt-5 pb-0 shrink-0",children:r.jsx(_t,{className:"text-base font-semibold",children:i==="browse"?"Connections":"Add Connection"})}),r.jsx("div",{className:"pt-3 shrink-0",children:r.jsx(Wr,{value:V,onChange:m,placeholder:"Search connections..."})}),r.jsx(g.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Yt,{size:24,className:"animate-spin text-muted-foreground"})}),children:r.jsx(tV,{mode:i,agentId:a,addedConnectionIds:c,onAdd:d,onCloneAndAdd:b,onConnectAndAdd:A,connectingItemId:f,search:V,onCreateConnection:()=>p(!0),onBrowseNavigate:N,defaultTab:n})})]}),r.jsx(eV,{open:v,onOpenChange:p,onCreated:async j=>{p(!1);const I=await Zn({connectionId:j,orgId:h.id,orgSlug:h.slug,persistFallback:D=>x.update.mutateAsync({id:j,data:{connection_token:D}}).then(()=>{})});if(I.ran&&!I.ok){X("connection_oauth_failed",{connection_id:j,flow:"custom_create",error:I.error??"no_token"}),ue.warning("Couldn't sign in to this connection",{description:`It was added to your agent, but its sign-in setup looks off. You can try authenticating again later from the connection's settings. (${I.error??"no token received"})`}),u(j,null,"custom"),d(j),e(!1);return}if(I.ran){X("connection_oauth_succeeded",{connection_id:j,flow:"custom_create"});const D=new URL(`/api/${h.slug}/mcp/${j}`,window.location.origin);await w.invalidateQueries({queryKey:Je.isMCPAuthenticated(D.href,null)}),C()}u(j,null,"custom"),d(j),e(!1)}})]})}const dV=[{src:"/connections/github.png",name:"GitHub"},{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/linear.png",name:"Linear"},{src:"/connections/shopify.png",name:"Shopify"},{src:"/connections/firecrawl.png",name:"Firecrawl"},{src:"/connections/perplexity.png",name:"Perplexity"}];function uV(){const t=z.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1",children:dV.map(fV)}),t[0]=e):e=t[0],e}function fV(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function VV(t){const e=z.c(6),{onClick:n}=t;let s,o,i,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Y("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),o=r.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),i=r.jsx(uV,{}),a=r.jsx(Xl,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=s,e[1]=o,e[2]=i,e[3]=a):(s=e[0],o=e[1],i=e[2],a=e[3]);let c;return e[4]!==n?(c=r.jsxs("button",{type:"button",onClick:n,className:s,children:[o,i,a]}),e[4]=n,e[5]=c):c=e[5],c}const Kt=48;function mV(){const t=z.c(9),[e,n]=g.useState("idle"),[s,o]=g.useState(""),[i,a]=g.useState(""),[c,d]=g.useState(gV),u=g.useRef(null),f=g.useRef(null),l=g.useRef(null),V=g.useRef(null),m=g.useRef(0),v=g.useRef(!1),p=g.useRef(""),h=g.useRef(""),y=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let x;t[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),f.current?.close().catch(hV),V.current?.getTracks().forEach(pV),l.current=null,f.current=null,V.current=null},t[0]=x):x=t[0];const w=x;let S;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const D=_=>{V.current=_;const R=new AudioContext;f.current=R;const k=R.createMediaStreamSource(_),M=R.createAnalyser();M.fftSize=128,M.smoothingTimeConstant=.8,k.connect(M),l.current=M;const E=new Uint8Array(M.frequencyBinCount),P=()=>{if(!l.current)return;l.current.getByteFrequencyData(E);const T=[];for(let L=0;L<Kt;L++){const U=Math.floor(L/Kt*E.length);T.push(Math.max(.04,(E[U]??0)/255))}d(T),m.current=requestAnimationFrame(P)};P()};S=async()=>{const _=window.SpeechRecognition||window.webkitSpeechRecognition;if(!_){n("unsupported");return}let R;try{R=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{n("permission-denied");return}o(""),a(""),h.current="",p.current="",v.current=!0,n("recording"),D(R);const k=new _;u.current=k,k.interimResults=!0,k.continuous=!0,k.lang=navigator.language||"en-US",k.onresult=M=>{let E="",P="";for(let T=M.resultIndex;T<M.results.length;T++){const L=M.results[T],U=L?.[0]?.transcript??"";L?.isFinal?P=P+U:E=E+U}P&&(p.current=p.current+P,o(p.current)),h.current=E,a(E)},k.onend=()=>{if(v.current)try{k.start()}catch{}};try{k.start()}catch{n("idle")}},t[1]=S}else S=t[1];const N=S;let C;t[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{v.current=!1,u.current?.stop(),w(),n("idle"),d(Array(Kt).fill(.05)),a("");const D=(p.current+(h.current?" "+h.current:"")).trim();return o(""),p.current="",h.current="",D},t[2]=C):C=t[2];const b=C;let A;t[3]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{v.current=!1,u.current?.abort(),w(),n("idle"),o(""),a(""),d(Array(Kt).fill(.05)),p.current="",h.current=""},t[3]=A):A=t[3];const j=A;let I;return t[4]!==i||t[5]!==e||t[6]!==s||t[7]!==c?(I={status:e,transcript:s,interimTranscript:i,waveformData:c,isSupported:y,startRecording:N,stopRecording:b,cancelRecording:j},t[4]=i,t[5]=e,t[6]=s,t[7]=c,t[8]=I):I=t[8],I}function pV(t){return t.stop()}function hV(){}function gV(){return Array(Kt).fill(.05)}function xV(t){const e=z.c(4),{data:n}=t;let s;e[0]!==n?(s=n.map(vV),e[0]=n,e[1]=s):s=e[1];let o;return e[2]!==s?(o=r.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:s}),e[2]=s,e[3]=o):o=e[3],o}function vV(t,e){return r.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}function bV({messageCount:t,showConnectionsBanner:e}){return t>0||e}function yV(t){return t.hasDraft?"send":t.isStreaming||t.isRunInProgress?"stop":"disabled"}function wV(t){const e=z.c(3),{message:n}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Lr,{size:14,className:"shrink-0"}),e[0]=s):s=e[0];let o;return e[1]!==n?(o=r.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[s,r.jsx("span",{className:"text-sm",children:n})]}),e[1]=n,e[2]=o):o=e[2],o}function jV(t,e){const n=z.c(5),{editor:s}=As(),[o,i]=g.useState(!1),a=g.useRef(0);let c,d;return n[0]!==s||n[1]!==e||n[2]!==t?(c=()=>{const u=m=>{m.dataTransfer?.types.includes("Files")&&(m.preventDefault(),a.current=a.current+1,i(!0))},f=m=>{m.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&i(!1)},l=AV,V=m=>{if(m.preventDefault(),a.current=0,i(!1),!s||!t||!$n(t))return;const v=m.dataTransfer?.files;if(!v||v.length===0)return;const{from:p}=s.state.selection;for(const h of Array.from(v))Ds(s,t,h,p,e)};return window.addEventListener("dragenter",u),window.addEventListener("dragleave",f),window.addEventListener("dragover",l),window.addEventListener("drop",V),()=>{window.removeEventListener("dragenter",u),window.removeEventListener("dragleave",f),window.removeEventListener("dragover",l),window.removeEventListener("drop",V)}},d=[s,t,e],n[0]=s,n[1]=e,n[2]=t,n[3]=c,n[4]=d):(c=n[3],d=n[4]),g.useEffect(c,d),o}function AV(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function CV(t){const e=z.c(11),{selectedModel:n,onUnsupportedFile:s}=t,o=jV(n,s);let i;e[0]!==n?(i=$n(n),e[0]=n,e[1]=i):i=e[1];const a=i,c=o?"opacity-100":"opacity-0 pointer-events-none",d=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let u;e[2]!==c||e[3]!==d?(u=Y("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",c,d),e[2]=c,e[3]=d,e[4]=u):u=e[4];let f;e[5]!==n||e[6]!==a?(f=a?r.jsxs(r.Fragment,{children:[r.jsx(ol,{size:24}),r.jsxs("span",{className:"text-sm font-medium",children:["Drop ",xo(n)," here"]})]}):r.jsxs(r.Fragment,{children:[r.jsx(Lr,{size:24}),r.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=n,e[6]=a,e[7]=f):f=e[7];let l;return e[8]!==u||e[9]!==f?(l=r.jsx("div",{className:u,children:f}),e[8]=u,e[9]=f,e[10]=l):l=e[10],l}function SV(){const t=z.c(6),e=ht(),{org:n,locator:s}=Ce(),{create:o}=Ua();let i;return t[0]!==o||t[1]!==s||t[2]!==e||t[3]!==n.id||t[4]!==n.slug?(i=async a=>{const{tiptapDoc:c,virtualMcp:d}=a,u=crypto.randomUUID(),f=d?.id??Mn(n.id).id;Ka(sessionStorage,s,u,{tiptapDoc:c});try{await o({id:u,virtual_mcp_id:f})}catch{}const l={virtualmcpid:f,autosend:qa};e({to:"/$org/$taskId",params:{org:n.slug,taskId:u},search:l})},t[0]=o,t[1]=s,t[2]=e,t[3]=n.id,t[4]=n.slug,t[5]=i):i=t[5],i}function NV({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const n=Br(),s=En(),o=n?.messages??[],i=n?.isStreaming??!1,a=n?.isRunInProgress??!1,c=n?.stop??(()=>{}),d=s?.taskId??"",u=d||wc,f=SV(),{selectedModel:l,selectedVirtualMcp:V,isModelsLoading:m,tiptapDocRef:v,imageModel:p,webSearchModel:h,deepResearchModel:y,chatMode:x,setChatMode:w}=ut(),{data:S}=_n.useSession(),N=S?.user?.id,{org:C,locator:b}=Ce(),A=Mn(C.id).id,j=Wa(V?.id??A),I=ri(Ml),[D,_]=g.useState(!1),{unsupportedFile:R,onUnsupportedFile:k,clearUnsupportedFile:M}=Su(),E=mV(),P=g.useRef(void 0),T=async()=>{P.current=B,await E.startRecording();const re=E.status==="recording"?"started":E.status==="unsupported"?"unsupported":E.status==="permission-denied"?"permission_denied":"unknown";X("chat_voice_started",{thread_id:d,outcome:re})},L=()=>{X("chat_voice_confirmed",{thread_id:d});const re=E.stopRecording();Q.current?.syncVoiceText(P.current,re),Q.current?.focus()},U=()=>{X("chat_voice_cancelled",{thread_id:d}),E.cancelRecording(),Q.current?.restoreContent(P.current)};g.useEffect(()=>{if(E.status!=="recording")return;const re=(E.transcript+(E.interimTranscript?" "+E.interimTranscript:"")).trim();Q.current?.syncVoiceText(P.current,re)},[E.transcript,E.interimTranscript,E.status]);const $=s?.activeTask??null,[B,K]=g.useState(()=>Gs(sessionStorage,b,u)??void 0),H=re=>{K(re),v.current=re,Ac(sessionStorage,b,u,re,{onQuotaExceeded:({docSizeBytes:de})=>{X("chat_draft_quota_exceeded",{thread_id:d||null,doc_size_bytes:de}),console.warn("[chat-draft] sessionStorage quota exceeded; draft not saved")}})},O=g.useRef(d);if(O.current!==d){O.current=d;const re=Gs(sessionStorage,b,u)??void 0;K(re),v.current=re}const J=[...o].reverse().find(re=>re.role==="assistant")?.metadata?.modelLimits?.contextWindow??l?.limits?.contextWindow,Q=g.useRef(null),Z=x==="plan";g.useEffect(()=>{const re=de=>{Ha(de)&&de.code==="KeyL"&&(de.preventDefault(),de.shiftKey&&w(x==="plan"?"default":"plan"),Q.current?.focus())};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[x,w]);const q=Ra(o),ee=[...o].reverse().find(re=>re.role==="assistant"&&re.metadata?.usage)?.metadata?.usage?.contextTokens??0,te=!m&&!Io(B),G=yV({hasDraft:te,isStreaming:i,isRunInProgress:a}),le=G==="send",ne=G==="stop",me=bV({messageCount:o.length,showConnectionsBanner:e}),pe=re=>{if(re?.preventDefault(),G==="send"&&B){if(X("chat_message_sent",{thread_id:d||null,mode:x,model_id:l?.modelId??null,model_provider:l?.providerId??null,virtual_mcp_id:V?.id??null,submission:re?"button_or_enter":"programmatic"}),n){if(n.isSendInFlight()){ue.info("Still sending your previous message — try again in a moment");return}n.sendMessage(B)}else f({tiptapDoc:B,virtualMcp:V});Cc(sessionStorage,b,u),H(void 0)}else G==="stop"&&(X("chat_message_stopped",{thread_id:d}),c())};return N&&$?.created_by&&$.created_by!==N?r.jsx(wV,{message:"Read only - you're viewing someone else's thread"}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col w-full justify-end",children:r.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&r.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),n&&s&&r.jsx(zn,{}),n&&s&&d?r.jsx(Ad,{taskId:d}):null,r.jsx(Yf,{tiptapDoc:B,setTiptapDoc:H,disabled:!1,enterToSubmit:!0,onSubmit:pe,children:r.jsxs("form",{onSubmit:pe,className:Y("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-card dark:bg-muted card-shadow overflow-hidden"),children:[r.jsx(CV,{selectedModel:l,onUnsupportedFile:k}),r.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:r.jsx(Hf,{ref:Q,disabled:E.status==="recording",virtualMcpId:V?.id??A,showFileUploader:!0,selectedModel:l,onUnsupportedFile:k})}),r.jsx("div",{className:"@container/chat-bottom flex items-center justify-between p-2.5 gap-1",children:E.status==="recording"?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsx(xV,{data:E.waveformData.slice(0,28)}),r.jsx("button",{type:"button",onClick:U,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Cancel recording",children:r.jsx(yt,{size:16})}),r.jsx("button",{type:"button",onClick:L,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:r.jsx(Vt,{size:16})})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.jsx(Zf,{disabled:!1,onOpenConnections:()=>{X("connections_dialog_opened",{source:"tools_popover",mode:"add"}),_(!0)},virtualMcpId:V?.id??A,selectedModel:l,isStreaming:i,onUnsupportedFile:k}),Z&&r.jsxs("button",{type:"button",onClick:()=>{I(),X("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),w("default")},title:"Plan mode","aria-label":"Plan mode",className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group min-w-0 shrink animate-in fade-in duration-200",children:[r.jsx(Jr,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100",children:"Plan mode"}),r.jsx(yt,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),x==="gen-image"&&p&&r.jsxs("button",{type:"button",onClick:()=>{I(),X("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),w("default")},title:"Create image","aria-label":"Create image",className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[r.jsx(Zr,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Create image"}),r.jsx(yt,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),x==="web-search"&&h&&r.jsxs("button",{type:"button",onClick:()=>{I(),X("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),w("default")},title:"Web search","aria-label":"Web search",className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[r.jsx(Ht,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Web search"}),r.jsx(yt,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),x==="deep-research"&&y&&r.jsxs("button",{type:"button",onClick:()=>{I(),X("chat_mode_changed",{from_mode:"deep-research",to_mode:"default",source:"pill_dismiss"}),w("default")},title:"Deep research","aria-label":"Deep research",className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[r.jsx(no,{size:14,className:"shrink-0"}),r.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Deep research"}),r.jsx(yt,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),J&&ee>0&&r.jsx(_a,{usage:q,totalTokens:ee,contextWindow:J,onOpenContextPanel:t})]}),r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[me&&r.jsx(hu,{virtualMcp:j,currentBranch:s?.currentBranch??null}),r.jsx(bu,{}),E.isSupported&&r.jsx(ie,{type:"button",onClick:T,disabled:!1,variant:"ghost",size:"icon",className:Y("size-8 rounded-lg transition-colors",E.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:E.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:r.jsx(sl,{size:18})}),r.jsx(ie,{type:ne?"button":"submit",onClick:re=>{ne&&(re.preventDefault(),re.stopPropagation(),c())},variant:le||ne?"default":"ghost",size:"icon",disabled:!le&&!ne,className:Y("size-8 rounded-lg transition-all",!le&&!ne&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:G==="stop"?i?"Stop generating":"Cancel run":"Send message (Enter)",children:ne?r.jsx(rl,{size:20}):r.jsx(Fr,{size:20})})]})]})})]})},d),e&&r.jsx(VV,{onClick:()=>{X("connections_banner_clicked",{source:"home_chat_input"}),X("connections_dialog_opened",{source:"home_banner",mode:"add"}),_(!0)}})]})}),r.jsx(cV,{mode:"browse",open:D,onOpenChange:_,defaultTab:"all"}),r.jsx(Au,{info:R,onClose:M})]})}const kV={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]};function oi(t){return`deco-credits-empty-dismissed:${t}`}function Th(t){try{return localStorage.getItem(oi(t))==="1"}catch{return!1}}function IV(){const t=z.c(47),{org:e}=Ce(),n=ht(),{decoKeyId:s}=fo(),o=Vo(),[i,a]=g.useState(!0),[c,d]=g.useState(""),[u,f]=g.useState(!1),[l,V]=g.useState("usd"),m=l==="brl"?"R$":"$";let v;t[0]!==e.id?(v=()=>{X("credits_empty_state_dismissed",{organization_id:e.id}),a(!1);try{localStorage.setItem(oi(e.id),"1")}catch{}},t[0]=e.id,t[1]=v):v=t[1];const p=v;let h,y;t[2]!==i||t[3]!==e.id?(h=()=>{i&&X("credits_empty_state_shown",{organization_id:e.id})},y=[i,e.id],t[2]=i,t[3]=e.id,t[4]=h,t[5]=y):(h=t[4],y=t[5]),g.useEffect(h,y);let x;t[6]!==l||t[7]!==o?(x=async $=>{const{url:B}=await o.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:$,currency:l});return B},t[6]=l,t[7]=o,t[8]=x):x=t[8];let w;t[9]!==p?(w=$=>{$&&window.open($,"_blank","noopener,noreferrer"),p()},t[9]=p,t[10]=w):w=t[10];let S;t[11]!==x||t[12]!==w?(S={mutationFn:x,onSuccess:w,onError:RV},t[11]=x,t[12]=w,t[13]=S):S=t[13];const{mutate:N,isPending:C}=ws(S),b=parseFloat(c),A=!isNaN(b)&&b>=1;if(!i)return null;let j;t[14]!==p?(j=$=>!$&&p(),t[14]=p,t[15]=j):j=t[15];let I;t[16]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-amber-500/8 to-transparent pointer-events-none rounded-t-lg"}),t[16]=I):I=t[16];let D;t[17]===Symbol.for("react.memo_cache_sentinel")?(D=r.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-100 dark:bg-amber-900/40 border border-amber-200/60 dark:border-amber-800/40 mx-auto",children:r.jsx(so,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[17]=D):D=t[17];let _;t[18]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[I,r.jsxs(Rt,{className:"relative gap-3",children:[D,r.jsxs("div",{className:"text-center",children:[r.jsx(_t,{className:"text-lg font-semibold",children:"This workspace has no credits"}),r.jsx(Pn,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:"Your free credits were used in another workspace. Add credits to use AI here."})]})]})]}),t[18]=_):_=t[18];let R;t[19]!==l||t[20]!==m||t[21]!==c||t[22]!==b||t[23]!==s||t[24]!==A||t[25]!==C||t[26]!==u||t[27]!==N?(R=s&&r.jsxs("div",{className:"px-6 pb-5",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(uo,{type:"single",variant:"outline",size:"sm",value:l,onValueChange:$=>{$&&V($)},children:[r.jsx(yn,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(yn,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:kV[l].map($=>{const{dollars:B,label:K}=$;return r.jsxs("button",{type:"button",disabled:C,onClick:()=>{X("credits_topup_clicked",{amount_cents:B*100,currency:l,tier_label:K,source:"empty_state"}),N(B*100)},className:Y("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,B]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:K})]},B)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),r.jsx(tt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:$=>d($.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(ie,{className:"h-10",disabled:!A||C,onClick:()=>{X("credits_topup_clicked",{amount_cents:Math.round(b*100),currency:l,tier_label:"custom",source:"empty_state"}),N(Math.round(b*100))},children:C?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>f(!0),children:"Enter custom amount"})]}),t[19]=l,t[20]=m,t[21]=c,t[22]=b,t[23]=s,t[24]=A,t[25]=C,t[26]=u,t[27]=N,t[28]=R):R=t[28];let k;t[29]!==p||t[30]!==n||t[31]!==e.slug?(k=()=>{n({to:"/$org/settings/ai-providers",params:{org:e.slug}}),p()},t[29]=p,t[30]=n,t[31]=e.slug,t[32]=k):k=t[32];let M;t[33]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(co,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[33]=M):M=t[33];let E;t[34]!==k?(E=r.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:k,children:["Use your own provider",M]}),t[34]=k,t[35]=E):E=t[35];let P;t[36]!==p?(P=r.jsx(ie,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:p,children:"Skip for now"}),t[36]=p,t[37]=P):P=t[37];let T;t[38]!==E||t[39]!==P?(T=r.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[E,P]}),t[38]=E,t[39]=P,t[40]=T):T=t[40];let L;t[41]!==R||t[42]!==T?(L=r.jsxs(Et,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:DV,children:[_,R,T]}),t[41]=R,t[42]=T,t[43]=L):L=t[43];let U;return t[44]!==L||t[45]!==j?(U=r.jsx(Tt,{open:!0,onOpenChange:j,children:L}),t[44]=L,t[45]=j,t[46]=U):U=t[46],U}function DV(t){return t.preventDefault()}function RV(t){ue.error(`Top-up failed: ${t.message}`)}function _V(t){const e=z.c(6),{balanceDollars:n}=t;let s;e[0]!==n?(s=n.toFixed(2),e[0]=n,e[1]=s):s=e[1];const o=s;let i,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=Y("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-emerald-50 dark:bg-emerald-950/30","border border-emerald-200/60 dark:border-emerald-800/40","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=r.jsx(so,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=i,e[3]=a):(i=e[2],a=e[3]);let c;return e[4]!==o?(c=r.jsxs("div",{className:i,children:[a,r.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",o," in credits to get started"]})]}),e[4]=o,e[5]=c):c=e[5],c}function EV(){const t=z.c(8),{org:e}=Ce(),n=ht();let s;t[0]!==n||t[1]!==e.slug?(s=()=>n({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=n,t[1]=e.slug,t[2]=s):s=t[2];let o,i,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=Y("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-amber-50 dark:bg-amber-950/30","border border-amber-200/60 dark:border-amber-800/40","hover:bg-amber-100/60 dark:hover:bg-amber-900/30","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),i=r.jsx(ro,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=r.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=o,t[4]=i,t[5]=a):(o=t[3],i=t[4],a=t[5]);let c;return t[6]!==s?(c=r.jsxs("button",{type:"button",onClick:s,className:o,children:[i,a]}),t[6]=s,t[7]=c):c=t[7],c}function TV(t){const e=z.c(11),{className:n}=t;let s;e[0]!==n?(s=Y("flex h-full w-full flex-col bg-background",n),e[0]=n,e[1]=s):s=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=o):o=e[2];let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsxs("div",{className:"flex items-center gap-3",children:[o,r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),r.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=i):i=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:r.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[i,r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),r.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[r.jsx(un,{align:"right",width:"w-3/4"}),r.jsx(un,{align:"left",width:"w-full",lines:3}),r.jsx(un,{align:"right",width:"w-2/3"}),r.jsx(un,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:r.jsx("div",{className:"relative flex-1",children:r.jsxs("div",{className:"space-y-2 p-2",children:[r.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),r.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=d):d=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx("div",{className:"px-4 py-4",children:r.jsx("div",{className:"mx-auto w-full max-w-2xl",children:r.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[d,r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[u,r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),r.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=f):f=e[8];let l;return e[9]!==s?(l=r.jsxs("div",{className:s,children:[a,c,f]}),e[9]=s,e[10]=l):l=e[10],l}function un(t){const e=z.c(22),{align:n,width:s,lines:o}=t,i=s===void 0?"w-full":s,a=o===void 0?1:o,c=n==="right"?"flex-row-reverse":"flex-row";let d;e[0]!==c?(d=Y("flex w-full gap-4 px-4 py-2",c),e[0]=c,e[1]=d):d=e[1];const u=n==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let f;e[2]!==u?(f=Y("flex min-w-0 flex-col gap-2",u),e[2]=u,e[3]=f):f=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=l):l=e[4];const V=n==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==V||e[6]!==i?(m=Y("min-w-0 rounded-2xl p-4",V,i),e[5]=V,e[6]=i,e[7]=m):m=e[7];let v;e[8]!==a?(v=Array.from({length:a}),e[8]=a,e[9]=v):v=e[9];let p;e[10]!==a||e[11]!==v?(p=r.jsx("div",{className:"space-y-2",children:v.map((w,S)=>r.jsx("div",{className:Y("h-3 rounded bg-muted-foreground/20 animate-pulse",S===a-1?"w-3/4":"w-full"),style:{animationDelay:`${S*.1}s`}},S))}),e[10]=a,e[11]=v,e[12]=p):p=e[12];let h;e[13]!==p||e[14]!==m?(h=r.jsx("div",{className:m,children:p}),e[13]=p,e[14]=m,e[15]=h):h=e[15];let y;e[16]!==h||e[17]!==f?(y=r.jsxs("div",{className:f,children:[l,h]}),e[16]=h,e[17]=f,e[18]=y):y=e[18];let x;return e[19]!==y||e[20]!==d?(x=r.jsx("div",{className:d,children:y}),e[19]=y,e[20]=d,e[21]=x):x=e[21],x}function PV(t){const e=z.c(7),{scrollRef:n,sentinelRef:s,hasMoreOlder:o,isFetchingOlder:i,fetchOlderMessages:a}=t;let c,d;e[0]!==a||e[1]!==o||e[2]!==i||e[3]!==n||e[4]!==s?(c=()=>{const u=s.current,f=n.current;if(!u||!f||!o)return;const l=new IntersectionObserver(async V=>{if(!V[0]?.isIntersecting||i||!o)return;const v=f.scrollHeight,p=f.scrollTop;await a(),requestAnimationFrame(()=>{const h=f.scrollHeight;f.scrollTop=p+(h-v)})},{root:f,rootMargin:"200px 0px 0px 0px"});return l.observe(u),()=>l.disconnect()},d=[n,s,o,i,a],e[0]=a,e[1]=o,e[2]=i,e[3]=n,e[4]=s,e[5]=c,e[6]=d):(c=e[5],d=e[6]),g.useEffect(c,d)}function MV(t){const e=z.c(5),{className:n,children:s}=t;let o;e[0]!==n?(o=Y("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",n),e[0]=n,e[1]=o):o=e[1];let i;return e[2]!==s||e[3]!==o?(i=r.jsx("div",{className:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4],i}function OV(t){const e=z.c(5),{children:n,className:s}=t;let o;e[0]!==s?(o=Y("flex-1 min-h-0 overflow-y-auto isolate",s),e[0]=s,e[1]=o):o=e[1];let i;return e[2]!==n||e[3]!==o?(i=r.jsx("div",{className:o,children:n}),e[2]=n,e[3]=o,e[4]=i):i=e[4],i}function LV(t){const e=z.c(2),{children:n}=t;let s;return e[0]!==n?(s=r.jsx("div",{className:"min-h-full shrink-0 w-full flex items-center justify-center max-w-2xl mx-auto py-10",children:n}),e[0]=n,e[1]=s):s=e[1],s}function FV(){const{messages:t,status:e,hasMoreOlder:n,isFetchingOlder:s,fetchOlderMessages:o}=Dt(),{taskId:i}=$r(),a=zr(i??""),c=pa(a),d=c.size===0?t:t.filter(y=>!c.has(y.id)),u=Ea(d),f=u.at(-1),V=yc()*cc+16,m=g.useRef(null),v=g.useRef(null);PV({scrollRef:m,sentinelRef:v,hasMoreOlder:n,isFetchingOlder:s,fetchOlderMessages:o});const p=Ta({initial:!1}),h=y=>{m.current=y,p.scrollRef(y)};return r.jsx(Pa,{messages:t,children:r.jsxs("div",{className:"relative h-full w-full min-w-0",children:[r.jsx("div",{ref:h,"data-chat-scroller":!0,className:"w-full min-w-0 max-w-full overflow-y-auto h-full [container-type:size]",style:{paddingBottom:V},children:r.jsxs("div",{ref:p.contentRef,className:"overflow-x-clip",children:[r.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[r.jsx("div",{ref:v,"aria-hidden":!0,className:"h-px"}),s&&r.jsx("div",{className:"flex items-center justify-center py-3 text-xs text-muted-foreground",children:"Loading older messages…"}),u.slice(0,-1).map((y,x)=>r.jsx(Fs,{pair:y,isLastPair:!1,status:x===u.length-1?e:void 0},`pair-${y.user?.id??y.assistant?.id}`))]}),f&&r.jsx("div",{className:"min-h-[100cqh] min-w-0 max-w-2xl mx-auto w-full",children:r.jsx(Fs,{pair:f,isLastPair:!0,status:e},`pair-${f.user?.id??f.assistant?.id}`)})]})}),!p.isAtBottom&&r.jsx(ie,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Jump to latest",className:"absolute left-1/2 z-50 -translate-x-1/2 rounded-full shadow-md animate-in fade-in duration-200 dark:bg-background dark:hover:bg-accent",style:{bottom:V+8},onClick:()=>{p.scrollToBottom()},children:r.jsx(la,{size:14})})]})})}function $V(t){const e=z.c(5),{children:n,className:s}=t;let o;e[0]!==s?(o=Y("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",s),e[0]=s,e[1]=o):o=e[1];let i;return e[2]!==n||e[3]!==o?(i=r.jsx("div",{className:o,children:n}),e[2]=n,e[3]=o,e[4]=i):i=e[4],i}const Ph=Object.assign(MV,{Main:OV,Messages:FV,EmptyState:LV,Footer:$V,Input:NV,Provider:ma,ActiveTaskProvider:Va,Skeleton:TV,IceBreakers:lc,NoAiProviderEmptyState:hl,CreditsEmptyState:IV,CreditsEyebrow:_V,NoCreditsEyebrow:EV,CreditsExhaustedBanner:Fo});function zV(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return g.useMemo(()=>s=>{e.forEach(o=>o(s))},e)}const Bn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pt(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Es(t){return"nodeType"in t}function Se(t){var e,n;return t?Pt(t)?t:Es(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function Ts(t){const{Document:e}=Se(t);return t instanceof e}function sn(t){return Pt(t)?!1:t instanceof Se(t).HTMLElement}function ii(t){return t instanceof Se(t).SVGElement}function Mt(t){return t?Pt(t)?t.document:Es(t)?Ts(t)?t:sn(t)||ii(t)?t.ownerDocument:document:document:document}const Ye=Bn?g.useLayoutEffect:g.useEffect;function Un(t){const e=g.useRef(t);return Ye(()=>{e.current=t}),g.useCallback(function(){for(var n=arguments.length,s=new Array(n),o=0;o<n;o++)s[o]=arguments[o];return e.current==null?void 0:e.current(...s)},[])}function BV(){const t=g.useRef(null),e=g.useCallback((s,o)=>{t.current=setInterval(s,o)},[]),n=g.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function en(t,e){e===void 0&&(e=[t]);const n=g.useRef(t);return Ye(()=>{n.current!==t&&(n.current=t)},e),n}function rn(t,e){const n=g.useRef();return g.useMemo(()=>{const s=t(n.current);return n.current=s,s},[...e])}function Sn(t){const e=Un(t),n=g.useRef(null),s=g.useCallback(o=>{o!==n.current&&e?.(o,n.current),n.current=o},[]);return[n,s]}function Nn(t){const e=g.useRef();return g.useEffect(()=>{e.current=t},[t]),e.current}let is={};function on(t,e){return g.useMemo(()=>{if(e)return e;const n=is[t]==null?0:is[t]+1;return is[t]=n,t+"-"+n},[t,e])}function ai(t){return function(e){for(var n=arguments.length,s=new Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return s.reduce((i,a)=>{const c=Object.entries(a);for(const[d,u]of c){const f=i[d];f!=null&&(i[d]=f+t*u)}return i},{...e})}}const Ct=ai(1),tn=ai(-1);function UV(t){return"clientX"in t&&"clientY"in t}function Kn(t){if(!t)return!1;const{KeyboardEvent:e}=Se(t.target);return e&&t instanceof e}function KV(t){if(!t)return!1;const{TouchEvent:e}=Se(t.target);return e&&t instanceof e}function kn(t){if(KV(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return UV(t)?{x:t.clientX,y:t.clientY}:null}const mt=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[mt.Translate.toString(t),mt.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:s}=t;return e+" "+n+"ms "+s}}}),xr="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function qV(t){return t.matches(xr)?t:t.querySelector(xr)}const YV={display:"none"};function HV(t){let{id:e,value:n}=t;return Ve.createElement("div",{id:e,style:YV},n)}function QV(t){let{id:e,announcement:n,ariaLiveType:s="assertive"}=t;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ve.createElement("div",{id:e,style:o,role:"status","aria-live":s,"aria-atomic":!0},n)}function WV(){const[t,e]=g.useState("");return{announce:g.useCallback(s=>{s!=null&&e(s)},[]),announcement:t}}const li=g.createContext(null);function GV(t){const e=g.useContext(li);g.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function XV(){const[t]=g.useState(()=>new Set),e=g.useCallback(s=>(t.add(s),()=>t.delete(s)),[t]);return[g.useCallback(s=>{let{type:o,event:i}=s;t.forEach(a=>{var c;return(c=a[o])==null?void 0:c.call(a,i)})},[t]),e]}const JV={draggable:`
|
|
4
4
|
To pick up a draggable item, press the space bar.
|