decocms 4.40.0 → 4.41.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-BQoAJ7Pc.js → AlertCircle-alrsw5sb.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-CfcRtZ8o.js → ArrowUpRight-BYn37fLS.js} +1 -1
- package/dist/client/assets/{Check-ByMMRPdN.js → Check-BoClJlGr.js} +1 -1
- package/dist/client/assets/{CheckCircle-uSDvDj68.js → CheckCircle-DU5VsEiy.js} +1 -1
- package/dist/client/assets/{ChevronDown-Ds93wwRe.js → ChevronDown-Brul_emp.js} +1 -1
- package/dist/client/assets/{ChevronRight-BUqzT2AZ.js → ChevronRight-CPjbrY1z.js} +1 -1
- package/dist/client/assets/{ChevronUp-hSMVM7_9.js → ChevronUp-bdu2geyR.js} +1 -1
- package/dist/client/assets/{Circle-CIBa1C-R.js → Circle-BOYi0Xck.js} +1 -1
- package/dist/client/assets/{Copy01-Dn74k5DV.js → Copy01-CmYZk_Oi.js} +1 -1
- package/dist/client/assets/{DotsVertical-OqISO6nN.js → DotsVertical-DO_6KMLL.js} +1 -1
- package/dist/client/assets/{Eye-DMTaYgfE.js → Eye-BvH_DPVP.js} +1 -1
- package/dist/client/assets/{FilterLines-BmSHEouM.js → FilterLines-DO_aU8_D.js} +1 -1
- package/dist/client/assets/{Globe01-DCyvmziv.js → Globe01-CRp5QOra.js} +1 -1
- package/dist/client/assets/{Globe04-iXXVu6cY.js → Globe04-B4Ko9COZ.js} +1 -1
- package/dist/client/assets/{HardDrive-BOMqphCJ.js → HardDrive-DuDQqVUp.js} +1 -1
- package/dist/client/assets/{Key01-CyxwtgAw.js → Key01-BQ6DQsHX.js} +1 -1
- package/dist/client/assets/{LayoutLeft-Lv2ZhZwN.js → LayoutLeft--MRcuBrS.js} +1 -1
- package/dist/client/assets/{LinkExternal01-CqYi3PbY.js → LinkExternal01-CZdZ3Gp9.js} +1 -1
- package/dist/client/assets/{List-CjQLqVV2.js → List-CLefXpG9.js} +1 -1
- package/dist/client/assets/{Loading02-Br4Qsbis.js → Loading02-CfrU2bHj.js} +1 -1
- package/dist/client/assets/{Monitor01-Dj7mHFbg.js → Monitor01-C7sxGC0d.js} +1 -1
- package/dist/client/assets/{Palette-CYfpdldc.js → Palette-ByeXYG5e.js} +1 -1
- package/dist/client/assets/{Play-Ct1jkZWO.js → Play-Du9xpw0U.js} +1 -1
- package/dist/client/assets/{Plus-BdYdKkzh.js → Plus-1psGuynD.js} +1 -1
- package/dist/client/assets/{SearchLg-BKceB_7Q.js → SearchLg-BmO74DiK.js} +1 -1
- package/dist/client/assets/{SearchMd-CIebSZD2.js → SearchMd-CSePLCcA.js} +1 -1
- package/dist/client/assets/{Settings02-CO032VQ5.js → Settings02-MYpqMtoa.js} +1 -1
- package/dist/client/assets/{Shield01-BOKAaJ_3.js → Shield01-C1_5VC4J.js} +1 -1
- package/dist/client/assets/{Star01-BEjXt6EU.js → Star01-DR542MT0.js} +1 -1
- package/dist/client/assets/{Stars01-CCdr3QPh.js → Stars01-DFxlT01N.js} +1 -1
- package/dist/client/assets/{Stars02-RAKDMyiv.js → Stars02-BEUdLZEv.js} +1 -1
- package/dist/client/assets/{Sun-CZYFQMTR.js → Sun-DdMchr6Q.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-ypxOAaEV.js → SwitchHorizontal01-DmcI1SxK.js} +1 -1
- package/dist/client/assets/{Tool01-BjsyNNOX.js → Tool01-CLxmN9mS.js} +1 -1
- package/dist/client/assets/{Trash01-CkdTj_48.js → Trash01-D0Cq2EdB.js} +1 -1
- package/dist/client/assets/{Upload01-pwMs2gu0.js → Upload01-u7texoe_.js} +1 -1
- package/dist/client/assets/{User01-CJUJXUar.js → User01-C6Q6FZ5h.js} +1 -1
- package/dist/client/assets/{Users01-DXfhOPWM.js → Users01-BaAnt9k2.js} +1 -1
- package/dist/client/assets/{Users03-BgboQghl.js → Users03-BWAP9RHq.js} +1 -1
- package/dist/client/assets/{X-BsHMY5bm.js → X-OMJfEq4b.js} +1 -1
- package/dist/client/assets/{XCircle-C_yScwcR.js → XCircle-CZr5n04C.js} +1 -1
- package/dist/client/assets/{XClose-CAJh-urJ.js → XClose-DN4fuk7G.js} +1 -1
- package/dist/client/assets/{Zap-dPP-v905.js → Zap-DR-fQuEw.js} +1 -1
- package/dist/client/assets/{ZapSquare-BXCU0Zkc.js → ZapSquare-B6bJc7NY.js} +1 -1
- package/dist/client/assets/{ZoomOut-Z_A5DKtk.js → ZoomOut-DZtqvzaF.js} +1 -1
- package/dist/client/assets/{access-gate-AdoS_2mp.js → access-gate-D0Yziy4K.js} +1 -1
- package/dist/client/assets/{add-section-modal-D_ZZ5oen.js → add-section-modal-7QHISFHk.js} +1 -1
- package/dist/client/assets/{agent-capabilities-Bbkrqncd.js → agent-capabilities-CdrlnYho.js} +1 -1
- package/dist/client/assets/{agent-icon-7Bw2_U9B.js → agent-icon-DvxUJZQr.js} +1 -1
- package/dist/client/assets/agents-list-DqGbI6wK.js +1 -0
- package/dist/client/assets/{ai-providers-Dz-kVb5L.js → ai-providers-BXjxg9pA.js} +1 -1
- package/dist/client/assets/{alert-Bkzkh_iw.js → alert-CpvYl4NL.js} +1 -1
- package/dist/client/assets/{alert-dialog-Byb-84-w.js → alert-dialog-eNWhkEoy.js} +1 -1
- package/dist/client/assets/{app-editor-BHj37cnk.js → app-editor-hzVyG0y7.js} +1 -1
- package/dist/client/assets/{auth-B4QHxlg3.js → auth-CsnJqa1F.js} +1 -1
- package/dist/client/assets/{auth-catchall-BzSqMvEC.js → auth-catchall-DdCNV_zX.js} +1 -1
- package/dist/client/assets/{auth-entry-D_mlfJVE.js → auth-entry-bPX7Q_6Z.js} +1 -1
- package/dist/client/assets/{auth-split-layout-B8OLwRqq.js → auth-split-layout-CmbqYndx.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-BnshO0o5.js → authenticate-and-persist-oauth-B_9_tvH8.js} +1 -1
- package/dist/client/assets/{automation-list-row-BaV_jeUH.js → automation-list-row-BW7BWI_0.js} +1 -1
- package/dist/client/assets/{automation-runs-BTJrtjXJ.js → automation-runs-DuxW2iQ2.js} +1 -1
- package/dist/client/assets/{automations-Biqrif9W.js → automations-CtC6XnpR.js} +1 -1
- package/dist/client/assets/{autosend-DQZl8KyP.js → autosend-7cnPPC-f.js} +1 -1
- package/dist/client/assets/{avatar-Btcoxp_w.js → avatar-ClX7LKnq.js} +1 -1
- package/dist/client/assets/{badge-Be_N2FuK.js → badge-DjjYK3hM.js} +1 -1
- package/dist/client/assets/{block-document-DxWYxLCB.js → block-document-DK7lTXBo.js} +1 -1
- package/dist/client/assets/{brand-context-Dgf9CN4T.js → brand-context-DlN9CIFW.js} +1 -1
- package/dist/client/assets/{breadcrumb-C8UiQMDq.js → breadcrumb-PniBBMek.js} +1 -1
- package/dist/client/assets/{buckets-CybWqIzM.js → buckets-gxzaiz2d.js} +1 -1
- package/dist/client/assets/{bulk-category-panel-BoL-CJ9Q.js → bulk-category-panel-C3uWZXv5.js} +1 -1
- package/dist/client/assets/{calendar-C4lHCPAe.js → calendar-CK3Sat10.js} +1 -1
- package/dist/client/assets/{capability-load-error-pQOhA0uu.js → capability-load-error-DyHBZvtv.js} +1 -1
- package/dist/client/assets/{card-DhyAaYbH.js → card-B59c-zKl.js} +1 -1
- package/dist/client/assets/{category-editor-Bf6cCUx0.js → category-editor-Nlp7pH1k.js} +1 -1
- package/dist/client/assets/{chat-context-CSDQ2V59.js → chat-context-A7nmjc6x.js} +1 -1
- package/dist/client/assets/{checkbox-CAOM_6bX.js → checkbox-B9H3Kcg1.js} +1 -1
- package/dist/client/assets/{cli-auth-success-Dpmw0i2r.js → cli-auth-success-DlMGgqe7.js} +1 -1
- package/dist/client/assets/{collection-detail-Dn9SOp1e.js → collection-detail-BOn69uPs.js} +1 -1
- package/dist/client/assets/{collection-display-button-CHYrGfBD.js → collection-display-button-s_3IDVT0.js} +1 -1
- package/dist/client/assets/{collection-search-Dq5OTSM6.js → collection-search-C1a7Zgcm.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-VRqIBkXR.js → collection-table-wrapper-ByYKvUqb.js} +1 -1
- package/dist/client/assets/{collection-tabs-C-L6t4af.js → collection-tabs-DkseRL6k.js} +1 -1
- package/dist/client/assets/{command-CzaPqse4.js → command-B9xNHDhN.js} +1 -1
- package/dist/client/assets/{commerce-onboarding-CCMdnsEm.js → commerce-onboarding-Bbw-pZSR.js} +1 -1
- package/dist/client/assets/{connect-desktop-dialog-B05P9T9A.js → connect-desktop-dialog-D7Moybni.js} +1 -1
- package/dist/client/assets/{connection-card-uIsG5TxJ.js → connection-card-DeB2bj2L.js} +1 -1
- package/dist/client/assets/{connection-detail-BdYVs7Y7.js → connection-detail-B7hMgi8f.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-BEcWB5x3.js → connection-form-helpers-Bi9IvJ4z.js} +1 -1
- package/dist/client/assets/{connections-Can6s0sB.js → connections-rsSwh4TC.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-C_JJ7Vcr.js → decopilot-sse-pool-DRCw2_hc.js} +1 -1
- package/dist/client/assets/{dialog-DCS2OMH4.js → dialog-BZT5GyRD.js} +1 -1
- package/dist/client/assets/{domain-settings-DWf_GZRj.js → domain-settings-DI0pyWvk.js} +1 -1
- package/dist/client/assets/{drawer-3OE7N_2G.js → drawer-B1mbeoBW.js} +1 -1
- package/dist/client/assets/{dropdown-menu-DcvaX3-F.js → dropdown-menu-VYc_jtsE.js} +1 -1
- package/dist/client/assets/{empty-state-hC3dFQXj.js → empty-state-DdYIETDL.js} +1 -1
- package/dist/client/assets/{extract-connection-data-qlF7ZWrt.js → extract-connection-data-i1upuIiY.js} +1 -1
- package/dist/client/assets/{file-explorer-QRM6gqgi.js → file-explorer-grrkdCaR.js} +1 -1
- package/dist/client/assets/{file-type-icon-DOhIggRJ.js → file-type-icon-BBIUqTz8.js} +1 -1
- package/dist/client/assets/{files-DMPByaM3.js → files-4OV5RCUC.js} +1 -1
- package/dist/client/assets/{form-TXHpDJV5.js → form-DsC2p383.js} +1 -1
- package/dist/client/assets/{general-CBUVeNez.js → general-CyBCG4y2.js} +1 -1
- package/dist/client/assets/github-repo-picker-kM8XNde1.js +1 -0
- package/dist/client/assets/{hooks-BQcGIBer.js → hooks-sbzuLwH3.js} +1 -1
- package/dist/client/assets/{index-CXah3T6b.js → index-5CO29rZe.js} +1 -1
- package/dist/client/assets/{index-BS7P87_E.js → index-93HCuWf6.js} +1 -1
- package/dist/client/assets/{index-7o2IzKac.js → index-BH17km_1.js} +1 -1
- package/dist/client/assets/{index-CZiyq9bL.js → index-BrDZHTLR.js} +3 -3
- package/dist/client/assets/{index-2kogngRp.js → index-Bwu7f1fJ.js} +1 -1
- package/dist/client/assets/{index-AQ-qvM9M.js → index-CIOAd4qO.js} +5 -5
- package/dist/client/assets/{index-BveuunA1.js → index-CYUBf2mm.js} +1 -1
- package/dist/client/assets/index-Ca1LwOX2.js +1 -0
- package/dist/client/assets/{index-Jx11C7Wo.js → index-Ca_J943o.js} +1 -1
- package/dist/client/assets/{index-v5fWJqXW.js → index-CcToIFKw.js} +1 -1
- package/dist/client/assets/{index-BbP2mJoY.js → index-UEam1TE5.js} +1 -1
- package/dist/client/assets/{index-CN-uq_6E.js → index-c1JpYe_A.js} +1 -1
- package/dist/client/assets/{index-CbYZTRTc.js → index-mC3b7Drk.js} +1 -1
- package/dist/client/assets/{index-DBpZEK7p.js → index-qeTrhZ5z.js} +1 -1
- package/dist/client/assets/{index-redirect-D0BYIrK2.js → index-redirect-CLndP6tO.js} +1 -1
- package/dist/client/assets/{input-DnW5bl5u.js → input-C1Kmo3vK.js} +1 -1
- package/dist/client/assets/{integration-icon-BSkS97aB.js → integration-icon-Bpdl0ZYs.js} +1 -1
- package/dist/client/assets/{invite-member-dialog-BaE04Tgl.js → invite-member-dialog-xOG3iMjC.js} +1 -1
- package/dist/client/assets/{label-DeNhnW1K.js → label-DYYJC9Z1.js} +1 -1
- package/dist/client/assets/{login-D7-Umlvc.js → login-Ck3ThVnx.js} +1 -1
- package/dist/client/assets/{mcp-oauth-B6n4lY5H.js → mcp-oauth-D84eIMFG.js} +1 -1
- package/dist/client/assets/{members-D6b_SyPY.js → members-CGpbseRw.js} +1 -1
- package/dist/client/assets/{monaco-editor-CP8nMfPS.js → monaco-editor-fHkuT6U5.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-Bx24pOuR.js → monitoring-stats-row-D_ab5fuA.js} +1 -1
- package/dist/client/assets/{oauth-callback-DpPxlohU.js → oauth-callback-DjpZ1CHA.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-DI_CjOsa.js → oauth-callback-ai-provider-DMGr3Yxu.js} +1 -1
- package/dist/client/assets/{onboarding-DatxqVBu.js → onboarding-DaiEBZfh.js} +1 -1
- package/dist/client/assets/{org-install-CN9xltsE.js → org-install-B592i53z.js} +1 -1
- package/dist/client/assets/{org-layout-CkUoNFto.js → org-layout-BqQo4_yS.js} +1 -1
- package/dist/client/assets/{organization-choice-DsGaGCSI.js → organization-choice-DPAHeOTx.js} +1 -1
- package/dist/client/assets/{page-seo-form-BAwWoCrB.js → page-seo-form-D8fbKZ1h.js} +1 -1
- package/dist/client/assets/page-seo-sheet-CXtm2wdS.js +1 -0
- package/dist/client/assets/{popover-BtkVBk9O.js → popover-CgDNpU8B.js} +1 -1
- package/dist/client/assets/{post-editor-DSGnoUmA.js → post-editor-NfJoTyDC.js} +1 -1
- package/dist/client/assets/{primitives-DaNtYP9L.js → primitives--tVK20cV.js} +1 -1
- package/dist/client/assets/{profile-C0fMGjjc.js → profile-CJ4VFOtj.js} +1 -1
- package/dist/client/assets/project-app-view-C9GFnxtU.js +1 -0
- package/dist/client/assets/record-editor-CgHrbjzN.js +1 -0
- package/dist/client/assets/{registry-layout-BOz2CQvs.js → registry-layout-2FJLNRL3.js} +1 -1
- package/dist/client/assets/registry-ykorVpcK.js +2 -0
- package/dist/client/assets/{require-capability-x8Fj1OOf.js → require-capability-DgRedFhr.js} +1 -1
- package/dist/client/assets/{required-auth-layout-DGg5Hfsv.js → required-auth-layout-DrLP3sOL.js} +1 -1
- package/dist/client/assets/{reset-password-DS17zoPA.js → reset-password-BcmEhh5v.js} +1 -1
- package/dist/client/assets/{roles-Dkepi16W.js → roles-DIxwwmPK.js} +1 -1
- package/dist/client/assets/{search-input-DbIhh1K9.js → search-input-CjSpFSFv.js} +1 -1
- package/dist/client/assets/{secrets-D3_ZBUEY.js → secrets-CbLWjCnY.js} +1 -1
- package/dist/client/assets/{sections-editor-BXA6IVl3.js → sections-editor-BIBNvxJf.js} +1 -1
- package/dist/client/assets/{select-BloW6tH6.js → select-YjEses9D.js} +1 -1
- package/dist/client/assets/{select-model-CXs0fKE0.js → select-model-CgdZqY7t.js} +1 -1
- package/dist/client/assets/{seo-editor-gYApNiNE.js → seo-editor-Cxn7J1o3.js} +1 -1
- package/dist/client/assets/{settings-layout-Dijgs1Xz.js → settings-layout-DTnHKxHy.js} +1 -1
- package/dist/client/assets/{settings-section-C9xZekaQ.js → settings-section-DizG3l8Q.js} +1 -1
- package/dist/client/assets/{shell-controls--WEatP4X.js → shell-controls-J_MoYL7U.js} +1 -1
- package/dist/client/assets/{shell-layout-DzGqfR6q.js → shell-layout-B82J_KPo.js} +1 -1
- package/dist/client/assets/{sidebar-Dvoriw7V.js → sidebar-DFX-m3oC.js} +1 -1
- package/dist/client/assets/{skeleton-Ky3jBeUP.js → skeleton-DqDfsqHy.js} +1 -1
- package/dist/client/assets/{sso-DQVCony7.js → sso-stL1wU3z.js} +1 -1
- package/dist/client/assets/{store-6qk4XsXB.js → store-Xq2n79iO.js} +1 -1
- package/dist/client/assets/store-registry-D6m7tbUD.js +2 -0
- package/dist/client/assets/{studio-tools-rhnNh1x_.js → studio-tools-D0ghBj1q.js} +1 -1
- package/dist/client/assets/{switch-BSaVqgeH.js → switch-C2fH9o8L.js} +1 -1
- package/dist/client/assets/{table-BPvxLDuP.js → table-DbIpX7-0.js} +1 -1
- package/dist/client/assets/{tabs-BwxHAAl0.js → tabs-CVnXbEbf.js} +1 -1
- package/dist/client/assets/{textarea-ByYUJCqn.js → textarea-DiiyNZoM.js} +1 -1
- package/dist/client/assets/{toggle-group-Dh7bEZa1.js → toggle-group-t0AjASu3.js} +1 -1
- package/dist/client/assets/{toolbar-BR5ie4nh.js → toolbar-BiSenxgj.js} +1 -1
- package/dist/client/assets/{toolbar-icon-button-CD0nzSrw.js → toolbar-icon-button-Putd7Z1P.js} +1 -1
- package/dist/client/assets/{tools-list-CfZBf99o.js → tools-list-BKRJivYX.js} +1 -1
- package/dist/client/assets/{tooltip-BvZsaZo1.js → tooltip-Cn3wVH17.js} +1 -1
- package/dist/client/assets/{types-tGK3rxv3.js → types-DJxzgNPE.js} +1 -1
- package/dist/client/assets/{use-ai-providers-Df_6Lv76.js → use-ai-providers-D3-RoSuB.js} +1 -1
- package/dist/client/assets/{use-automations-CX4ke4Gn.js → use-automations-BR5JBwGL.js} +1 -1
- package/dist/client/assets/{use-capability-WrhvLN3Q.js → use-capability-DHjmgTGt.js} +1 -1
- package/dist/client/assets/{use-clock-tick-Co2laZ_v.js → use-clock-tick-DH0G_lc3.js} +1 -1
- package/dist/client/assets/{use-collections-0y8z6h6B.js → use-collections-BYXy-R3E.js} +1 -1
- package/dist/client/assets/{use-connection-D6vKxP6c.js → use-connection-CRDT9Ldi.js} +1 -1
- package/dist/client/assets/{use-copy-DEsN1JWA.js → use-copy-Cz3O5WiP.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-CjfdEFEm.js → use-create-virtual-mcp-4Ix0bA_M.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-ykAA77u8.js → use-debounced-autosave-B0vb-HYP.js} +1 -1
- package/dist/client/assets/{use-debounced-value-BpYGxCFi.js → use-debounced-value-BmUV4CbZ.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-DepdMgPX.js → use-decopilot-events-BaYxDi6g.js} +1 -1
- package/dist/client/assets/{use-delete-connection-DRyaCpbw.js → use-delete-connection-Dr8YUydr.js} +1 -1
- package/dist/client/assets/{use-file-configs-DKRnyJ3w.js → use-file-configs-ChSgKNGP.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-CAwsvAnT.js → use-infinite-scroll-Cc-eI5dW.js} +1 -1
- package/dist/client/assets/{use-join-requests-DDC__CaF.js → use-join-requests-DdIBSZSe.js} +1 -1
- package/dist/client/assets/{use-mcp-client-B3WRhZdt.js → use-mcp-client-Tn0EaYl-.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-C1R-WVFz.js → use-mcp-prompts-D2ADBynP.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-BVxAk373.js → use-mcp-tools-B0s72NAd.js} +1 -1
- package/dist/client/assets/{use-members-Cf18JViN.js → use-members-DQ95-jnU.js} +1 -1
- package/dist/client/assets/{use-mobile-Cpcc36Em.js → use-mobile-KpS88y1x.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-IHN5iTDI.js → use-navigate-to-agent-D9dmHsrm.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-C3YxdmcM.js → use-org-auth-client-Bt8pW8tY.js} +1 -1
- package/dist/client/assets/{use-org-sso-reL-KJxj.js → use-org-sso-Bj7oxuZp.js} +1 -1
- package/dist/client/assets/{use-organization-roles--3C-OX-U.js → use-organization-roles-syk5pt4r.js} +1 -1
- package/dist/client/assets/{use-organization-settings-D6NjaCfk.js → use-organization-settings-CpKXAWmk.js} +1 -1
- package/dist/client/assets/{use-registry-connections-Cs9PospA.js → use-registry-connections-CSbURcZz.js} +1 -1
- package/dist/client/assets/{use-secrets-kk5sLuVp.js → use-secrets--hJvdN8v.js} +1 -1
- package/dist/client/assets/{use-status-sounds-I1tajHMm.js → use-status-sounds-C0yOb1Wm.js} +1 -1
- package/dist/client/assets/{use-view-mode-CEB4Lc4b.js → use-view-mode-C43sfWHy.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-vpIsUoOg.js → use-virtual-mcp-BY7edM8i.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-DMTZr3Km.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-CCpKF6B-.js +1 -0
- package/dist/client/assets/{variant-calendar-BMmdw5vi.js → variant-calendar-FLrb-T5o.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-CjXL0rHJ.js → view-mode-toggle-DbhZEvJk.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -1
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/agents-list-B7x2LOrI.js +0 -1
- package/dist/client/assets/github-repo-picker-ks7lf0Ye.js +0 -1
- package/dist/client/assets/index-B_hBmOqK.js +0 -1
- package/dist/client/assets/page-seo-sheet-DlP_RlkU.js +0 -1
- package/dist/client/assets/project-app-view-D3NA74TU.js +0 -1
- package/dist/client/assets/record-editor-BDKvL12x.js +0 -1
- package/dist/client/assets/registry-DqY4gr9J.js +0 -2
- package/dist/client/assets/store-registry-CBjkyCS6.js +0 -2
- package/dist/client/assets/useInfiniteQuery-oZPFa0FQ.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-fOtFcKQk.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-editor-
|
|
2
|
-
import{p as os,r as C,o as S4,n as w4,c as B,$ as Ae,l as ne,j as i,P as ps,t as de,G as nn,a8 as j4,H as Qt,a9 as h9,V as v1,B as ie,J as f9,I as _1,aa as C4,ab as V4,a1 as sr,ac as fs,ad as Pr,ae as uu,b as Ct,d as Ds,M as Ce,af as k4,ag as nr,ah as N4,Z as b1,ai as y1,K as Qe,aj as Ll,a as vi,ak as A4,al as L1,am as T4,an as Zs,ao as dc,ap as Ri,aq as E4,ar as uc,as as R4,at as P4,au as I4,av as D4,L as m9,aw as M4,ax as O4,ay as $4,az as B4,aA as S1,aB as Kr,k as gs,i as qe,aC as p9,aD as Ge,a6 as w1,aE as zi,aF as Ws,Y as z4,u as Sl,aG as F4,aH as U4,aI as j1,aJ as H4,aK as wl,aL as Fi,aM as C1,aN as K4,aO as W4,aP as V1,aQ as q4,aR as G4,aS as Y4,aT as J4,aU as Xo,e as k1,a7 as X4}from"./index-CZiyq9bL.js";import{i as g9,n as Q4,c as N1}from"./SwitchHorizontal01-ypxOAaEV.js";import{u as xs,a as js,S as Ui,b as ir,c as as,d as A1,s as Z4,e as e5,f as t5,p as T1,g as E1,A as s5,h as n5,i as i5,t as r5,j as o5,k as a5}from"./chat-context-CSDQ2V59.js";import{c as x9,s as rr,g as rn,P as io,d as v9,t as di,a as l5,M as c5,i as d5,b as Ma,e as R1,f as u5,D as h5,h as f5,j as m5,k as Hi,l as p5,u as P1,E as g5,m as _9,n as x5,F as v5,o as I1,p as D1,q as M1,S as _5,r as b5,v as y5,w as L5,x as hu,y as S5,z as O1,O as w5,A as j5,B as Sn,G as C5,T as V5,C as $1,R as k5,H as N5,I as A5,J as T5,K as E5,L as R5}from"./automation-runs-BTJrtjXJ.js";import{c as ro,a as Re,b as Pe,T as Ie}from"./tooltip-BvZsaZo1.js";import{c as ns,a as is,d as Ft,e as Ut,b as qn,D as _i}from"./dialog-DCS2OMH4.js";import{c as P5,b as B1,a as z1,D as F1}from"./drawer-3OE7N_2G.js";import{C as I5}from"./collection-search-Dq5OTSM6.js";import{u as jo}from"./use-mobile-Cpcc36Em.js";import{u as pt,a as D5,m as M5}from"./use-mcp-client-B3WRhZdt.js";import{a as Co,S as b9,i as Oa,c as O5,d as U1,b as fu}from"./constants-B72Xmt_K.js";import{u as H1,g as Vo,l as n0}from"./use-mcp-prompts-C1R-WVFz.js";import{t as Ht}from"./ChevronDown-Ds93wwRe.js";import{i as ms}from"./X-BsHMY5bm.js";import{t as $5,z as B5,b as y9,u as K1}from"./hooks-BQcGIBer.js";import{K as z5,i as W1,u as ko,D as F5,c as q1,a as G1,s as mu,b as U5,m as H5,d as K5,e as W5,f as q5}from"./shell-layout-DzGqfR6q.js";import{a as No,u as qs,b as L9,c as G5}from"./use-virtual-mcp-vpIsUoOg.js";import{w as Y1,A as Y5}from"./autosend-DQZl8KyP.js";import{n as Ki,b as J1}from"./ZapSquare-BXCU0Zkc.js";import{i as Tt}from"./Check-ByMMRPdN.js";import{s as on}from"./Star01-BEjXt6EU.js";import{a as _n,i as J5,b as S9,c as w9,d as j9}from"./Tool01-BjsyNNOX.js";import{g as jl,h as X1,j as C9,k as an,l as V9,m as k9,n as Q1,o as X5,A as Hn,p as Z1,q as em,r as tm,u as Q5,v as Z5,c as sm,w as ex,x as tx,y as sx,z as nx,B as ix,C as rx,D as ox,E as ax,F as lx,G as Gn,H as Dn,I as Wi,J as pu,K as bi,L as N9,M as Ao,N as cx,O as dx,P as nm,Q as $a,R as A9,S as ux,T as im,t as rm,U as Ba,V as hx,W as fx,X as mx,e as om,Y as px,Z as am,_ as gx,$ as Cl,a0 as T9,a1 as lm,a2 as i0,a3 as hc,a4 as gu,a5 as xx,a6 as vx,a7 as _x,a8 as bx,a9 as yx,aa as E9,i as r0,ab as cm,ac as xu,ad as Lx,ae as Sx,af as wx,ag as jx,ah as Cx,ai as Vx,aj as kx,ak as Nx,al as dm,am as Ax,an as Tx}from"./agent-icon-7Bw2_U9B.js";import{i as or}from"./Upload01-pwMs2gu0.js";import{i as fn}from"./AlertCircle-BQoAJ7Pc.js";import{a as Ss}from"./Copy01-Dn74k5DV.js";import{a as o0,b as R9,d as P9,e as I9,F as um}from"./form-TXHpDJV5.js";import{S as $t,a as Bt,b as nt,c as zt,d as Gt}from"./select-BloW6tH6.js";import{b as Vl,i as Ex,a as Rx}from"./Settings02-CO032VQ5.js";import{i as To,t as a0,a as hm,b as Px}from"./XCircle-C_yScwcR.js";import{T as ri,a as Eo,b as $n,c as kl}from"./tabs-BwxHAAl0.js";import{a as fm,T as za}from"./toggle-group-Dh7bEZa1.js";import{I as Ye}from"./input-DnW5bl5u.js";import{u as D9,g as Ro,a as M9,A as mm,c as pm,b as bn,r as Ix,f as Dx,d as Mx}from"./agent-capabilities-Bbkrqncd.js";import{u as Ms}from"./studio-tools-rhnNh1x_.js";import{i as ar}from"./Monitor01-Dj7mHFbg.js";import{u as gm,C as Ox,a as $x,b as Bx,l as zx}from"./connect-desktop-dialog-B05P9T9A.js";import{s as yn}from"./XClose-CAJh-urJ.js";import{m as Nl,i as Fx,g as xm,a as Ux,N as vm,M as Hx}from"./select-model-CXs0fKE0.js";import{e as Fs,a as Ps,f as Kx,b as yi,C as Li,c as Si,d as lr,g as Wx}from"./command-CzaPqse4.js";import{a as Cs,b as Vs,P as ks}from"./popover-BtkVBk9O.js";import{u as _m}from"./useInfiniteQuery-oZPFa0FQ.js";import{D as Zt,a as es,b as Ir,c as ts,d as He,e as oo,f as ao,g as lo,h as l0,i as Po,j as Di}from"./dropdown-menu-DcvaX3-F.js";import{t as Bn}from"./Stars01-CCdr3QPh.js";import{u as Al,a as bm,b as ym,c as qx}from"./use-organization-settings-D6NjaCfk.js";import{f as Gx,a as Yx,d as Lm,b as Jx,u as Xx,c as Qx,e as Zx,g as ev,h as tv,i as sv,F as nv,j as iv,k as rv,l as ov,m as av,n as lv,o as cv,H as dv,L as uv,p as hv,S as fv,B as mv,R as vu,q as pv,r as gv,s as co,T as O9,t as xv}from"./index-CN-uq_6E.js";import{s as Lt}from"./Plus-BdYdKkzh.js";import{p as vv,q as _v}from"./question-004-sINsf4GQ.js";import{i as cn}from"./ChevronRight-BUqzT2AZ.js";import{u as Sm}from"./use-ai-providers-Df_6Lv76.js";import{i as Tl}from"./CheckCircle-uSDvDj68.js";import{n as _u,a as wm,s as jm,b as bv}from"./Loading02-Br4Qsbis.js";import{I as Gs}from"./integration-icon-BSkS97aB.js";import{u as yv}from"./use-status-sounds-I1tajHMm.js";import{E as qi}from"./empty-state-hC3dFQXj.js";import{T as uo}from"./toolbar-BR5ie4nh.js";import{i as $9}from"./SearchLg-BKceB_7Q.js";import{s as ws}from"./Trash01-CkdTj_48.js";import{t as B9}from"./Users01-DXfhOPWM.js";import{i as ui}from"./Zap-dPP-v905.js";import{f as Fa,a as Ua,b as Ha,c as Ka,d as Wa,e as qa,A as Ga,g as Ya}from"./alert-dialog-Byb-84-w.js";import{C as cr}from"./checkbox-CAOM_6bX.js";import{a as Io,b as Lv,c as Sv,d as hi,i as Cm}from"./ZoomOut-Z_A5DKtk.js";import{r as wv,a as bu,p as Vm,f as c0,b as km,c as Nm,d as Am,e as jv,F as Cv,g as Vv,h as kv,i as Nv,j as Av,k as Tv,l as Tm,m as Ev}from"./tab-id-C4S0EPFu.js";import{i as Yn,n as Rv}from"./Globe01-DCyvmziv.js";import{u as Do,a as z9,b as Em}from"./use-connection-D6vKxP6c.js";import{u as El,a as F9,b as Rm}from"./use-mcp-tools-BVxAk373.js";import{g as Rl,M as Pv}from"./types-tGK3rxv3.js";import{e as Pm}from"./backoff-CrEUbyZT.js";import{u as Iv}from"./use-capability-WrhvLN3Q.js";import{F as Gi,M as U9,O as Dv}from"./file-type-icon-DOhIggRJ.js";import{a as Mv}from"./extract-connection-data-qlF7ZWrt.js";import{A as La}from"./avatar-Btcoxp_w.js";import{T as Im,u as Dm}from"./tools-list-CfZBf99o.js";import{a as Ov,i as yu}from"./mcp-oauth-B6n4lY5H.js";import{s as Mm,g as $v}from"./connection-slug-eyAPH6o3.js";import{C as H9,a as Ja}from"./card-DhyAaYbH.js";import{L as Xe}from"./label-DeNhnW1K.js";import{S as ho}from"./switch-BSaVqgeH.js";import{T as Yi}from"./textarea-ByYUJCqn.js";import{i as fi}from"./Play-Ct1jkZWO.js";import{u as Xa}from"./use-debounced-autosave-ykAA77u8.js";import{i as fo}from"./SearchMd-CIebSZD2.js";import{i as Bv}from"./LayoutLeft-Lv2ZhZwN.js";import{P as zs}from"./index-v5fWJqXW.js";import{S as K9}from"./search-input-DbIhh1K9.js";import{C as Om}from"./collection-tabs-C-L6t4af.js";import{i as W9}from"./Key01-CyxwtgAw.js";import{a as q9,G as zv}from"./github-repo-picker-ks7lf0Ye.js";import{S as yt}from"./skeleton-Ky3jBeUP.js";import{s as Fv}from"./User01-CJUJXUar.js";import{u as Uv,a as Hv}from"./use-secrets-kk5sLuVp.js";import{f as $m}from"./formatDistanceToNow-Cb2QZZJn.js";import{u as Kv}from"./use-members-Cf18JViN.js";import{u as Wv,S as qv,T as Gv}from"./index-BbP2mJoY.js";import{m as Yv,n as Jv,o as Xv,p as Qv,q as Zv}from"./sidebar-Dvoriw7V.js";import{n as wn}from"./LinkExternal01-CqYi3PbY.js";import{l as e6,w as t6}from"./index-BS7P87_E.js";import{T as Lu}from"./toolbar-icon-button-CD0nzSrw.js";import{d as s6}from"./delay-CnY5UFtP.js";import{B as n6}from"./badge-Be_N2FuK.js";import{u as Mo,a as i6,b as r6,c as o6,d as a6}from"./use-automations-CX4ke4Gn.js";import{s as Wr}from"./Stars02-RAKDMyiv.js";import{M as Pl}from"./monaco-editor-CP8nMfPS.js";import{A as l6}from"./automation-list-row-BaV_jeUH.js";import{s as Bm}from"./Eye-DMTaYgfE.js";import{C as c6}from"./calendar-C4lHCPAe.js";import{i as d6}from"./List-CjQLqVV2.js";import{i as u6}from"./DotsVertical-OqISO6nN.js";import{u as h6}from"./use-debounced-value-BpYGxCFi.js";import{u as f6,a as zm}from"./use-file-configs-DKRnyJ3w.js";import{i as m6}from"./FilterLines-BmSHEouM.js";function p6(t,e){const s=os(e);return g6({filters:{...t,status:"pending"}},s).length}function Su(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function g6(t={},e){const s=os(e).getMutationCache(),n=C.useRef(t),r=C.useRef(null);return r.current===null&&(r.current=Su(s,t)),C.useEffect(()=>{n.current=t}),C.useSyncExternalStore(C.useCallback(o=>s.subscribe(()=>{const a=S4(r.current,Su(s,n.current));r.current!==a&&(r.current=a,w4.schedule(o))}),[s]),()=>r.current,()=>r.current)}const wu=3,Fm="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",x6="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Um(t){const e=B.c(46),{item:s,onSelect:n,isLoading:r,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const S=rn(c._meta);d=c.title??v9(c.name,S),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const h=d,u=c.description||null;if(l==="card"){let S;e[4]!==n||e[5]!==c?(S=()=>n(c),e[4]=n,e[5]=c,e[6]=S):S=e[6];const j=o||r,V=r&&"bg-accent/40",k=(o||r)&&"cursor-not-allowed opacity-50";let T;e[7]!==V||e[8]!==k?(T=ne(x6,"hover:bg-accent/60 text-foreground",V,k),e[7]=V,e[8]=k,e[9]=T):T=e[9];let A;e[10]!==h?(A=i.jsx("span",{className:"font-medium truncate capitalize",children:h}),e[10]=h,e[11]=A):A=e[11];let N;e[12]!==r?(N=r&&i.jsx(Ui,{size:"xs"}),e[12]=r,e[13]=N):N=e[13];let R;e[14]!==A||e[15]!==N?(R=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A,N]}),e[14]=A,e[15]=N,e[16]=R):R=e[16];let I;e[17]!==u?(I=u&&i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:u}),e[17]=u,e[18]=I):I=e[18];let D;return e[19]!==R||e[20]!==I||e[21]!==S||e[22]!==j||e[23]!==T?(D=i.jsxs("button",{type:"button",onClick:S,disabled:j,className:T,children:[R,I]}),e[19]=R,e[20]=I,e[21]=S,e[22]=j,e[23]=T,e[24]=D):D=e[24],D}let f;e[25]!==n||e[26]!==c?(f=()=>n(c),e[25]=n,e[26]=c,e[27]=f):f=e[27];const m=o||r,p=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let x;e[28]!==p||e[29]!==g?(x=ne(Fm,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=x):x=e[30];let v;e[31]!==h?(v=i.jsx("span",{className:"capitalize",children:h}),e[31]=h,e[32]=v):v=e[32];let _;e[33]!==r?(_=r&&i.jsx(Ui,{size:"xs"}),e[33]=r,e[34]=_):_=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==x||e[38]!==v||e[39]!==_?(b=i.jsx(Re,{asChild:!0,children:i.jsxs("button",{type:"button",onClick:f,disabled:m,className:x,children:[v,_]})}),e[35]=f,e[36]=m,e[37]=x,e[38]=v,e[39]=_,e[40]=b):b=e[40];const y=u??h;let L;e[41]!==y?(L=i.jsx(Pe,{side:"top",className:"max-w-xs",children:i.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=L):L=e[42];let w;return e[43]!==b||e[44]!==L?(w=i.jsxs(Ie,{delayDuration:400,children:[b,L]}),e[43]=b,e[44]=L,e[45]=w):w=e[45],w}function v6(t){const e=B.c(41),{items:s,open:n,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[l,c]=C.useState(""),d=!!a;let h;e[0]!==s||e[1]!==l?(h=l.trim()?s.filter(j=>{const V=l.toLowerCase();return j.prompt.name.toLowerCase().includes(V)||(j.prompt.title??"").toLowerCase().includes(V)||(j.prompt.description??"").toLowerCase().includes(V)}):s,e[0]=s,e[1]=l,e[2]=h):h=e[2];const u=h,f=jo();let m;e[3]!==u.length||e[4]!==l?(m=u.length===0&&i.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=u.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==u||e[7]!==d||e[8]!==a?.name||e[9]!==r||e[10]!==o){let j;e[12]!==d||e[13]!==a?.name||e[14]!==r||e[15]!==o?(j=V=>i.jsx(Um,{item:V,variant:"card",onSelect:k=>{r(!1),o(k)},isLoading:a?.name===V.prompt.name,isDisabled:d&&a?.name!==V.prompt.name},V.prompt.name),e[12]=d,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=j):j=e[16],p=u.map(j),e[6]=u,e[7]=d,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=i.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const x=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=j=>{j.key==="Escape"&&c("")},e[20]=v):v=e[20];let _;e[21]!==l?(_=i.jsx(I5,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=_):_=e[22];const b=_;if(f){let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(P5,{className:"sr-only",children:i.jsx(B1,{children:"All prompts"})}),e[23]=j):j=e[23];let V;e[24]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=V):V=e[24];let k;e[25]!==x||e[26]!==b?(k=i.jsxs(z1,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[j,V,b,x]}),e[25]=x,e[26]=b,e[27]=k):k=e[27];let T;return e[28]!==r||e[29]!==n||e[30]!==k?(T=i.jsx(ro,{delayDuration:400,children:i.jsx(F1,{open:n,onOpenChange:r,children:k})}),e[28]=r,e[29]=n,e[30]=k,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ns,{className:"sr-only",children:i.jsx(is,{children:"All prompts"})}),e[32]=y):y=e[32];let L;e[33]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=L):L=e[33];let w;e[34]!==x||e[35]!==b?(w=i.jsxs(Ft,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,L,b,x]}),e[34]=x,e[35]=b,e[36]=w):w=e[36];let S;return e[37]!==r||e[38]!==n||e[39]!==w?(S=i.jsx(ro,{delayDuration:400,children:i.jsx(Ut,{open:n,onOpenChange:r,children:w})}),e[37]=r,e[38]=n,e[39]=w,e[40]=S):S=e[40],S}function _6(t){const e=B.c(29),{items:s,onSelect:n,loadingPrompt:r,className:o}=t,[a,l]=C.useState(!1);if(s.length===0)return null;let c,d,h;if(e[0]!==s||e[1]!==r||e[2]!==n){const v=s.slice(0,wu);let _;e[6]!==s?(_=s.slice(wu),e[6]=s,e[7]=_):_=e[7],c=_,d=!!r;let b;e[8]!==d||e[9]!==r?.name||e[10]!==n?(b=y=>i.jsx(Um,{item:y,onSelect:n,isLoading:r?.name===y.prompt.name,isDisabled:d&&r?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=r?.name,e[10]=n,e[11]=b):b=e[11],h=v.map(b),e[0]=s,e[1]=r,e[2]=n,e[3]=c,e[4]=d,e[5]=h}else c=e[3],d=e[4],h=e[5];const u=h;let f;e[12]!==o?(f=ne("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&i.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:ne(Fm,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==u||e[18]!==f||e[19]!==m?(p=i.jsxs("div",{className:f,children:[u,m]}),e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==n?(g=i.jsx(v6,{items:s,open:a,onOpenChange:l,onSelect:n,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=n,e[25]=g):g=e[25];let x;return e[26]!==p||e[27]!==g?(x=i.jsxs(ro,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=x):x=e[28],x}function b6(){return null}function y6(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 L6(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:n}=js(),{org:r}=Ae();let o;e[0]!==s||e[1]!==r.id||e[2]!==r.slug?(o={connectionId:s,orgId:r.id,orgSlug:r.slug},e[0]=s,e[1]=r.id,e[2]=r.slug,e[3]=o):o=e[3];const a=pt(o);let l;e[4]!==a?(l={client:a,staleTime:6e4},e[4]=a,e[5]=l):l=e[5];const{data:c}=H1(l);let d;e[6]!==c?.prompts?(d=c?.prompts??[],e[6]=c?.prompts,e[7]=d):d=e[7];const h=d;let u;e[8]!==h?(u=h.map(S6),e[8]=h,e[9]=u):u=e[9];const f=u;let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m={stage:"idle"},e[10]=m):m=e[10];const[p,g]=C.useReducer(y6,m),[x,v]=C.useState(null);let _;e[11]!==a||e[12]!==n?(_=async(N,R)=>{if(!a){de.error("MCP client not available"),g({type:"RESET"});return}try{const I=await Vo(a,N.name,R);g({type:"RESET"});const D={type:"doc",content:[{type:"paragraph",content:[x9({id:N.name,name:rr(N.name,rn(N._meta)),metadata:I.messages,char:"/",kind:"prompt",args:R}),{type:"text",text:" "}]}]};await n(D)}catch(I){console.error("[ice-breakers] Failed to fetch prompt:",I),de.error("Failed to load prompt. Please try again."),g({type:"RESET"})}},e[11]=a,e[12]=n,e[13]=_):_=e[13];const b=_;let y;e[14]!==b?(y=async N=>{if(N.arguments&&N.arguments.length>0){g({type:"SELECT_PROMPT",prompt:N}),v(N);return}g({type:"START_LOADING",prompt:N}),await b(N)},e[14]=b,e[15]=y):y=e[15];const L=y;let w;e[16]!==x||e[17]!==b?(w=async N=>{x&&(g({type:"START_LOADING",prompt:x,arguments:N}),v(null),await b(x,N))},e[16]=x,e[17]=b,e[18]=w):w=e[18];const S=w;if(f.length===0)return null;const j=p.stage==="loading"?p.prompt:null;let V;e[19]!==L||e[20]!==f||e[21]!==j?(V=i.jsx(_6,{items:f,onSelect:L,loadingPrompt:j}),e[19]=L,e[20]=f,e[21]=j,e[22]=V):V=e[22];let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{v(null),g({type:"RESET"})},e[23]=k):k=e[23];let T;e[24]!==x||e[25]!==S?(T=i.jsx(io,{prompt:x,setPrompt:k,onSubmit:S}),e[24]=x,e[25]=S,e[26]=T):T=e[26];let A;return e[27]!==V||e[28]!==T?(A=i.jsxs(i.Fragment,{children:[V,T]}),e[27]=V,e[28]=T,e[29]=A):A=e[29],A}function S6(t){return{prompt:t}}function w6(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:n}=xs(),{org:r}=Ae();let o;e[0]!==r.id?(o=Co(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,l=n?.id??a;let c;e[2]!==s?(c=ne("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(b6,{}),e[4]=h):h=e[4];let u;e[5]!==l?(u=i.jsx(L6,{connectionId:l}),e[5]=l,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=i.jsx(ps,{fallback:null,children:i.jsx(C.Suspense,{fallback:h,children:u},d)}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=i.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}const fc="cubic-bezier(0.645, 0.045, 0.355, 1)",j6=44,C6={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"},V6={default:"border-border",error:"border-destructive/30",warning:"border-amber-500/30"},k6={default:"text-muted-foreground",error:"text-destructive",warning:"text-amber-600 dark:text-amber-500"};function Kn(t){const e=B.c(61),{icon:s,label:n,count:r,title:o,footerLeft:a,footerRight:l,children:c,defaultExpanded:d,variant:h,onClose:u}=t,f=h===void 0?"default":h,[m,p]=C.useState(d),[g,x]=C.useState(!1);let v;e[0]!==u?(v=()=>{x(!0),u?.()},e[0]=u,e[1]=v):v=e[1];const _=v;if(g)return null;const b=V6[f],y=C6[f];let L;e[2]!==b||e[3]!==y?(L=ne("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",b,y),e[2]=b,e[3]=y,e[4]=L):L=e[4];let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>p(N6),e[5]=w):w=e[5];const S=m&&"rounded-b-none",j=!m&&"rounded-b-xl";let V;e[6]!==S||e[7]!==j?(V=ne("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",S,j),e[6]=S,e[7]=j,e[8]=V):V=e[8];const k=k6[f];let T;e[9]!==k?(T=ne("shrink-0",k),e[9]=k,e[10]=T):T=e[10];let A;e[11]!==s||e[12]!==T?(A=i.jsx("span",{className:T,children:s}),e[11]=s,e[12]=T,e[13]=A):A=e[13];let N;e[14]!==n?(N=i.jsx("span",{className:"flex-1 min-w-0 truncate",children:n}),e[14]=n,e[15]=N):N=e[15];let R;e[16]!==r?(R=r?i.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:r}):null,e[16]=r,e[17]=R):R=e[17];const I=m?"rotate(180deg)":"rotate(0deg)";let D;e[18]!==I?(D=i.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:i.jsx(Ht,{size:16,style:{transform:I,transition:`transform 180ms ${fc}`}})}),e[18]=I,e[19]=D):D=e[19];let E,P;e[20]!==_?(E=Z=>{Z.stopPropagation(),_()},P=Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),Z.stopPropagation(),_())},e[20]=_,e[21]=E,e[22]=P):(E=e[21],P=e[22]);let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx(ms,{size:16}),e[23]=M):M=e[23];let z;e[24]!==E||e[25]!==P?(z=i.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":"Close",title:"Close",onClick:E,onKeyDown:P,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:M}),e[24]=E,e[25]=P,e[26]=z):z=e[26];let $;e[27]!==m||e[28]!==A||e[29]!==N||e[30]!==R||e[31]!==D||e[32]!==z||e[33]!==V?($=i.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":m,onClick:w,className:V,children:[A,N,R,D,z]}),e[27]=m,e[28]=A,e[29]=N,e[30]=R,e[31]=D,e[32]=z,e[33]=V,e[34]=$):$=e[34];const O=m?"1fr":"0fr";let U;e[35]!==O?(U={display:"grid",gridTemplateRows:O,transition:`grid-template-rows 180ms ${fc}`},e[35]=O,e[36]=U):U=e[36];let H;e[37]===Symbol.for("react.memo_cache_sentinel")?(H={overflow:"hidden",minHeight:0},e[37]=H):H=e[37];const Y=m?1:0;let G;e[38]!==Y?(G={opacity:Y,transition:`opacity 120ms ${fc}`},e[38]=Y,e[39]=G):G=e[39];let K;e[40]!==o?(K=o?i.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:i.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):i.jsx("div",{className:"border-t border-dashed border-border/60"}),e[40]=o,e[41]=K):K=e[41];let q;e[42]!==c||e[43]!==o?(q=c?i.jsx("div",{className:ne("overflow-clip pb-4",!o&&"pt-4"),children:c}):null,e[42]=c,e[43]=o,e[44]=q):q=e[44];let W;e[45]!==a||e[46]!==l?(W=a||l?i.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{children:a}),i.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[45]=a,e[46]=l,e[47]=W):W=e[47];let F;e[48]!==G||e[49]!==K||e[50]!==q||e[51]!==W?(F=i.jsx("div",{style:H,children:i.jsxs("div",{style:G,children:[K,q,W]})}),e[48]=G,e[49]=K,e[50]=q,e[51]=W,e[52]=F):F=e[52];let X;e[53]!==U||e[54]!==F?(X=i.jsx("div",{"data-testid":"collapsible-highlight-body",style:U,children:F}),e[53]=U,e[54]=F,e[55]=X):X=e[55];let Q;return e[56]!==$||e[57]!==X||e[58]!==L||e[59]!==f?(Q=i.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":f,className:L,children:[$,X]}),e[56]=$,e[57]=X,e[58]=L,e[59]=f,e[60]=Q):Q=e[60],Q}function N6(t){return!t}const A6=nn({content:Qt().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:h9(["pending","in_progress","completed"]),activeForm:Qt().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),Hm=nn({todos:j4(A6)}),T6="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.";$5({description:T6,inputSchema:B5(Hm),execute:async({todos:t})=>({ok:!0,count:t.length})});const E6="tool-todo_write",R6=new Set(["input-available","output-available"]);function Km(t){for(let e=t.length-1;e>=0;e--){const s=t[e];if(s.role!=="assistant")continue;const n=s.parts;if(Array.isArray(n))for(let r=n.length-1;r>=0;r--){const o=n[r];if(o.type!==E6||typeof o.state!="string"||!R6.has(o.state))continue;const a=Hm.safeParse(o.input);if(a.success)return a.data.todos}}return[]}function Wm(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const n="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:n,friendlyName:di(l5(n)),input:s.input})}return e}function qm(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const n=s.input;e.push({toolCallId:s.toolCallId,plan:n.plan,state:s.state})}return e}function P6(t){return t?t.message.startsWith("[CREDITS]"):!1}const I6={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1};function D6(t){const{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=t;if(!r&&s&&P6(s))return{...I6,isCreditExhausted:!0};const a=e.at(-1),l=a?.role==="assistant"?a.parts:[],c=l,h=!!c.filter(b=>b.type==="tool-user_ask").filter(b=>b.state!=="output-available").length,u=qm(l),f=Wm(c),m=Km(e),p=!r&&!!s,g=f.length>0||r&&o,x=u.length>0,_=!r&&!!n&&n!=="stop"&&!(n==="tool-calls"&&(h||g||x))&&!p;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:p,showWarning:_,hasApprovals:g,hasPlans:x,isWaitingForUserInput:h}}function Gm(){const t=B.c(6),{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=js(),a=s??null,l=n??null;let c;return t[0]!==r||t[1]!==o||t[2]!==e||t[3]!==a||t[4]!==l?(c=D6({messages:e,error:a,finishReason:l,isStreaming:r,isWaitingForApprovals:o}),t[0]=r,t[1]=o,t[2]=e,t[3]=a,t[4]=l,t[5]=c):c=t[5],c}function M6(){const t=Gm();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function Ym(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(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}const O6="__home__";function G9(t,e){return v1.chatDraft(t,e)}function $6(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 s=e.tiptapDoc;return!s||typeof s!="object"||s.type!=="doc"||!Array.isArray(s.content)?null:s}function B6(t,e,s,n,r){const o=G9(e,s);if(Ym(n)){t.removeItem(o);return}const a={tiptapDoc:n,updatedAt:Date.now()},l=JSON.stringify(a);try{t.setItem(o,l)}catch(c){if(F6(c)){const d=new TextEncoder().encode(l).byteLength;r?.onQuotaExceeded?.({docSizeBytes:d});return}throw c}}function ju(t,e,s){const n=G9(e,s),r=t.getItem(n),o=$6(r);return r!==null&&o===null&&t.removeItem(n),o}function z6(t,e,s){t.removeItem(G9(e,s))}function F6(t){if(!t||typeof t!="object")return!1;const e=t.name;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"}function U6(t){const e=B.c(21),{current:s,total:n,onPrev:r,onNext:o}=t;if(n<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=ne("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Vl,{size:14}),e[2]=d):d=e[2];let h;e[3]!==r||e[4]!==a||e[5]!==c?(h=i.jsx("button",{type:"button",onClick:r,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=a,e[5]=c,e[6]=h):h=e[6];const u=s+1;let f;e[7]!==u||e[8]!==n?(f=i.jsxs("span",{className:"tabular-nums text-xs",children:[u," of ",n]}),e[7]=u,e[8]=n,e[9]=f):f=e[9];const m=s===n-1,p=s===n-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=ne("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(To,{size:14}),e[12]=x):x=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=i.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:x}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let _;return e[17]!==v||e[18]!==h||e[19]!==f?(_=i.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[h,f,v]}),e[17]=v,e[18]=h,e[19]=f,e[20]=_):_=e[20],_}function Jm(t){const e=B.c(8),{currentIndex:s,total:n,onPrev:r,onNext:o,extraLeft:a}=t;let l;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==n?(l=i.jsx(U6,{current:s,total:n,onPrev:r,onNext:o}),e[0]=s,e[1]=o,e[2]=r,e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=i.jsxs("div",{className:"flex items-center gap-2",children:[l,a]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function H6(t){const e=B.c(17),{isStreaming:s,isAllAnswered:n,isCurrentAnswered:r,onAdvanceOrSubmit:o,submitLabel:a,nextLabel:l}=t,h=n?a===void 0?"Submit":a:l===void 0?"Next":l,u=n?s:!r,f=u?n?"Waiting for the assistant to finish…":"Answer this item to continue":null;let m;e[0]!==u||e[1]!==o?(m=()=>{u||o()},e[0]=u,e[1]=o,e[2]=m):m=e[2];const p=u&&"opacity-50 cursor-not-allowed";let g;e[3]!==p?(g=ne("h-7 px-2.5 text-xs",p),e[3]=p,e[4]=g):g=e[4];let x;e[5]!==u||e[6]!==h||e[7]!==m||e[8]!==g?(x=i.jsx(ie,{type:"button",size:"sm","aria-disabled":u,onClick:m,className:g,children:h}),e[5]=u,e[6]=h,e[7]=m,e[8]=g,e[9]=x):x=e[9];const v=x;if(!f)return v;let _;e[10]!==v?(_=i.jsx(Re,{asChild:!0,children:v}),e[10]=v,e[11]=_):_=e[11];let b;e[12]!==f?(b=i.jsx(Pe,{children:f}),e[12]=f,e[13]=b):b=e[13];let y;return e[14]!==_||e[15]!==b?(y=i.jsxs(Ie,{children:[_,b]}),e[14]=_,e[15]=b,e[16]=y):y=e[16],y}function Xm(t,e,s){return t.findIndex(n=>e(n)===s)}function Cu(t,e,s,n){return t.length===0?!1:t.every(r=>n(s[e(r)]))}function Vu(t,e,s,n,r){if(t.length===0)return null;const o=Xm(t,e,r);for(let a=1;a<=t.length;a++){const l=t[(o+a)%t.length];if(!l)continue;const c=e(l);if(c!==r&&!n(s[c]))return c}return null}function K6(t){return!t.isStreaming&&t.allAnswered}function Qm(t){const{parts:e,partKey:s,schema:n,defaultValues:r,isStreaming:o,hasAnswer:a,onSubmit:l}=t,c=e[0]?s(e[0]):"",[d,h]=C.useState(c),[u,f]=C.useState(!1),m=f9({resolver:_1(n),defaultValues:r}),p=m.watch(),g=Xm(e,s,d),x=g>=0?e[g]:void 0,v=a(p[d]),_=Cu(e,s,p,a),b=K6({isStreaming:o,allAnswered:_}),y=()=>{if(g>0){const T=e[g-1];T&&h(s(T))}},L=()=>{if(g>=0&&g<e.length-1){const T=e[g+1];T&&h(s(T))}},w=()=>{const T=m.getValues(),A=Vu(e,s,T,a,d);A&&h(A)},S=()=>{m.handleSubmit(T=>{const A=T;for(const N of e)l(N,A[s(N)])})()},j=C.useRef(S);j.current=S;const V=()=>{b&&(f(!1),j.current())},k=()=>{const T=m.getValues();if(Cu(e,s,T,a)){if(o){f(!0);return}f(!1),j.current()}else{const A=Vu(e,s,T,a,d);A&&h(A)}};return C.useEffect(()=>{if(u&&!o){if(!_){f(!1);return}f(!1),j.current()}},[u,o,_]),{form:m,activeKey:d,setActiveKey:h,currentIndex:g,currentPart:x,isCurrentAnswered:v,isAllAnswered:_,canSubmit:b,goPrev:y,goNext:L,advanceToNextUnanswered:w,submit:V,submitOrAdvance:k}}const Zm="User denied this tool call, give other alternatives.";function e2(t){const e=B.c(9),{onYolo:s}=t,[n,r]=sr();let o;e[0]!==s||e[1]!==n||e[2]!==r?(o=h=>{const u=h,f=n.toolApprovalLevel??"readonly";r({...n,toolApprovalLevel:u}),u==="auto"&&s(f)},e[0]=s,e[1]=n,e[2]=r,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(zt,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:q6,children:i.jsx(Gt,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx($t,{children:Pr.map(W6)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==n.toolApprovalLevel?(d=i.jsxs(Bt,{value:n.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=n.toolApprovalLevel,e[8]=d):d=e[8],d}function W6(t){return i.jsx(nt,{value:t.value,children:t.label},t.value)}function q6(t){return t.stopPropagation()}function t2(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let n;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],n=o}catch{n=String(s)}let r;return e[3]!==n?(r=i.jsx("div",{className:"px-4",children:i.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:n})}),e[3]=n,e[4]=r):r=e[4],r}function G6(t){const e=B.c(28),{approval:s,onRespond:n}=t,[r]=sr(),o=r.toolApprovalLevel??"readonly";let a;e[0]!==s.approvalId||e[1]!==o||e[2]!==n?(a=()=>n(s.approvalId,!1,Zm,o),e[0]=s.approvalId,e[1]=o,e[2]=n,e[3]=a):a=e[3];const l=a;let c;e[4]!==s.approvalId||e[5]!==o||e[6]!==n?(c=()=>n(s.approvalId,!0,void 0,o),e[4]=s.approvalId,e[5]=o,e[6]=n,e[7]=c):c=e[7];const d=c;let h;e[8]!==s.approvalId||e[9]!==n?(h=L=>n(s.approvalId,!0,void 0,L),e[8]=s.approvalId,e[9]=n,e[10]=h):h=e[10];const u=h;let f;e[11]!==u?(f=i.jsx("div",{className:"flex items-center gap-2",children:i.jsx(e2,{onYolo:u})}),e[11]=u,e[12]=f):f=e[12];const m=f;let p;e[13]!==l?(p=i.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:l,children:"Deny"}),e[13]=l,e[14]=p):p=e[14];let g;e[15]!==d?(g=i.jsx(ie,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:d,children:"Accept"}),e[15]=d,e[16]=g):g=e[16];let x;e[17]!==p||e[18]!==g?(x=i.jsxs(i.Fragment,{children:[p,g]}),e[17]=p,e[18]=g,e[19]=x):x=e[19];const v=x;let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(jl,{size:14}),e[20]=_):_=e[20];let b;e[21]!==s.input?(b=i.jsx(t2,{input:s.input}),e[21]=s.input,e[22]=b):b=e[22];let y;return e[23]!==s.friendlyName||e[24]!==m||e[25]!==v||e[26]!==b?(y=i.jsx(Kn,{icon:_,label:"Approval needed",title:s.friendlyName,defaultExpanded:!0,footerLeft:m,footerRight:v,children:b}),e[23]=s.friendlyName,e[24]=m,e[25]=v,e[26]=b,e[27]=y):y=e[27],y}const Y6=C4(Qt(),nn({approved:V4().optional(),levelOverride:h9(["auto","readonly"]).optional()}));function J6(t){const e=B.c(42),{approvals:s,isStreaming:n,onRespond:r}=t,[o]=sr(),a=o.toolApprovalLevel??"readonly";let l;e[0]!==s?(l=Object.fromEntries(s.map(Z6)),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]!==a||e[3]!==r?(d=(k,T)=>{const A=T;typeof A?.approved=="boolean"&&r(k.approvalId,A.approved,A.approved===!1?Zm:void 0,A.levelOverride??a)},e[2]=a,e[3]=r,e[4]=d):d=e[4];let h;e[5]!==s||e[6]!==c||e[7]!==n||e[8]!==d?(h={parts:s,partKey:Q6,schema:Y6,defaultValues:c,isStreaming:n,hasAnswer:X6,onSubmit:d},e[5]=s,e[6]=c,e[7]=n,e[8]=d,e[9]=h):h=e[9];const u=Qm(h);let f;e[10]!==s||e[11]!==u?(f=k=>{u.form.reset(Object.fromEntries(s.map(T=>[T.approvalId,{approved:!0,levelOverride:k}]))),u.submitOrAdvance()},e[10]=s,e[11]=u,e[12]=f):f=e[12];const m=f,p=u.currentPart;let g;e[13]!==u?(g=k=>{k.preventDefault(),u.submit()},e[13]=u,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(jl,{size:14}),e[15]=x):x=e[15];const v=`${s.length} approvals pending`,_=p?.friendlyName??"";let b;e[16]!==m?(b=i.jsx(e2,{onYolo:m}),e[16]=m,e[17]=b):b=e[17];let y;e[18]!==s.length||e[19]!==u.currentIndex||e[20]!==u.goNext||e[21]!==u.goPrev||e[22]!==b?(y=i.jsx(Jm,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext,extraLeft:b}),e[18]=s.length,e[19]=u.currentIndex,e[20]=u.goNext,e[21]=u.goPrev,e[22]=b,e[23]=y):y=e[23];let L;e[24]!==p||e[25]!==u.form.control||e[26]!==u.submitOrAdvance?(L=p?i.jsx(e_,{approvalId:p.approvalId,control:u.form.control,onChange:u.submitOrAdvance}):null,e[24]=p,e[25]=u.form.control,e[26]=u.submitOrAdvance,e[27]=L):L=e[27];let w;e[28]!==p?(w=p?i.jsx(t2,{input:p.input}):null,e[28]=p,e[29]=w):w=e[29];let S;e[30]!==y||e[31]!==L||e[32]!==w||e[33]!==v||e[34]!==_?(S=i.jsx(Kn,{icon:x,label:v,title:_,defaultExpanded:!0,footerLeft:y,footerRight:L,children:w}),e[30]=y,e[31]=L,e[32]=w,e[33]=v,e[34]=_,e[35]=S):S=e[35];let j;e[36]!==S||e[37]!==g?(j=i.jsx("form",{onSubmit:g,children:S}),e[36]=S,e[37]=g,e[38]=j):j=e[38];let V;return e[39]!==u.form||e[40]!==j?(V=i.jsx(o0,{...u.form,children:j}),e[39]=u.form,e[40]=j,e[41]=V):V=e[41],V}function X6(t){return typeof t?.approved=="boolean"}function Q6(t){return t.approvalId}function Z6(t){return[t.approvalId,{approved:void 0}]}function e_(t){const e=B.c(6),{approvalId:s,control:n,onChange:r}=t,o=`${s}.approved`;let a;e[0]!==r?(a=c=>{const{field:d}=c,h=d.value===!0,u=d.value===!1;return i.jsxs(i.Fragment,{children:[i.jsx(ie,{type:"button",variant:u?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!1),r()},"aria-pressed":u,children:"Deny"}),i.jsx(ie,{type:"button",variant:h?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!0),r()},"aria-pressed":h,children:"Accept"})]})},e[0]=r,e[1]=a):a=e[1];let l;return e[2]!==n||e[3]!==o||e[4]!==a?(l=i.jsx(fs,{control:n,name:o,render:a}),e[2]=n,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function t_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.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:[i.jsx(jl,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function s_(t){const e=B.c(8),{approvals:s,isStreaming:n,onRespond:r}=t;if(n&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(t_,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;if(s.length===1){const a=s[0];if(!a)return null;let l;return e[1]!==r||e[2]!==a?(l=i.jsx(G6,{approval:a,onRespond:r}),e[1]=r,e[2]=a,e[3]=l):l=e[3],l}let o;return e[4]!==s||e[5]!==n||e[6]!==r?(o=i.jsx(J6,{approvals:s,isStreaming:n,onRespond:r}),e[4]=s,e[5]=n,e[6]=r,e[7]=o):o=e[7],o}function n_(t){const e=B.c(16),{plan:s,onApprove:n,onDismiss:r}=t;let o;e[0]!==n||e[1]!==s.plan?(o=()=>{n(s.plan)},e[0]=n,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==r?(l=i.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:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let c;e[5]!==a?(c=i.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]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=i.jsxs(i.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const h=d;let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(X1,{size:14}),e[10]=u):u=e[10];let f;e[11]!==s.plan?(f=i.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:i.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:i.jsx(c5,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[11]=s.plan,e[12]=f):f=e[12];let m;return e[13]!==h||e[14]!==f?(m=i.jsx(Kn,{icon:u,label:"Plan ready",title:"Implementation Plan",defaultExpanded:!0,footerRight:h,children:f}),e[13]=h,e[14]=f,e[15]=m):m=e[15],m}function i_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.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:[i.jsx(Tt,{className:"size-5 text-purple-500 shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function r_(t){const e=B.c(7),{plans:s,isStreaming:n,onApprove:r,onDismiss:o}=t;if(n&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(i_,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==r||e[5]!==o?(c=i.jsx(n_,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function s2(t){return t?"response"in t?t.response:t.option??t.draft:""}const ku=nn({response:Qt().min(1,"Response is required")}),o_=nn({option:Qt().nullable(),draft:Qt()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),a_=nn({response:h9(["yes","no"])});function l_(t){switch(t.type){case"text":return ku;case"choice":return o_;case"confirm":return a_;default:return ku}}function c_(t){const e={};for(const s of t)e[s.toolCallId]=l_(s.input);return nn(e)}function d_(t){const e=B.c(6),{control:s,name:n,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:c}=l,d=c.value??"";return i.jsxs(R9,{children:[i.jsx(P9,{children:i.jsx("div",{className:"px-2",children:i.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(C9,{size:16,className:"text-muted-foreground"})}),i.jsx("input",{...c,value:d,type:"text",placeholder:r||"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"})]})})}),i.jsx(I9,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==n||e[4]!==o?(a=i.jsx(um,{control:s,name:n,render:o}),e[2]=s,e[3]=n,e[4]=o,e[5]=a):a=e[5],a}function n2(t,e){const s=B.c(4);let n,r;s[0]!==t||s[1]!==e?(n=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],s[0]=t,s[1]=e,s[2]=n,s[3]=r):(n=s[2],r=s[3]),C.useEffect(n,r)}function u_(t){const e=B.c(40),{control:s,name:n,options:r}=t,o=`${n}.option`;let a;e[0]!==s||e[1]!==o?(a={control:s,name:o,defaultValue:null},e[0]=s,e[1]=o,e[2]=a):a=e[2];const{field:l}=uu(a),c=`${n}.draft`;let d;e[3]!==s||e[4]!==c?(d={control:s,name:c,defaultValue:""},e[3]=s,e[4]=c,e[5]=d):d=e[5];const{field:h}=uu(d),u=l.value,f=h.value??"";let m;if(e[6]!==l||e[7]!==r?(m=A=>{const N=r[A];N!=null&&l.onChange(N)},e[6]=l,e[7]=r,e[8]=m):m=e[8],n2(r.length,m),r.length===0)return null;const p=u===null;let g;if(e[9]!==l||e[10]!==u||e[11]!==r){let A;e[13]!==l||e[14]!==u?(A=(N,R)=>{const I=u===N;return i.jsxs("button",{type:"button",onClick:()=>l.onChange(N),className:ne("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",I&&"bg-accent/50",!I&&"hover:bg-accent/30"),"aria-label":`Select ${N}`,children:[i.jsx("span",{className:ne("flex items-center justify-center size-6 rounded-md text-sm shrink-0",I?"bg-chart-1 text-white":"bg-muted text-foreground"),children:R+1}),i.jsx("span",{className:"text-sm text-foreground truncate",children:N})]},`${R}-${N}`)},e[13]=l,e[14]=u,e[15]=A):A=e[15],g=r.map(A),e[9]=l,e[10]=u,e[11]=r,e[12]=g}else g=e[12];const x=p&&"bg-accent/50",v=!p&&"hover:bg-accent/30";let _;e[16]!==x||e[17]!==v?(_=ne("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",x,v),e[16]=x,e[17]=v,e[18]=_):_=e[18];let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(C9,{size:16,className:"text-muted-foreground"})}),e[19]=b):b=e[19];const y=p?f:"";let L;e[20]!==h||e[21]!==l||e[22]!==u?(L=A=>{h.onChange(A.target.value),u!==null&&l.onChange(null)},e[20]=h,e[21]=l,e[22]=u,e[23]=L):L=e[23];let w;e[24]!==l||e[25]!==u?(w=()=>{u!==null&&l.onChange(null)},e[24]=l,e[25]=u,e[26]=w):w=e[26];let S;e[27]!==y||e[28]!==L||e[29]!==w?(S=i.jsx("input",{type:"text",value:y,onChange:L,onFocus:w,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]=y,e[28]=L,e[29]=w,e[30]=S):S=e[30];let j;e[31]!==S||e[32]!==_?(j=i.jsxs("label",{className:_,children:[b,S]}),e[31]=S,e[32]=_,e[33]=j):j=e[33];let V;e[34]!==j||e[35]!==g?(V=i.jsx(P9,{children:i.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[g,j]})}),e[34]=j,e[35]=g,e[36]=V):V=e[36];let k;e[37]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx(I9,{}),e[37]=k):k=e[37];let T;return e[38]!==V?(T=i.jsxs(R9,{children:[V,k]}),e[38]=V,e[39]=T):T=e[39],T}function h_(t){const e=B.c(6),{control:s,name:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=C.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=h=>{a.current?.onChange(o[h]??"")},e[1]=l):l=e[1],n2(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=h=>{const{field:u}=h;return a.current=u,i.jsxs(R9,{children:[i.jsx(P9,{children:i.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=u.value===f;return i.jsxs("button",{type:"button",onClick:()=>u.onChange(f),className:ne("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 ${f}`,children:[i.jsx("span",{className:ne("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),i.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),i.jsx(I9,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==n?(d=i.jsx(um,{control:s,name:n,render:c}),e[3]=s,e[4]=n,e[5]=d):d=e[5],d}function Nu(t){const e=B.c(13),{input:s,control:n,toolCallId:r}=t;switch(s.type){case"text":{const o=`${r}.response`;let a;return e[0]!==n||e[1]!==s.default||e[2]!==o?(a=i.jsx(d_,{control:n,name:o,placeholder:s.default}),e[0]=n,e[1]=s.default,e[2]=o,e[3]=a):a=e[3],a}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==n||e[7]!==a||e[8]!==r?(l=i.jsx(u_,{control:n,name:r,options:a}),e[6]=n,e[7]=a,e[8]=r,e[9]=l):l=e[9],l}case"confirm":{const o=`${r}.response`;let a;return e[10]!==n||e[11]!==o?(a=i.jsx(h_,{control:n,name:o}),e[10]=n,e[11]=o,e[12]=a):a=e[12],a}default:return null}}function f_(t){const e=B.c(71),{parts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=c_(s.map(x_)),e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=Object.fromEntries(s.map(g_)),e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==r?(d=(E,P)=>{const M=s2(P);M&&r(E,M)},e[4]=r,e[5]=d):d=e[5];let h;e[6]!==c||e[7]!==n||e[8]!==s||e[9]!==a||e[10]!==d?(h={parts:s,partKey:p_,schema:a,defaultValues:c,isStreaming:n,hasAnswer:m_,onSubmit:d},e[6]=c,e[7]=n,e[8]=s,e[9]=a,e[10]=d,e[11]=h):h=e[11];const u=Qm(h),f=u.currentPart;let m;e[12]!==f||e[13]!==u?(m=()=>{const E=f;if(!E)return;const P=E.toolCallId;E.input?.type==="choice"?(u.form.setValue(`${P}.option`,null),u.form.setValue(`${P}.draft`,"user has skip this question")):u.form.setValue(`${P}.response`,"user has skip this question"),u.advanceToNextUnanswered()},e[12]=f,e[13]=u,e[14]=m):m=e[14];const p=m;let g;e[15]!==u.currentIndex||e[16]!==u.goNext||e[17]!==u.goPrev||e[18]!==s.length?(g=i.jsx(Jm,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext}),e[15]=u.currentIndex,e[16]=u.goNext,e[17]=u.goPrev,e[18]=s.length,e[19]=g):g=e[19];const x=g;let v;e[20]!==p?(v=i.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7",children:"Skip"}),e[20]=p,e[21]=v):v=e[21];let _;e[22]!==u.isAllAnswered||e[23]!==u.isCurrentAnswered||e[24]!==u.submitOrAdvance||e[25]!==n?(_=i.jsx(H6,{isStreaming:n,isAllAnswered:u.isAllAnswered,isCurrentAnswered:u.isCurrentAnswered,onAdvanceOrSubmit:u.submitOrAdvance}),e[22]=u.isAllAnswered,e[23]=u.isCurrentAnswered,e[24]=u.submitOrAdvance,e[25]=n,e[26]=_):_=e[26];let b;e[27]!==v||e[28]!==_?(b=i.jsxs(i.Fragment,{children:[v,_]}),e[27]=v,e[28]=_,e[29]=b):b=e[29];const y=b;if(s.length===1){const E=s[0];if(!E?.input)return null;let P;e[30]!==u?(P=G=>{G.preventDefault(),u.submit()},e[30]=u,e[31]=P):P=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx(a0,{size:14}),e[32]=M):M=e[32];const z=E.input?.prompt??"Question",$=E.input;let O;e[33]!==u.form.control||e[34]!==E.toolCallId||e[35]!==$?(O=i.jsx(Nu,{input:$,control:u.form.control,toolCallId:E.toolCallId}),e[33]=u.form.control,e[34]=E.toolCallId,e[35]=$,e[36]=O):O=e[36];let U;e[37]!==y||e[38]!==z||e[39]!==O?(U=i.jsx(Kn,{icon:M,label:"Question pending",title:z,defaultExpanded:!0,footerRight:y,children:O}),e[37]=y,e[38]=z,e[39]=O,e[40]=U):U=e[40];let H;e[41]!==P||e[42]!==U?(H=i.jsx("form",{onSubmit:P,autoComplete:"off",children:U}),e[41]=P,e[42]=U,e[43]=H):H=e[43];let Y;return e[44]!==u.form||e[45]!==H?(Y=i.jsx(o0,{...u.form,children:H}),e[44]=u.form,e[45]=H,e[46]=Y):Y=e[46],Y}const L=u.form;let w;e[47]!==u?(w=E=>{E.preventDefault(),u.submit()},e[47]=u,e[48]=w):w=e[48];let S;e[49]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(a0,{size:14}),e[49]=S):S=e[49];const j=`${u.currentIndex+1} of ${s.length}`,V=f?.input?.prompt??"Question",k=u.activeKey,T=u.setActiveKey;let A;if(e[50]!==u.form||e[51]!==s){let E;e[53]!==u.form?(E=P=>i.jsx(ri,{value:P.toolCallId,className:"mt-0",children:i.jsx(Nu,{input:P.input,control:u.form.control,toolCallId:P.toolCallId})},P.toolCallId),e[53]=u.form,e[54]=E):E=e[54],A=s.map(E),e[50]=u.form,e[51]=s,e[52]=A}else A=e[52];let N;e[55]!==u.activeKey||e[56]!==u.setActiveKey||e[57]!==A?(N=i.jsx(Eo,{value:k,onValueChange:T,children:A}),e[55]=u.activeKey,e[56]=u.setActiveKey,e[57]=A,e[58]=N):N=e[58];let R;e[59]!==x||e[60]!==y||e[61]!==j||e[62]!==V||e[63]!==N?(R=i.jsx(Kn,{icon:S,label:"Question pending",count:j,title:V,defaultExpanded:!0,footerLeft:x,footerRight:y,children:N}),e[59]=x,e[60]=y,e[61]=j,e[62]=V,e[63]=N,e[64]=R):R=e[64];let I;e[65]!==w||e[66]!==R?(I=i.jsx("form",{onSubmit:w,autoComplete:"off",children:R}),e[65]=w,e[66]=R,e[67]=I):I=e[67];let D;return e[68]!==u.form||e[69]!==I?(D=i.jsx(o0,{...L,children:I}),e[68]=u.form,e[69]=I,e[70]=D):D=e[70],D}function m_(t){return!!s2(t)}function p_(t){return t.toolCallId}function g_(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function x_(t){return{toolCallId:t.toolCallId,input:t.input}}function v_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.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:[i.jsx(a0,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function i2(t){const e=B.c(7),{userAskParts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(__),e[0]=s,e[1]=o):o=e[1];const a=o;if(a.length===0){if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(v_,{}),e[2]=c):c=e[2],c}return null}let l;return e[3]!==n||e[4]!==r||e[5]!==a?(l=i.jsx(f_,{parts:a,isStreaming:n,onSubmit:r}),e[3]=n,e[4]=r,e[5]=a,e[6]=l):l=e[6],l}function __(t){return t.state==="input-available"}function b_(t){const e=t.filter(o=>o.status==="in_progress"),s=t.filter(o=>o.status==="completed").length,n=t.length;if(n>0&&s===n)return{icon:"completed",activity:"All done",progress:`${n}/${n}`};const[r]=e;return r&&e.length===1?{icon:"in_progress",activity:r.activeForm,progress:`${s}/${n} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${s}/${n} done`}:s>0?{icon:"pending",activity:`${n-s} pending`,progress:`${s}/${n} done`}:{icon:"pending",activity:`${n} todos`,progress:"not started"}}function y_(){const t=B.c(21),{messages:e}=js();let s,n,r,o,a,l,c,d,h;if(t[0]!==e){h=Symbol.for("react.early_return_sentinel");e:{const m=Km(e);if(m.length===0){h=null;break e}const p=b_(m);s=Kn,a=i.jsx(j_,{status:p.icon}),l=p.activity,c=p.progress,d=!1,n="todos-list",r="flex flex-col px-2 max-h-[40vh] overflow-y-auto",o=m.map(L_)}t[0]=e,t[1]=s,t[2]=n,t[3]=r,t[4]=o,t[5]=a,t[6]=l,t[7]=c,t[8]=d,t[9]=h}else s=t[1],n=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],d=t[8],h=t[9];if(h!==Symbol.for("react.early_return_sentinel"))return h;let u;t[10]!==n||t[11]!==r||t[12]!==o?(u=i.jsx("ul",{"data-testid":n,className:r,children:o}),t[10]=n,t[11]=r,t[12]=o,t[13]=u):u=t[13];let f;return t[14]!==s||t[15]!==a||t[16]!==l||t[17]!==c||t[18]!==d||t[19]!==u?(f=i.jsx(s,{icon:a,label:l,count:c,defaultExpanded:d,children:u}),t[14]=s,t[15]=a,t[16]=l,t[17]=c,t[18]=d,t[19]=u,t[20]=f):f=t[20],f}function L_(t,e){return i.jsx(S_,{todo:t},e)}function S_(t){const e=B.c(14),{todo:s}=t,n=s.status==="completed",o=s.status==="in_progress"?s.activeForm:s.content;let a;e[0]!==s.status?(a=i.jsx(w_,{status:s.status}),e[0]=s.status,e[1]=a):a=e[1];const l=n&&"text-muted-foreground";let c;e[2]!==l?(c=ne("relative text-sm leading-snug pt-px select-none",l),e[2]=l,e[3]=c):c=e[3];const d=n?"100%":"0%",h=n?"width 300ms ease 200ms":"width 150ms ease";let u;e[4]!==d||e[5]!==h?(u=i.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:d,transition:h}}),e[4]=d,e[5]=h,e[6]=u):u=e[6];let f;e[7]!==o||e[8]!==c||e[9]!==u?(f=i.jsxs("span",{className:c,children:[o,u]}),e[7]=o,e[8]=c,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==a||e[12]!==f?(m=i.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,f]}),e[11]=a,e[12]=f,e[13]=m):m=e[13],m}function w_(t){const e=B.c(4),{status:s}=t,n=s==="completed"?"true":void 0,r=s==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("svg",{viewBox:"0 0 21 21",children:i.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]=o):o=e[0];let a;return e[1]!==n||e[2]!==r?(a=i.jsx("div",{className:"todo-cb mt-0.5","data-checked":n,"data-progress":r,"aria-hidden":"true",children:o}),e[1]=n,e[2]=r,e[3]=a):a=e[3],a}function j_(t){const e=B.c(3),{status:s}=t;if(s==="completed"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:i.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:i.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=r):r=e[0],r}if(s==="in_progress"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=r):r=e[1],r}let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.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]=n):n=e[2],n}const C_={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"}]},V_=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function r2(t){const e=B.c(41),{onDismiss:s}=t,{org:n}=Ae(),r=Ct(),{decoKeyId:o}=D9(),a=Ms(),[l,c]=C.useState(""),[d,h]=C.useState(!1),[u,f]=C.useState("usd"),m=u==="brl"?"R$":"$";let p,g;e[0]!==n.id?(p=()=>{Ce("credits_exhausted_shown",{organization_id:n.id})},g=[n.id],e[0]=n.id,e[1]=p,e[2]=g):(p=e[1],g=e[2]),C.useEffect(p,g);let x;e[3]!==u||e[4]!==a?(x=async E=>{const{url:P}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:E,currency:u});return P},e[3]=u,e[4]=a,e[5]=x):x=e[5];let v;e[6]!==s?(v=E=>{E&&window.open(E,"_blank","noopener,noreferrer"),s?.()},e[6]=s,e[7]=v):v=e[7];let _;e[8]!==x||e[9]!==v?(_={mutationFn:x,onSuccess:v,onError:A_},e[8]=x,e[9]=v,e[10]=_):_=e[10];const{mutate:b,isPending:y}=Ds(_),L=parseFloat(l),w=!isNaN(L)&&L>=1;let S;e[11]!==s?(S=E=>!E&&s?.(),e[11]=s,e[12]=S):S=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=["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]=j):j=e[13];let V;e[14]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[14]=V):V=e[14];let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[V,i.jsxs(ns,{className:"relative gap-4",children:[i.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"}),i.jsxs("div",{children:[i.jsx(is,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),i.jsx(qn,{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]=k):k=e[15];let T;e[16]!==u||e[17]!==m||e[18]!==l||e[19]!==L||e[20]!==o||e[21]!==w||e[22]!==y||e[23]!==d||e[24]!==b?(T=o&&i.jsxs("div",{className:"px-8 pt-5 pb-6",children:[i.jsx("div",{className:"mb-4",children:i.jsxs(fm,{type:"single",variant:"outline",size:"sm",value:u,onValueChange:E=>{E&&f(E)},children:[i.jsx(za,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),i.jsx(za,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),i.jsxs("div",{className:"rounded-xl border border-border p-5",children:[i.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:C_[u].map(E=>{const{dollars:P,label:M}=E;return i.jsxs("button",{type:"button",disabled:y,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:P*100,currency:u,tier_label:M,source:"exhausted_banner"}),b(P*100)},className:ne("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:[i.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,P]}),i.jsx("span",{className:"text-xs text-muted-foreground",children:M})]},P)})}),d?i.jsxs("div",{className:"flex gap-2 mt-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),i.jsx(Ye,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:E=>c(E.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),i.jsx(ie,{className:"h-10",disabled:!w||y,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:Math.round(L*100),currency:u,tier_label:"custom",source:"exhausted_banner"}),b(Math.round(L*100))},children:y?"Opening...":"Add"})]}):i.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),i.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:V_.map(k_)})]}),e[16]=u,e[17]=m,e[18]=l,e[19]=L,e[20]=o,e[21]=w,e[22]=y,e[23]=d,e[24]=b,e[25]=T):T=e[25];let A;e[26]!==s?(A=i.jsx(ie,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[26]=s,e[27]=A):A=e[27];let N;e[28]!==r||e[29]!==s||e[30]!==n.slug?(N=i.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:n.slug}}),s?.()},children:"Manage providers"}),e[28]=r,e[29]=s,e[30]=n.slug,e[31]=N):N=e[31];let R;e[32]!==A||e[33]!==N?(R=i.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[A,N]}),e[32]=A,e[33]=N,e[34]=R):R=e[34];let I;e[35]!==T||e[36]!==R?(I=i.jsxs(Ft,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:N_,children:[k,T,R]}),e[35]=T,e[36]=R,e[37]=I):I=e[37];let D;return e[38]!==I||e[39]!==S?(D=i.jsx(Ut,{open:!0,onOpenChange:S,children:I}),e[38]=I,e[39]=S,e[40]=D):D=e[40],D}function k_(t){return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:i.jsx(Tt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),i.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function N_(t){return t.preventDefault()}function A_(t){de.error(`Top-up failed: ${t.message}`)}function T_(){const t=B.c(5),e=ir(),s=gm(),[n,r]=C.useState(!1);if(!(e?.lockedSandbox==="user-desktop")||!s.ready||s.online)return null;let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(ar,{size:14}),t[0]=a):a=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(ie,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>r(!0),children:"Reconnect desktop"}),t[1]=l):l=t[1];let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Kn,{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:l,children:i.jsxs("p",{className:"mx-4 text-xs text-muted-foreground",children:["Run ",i.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]=c):c=t[2];let d;return t[3]!==n?(d=i.jsxs(i.Fragment,{children:[c,i.jsx(Ox,{open:n,onOpenChange:r})]}),t[3]=n,t[4]=d):d=t[4],d}function E_(t){const e=t.trim(),s=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),n=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),r=/failed to fetch|networkerror|load failed|offline/i.test(e),o=/timeout|timed out|aborted|deadline/i.test(e),a=e.length>240,l=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(l){const c=l[1]?.trim().replace(/\.$/,"");return{summary:c?`Your sandbox didn't finish starting up (${c}). 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}:n||s&&a?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:r?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:o?{summary:"That took longer than expected. Try again.",rawDetails:t}:s||a?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const R_={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 Qa(t){const e=B.c(19),{variant:s,onDismiss:n}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?fn:nr,l=r?t.error.message:R_[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`;let c;e[0]!==r||e[1]!==l?(c=r?E_(l):{summary:l,rawDetails:null},e[0]=r,e[1]=l,e[2]=c):c=e[2];const{summary:d,rawDetails:h}=c;let u;e[3]!==a?(u=i.jsx(a,{size:14}),e[3]=a,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==t.onContinue||e[7]!==t.onFixInChat?(f=r?i.jsx(ie,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}):i.jsx(ie,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"}),e[5]=r,e[6]=t.onContinue,e[7]=t.onFixInChat,e[8]=f):f=e[8];let m;e[9]!==h?(m=h?i.jsxs("details",{className:"group mx-4",children:[i.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:[i.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:i.jsx("path",{d:"m4.5 3 3 3-3 3"})}),i.jsx("span",{className:"group-open:hidden",children:"Show technical details"}),i.jsx("span",{className:"hidden group-open:inline",children:"Hide technical details"})]}),i.jsxs("div",{className:"relative mt-2",children:[i.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(h).then(I_).catch(P_)},"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:i.jsx(Ss,{className:"size-3.5"})}),i.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:h})]})]}):null,e[9]=h,e[10]=m):m=e[10];let p;return e[11]!==o||e[12]!==n||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==m||e[17]!==s?(p=i.jsx(Kn,{icon:u,label:o,title:d,defaultExpanded:!0,variant:s,onClose:n,footerRight:f,children:m}),e[11]=o,e[12]=n,e[13]=d,e[14]=u,e[15]=f,e[16]=m,e[17]=s,e[18]=p):p=e[18],p}function P_(){return de.error("Could not copy")}function I_(){return de.success("Copied to clipboard")}function Il(){const t=B.c(62),{error:e,clearError:s,finishReason:n,clearFinishReason:r,messages:o,isStreaming:a,submit:l,sendMessage:c}=js(),[d,h]=sr(),{virtualMcpId:u,createTaskWithMessage:f}=as(),{chatMode:m,simpleModeTier:p}=xs();let g;t[0]!==m||t[1]!==p||t[2]!==u?(g=J=>({tier:p,mode:m,toolApprovalLevel:J,agent:u?{id:u}:void 0}),t[0]=m,t[1]=p,t[2]=u,t[3]=g):g=t[3];const x=g;let v;t[4]!==d.toolApprovalLevel?(v=d.toolApprovalLevel??k4(),t[4]=d.toolApprovalLevel,t[5]=v):v=t[5];const _=v,b=o.at(-1),y=b?.role==="assistant"?b.parts:[],L=y.filter($_),w=qm(y),S=Wm(y);let j;t[6]!==e||t[7]!==c?(j=()=>{if(e){const ee={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};c(ee)}},t[6]=e,t[7]=c,t[8]=j):j=t[8];const V=j;let k;t[9]!==c?(k=()=>{c({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[9]=c,t[10]=k):k=t[10];const T=k;let A;t[11]!==x||t[12]!==_||t[13]!==l?(A=(J,ee)=>{l({kind:"toolOutput",toolCallId:J.toolCallId,output:{response:ee}},x(_))},t[11]=x,t[12]=_,t[13]=l,t[14]=A):A=t[14];const N=A;let R;t[15]!==f||t[16]!==d||t[17]!==h||t[18]!==u?(R=J=>{h({...d,toolApprovalLevel:"auto"}),f({virtualMcpId:u,message:{parts:[{type:"text",text:`Implement this plan:
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-editor-hzVyG0y7.js","assets/index-BrDZHTLR.js","assets/index-C2ybUFaX.css","assets/ChevronRight-CPjbrY1z.js","assets/automation-runs-DuxW2iQ2.js","assets/select-YjEses9D.js","assets/tooltip-Cn3wVH17.js","assets/Check-BoClJlGr.js","assets/ChevronDown-Brul_emp.js","assets/ChevronUp-bdu2geyR.js","assets/useInfiniteQuery-DMTZr3Km.js","assets/use-infinite-scroll-Cc-eI5dW.js","assets/use-connection-CRDT9Ldi.js","assets/use-collections-BYXy-R3E.js","assets/use-mcp-client-Tn0EaYl-.js","assets/constants-B72Xmt_K.js","assets/auth-CsnJqa1F.js","assets/use-virtual-mcp-BY7edM8i.js","assets/card-B59c-zKl.js","assets/sidebar-DFX-m3oC.js","assets/LayoutLeft--MRcuBrS.js","assets/use-mobile-KpS88y1x.js","assets/X-OMJfEq4b.js","assets/table-DbIpX7-0.js","assets/empty-state-DdYIETDL.js","assets/use-members-DQ95-jnU.js","assets/use-org-auth-client-Bt8pW8tY.js","assets/use-clock-tick-DH0G_lc3.js","assets/AlertCircle-alrsw5sb.js","assets/CheckCircle-DU5VsEiy.js","assets/Circle-BOYi0Xck.js","assets/agent-icon-DvxUJZQr.js","assets/Tool01-CLxmN9mS.js","assets/SwitchHorizontal01-DmcI1SxK.js","assets/Settings02-MYpqMtoa.js","assets/XCircle-CZr5n04C.js","assets/ArrowUpRight-BYn37fLS.js","assets/ZapSquare-B6bJc7NY.js","assets/Users03-BWAP9RHq.js","assets/Loading02-CfrU2bHj.js","assets/Stars02-BEUdLZEv.js","assets/Copy01-CmYZk_Oi.js","assets/ZoomOut-DZtqvzaF.js","assets/DotsVertical-DO_6KMLL.js","assets/Globe01-CRp5QOra.js","assets/Eye-BvH_DPVP.js","assets/FilterLines-DO_aU8_D.js","assets/Star01-DR542MT0.js","assets/Globe04-B4Ko9COZ.js","assets/HardDrive-DuDQqVUp.js","assets/Key01-BQ6DQsHX.js","assets/LinkExternal01-CZdZ3Gp9.js","assets/List-CLefXpG9.js","assets/Monitor01-C7sxGC0d.js","assets/Sun-DdMchr6Q.js","assets/Palette-ByeXYG5e.js","assets/Play-Du9xpw0U.js","assets/Plus-1psGuynD.js","assets/SearchLg-BmO74DiK.js","assets/SearchMd-CSePLCcA.js","assets/Shield01-C1_5VC4J.js","assets/Stars01-DFxlT01N.js","assets/Trash01-D0Cq2EdB.js","assets/Upload01-u7texoe_.js","assets/User01-C6Q6FZ5h.js","assets/Users01-BaAnt9k2.js","assets/XClose-DN4fuk7G.js","assets/Zap-DR-fQuEw.js","assets/use-automations-BR5JBwGL.js","assets/studio-tools-D0ghBj1q.js","assets/useSuspenseInfiniteQuery-CCpKF6B-.js","assets/badge-DjjYK3hM.js","assets/checkbox-B9H3Kcg1.js","assets/command-B9xNHDhN.js","assets/index-qeTrhZ5z.js","assets/dialog-BZT5GyRD.js","assets/popover-CgDNpU8B.js","assets/avatar-ClX7LKnq.js","assets/format-time-Cy7tTmZp.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-Cz3O5WiP.js","assets/file-type-icon-BBIUqTz8.js","assets/tab-id-C4S0EPFu.js","assets/monaco-editor-fHkuT6U5.js","assets/index-93HCuWf6.js","assets/chat-context-A7nmjc6x.js","assets/autosend-7cnPPC-f.js","assets/hooks-sbzuLwH3.js","assets/decopilot-sse-pool-DRCw2_hc.js","assets/backoff-CrEUbyZT.js","assets/delay-CnY5UFtP.js","assets/use-ai-providers-D3-RoSuB.js","assets/use-decopilot-events-BaYxDi6g.js","assets/use-organization-settings-CpKXAWmk.js","assets/types-DJxzgNPE.js","assets/shell-layout-B82J_KPo.js","assets/alert-dialog-eNWhkEoy.js","assets/required-auth-layout-DrLP3sOL.js","assets/use-org-sso-Bj7oxuZp.js","assets/integration-icon-Bpdl0ZYs.js","assets/use-navigate-to-agent-D9dmHsrm.js","assets/reusable-new-chat-qqWu133U.js","assets/use-mcp-prompts-D2ADBynP.js","assets/form-DsC2p383.js","assets/label-DYYJC9Z1.js","assets/input-C1Kmo3vK.js","assets/add-section-modal-7QHISFHk.js","assets/drawer-B1mbeoBW.js","assets/collection-search-C1a7Zgcm.js","assets/tabs-CVnXbEbf.js","assets/toggle-group-t0AjASu3.js","assets/agent-capabilities-CdrlnYho.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-DeB2bj2L.js","assets/use-registry-connections-CSbURcZz.js","assets/extract-connection-data-i1upuIiY.js","assets/collection-tabs-DkseRL6k.js","assets/textarea-DiiyNZoM.js","assets/connection-form-helpers-Bi9IvJ4z.js","assets/authenticate-and-persist-oauth-B_9_tvH8.js","assets/mcp-oauth-D84eIMFG.js","assets/connect-desktop-dialog-D7Moybni.js","assets/select-model-CgdZqY7t.js","assets/skeleton-DqDfsqHy.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-DizG3l8Q.js","assets/dropdown-menu-VYc_jtsE.js","assets/index-c1JpYe_A.js","assets/toolbar-BiSenxgj.js","assets/use-debounced-value-BmUV4CbZ.js","assets/question-004-sINsf4GQ.js","assets/use-status-sounds-C0yOb1Wm.js","assets/use-mcp-tools-B0s72NAd.js","assets/use-capability-DHjmgTGt.js","assets/tools-list-BKRJivYX.js","assets/switch-C2fH9o8L.js","assets/use-debounced-autosave-B0vb-HYP.js","assets/index-CcToIFKw.js","assets/search-input-CjSpFSFv.js","assets/github-repo-picker-kM8XNde1.js","assets/github-installations-DzN1UQ4x.js","assets/use-secrets--hJvdN8v.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/index-UEam1TE5.js","assets/get-initials-D-f_fDFw.js","assets/calendar-CK3Sat10.js","assets/toolbar-icon-button-Putd7Z1P.js","assets/automation-list-row-BW7BWI_0.js","assets/use-file-configs-ChSgKNGP.js","assets/post-editor-NfJoTyDC.js","assets/block-document-DK7lTXBo.js","assets/primitives--tVK20cV.js","assets/record-editor-CgHrbjzN.js","assets/category-editor-Nlp7pH1k.js","assets/bulk-category-panel-C3uWZXv5.js","assets/index-mC3b7Drk.js","assets/sections-editor-BIBNvxJf.js","assets/page-seo-form-D8fbKZ1h.js","assets/seo-editor-Cxn7J1o3.js","assets/variant-calendar-FLrb-T5o.js","assets/view-mode-toggle-DbhZEvJk.js","assets/page-seo-sheet-CXtm2wdS.js","assets/file-explorer-grrkdCaR.js","assets/project-app-view-C9GFnxtU.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{p as os,r as C,o as S4,n as w4,c as B,$ as Ae,l as ne,j as i,P as ps,t as de,G as nn,a8 as j4,H as Qt,a9 as h9,V as v1,B as ie,J as f9,I as _1,aa as C4,ab as V4,a1 as sr,ac as fs,ad as Pr,ae as uu,b as Ct,d as Ds,M as Ce,af as k4,ag as nr,ah as N4,Z as b1,ai as y1,K as Qe,aj as Ll,a as vi,ak as A4,al as L1,am as T4,an as Zs,ao as dc,ap as Ri,aq as E4,ar as uc,as as R4,at as P4,au as I4,av as D4,L as m9,aw as M4,ax as O4,ay as $4,az as B4,aA as S1,aB as Kr,k as gs,i as qe,aC as p9,aD as Ge,a6 as w1,aE as zi,aF as Ws,Y as z4,u as Sl,aG as F4,aH as U4,aI as j1,aJ as H4,aK as wl,aL as Fi,aM as C1,aN as K4,aO as W4,aP as V1,aQ as q4,aR as G4,aS as Y4,aT as J4,aU as Xo,e as k1,a7 as X4}from"./index-BrDZHTLR.js";import{i as g9,n as Q4,c as N1}from"./SwitchHorizontal01-DmcI1SxK.js";import{u as xs,a as js,S as Ui,b as ir,c as as,d as A1,s as Z4,e as e5,f as t5,p as T1,g as E1,A as s5,h as n5,i as i5,t as r5,j as o5,k as a5}from"./chat-context-A7nmjc6x.js";import{c as x9,s as rr,g as rn,P as io,d as v9,t as di,a as l5,M as c5,i as d5,b as Ma,e as R1,f as u5,D as h5,h as f5,j as m5,k as Hi,l as p5,u as P1,E as g5,m as _9,n as x5,F as v5,o as I1,p as D1,q as M1,S as _5,r as b5,v as y5,w as L5,x as hu,y as S5,z as O1,O as w5,A as j5,B as Sn,G as C5,T as V5,C as $1,R as k5,H as N5,I as A5,J as T5,K as E5,L as R5}from"./automation-runs-DuxW2iQ2.js";import{c as ro,a as Re,b as Pe,T as Ie}from"./tooltip-Cn3wVH17.js";import{c as ns,a as is,d as Ft,e as Ut,b as qn,D as _i}from"./dialog-BZT5GyRD.js";import{c as P5,b as B1,a as z1,D as F1}from"./drawer-B1mbeoBW.js";import{C as I5}from"./collection-search-C1a7Zgcm.js";import{u as jo}from"./use-mobile-KpS88y1x.js";import{u as pt,a as D5,m as M5}from"./use-mcp-client-Tn0EaYl-.js";import{a as Co,S as b9,i as Oa,c as O5,d as U1,b as fu}from"./constants-B72Xmt_K.js";import{u as H1,g as Vo,l as n0}from"./use-mcp-prompts-D2ADBynP.js";import{t as Ht}from"./ChevronDown-Brul_emp.js";import{i as ms}from"./X-OMJfEq4b.js";import{t as $5,z as B5,b as y9,u as K1}from"./hooks-sbzuLwH3.js";import{K as z5,i as W1,u as ko,D as F5,c as q1,a as G1,s as mu,b as U5,m as H5,d as K5,e as W5,f as q5}from"./shell-layout-B82J_KPo.js";import{a as No,u as qs,b as L9,c as G5}from"./use-virtual-mcp-BY7edM8i.js";import{w as Y1,A as Y5}from"./autosend-7cnPPC-f.js";import{n as Ki,b as J1}from"./ZapSquare-B6bJc7NY.js";import{i as Tt}from"./Check-BoClJlGr.js";import{s as on}from"./Star01-DR542MT0.js";import{a as _n,i as J5,b as S9,c as w9,d as j9}from"./Tool01-CLxmN9mS.js";import{g as jl,h as X1,j as C9,k as an,l as V9,m as k9,n as Q1,o as X5,A as Hn,p as Z1,q as em,r as tm,u as Q5,v as Z5,c as sm,w as ex,x as tx,y as sx,z as nx,B as ix,C as rx,D as ox,E as ax,F as lx,G as Gn,H as Dn,I as Wi,J as pu,K as bi,L as N9,M as Ao,N as cx,O as dx,P as nm,Q as $a,R as A9,S as ux,T as im,t as rm,U as Ba,V as hx,W as fx,X as mx,e as om,Y as px,Z as am,_ as gx,$ as Cl,a0 as T9,a1 as lm,a2 as i0,a3 as hc,a4 as gu,a5 as xx,a6 as vx,a7 as _x,a8 as bx,a9 as yx,aa as E9,i as r0,ab as cm,ac as xu,ad as Lx,ae as Sx,af as wx,ag as jx,ah as Cx,ai as Vx,aj as kx,ak as Nx,al as dm,am as Ax,an as Tx}from"./agent-icon-DvxUJZQr.js";import{i as or}from"./Upload01-u7texoe_.js";import{i as fn}from"./AlertCircle-alrsw5sb.js";import{a as Ss}from"./Copy01-CmYZk_Oi.js";import{a as o0,b as R9,d as P9,e as I9,F as um}from"./form-DsC2p383.js";import{S as $t,a as Bt,b as nt,c as zt,d as Gt}from"./select-YjEses9D.js";import{b as Vl,i as Ex,a as Rx}from"./Settings02-MYpqMtoa.js";import{i as To,t as a0,a as hm,b as Px}from"./XCircle-CZr5n04C.js";import{T as ri,a as Eo,b as $n,c as kl}from"./tabs-CVnXbEbf.js";import{a as fm,T as za}from"./toggle-group-t0AjASu3.js";import{I as Ye}from"./input-C1Kmo3vK.js";import{u as D9,g as Ro,a as M9,A as mm,c as pm,b as bn,r as Ix,f as Dx,d as Mx}from"./agent-capabilities-CdrlnYho.js";import{u as Ms}from"./studio-tools-D0ghBj1q.js";import{i as ar}from"./Monitor01-C7sxGC0d.js";import{u as gm,C as Ox,a as $x,b as Bx,l as zx}from"./connect-desktop-dialog-D7Moybni.js";import{s as yn}from"./XClose-DN4fuk7G.js";import{m as Nl,i as Fx,g as xm,a as Ux,N as vm,M as Hx}from"./select-model-CgdZqY7t.js";import{e as Fs,a as Ps,f as Kx,b as yi,C as Li,c as Si,d as lr,g as Wx}from"./command-B9xNHDhN.js";import{a as Cs,b as Vs,P as ks}from"./popover-CgDNpU8B.js";import{u as _m}from"./useInfiniteQuery-DMTZr3Km.js";import{D as Zt,a as es,b as Ir,c as ts,d as He,e as oo,f as ao,g as lo,h as l0,i as Po,j as Di}from"./dropdown-menu-VYc_jtsE.js";import{t as Bn}from"./Stars01-DFxlT01N.js";import{u as Al,a as bm,b as ym,c as qx}from"./use-organization-settings-CpKXAWmk.js";import{f as Gx,a as Yx,d as Lm,b as Jx,u as Xx,c as Qx,e as Zx,g as ev,h as tv,i as sv,F as nv,j as iv,k as rv,l as ov,m as av,n as lv,o as cv,H as dv,L as uv,p as hv,S as fv,B as mv,R as vu,q as pv,r as gv,s as co,T as O9,t as xv}from"./index-c1JpYe_A.js";import{s as Lt}from"./Plus-1psGuynD.js";import{p as vv,q as _v}from"./question-004-sINsf4GQ.js";import{i as cn}from"./ChevronRight-CPjbrY1z.js";import{u as Sm}from"./use-ai-providers-D3-RoSuB.js";import{i as Tl}from"./CheckCircle-DU5VsEiy.js";import{n as _u,a as wm,s as jm,b as bv}from"./Loading02-CfrU2bHj.js";import{I as Gs}from"./integration-icon-Bpdl0ZYs.js";import{u as yv}from"./use-status-sounds-C0yOb1Wm.js";import{E as qi}from"./empty-state-DdYIETDL.js";import{T as uo}from"./toolbar-BiSenxgj.js";import{i as $9}from"./SearchLg-BmO74DiK.js";import{s as ws}from"./Trash01-D0Cq2EdB.js";import{t as B9}from"./Users01-BaAnt9k2.js";import{i as ui}from"./Zap-DR-fQuEw.js";import{f as Fa,a as Ua,b as Ha,c as Ka,d as Wa,e as qa,A as Ga,g as Ya}from"./alert-dialog-eNWhkEoy.js";import{C as cr}from"./checkbox-B9H3Kcg1.js";import{a as Io,b as Lv,c as Sv,d as hi,i as Cm}from"./ZoomOut-DZtqvzaF.js";import{r as wv,a as bu,p as Vm,f as c0,b as km,c as Nm,d as Am,e as jv,F as Cv,g as Vv,h as kv,i as Nv,j as Av,k as Tv,l as Tm,m as Ev}from"./tab-id-C4S0EPFu.js";import{i as Yn,n as Rv}from"./Globe01-CRp5QOra.js";import{u as Do,a as z9,b as Em}from"./use-connection-CRDT9Ldi.js";import{u as El,a as F9,b as Rm}from"./use-mcp-tools-B0s72NAd.js";import{g as Rl,M as Pv}from"./types-DJxzgNPE.js";import{e as Pm}from"./backoff-CrEUbyZT.js";import{u as Iv}from"./use-capability-DHjmgTGt.js";import{F as Gi,M as U9,O as Dv}from"./file-type-icon-BBIUqTz8.js";import{a as Mv}from"./extract-connection-data-i1upuIiY.js";import{A as La}from"./avatar-ClX7LKnq.js";import{T as Im,u as Dm}from"./tools-list-BKRJivYX.js";import{a as Ov,i as yu}from"./mcp-oauth-D84eIMFG.js";import{s as Mm,g as $v}from"./connection-slug-eyAPH6o3.js";import{C as H9,a as Ja}from"./card-B59c-zKl.js";import{L as Xe}from"./label-DYYJC9Z1.js";import{S as ho}from"./switch-C2fH9o8L.js";import{T as Yi}from"./textarea-DiiyNZoM.js";import{i as fi}from"./Play-Du9xpw0U.js";import{u as Xa}from"./use-debounced-autosave-B0vb-HYP.js";import{i as fo}from"./SearchMd-CSePLCcA.js";import{i as Bv}from"./LayoutLeft--MRcuBrS.js";import{P as zs}from"./index-CcToIFKw.js";import{S as K9}from"./search-input-CjSpFSFv.js";import{C as Om}from"./collection-tabs-DkseRL6k.js";import{i as W9}from"./Key01-BQ6DQsHX.js";import{a as q9,G as zv}from"./github-repo-picker-kM8XNde1.js";import{S as yt}from"./skeleton-DqDfsqHy.js";import{s as Fv}from"./User01-C6Q6FZ5h.js";import{u as Uv,a as Hv}from"./use-secrets--hJvdN8v.js";import{f as $m}from"./formatDistanceToNow-Cb2QZZJn.js";import{u as Kv}from"./use-members-DQ95-jnU.js";import{u as Wv,S as qv,T as Gv}from"./index-UEam1TE5.js";import{m as Yv,n as Jv,o as Xv,p as Qv,q as Zv}from"./sidebar-DFX-m3oC.js";import{n as wn}from"./LinkExternal01-CZdZ3Gp9.js";import{l as e6,w as t6}from"./index-93HCuWf6.js";import{T as Lu}from"./toolbar-icon-button-Putd7Z1P.js";import{d as s6}from"./delay-CnY5UFtP.js";import{B as n6}from"./badge-DjjYK3hM.js";import{u as Mo,a as i6,b as r6,c as o6,d as a6}from"./use-automations-BR5JBwGL.js";import{s as Wr}from"./Stars02-BEUdLZEv.js";import{M as Pl}from"./monaco-editor-fHkuT6U5.js";import{A as l6}from"./automation-list-row-BW7BWI_0.js";import{s as Bm}from"./Eye-BvH_DPVP.js";import{C as c6}from"./calendar-CK3Sat10.js";import{i as d6}from"./List-CLefXpG9.js";import{i as u6}from"./DotsVertical-DO_6KMLL.js";import{u as h6}from"./use-debounced-value-BmUV4CbZ.js";import{u as f6,a as zm}from"./use-file-configs-ChSgKNGP.js";import{i as m6}from"./FilterLines-DO_aU8_D.js";function p6(t,e){const s=os(e);return g6({filters:{...t,status:"pending"}},s).length}function Su(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function g6(t={},e){const s=os(e).getMutationCache(),n=C.useRef(t),r=C.useRef(null);return r.current===null&&(r.current=Su(s,t)),C.useEffect(()=>{n.current=t}),C.useSyncExternalStore(C.useCallback(o=>s.subscribe(()=>{const a=S4(r.current,Su(s,n.current));r.current!==a&&(r.current=a,w4.schedule(o))}),[s]),()=>r.current,()=>r.current)}const wu=3,Fm="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",x6="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Um(t){const e=B.c(46),{item:s,onSelect:n,isLoading:r,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const S=rn(c._meta);d=c.title??v9(c.name,S),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const h=d,u=c.description||null;if(l==="card"){let S;e[4]!==n||e[5]!==c?(S=()=>n(c),e[4]=n,e[5]=c,e[6]=S):S=e[6];const j=o||r,V=r&&"bg-accent/40",k=(o||r)&&"cursor-not-allowed opacity-50";let T;e[7]!==V||e[8]!==k?(T=ne(x6,"hover:bg-accent/60 text-foreground",V,k),e[7]=V,e[8]=k,e[9]=T):T=e[9];let A;e[10]!==h?(A=i.jsx("span",{className:"font-medium truncate capitalize",children:h}),e[10]=h,e[11]=A):A=e[11];let N;e[12]!==r?(N=r&&i.jsx(Ui,{size:"xs"}),e[12]=r,e[13]=N):N=e[13];let R;e[14]!==A||e[15]!==N?(R=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A,N]}),e[14]=A,e[15]=N,e[16]=R):R=e[16];let I;e[17]!==u?(I=u&&i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:u}),e[17]=u,e[18]=I):I=e[18];let D;return e[19]!==R||e[20]!==I||e[21]!==S||e[22]!==j||e[23]!==T?(D=i.jsxs("button",{type:"button",onClick:S,disabled:j,className:T,children:[R,I]}),e[19]=R,e[20]=I,e[21]=S,e[22]=j,e[23]=T,e[24]=D):D=e[24],D}let f;e[25]!==n||e[26]!==c?(f=()=>n(c),e[25]=n,e[26]=c,e[27]=f):f=e[27];const m=o||r,p=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let x;e[28]!==p||e[29]!==g?(x=ne(Fm,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=x):x=e[30];let v;e[31]!==h?(v=i.jsx("span",{className:"capitalize",children:h}),e[31]=h,e[32]=v):v=e[32];let _;e[33]!==r?(_=r&&i.jsx(Ui,{size:"xs"}),e[33]=r,e[34]=_):_=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==x||e[38]!==v||e[39]!==_?(b=i.jsx(Re,{asChild:!0,children:i.jsxs("button",{type:"button",onClick:f,disabled:m,className:x,children:[v,_]})}),e[35]=f,e[36]=m,e[37]=x,e[38]=v,e[39]=_,e[40]=b):b=e[40];const y=u??h;let L;e[41]!==y?(L=i.jsx(Pe,{side:"top",className:"max-w-xs",children:i.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=L):L=e[42];let w;return e[43]!==b||e[44]!==L?(w=i.jsxs(Ie,{delayDuration:400,children:[b,L]}),e[43]=b,e[44]=L,e[45]=w):w=e[45],w}function v6(t){const e=B.c(41),{items:s,open:n,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[l,c]=C.useState(""),d=!!a;let h;e[0]!==s||e[1]!==l?(h=l.trim()?s.filter(j=>{const V=l.toLowerCase();return j.prompt.name.toLowerCase().includes(V)||(j.prompt.title??"").toLowerCase().includes(V)||(j.prompt.description??"").toLowerCase().includes(V)}):s,e[0]=s,e[1]=l,e[2]=h):h=e[2];const u=h,f=jo();let m;e[3]!==u.length||e[4]!==l?(m=u.length===0&&i.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=u.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==u||e[7]!==d||e[8]!==a?.name||e[9]!==r||e[10]!==o){let j;e[12]!==d||e[13]!==a?.name||e[14]!==r||e[15]!==o?(j=V=>i.jsx(Um,{item:V,variant:"card",onSelect:k=>{r(!1),o(k)},isLoading:a?.name===V.prompt.name,isDisabled:d&&a?.name!==V.prompt.name},V.prompt.name),e[12]=d,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=j):j=e[16],p=u.map(j),e[6]=u,e[7]=d,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=i.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const x=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=j=>{j.key==="Escape"&&c("")},e[20]=v):v=e[20];let _;e[21]!==l?(_=i.jsx(I5,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=_):_=e[22];const b=_;if(f){let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(P5,{className:"sr-only",children:i.jsx(B1,{children:"All prompts"})}),e[23]=j):j=e[23];let V;e[24]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=V):V=e[24];let k;e[25]!==x||e[26]!==b?(k=i.jsxs(z1,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[j,V,b,x]}),e[25]=x,e[26]=b,e[27]=k):k=e[27];let T;return e[28]!==r||e[29]!==n||e[30]!==k?(T=i.jsx(ro,{delayDuration:400,children:i.jsx(F1,{open:n,onOpenChange:r,children:k})}),e[28]=r,e[29]=n,e[30]=k,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ns,{className:"sr-only",children:i.jsx(is,{children:"All prompts"})}),e[32]=y):y=e[32];let L;e[33]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=L):L=e[33];let w;e[34]!==x||e[35]!==b?(w=i.jsxs(Ft,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,L,b,x]}),e[34]=x,e[35]=b,e[36]=w):w=e[36];let S;return e[37]!==r||e[38]!==n||e[39]!==w?(S=i.jsx(ro,{delayDuration:400,children:i.jsx(Ut,{open:n,onOpenChange:r,children:w})}),e[37]=r,e[38]=n,e[39]=w,e[40]=S):S=e[40],S}function _6(t){const e=B.c(29),{items:s,onSelect:n,loadingPrompt:r,className:o}=t,[a,l]=C.useState(!1);if(s.length===0)return null;let c,d,h;if(e[0]!==s||e[1]!==r||e[2]!==n){const v=s.slice(0,wu);let _;e[6]!==s?(_=s.slice(wu),e[6]=s,e[7]=_):_=e[7],c=_,d=!!r;let b;e[8]!==d||e[9]!==r?.name||e[10]!==n?(b=y=>i.jsx(Um,{item:y,onSelect:n,isLoading:r?.name===y.prompt.name,isDisabled:d&&r?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=r?.name,e[10]=n,e[11]=b):b=e[11],h=v.map(b),e[0]=s,e[1]=r,e[2]=n,e[3]=c,e[4]=d,e[5]=h}else c=e[3],d=e[4],h=e[5];const u=h;let f;e[12]!==o?(f=ne("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&i.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:ne(Fm,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==u||e[18]!==f||e[19]!==m?(p=i.jsxs("div",{className:f,children:[u,m]}),e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==n?(g=i.jsx(v6,{items:s,open:a,onOpenChange:l,onSelect:n,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=n,e[25]=g):g=e[25];let x;return e[26]!==p||e[27]!==g?(x=i.jsxs(ro,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=x):x=e[28],x}function b6(){return null}function y6(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 L6(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:n}=js(),{org:r}=Ae();let o;e[0]!==s||e[1]!==r.id||e[2]!==r.slug?(o={connectionId:s,orgId:r.id,orgSlug:r.slug},e[0]=s,e[1]=r.id,e[2]=r.slug,e[3]=o):o=e[3];const a=pt(o);let l;e[4]!==a?(l={client:a,staleTime:6e4},e[4]=a,e[5]=l):l=e[5];const{data:c}=H1(l);let d;e[6]!==c?.prompts?(d=c?.prompts??[],e[6]=c?.prompts,e[7]=d):d=e[7];const h=d;let u;e[8]!==h?(u=h.map(S6),e[8]=h,e[9]=u):u=e[9];const f=u;let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m={stage:"idle"},e[10]=m):m=e[10];const[p,g]=C.useReducer(y6,m),[x,v]=C.useState(null);let _;e[11]!==a||e[12]!==n?(_=async(N,R)=>{if(!a){de.error("MCP client not available"),g({type:"RESET"});return}try{const I=await Vo(a,N.name,R);g({type:"RESET"});const D={type:"doc",content:[{type:"paragraph",content:[x9({id:N.name,name:rr(N.name,rn(N._meta)),metadata:I.messages,char:"/",kind:"prompt",args:R}),{type:"text",text:" "}]}]};await n(D)}catch(I){console.error("[ice-breakers] Failed to fetch prompt:",I),de.error("Failed to load prompt. Please try again."),g({type:"RESET"})}},e[11]=a,e[12]=n,e[13]=_):_=e[13];const b=_;let y;e[14]!==b?(y=async N=>{if(N.arguments&&N.arguments.length>0){g({type:"SELECT_PROMPT",prompt:N}),v(N);return}g({type:"START_LOADING",prompt:N}),await b(N)},e[14]=b,e[15]=y):y=e[15];const L=y;let w;e[16]!==x||e[17]!==b?(w=async N=>{x&&(g({type:"START_LOADING",prompt:x,arguments:N}),v(null),await b(x,N))},e[16]=x,e[17]=b,e[18]=w):w=e[18];const S=w;if(f.length===0)return null;const j=p.stage==="loading"?p.prompt:null;let V;e[19]!==L||e[20]!==f||e[21]!==j?(V=i.jsx(_6,{items:f,onSelect:L,loadingPrompt:j}),e[19]=L,e[20]=f,e[21]=j,e[22]=V):V=e[22];let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{v(null),g({type:"RESET"})},e[23]=k):k=e[23];let T;e[24]!==x||e[25]!==S?(T=i.jsx(io,{prompt:x,setPrompt:k,onSubmit:S}),e[24]=x,e[25]=S,e[26]=T):T=e[26];let A;return e[27]!==V||e[28]!==T?(A=i.jsxs(i.Fragment,{children:[V,T]}),e[27]=V,e[28]=T,e[29]=A):A=e[29],A}function S6(t){return{prompt:t}}function w6(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:n}=xs(),{org:r}=Ae();let o;e[0]!==r.id?(o=Co(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,l=n?.id??a;let c;e[2]!==s?(c=ne("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(b6,{}),e[4]=h):h=e[4];let u;e[5]!==l?(u=i.jsx(L6,{connectionId:l}),e[5]=l,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=i.jsx(ps,{fallback:null,children:i.jsx(C.Suspense,{fallback:h,children:u},d)}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=i.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}const fc="cubic-bezier(0.645, 0.045, 0.355, 1)",j6=44,C6={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"},V6={default:"border-border",error:"border-destructive/30",warning:"border-amber-500/30"},k6={default:"text-muted-foreground",error:"text-destructive",warning:"text-amber-600 dark:text-amber-500"};function Kn(t){const e=B.c(61),{icon:s,label:n,count:r,title:o,footerLeft:a,footerRight:l,children:c,defaultExpanded:d,variant:h,onClose:u}=t,f=h===void 0?"default":h,[m,p]=C.useState(d),[g,x]=C.useState(!1);let v;e[0]!==u?(v=()=>{x(!0),u?.()},e[0]=u,e[1]=v):v=e[1];const _=v;if(g)return null;const b=V6[f],y=C6[f];let L;e[2]!==b||e[3]!==y?(L=ne("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",b,y),e[2]=b,e[3]=y,e[4]=L):L=e[4];let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>p(N6),e[5]=w):w=e[5];const S=m&&"rounded-b-none",j=!m&&"rounded-b-xl";let V;e[6]!==S||e[7]!==j?(V=ne("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",S,j),e[6]=S,e[7]=j,e[8]=V):V=e[8];const k=k6[f];let T;e[9]!==k?(T=ne("shrink-0",k),e[9]=k,e[10]=T):T=e[10];let A;e[11]!==s||e[12]!==T?(A=i.jsx("span",{className:T,children:s}),e[11]=s,e[12]=T,e[13]=A):A=e[13];let N;e[14]!==n?(N=i.jsx("span",{className:"flex-1 min-w-0 truncate",children:n}),e[14]=n,e[15]=N):N=e[15];let R;e[16]!==r?(R=r?i.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:r}):null,e[16]=r,e[17]=R):R=e[17];const I=m?"rotate(180deg)":"rotate(0deg)";let D;e[18]!==I?(D=i.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:i.jsx(Ht,{size:16,style:{transform:I,transition:`transform 180ms ${fc}`}})}),e[18]=I,e[19]=D):D=e[19];let E,P;e[20]!==_?(E=Z=>{Z.stopPropagation(),_()},P=Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),Z.stopPropagation(),_())},e[20]=_,e[21]=E,e[22]=P):(E=e[21],P=e[22]);let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx(ms,{size:16}),e[23]=M):M=e[23];let z;e[24]!==E||e[25]!==P?(z=i.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":"Close",title:"Close",onClick:E,onKeyDown:P,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:M}),e[24]=E,e[25]=P,e[26]=z):z=e[26];let $;e[27]!==m||e[28]!==A||e[29]!==N||e[30]!==R||e[31]!==D||e[32]!==z||e[33]!==V?($=i.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":m,onClick:w,className:V,children:[A,N,R,D,z]}),e[27]=m,e[28]=A,e[29]=N,e[30]=R,e[31]=D,e[32]=z,e[33]=V,e[34]=$):$=e[34];const O=m?"1fr":"0fr";let U;e[35]!==O?(U={display:"grid",gridTemplateRows:O,transition:`grid-template-rows 180ms ${fc}`},e[35]=O,e[36]=U):U=e[36];let H;e[37]===Symbol.for("react.memo_cache_sentinel")?(H={overflow:"hidden",minHeight:0},e[37]=H):H=e[37];const Y=m?1:0;let G;e[38]!==Y?(G={opacity:Y,transition:`opacity 120ms ${fc}`},e[38]=Y,e[39]=G):G=e[39];let K;e[40]!==o?(K=o?i.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:i.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):i.jsx("div",{className:"border-t border-dashed border-border/60"}),e[40]=o,e[41]=K):K=e[41];let q;e[42]!==c||e[43]!==o?(q=c?i.jsx("div",{className:ne("overflow-clip pb-4",!o&&"pt-4"),children:c}):null,e[42]=c,e[43]=o,e[44]=q):q=e[44];let W;e[45]!==a||e[46]!==l?(W=a||l?i.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{children:a}),i.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[45]=a,e[46]=l,e[47]=W):W=e[47];let F;e[48]!==G||e[49]!==K||e[50]!==q||e[51]!==W?(F=i.jsx("div",{style:H,children:i.jsxs("div",{style:G,children:[K,q,W]})}),e[48]=G,e[49]=K,e[50]=q,e[51]=W,e[52]=F):F=e[52];let X;e[53]!==U||e[54]!==F?(X=i.jsx("div",{"data-testid":"collapsible-highlight-body",style:U,children:F}),e[53]=U,e[54]=F,e[55]=X):X=e[55];let Q;return e[56]!==$||e[57]!==X||e[58]!==L||e[59]!==f?(Q=i.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":f,className:L,children:[$,X]}),e[56]=$,e[57]=X,e[58]=L,e[59]=f,e[60]=Q):Q=e[60],Q}function N6(t){return!t}const A6=nn({content:Qt().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:h9(["pending","in_progress","completed"]),activeForm:Qt().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),Hm=nn({todos:j4(A6)}),T6="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.";$5({description:T6,inputSchema:B5(Hm),execute:async({todos:t})=>({ok:!0,count:t.length})});const E6="tool-todo_write",R6=new Set(["input-available","output-available"]);function Km(t){for(let e=t.length-1;e>=0;e--){const s=t[e];if(s.role!=="assistant")continue;const n=s.parts;if(Array.isArray(n))for(let r=n.length-1;r>=0;r--){const o=n[r];if(o.type!==E6||typeof o.state!="string"||!R6.has(o.state))continue;const a=Hm.safeParse(o.input);if(a.success)return a.data.todos}}return[]}function Wm(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const n="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:n,friendlyName:di(l5(n)),input:s.input})}return e}function qm(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const n=s.input;e.push({toolCallId:s.toolCallId,plan:n.plan,state:s.state})}return e}function P6(t){return t?t.message.startsWith("[CREDITS]"):!1}const I6={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1};function D6(t){const{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=t;if(!r&&s&&P6(s))return{...I6,isCreditExhausted:!0};const a=e.at(-1),l=a?.role==="assistant"?a.parts:[],c=l,h=!!c.filter(b=>b.type==="tool-user_ask").filter(b=>b.state!=="output-available").length,u=qm(l),f=Wm(c),m=Km(e),p=!r&&!!s,g=f.length>0||r&&o,x=u.length>0,_=!r&&!!n&&n!=="stop"&&!(n==="tool-calls"&&(h||g||x))&&!p;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:p,showWarning:_,hasApprovals:g,hasPlans:x,isWaitingForUserInput:h}}function Gm(){const t=B.c(6),{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=js(),a=s??null,l=n??null;let c;return t[0]!==r||t[1]!==o||t[2]!==e||t[3]!==a||t[4]!==l?(c=D6({messages:e,error:a,finishReason:l,isStreaming:r,isWaitingForApprovals:o}),t[0]=r,t[1]=o,t[2]=e,t[3]=a,t[4]=l,t[5]=c):c=t[5],c}function M6(){const t=Gm();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function Ym(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(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}const O6="__home__";function G9(t,e){return v1.chatDraft(t,e)}function $6(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 s=e.tiptapDoc;return!s||typeof s!="object"||s.type!=="doc"||!Array.isArray(s.content)?null:s}function B6(t,e,s,n,r){const o=G9(e,s);if(Ym(n)){t.removeItem(o);return}const a={tiptapDoc:n,updatedAt:Date.now()},l=JSON.stringify(a);try{t.setItem(o,l)}catch(c){if(F6(c)){const d=new TextEncoder().encode(l).byteLength;r?.onQuotaExceeded?.({docSizeBytes:d});return}throw c}}function ju(t,e,s){const n=G9(e,s),r=t.getItem(n),o=$6(r);return r!==null&&o===null&&t.removeItem(n),o}function z6(t,e,s){t.removeItem(G9(e,s))}function F6(t){if(!t||typeof t!="object")return!1;const e=t.name;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"}function U6(t){const e=B.c(21),{current:s,total:n,onPrev:r,onNext:o}=t;if(n<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=ne("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Vl,{size:14}),e[2]=d):d=e[2];let h;e[3]!==r||e[4]!==a||e[5]!==c?(h=i.jsx("button",{type:"button",onClick:r,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=a,e[5]=c,e[6]=h):h=e[6];const u=s+1;let f;e[7]!==u||e[8]!==n?(f=i.jsxs("span",{className:"tabular-nums text-xs",children:[u," of ",n]}),e[7]=u,e[8]=n,e[9]=f):f=e[9];const m=s===n-1,p=s===n-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=ne("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(To,{size:14}),e[12]=x):x=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=i.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:x}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let _;return e[17]!==v||e[18]!==h||e[19]!==f?(_=i.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[h,f,v]}),e[17]=v,e[18]=h,e[19]=f,e[20]=_):_=e[20],_}function Jm(t){const e=B.c(8),{currentIndex:s,total:n,onPrev:r,onNext:o,extraLeft:a}=t;let l;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==n?(l=i.jsx(U6,{current:s,total:n,onPrev:r,onNext:o}),e[0]=s,e[1]=o,e[2]=r,e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=i.jsxs("div",{className:"flex items-center gap-2",children:[l,a]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function H6(t){const e=B.c(17),{isStreaming:s,isAllAnswered:n,isCurrentAnswered:r,onAdvanceOrSubmit:o,submitLabel:a,nextLabel:l}=t,h=n?a===void 0?"Submit":a:l===void 0?"Next":l,u=n?s:!r,f=u?n?"Waiting for the assistant to finish…":"Answer this item to continue":null;let m;e[0]!==u||e[1]!==o?(m=()=>{u||o()},e[0]=u,e[1]=o,e[2]=m):m=e[2];const p=u&&"opacity-50 cursor-not-allowed";let g;e[3]!==p?(g=ne("h-7 px-2.5 text-xs",p),e[3]=p,e[4]=g):g=e[4];let x;e[5]!==u||e[6]!==h||e[7]!==m||e[8]!==g?(x=i.jsx(ie,{type:"button",size:"sm","aria-disabled":u,onClick:m,className:g,children:h}),e[5]=u,e[6]=h,e[7]=m,e[8]=g,e[9]=x):x=e[9];const v=x;if(!f)return v;let _;e[10]!==v?(_=i.jsx(Re,{asChild:!0,children:v}),e[10]=v,e[11]=_):_=e[11];let b;e[12]!==f?(b=i.jsx(Pe,{children:f}),e[12]=f,e[13]=b):b=e[13];let y;return e[14]!==_||e[15]!==b?(y=i.jsxs(Ie,{children:[_,b]}),e[14]=_,e[15]=b,e[16]=y):y=e[16],y}function Xm(t,e,s){return t.findIndex(n=>e(n)===s)}function Cu(t,e,s,n){return t.length===0?!1:t.every(r=>n(s[e(r)]))}function Vu(t,e,s,n,r){if(t.length===0)return null;const o=Xm(t,e,r);for(let a=1;a<=t.length;a++){const l=t[(o+a)%t.length];if(!l)continue;const c=e(l);if(c!==r&&!n(s[c]))return c}return null}function K6(t){return!t.isStreaming&&t.allAnswered}function Qm(t){const{parts:e,partKey:s,schema:n,defaultValues:r,isStreaming:o,hasAnswer:a,onSubmit:l}=t,c=e[0]?s(e[0]):"",[d,h]=C.useState(c),[u,f]=C.useState(!1),m=f9({resolver:_1(n),defaultValues:r}),p=m.watch(),g=Xm(e,s,d),x=g>=0?e[g]:void 0,v=a(p[d]),_=Cu(e,s,p,a),b=K6({isStreaming:o,allAnswered:_}),y=()=>{if(g>0){const T=e[g-1];T&&h(s(T))}},L=()=>{if(g>=0&&g<e.length-1){const T=e[g+1];T&&h(s(T))}},w=()=>{const T=m.getValues(),A=Vu(e,s,T,a,d);A&&h(A)},S=()=>{m.handleSubmit(T=>{const A=T;for(const N of e)l(N,A[s(N)])})()},j=C.useRef(S);j.current=S;const V=()=>{b&&(f(!1),j.current())},k=()=>{const T=m.getValues();if(Cu(e,s,T,a)){if(o){f(!0);return}f(!1),j.current()}else{const A=Vu(e,s,T,a,d);A&&h(A)}};return C.useEffect(()=>{if(u&&!o){if(!_){f(!1);return}f(!1),j.current()}},[u,o,_]),{form:m,activeKey:d,setActiveKey:h,currentIndex:g,currentPart:x,isCurrentAnswered:v,isAllAnswered:_,canSubmit:b,goPrev:y,goNext:L,advanceToNextUnanswered:w,submit:V,submitOrAdvance:k}}const Zm="User denied this tool call, give other alternatives.";function e2(t){const e=B.c(9),{onYolo:s}=t,[n,r]=sr();let o;e[0]!==s||e[1]!==n||e[2]!==r?(o=h=>{const u=h,f=n.toolApprovalLevel??"readonly";r({...n,toolApprovalLevel:u}),u==="auto"&&s(f)},e[0]=s,e[1]=n,e[2]=r,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(zt,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:q6,children:i.jsx(Gt,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx($t,{children:Pr.map(W6)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==n.toolApprovalLevel?(d=i.jsxs(Bt,{value:n.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=n.toolApprovalLevel,e[8]=d):d=e[8],d}function W6(t){return i.jsx(nt,{value:t.value,children:t.label},t.value)}function q6(t){return t.stopPropagation()}function t2(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let n;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],n=o}catch{n=String(s)}let r;return e[3]!==n?(r=i.jsx("div",{className:"px-4",children:i.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:n})}),e[3]=n,e[4]=r):r=e[4],r}function G6(t){const e=B.c(28),{approval:s,onRespond:n}=t,[r]=sr(),o=r.toolApprovalLevel??"readonly";let a;e[0]!==s.approvalId||e[1]!==o||e[2]!==n?(a=()=>n(s.approvalId,!1,Zm,o),e[0]=s.approvalId,e[1]=o,e[2]=n,e[3]=a):a=e[3];const l=a;let c;e[4]!==s.approvalId||e[5]!==o||e[6]!==n?(c=()=>n(s.approvalId,!0,void 0,o),e[4]=s.approvalId,e[5]=o,e[6]=n,e[7]=c):c=e[7];const d=c;let h;e[8]!==s.approvalId||e[9]!==n?(h=L=>n(s.approvalId,!0,void 0,L),e[8]=s.approvalId,e[9]=n,e[10]=h):h=e[10];const u=h;let f;e[11]!==u?(f=i.jsx("div",{className:"flex items-center gap-2",children:i.jsx(e2,{onYolo:u})}),e[11]=u,e[12]=f):f=e[12];const m=f;let p;e[13]!==l?(p=i.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:l,children:"Deny"}),e[13]=l,e[14]=p):p=e[14];let g;e[15]!==d?(g=i.jsx(ie,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:d,children:"Accept"}),e[15]=d,e[16]=g):g=e[16];let x;e[17]!==p||e[18]!==g?(x=i.jsxs(i.Fragment,{children:[p,g]}),e[17]=p,e[18]=g,e[19]=x):x=e[19];const v=x;let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(jl,{size:14}),e[20]=_):_=e[20];let b;e[21]!==s.input?(b=i.jsx(t2,{input:s.input}),e[21]=s.input,e[22]=b):b=e[22];let y;return e[23]!==s.friendlyName||e[24]!==m||e[25]!==v||e[26]!==b?(y=i.jsx(Kn,{icon:_,label:"Approval needed",title:s.friendlyName,defaultExpanded:!0,footerLeft:m,footerRight:v,children:b}),e[23]=s.friendlyName,e[24]=m,e[25]=v,e[26]=b,e[27]=y):y=e[27],y}const Y6=C4(Qt(),nn({approved:V4().optional(),levelOverride:h9(["auto","readonly"]).optional()}));function J6(t){const e=B.c(42),{approvals:s,isStreaming:n,onRespond:r}=t,[o]=sr(),a=o.toolApprovalLevel??"readonly";let l;e[0]!==s?(l=Object.fromEntries(s.map(Z6)),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]!==a||e[3]!==r?(d=(k,T)=>{const A=T;typeof A?.approved=="boolean"&&r(k.approvalId,A.approved,A.approved===!1?Zm:void 0,A.levelOverride??a)},e[2]=a,e[3]=r,e[4]=d):d=e[4];let h;e[5]!==s||e[6]!==c||e[7]!==n||e[8]!==d?(h={parts:s,partKey:Q6,schema:Y6,defaultValues:c,isStreaming:n,hasAnswer:X6,onSubmit:d},e[5]=s,e[6]=c,e[7]=n,e[8]=d,e[9]=h):h=e[9];const u=Qm(h);let f;e[10]!==s||e[11]!==u?(f=k=>{u.form.reset(Object.fromEntries(s.map(T=>[T.approvalId,{approved:!0,levelOverride:k}]))),u.submitOrAdvance()},e[10]=s,e[11]=u,e[12]=f):f=e[12];const m=f,p=u.currentPart;let g;e[13]!==u?(g=k=>{k.preventDefault(),u.submit()},e[13]=u,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(jl,{size:14}),e[15]=x):x=e[15];const v=`${s.length} approvals pending`,_=p?.friendlyName??"";let b;e[16]!==m?(b=i.jsx(e2,{onYolo:m}),e[16]=m,e[17]=b):b=e[17];let y;e[18]!==s.length||e[19]!==u.currentIndex||e[20]!==u.goNext||e[21]!==u.goPrev||e[22]!==b?(y=i.jsx(Jm,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext,extraLeft:b}),e[18]=s.length,e[19]=u.currentIndex,e[20]=u.goNext,e[21]=u.goPrev,e[22]=b,e[23]=y):y=e[23];let L;e[24]!==p||e[25]!==u.form.control||e[26]!==u.submitOrAdvance?(L=p?i.jsx(e_,{approvalId:p.approvalId,control:u.form.control,onChange:u.submitOrAdvance}):null,e[24]=p,e[25]=u.form.control,e[26]=u.submitOrAdvance,e[27]=L):L=e[27];let w;e[28]!==p?(w=p?i.jsx(t2,{input:p.input}):null,e[28]=p,e[29]=w):w=e[29];let S;e[30]!==y||e[31]!==L||e[32]!==w||e[33]!==v||e[34]!==_?(S=i.jsx(Kn,{icon:x,label:v,title:_,defaultExpanded:!0,footerLeft:y,footerRight:L,children:w}),e[30]=y,e[31]=L,e[32]=w,e[33]=v,e[34]=_,e[35]=S):S=e[35];let j;e[36]!==S||e[37]!==g?(j=i.jsx("form",{onSubmit:g,children:S}),e[36]=S,e[37]=g,e[38]=j):j=e[38];let V;return e[39]!==u.form||e[40]!==j?(V=i.jsx(o0,{...u.form,children:j}),e[39]=u.form,e[40]=j,e[41]=V):V=e[41],V}function X6(t){return typeof t?.approved=="boolean"}function Q6(t){return t.approvalId}function Z6(t){return[t.approvalId,{approved:void 0}]}function e_(t){const e=B.c(6),{approvalId:s,control:n,onChange:r}=t,o=`${s}.approved`;let a;e[0]!==r?(a=c=>{const{field:d}=c,h=d.value===!0,u=d.value===!1;return i.jsxs(i.Fragment,{children:[i.jsx(ie,{type:"button",variant:u?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!1),r()},"aria-pressed":u,children:"Deny"}),i.jsx(ie,{type:"button",variant:h?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!0),r()},"aria-pressed":h,children:"Accept"})]})},e[0]=r,e[1]=a):a=e[1];let l;return e[2]!==n||e[3]!==o||e[4]!==a?(l=i.jsx(fs,{control:n,name:o,render:a}),e[2]=n,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function t_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.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:[i.jsx(jl,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function s_(t){const e=B.c(8),{approvals:s,isStreaming:n,onRespond:r}=t;if(n&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(t_,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;if(s.length===1){const a=s[0];if(!a)return null;let l;return e[1]!==r||e[2]!==a?(l=i.jsx(G6,{approval:a,onRespond:r}),e[1]=r,e[2]=a,e[3]=l):l=e[3],l}let o;return e[4]!==s||e[5]!==n||e[6]!==r?(o=i.jsx(J6,{approvals:s,isStreaming:n,onRespond:r}),e[4]=s,e[5]=n,e[6]=r,e[7]=o):o=e[7],o}function n_(t){const e=B.c(16),{plan:s,onApprove:n,onDismiss:r}=t;let o;e[0]!==n||e[1]!==s.plan?(o=()=>{n(s.plan)},e[0]=n,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==r?(l=i.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:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let c;e[5]!==a?(c=i.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]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=i.jsxs(i.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const h=d;let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(X1,{size:14}),e[10]=u):u=e[10];let f;e[11]!==s.plan?(f=i.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:i.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:i.jsx(c5,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[11]=s.plan,e[12]=f):f=e[12];let m;return e[13]!==h||e[14]!==f?(m=i.jsx(Kn,{icon:u,label:"Plan ready",title:"Implementation Plan",defaultExpanded:!0,footerRight:h,children:f}),e[13]=h,e[14]=f,e[15]=m):m=e[15],m}function i_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.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:[i.jsx(Tt,{className:"size-5 text-purple-500 shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function r_(t){const e=B.c(7),{plans:s,isStreaming:n,onApprove:r,onDismiss:o}=t;if(n&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(i_,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==r||e[5]!==o?(c=i.jsx(n_,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function s2(t){return t?"response"in t?t.response:t.option??t.draft:""}const ku=nn({response:Qt().min(1,"Response is required")}),o_=nn({option:Qt().nullable(),draft:Qt()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),a_=nn({response:h9(["yes","no"])});function l_(t){switch(t.type){case"text":return ku;case"choice":return o_;case"confirm":return a_;default:return ku}}function c_(t){const e={};for(const s of t)e[s.toolCallId]=l_(s.input);return nn(e)}function d_(t){const e=B.c(6),{control:s,name:n,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:c}=l,d=c.value??"";return i.jsxs(R9,{children:[i.jsx(P9,{children:i.jsx("div",{className:"px-2",children:i.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(C9,{size:16,className:"text-muted-foreground"})}),i.jsx("input",{...c,value:d,type:"text",placeholder:r||"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"})]})})}),i.jsx(I9,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==n||e[4]!==o?(a=i.jsx(um,{control:s,name:n,render:o}),e[2]=s,e[3]=n,e[4]=o,e[5]=a):a=e[5],a}function n2(t,e){const s=B.c(4);let n,r;s[0]!==t||s[1]!==e?(n=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],s[0]=t,s[1]=e,s[2]=n,s[3]=r):(n=s[2],r=s[3]),C.useEffect(n,r)}function u_(t){const e=B.c(40),{control:s,name:n,options:r}=t,o=`${n}.option`;let a;e[0]!==s||e[1]!==o?(a={control:s,name:o,defaultValue:null},e[0]=s,e[1]=o,e[2]=a):a=e[2];const{field:l}=uu(a),c=`${n}.draft`;let d;e[3]!==s||e[4]!==c?(d={control:s,name:c,defaultValue:""},e[3]=s,e[4]=c,e[5]=d):d=e[5];const{field:h}=uu(d),u=l.value,f=h.value??"";let m;if(e[6]!==l||e[7]!==r?(m=A=>{const N=r[A];N!=null&&l.onChange(N)},e[6]=l,e[7]=r,e[8]=m):m=e[8],n2(r.length,m),r.length===0)return null;const p=u===null;let g;if(e[9]!==l||e[10]!==u||e[11]!==r){let A;e[13]!==l||e[14]!==u?(A=(N,R)=>{const I=u===N;return i.jsxs("button",{type:"button",onClick:()=>l.onChange(N),className:ne("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",I&&"bg-accent/50",!I&&"hover:bg-accent/30"),"aria-label":`Select ${N}`,children:[i.jsx("span",{className:ne("flex items-center justify-center size-6 rounded-md text-sm shrink-0",I?"bg-chart-1 text-white":"bg-muted text-foreground"),children:R+1}),i.jsx("span",{className:"text-sm text-foreground truncate",children:N})]},`${R}-${N}`)},e[13]=l,e[14]=u,e[15]=A):A=e[15],g=r.map(A),e[9]=l,e[10]=u,e[11]=r,e[12]=g}else g=e[12];const x=p&&"bg-accent/50",v=!p&&"hover:bg-accent/30";let _;e[16]!==x||e[17]!==v?(_=ne("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",x,v),e[16]=x,e[17]=v,e[18]=_):_=e[18];let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(C9,{size:16,className:"text-muted-foreground"})}),e[19]=b):b=e[19];const y=p?f:"";let L;e[20]!==h||e[21]!==l||e[22]!==u?(L=A=>{h.onChange(A.target.value),u!==null&&l.onChange(null)},e[20]=h,e[21]=l,e[22]=u,e[23]=L):L=e[23];let w;e[24]!==l||e[25]!==u?(w=()=>{u!==null&&l.onChange(null)},e[24]=l,e[25]=u,e[26]=w):w=e[26];let S;e[27]!==y||e[28]!==L||e[29]!==w?(S=i.jsx("input",{type:"text",value:y,onChange:L,onFocus:w,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]=y,e[28]=L,e[29]=w,e[30]=S):S=e[30];let j;e[31]!==S||e[32]!==_?(j=i.jsxs("label",{className:_,children:[b,S]}),e[31]=S,e[32]=_,e[33]=j):j=e[33];let V;e[34]!==j||e[35]!==g?(V=i.jsx(P9,{children:i.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[g,j]})}),e[34]=j,e[35]=g,e[36]=V):V=e[36];let k;e[37]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx(I9,{}),e[37]=k):k=e[37];let T;return e[38]!==V?(T=i.jsxs(R9,{children:[V,k]}),e[38]=V,e[39]=T):T=e[39],T}function h_(t){const e=B.c(6),{control:s,name:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=C.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=h=>{a.current?.onChange(o[h]??"")},e[1]=l):l=e[1],n2(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=h=>{const{field:u}=h;return a.current=u,i.jsxs(R9,{children:[i.jsx(P9,{children:i.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=u.value===f;return i.jsxs("button",{type:"button",onClick:()=>u.onChange(f),className:ne("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 ${f}`,children:[i.jsx("span",{className:ne("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),i.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),i.jsx(I9,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==n?(d=i.jsx(um,{control:s,name:n,render:c}),e[3]=s,e[4]=n,e[5]=d):d=e[5],d}function Nu(t){const e=B.c(13),{input:s,control:n,toolCallId:r}=t;switch(s.type){case"text":{const o=`${r}.response`;let a;return e[0]!==n||e[1]!==s.default||e[2]!==o?(a=i.jsx(d_,{control:n,name:o,placeholder:s.default}),e[0]=n,e[1]=s.default,e[2]=o,e[3]=a):a=e[3],a}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==n||e[7]!==a||e[8]!==r?(l=i.jsx(u_,{control:n,name:r,options:a}),e[6]=n,e[7]=a,e[8]=r,e[9]=l):l=e[9],l}case"confirm":{const o=`${r}.response`;let a;return e[10]!==n||e[11]!==o?(a=i.jsx(h_,{control:n,name:o}),e[10]=n,e[11]=o,e[12]=a):a=e[12],a}default:return null}}function f_(t){const e=B.c(71),{parts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=c_(s.map(x_)),e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=Object.fromEntries(s.map(g_)),e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==r?(d=(E,P)=>{const M=s2(P);M&&r(E,M)},e[4]=r,e[5]=d):d=e[5];let h;e[6]!==c||e[7]!==n||e[8]!==s||e[9]!==a||e[10]!==d?(h={parts:s,partKey:p_,schema:a,defaultValues:c,isStreaming:n,hasAnswer:m_,onSubmit:d},e[6]=c,e[7]=n,e[8]=s,e[9]=a,e[10]=d,e[11]=h):h=e[11];const u=Qm(h),f=u.currentPart;let m;e[12]!==f||e[13]!==u?(m=()=>{const E=f;if(!E)return;const P=E.toolCallId;E.input?.type==="choice"?(u.form.setValue(`${P}.option`,null),u.form.setValue(`${P}.draft`,"user has skip this question")):u.form.setValue(`${P}.response`,"user has skip this question"),u.advanceToNextUnanswered()},e[12]=f,e[13]=u,e[14]=m):m=e[14];const p=m;let g;e[15]!==u.currentIndex||e[16]!==u.goNext||e[17]!==u.goPrev||e[18]!==s.length?(g=i.jsx(Jm,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext}),e[15]=u.currentIndex,e[16]=u.goNext,e[17]=u.goPrev,e[18]=s.length,e[19]=g):g=e[19];const x=g;let v;e[20]!==p?(v=i.jsx(ie,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7",children:"Skip"}),e[20]=p,e[21]=v):v=e[21];let _;e[22]!==u.isAllAnswered||e[23]!==u.isCurrentAnswered||e[24]!==u.submitOrAdvance||e[25]!==n?(_=i.jsx(H6,{isStreaming:n,isAllAnswered:u.isAllAnswered,isCurrentAnswered:u.isCurrentAnswered,onAdvanceOrSubmit:u.submitOrAdvance}),e[22]=u.isAllAnswered,e[23]=u.isCurrentAnswered,e[24]=u.submitOrAdvance,e[25]=n,e[26]=_):_=e[26];let b;e[27]!==v||e[28]!==_?(b=i.jsxs(i.Fragment,{children:[v,_]}),e[27]=v,e[28]=_,e[29]=b):b=e[29];const y=b;if(s.length===1){const E=s[0];if(!E?.input)return null;let P;e[30]!==u?(P=G=>{G.preventDefault(),u.submit()},e[30]=u,e[31]=P):P=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx(a0,{size:14}),e[32]=M):M=e[32];const z=E.input?.prompt??"Question",$=E.input;let O;e[33]!==u.form.control||e[34]!==E.toolCallId||e[35]!==$?(O=i.jsx(Nu,{input:$,control:u.form.control,toolCallId:E.toolCallId}),e[33]=u.form.control,e[34]=E.toolCallId,e[35]=$,e[36]=O):O=e[36];let U;e[37]!==y||e[38]!==z||e[39]!==O?(U=i.jsx(Kn,{icon:M,label:"Question pending",title:z,defaultExpanded:!0,footerRight:y,children:O}),e[37]=y,e[38]=z,e[39]=O,e[40]=U):U=e[40];let H;e[41]!==P||e[42]!==U?(H=i.jsx("form",{onSubmit:P,autoComplete:"off",children:U}),e[41]=P,e[42]=U,e[43]=H):H=e[43];let Y;return e[44]!==u.form||e[45]!==H?(Y=i.jsx(o0,{...u.form,children:H}),e[44]=u.form,e[45]=H,e[46]=Y):Y=e[46],Y}const L=u.form;let w;e[47]!==u?(w=E=>{E.preventDefault(),u.submit()},e[47]=u,e[48]=w):w=e[48];let S;e[49]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(a0,{size:14}),e[49]=S):S=e[49];const j=`${u.currentIndex+1} of ${s.length}`,V=f?.input?.prompt??"Question",k=u.activeKey,T=u.setActiveKey;let A;if(e[50]!==u.form||e[51]!==s){let E;e[53]!==u.form?(E=P=>i.jsx(ri,{value:P.toolCallId,className:"mt-0",children:i.jsx(Nu,{input:P.input,control:u.form.control,toolCallId:P.toolCallId})},P.toolCallId),e[53]=u.form,e[54]=E):E=e[54],A=s.map(E),e[50]=u.form,e[51]=s,e[52]=A}else A=e[52];let N;e[55]!==u.activeKey||e[56]!==u.setActiveKey||e[57]!==A?(N=i.jsx(Eo,{value:k,onValueChange:T,children:A}),e[55]=u.activeKey,e[56]=u.setActiveKey,e[57]=A,e[58]=N):N=e[58];let R;e[59]!==x||e[60]!==y||e[61]!==j||e[62]!==V||e[63]!==N?(R=i.jsx(Kn,{icon:S,label:"Question pending",count:j,title:V,defaultExpanded:!0,footerLeft:x,footerRight:y,children:N}),e[59]=x,e[60]=y,e[61]=j,e[62]=V,e[63]=N,e[64]=R):R=e[64];let I;e[65]!==w||e[66]!==R?(I=i.jsx("form",{onSubmit:w,autoComplete:"off",children:R}),e[65]=w,e[66]=R,e[67]=I):I=e[67];let D;return e[68]!==u.form||e[69]!==I?(D=i.jsx(o0,{...L,children:I}),e[68]=u.form,e[69]=I,e[70]=D):D=e[70],D}function m_(t){return!!s2(t)}function p_(t){return t.toolCallId}function g_(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function x_(t){return{toolCallId:t.toolCallId,input:t.input}}function v_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.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:[i.jsx(a0,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function i2(t){const e=B.c(7),{userAskParts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(__),e[0]=s,e[1]=o):o=e[1];const a=o;if(a.length===0){if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(v_,{}),e[2]=c):c=e[2],c}return null}let l;return e[3]!==n||e[4]!==r||e[5]!==a?(l=i.jsx(f_,{parts:a,isStreaming:n,onSubmit:r}),e[3]=n,e[4]=r,e[5]=a,e[6]=l):l=e[6],l}function __(t){return t.state==="input-available"}function b_(t){const e=t.filter(o=>o.status==="in_progress"),s=t.filter(o=>o.status==="completed").length,n=t.length;if(n>0&&s===n)return{icon:"completed",activity:"All done",progress:`${n}/${n}`};const[r]=e;return r&&e.length===1?{icon:"in_progress",activity:r.activeForm,progress:`${s}/${n} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${s}/${n} done`}:s>0?{icon:"pending",activity:`${n-s} pending`,progress:`${s}/${n} done`}:{icon:"pending",activity:`${n} todos`,progress:"not started"}}function y_(){const t=B.c(21),{messages:e}=js();let s,n,r,o,a,l,c,d,h;if(t[0]!==e){h=Symbol.for("react.early_return_sentinel");e:{const m=Km(e);if(m.length===0){h=null;break e}const p=b_(m);s=Kn,a=i.jsx(j_,{status:p.icon}),l=p.activity,c=p.progress,d=!1,n="todos-list",r="flex flex-col px-2 max-h-[40vh] overflow-y-auto",o=m.map(L_)}t[0]=e,t[1]=s,t[2]=n,t[3]=r,t[4]=o,t[5]=a,t[6]=l,t[7]=c,t[8]=d,t[9]=h}else s=t[1],n=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],d=t[8],h=t[9];if(h!==Symbol.for("react.early_return_sentinel"))return h;let u;t[10]!==n||t[11]!==r||t[12]!==o?(u=i.jsx("ul",{"data-testid":n,className:r,children:o}),t[10]=n,t[11]=r,t[12]=o,t[13]=u):u=t[13];let f;return t[14]!==s||t[15]!==a||t[16]!==l||t[17]!==c||t[18]!==d||t[19]!==u?(f=i.jsx(s,{icon:a,label:l,count:c,defaultExpanded:d,children:u}),t[14]=s,t[15]=a,t[16]=l,t[17]=c,t[18]=d,t[19]=u,t[20]=f):f=t[20],f}function L_(t,e){return i.jsx(S_,{todo:t},e)}function S_(t){const e=B.c(14),{todo:s}=t,n=s.status==="completed",o=s.status==="in_progress"?s.activeForm:s.content;let a;e[0]!==s.status?(a=i.jsx(w_,{status:s.status}),e[0]=s.status,e[1]=a):a=e[1];const l=n&&"text-muted-foreground";let c;e[2]!==l?(c=ne("relative text-sm leading-snug pt-px select-none",l),e[2]=l,e[3]=c):c=e[3];const d=n?"100%":"0%",h=n?"width 300ms ease 200ms":"width 150ms ease";let u;e[4]!==d||e[5]!==h?(u=i.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:d,transition:h}}),e[4]=d,e[5]=h,e[6]=u):u=e[6];let f;e[7]!==o||e[8]!==c||e[9]!==u?(f=i.jsxs("span",{className:c,children:[o,u]}),e[7]=o,e[8]=c,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==a||e[12]!==f?(m=i.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,f]}),e[11]=a,e[12]=f,e[13]=m):m=e[13],m}function w_(t){const e=B.c(4),{status:s}=t,n=s==="completed"?"true":void 0,r=s==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("svg",{viewBox:"0 0 21 21",children:i.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]=o):o=e[0];let a;return e[1]!==n||e[2]!==r?(a=i.jsx("div",{className:"todo-cb mt-0.5","data-checked":n,"data-progress":r,"aria-hidden":"true",children:o}),e[1]=n,e[2]=r,e[3]=a):a=e[3],a}function j_(t){const e=B.c(3),{status:s}=t;if(s==="completed"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:i.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:i.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=r):r=e[0],r}if(s==="in_progress"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=r):r=e[1],r}let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.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]=n):n=e[2],n}const C_={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"}]},V_=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function r2(t){const e=B.c(41),{onDismiss:s}=t,{org:n}=Ae(),r=Ct(),{decoKeyId:o}=D9(),a=Ms(),[l,c]=C.useState(""),[d,h]=C.useState(!1),[u,f]=C.useState("usd"),m=u==="brl"?"R$":"$";let p,g;e[0]!==n.id?(p=()=>{Ce("credits_exhausted_shown",{organization_id:n.id})},g=[n.id],e[0]=n.id,e[1]=p,e[2]=g):(p=e[1],g=e[2]),C.useEffect(p,g);let x;e[3]!==u||e[4]!==a?(x=async E=>{const{url:P}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:E,currency:u});return P},e[3]=u,e[4]=a,e[5]=x):x=e[5];let v;e[6]!==s?(v=E=>{E&&window.open(E,"_blank","noopener,noreferrer"),s?.()},e[6]=s,e[7]=v):v=e[7];let _;e[8]!==x||e[9]!==v?(_={mutationFn:x,onSuccess:v,onError:A_},e[8]=x,e[9]=v,e[10]=_):_=e[10];const{mutate:b,isPending:y}=Ds(_),L=parseFloat(l),w=!isNaN(L)&&L>=1;let S;e[11]!==s?(S=E=>!E&&s?.(),e[11]=s,e[12]=S):S=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=["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]=j):j=e[13];let V;e[14]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[14]=V):V=e[14];let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[V,i.jsxs(ns,{className:"relative gap-4",children:[i.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"}),i.jsxs("div",{children:[i.jsx(is,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),i.jsx(qn,{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]=k):k=e[15];let T;e[16]!==u||e[17]!==m||e[18]!==l||e[19]!==L||e[20]!==o||e[21]!==w||e[22]!==y||e[23]!==d||e[24]!==b?(T=o&&i.jsxs("div",{className:"px-8 pt-5 pb-6",children:[i.jsx("div",{className:"mb-4",children:i.jsxs(fm,{type:"single",variant:"outline",size:"sm",value:u,onValueChange:E=>{E&&f(E)},children:[i.jsx(za,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),i.jsx(za,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),i.jsxs("div",{className:"rounded-xl border border-border p-5",children:[i.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:C_[u].map(E=>{const{dollars:P,label:M}=E;return i.jsxs("button",{type:"button",disabled:y,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:P*100,currency:u,tier_label:M,source:"exhausted_banner"}),b(P*100)},className:ne("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:[i.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,P]}),i.jsx("span",{className:"text-xs text-muted-foreground",children:M})]},P)})}),d?i.jsxs("div",{className:"flex gap-2 mt-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),i.jsx(Ye,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:E=>c(E.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),i.jsx(ie,{className:"h-10",disabled:!w||y,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:Math.round(L*100),currency:u,tier_label:"custom",source:"exhausted_banner"}),b(Math.round(L*100))},children:y?"Opening...":"Add"})]}):i.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),i.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:V_.map(k_)})]}),e[16]=u,e[17]=m,e[18]=l,e[19]=L,e[20]=o,e[21]=w,e[22]=y,e[23]=d,e[24]=b,e[25]=T):T=e[25];let A;e[26]!==s?(A=i.jsx(ie,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[26]=s,e[27]=A):A=e[27];let N;e[28]!==r||e[29]!==s||e[30]!==n.slug?(N=i.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:n.slug}}),s?.()},children:"Manage providers"}),e[28]=r,e[29]=s,e[30]=n.slug,e[31]=N):N=e[31];let R;e[32]!==A||e[33]!==N?(R=i.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[A,N]}),e[32]=A,e[33]=N,e[34]=R):R=e[34];let I;e[35]!==T||e[36]!==R?(I=i.jsxs(Ft,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:N_,children:[k,T,R]}),e[35]=T,e[36]=R,e[37]=I):I=e[37];let D;return e[38]!==I||e[39]!==S?(D=i.jsx(Ut,{open:!0,onOpenChange:S,children:I}),e[38]=I,e[39]=S,e[40]=D):D=e[40],D}function k_(t){return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:i.jsx(Tt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),i.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function N_(t){return t.preventDefault()}function A_(t){de.error(`Top-up failed: ${t.message}`)}function T_(){const t=B.c(5),e=ir(),s=gm(),[n,r]=C.useState(!1);if(!(e?.lockedSandbox==="user-desktop")||!s.ready||s.online)return null;let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(ar,{size:14}),t[0]=a):a=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(ie,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>r(!0),children:"Reconnect desktop"}),t[1]=l):l=t[1];let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Kn,{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:l,children:i.jsxs("p",{className:"mx-4 text-xs text-muted-foreground",children:["Run ",i.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]=c):c=t[2];let d;return t[3]!==n?(d=i.jsxs(i.Fragment,{children:[c,i.jsx(Ox,{open:n,onOpenChange:r})]}),t[3]=n,t[4]=d):d=t[4],d}function E_(t){const e=t.trim(),s=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),n=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),r=/failed to fetch|networkerror|load failed|offline/i.test(e),o=/timeout|timed out|aborted|deadline/i.test(e),a=e.length>240,l=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(l){const c=l[1]?.trim().replace(/\.$/,"");return{summary:c?`Your sandbox didn't finish starting up (${c}). 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}:n||s&&a?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:r?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:o?{summary:"That took longer than expected. Try again.",rawDetails:t}:s||a?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const R_={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 Qa(t){const e=B.c(19),{variant:s,onDismiss:n}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?fn:nr,l=r?t.error.message:R_[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`;let c;e[0]!==r||e[1]!==l?(c=r?E_(l):{summary:l,rawDetails:null},e[0]=r,e[1]=l,e[2]=c):c=e[2];const{summary:d,rawDetails:h}=c;let u;e[3]!==a?(u=i.jsx(a,{size:14}),e[3]=a,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==t.onContinue||e[7]!==t.onFixInChat?(f=r?i.jsx(ie,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}):i.jsx(ie,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"}),e[5]=r,e[6]=t.onContinue,e[7]=t.onFixInChat,e[8]=f):f=e[8];let m;e[9]!==h?(m=h?i.jsxs("details",{className:"group mx-4",children:[i.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:[i.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:i.jsx("path",{d:"m4.5 3 3 3-3 3"})}),i.jsx("span",{className:"group-open:hidden",children:"Show technical details"}),i.jsx("span",{className:"hidden group-open:inline",children:"Hide technical details"})]}),i.jsxs("div",{className:"relative mt-2",children:[i.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(h).then(I_).catch(P_)},"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:i.jsx(Ss,{className:"size-3.5"})}),i.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:h})]})]}):null,e[9]=h,e[10]=m):m=e[10];let p;return e[11]!==o||e[12]!==n||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==m||e[17]!==s?(p=i.jsx(Kn,{icon:u,label:o,title:d,defaultExpanded:!0,variant:s,onClose:n,footerRight:f,children:m}),e[11]=o,e[12]=n,e[13]=d,e[14]=u,e[15]=f,e[16]=m,e[17]=s,e[18]=p):p=e[18],p}function P_(){return de.error("Could not copy")}function I_(){return de.success("Copied to clipboard")}function Il(){const t=B.c(62),{error:e,clearError:s,finishReason:n,clearFinishReason:r,messages:o,isStreaming:a,submit:l,sendMessage:c}=js(),[d,h]=sr(),{virtualMcpId:u,createTaskWithMessage:f}=as(),{chatMode:m,simpleModeTier:p}=xs();let g;t[0]!==m||t[1]!==p||t[2]!==u?(g=J=>({tier:p,mode:m,toolApprovalLevel:J,agent:u?{id:u}:void 0}),t[0]=m,t[1]=p,t[2]=u,t[3]=g):g=t[3];const x=g;let v;t[4]!==d.toolApprovalLevel?(v=d.toolApprovalLevel??k4(),t[4]=d.toolApprovalLevel,t[5]=v):v=t[5];const _=v,b=o.at(-1),y=b?.role==="assistant"?b.parts:[],L=y.filter($_),w=qm(y),S=Wm(y);let j;t[6]!==e||t[7]!==c?(j=()=>{if(e){const ee={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};c(ee)}},t[6]=e,t[7]=c,t[8]=j):j=t[8];const V=j;let k;t[9]!==c?(k=()=>{c({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[9]=c,t[10]=k):k=t[10];const T=k;let A;t[11]!==x||t[12]!==_||t[13]!==l?(A=(J,ee)=>{l({kind:"toolOutput",toolCallId:J.toolCallId,output:{response:ee}},x(_))},t[11]=x,t[12]=_,t[13]=l,t[14]=A):A=t[14];const N=A;let R;t[15]!==f||t[16]!==d||t[17]!==h||t[18]!==u?(R=J=>{h({...d,toolApprovalLevel:"auto"}),f({virtualMcpId:u,message:{parts:[{type:"text",text:`Implement this plan:
|
|
3
3
|
|
|
4
4
|
${J}`}]}})},t[15]=f,t[16]=d,t[17]=h,t[18]=u,t[19]=R):R=t[19];const I=R,D=O_;let E;t[20]!==x||t[21]!==l?(E=(J,ee,te,ae)=>{l({kind:"approval",approvalId:J,approved:ee,...te?{reason:te}:{}},x(ae))},t[20]=x,t[21]=l,t[22]=E):E=t[22];const P=E,M=Gm();if(M.isCreditExhausted){let J;return t[23]!==s?(J=i.jsx(r2,{onDismiss:s}),t[23]=s,t[24]=J):J=t[24],J}const{showError:z,showWarning:$,hasApprovals:O}=M,U=L.map(M_).join("|"),H=w[0]?.toolCallId??"",Y=S.map(D_).join("|");let G,K;t[25]===Symbol.for("react.memo_cache_sentinel")?(G=i.jsx(y_,{}),K=i.jsx(T_,{}),t[25]=G,t[26]=K):(G=t[25],K=t[26]);let q;t[27]!==s||t[28]!==e||t[29]!==V||t[30]!==z?(q=z&&i.jsx(Qa,{variant:"error",error:e,onDismiss:s,onFixInChat:V}),t[27]=s,t[28]=e,t[29]=V,t[30]=z,t[31]=q):q=t[31];let W;t[32]!==r||t[33]!==n||t[34]!==T||t[35]!==$?(W=$&&i.jsx(Qa,{variant:"warning",finishReason:n,onDismiss:r,onContinue:T}),t[32]=r,t[33]=n,t[34]=T,t[35]=$,t[36]=W):W=t[36];let F;t[37]!==Y||t[38]!==P||t[39]!==O||t[40]!==a||t[41]!==S?(F=O&&i.jsx(s_,{approvals:S,isStreaming:a,onRespond:P},Y),t[37]=Y,t[38]=P,t[39]=O,t[40]=a,t[41]=S,t[42]=F):F=t[42];let X;t[43]!==M.hasPlans||t[44]!==I||t[45]!==D||t[46]!==a||t[47]!==w||t[48]!==H?(X=M.hasPlans&&i.jsx(r_,{plans:w,isStreaming:a,onApprove:I,onDismiss:D},H),t[43]=M.hasPlans,t[44]=I,t[45]=D,t[46]=a,t[47]=w,t[48]=H,t[49]=X):X=t[49];let Q;t[50]!==M.isWaitingForUserInput||t[51]!==N||t[52]!==a||t[53]!==U||t[54]!==L?(Q=M.isWaitingForUserInput&&i.jsx(i2,{userAskParts:L,isStreaming:a,onSubmit:N},U),t[50]=M.isWaitingForUserInput,t[51]=N,t[52]=a,t[53]=U,t[54]=L,t[55]=Q):Q=t[55];let Z;return t[56]!==W||t[57]!==F||t[58]!==X||t[59]!==Q||t[60]!==q?(Z=i.jsxs("div",{className:"absolute bottom-full left-0 right-0",children:[G,K,q,W,F,X,Q]}),t[56]=W,t[57]=F,t[58]=X,t[59]=Q,t[60]=q,t[61]=Z):Z=t[61],Z}function D_(t){return t.approvalId}function M_(t){return t.toolCallId}function O_(){document.querySelector("[data-chat-input]")?.focus()}function $_(t){return t.type==="tool-user_ask"}Il.Error=function(e){return i.jsx(Qa,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};Il.Warning=function(e){return i.jsx(Qa,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};Il.UserAskQuestion=i2;function B_(t){const e=B.c(12),{taskId:s}=t,n=A1(s),r=Z4(n),o=e5(),{stop:a,removeLocalMessage:l}=js();if(r.length===0)return null;let c;e[0]!==a?(c=()=>{a()},e[0]=a,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(g9,{size:14}),e[2]=d):d=e[2];let h;e[3]!==c?(h=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",onClick:c,children:d})}),e[3]=c,e[4]=h):h=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Pe,{side:"top",children:i.jsx("p",{className:"text-xs",children:"Send now"})}),e[5]=u):u=e[5];let f;e[6]!==h?(f=i.jsxs(Ie,{delayDuration:400,children:[h,u]}),e[6]=h,e[7]=f):f=e[7];let m;return e[8]!==o||e[9]!==l||e[10]!==s?(m=(p,g)=>i.jsxs("div",{className:"group/queuerow flex items-center gap-2 px-3 py-1.5",children:[i.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:g+1}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:p.text}),i.jsx("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/queuerow:opacity-100",children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon-sm",title:"Remove from queue",onClick:()=>{o.cancel(s,p.messageId).then(x=>{x&&(t5(s,p.messageId),l(p.messageId))})},children:i.jsx(yn,{className:"size-3.5"})})})]},p.messageId),e[8]=o,e[9]=l,e[10]=s,e[11]=m):m=e[11],i.jsxs("div",{className:"mb-1 overflow-hidden rounded-2xl border border-border bg-card dark:bg-muted",children:[i.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:[i.jsxs("span",{children:[r.length," queued message",r.length>1?"s":""]}),f]}),r.map(m)]})}function z_(t){return(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"user"}function o2(t){const e=z_(t),s=Date.now().toString(36).split("").reverse().join("");return`${e}-${s}`}const Sa=100;function F_(t,e,s){const n=e.trim().toLowerCase();return n?(t??[]).some(r=>r.branches.some(o=>typeof o.name=="string"&&!s.has(o.name)&&o.name.toLowerCase().includes(n))):!0}function U_(t,e){const s=e.trim().toLowerCase();return s?[...t].some(n=>n.toLowerCase().includes(s)):!0}function H_(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(n=>n.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function K_(t){const e=B.c(48),{orgId:s,orgSlug:n,userId:r,connectionId:o,sandboxMap:a,owner:l,repo:c,enabled:d}=t,h=d===void 0?!0:d,u=o??null;let f;e[0]!==s||e[1]!==n||e[2]!==u?(f={connectionId:u,orgId:s,orgSlug:n},e[0]=s,e[1]=n,e[2]=u,e[3]=f):f=e[3];const m=pt(f);let p;e[4]!==o||e[5]!==s||e[6]!==n||e[7]!==l||e[8]!==c?(p=N4.githubBranches(s,n,o,l,c),e[4]=o,e[5]=s,e[6]=n,e[7]=l,e[8]=c,e[9]=p):p=e[9];const g=h&&!!o&&!!l&&!!c;let x;e[10]!==m||e[11]!==l||e[12]!==c?(x=async $=>{const{pageParam:O,signal:U}=$,H=Number(O),Y=await m.callTool({name:"list_branches",arguments:{owner:l,repo:c,page:H,perPage:Sa}},void 0,{signal:U}),G=H_(Y);return{branches:Array.isArray(G)?G:G.branches??[],default_branch:Array.isArray(G)?null:G.default_branch??null,page:H}},e[10]=m,e[11]=l,e[12]=c,e[13]=x):x=e[13];let v;e[14]!==p||e[15]!==g||e[16]!==x?(v={queryKey:p,enabled:g,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:x,getNextPageParam:X_},e[14]=p,e[15]=g,e[16]=x,e[17]=v):v=e[17];const{data:_,isLoading:b,isError:y,hasNextPage:L,isFetchingNextPage:w,fetchNextPage:S}=_m(v);let j,V;e[18]!==a||e[19]!==r?(V=new Set(Object.keys(a?.[r]??{})),j=[...V].sort().map(J_),e[18]=a,e[19]=r,e[20]=j,e[21]=V):(j=e[20],V=e[21]);const k=j;let T;if(e[22]!==_?.pages){const $=new Map;for(const U of _?.pages??[])for(const H of U.branches)typeof H.name=="string"&&$.set(H.name,H);T=[...$.values()].filter(Y_),e[22]=_?.pages,e[23]=T}else T=e[23];let A;e[24]!==T||e[25]!==V?(A=T.filter($=>!V.has($.name)).map(G_),e[24]=T,e[25]=V,e[26]=A):A=e[26];const N=A;let R;e[27]!==_?.pages?(R=_?.pages.find(q_)?.default_branch??null,e[27]=_?.pages,e[28]=R):R=e[28];const I=R;let D;e[29]!==_?.pages||e[30]!==S||e[31]!==w||e[32]!==V?(D=async($,O)=>{const U=O===void 0?W_:O;if(!U()||U_(V,$)||w)return;let H=_?.pages??[];for(;U()&&!F_(H,$,V)&&(H.at(-1)?.branches.length??Sa)>=Sa;){const Y=await S();if(!U())break;const G=Y.data?.pages??H;if(G.length===H.length)break;H=G}},e[29]=_?.pages,e[30]=S,e[31]=w,e[32]=V,e[33]=D):D=e[33];const E=D,P=L??!1;let M;e[34]!==S||e[35]!==L||e[36]!==w?(M=()=>{L&&!w&&S()},e[34]=S,e[35]=L,e[36]=w,e[37]=M):M=e[37];let z;return e[38]!==I||e[39]!==E||e[40]!==y||e[41]!==w||e[42]!==b||e[43]!==N||e[44]!==P||e[45]!==M||e[46]!==k?(z={yours:k,others:N,defaultBase:I,isLoading:b,isError:y,hasMore:P,isFetchingMore:w,fetchMore:M,fetchUntilMatch:E},e[38]=I,e[39]=E,e[40]=y,e[41]=w,e[42]=b,e[43]=N,e[44]=P,e[45]=M,e[46]=k,e[47]=z):z=e[47],z}function W_(){return!0}function q_(t){return t.default_branch}function G_(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Y_(t){return typeof t.name=="string"}function J_(t){return{name:t,source:"yours"}}function X_(t){if(!(t.branches.length<Sa))return t.page+1}function Q_(t){const e=B.c(85),{orgId:s,orgSlug:n,userId:r,userLabel:o,connectionId:a,owner:l,repo:c,sandboxMap:d,value:h,onChange:u,disabled:f,placement:m}=t,p=f===void 0?!1:f,x=(m===void 0?"chat":m)==="header",[v,_]=C.useState(!1),[b,y]=C.useState(""),[L,w]=C.useState(!1),S=C.useRef(0);let j;e[0]!==a||e[1]!==v||e[2]!==s||e[3]!==n||e[4]!==l||e[5]!==c||e[6]!==d||e[7]!==r?(j={orgId:s,orgSlug:n,userId:r,connectionId:a,sandboxMap:d,owner:l,repo:c,enabled:v},e[0]=a,e[1]=v,e[2]=s,e[3]=n,e[4]=l,e[5]=c,e[6]=d,e[7]=r,e[8]=j):j=e[8];const{yours:V,others:k,isLoading:T,isError:A,hasMore:N,isFetchingMore:R,fetchMore:I,fetchUntilMatch:D}=K_(j);let E;e[9]!==u?(E=ye=>{u(ye),_(!1)},e[9]=u,e[10]=E):E=e[10];const P=E,M=h??"Select branch…";let z;e[11]!==D?(z=ye=>{y(ye),S.current=S.current+1;const $e=S.current,Fe=ye.trim();if(!Fe){w(!1);return}w(!0),D(Fe,()=>$e===S.current).finally(()=>{$e===S.current&&w(!1)})},e[11]=D,e[12]=z):z=e[12];const $=z;let O;e[13]!==I?(O=ye=>{const $e=ye.currentTarget;$e.scrollHeight-$e.scrollTop-$e.clientHeight<48&&I()},e[13]=I,e[14]=O):O=e[14];const U=O,H=p?void 0:_,Y=x?"outline":"ghost",G=x?"sm":"default";let K;e[15]!==p||e[16]!==x?(K=ne("font-mono shrink min-w-0 max-w-[200px]",x?"gap-1.5 text-xs":ne("text-xs text-muted-foreground hover:text-foreground transition-[gap] duration-200",p?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5")),e[15]=p,e[16]=x,e[17]=K):K=e[17];let q;e[18]===Symbol.for("react.memo_cache_sentinel")?(q=i.jsx(an,{className:"h-3.5 w-3.5 shrink-0"}),e[18]=q):q=e[18];const W=x?"":"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 F;e[19]!==W?(F=ne("min-w-0 truncate",W),e[19]=W,e[20]=F):F=e[20];let X;e[21]!==M||e[22]!==F?(X=i.jsx("span",{className:F,children:M}),e[21]=M,e[22]=F,e[23]=X):X=e[23];let Q;e[24]!==p||e[25]!==x?(Q=!p&&i.jsx(Ht,{size:12,className:ne("opacity-60 shrink-0",x?"":"hidden @[320px]/chat-bottom:inline-block")}),e[24]=p,e[25]=x,e[26]=Q):Q=e[26];let Z;e[27]!==p||e[28]!==M||e[29]!==K||e[30]!==X||e[31]!==Q||e[32]!==Y||e[33]!==G?(Z=i.jsx(Re,{asChild:!0,children:i.jsx("span",{className:"inline-flex min-w-0 shrink",children:i.jsx(Cs,{asChild:!0,children:i.jsxs(ie,{variant:Y,size:G,"aria-label":M,disabled:p,className:K,children:[q,X,Q]})})})}),e[27]=p,e[28]=M,e[29]=K,e[30]=X,e[31]=Q,e[32]=Y,e[33]=G,e[34]=Z):Z=e[34];let J;e[35]!==M?(J=i.jsx(Pe,{children:M}),e[35]=M,e[36]=J):J=e[36];let ee;e[37]!==Z||e[38]!==J?(ee=i.jsxs(Ie,{children:[Z,J]}),e[37]=Z,e[38]=J,e[39]=ee):ee=e[39];let te;e[40]!==$||e[41]!==b?(te=i.jsx(yi,{placeholder:"Search loaded branches…",value:b,onValueChange:$}),e[40]=$,e[41]=b,e[42]=te):te=e[42];let ae;e[43]!==P||e[44]!==o?(ae=i.jsx(ie,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>P(o2(o)),children:"New"}),e[43]=P,e[44]=o,e[45]=ae):ae=e[45];let se;e[46]!==te||e[47]!==ae?(se=i.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:[te,ae]}),e[46]=te,e[47]=ae,e[48]=se):se=e[48];let oe;e[49]!==A?(oe=A&&i.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]=A,e[50]=oe):oe=e[50];let ce;e[51]!==N||e[52]!==A||e[53]!==T?(ce=!A&&!T&&i.jsx(Li,{children:N?"Looking through more branches...":"No branches found."}),e[51]=N,e[52]=A,e[53]=T,e[54]=ce):ce=e[54];let fe;e[55]!==P||e[56]!==V?(fe=V.length>0&&i.jsx(Fs,{heading:"Your branches",children:V.map(ye=>i.jsxs(Ps,{value:ye.name,onSelect:()=>P(ye.name),children:[i.jsx(an,{className:"mr-2 h-4 w-4"}),i.jsx("span",{className:"flex-1 truncate",children:ye.name})]},ye.name))}),e[55]=P,e[56]=V,e[57]=fe):fe=e[57];let be;e[58]!==k||e[59]!==P?(be=k.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(Kx,{}),i.jsx(Fs,{heading:"Other branches in repo",children:k.map(ye=>i.jsxs(Ps,{value:ye.name,onSelect:()=>P(ye.name),children:[i.jsx(an,{className:"mr-2 h-4 w-4"}),i.jsx("span",{className:"flex-1 truncate",children:ye.name}),ye.author&&i.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",ye.author]})]},ye.name))})]}),e[58]=k,e[59]=P,e[60]=be):be=e[60];let _e;e[61]!==I||e[62]!==N||e[63]!==R||e[64]!==L?(_e=N&&i.jsx("div",{className:"border-t p-2",children:i.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:R,onClick:I,children:R||L?"Loading more…":"Load more branches"})}),e[61]=I,e[62]=N,e[63]=R,e[64]=L,e[65]=_e):_e=e[65];let xe;e[66]!==N||e[67]!==k.length?(xe=!N&&k.length>0&&i.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"}),e[66]=N,e[67]=k.length,e[68]=xe):xe=e[68];let Ve;e[69]!==U||e[70]!==oe||e[71]!==ce||e[72]!==fe||e[73]!==be||e[74]!==_e||e[75]!==xe?(Ve=i.jsxs(Si,{onScroll:U,children:[oe,ce,fe,be,_e,xe]}),e[69]=U,e[70]=oe,e[71]=ce,e[72]=fe,e[73]=be,e[74]=_e,e[75]=xe,e[76]=Ve):Ve=e[76];let Ne;e[77]!==se||e[78]!==Ve?(Ne=i.jsx(Vs,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:i.jsxs(lr,{children:[se,Ve]})}),e[77]=se,e[78]=Ve,e[79]=Ne):Ne=e[79];let we;return e[80]!==v||e[81]!==ee||e[82]!==Ne||e[83]!==H?(we=i.jsxs(ks,{open:v,onOpenChange:H,children:[ee,Ne]}),e[80]=v,e[81]=ee,e[82]=Ne,e[83]=H,e[84]=we):we=e[84],we}function Z_(t){const e=B.c(25);let s,n,r,o;e[0]!==t?({locked:s,placement:n,value:o,...r}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=r,e[4]=o):(s=e[1],n=e[2],r=e[3],o=e[4]);const a=n==="header";if(s){const c=o??"(no branch)",d=a?"h-8 gap-1.5 border border-input bg-background px-2.5":"h-9 gap-0 px-2";let h;e[5]!==d?(h=ne("inline-flex items-center rounded-md font-mono text-xs","text-muted-foreground cursor-default min-w-0 max-w-[200px]",d),e[5]=d,e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(an,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e[7]=u):u=e[7];const f=a?"":"max-w-0 opacity-0";let m;e[8]!==f?(m=ne("min-w-0 truncate",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==m?(p=i.jsx("span",{className:m,children:c}),e[10]=c,e[11]=m,e[12]=p):p=e[12];let g;e[13]!==h||e[14]!==p?(g=i.jsx(Re,{asChild:!0,children:i.jsxs("span",{"data-testid":"branch-picker-locked","aria-disabled":"true",className:h,children:[u,p]})}),e[13]=h,e[14]=p,e[15]=g):g=e[15];let x;e[16]!==c?(x=i.jsxs(Pe,{children:["This chat is using branch ",c,". Start a new chat to use a different branch."]}),e[16]=c,e[17]=x):x=e[17];let v;return e[18]!==g||e[19]!==x?(v=i.jsxs(Ie,{children:[g,x]}),e[18]=g,e[19]=x,e[20]=v):v=e[20],v}let l;return e[21]!==n||e[22]!==r||e[23]!==o?(l=i.jsx(Q_,{...r,value:o,placement:n}),e[21]=n,e[22]=r,e[23]=o,e[24]=l):l=e[24],l}function Dl(){const t=B.c(11),e=gm(),s=b1();let n;t[0]!==e.capabilities||t[1]!==e.online?(n=e.online&&e.capabilities.includes("claude-code"),t[0]=e.capabilities,t[1]=e.online,t[2]=n):n=t[2];let r;t[3]!==e.capabilities||t[4]!==e.online?(r=e.online&&e.capabilities.includes("codex"),t[3]=e.capabilities,t[4]=e.online,t[5]=r):r=t[5];let o;return t[6]!==e.online||t[7]!==s.runtime.agentSandbox||t[8]!==n||t[9]!==r?(o={agentSandbox:s.runtime.agentSandbox,userDesktop:e.online,claudeCode:n,codex:r},t[6]=e.online,t[7]=s.runtime.agentSandbox,t[8]=n,t[9]=r,t[10]=o):o=t[10],o}function a2(t){const e=Object.values(t),[s]=e;return s?e.find(n=>n.sandboxProviderKind!=="user-desktop")??s:null}async function eb(t,e,s){const n=await t.callTool({name:e,arguments:s});if(n.isError){const r=n.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return n}const l2=["SANDBOX_START"],Qo=new Map,tb=t=>`${t.virtualMcpId}::${t.branch??""}`,mc=new Set,Za={mark:(t,e)=>mc.add(`${t}::${e}`),clear:(t,e)=>mc.delete(`${t}::${e}`),isStopped:(t,e)=>mc.has(`${t}::${e}`)};function Y9(t){const e=os();return Ds({mutationKey:l2,mutationFn:async s=>{s.branch&&Za.clear(s.virtualMcpId,s.branch);const n=tb(s),r=Qo.get(n);if(r)return r;const o=(async()=>(await eb(t,"SANDBOX_START",s)).structuredContent)();Qo.set(n,o);try{return await o}finally{Qo.get(n)===o&&Qo.delete(n)}},onSuccess:()=>{y1(e)}})}function sb(t,e){const s=B.c(3);let n;return s[0]!==e||s[1]!==t?(n={mutationKey:l2,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=n):n=s[2],p6(n)>0}const nb={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{}},c2=C.createContext(nb),Au=16384;class ib{data="";append(e){this.data+=e,this.data.length>Au&&(this.data=this.data.slice(this.data.length-Au))}get(){return this.data}clear(){this.data=""}}const rb=1e3,ob=3e4,ab=3e3,Tu=["lifecycle","status","tasks","scripts","branch","reload","file-changed"],Eu="log";function lb(t){if(!t)return null;try{return new URL("/_sandbox/events",t).href}catch{return null}}function cb(t){return t===404}async function db(t){try{const e=await fetch(t,{headers:{Accept:"text/event-stream"},cache:"no-store",signal:AbortSignal.timeout(ab)});return await e.body?.cancel().catch(()=>{}),cb(e.status)}catch{return!1}}function ub({virtualMcpId:t,branch:e,previewUrl:s=null,enabled:n=!0,children:r}){const{org:o}=Ae(),a=os(),[l,c]=C.useState(null),[d,h]=C.useState({phase:"idle"}),[u,f]=C.useState({state:"running"}),[m,p]=C.useState({kind:"unknown"}),[g,x]=C.useState(!1),[v,_]=C.useState([]),[b,y]=C.useState([]),[,L]=C.useState(0),w=C.useRef(new Map),S=C.useRef(new Set),j=C.useRef(new Set),V=C.useRef(null),k=lb(s),T=N=>{let R=w.current.get(N);return R||(R=new ib,w.current.set(N,R)),R};C.useEffect(()=>{if(c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),V.current=null,x(!1),_([]),y([]),w.current.clear(),!t||!e||!n)return;const N=`/api/${encodeURIComponent(o.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let R=!1,I=0,D=null,E=null,P=null,M=null,z=null;const $=W=>{try{const F=JSON.parse(W.data);c(F),F.kind!=="failed"&&(x(!1),I=0),F.kind==="ready"&&G()}catch(F){console.warn("[vm-events] bad phase payload",F)}},O=()=>{x(!0),c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),_([]),y([]),w.current.clear()},U=W=>{try{const F=JSON.parse(W.data);if(typeof F.data!="string")return;I=0;const X=F.data.replace(/\r?\n/g,`\r
|
|
5
5
|
`);T(F.source).append(X);for(const Q of S.current)try{Q(F.source,X)}catch{}L(Q=>Q+1)}catch{}},H=W=>{const F=W.type;try{const X=JSON.parse(W.data);switch(I=0,F){case"lifecycle":{const Q=X;h(Q.state);const Z=Q.state.phase==="running"?Q.state.port:null,J=V.current;if(V.current=Z,J!==null&&Z!==null&&J!==Z)for(const ee of j.current)try{ee()}catch{}return}case"status":f(X);return;case"tasks":{const Z=X.active.map(J=>J.logName??"").filter(Boolean);y(Z);return}case"scripts":_(X.scripts);return;case"branch":{const Q=X.meta;p(Q);return}case"reload":for(const Q of j.current)try{Q()}catch{}return;case"file-changed":{const{path:Q}=X,Z=`${o.slug}/${t}/${e}`;Q.startsWith(".deco/")?(P&&clearTimeout(P),P=setTimeout(()=>{P=null,a.invalidateQueries({queryKey:Qe.decofile(Z)})},1e3)):(E&&clearTimeout(E),E=setTimeout(()=>{E=null,a.invalidateQueries({predicate:J=>{const ee=J.queryKey;return ee[0]==="live-meta"&&typeof ee[1]=="string"&&ee[1].startsWith(`${Z}/`)}})},1e3));return}}}catch{}};function Y(){if(R)return;const W=new EventSource(N);M=W,W.onopen=()=>{},W.onerror=()=>{M===W&&W.readyState===EventSource.CLOSED&&q("studio")},W.addEventListener("phase",$),W.addEventListener("gone",O),W.addEventListener(Eu,U);for(const F of Tu)W.addEventListener(F,H)}function G(){if(R||!k||z)return;const W=new EventSource(k);z=W;let F=!1;W.onopen=()=>{if(R||z!==W)return;F=!0,I=0;const X=M;M=null,X?.close()},W.onerror=()=>{z===W&&W.readyState===EventSource.CLOSED&&K(W,F)},W.addEventListener(Eu,U);for(const X of Tu)W.addEventListener(X,H)}async function K(W,F){const X=k?await db(k):!1;if(!(R||z!==W)){if(W.close(),z=null,X){O(),M||Y();return}F&&q("direct")}}function q(W){if(R||D)return;const F=Math.min(rb*2**I,ob);I++,D=setTimeout(()=>{if(D=null,!R){if(W==="direct"){z?.close(),z=null,G();return}M?.close(),M=null,Y()}},F)}return Y(),()=>{R=!0,M?.close(),z?.close(),D&&clearTimeout(D),E&&clearTimeout(E),P&&clearTimeout(P)}},[t,e,o.slug,n,k,a]);const A={phase:l,lifecycle:d,status:u,branch:m,notFound:g,scripts:v,activeProcesses:b,getBuffer:N=>w.current.get(N)?.get()??"",hasData:N=>(w.current.get(N)?.get().length??0)>0,subscribeChunks:N=>(S.current.add(N),()=>{S.current.delete(N)}),subscribeReload:N=>(j.current.add(N),()=>{j.current.delete(N)})};return i.jsx(c2,{value:A,children:r})}function Os(){return C.use(c2)}function d2(t){const{subscribeChunks:e}=Os(),s=C.useRef(t);s.current=t,C.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function hb(t){const{subscribeReload:e}=Os(),s=C.useRef(t);s.current=t,C.useEffect(()=>e(()=>{s.current?.()}),[e])}function u2(t){return t.appPaused||t.userStopped?{kind:"suspended"}:t.startError&&!t.previewUrl?{kind:"errored",error:t.startError}:t.previewUrl?{kind:"iframe",previewUrl:t.previewUrl}:{kind:"starting"}}const h2={githubNotAuthenticated:"GITHUB_NOT_AUTHENTICATED"},Ru="::";function f2(t){const e=t.indexOf(Ru);if(e>0){const s=t.slice(0,e);if(Object.values(h2).includes(s))return{code:s,message:t.slice(e+Ru.length)}}return{code:null,message:t}}function fb(t){return t.hasActiveGithubRepo&&!!t.userId&&!t.vmEntry&&!t.userStopped&&!t.isPending&&!t.attempted}function mb(t){return t.notFound&&!!t.deadVmId&&!t.isPending&&!t.userStopped&&t.deadVmId!==t.lastDeadVmId}function pc(t,e,s){const n={virtualMcpId:t};return e&&(n.branch=e),s&&(n.sandboxProviderKind=s),n}function pb(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting";case"errored":return"errored"}}const gb={branch:null,previewState:{kind:"starting"},status:"idle",vmEntry:null,previewUrl:null,userStopped:!1,start:()=>{},stop:async()=>{},restart:async()=>{},retry:()=>{},resume:()=>{}},m2=C.createContext(gb);function dr(){return C.use(m2)}function xb({virtualMcpId:t,branch:e,userId:s,hasActiveGithubRepo:n,sandboxMap:r,sandboxProviderKind:o,children:a}){const{org:l}=Ae(),{setCurrentTaskBranch:c}=as(),d=Os(),h=os(),u=pt({connectionId:b9,orgId:l.id,orgSlug:l.slug}),f=Y9(u),{mutate:m,reset:p}=f,g=C.useRef(new Set),x=C.useRef(null),v=s&&e?Ll(r?.[s]?.[e]):{},_=o?v[o]??null:a2(v),b=_?.previewUrl??null,y=!!t&&!!e&&Za.isStopped(t,e),L=d.status.state==="paused",w=f.isError&&f.error?f2(f.error.message):null,S=u2({previewUrl:b,appPaused:L,userStopped:y,startError:w}),j=pb(S),V=e??"",k=g.current.has(V),T=fb({hasActiveGithubRepo:n,userId:s,vmEntry:_,userStopped:y,isPending:f.isPending,attempted:k});C.useEffect(()=>{if(!T||!t)return;g.current.add(V);const z=pc(t,e,o);m(z,{onSuccess:$=>{$?.branch&&!e&&c($.branch)},onError:$=>{console.error("[sandbox-lifecycle] auto-start failed:",$)}})},[T,V,e,t,o,m,c]);const A=d.notFound?_?.sandboxHandle??null:null,N=mb({notFound:d.notFound,deadVmId:A,lastDeadVmId:x.current,isPending:f.isPending,userStopped:y});C.useEffect(()=>{if(!N||!A||!t)return;x.current=A;const z=pc(t,e,o);m(z,{onSuccess:$=>{$?.branch&&!e&&c($.branch)},onError:$=>{console.error("[sandbox-lifecycle] self-heal failed:",$)}})},[N,A,t,e,o,m,c]);const R=()=>{if(!t)return;const z=pc(t,e,o);m(z,{onSuccess:$=>{$?.branch&&!e&&c($.branch)},onError:$=>{console.error("[sandbox-lifecycle] user start failed:",$)}})},I=async()=>{if(!t||!e)return;const z=_?.sandboxProviderKind;if(z){Za.mark(t,e);try{await u.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:t,branch:e,sandboxProviderKind:z}})}catch{}y1(h)}},D=async()=>{await I(),R()},E=()=>{g.current=new Set,x.current=null,p(),R()},M={branch:e,previewState:S,status:j,vmEntry:_,previewUrl:b,userStopped:y,start:R,stop:I,restart:D,retry:E,resume:E};return i.jsx(m2,{value:M,children:a})}function vb(t){return t==="user-desktop"?{key:"local",label:"This device",Icon:ar}:{key:"cloud",label:"Cloud sandbox",Icon:V9}}function Pu(t){const e=B.c(20),{icon:s,label:n,description:r,active:o,available:a,disabledHint:l,onSelect:c}=t,d=!a,h=a?"cursor-pointer hover:bg-accent":"cursor-not-allowed opacity-50";let u;e[0]!==h?(u=ne("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",h),e[0]=h,e[1]=u):u=e[1];let f;e[2]!==s?(f=i.jsx("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:s}),e[2]=s,e[3]=f):f=e[3];let m;e[4]!==o?(m=o&&i.jsx(Tt,{size:13,className:"text-muted-foreground"}),e[4]=o,e[5]=m):m=e[5];let p;e[6]!==n||e[7]!==m?(p=i.jsxs("span",{className:"flex items-center gap-1.5 text-[13px] font-medium text-foreground",children:[n,m]}),e[6]=n,e[7]=m,e[8]=p):p=e[8];const g=a?r:l;let x;e[9]!==g?(x=i.jsx("span",{className:"block text-xs text-muted-foreground",children:g}),e[9]=g,e[10]=x):x=e[10];let v;e[11]!==p||e[12]!==x?(v=i.jsxs("span",{className:"min-w-0 flex-1",children:[p,x]}),e[11]=p,e[12]=x,e[13]=v):v=e[13];let _;return e[14]!==c||e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==v?(_=i.jsxs("button",{type:"button",disabled:d,onClick:c,className:u,children:[f,v]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f,e[18]=v,e[19]=_):_=e[19],_}function _b(t){const e=B.c(50);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{showLabel:n}=s,r=n===void 0?!1:n,{pendingSandboxProviderKind:o,setPendingAgentOption:a}=xs(),{isThreadLocked:l}=as(),{vmEntry:c}=dr(),d=Dl();if(l)return null;let h;e[2]!==d?(h=T1(d),e[2]=d,e[3]=h):h=e[3];const u=h,f=c?.sandboxProviderKind??o??(d.agentSandbox?"agent-sandbox":u?"user-desktop":null);let m,p,g,x,v,_,b,y;if(e[4]!==f||e[5]!==r){x=vb(f);const M=x.Icon;g=Zt,p=Ie;const z=r?"h-9 gap-1.5 px-2 text-xs font-medium":"size-9";let $;e[14]!==z?($=ne("text-muted-foreground hover:text-foreground",z),e[14]=z,e[15]=$):$=e[15];const O=i.jsxs(ie,{variant:"ghost",size:r?"sm":"icon","aria-label":`Runtime: ${x.label}`,className:$,children:[i.jsx(M,{size:16}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"truncate",children:x.label}),i.jsx(Ht,{size:12,className:"shrink-0 opacity-70"})]})]});e[16]!==O?(y=i.jsx(Re,{asChild:!0,children:i.jsx(es,{asChild:!0,children:O})}),e[16]=O,e[17]=y):y=e[17],m=Pe,v="bottom",_="Running on ",b=x.label.toLowerCase(),e[4]=f,e[5]=r,e[6]=m,e[7]=p,e[8]=g,e[9]=x,e[10]=v,e[11]=_,e[12]=b,e[13]=y}else m=e[6],p=e[7],g=e[8],x=e[9],v=e[10],_=e[11],b=e[12],y=e[13];let L;e[18]!==m||e[19]!==v||e[20]!==_||e[21]!==b?(L=i.jsxs(m,{side:v,children:[_,b]}),e[18]=m,e[19]=v,e[20]=_,e[21]=b,e[22]=L):L=e[22];let w;e[23]!==p||e[24]!==y||e[25]!==L?(w=i.jsxs(p,{children:[y,L]}),e[23]=p,e[24]=y,e[25]=L,e[26]=w):w=e[26];let S;e[27]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(Ir,{className:"text-xs font-normal text-muted-foreground",children:"Run on"}),e[27]=S):S=e[27];let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(V9,{size:14}),e[28]=j):j=e[28];const V=x.key==="cloud";let k;e[29]!==a?(k=()=>a("decopilot"),e[29]=a,e[30]=k):k=e[30];let T;e[31]!==d.agentSandbox||e[32]!==V||e[33]!==k?(T=i.jsx(Pu,{icon:j,label:"Cloud sandbox",description:"Runs in deco's cloud",active:V,available:d.agentSandbox,disabledHint:"Not available on this deployment",onSelect:k}),e[31]=d.agentSandbox,e[32]=V,e[33]=k,e[34]=T):T=e[34];let A;e[35]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx(ar,{size:14}),e[35]=A):A=e[35];const N=x.key==="local",R=u!==null;let I;e[36]!==u||e[37]!==a?(I=()=>u&&a(u),e[36]=u,e[37]=a,e[38]=I):I=e[38];let D;e[39]!==N||e[40]!==R||e[41]!==I?(D=i.jsx(Pu,{icon:A,label:"This device",description:"Runs on your machine via deco link",active:N,available:R,disabledHint:"Run `decocms link` on your desktop",onSelect:I}),e[39]=N,e[40]=R,e[41]=I,e[42]=D):D=e[42];let E;e[43]!==T||e[44]!==D?(E=i.jsxs(ts,{align:"start",className:"w-64 p-1",children:[S,T,D]}),e[43]=T,e[44]=D,e[45]=E):E=e[45];let P;return e[46]!==g||e[47]!==E||e[48]!==w?(P=i.jsxs(g,{children:[w,E]}),e[46]=g,e[47]=E,e[48]=w,e[49]=P):P=e[49],P}function bb(t){const e=B.c(2),{branchPill:s}=t;if(!s)return null;let n;return e[0]!==s?(n=i.jsx(i.Fragment,{children:s}),e[0]=s,e[1]=n):n=e[1],n}function p2(t){const e=B.c(27),{virtualMcp:s,currentBranch:n,showRuntimeLabel:r}=t,o=r===void 0?!1:r,a=E1(),l=ir();let c;e[0]!==a?.messages||e[1]!==l?.isThreadLocked?(c=(a?.messages??[]).length>0||(l?.isThreadLocked??!1),e[0]=a?.messages,e[1]=l?.isThreadLocked,e[2]=c):c=e[2];const d=c,h=l?.setCurrentTaskBranch;let u;e[3]!==s?(u=Ro(s),e[3]=s,e[4]=u):u=e[4];const f=u,m=f?.connectionId,p=!!f,{data:g}=vi.useSession(),x=g?.user?.id??"";let v;e[5]!==g?.user?.email||e[6]!==g?.user?.name?(v=g?.user?.name??g?.user?.email?.split("@")[0],e[5]=g?.user?.email,e[6]=g?.user?.name,e[7]=v):v=e[7];const _=v,{org:b}=Ae();let y;e[8]!==m||e[9]!==n||e[10]!==f||e[11]!==d||e[12]!==b||e[13]!==h||e[14]!==x||e[15]!==_||e[16]!==s?.id||e[17]!==s?.metadata?.sandboxMap?(y=f&&m?i.jsx(Z_,{orgId:b.id,orgSlug:b.slug,userId:x,userLabel:_,virtualMcpId:s?.id??"",connectionId:m,owner:f.owner,repo:f.name,sandboxMap:s?.metadata?.sandboxMap,value:n,onChange:V=>{h&&h(V)},locked:d,placement:"chat"}):null,e[8]=m,e[9]=n,e[10]=f,e[11]=d,e[12]=b,e[13]=h,e[14]=x,e[15]=_,e[16]=s?.id,e[17]=s?.metadata?.sandboxMap,e[18]=y):y=e[18];const L=y;let w;e[19]!==p||e[20]!==o?(w=p&&i.jsx(_b,{showLabel:o}),e[19]=p,e[20]=o,e[21]=w):w=e[21];let S;e[22]!==L?(S=i.jsx(bb,{branchPill:L}),e[22]=L,e[23]=S):S=e[23];let j;return e[24]!==w||e[25]!==S?(j=i.jsxs(i.Fragment,{children:[w,S]}),e[24]=w,e[25]=S,e[26]=j):j=e[26],j}const yb={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"}},Lb={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 Sb(t){return t==="claude-code"?yb:t==="codex"?Lb:null}function Iu(t,e){return Sb(t)?.[e]??null}const wb={decopilot:"cloud-decopilot","claude-code-desktop":"local-claude-code","codex-desktop":"local-codex"};function jb(t){return t===null?"cloud-decopilot":wb[t]}function Cb(){const t=B.c(2),{pendingAgentOption:e}=xs();let s;return t[0]!==e?(s=jb(e),t[0]=e,t[1]=s):s=t[1],s}function Vb(){return xs().simpleModeTier}function kb(){return xs().setSimpleModeTier}const Nb={fast:"Quicker responses",smart:"Balanced quality",thinking:"Deeper reasoning"};function g2(t,e){return t==="local-claude-code"?Iu("claude-code",e)?.label??null:t==="local-codex"?Iu("codex",e)?.label??null:Nb[e]}const x2=["fast","smart","thinking"],Mi={fast:"Fast",smart:"Smart",thinking:"Thinking"};function Ab(t){const e=B.c(29),{tier:s,pillIcon:n,pillLabel:r,groups:o,header:a}=t,l=r===void 0?Mi[s]:r,[c,d]=C.useState(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=V=>{V.onSelect(),d(!1)},e[0]=h):h=e[0];const u=h;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=ne("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),e[1]=f):f=e[1];let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=ne("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[2]=m):m=e[2];const p=Mi[s];let g;e[3]!==p?(g=i.jsx("span",{className:m,children:p}),e[3]=p,e[4]=g):g=e[4];let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Ht,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[5]=x):x=e[5];let v;e[6]!==n||e[7]!==l||e[8]!==g?(v=i.jsx(Re,{asChild:!0,children:i.jsx("span",{className:"inline-flex min-w-0 shrink",children:i.jsx(Cs,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"ghost",size:"default","aria-label":l,className:f,children:[n,g,x]})})})}),e[6]=n,e[7]=l,e[8]=g,e[9]=v):v=e[9];let _;e[10]!==l?(_=i.jsx(Pe,{children:l}),e[10]=l,e[11]=_):_=e[11];let b;e[12]!==v||e[13]!==_?(b=i.jsxs(Ie,{children:[v,_]}),e[12]=v,e[13]=_,e[14]=b):b=e[14];let y;e[15]!==a?(y=a&&i.jsx("div",{className:"mb-1 border-b border-border/60 pb-1",children:a}),e[15]=a,e[16]=y):y=e[16];let L;if(e[17]!==o){let V;e[19]===Symbol.for("react.memo_cache_sentinel")?(V=k=>i.jsxs("div",{className:"flex flex-col",children:[k.label&&i.jsx("div",{className:"flex items-center gap-1.5 px-2 pt-1.5 pb-0.5 text-xs font-medium text-muted-foreground",children:i.jsx("span",{className:"truncate",children:k.label})}),k.rows.map(T=>i.jsxs("button",{type:"button",role:"menuitem","aria-label":k.label?`${k.label} ${T.title}`:T.title,onClick:()=>u(T),className:ne("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),children:[T.icon&&i.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:T.icon}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"text-sm",children:T.title}),T.subtitle&&i.jsx("div",{className:"text-xs text-muted-foreground",children:T.subtitle})]}),T.active&&i.jsx(Tt,{size:14,className:"text-foreground mt-0.5"})]},T.key))]},k.key),e[19]=V):V=e[19],L=o.map(V),e[17]=o,e[18]=L}else L=e[18];let w;e[20]!==L?(w=i.jsx("div",{role:"menu",className:"flex flex-col",children:L}),e[20]=L,e[21]=w):w=e[21];let S;e[22]!==y||e[23]!==w?(S=i.jsxs(Vs,{align:"end",className:"p-1 w-64",children:[y,w]}),e[22]=y,e[23]=w,e[24]=S):S=e[24];let j;return e[25]!==c||e[26]!==b||e[27]!==S?(j=i.jsxs(ks,{open:c,onOpenChange:d,children:[b,S]}),e[25]=c,e[26]=b,e[27]=S,e[28]=j):j=e[28],j}function Du(t){return t==="fast"?i.jsx(k9,{size:16}):t==="thinking"?i.jsx(Q1,{size:16}):i.jsx(Bn,{size:16})}const Tb="flex items-center justify-center gap-1.5 flex-1 rounded-md px-2 py-1.5 text-xs font-medium transition-colors min-w-0",Eb="bg-background text-foreground shadow-sm",Rb="text-muted-foreground hover:text-foreground";function Pb(t){const e=B.c(4),{options:s}=t;let n;e[0]!==s?(n=s.map(Ib),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{className:"flex items-center gap-1 p-1 rounded-lg bg-muted",children:n}),e[2]=n,e[3]=r):r=e[3],r}function Ib(t){return i.jsxs("button",{type:"button",onClick:t.onSelect,className:ne(Tb,t.active?Eb:Rb),children:[t.icon,i.jsx("span",{className:"truncate",children:t.label})]},t.key)}function Db(){const t=B.c(18),{pendingHarnessId:e,setPendingAgentOption:s}=xs(),n=Dl(),r=e==="claude-code"||e==="codex";let o;t[0]!==n?(o=T1(n)??"claude-code-desktop",t[0]=n,t[1]=o):o=t[1];const a=o;let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(V9,{size:14}),t[2]=l):l=t[2];const c=!r;let d;t[3]!==s?(d=()=>s("decopilot"),t[3]=s,t[4]=d):d=t[4];let h;t[5]!==c||t[6]!==d?(h={key:"cloud",icon:l,label:"Cloud",active:c,onSelect:d},t[5]=c,t[6]=d,t[7]=h):h=t[7];let u;t[8]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(ar,{size:14}),t[8]=u):u=t[8];let f;t[9]!==a||t[10]!==s?(f=()=>s(a),t[9]=a,t[10]=s,t[11]=f):f=t[11];let m;t[12]!==r||t[13]!==f?(m={key:"local",icon:u,label:"This device",active:r,onSelect:f},t[12]=r,t[13]=f,t[14]=m):m=t[14];let p;return t[15]!==h||t[16]!==m?(p=i.jsx("div",{className:"p-1",children:i.jsx(Pb,{options:[h,m]})}),t[15]=h,t[16]=m,t[17]=p):p=t[17],p}function Mu(t){return{key:t.key,label:t.label,rows:x2.map(e=>({key:`${t.key}-${e}`,icon:t.icon,title:Mi[e],subtitle:g2(t.mode,e),active:t.isActiveRuntime&&t.currentTier===e,onSelect:()=>{t.setOption(t.option),t.setTier(e)}}))}}function Mb(){const t=B.c(42),e=Vb(),s=kb(),n=Cb(),{pendingHarnessId:r,setPendingAgentOption:o}=xs(),a=Dl(),l=ir(),c=Al(),d=l?.isThreadLocked??!1,h=a.claudeCode||a.codex,u=n!=="cloud-decopilot";let f;if(u){const y=d?r==="claude-code":a.claudeCode||r==="claude-code",L=d?r==="codex":a.codex||r==="codex",w=y&&L;let S;if(t[0]!==w||t[1]!==r||t[2]!==o||t[3]!==s||t[4]!==y||t[5]!==L||t[6]!==e){if(S=[],y){const j=w?"Claude Code":void 0;let V;t[8]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx($x,{size:16}),t[8]=V):V=t[8];const k=r==="claude-code";let T;t[9]!==o||t[10]!==s||t[11]!==j||t[12]!==k||t[13]!==e?(T=Mu({key:"claude-code",label:j,icon:V,mode:"local-claude-code",option:"claude-code-desktop",isActiveRuntime:k,currentTier:e,setOption:o,setTier:s}),t[9]=o,t[10]=s,t[11]=j,t[12]=k,t[13]=e,t[14]=T):T=t[14],S.push(T)}if(L){const j=w?"Codex":void 0;let V;t[15]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx(Bx,{size:16}),t[15]=V):V=t[15];const k=r==="codex";let T;t[16]!==o||t[17]!==s||t[18]!==j||t[19]!==k||t[20]!==e?(T=Mu({key:"codex",label:j,icon:V,mode:"local-codex",option:"codex-desktop",isActiveRuntime:k,currentTier:e,setOption:o,setTier:s}),t[16]=o,t[17]=s,t[18]=j,t[19]=k,t[20]=e,t[21]=T):T=t[21],S.push(T)}t[0]=w,t[1]=r,t[2]=o,t[3]=s,t[4]=y,t[5]=L,t[6]=e,t[7]=S}else S=t[7];f=S}else{let y;t[22]!==s||t[23]!==e?(y=x2.map(w=>({key:`cloud-${w}`,icon:Du(w),title:Mi[w],subtitle:g2("cloud-decopilot",w),active:e===w,onSelect:()=>s(w)})),t[22]=s,t[23]=e,t[24]=y):y=t[24];let L;t[25]!==y?(L=[{key:"cloud",rows:y}],t[25]=y,t[26]=L):L=t[26],f=L}if(c)return null;let m;t[27]!==u||t[28]!==r?(m=u?zx(r):null,t[27]=u,t[28]=r,t[29]=m):m=t[29];const p=m,g=p?.Icon;let x;t[30]!==g||t[31]!==e?(x=g?i.jsx(g,{size:16}):Du(e),t[30]=g,t[31]=e,t[32]=x):x=t[32];const v=p?`${p.label} ${Mi[e]}`:Mi[e];let _;t[33]!==h||t[34]!==d?(_=h&&!d?i.jsx(Db,{}):void 0,t[33]=h,t[34]=d,t[35]=_):_=t[35];let b;return t[36]!==f||t[37]!==x||t[38]!==v||t[39]!==_||t[40]!==e?(b=i.jsx(Ab,{tier:e,pillIcon:x,pillLabel:v,groups:f,header:_}),t[36]=f,t[37]=x,t[38]=v,t[39]=_,t[40]=e,t[41]=b):b=t[41],b}async function J9(t,e,s,n,r){if(!Nl(e)){de.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!Fx(o,e)){const l=xm(e),c=e?.title??"This model";r?r({fileName:s.name,modelName:c,accepted:l}):de.error(`"${s.name}" can't be attached`,{description:`${c} accepts ${l}.`});return}const a=10*1024*1024;if(s.size>a){de.error(`File "${s.name}" exceeds 10MB limit`);return}try{const l=new FileReader,c=new Promise((u,f)=>{l.onload=()=>{const m=l.result;if(typeof m!="string"){f(new Error("Failed to read file as data URL"));return}const p=m.includes(",")?m.split(",")[1]??m:m;u(p)},l.onerror=f});l.readAsDataURL(s);const d=await c,h={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:d};d5(t,{from:n,to:n},h)}catch(l){console.error("Failed to process file:",l),de.error(`Failed to load file "${s.name}"`)}}function Ob(t){const e=B.c(8),{editor:s,selectedModel:n,onUnsupportedFile:r}=t,o=C.useRef(Bb);let a,l;e[0]!==s||e[1]!==r||e[2]!==n?(a=()=>{o.current=async(h,u)=>{await J9(s,n,h,u,r)}},l=[s,n,r],e[0]=s,e[1]=r,e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),C.useEffect(a,l);let c,d;return e[5]!==s?(c=()=>{if(s?.isDestroyed)return;const h=new Ma("fileDropHandler");s.state.plugins.find(m=>m.spec.key===h)&&s.unregisterPlugin(h);const f=new R1({key:h,props:{handleDrop:(m,p,g,x)=>{if(x)return!1;const v=p.dataTransfer?.files;if(!v||v.length===0)return!1;p.preventDefault();const _=m.posAtCoords({left:p.clientX,top:p.clientY});if(!_)return!1;const b=Array.from(v),y=_.pos;for(const L of b)o.current?.(L,y);return!0},handlePaste:(m,p)=>{const g=p.clipboardData?.items;if(!g)return!1;const x=Array.from(g).filter($b);if(x.length===0)return!1;p.preventDefault();const{from:v}=m.state.selection;for(const _ of x){const b=_.getAsFile();b&&o.current?.(b,v)}return!0}}});return s.registerPlugin(f),()=>{s?.isDestroyed||s.unregisterPlugin(h)}},d=[s],e[5]=s,e[6]=c,e[7]=d):(c=e[6],d=e[7]),C.useEffect(c,d),null}function $b(t){return t.kind==="file"}function Bb(){return Promise.resolve()}function zb(t){const e=B.c(26),{info:s,onClose:n}=t,r=s!==null;let o;e[0]!==n?(o=L=>!L&&n(),e[0]=n,e[1]=o):o=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 l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=i.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]=l):l=e[3];let c,d;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:i.jsx(nr,{size:18})}),d=i.jsx(is,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=c,e[5]=d):(c=e[4],d=e[5]);const h=s?.fileName;let u;e[6]!==h?(u=i.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[l,i.jsxs(ns,{className:"relative gap-4",children:[c,i.jsxs("div",{children:[d,i.jsxs(qn,{className:"mt-1.5 text-sm leading-relaxed",children:[i.jsxs("span",{className:"font-medium text-foreground",children:["“",h,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=h,e[7]=u):u=e[7];const f=s?.modelName;let m;e[8]!==f?(m=i.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[f," accepts"]}),e[8]=f,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(X5,{size:14,className:"text-muted-foreground"}),e[10]=p):p=e[10];const g=s?.accepted;let x;e[11]!==g?(x=i.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[p,i.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=x):x=e[12];let v;e[13]!==m||e[14]!==x?(v=i.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:i.jsxs("div",{className:"rounded-xl border border-border p-4",children:[m,x]})}),e[13]=m,e[14]=x,e[15]=v):v=e[15];let _;e[16]!==n?(_=i.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:i.jsx(ie,{onClick:n,children:"Got it"})}),e[16]=n,e[17]=_):_=e[17];let b;e[18]!==v||e[19]!==_||e[20]!==u?(b=i.jsxs(Ft,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Fb,children:[u,v,_]}),e[18]=v,e[19]=_,e[20]=u,e[21]=b):b=e[21];let y;return e[22]!==r||e[23]!==b||e[24]!==o?(y=i.jsx(Ut,{open:r,onOpenChange:o,children:b}),e[22]=r,e[23]=b,e[24]=o,e[25]=y):y=e[25],y}function Fb(t){return t.preventDefault()}function Ub(){const t=B.c(3),[e,s]=C.useState(null);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>s(null),t[0]=n):n=t[0];let r;return t[1]!==e?(r={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:n},t[1]=e,t[2]=r):r=t[2],r}var Hb=u5;var Kb=["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] *)"],d0=Kb.join(","),v2=typeof Element>"u",mo=v2?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,el=!v2&&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},tl=function(e,s){var n;s===void 0&&(s=!0);var r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"inert"),o=r===""||r==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):tl(e.parentNode));return a},Wb=function(e){var s,n=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return n===""||n==="true"},qb=function(e,s,n){if(tl(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(d0));return s&&mo.call(e,d0)&&r.unshift(e),r=r.filter(n),r},u0=function(e,s,n){for(var r=[],o=Array.from(e);o.length;){var a=o.shift();if(!tl(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=u0(c,!0,n);n.flatten?r.push.apply(r,d):r.push({scopeParent:a,candidates:d})}else{var h=mo.call(a,d0);h&&n.filter(a)&&(s||!e.includes(a))&&r.push(a);var u=a.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(a),f=!tl(u,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(a));if(u&&f){var m=u0(u===!0?a.children:u.children,!0,n);n.flatten?r.push.apply(r,m):r.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return r},_2=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},b2=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Wb(e))&&!_2(e)?0:e.tabIndex},Gb=function(e,s){var n=b2(e);return n<0&&s&&!_2(e)?0:n},Yb=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},y2=function(e){return e.tagName==="INPUT"},Jb=function(e){return y2(e)&&e.type==="hidden"},Xb=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(n){return n.tagName==="SUMMARY"});return s},Qb=function(e,s){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===s)return e[n]},Zb=function(e){if(!e.name)return!0;var s=e.form||el(e),n=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=n(window.CSS.escape(e.name));else try{r=n(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 o=Qb(r,e.form);return!o||o===e},ey=function(e){return y2(e)&&e.type==="radio"},ty=function(e){return ey(e)&&!Zb(e)},sy=function(e){var s,n=e&&el(e),r=(s=n)===null||s===void 0?void 0:s.host,o=!1;if(n&&n!==e){var a,l,c;for(o=!!((a=r)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(r)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&r;){var d,h,u;n=el(r),r=(d=n)===null||d===void 0?void 0:d.host,o=!!((h=r)!==null&&h!==void 0&&(u=h.ownerDocument)!==null&&u!==void 0&&u.contains(r))}}return o},Ou=function(e){var s=e.getBoundingClientRect(),n=s.width,r=s.height;return n===0&&r===0},ny=function(e,s){var n=s.displayCheck,r=s.getShadowRoot;if(n==="full-native"&&"checkVisibility"in e){var o=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(e).visibility==="hidden")return!0;var a=mo.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(mo.call(l,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="full-native"||n==="legacy-full"){if(typeof r=="function"){for(var c=e;e;){var d=e.parentElement,h=el(e);if(d&&!d.shadowRoot&&r(d)===!0)return Ou(e);e.assignedSlot?e=e.assignedSlot:!d&&h!==e.ownerDocument?e=h.host:e=d}e=c}if(sy(e))return!e.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return Ou(e);return!1},iy=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var n=0;n<s.children.length;n++){var r=s.children.item(n);if(r.tagName==="LEGEND")return mo.call(s,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}s=s.parentElement}return!1},ry=function(e,s){return!(s.disabled||Jb(s)||ny(s,e)||Xb(s)||iy(s))},$u=function(e,s){return!(ty(s)||b2(s)<0||!ry(e,s))},oy=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},L2=function(e){var s=[],n=[];return e.forEach(function(r,o){var a=!!r.scopeParent,l=a?r.scopeParent:r,c=Gb(l,a),d=a?L2(r.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):n.push({documentOrder:o,tabIndex:c,item:r,isScope:a,content:d})}),n.sort(Yb).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(s)},S2=function(e,s){s=s||{};var n;return s.getShadowRoot?n=u0([e],s.includeContainer,{filter:$u.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:oy}):n=qb(e,s.includeContainer,$u.bind(null,s)),L2(n)};function ay(){return/apple/i.test(navigator.vendor)}const Bu="data-floating-ui-focusable";function ly(t){let e=t.activeElement;for(;((s=e)==null||(s=s.shadowRoot)==null?void 0:s.activeElement)!=null;){var s;e=e.shadowRoot.activeElement}return e}function h0(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&A4(s)){let n=e;for(;n;){if(t===n)return!0;n=n.parentNode||n.host}}return!1}function yr(t){return"composedPath"in t?t.composedPath()[0]:t.target}function gc(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const s=t;return s.target!=null&&e.contains(s.target)}function cy(t){return t.matches("html,body")}function po(t){return t?.ownerDocument||document}function dy(t){return t?t.hasAttribute(Bu)?t:t.querySelector("["+Bu+"]")||t:null}function wa(t,e,s){return s===void 0&&(s=!0),t.filter(r=>{var o;return r.parentId===e&&(!s||((o=r.context)==null?void 0:o.open))}).flatMap(r=>[r,...wa(t,r.id,s)])}function uy(t){return"nativeEvent"in t}var hy=typeof document<"u",fy=function(){},oi=hy?C.useLayoutEffect:fy;const my={...L1},py=my.useInsertionEffect,gy=py||(t=>t());function Ti(t){const e=C.useRef(()=>{});return gy(()=>{e.current=t}),C.useCallback(function(){for(var s=arguments.length,n=new Array(s),r=0;r<s;r++)n[r]=arguments[r];return e.current==null?void 0:e.current(...n)},[])}const w2=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function j2(t,e){const s=S2(t,w2()),n=s.length;if(n===0)return;const r=ly(po(t)),o=s.indexOf(r),a=o===-1?e===1?0:n-1:o+e;return s[a]}function xy(t){return j2(po(t).body,1)||t}function vy(t){return j2(po(t).body,-1)||t}function xc(t,e){const s=e||t.currentTarget,n=t.relatedTarget;return!n||!h0(s,n)}function _y(t){S2(t,w2()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function zu(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const n=s.dataset.tabindex;delete s.dataset.tabindex,n?s.setAttribute("tabindex",n):s.removeAttribute("tabindex")})}const by="data-floating-ui-focusable",Fu="active",Uu="selected",yy={...L1};let Hu=!1,Ly=0;const Ku=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Ly++;function Sy(){const[t,e]=C.useState(()=>Hu?Ku():void 0);return oi(()=>{t==null&&e(Ku())},[]),C.useEffect(()=>{Hu=!0},[]),t}const wy=yy.useId,X9=wy||Sy;function jy(){const t=new Map;return{emit(e,s){var n;(n=t.get(e))==null||n.forEach(r=>r(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var n;(n=t.get(e))==null||n.delete(s)}}}const Cy=C.createContext(null),Vy=C.createContext(null),C2=()=>{var t;return((t=C.useContext(Cy))==null?void 0:t.id)||null},V2=()=>C.useContext(Vy);function Q9(t){return"data-floating-ui-"+t}const ky={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},Wu=C.forwardRef(function(e,s){const[n,r]=C.useState();oi(()=>{ay()&&r("button")},[]);const o={ref:s,tabIndex:0,role:n,"aria-hidden":n?void 0:!0,[Q9("focus-guard")]:"",style:ky};return i.jsx("span",{...e,...o})}),Ny={clipPath:"inset(50%)",position:"fixed",top:0,left:0},k2=C.createContext(null),qu=Q9("portal");function Ay(t){t===void 0&&(t={});const{id:e,root:s}=t,n=X9(),r=Ey(),[o,a]=C.useState(null),l=C.useRef(null);return oi(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),oi(()=>{if(!n||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=n,d.setAttribute(qu,""),c.appendChild(d),l.current=d,a(d)},[e,n]),oi(()=>{if(s===null||!n||l.current)return;let c=s||r?.portalNode;c&&!D4(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const h=document.createElement("div");h.id=n,h.setAttribute(qu,""),c=d||c,c.appendChild(h),l.current=h,a(h)},[e,s,n,r]),o}function Ty(t){const{children:e,id:s,root:n,preserveTabOrder:r=!0}=t,o=Ay({id:s,root:n}),[a,l]=C.useState(null),c=C.useRef(null),d=C.useRef(null),h=C.useRef(null),u=C.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&r&&!!(n||o);return C.useEffect(()=>{if(!o||!r||f)return;function g(x){o&&xc(x)&&(x.type==="focusin"?zu:_y)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,r,f]),C.useEffect(()=>{o&&(m||zu(o))},[m,o]),i.jsxs(k2.Provider,{value:C.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:h,afterInsideRef:u,portalNode:o,setFocusManagerState:l}),[r,o]),children:[p&&o&&i.jsx(Wu,{"data-type":"outside",ref:c,onFocus:g=>{if(xc(g,o)){var x;(x=h.current)==null||x.focus()}else{const v=a?a.domReference:null,_=vy(v);_?.focus()}}}),p&&o&&i.jsx("span",{"aria-owns":o.id,style:Ny}),o&&Ri.createPortal(e,o),p&&o&&i.jsx(Wu,{"data-type":"outside",ref:d,onFocus:g=>{if(xc(g,o)){var x;(x=u.current)==null||x.focus()}else{const v=a?a.domReference:null,_=xy(v);_?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const Ey=()=>C.useContext(k2),Ry={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Py={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Gu=t=>{var e,s;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(s=t?.outsidePress)!=null?s:!0}};function Iy(t,e){e===void 0&&(e={});const{open:s,onOpenChange:n,elements:r,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:h=!1,referencePressEvent:u="pointerdown",ancestorScroll:f=!1,bubbles:m,capture:p}=e,g=V2(),x=Ti(typeof c=="function"?c:()=>!1),v=typeof c=="function"?x:c,_=C.useRef(!1),{escapeKey:b,outsidePress:y}=Gu(m),{escapeKey:L,outsidePress:w}=Gu(p),S=C.useRef(!1),j=Ti(R=>{var I;if(!s||!a||!l||R.key!=="Escape"||S.current)return;const D=(I=o.current.floatingContext)==null?void 0:I.nodeId,E=g?wa(g.nodesRef.current,D):[];if(!b&&(R.stopPropagation(),E.length>0)){let P=!0;if(E.forEach(M=>{var z;if((z=M.context)!=null&&z.open&&!M.context.dataRef.current.__escapeKeyBubbles){P=!1;return}}),!P)return}n(!1,uy(R)?R.nativeEvent:R,"escape-key")}),V=Ti(R=>{var I;const D=()=>{var E;j(R),(E=yr(R))==null||E.removeEventListener("keydown",D)};(I=yr(R))==null||I.addEventListener("keydown",D)}),k=Ti(R=>{var I;const D=o.current.insideReactTree;o.current.insideReactTree=!1;const E=_.current;if(_.current=!1,d==="click"&&E||D||typeof v=="function"&&!v(R))return;const P=yr(R),M="["+Q9("inert")+"]",z=po(r.floating).querySelectorAll(M);let $=Zs(P)?P:null;for(;$&&!uc($);){const Y=R4($);if(uc(Y)||!Zs(Y))break;$=Y}if(z.length&&Zs(P)&&!cy(P)&&!h0(P,r.floating)&&Array.from(z).every(Y=>!h0($,Y)))return;if(P4(P)&&N){const Y=uc(P),G=I4(P),K=/auto|scroll/,q=Y||K.test(G.overflowX),W=Y||K.test(G.overflowY),F=q&&P.clientWidth>0&&P.scrollWidth>P.clientWidth,X=W&&P.clientHeight>0&&P.scrollHeight>P.clientHeight,Q=G.direction==="rtl",Z=X&&(Q?R.offsetX<=P.offsetWidth-P.clientWidth:R.offsetX>P.clientWidth),J=F&&R.offsetY>P.clientHeight;if(Z||J)return}const O=(I=o.current.floatingContext)==null?void 0:I.nodeId,U=g&&wa(g.nodesRef.current,O).some(Y=>{var G;return gc(R,(G=Y.context)==null?void 0:G.elements.floating)});if(gc(R,r.floating)||gc(R,r.domReference)||U)return;const H=g?wa(g.nodesRef.current,O):[];if(H.length>0){let Y=!0;if(H.forEach(G=>{var K;if((K=G.context)!=null&&K.open&&!G.context.dataRef.current.__outsidePressBubbles){Y=!1;return}}),!Y)return}n(!1,R,"outside-press")}),T=Ti(R=>{var I;const D=()=>{var E;k(R),(E=yr(R))==null||E.removeEventListener(d,D)};(I=yr(R))==null||I.addEventListener(d,D)});C.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=b,o.current.__outsidePressBubbles=y;let R=-1;function I(z){n(!1,z,"ancestor-scroll")}function D(){window.clearTimeout(R),S.current=!0}function E(){R=window.setTimeout(()=>{S.current=!1},E4()?5:0)}const P=po(r.floating);l&&(P.addEventListener("keydown",L?V:j,L),P.addEventListener("compositionstart",D),P.addEventListener("compositionend",E)),v&&P.addEventListener(d,w?T:k,w);let M=[];return f&&(Zs(r.domReference)&&(M=dc(r.domReference)),Zs(r.floating)&&(M=M.concat(dc(r.floating))),!Zs(r.reference)&&r.reference&&r.reference.contextElement&&(M=M.concat(dc(r.reference.contextElement)))),M=M.filter(z=>{var $;return z!==(($=P.defaultView)==null?void 0:$.visualViewport)}),M.forEach(z=>{z.addEventListener("scroll",I,{passive:!0})}),()=>{l&&(P.removeEventListener("keydown",L?V:j,L),P.removeEventListener("compositionstart",D),P.removeEventListener("compositionend",E)),v&&P.removeEventListener(d,w?T:k,w),M.forEach(z=>{z.removeEventListener("scroll",I)}),window.clearTimeout(R)}},[o,r,l,v,d,s,n,f,a,b,y,j,L,V,k,w,T]),C.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const A=C.useMemo(()=>({onKeyDown:j,...h&&{[Ry[u]]:R=>{n(!1,R.nativeEvent,"reference-press")},...u!=="click"&&{onClick(R){n(!1,R.nativeEvent,"reference-press")}}}}),[j,n,h,u]),N=C.useMemo(()=>{function R(I){I.button===0&&(_.current=!0)}return{onKeyDown:j,onMouseDown:R,onMouseUp:R,[Py[d]]:()=>{o.current.insideReactTree=!0}}},[j,d,o]);return C.useMemo(()=>a?{reference:A,floating:N}:{},[a,A,N])}function Dy(t){const{open:e=!1,onOpenChange:s,elements:n}=t,r=X9(),o=C.useRef({}),[a]=C.useState(()=>jy()),l=C2()!=null,[c,d]=C.useState(n.reference),h=Ti((m,p,g)=>{o.current.openEvent=m?p:void 0,a.emit("openchange",{open:m,event:p,reason:g,nested:l}),s?.(m,p,g)}),u=C.useMemo(()=>({setPositionReference:d}),[]),f=C.useMemo(()=>({reference:c||n.reference||null,floating:n.floating||null,domReference:n.reference}),[c,n.reference,n.floating]);return C.useMemo(()=>({dataRef:o,open:e,onOpenChange:h,elements:f,events:a,floatingId:r,refs:u}),[e,h,f,a,r,u])}function My(t){t===void 0&&(t={});const{nodeId:e}=t,s=Dy({...t,elements:{reference:null,floating:null,...t.elements}}),n=t.rootContext||s,r=n.elements,[o,a]=C.useState(null),[l,c]=C.useState(null),h=r?.domReference||o,u=C.useRef(null),f=V2();oi(()=>{h&&(u.current=h)},[h]);const m=T4({...t,elements:{...r,...l&&{reference:l}}}),p=C.useCallback(b=>{const y=Zs(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;c(y),m.refs.setReference(y)},[m.refs]),g=C.useCallback(b=>{(Zs(b)||b===null)&&(u.current=b,a(b)),(Zs(m.refs.reference.current)||m.refs.reference.current===null||b!==null&&!Zs(b))&&m.refs.setReference(b)},[m.refs]),x=C.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:u}),[m.refs,g,p]),v=C.useMemo(()=>({...m.elements,domReference:h}),[m.elements,h]),_=C.useMemo(()=>({...m,...n,refs:x,elements:v,nodeId:e}),[m,x,v,e,n]);return oi(()=>{n.dataRef.current.floatingContext=_;const b=f?.nodesRef.current.find(y=>y.id===e);b&&(b.context=_)}),C.useMemo(()=>({...m,context:_,refs:x,elements:v}),[m,x,v,_])}function vc(t,e,s){const n=new Map,r=s==="item";let o=t;if(r&&t){const{[Fu]:a,[Uu]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[by]:""},...o,...e.map(a=>{const l=a?a[s]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((a,l)=>(l&&Object.entries(l).forEach(c=>{let[d,h]=c;if(!(r&&[Fu,Uu].includes(d)))if(d.indexOf("on")===0){if(n.has(d)||n.set(d,[]),typeof h=="function"){var u;(u=n.get(d))==null||u.push(h),a[d]=function(){for(var f,m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];return(f=n.get(d))==null?void 0:f.map(x=>x(...p)).find(x=>x!==void 0)}}}else a[d]=h}),a),{})}}function Oy(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),n=t.map(l=>l?.item),r=C.useCallback(l=>vc(l,t,"reference"),e),o=C.useCallback(l=>vc(l,t,"floating"),s),a=C.useCallback(l=>vc(l,t,"item"),n);return C.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:a}),[r,o,a])}const $y=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function By(t,e){var s,n;e===void 0&&(e={});const{open:r,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=X9(),h=((s=o.domReference)==null?void 0:s.id)||d,u=C.useMemo(()=>{var _;return((_=dy(o.floating))==null?void 0:_.id)||a},[o.floating,a]),f=(n=$y.get(c))!=null?n:c,p=C2()!=null,g=C.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:r?u:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":r?u:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:h},...f==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[f,u,p,r,h,c]),x=C.useMemo(()=>{const _={id:u,...f&&{role:f}};return f==="tooltip"||c==="label"?_:{..._,...f==="menu"&&{"aria-labelledby":h}}},[f,u,h,c]),v=C.useCallback(_=>{let{active:b,selected:y}=_;const L={role:"option",...b&&{id:u+"-fui-option"}};switch(c){case"select":case"combobox":return{...L,"aria-selected":y}}return{}},[u,c]);return C.useMemo(()=>l?{reference:g,floating:x,item:v}:{},[l,g,x,v])}function zy(t){var e;const{char:s,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:o,startOfLine:a,$position:l}=t,c=n&&!r,d=m5(s),h=new RegExp(`\\s${d}$`),u=a?"^":"",f=r?"":d,m=c?new RegExp(`${u}${d}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${d}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,x=Array.from(p.matchAll(m)).pop();if(!x||x.input===void 0||x.index===void 0)return null;const v=x.input.slice(Math.max(0,x.index-1),x.index),_=new RegExp(`^[${o?.join("")}\0]?$`).test(v);if(o!==null&&!_)return null;const b=g+x.index;let y=b+x[0].length;return c&&h.test(p.slice(y-1,y+1))&&(x[0]+=" ",y+=1),b<l.pos&&y>=l.pos?{range:{from:b,to:y},query:x[0].slice(s.length),text:x[0]}:null}var Fy=new Ma("suggestion");function Uy({pluginKey:t=Fy,editor:e,char:s="@",allowSpaces:n=!1,allowToIncludeChar:r=!1,allowedPrefixes:o=[" "],startOfLine:a=!1,decorationTag:l="span",decorationClass:c="suggestion",decorationContent:d="",decorationEmptyClass:h="is-empty",command:u=()=>null,items:f=()=>[],render:m=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=zy,shouldShow:x}){let v;const _=m?.(),b=()=>{const S=e.state.selection.$anchor.pos,j=e.view.coordsAtPos(S),{top:V,right:k,bottom:T,left:A}=j;try{return new DOMRect(A,V,k-A,T-V)}catch{return null}},y=(S,j)=>j?()=>{const V=t.getState(e.state),k=V?.decorationId,T=S.dom.querySelector(`[data-decoration-id="${k}"]`);return T?.getBoundingClientRect()||null}:b;function L(S,j){var V;try{const T=t.getState(S.state),A=T?.decorationId?S.dom.querySelector(`[data-decoration-id="${T.decorationId}"]`):null,N={editor:e,range:T?.range||{from:0,to:0},query:T?.query||null,text:T?.text||null,items:[],command:R=>u({editor:e,range:T?.range||{from:0,to:0},props:R}),decorationNode:A,clientRect:y(S,A)};(V=_?.onExit)==null||V.call(_,N)}catch{}const k=S.state.tr.setMeta(j,{exit:!0});S.dispatch(k)}const w=new R1({key:t,view(){return{update:async(S,j)=>{var V,k,T,A,N,R,I;const D=(V=this.key)==null?void 0:V.getState(j),E=(k=this.key)==null?void 0:k.getState(S.state),P=D.active&&E.active&&D.range.from!==E.range.from,M=!D.active&&E.active,z=D.active&&!E.active,$=!M&&!z&&D.query!==E.query,O=M||P&&$,U=$||P,H=z||P&&$;if(!O&&!U&&!H)return;const Y=H&&!O?D:E,G=S.dom.querySelector(`[data-decoration-id="${Y.decorationId}"]`);v={editor:e,range:Y.range,query:Y.query,text:Y.text,items:[],command:K=>u({editor:e,range:Y.range,props:K}),decorationNode:G,clientRect:y(S,G)},O&&((T=_?.onBeforeStart)==null||T.call(_,v)),U&&((A=_?.onBeforeUpdate)==null||A.call(_,v)),(U||O)&&(v.items=await f({editor:e,query:Y.query})),H&&((N=_?.onExit)==null||N.call(_,v)),U&&((R=_?.onUpdate)==null||R.call(_,v)),O&&((I=_?.onStart)==null||I.call(_,v))},destroy:()=>{var S;v&&((S=_?.onExit)==null||S.call(_,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(S,j,V,k){const{isEditable:T}=e,{composing:A}=e.view,{selection:N}=S,{empty:R,from:I}=N,D={...j},E=S.getMeta(t);if(E&&E.exit)return D.active=!1,D.decorationId=null,D.range={from:0,to:0},D.query=null,D.text=null,D;if(D.composing=A,T&&(R||e.view.composing)){(I<j.range.from||I>j.range.to)&&!A&&!j.composing&&(D.active=!1);const P=g({char:s,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:o,startOfLine:a,$position:N.$from}),M=`id_${Math.floor(Math.random()*4294967295)}`;P&&p({editor:e,state:k,range:P.range,isActive:j.active})&&(!x||x({editor:e,range:P.range,query:P.query,text:P.text,transaction:S}))?(D.active=!0,D.decorationId=j.decorationId?j.decorationId:M,D.range=P.range,D.query=P.query,D.text=P.text):D.active=!1}else D.active=!1;return D.active||(D.decorationId=null,D.range={from:0,to:0},D.query=null,D.text=null),D}},props:{handleKeyDown(S,j){var V,k,T,A;const{active:N,range:R}=w.getState(S.state);if(!N)return!1;if(j.key==="Escape"||j.key==="Esc"){const D=w.getState(S.state),E=(V=v?.decorationNode)!=null?V:null,P=E??(D?.decorationId?S.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`):null);if(((k=_?.onKeyDown)==null?void 0:k.call(_,{view:S,event:j,range:D.range}))||!1)return!0;const z={editor:e,range:D.range,query:D.query,text:D.text,items:[],command:$=>u({editor:e,range:D.range,props:$}),decorationNode:P,clientRect:P?()=>P.getBoundingClientRect()||null:null};return(T=_?.onExit)==null||T.call(_,z),L(S,t),!0}return((A=_?.onKeyDown)==null?void 0:A.call(_,{view:S,event:j,range:R}))||!1},decorations(S){const{active:j,range:V,decorationId:k,query:T}=w.getState(S);if(!j)return null;const A=!T?.length,N=[c];return A&&N.push(h),h5.create(S.doc,[f5.inline(V.from,V.to,{nodeName:l,class:N.join(" "),"data-decoration-id":k,"data-decoration-content":d})])}}});return w}function Hy(t){const e=B.c(24),{editor:s,query:n,items:r,onSelect:o,onClose:a}=t,[l,c]=C.useState(0),d=C.useRef(r),h=C.useRef(l),u=C.useRef(o),f=C.useRef(a),m=C.useDeferredValue(n);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{c(0)},e[0]=p):p=e[0];let g;e[1]!==m?(g=[m],e[1]=m,e[2]=g):g=e[2],C.useEffect(p,g);let x,v;e[3]!==r.length||e[4]!==l?(x=()=>{l>=r.length&&r.length>0&&c(0)},v=[r.length,l],e[3]=r.length,e[4]=l,e[5]=x,e[6]=v):(x=e[5],v=e[6]),C.useEffect(x,v);let _,b;e[7]!==r?(_=()=>{d.current=r},b=[r],e[7]=r,e[8]=_,e[9]=b):(_=e[8],b=e[9]),C.useEffect(_,b);let y,L;e[10]!==l?(y=()=>{h.current=l},L=[l],e[10]=l,e[11]=y,e[12]=L):(y=e[11],L=e[12]),C.useEffect(y,L);let w,S;e[13]!==o?(S=()=>{u.current=o},w=[o],e[13]=o,e[14]=w,e[15]=S):(w=e[14],S=e[15]),C.useEffect(S,w);let j,V;e[16]!==a?(j=()=>{f.current=a},V=[a],e[16]=a,e[17]=j,e[18]=V):(j=e[17],V=e[18]),C.useEffect(j,V);let k,T;e[19]!==s?(k=()=>{if(s?.isDestroyed)return;let R;try{R=s.view.dom}catch{return}if(!R)return;const I=E=>{const P=d.current;if(!P.length)return!1;const M=()=>c($=>($+1)%P.length),z=()=>c($=>($-1+P.length)%P.length);switch(E.key){case"ArrowUp":return E.preventDefault(),z(),!0;case"ArrowDown":return E.preventDefault(),M(),!0;case"Tab":return E.preventDefault(),E.shiftKey?z():M(),!0;case"Home":return E.preventDefault(),c(0),!0;case"End":return E.preventDefault(),c(P.length-1),!0;case"Enter":{if(E.isComposing)return!1;E.preventDefault();const $=h.current;return $!==-1&&P[$]&&u.current?.(P[$],$),!0}case"Escape":return E.preventDefault(),f.current?.(),!0;default:return!1}},D=E=>{I(E)};return R.addEventListener("keydown",D,!0),()=>{R?.removeEventListener("keydown",D,!0)}},T=[s],e[19]=s,e[20]=k,e[21]=T):(k=e[20],T=e[21]),C.useEffect(k,T);const A=r.length?l:void 0;let N;return e[22]!==A?(N={selectedIndex:A,setSelectedIndex:c},e[22]=A,e[23]=N):N=e[23],N}function Ky(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 N2=C.createContext(void 0);function A2(){const t=C.useContext(N2);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function Wy({editor:t,char:e,pluginKey:s,allow:n,onOpenChange:r}){const[o,a]=C.useReducer(Ky,{open:!1,element:null,query:"",range:null,selectedItem:null}),l=C.useRef(r);return l.current=r,C.useEffect(()=>{if(t?.isDestroyed)return;const c=s instanceof Ma?s:new Ma(s);t.state.plugins.find(u=>u.spec.key===c)&&t.unregisterPlugin(c);const h=Uy({pluginKey:c,editor:t,char:e,allow(u){const f=t.state.doc.resolve(u.range.from);for(let m=f.depth;m>0;m--)if(f.node(m).type.name==="image")return!1;return!(n&&!n(u))},command(){},render:()=>({onStart:u=>{a({type:"ON_START",payload:{element:u.decorationNode??null,query:u.query,range:u.range}}),l.current?.(!0)},onUpdate:u=>{a({type:"ON_UPDATE",payload:{element:u.decorationNode??null,query:u.query,range:u.range}})},onKeyDown:u=>u.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),l.current?.(!1)}}),items:()=>[]});return t.registerPlugin(h),()=>{t?.isDestroyed||t.unregisterPlugin(c)}},[t,s,e,a,n]),{state:o,dispatch:a}}function qy({editor:t,queryKey:e,queryFn:s,onSelect:n}){const{state:r,dispatch:o}=A2(),a=C.useDeferredValue(r.query),{data:l}=m9({queryKey:Qe.suggestionItems(e,r.open,a),queryFn:()=>r.open?s({query:a}):[]}),c=()=>{o({type:"ON_EXIT"})},d=async(u,f)=>{if(!(r.selectedItem!==null||!r.range)){o({type:"SET_SELECTED_ITEM",payload:u});try{const{view:m}=t,g=m.state.selection.$to.nodeAfter?.text?.startsWith(" "),x=r.range?{...r.range}:{from:0,to:0};g&&r.range&&(x.to+=1),await n({range:x,item:u})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):c()}catch{c()}}},{selectedIndex:h}=Hy({editor:t,query:a,items:l,onSelect:d,onClose:c});return{selectedItem:r.selectedItem,items:l,selectedIndex:h,close:c,onSelect:d}}function Gy({children:t}){const{state:e,dispatch:s}=A2(),{open:n,element:r}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=My({placement:"bottom-start",open:n,onOpenChange:f=>{f||o()},elements:{reference:r},middleware:[M4(10),O4(),$4()],whileElementsMounted:B4}),d=Iy(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),h=By(c,{role:"listbox"}),{getFloatingProps:u}=Oy([d,h]);return n?i.jsx(Ty,{children:i.jsx("div",{ref:a.setFloating,style:l,...u(),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 Yy=t=>{const e=B.c(29),{item:s,isSelected:n,onSelect:r,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const w=rn(s._meta);l=s.title||v9(s.name,w),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,h=s.icon,u=n&&"bg-accent text-accent-foreground",f=o&&"pointer-events-none opacity-50";let m;e[2]!==u||e[3]!==f?(m=ne("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",u,f),e[2]=u,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==h||e[6]!==c?(p=h!==void 0&&i.jsx(Hn,{icon:h,name:c,size:"xs",className:"mr-2"}),e[5]=h,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=i.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let x;e[10]!==o?(x=o&&i.jsx(Ui,{size:"xs"}),e[10]=o,e[11]=x):x=e[11];let v;e[12]!==g||e[13]!==x?(v=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,x]}),e[12]=g,e[13]=x,e[14]=v):v=e[14];let _;e[15]!==d?(_=d&&i.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=_):_=e[16];let b;e[17]!==v||e[18]!==_?(b=i.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,_]}),e[17]=v,e[18]=_,e[19]=b):b=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&i.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]=s.drillable,e[21]=y):y=e[21];let L;return e[22]!==r||e[23]!==a||e[24]!==b||e[25]!==y||e[26]!==m||e[27]!==p?(L=i.jsxs("div",{ref:a,onClick:r,className:m,children:[p,b,y]}),e[22]=r,e[23]=a,e[24]=b,e[25]=y,e[26]=m,e[27]=p,e[28]=L):L=e[28],L},Jy=t=>{const e=B.c(18),{editor:s,queryKey:n,queryFn:r,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==n?(a={editor:s,queryKey:n,queryFn:r,onSelect:o},e[0]=s,e[1]=o,e[2]=r,e[3]=n,e[4]=a):a=e[4];const{items:l,selectedIndex:c,onSelect:d,selectedItem:h}=qy(a);if(!l.length){let p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(p=i.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]=p):p=e[5],p}let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=u):u=e[6];let f;if(e[7]!==d||e[8]!==l||e[9]!==c||e[10]!==h?.name){let p;e[12]!==d||e[13]!==c||e[14]!==h?.name?(p=(g,x)=>i.jsx(Yy,{item:g,isSelected:x===c,ref:x===c?Zy:void 0,onSelect:()=>d(g,x),isLoading:h?.name===g.name},`${g.kind??"item"}:${g.name}`),e[12]=d,e[13]=c,e[14]=h?.name,e[15]=p):p=e[15],f=l.map(p),e[7]=d,e[8]=l,e[9]=c,e[10]=h?.name,e[11]=f}else f=e[11];let m;return e[16]!==f?(m=i.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:u,children:i.jsx("div",{className:"p-1",children:f})}),e[16]=f,e[17]=m):m=e[17],m};function Xy(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"p-1",children:[...Array(3)].map(Qy)}),t[0]=e):e=t[0],e}function Qy(t,e){return i.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[i.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),i.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function T2(t){const e=B.c(18),{editor:s,char:n,pluginKey:r,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let h;e[0]!==c||e[1]!==n||e[2]!==s||e[3]!==d||e[4]!==r?(h={editor:s,char:n,pluginKey:r,allow:c,onOpenChange:d},e[0]=c,e[1]=n,e[2]=s,e[3]=d,e[4]=r,e[5]=h):h=e[5];const{state:u,dispatch:f}=Wy(h);let m;e[6]!==f||e[7]!==u?(m={state:u,dispatch:f},e[6]=f,e[7]=u,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Xy,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=i.jsx(Gy,{children:i.jsx(C.Suspense,{fallback:p,children:i.jsx(Jy,{editor:s,queryKey:o,queryFn:a,onSelect:l})})}),e[10]=s,e[11]=l,e[12]=a,e[13]=o,e[14]=g):g=e[14];let x;return e[15]!==m||e[16]!==g?(x=i.jsx(N2.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=x):x=e[17],x}function Zy(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const e8=[{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}],t8=({editor:t,virtualMcpId:e})=>{const s=os(),{org:n}=Ae(),r=No(),o=M9(r),a=pt({connectionId:e,orgId:n.id,orgSlug:n.slug}),l=Qe.virtualMcpResources(e,n.id),[c,d]=C.useState("categories"),h=C.useRef(c);h.current=c;const u=C.useRef(null),f=C.useRef(!1),m=["at-mention",n.id,e??"default",c],p=async({item:v,range:_})=>{if(Ce("chat_picker_item_selected",{picker:"@",item_kind:v.kind,item_name:v.name}),v.kind!=="category"&&(f.current=!0),v.kind==="category")return d(v.name==="agents"?"agents":"resources"),!1;if(v.kind==="agent"&&v.agentId){Hi(t,_,{id:v.agentId,name:v.name,metadata:{agentId:v.agentId,title:v.name},char:"@"}),d("categories");return}if(v.kind==="resource"&&v.uri&&a){try{const b=await S1(a,v.uri);Hi(t,_,{id:v.uri,name:v.uri,metadata:b.contents,char:"@"})}catch(b){console.error("[at-mention] Failed to fetch resource:",b),de.error("Failed to load resource. Please try again.")}d("categories");return}},g=async v=>{const{query:_}=v,b=h.current;if(b==="categories"){if(!_.trim())return e8;const w=_.toLowerCase(),S=r.filter(V=>V.status==="active"&&(!V.id||!Oa(V.id))&&!o.has(V.id)&&V.id!==e&&(V.title.toLowerCase().includes(w)||V.description?.toLowerCase().includes(w))).map(V=>({name:V.title,title:V.title,description:V.description??void 0,icon:V.icon??null,kind:"agent",agentId:V.id})),j=await(async()=>{if(!a)return[];let V=s.getQueryData(l);return V||(V=await s.fetchQuery({queryKey:l,queryFn:()=>Kr(a),staleTime:6e4})),(V?.resources??[]).filter(k=>k.uri.toLowerCase().includes(w)||k.name?.toLowerCase().includes(w)||k.description?.toLowerCase().includes(w)).map(k=>({name:k.name??k.uri,title:k.name,description:k.description,kind:"resource",uri:k.uri}))})();return[...S,...j]}if(b==="agents"){let w=r.filter(S=>S.status==="active"&&(!S.id||!Oa(S.id))&&!o.has(S.id)&&S.id!==e);if(_.trim()){const S=_.toLowerCase();w=w.filter(j=>j.title.toLowerCase().includes(S)||j.description?.toLowerCase().includes(S))}return w.map(S=>({name:S.title,title:S.title,description:S.description??void 0,icon:S.icon??null,kind:"agent",agentId:S.id}))}if(!a)return[];let y=s.getQueryData(l);y?s.fetchQuery({queryKey:l,queryFn:()=>Kr(a),staleTime:6e4}).catch(()=>{}):y=await s.fetchQuery({queryKey:l,queryFn:()=>Kr(a),staleTime:6e4});let L=y?.resources??[];if(_.trim()){const w=_.toLowerCase();L=L.filter(S=>S.uri.toLowerCase().includes(w)||S.name?.toLowerCase().includes(w)||S.description?.toLowerCase().includes(w))}return L.map(w=>({name:w.name??w.uri,title:w.name,description:w.description,kind:"resource",uri:w.uri}))},x=v=>{if(v)u.current=Date.now(),f.current=!1,Ce("chat_picker_opened",{picker:"@"});else{const _=u.current;Ce("chat_picker_closed",{picker:"@",outcome:f.current?"selected":"dismissed",duration_ms:_?Date.now()-_:null}),u.current=null,d("categories")}};return i.jsx(T2,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:m,queryFn:g,onSelect:p,onOpenChange:x})};async function Yu(t,e,s,n,r,o){try{const a=await Vo(s,n,o);Hi(t,e,{id:n,name:rr(n,r),metadata:a.messages,char:"/",kind:"prompt",args:o})}catch(a){console.error("[slash] Failed to fetch prompt:",a),de.error("Failed to load prompt. Please try again.")}}async function s8(t,e,s,n){try{const r=await S1(s,n);Hi(t,e,{id:n,name:n,metadata:r.contents,char:"/",kind:"resource"})}catch(r){console.error("[slash] Failed to fetch resource:",r),de.error("Failed to load resource. Please try again.")}}async function n8(t,e,s,n){try{const{files:r,omittedPaths:o}=await Gx(s,n.volume,n.path),a={sandboxPath:n.sandboxPath,files:r,omittedPaths:o};Hi(t,e,{id:n.id,name:n.name,metadata:a,char:"/",kind:"skill"})}catch(r){console.error("[slash] Failed to fetch skill:",r),de.error("Failed to load skill. Please try again.")}}const i8=({editor:t,virtualMcpId:e})=>{const s=os(),{org:n}=Ae(),r=pt({connectionId:e,orgId:n.id,orgSlug:n.slug}),o=Qe.virtualMcpPrompts(e,n.id),a=Qe.virtualMcpResources(e,n.id),l=Qe.slashSkills(n.id),c=["slash-mention",n.id,e??"default"],[d,h]=C.useState(null),[u,f]=C.useState(null),m=p5(t);m&&(m.onEditChip=async L=>{if(r)try{const S=(await Ju(s,o,r)).find(j=>j.name===L.promptId);if(!S?.arguments||S.arguments.length===0)return;f({...L,prompt:S})}catch(w){console.error("[slash] Failed to load prompt for editing:",w),de.error("Failed to load prompt. Please try again.")}});const p=C.useRef(null),g=C.useRef(!1),x=async({item:L,range:w})=>{if(Ce("chat_picker_item_selected",{picker:"/",item_kind:L.kind,item_name:L.name}),g.current=!0,!!r)if(L.kind==="prompt"){if(L.arguments&&L.arguments.length>0){h({range:w,item:L});return}const S=rn(L._meta);await Yu(t,w,r,L.name,S)}else L.kind==="skill"?L.skill&&await n8(t,w,n.slug,L.skill):L.uri&&await s8(t,w,r,L.uri)},v=async L=>{if(!d||!r)return;const{range:w,item:S}=d,j=rn(S._meta);await Yu(t,w,r,S.name,j,L),h(null)},_=async L=>{if(!(!u||!r)){try{const w=await Vo(r,u.promptId,L),S=rn(u.prompt._meta);t.chain().focus().setNodeSelection(u.pos).deleteSelection().insertContentAt(u.pos,x9({id:u.promptId,name:rr(u.promptId,S),metadata:w.messages,char:"/",kind:"prompt",args:L})).run(),Ce("chat_picker_item_selected",{picker:"/edit",item_kind:"prompt",item_name:u.promptId})}catch(w){console.error("[slash] Failed to update prompt:",w),de.error("Failed to update prompt. Please try again.")}f(null)}},b=async L=>{const{query:w}=L;if(!r)return[];const[S,j,V]=await Promise.all([Ju(s,o,r),o8(s,a,r),r8(s,l,n.slug)]),k=w.trim().toLowerCase(),T=(S??[]).filter(R=>!k||R.name.toLowerCase().includes(k)||R.title?.toLowerCase().includes(k)||R.description?.toLowerCase().includes(k)).map(R=>({name:R.name,title:R.title,description:R.description,kind:"prompt",arguments:R.arguments,_meta:R._meta})),A=(j??[]).filter(R=>!k||R.uri.toLowerCase().includes(k)||R.name?.toLowerCase().includes(k)||R.description?.toLowerCase().includes(k)).map(R=>({name:R.name??R.uri,title:R.name,description:R.description,kind:"resource",uri:R.uri})),N=(V??[]).filter(R=>!k||R.name.toLowerCase().includes(k)||R.id.toLowerCase().includes(k)||R.description?.toLowerCase().includes(k)).map(R=>({name:R.name,title:R.name,description:R.description??void 0,kind:"skill",skill:R}));return[...T,...A,...N]},y=d?.item.kind==="prompt"?{name:d.item.name,title:d.item.title,arguments:d.item.arguments,description:d.item.description,_meta:d.item._meta}:null;return i.jsxs(i.Fragment,{children:[i.jsx(T2,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:c,queryFn:b,onSelect:x,onOpenChange:L=>{if(L)p.current=Date.now(),g.current=!1,Ce("chat_picker_opened",{picker:"/"});else{const w=p.current;Ce("chat_picker_closed",{picker:"/",outcome:g.current?"selected":"dismissed",duration_ms:w?Date.now()-w:null}),p.current=null}}}),i.jsx(io,{prompt:y,setPrompt:()=>h(null),onSubmit:v}),i.jsx(io,{prompt:u?.prompt??null,setPrompt:()=>f(null),onSubmit:_,defaultValues:u?.args},u?`edit-${u.promptId}-${u.pos}`:"edit-idle")]})};async function Ju(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>n0(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>n0(s),staleTime:6e4}),n?.prompts??[]}async function r8(t,e,s){const n=t.getQueryData(e),r=()=>t.fetchQuery({queryKey:e,queryFn:()=>Yx(s),staleTime:6e4});return n?(r().catch(()=>{}),n):r().catch(()=>[])}async function o8(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>Kr(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>Kr(s),staleTime:6e4}),n?.resources??[]}function a8(t){return[I1.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),Hb.configure({placeholder:()=>t.current??"Ask anything, / for prompts & skills, @ for agents & resources...",showOnlyWhenEditable:!1}),x5,v5]}function E2({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:n=!1,placeholder:r,onSubmit:o,children:a}){const l=C.useRef(o),c=C.useRef(e),d=C.useRef(n),h=C.useRef(r),u=P1({extensions:a8(h),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:(f,m)=>m.key==="Enter"&&!m.shiftKey&&d.current?(m.preventDefault(),l.current?.(),!0):!1},onUpdate:({editor:f})=>{c.current(f?.getJSON())}});return C.useEffect(()=>{u?.setEditable(!s)},[u,s]),C.useEffect(()=>{l.current=o},[o]),C.useEffect(()=>{c.current=e},[e]),C.useEffect(()=>{d.current=n},[n]),C.useEffect(()=>{h.current=r},[r]),C.useEffect(()=>{if(!u||u.isDestroyed)return;const f=JSON.stringify(u.getJSON()),m=JSON.stringify(t||{type:"doc",content:[]});f!==m&&u.commands.setContent(t||{type:"doc",content:[]})},[u,t]),i.jsx(g5.Provider,{value:{editor:u},children:a})}function R2(t){const e=B.c(26),{disabled:s,virtualMcpId:n,showFileUploader:r,selectedModel:o,onUnsupportedFile:a,ref:l,className:c}=t,d=s===void 0?!1:s,h=r===void 0?!1:r,{editor:u}=_9();let f,m;if(e[0]!==u?(f=()=>({focus:()=>{u?.commands.focus()},clear:()=>{u?.commands.clearContent(!0)},appendText:j=>{if(!u)return;const V=u.state.doc.textContent.trim()==="";u.commands.focus("end"),V||u.commands.insertContent(" "),u.commands.insertContent(j)},syncVoiceText:(j,V)=>{if(u&&(u.commands.setContent(j||{type:"doc",content:[]}),V)){u.commands.focus("end");const k=u.state.doc.textContent.trim().length>0;u.commands.insertContent(k?" "+V:V)}},restoreContent:j=>{u&&u.commands.setContent(j||{type:"doc",content:[]})}}),m=[u],e[0]=u,e[1]=f,e[2]=m):(f=e[1],m=e[2]),C.useImperativeHandle(l??null,f,m),!u)return null;const p=d&&"cursor-not-allowed opacity-70",g=d&&"[&_.ProseMirror]:cursor-not-allowed";let x;e[3]!==c||e[4]!==p||e[5]!==g?(x=ne("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",c,"[&_.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",p,g),e[3]=c,e[4]=p,e[5]=g,e[6]=x):x=e[6];let v;e[7]!==u||e[8]!==x?(v=i.jsx(D1,{editor:u,className:x}),e[7]=u,e[8]=x,e[9]=v):v=e[9];const _=n??null;let b;e[10]!==u||e[11]!==_?(b=i.jsx(C.Suspense,{fallback:null,children:i.jsx(i8,{editor:u,virtualMcpId:_})}),e[10]=u,e[11]=_,e[12]=b):b=e[12];const y=n??null;let L;e[13]!==u||e[14]!==y?(L=i.jsx(C.Suspense,{fallback:null,children:i.jsx(t8,{editor:u,virtualMcpId:y})}),e[13]=u,e[14]=y,e[15]=L):L=e[15];let w;e[16]!==u||e[17]!==a||e[18]!==o||e[19]!==h?(w=h&&o?i.jsx(Ob,{editor:u,selectedModel:o,onUnsupportedFile:a}):null,e[16]=u,e[17]=a,e[18]=o,e[19]=h,e[20]=w):w=e[20];let S;return e[21]!==b||e[22]!==L||e[23]!==w||e[24]!==v?(S=i.jsxs(i.Fragment,{children:[v,b,L,w]}),e[21]=b,e[22]=L,e[23]=w,e[24]=v,e[25]=S):S=e[25],S}function P2(t){const e=B.c(3),[s]=sr();let n;return e[0]!==s.enableSounds||e[1]!==t?(n=()=>{s.enableSounds&&vv(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=n):n=e[2],n}const l8={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"},c8=z5.togglePlanMode.keys.map(t=>t==="Shift"?"⇧":t).join(""),d8=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function u8(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"flex items-center -space-x-1.5",children:d8.map(h8)}),t[0]=e):e=t[0],e}function h8(t){return i.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function f8({disabled:t,onOpenConnections:e,virtualMcpId:s,selectedModel:n,isStreaming:r,onUnsupportedFile:o}){const[a,l]=C.useState(!1),c=P2(l8),{org:d}=Ae(),{editor:h}=_9(),u=Al(),f=C.useRef(null),m=Nl(n),p=()=>{!m||r||(l(!1),f.current?.click())},g=async K=>{const q=K.target.files;if(!q||q.length===0||!h)return;const W=Array.from(q),{from:F}=h.state.selection;try{for(const X of W)await J9(h,n??null,X,F,o)}finally{f.current&&(f.current.value="")}},x=pt({connectionId:s,orgId:d.id,orgSlug:d.slug}),v=Qe.virtualMcpPrompts(s,d.id),{data:_,isLoading:b}=gs({queryKey:v,queryFn:()=>n0(x),staleTime:6e4,enabled:a&&!!x}),y=_?.prompts??[],[L,w]=C.useState(null),{chatMode:S,setChatMode:j}=xs(),[V,k]=sr(),A=(Pr.find(K=>K.value===V.toolApprovalLevel)??Pr[0]).short,N=K=>{const q=Pr.find(W=>W.value===K);if(q){if(q.value===V.toolApprovalLevel){l(!1);return}c(),Ce("chat_approval_level_changed",{from_level:V.toolApprovalLevel,to_level:q.value,source:"tools_popover"}),k({...V,toolApprovalLevel:q.value}),l(!1)}},R=S==="plan",I=()=>{c();const K=R?"default":"plan";Ce("chat_mode_changed",{from_mode:S,to_mode:K,source:"tools_popover"}),j(K),l(!1)},D=()=>{e(),l(!1)},E=async(K,q)=>{if(!h||!x)return;const W=rn(K._meta),F={from:h.state.selection.from,to:h.state.selection.to};try{const X=await Vo(x,K.name,q);Hi(h,F,{id:K.name,name:rr(K.name,W),metadata:X.messages,char:"/",kind:"prompt",args:q})}catch{de.error("Failed to load prompt. Please try again.")}},P=async K=>{l(!1);const q=!!(K.arguments&&K.arguments.length>0);if(Ce("chat_prompt_inserted",{prompt_name:K.name,with_arguments:q}),q){w(K);return}await E(K)},M=async K=>{L&&(await E(L,K),w(null))},z=()=>{c();const K=S==="gen-image"?"default":"gen-image";Ce("chat_mode_changed",{from_mode:S,to_mode:K,source:"tools_popover"}),j(K),l(!1)},$=()=>{c();const K=S==="web-search"?"default":"web-search";Ce("chat_mode_changed",{from_mode:S,to_mode:K,source:"tools_popover"}),j(K),l(!1)},O=()=>{c();const K=S==="deep-research"?"default":"deep-research";Ce("chat_mode_changed",{from_mode:S,to_mode:K,source:"tools_popover"}),j(K),l(!1)},U=S==="gen-image",H=S==="web-search",Y=S==="deep-research",G=i.jsx("input",{ref:f,type:"file",multiple:!0,accept:Ux(n??null),className:"hidden",onChange:g,disabled:r});return u?i.jsxs(i.Fragment,{children:[G,i.jsxs(ie,{type:"button",variant:"ghost",size:"default",disabled:t||!m||r,title:"Add file","aria-label":"Add file",onClick:p,className:ne("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),children:[i.jsx(Z1,{size:14}),i.jsx("span",{className:ne("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:"Add file"})]})]}):i.jsxs(i.Fragment,{children:[G,i.jsxs(Zt,{open:a,onOpenChange:K=>{K&&!a&&Ce("chat_tools_popover_opened",{chat_mode:S}),l(K)},children:[i.jsx(es,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"ghost",size:"default",disabled:t,title:"Tools","aria-label":"Tools",className:ne("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),children:[i.jsx(em,{size:14}),i.jsx("span",{className:ne("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"})]})}),i.jsxs(ts,{align:"start",className:"w-52 p-1.5 space-y-1",children:[m?i.jsxs(He,{onClick:p,disabled:r,children:[i.jsx(Lt,{size:16}),i.jsx("span",{className:"flex-1",children:"Add file"})]}):i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsxs(He,{"aria-disabled":"true",className:"opacity-50 cursor-not-allowed",onSelect:K=>K.preventDefault(),children:[i.jsx(Lt,{size:16}),i.jsx("span",{className:"flex-1",children:"Add file"})]})}),i.jsx(Pe,{side:"right",children:"The selected model does not support reading files or images."})]}),i.jsxs(He,{onClick:I,className:ne(R&&"text-violet-600 dark:text-violet-400"),children:[i.jsx(Ki,{size:16,className:ne(R&&"text-violet-500")}),i.jsx("span",{className:"flex-1",children:"Plan mode"}),i.jsx("span",{className:ne("text-xs text-muted-foreground",R&&"text-violet-500 font-medium"),children:c8})]}),i.jsxs(He,{onClick:z,className:ne(U&&"text-pink-600 dark:text-pink-400"),children:[i.jsx(_n,{size:16,className:ne(U&&"text-pink-500")}),i.jsx("span",{className:"flex-1",children:"Create image"}),U&&i.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),i.jsxs(He,{onClick:$,className:ne(H&&"text-blue-600 dark:text-blue-400"),children:[i.jsx(on,{size:16,className:ne(H&&"text-blue-500")}),i.jsx("span",{className:"flex-1",children:"Web search"}),H&&i.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),i.jsxs(He,{onClick:O,className:ne(Y&&"text-blue-600 dark:text-blue-400"),children:[i.jsx(tm,{size:16,className:ne(Y&&"text-blue-500")}),i.jsx("span",{className:"flex-1",children:"Deep research"}),Y&&i.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),i.jsxs(oo,{children:[i.jsxs(ao,{className:"gap-2",children:[i.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),i.jsx("span",{className:"flex-1",children:"Prompts"})]}),i.jsx(lo,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:b?i.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Loading prompts…"]}):y.length===0?i.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):y.map(K=>i.jsxs(He,{onClick:()=>P(K),className:"flex flex-col items-start gap-0.5",children:[i.jsx("span",{className:"font-medium text-sm capitalize",children:K.title||v9(K.name,rn(K._meta))}),K.description&&i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:K.description})]},K.name))})]}),i.jsxs(oo,{children:[i.jsxs(ao,{className:"gap-2",children:[i.jsx(jl,{size:16}),i.jsx("span",{className:"flex-1",children:"Approval"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:A})]}),i.jsx(lo,{className:"w-48 p-1.5",children:i.jsx(l0,{value:V.toolApprovalLevel,onValueChange:N,children:Pr.map(K=>i.jsx(Po,{value:K.value,children:K.label},K.value))})})]}),i.jsxs(He,{onClick:D,children:[i.jsx(hm,{size:16}),i.jsx("span",{className:"flex-1",children:"Connections"}),i.jsx(C.Suspense,{children:i.jsx(u8,{})})]})]})]}),i.jsx(io,{prompt:L,setPrompt:w,onSubmit:M})]})}const m8=[{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 p8(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"flex items-center -space-x-1",children:m8.map(g8)}),t[0]=e):e=t[0],e}function g8(t){return i.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function x8(t){const e=B.c(6),{onClick:s}=t;let n,r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ne("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),r=i.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=i.jsx(p8,{}),a=i.jsx(cn,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=n,e[1]=r,e[2]=o,e[3]=a):(n=e[0],r=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=i.jsxs("button",{type:"button",onClick:s,className:n,children:[r,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const Dr=48;function v8(){const t=B.c(9),[e,s]=C.useState("idle"),[n,r]=C.useState(""),[o,a]=C.useState(""),[l,c]=C.useState(y8),d=C.useRef(null),h=C.useRef(null),u=C.useRef(null),f=C.useRef(null),m=C.useRef(0),p=C.useRef(!1),g=C.useRef(""),x=C.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let _;t[0]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),h.current?.close().catch(b8),f.current?.getTracks().forEach(_8),u.current=null,h.current=null,f.current=null},t[0]=_):_=t[0];const b=_;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const T=A=>{f.current=A;const N=new AudioContext;h.current=N;const R=N.createMediaStreamSource(A),I=N.createAnalyser();I.fftSize=128,I.smoothingTimeConstant=.8,R.connect(I),u.current=I;const D=new Uint8Array(I.frequencyBinCount),E=()=>{if(!u.current)return;u.current.getByteFrequencyData(D);const P=[];for(let M=0;M<Dr;M++){const z=Math.floor(M/Dr*D.length);P.push(Math.max(.04,(D[z]??0)/255))}c(P),m.current=requestAnimationFrame(E)};E()};y=async()=>{const A=window.SpeechRecognition||window.webkitSpeechRecognition;if(!A){s("unsupported");return}let N;try{N=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}r(""),a(""),x.current="",g.current="",p.current=!0,s("recording"),T(N);const R=new A;d.current=R,R.interimResults=!0,R.continuous=!0,R.lang=navigator.language||"en-US",R.onresult=I=>{let D="",E="";for(let P=I.resultIndex;P<I.results.length;P++){const M=I.results[P],z=M?.[0]?.transcript??"";M?.isFinal?E=E+z:D=D+z}E&&(g.current=g.current+E,r(g.current)),x.current=D,a(D)},R.onend=()=>{if(p.current)try{R.start()}catch{}};try{R.start()}catch{s("idle")}},t[1]=y}else y=t[1];const L=y;let w;t[2]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{p.current=!1,d.current?.stop(),b(),s("idle"),c(Array(Dr).fill(.05)),a("");const T=(g.current+(x.current?" "+x.current:"")).trim();return r(""),g.current="",x.current="",T},t[2]=w):w=t[2];const S=w;let j;t[3]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{p.current=!1,d.current?.abort(),b(),s("idle"),r(""),a(""),c(Array(Dr).fill(.05)),g.current="",x.current=""},t[3]=j):j=t[3];const V=j;let k;return t[4]!==o||t[5]!==e||t[6]!==n||t[7]!==l?(k={status:e,transcript:n,interimTranscript:o,waveformData:l,isSupported:v,startRecording:L,stopRecording:S,cancelRecording:V},t[4]=o,t[5]=e,t[6]=n,t[7]=l,t[8]=k):k=t[8],k}function _8(t){return t.stop()}function b8(){}function y8(){return Array(Dr).fill(.05)}function L8(t){const e=B.c(4),{data:s}=t;let n;e[0]!==s?(n=s.map(S8),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:n}),e[2]=n,e[3]=r):r=e[3],r}function S8(t,e){return i.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 w8({messageCount:t,showConnectionsBanner:e}){return t>0||e}function j8(t){return t.hasDraft?"send":t.isStreaming||t.isRunInProgress?"stop":"disabled"}function C8(t){const e=B.c(3),{message:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(p9,{size:14,className:"shrink-0"}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.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:[n,i.jsx("span",{className:"text-sm",children:s})]}),e[1]=s,e[2]=r):r=e[2],r}function V8(t,e){const s=B.c(5),{editor:n}=_9(),[r,o]=C.useState(!1),a=C.useRef(0);let l,c;return s[0]!==n||s[1]!==e||s[2]!==t?(l=()=>{const d=m=>{m.dataTransfer?.types.includes("Files")&&(m.preventDefault(),a.current=a.current+1,o(!0))},h=m=>{m.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},u=k8,f=m=>{if(m.preventDefault(),a.current=0,o(!1),!n||!t||!Nl(t))return;const p=m.dataTransfer?.files;if(!p||p.length===0)return;const{from:g}=n.state.selection;for(const x of Array.from(p))J9(n,t,x,g,e)};return window.addEventListener("dragenter",d),window.addEventListener("dragleave",h),window.addEventListener("dragover",u),window.addEventListener("drop",f),()=>{window.removeEventListener("dragenter",d),window.removeEventListener("dragleave",h),window.removeEventListener("dragover",u),window.removeEventListener("drop",f)}},c=[n,t,e],s[0]=n,s[1]=e,s[2]=t,s[3]=l,s[4]=c):(l=s[3],c=s[4]),C.useEffect(l,c),r}function k8(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function N8(t){const e=B.c(11),{selectedModel:s,onUnsupportedFile:n}=t,r=V8(s,n);let o;e[0]!==s?(o=Nl(s),e[0]=s,e[1]=o):o=e[1];const a=o,l=r?"opacity-100":"opacity-0 pointer-events-none",c=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let d;e[2]!==l||e[3]!==c?(d=ne("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",l,c),e[2]=l,e[3]=c,e[4]=d):d=e[4];let h;e[5]!==s||e[6]!==a?(h=a?i.jsxs(i.Fragment,{children:[i.jsx(or,{size:24}),i.jsxs("span",{className:"text-sm font-medium",children:["Drop ",xm(s)," here"]})]}):i.jsxs(i.Fragment,{children:[i.jsx(p9,{size:24}),i.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=s,e[6]=a,e[7]=h):h=e[7];let u;return e[8]!==d||e[9]!==h?(u=i.jsx("div",{className:d,children:h}),e[8]=d,e[9]=h,e[10]=u):u=e[10],u}function A8(){const t=B.c(6),e=Ct(),{org:s,locator:n}=Ae(),{create:r}=y9();let o;return t[0]!==r||t[1]!==n||t[2]!==e||t[3]!==s.id||t[4]!==s.slug?(o=async a=>{const{tiptapDoc:l,virtualMcp:c}=a,d=crypto.randomUUID(),h=c?.id??Co(s.id).id;Y1(sessionStorage,n,d,{tiptapDoc:l});try{await r({id:d,virtual_mcp_id:h})}catch{}const u={virtualmcpid:h,autosend:Y5};e({to:"/$org/$taskId",params:{org:s.slug,taskId:d},search:u})},t[0]=r,t[1]=n,t[2]=e,t[3]=s.id,t[4]=s.slug,t[5]=o):o=t[5],o}function T8({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=E1(),n=ir(),r=s?.messages??[],o=s?.isStreaming??!1,a=s?.isRunInProgress??!1,l=s?.stop??(()=>{}),c=n?.taskId??"",d=c||O6,h=A8(),{selectedModel:u,selectedVirtualMcp:f,isModelsLoading:m,tiptapDocRef:p,imageModel:g,webSearchModel:x,deepResearchModel:v,chatMode:_,setChatMode:b}=xs(),{data:y}=vi.useSession(),L=y?.user?.id,{org:w,locator:S}=Ae(),j=Al(),V=Co(w.id).id,k=qs(f?.id??V),T=P2(_v),[A,N]=C.useState(!1),{unsupportedFile:R,onUnsupportedFile:I,clearUnsupportedFile:D}=Ub(),E=v8(),P=C.useRef(void 0),M=async()=>{P.current=U,await E.startRecording();const ce=E.status==="recording"?"started":E.status==="unsupported"?"unsupported":E.status==="permission-denied"?"permission_denied":"unknown";Ce("chat_voice_started",{thread_id:c,outcome:ce})},z=()=>{Ce("chat_voice_confirmed",{thread_id:c});const ce=E.stopRecording();W.current?.syncVoiceText(P.current,ce),W.current?.focus()},$=()=>{Ce("chat_voice_cancelled",{thread_id:c}),E.cancelRecording(),W.current?.restoreContent(P.current)};C.useEffect(()=>{if(E.status!=="recording")return;const ce=(E.transcript+(E.interimTranscript?" "+E.interimTranscript:"")).trim();W.current?.syncVoiceText(P.current,ce)},[E.transcript,E.interimTranscript,E.status]);const O=n?.activeTask??null,[U,H]=C.useState(()=>ju(sessionStorage,S,d)??void 0),Y=ce=>{H(ce),p.current=ce,B6(sessionStorage,S,d,ce,{onQuotaExceeded:({docSizeBytes:fe})=>{Ce("chat_draft_quota_exceeded",{thread_id:c||null,doc_size_bytes:fe}),console.warn("[chat-draft] sessionStorage quota exceeded; draft not saved")}})},G=C.useRef(c);if(G.current!==c){G.current=c;const ce=ju(sessionStorage,S,d)??void 0;H(ce),p.current=ce}const q=[...r].reverse().find(ce=>ce.role==="assistant")?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow,W=C.useRef(null),F=_==="plan";C.useEffect(()=>{const ce=fe=>{W1(fe)&&fe.code==="KeyL"&&(fe.preventDefault(),fe.shiftKey&&b(_==="plan"?"default":"plan"),W.current?.focus())};return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[_,b]);const X=M1(r),Z=[...r].reverse().find(ce=>ce.role==="assistant"&&ce.metadata?.usage)?.metadata?.usage?.contextTokens??0,J=!m&&!Ym(U),ee=j8({hasDraft:J,isStreaming:o,isRunInProgress:a}),te=ee==="send",ae=ee==="stop",se=w8({messageCount:r.length,showConnectionsBanner:e}),oe=ce=>{if(ce?.preventDefault(),ee==="send"&&U){if(Ce("chat_message_sent",{thread_id:c||null,mode:_,model_id:u?.modelId??null,model_provider:u?.providerId??null,virtual_mcp_id:f?.id??null,submission:ce?"button_or_enter":"programmatic"}),s){if(s.isSendInFlight()){de.info("Still sending your previous message — try again in a moment");return}s.sendMessage(U)}else h({tiptapDoc:U,virtualMcp:f});z6(sessionStorage,S,d),Y(void 0)}else ee==="stop"&&(Ce("chat_message_stopped",{thread_id:c}),l())};return L&&O?.created_by&&O.created_by!==L?i.jsx(C8,{message:"Read only - you're viewing someone else's thread"}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-col w-full justify-end",children:i.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&i.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),s&&n&&i.jsx(Il,{}),s&&n&&c?i.jsx(B_,{taskId:c}):null,i.jsx(E2,{tiptapDoc:U,setTiptapDoc:Y,disabled:!1,enterToSubmit:!0,placeholder:j?"Ask anything":void 0,onSubmit:oe,children:i.jsxs("form",{onSubmit:oe,className:ne("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:[i.jsx(N8,{selectedModel:u,onUnsupportedFile:I}),i.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:i.jsx(R2,{ref:W,disabled:E.status==="recording",virtualMcpId:f?.id??V,showFileUploader:!0,selectedModel:u,onUnsupportedFile:I})}),i.jsx("div",{className:"@container/chat-bottom flex items-center justify-between p-2.5 gap-1",children:E.status==="recording"?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[i.jsx(L8,{data:E.waveformData.slice(0,28)}),i.jsx("button",{type:"button",onClick:$,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:i.jsx(ms,{size:16})}),i.jsx("button",{type:"button",onClick:z,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:i.jsx(Tt,{size:16})})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[i.jsx(f8,{disabled:!1,onOpenConnections:()=>{Ce("connections_dialog_opened",{source:"tools_popover",mode:"add"}),N(!0)},virtualMcpId:f?.id??V,selectedModel:u,isStreaming:o,onUnsupportedFile:I}),F&&i.jsxs("button",{type:"button",onClick:()=>{T(),Ce("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),b("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:[i.jsx(Ki,{size:14,className:"shrink-0"}),i.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"}),i.jsx(ms,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="gen-image"&&g&&i.jsxs("button",{type:"button",onClick:()=>{T(),Ce("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),b("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:[i.jsx(_n,{size:14,className:"shrink-0"}),i.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"}),i.jsx(ms,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="web-search"&&x&&i.jsxs("button",{type:"button",onClick:()=>{T(),Ce("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),b("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:[i.jsx(on,{size:14,className:"shrink-0"}),i.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"}),i.jsx(ms,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="deep-research"&&v&&i.jsxs("button",{type:"button",onClick:()=>{T(),Ce("chat_mode_changed",{from_mode:"deep-research",to_mode:"default",source:"pill_dismiss"}),b("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:[i.jsx(tm,{size:14,className:"shrink-0"}),i.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"}),i.jsx(ms,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),q&&Z>0&&i.jsx(_5,{usage:X,totalTokens:Z,contextWindow:q,onOpenContextPanel:t})]}),i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[se&&i.jsx(p2,{virtualMcp:k,currentBranch:n?.currentBranch??null}),i.jsx(Mb,{}),E.isSupported&&i.jsx(ie,{type:"button",onClick:M,disabled:!1,variant:"ghost",size:"icon",className:ne("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:i.jsx(Q5,{size:18})}),i.jsx(ie,{type:ae?"button":"submit",onClick:ce=>{ae&&(ce.preventDefault(),ce.stopPropagation(),l())},variant:te||ae?"default":"ghost",size:"icon",disabled:!te&&!ae,className:ne("size-8 rounded-lg transition-all",!te&&!ae&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:ee==="stop"?o?"Stop generating":"Cancel run":"Send message (Enter)",children:ae?i.jsx(Z5,{size:20}):i.jsx(g9,{size:20})})]})]})})]})},c),e&&i.jsx(x8,{onClick:()=>{Ce("connections_banner_clicked",{source:"home_chat_input"}),Ce("connections_dialog_opened",{source:"home_banner",mode:"add"}),N(!0)}})]})}),i.jsx(mm,{mode:"browse",open:A,onOpenChange:N,defaultTab:"all"}),i.jsx(zb,{info:R,onClose:D})]})}const E8={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 I2(t){return`deco-credits-empty-dismissed:${t}`}function R8(t){try{return localStorage.getItem(I2(t))==="1"}catch{return!1}}function P8(){const t=B.c(47),{org:e}=Ae(),s=Ct(),{decoKeyId:n}=D9(),r=Ms(),[o,a]=C.useState(!0),[l,c]=C.useState(""),[d,h]=C.useState(!1),[u,f]=C.useState("usd"),m=u==="brl"?"R$":"$";let p;t[0]!==e.id?(p=()=>{Ce("credits_empty_state_dismissed",{organization_id:e.id}),a(!1);try{localStorage.setItem(I2(e.id),"1")}catch{}},t[0]=e.id,t[1]=p):p=t[1];const g=p;let x,v;t[2]!==o||t[3]!==e.id?(x=()=>{o&&Ce("credits_empty_state_shown",{organization_id:e.id})},v=[o,e.id],t[2]=o,t[3]=e.id,t[4]=x,t[5]=v):(x=t[4],v=t[5]),C.useEffect(x,v);let _;t[6]!==u||t[7]!==r?(_=async $=>{const{url:O}=await r.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:$,currency:u});return O},t[6]=u,t[7]=r,t[8]=_):_=t[8];let b;t[9]!==g?(b=$=>{$&&window.open($,"_blank","noopener,noreferrer"),g()},t[9]=g,t[10]=b):b=t[10];let y;t[11]!==_||t[12]!==b?(y={mutationFn:_,onSuccess:b,onError:D8},t[11]=_,t[12]=b,t[13]=y):y=t[13];const{mutate:L,isPending:w}=Ds(y),S=parseFloat(l),j=!isNaN(S)&&S>=1;if(!o)return null;let V;t[14]!==g?(V=$=>!$&&g(),t[14]=g,t[15]=V):V=t[15];let k;t[16]===Symbol.for("react.memo_cache_sentinel")?(k=i.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]=k):k=t[16];let T;t[17]===Symbol.for("react.memo_cache_sentinel")?(T=i.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:i.jsx(sm,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[17]=T):T=t[17];let A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[k,i.jsxs(ns,{className:"relative gap-3",children:[T,i.jsxs("div",{className:"text-center",children:[i.jsx(is,{className:"text-lg font-semibold",children:"This workspace has no credits"}),i.jsx(qn,{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]=A):A=t[18];let N;t[19]!==u||t[20]!==m||t[21]!==l||t[22]!==S||t[23]!==n||t[24]!==j||t[25]!==w||t[26]!==d||t[27]!==L?(N=n&&i.jsxs("div",{className:"px-6 pb-5",children:[i.jsx("div",{className:"mb-4",children:i.jsxs(fm,{type:"single",variant:"outline",size:"sm",value:u,onValueChange:$=>{$&&f($)},children:[i.jsx(za,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),i.jsx(za,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),i.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:E8[u].map($=>{const{dollars:O,label:U}=$;return i.jsxs("button",{type:"button",disabled:w,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:O*100,currency:u,tier_label:U,source:"empty_state"}),L(O*100)},className:ne("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:[i.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,O]}),i.jsx("span",{className:"text-xs text-muted-foreground",children:U})]},O)})}),d?i.jsxs("div",{className:"flex gap-2 mt-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),i.jsx(Ye,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:$=>c($.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),i.jsx(ie,{className:"h-10",disabled:!j||w,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:Math.round(S*100),currency:u,tier_label:"custom",source:"empty_state"}),L(Math.round(S*100))},children:w?"Opening...":"Add"})]}):i.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),t[19]=u,t[20]=m,t[21]=l,t[22]=S,t[23]=n,t[24]=j,t[25]=w,t[26]=d,t[27]=L,t[28]=N):N=t[28];let R;t[29]!==g||t[30]!==s||t[31]!==e.slug?(R=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),g()},t[29]=g,t[30]=s,t[31]=e.slug,t[32]=R):R=t[32];let I;t[33]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(To,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[33]=I):I=t[33];let D;t[34]!==R?(D=i.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:R,children:["Use your own provider",I]}),t[34]=R,t[35]=D):D=t[35];let E;t[36]!==g?(E=i.jsx(ie,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:g,children:"Skip for now"}),t[36]=g,t[37]=E):E=t[37];let P;t[38]!==D||t[39]!==E?(P=i.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[D,E]}),t[38]=D,t[39]=E,t[40]=P):P=t[40];let M;t[41]!==N||t[42]!==P?(M=i.jsxs(Ft,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:I8,children:[A,N,P]}),t[41]=N,t[42]=P,t[43]=M):M=t[43];let z;return t[44]!==M||t[45]!==V?(z=i.jsx(Ut,{open:!0,onOpenChange:V,children:M}),t[44]=M,t[45]=V,t[46]=z):z=t[46],z}function I8(t){return t.preventDefault()}function D8(t){de.error(`Top-up failed: ${t.message}`)}function M8(t){const e=B.c(6),{balanceDollars:s}=t;let n;e[0]!==s?(n=s.toFixed(2),e[0]=s,e[1]=n):n=e[1];const r=n;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=ne("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=i.jsx(sm,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==r?(l=i.jsxs("div",{className:o,children:[a,i.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",r," in credits to get started"]})]}),e[4]=r,e[5]=l):l=e[5],l}function O8(){const t=B.c(8),{org:e}=Ae(),s=Ct();let n;t[0]!==s||t[1]!==e.slug?(n=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=n):n=t[2];let r,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=ne("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"),o=i.jsx(fn,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=i.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=r,t[4]=o,t[5]=a):(r=t[3],o=t[4],a=t[5]);let l;return t[6]!==n?(l=i.jsxs("button",{type:"button",onClick:n,className:r,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function $8(t){const e=B.c(11),{className:s}=t;let n;e[0]!==s?(n=ne("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=n):n=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("div",{className:"flex items-center gap-3",children:[r,i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),i.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),i.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:i.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[i.jsx(Zo,{align:"right",width:"w-3/4"}),i.jsx(Zo,{align:"left",width:"w-full",lines:3}),i.jsx(Zo,{align:"right",width:"w-2/3"}),i.jsx(Zo,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:i.jsx("div",{className:"relative flex-1",children:i.jsxs("div",{className:"space-y-2 p-2",children:[i.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),i.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("div",{className:"flex items-center gap-1",children:i.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx("div",{className:"px-4 py-4",children:i.jsx("div",{className:"mx-auto w-full max-w-2xl",children:i.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,i.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),i.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=h):h=e[8];let u;return e[9]!==n?(u=i.jsxs("div",{className:n,children:[a,l,h]}),e[9]=n,e[10]=u):u=e[10],u}function Zo(t){const e=B.c(22),{align:s,width:n,lines:r}=t,o=n===void 0?"w-full":n,a=r===void 0?1:r,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=ne("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=c):c=e[1];const d=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let h;e[2]!==d?(h=ne("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=u):u=e[4];const f=s==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==f||e[6]!==o?(m=ne("min-w-0 rounded-2xl p-4",f,o),e[5]=f,e[6]=o,e[7]=m):m=e[7];let p;e[8]!==a?(p=Array.from({length:a}),e[8]=a,e[9]=p):p=e[9];let g;e[10]!==a||e[11]!==p?(g=i.jsx("div",{className:"space-y-2",children:p.map((b,y)=>i.jsx("div",{className:ne("h-3 rounded bg-muted-foreground/20 animate-pulse",y===a-1?"w-3/4":"w-full"),style:{animationDelay:`${y*.1}s`}},y))}),e[10]=a,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==g||e[14]!==m?(x=i.jsx("div",{className:m,children:g}),e[13]=g,e[14]=m,e[15]=x):x=e[15];let v;e[16]!==x||e[17]!==h?(v=i.jsxs("div",{className:h,children:[u,x]}),e[16]=x,e[17]=h,e[18]=v):v=e[18];let _;return e[19]!==v||e[20]!==c?(_=i.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=_):_=e[21],_}function B8(t){const e=B.c(7),{scrollRef:s,sentinelRef:n,hasMoreOlder:r,isFetchingOlder:o,fetchOlderMessages:a}=t;let l,c;e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==n?(l=()=>{const d=n.current,h=s.current;if(!d||!h||!r)return;const u=new IntersectionObserver(async f=>{if(!f[0]?.isIntersecting||o||!r)return;const p=h.scrollHeight,g=h.scrollTop;await a(),requestAnimationFrame(()=>{const x=h.scrollHeight;h.scrollTop=g+(x-p)})},{root:h,rootMargin:"200px 0px 0px 0px"});return u.observe(d),()=>u.disconnect()},c=[s,n,r,o,a],e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=n,e[5]=l,e[6]=c):(l=e[5],c=e[6]),C.useEffect(l,c)}function z8(t){const e=B.c(5),{className:s,children:n}=t;let r;e[0]!==s?(r=ne("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==n||e[3]!==r?(o=i.jsx("div",{className:r,children:n}),e[2]=n,e[3]=r,e[4]=o):o=e[4],o}function F8(t){const e=B.c(5),{children:s,className:n}=t;let r;e[0]!==n?(r=ne("flex-1 min-h-0 overflow-y-auto isolate",n),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=i.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function U8(t){const e=B.c(2),{children:s}=t;let n;return e[0]!==s?(n=i.jsx("div",{className:"min-h-full shrink-0 w-full flex items-center justify-center max-w-2xl mx-auto py-10",children:s}),e[0]=s,e[1]=n):n=e[1],n}function H8(){const{messages:t,status:e,hasMoreOlder:s,isFetchingOlder:n,fetchOlderMessages:r}=js(),{taskId:o}=as(),a=A1(o??""),l=i5(a),c=l.size===0?t:t.filter(v=>!l.has(v.id)),d=b5(c),h=d.at(-1),f=M6()*j6+16,m=C.useRef(null),p=C.useRef(null);B8({scrollRef:m,sentinelRef:p,hasMoreOlder:s,isFetchingOlder:n,fetchOlderMessages:r});const g=y5({initial:!1}),x=v=>{m.current=v,g.scrollRef(v)};return i.jsx(L5,{messages:t,children:i.jsxs("div",{className:"relative h-full w-full min-w-0",children:[i.jsx("div",{ref:x,"data-chat-scroller":!0,className:"w-full min-w-0 max-w-full overflow-y-auto h-full [container-type:size]",style:{paddingBottom:f},children:i.jsxs("div",{ref:g.contentRef,className:"overflow-x-clip",children:[i.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[i.jsx("div",{ref:p,"aria-hidden":!0,className:"h-px"}),n&&i.jsx("div",{className:"flex items-center justify-center py-3 text-xs text-muted-foreground",children:"Loading older messages…"}),d.slice(0,-1).map((v,_)=>i.jsx(hu,{pair:v,isLastPair:!1,status:_===d.length-1?e:void 0},`pair-${v.user?.id??v.assistant?.id}`))]}),h&&i.jsx("div",{className:"min-h-[100cqh] min-w-0 max-w-2xl mx-auto w-full",children:i.jsx(hu,{pair:h,isLastPair:!0,status:e},`pair-${h.user?.id??h.assistant?.id}`)})]})}),!g.isAtBottom&&i.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:f+8},onClick:()=>{g.scrollToBottom()},children:i.jsx(Q4,{size:14})})]})})}function K8(t){const e=B.c(5),{children:s,className:n}=t;let r;e[0]!==n?(r=ne("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",n),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=i.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}const dt=Object.assign(z8,{Main:F8,Messages:H8,EmptyState:U8,Footer:K8,Input:T8,Provider:n5,ActiveTaskProvider:s5,Skeleton:$8,IceBreakers:w6,NoAiProviderEmptyState:vm,CreditsEmptyState:P8,CreditsEyebrow:M8,NoCreditsEyebrow:O8,CreditsExhaustedBanner:r2});function Z9(){const t=Sm(),{pendingAgentOption:e}=xs(),s=Dl();if(ir()?.isThreadLocked)return!1;const r=e==="claude-code-desktop"&&s.claudeCode||e==="codex-desktop"&&s.codex;return t.length===0&&!r}function Lr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Xu(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function W8(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function q8(t){const e=B.c(4),{items:s}=t;let n;e[0]!==s?(n=s.map(G8),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:n}),e[2]=n,e[3]=r):r=e[3],r}function G8(t){return i.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[i.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),i.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Y8(t){const e=B.c(30),{userTokens:s,assistantTokens:n,otherTokens:r}=t,o=s+n+r,a=o>0?s/o*100:0,l=o>0?n/o*100:0,c=o>0?r/o*100:0;let d;e[0]!==a?(d=a>0&&i.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let h;e[2]!==l?(h=l>0&&i.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=h):h=e[3];let u;e[4]!==c?(u=c>0&&i.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=u):u=e[5];let f;e[6]!==d||e[7]!==h||e[8]!==u?(f=i.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,h,u]}),e[6]=d,e[7]=h,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=i.jsxs("div",{className:"flex items-center gap-1.5",children:[m,i.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=x):x=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let _;e[18]!==v?(_=i.jsxs("div",{className:"flex items-center gap-1.5",children:[x,i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=_):_=e[19];let b;e[20]!==c||e[21]!==r?(b=r>0&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=r,e[22]=b):b=e[22];let y;e[23]!==_||e[24]!==b||e[25]!==g?(y=i.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,_,b]}),e[23]=_,e[24]=b,e[25]=g,e[26]=y):y=e[26];let L;return e[27]!==y||e[28]!==f?(L=i.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=L):L=e[29],L}function J8(t){const e=B.c(11),{agentId:s,isError:n}=t,r=qs(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=i.jsx(Gs,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const c=n?"text-destructive":"text-foreground";let d;e[3]!==c?(d=ne("shrink-0 font-medium",c),e[3]=c,e[4]=d):d=e[4];let h;e[5]!==o||e[6]!==d?(h=i.jsx("span",{className:d,children:o}),e[5]=o,e[6]=d,e[7]=h):h=e[7];let u;return e[8]!==l||e[9]!==h?(u=i.jsxs(i.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function X8(t){const e=B.c(5),{isError:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Gs,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=n):n=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=ne("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=i.jsxs(i.Fragment,{children:[n,i.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function Q8(t){const e=B.c(18),{part:s}=t,n=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=i.jsx(X8,{isError:o}),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==o?(c=i.jsx(J8,{agentId:n,isError:o}),e[2]=n,e[3]=o,e[4]=c):c=e[4];let d;e[5]!==l||e[6]!==c?(d=i.jsx(C.Suspense,{fallback:l,children:c}),e[5]=l,e[6]=c,e[7]=d):d=e[7];let h;e[8]!==s.input?(h=s.input?.prompt&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-muted-foreground/50",children:"·"}),i.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=i.jsx("span",{className:"ml-auto shrink-0",children:r?i.jsx(qe,{size:12,className:"animate-spin text-muted-foreground"}):o?i.jsx(Px,{size:12,className:"text-destructive"}):a?i.jsx(fn,{size:12,className:"text-warning"}):i.jsx(Tl,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==h||e[16]!==u?(f=i.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,h,u]}),e[14]=d,e[15]=h,e[16]=u,e[17]=f):f=e[17],f}function Z8(t){const e=B.c(55),{onClose:s,back:n,className:r}=t,[o,a]=C.useState(null),{messages:l}=js(),{activeTask:c}=as(),{selectedModel:d,selectedVirtualMcp:h}=xs();let u,f,m,p,g,x,v,_;if(e[0]!==c||e[1]!==n||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==d||e[7]!==h?.title){_=Symbol.for("react.early_return_sentinel");e:{const L=M1(l),w=[...l].reverse().find(dL),S=w?.metadata?.usage,j=w?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,V=S?.contextTokens??0,k=j&&j>0?(V/j*100).toFixed(1):null,T=l;let A;e[16]!==T?(A=T.filter(cL).reduce(lL,0),e[16]=T,e[17]=A):A=e[17];const N=A,R=l;let I;e[18]!==R?(I=R.filter(aL).reduce(oL,0),e[18]=R,e[19]=I):I=e[19];const D=I,E=Math.max(0,L.totalTokens-N-D),P=l[0],M=l.at(-1),z=P?.metadata?.created_at??c?.created_at,$=M?.metadata?.created_at??c?.updated_at,O=l.filter(rL),U=l.flatMap(nL),H=d?.modelId?W8(d.modelId):"—",Y=h?.title??"Super Agent",G=[{label:"Session",value:c?.title??"New chat"},{label:"Messages",value:O.length},{label:"Agent",value:Y},{label:"Model",value:H},{label:"Context Limit",value:j?Lr(j):"—"},{label:"Session Tokens (billed)",value:L.totalTokens>0?Lr(L.totalTokens):"0"},{label:"Usage",value:k!==null?`${k}%`:"—"},{label:"Input Tokens",value:L.inputTokens>0?Lr(L.inputTokens):"0"},{label:"Output Tokens",value:L.outputTokens>0?Lr(L.outputTokens):"0"},{label:"Reasoning Tokens",value:L.reasoningTokens>0?Lr(L.reasoningTokens):"0"},{label:"Cost",value:L.cost>0?`$${L.cost<.001?L.cost.toFixed(6):L.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Xu(z)},{label:"Last Activity",value:Xu($)}];if(!c&&O.length===0){let F;e[20]!==r?(F=ne("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=F):F=e[21];let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=X):X=e[22];let Q;e[23]!==n?(Q=n?i.jsx(_u,{size:14,className:"text-muted-foreground"}):i.jsx(yn,{size:14,className:"text-muted-foreground"}),e[23]=n,e[24]=Q):Q=e[24];let Z;e[25]!==s||e[26]!==Q?(Z=i.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[X,i.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:Q})]}),e[25]=s,e[26]=Q,e[27]=Z):Z=e[27];let J;e[28]===Symbol.for("react.memo_cache_sentinel")?(J=i.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=J):J=e[28];let ee;e[29]!==F||e[30]!==Z?(ee=i.jsxs("div",{className:F,children:[Z,J]}),e[29]=F,e[30]=Z,e[31]=ee):ee=e[31],_=ee;break e}e[32]!==r?(x=ne("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=x):x=e[33];let K;e[34]===Symbol.for("react.memo_cache_sentinel")?(K=i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=K):K=e[34];let q;e[35]!==n?(q=n?i.jsx(_u,{size:14}):i.jsx(yn,{size:14}),e[35]=n,e[36]=q):q=e[36],e[37]!==s||e[38]!==q?(v=i.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[K,i.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:q})]}),e[37]=s,e[38]=q,e[39]=v):v=e[39],u="flex flex-col gap-8 p-6",f=U.length>0&&i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),i.jsx("div",{className:"flex flex-col gap-1",children:U.map(sL)})]}),m=i.jsx(q8,{items:G});let W;e[40]===Symbol.for("react.memo_cache_sentinel")?(W=i.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=W):W=e[40],e[41]!==D||e[42]!==E||e[43]!==N?(p=i.jsxs("div",{className:"flex flex-col gap-3",children:[W,i.jsx(Y8,{userTokens:N,assistantTokens:D,otherTokens:E})]}),e[41]=D,e[42]=E,e[43]=N,e[44]=p):p=e[44],g=O.length>0&&i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),i.jsx("div",{className:"flex flex-col gap-1",children:O.map(F=>{const X=F.metadata?.created_at,Q=o?.id===F.id;return i.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[i.jsxs("button",{type:"button",onClick:()=>a(Q?null:F),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx("span",{className:ne("shrink-0 font-medium",F.role==="user"?"text-chart-1":"text-chart-2"),children:F.role}),i.jsx("span",{className:"text-muted-foreground",children:"•"}),i.jsx("span",{className:"truncate text-muted-foreground font-mono",children:F.id})]}),X&&i.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(X).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),Q&&i.jsxs(i.Fragment,{children:[F.role==="assistant"&&(()=>{const Z=F.metadata?._request;if(!Z)return null;const J=Z.systemSections??[],ee=Math.max(1,...J.map(tL)),te=J.reduce(eL,0);return i.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-medium text-foreground",children:"Request"}),i.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[Z.activeTools??0," / ",Z.tools??0," ","tools active"]})]}),J.length>0&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",i.jsxs("span",{className:"tabular-nums",children:["~",Math.round(te/4).toLocaleString()," ","tok"]})]}),J.map((ae,se)=>{const oe=ae.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${se}`,ce=ae.chars/ee*100,fe=Math.round(ae.chars/4);return i.jsxs("div",{className:"space-y-0.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("span",{className:"font-mono text-foreground truncate",children:oe}),i.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",fe.toLocaleString()," tok"]})]}),i.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:i.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${ce}%`}})})]},se)})]})]})})(),i.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(F,null,2)})]})]},F.id)})})]})}e[0]=c,e[1]=n,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=d,e[7]=h?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v,e[15]=_}else u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14],_=e[15];if(_!==Symbol.for("react.early_return_sentinel"))return _;let b;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==g?(b=i.jsxs("div",{className:u,children:[f,m,p,g]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=g,e[50]=b):b=e[50];let y;return e[51]!==x||e[52]!==v||e[53]!==b?(y=i.jsxs("div",{className:x,children:[v,b]}),e[51]=x,e[52]=v,e[53]=b,e[54]=y):y=e[54],y}function eL(t,e){return t+e.chars}function tL(t){return t.chars}function sL(t,e){return i.jsx(Q8,{part:t},e)}function nL(t){return(t.parts??[]).filter(iL)}function iL(t){return t.type==="tool-subtask"}function rL(t){return t.role!=="system"}function oL(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function aL(t){return t.role==="assistant"}function lL(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function cL(t){return t.role==="user"}function dL(t){return t.role==="assistant"&&t.metadata?.usage}function uL(t){const e=B.c(27),{onOpenContextPanel:s}=t,{org:n}=Ae(),{selectedVirtualMcp:r}=xs(),{currentBranch:o}=as();let a;e[0]!==n.id?(a=Co(n.id),e[0]=n.id,e[1]=a):a=e[1];const c=r??a,d=qs(c.id),h=d??c,u=h.title??"Super Agent",f=h.icon??null,m=h.description??null;let p;e[2]!==f||e[3]!==u?(p=i.jsx(Hn,{icon:f,name:u,size:"lg"}),e[2]=f,e[3]=u,e[4]=p):p=e[4];let g;e[5]!==u?(g=i.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:u}),e[5]=u,e[6]=g):g=e[6];let x;e[7]!==m?(x=m?i.jsx("p",{className:"text-sm text-muted-foreground max-w-md text-balance",children:m}):null,e[7]=m,e[8]=x):x=e[8];let v;e[9]!==g||e[10]!==x?(v=i.jsxs("div",{className:"space-y-1.5",children:[g,x]}),e[9]=g,e[10]=x,e[11]=v):v=e[11];let _;e[12]!==p||e[13]!==v?(_=i.jsxs("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center gap-4 px-6 text-center overflow-hidden",children:[p,v]}),e[12]=p,e[13]=v,e[14]=_):_=e[14];let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(dt.IceBreakers,{className:"pb-3"}),e[15]=b):b=e[15];let y;e[16]!==o||e[17]!==d?(y=i.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom pb-1 flex justify-start gap-1",children:i.jsx(p2,{virtualMcp:d,currentBranch:o,showRuntimeLabel:!0})}),e[16]=o,e[17]=d,e[18]=y):y=e[18];let L;e[19]!==s?(L=i.jsx(dt.Input,{onOpenContextPanel:s}),e[19]=s,e[20]=L):L=e[20];let w;e[21]!==y||e[22]!==L?(w=i.jsxs(dt.Footer,{children:[b,y,L]}),e[21]=y,e[22]=L,e[23]=w):w=e[23];let S;return e[24]!==w||e[25]!==_?(S=i.jsxs(i.Fragment,{children:[_,w]}),e[24]=w,e[25]=_,e[26]=S):S=e[26],S}function Qu(t){const e=B.c(17),{outputs:s,collapsed:n,onToggle:r,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=ne(a),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=c):c=e[2];const d=n&&"-rotate-90";let h;e[3]!==d?(h=ne("size-4 text-muted-foreground transition-transform",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==h?(u=i.jsx(Ht,{className:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==r||e[8]!==u?(f=i.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[c,u]}),e[7]=r,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==n||e[11]!==s?(m=!n&&i.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(hL)}),e[10]=n,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=i.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function hL(t){return i.jsx(w5,{file:t},t.key)}function fL(){const t=B.c(13),e=ir()?.taskId??null,s=S5();let n;t[0]!==s?(n={enabled:s},t[0]=s,t[1]=n):n=t[1];const{data:r}=O1(e,n),[o,a]=C.useState(!1),[l,c]=C.useState(!0);if(!e||!r||r.length===0)return null;let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>a(pL),t[2]=d):d=t[2];let h;t[3]!==o||t[4]!==r?(h=i.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:i.jsx(Qu,{variant:"card",outputs:r,collapsed:o,onToggle:d})}),t[3]=o,t[4]=r,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>c(mL),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==r?(f=i.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:i.jsx(Qu,{variant:"bar",outputs:r,collapsed:l,onToggle:u})}),t[7]=l,t[8]=r,t[9]=f):f=t[9];let m;return t[10]!==h||t[11]!==f?(m=i.jsxs(i.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function mL(t){return!t}function pL(t){return!t}function gL(){const t=B.c(27),{org:e}=Ae(),{isChatEmpty:s}=js(),{openTab:n}=ko(),[r,o]=C.useState("chat"),a=D9();if(Z9()){let y;return t[0]!==n?(y=i.jsx(dt,{className:"animate-in fade-in-0 duration-200",children:i.jsx(dt.Main,{className:"flex flex-col items-center",children:i.jsx(dt.EmptyState,{children:i.jsx(dt.NoAiProviderEmptyState,{onLocalRuntimePicked:()=>n("overview")})})})}),t[0]=n,t[1]=y):y=t[1],y}let c;t[2]!==a.hasDecoKey||t[3]!==a.hasOnlyDecoProvider||t[4]!==a.isLoading||t[5]!==a.isZeroBalance||t[6]!==s||t[7]!==e?(c=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&s&&!R8(e.id),t[2]=a.hasDecoKey,t[3]=a.hasOnlyDecoProvider,t[4]=a.isLoading,t[5]=a.isZeroBalance,t[6]=s,t[7]=e,t[8]=c):c=t[8];const d=c;let h;t[9]!==d?(h=d&&i.jsx(dt.CreditsEmptyState,{}),t[9]=d,t[10]=h):h=t[10];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let f;t[11]!==u?(f=ne("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[11]=u,t[12]=f):f=t[12];let m;t[13]!==s?(m=s?i.jsx(uL,{onOpenContextPanel:()=>o("context")}):i.jsxs(i.Fragment,{children:[i.jsxs(dt.Main,{className:"relative flex flex-col overflow-hidden @container",children:[i.jsx(fL,{}),i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(dt.Messages,{})})]}),i.jsx(dt.Footer,{children:i.jsx(dt.Input,{onOpenContextPanel:()=>o("context")})})]}),t[13]=s,t[14]=m):m=t[14];let p;t[15]!==f||t[16]!==m?(p=i.jsx("div",{className:f,children:m}),t[15]=f,t[16]=m,t[17]=p):p=t[17];const g=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let x;t[18]!==g?(x=ne("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",g),t[18]=g,t[19]=x):x=t[19];let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx(Z8,{back:!0,onClose:()=>o("chat")}),t[20]=v):v=t[20];let _;t[21]!==x?(_=i.jsx("div",{className:x,children:v}),t[21]=x,t[22]=_):_=t[22];let b;return t[23]!==h||t[24]!==p||t[25]!==_?(b=i.jsxs(dt,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,p,_]}),t[23]=h,t[24]=p,t[25]=_,t[26]=b):b=t[26],b}function D2(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(dt.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(ps,{fallback:e,children:i.jsx(C.Suspense,{fallback:i.jsx(dt.Skeleton,{}),children:i.jsx(gL,{})})}),t[1]=s):s=t[1],s}function M2(t){try{const{hostname:e}=new URL(t);return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="::1"}catch{return!1}}function xL(){if(typeof document>"u")return null;const t=Array.from(document.querySelectorAll("iframe"));for(const e of t){const s=e.getAttribute("src");if(s&&M2(s))return s}return null}function vL(t){const e=t.previewUrl??t.getFallbackPreviewUrl?.()??xL();if(e&&M2(e))return new URL("/.decofile",e).toString();const s=new URLSearchParams({path:"/.decofile"});return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${s.toString()}`}function Ml(t,e){const s=B.c(8),n=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==n?(o=Qe.decofile(n),s[0]=n,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const d=await fetch(vL(t),{cache:"no-store"});if(!d.ok){const h=new Error(`Failed to fetch decofile: ${d.status}`);throw h.status=d.status,h}return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let c;return s[4]!==o||s[5]!==a||s[6]!==l?(c={queryKey:o,queryFn:a,enabled:l,staleTime:3e4,retry:bL,retryDelay:_L},s[4]=o,s[5]=a,s[6]=l,s[7]=c):c=s[7],gs(c)}function _L(t){return Pm(5e3,1e3,t,2,0)}function bL(t,e){return e.status!==502&&t<2}function Ol(t,e){const s=B.c(9),n=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}/${t.previewUrl??""}`:"",r=e?.fetchEnabled??!0,o=t?.previewUrl;let a;s[0]!==n?(a=Qe.liveMeta(n),s[0]=n,s[1]=a):a=s[1];let l;s[2]!==o?(l=async()=>{const u=new URL("/live/_meta",o).href,f=await fetch(u,{cache:"no-store"});if(!f.ok){const m=new Error(`Failed to fetch live meta: ${f.status}`);throw m.status=f.status,m}return await f.json()},s[2]=o,s[3]=l):l=s[3];const c=!!t&&!!o&&r,d=e?.refetchInterval;let h;return s[4]!==a||s[5]!==l||s[6]!==c||s[7]!==d?(h={queryKey:a,queryFn:l,enabled:c,refetchInterval:d,refetchIntervalInBackground:!1,staleTime:3e5,retry:LL,retryDelay:yL},s[4]=a,s[5]=l,s[6]=c,s[7]=d,s[8]=h):h=s[8],gs(h)}function yL(t){return Pm(5e3,1e3,t,2,0)}function LL(t,e){return e.status!==502&&t<3}function Zu(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function qr(t){return t.includes("@")}function f0(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function eh(t,e){if(t===e)return!0;const s=f0(t);return s?e===s||f0(e)===s:!1}function ed(t,e){const s=t.manifest?.blocks??{};for(const[n,r]of Object.entries(s))if(e in r)return n;return null}function O2(t,e){const s=ed(t,e);return s!==null&&s.includes("sections")}function SL(t,e){const s=ed(t,e);return s!==null&&s.includes("apps")}function wL(t,e){const s=ed(t,e);return s!==null&&s.includes("matchers")}function dn(t){return!(/\.\w+$/.test(t)||t==="__proto__"||t==="constructor")}function $l(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const td="oklch(0.7278 0.151 289)",$2="website/matchers/always.ts",Oo="website/matchers/never.ts",wi="website/flags/multivariate.ts",$o="website/flags/multivariate/section.ts";function Ji(){return{__resolveType:$2}}function vt(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())||t}const jL=12,ea=8,CL=40;function VL(t){const e=t.type;return e==="array"||Array.isArray(e)&&e.includes("array")}function kL(t,e){let s=t.items;if(!s)return!1;if(typeof s.$ref=="string"&&(s=e(s.$ref)),Array.isArray(s.anyOf)||Array.isArray(s.oneOf))return!0;const r=s.properties?.__resolveType?.enum;return Array.isArray(r)&&typeof r[0]=="string"}const NL="VideoWidget";function B2(t){return typeof btoa=="function"?btoa(t):Buffer.from(t).toString("base64")}function sd(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function nd(t){const e=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function z2(t,e){return[`site/apps/${t}/${e}.ts`,`site/apps/${t}/${e}.tsx`,`${t}/apps/${e}.ts`,`${t}/apps/${e}.tsx`]}function id(t,e){const s=e.manifest?.blocks??{};for(const l of Object.values(s))if(l[t])return l[t];const n=sd(t)??nd(t);if(n){for(const l of z2(n.vendor,n.app))for(const c of Object.values(s))if(c[l])return c[l]}const r=B2(t);for(const l of Object.values(s))if(l[r])return l[r];const o=e.schema??{};return(o.$defs??o.definitions??{})[r]?{$ref:`#/definitions/${r}`}:{}}function F2(t,e){if(SL(t,e))return!0;const s=sd(e)??nd(e);if(!s)return!1;const n=t.manifest?.blocks?.apps??{};if(z2(s.vendor,s.app).some(a=>a in n))return!0;const r=B2(e),o=t.schema?.$defs??t.schema?.definitions??{};return r in o}function U2(t){return t==="site/apps/site.ts"?!1:sd(t)!==null||nd(t)!==null}function Ln(t,e){const s=e.schema??{},n=id(t,e),r=s.$defs??s.definitions??{},o=s.root??{},a=v=>{if(v.startsWith("#/root/")){const b=v.slice(7);return o[b]??{}}const _=v.split("/").pop()??"";return r[_]??{}};let l;typeof n.$ref=="string"?l=a(n.$ref):Object.keys(n).length>0?l=n:l=s;const c=v=>typeof v.$ref=="string"?a(v.$ref):v,d=v=>{const b=c(v).properties?.type;if(b){if(typeof b.const=="string")return b.const;if(typeof b.default=="string")return b.default;if(Array.isArray(b.enum)&&typeof b.enum[0]=="string")return b.enum[0]}},h=(v,_)=>{const b=c(v);return typeof b.title=="string"&&!b.title.startsWith("#")?b.title:_},u=(v,_=new Set)=>{if(typeof v.$ref!="string"||v.properties||v.anyOf||v.allOf||v.oneOf||v.type)return v;const b=v.$ref.split("/").pop()??"";return!b||_.has(b)?v:u(a(v.$ref),new Set([..._,b]))},f=v=>{const _=v.hide;return _===!0||_==="true"},m=(v,_=new Set,b=0)=>{if(b>jL)return{};if(typeof v.$ref=="string"){const L=v.$ref.split("/").pop()??"";return _.has(L)?{}:m(a(v.$ref),new Set([..._,L]),b+1)}let y={};if(v.properties&&typeof v.properties=="object"&&(y={...y,...v.properties}),Array.isArray(v.required)){const L=Array.isArray(y.__required)?y.__required:[];y.__required=[...L,...v.required]}for(const L of["allOf","anyOf","oneOf"]){const w=v[L];if(Array.isArray(w))for(const S of w)y={...y,...m(S,_,b+1)}}return y},p=(v,_=0,b=new Set)=>{let y=v,L;if(typeof v.$ref=="string"){y=a(v.$ref);const D=v.$ref.split("/").pop()??"";L=D,D===NL&&!y.format&&(y={...y,format:"video-uri"})}y=u(y);const w=L!==void 0&&b.has(L),S=L!==void 0?new Set([...b,L]):b,j=(D,E,P,M=!0)=>!w&&(!M||P<=CL)&&E<ea?p(D,E,S):void 0;let V;{const D=y.anyOf??y.oneOf;if(Array.isArray(D)){const E=D.filter(M=>!(M.type==="null"||M.type===null)),P=M=>{if(typeof M.const=="string"||typeof M.const=="number")return M.const;if(Array.isArray(M.enum)&&M.enum.length===1&&(typeof M.enum[0]=="string"||typeof M.enum[0]=="number"))return M.enum[0]};E.length>0&&E.every(M=>P(M)!==void 0)&&(V=E.map(M=>P(M)))}}let k,T;if(y.type)k=Array.isArray(y.type)?String(y.type.find(D=>D!=="null")??y.type[0]):String(y.type);else if(y.anyOf||y.allOf||y.oneOf){const E=(y.anyOf??y.allOf??y.oneOf).filter(P=>!(P.type==="null"||P.type===null));if(E.length===0)k="null";else if(E.length===1){const P=E[0];T=P,k=P.type?Array.isArray(P.type)?String(P.type[0]):String(P.type):typeof P.$ref=="string"?"object":"string"}else{if(V)return{type:"string",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,enum:V};const P=E.filter(q=>{const W=q.properties?.__resolveType?.enum;return Array.isArray(W)&&typeof W[0]=="string"}),M=E.find(VL),z=P.some(q=>{const W=q.properties?.__resolveType?.enum;return Array.isArray(W)&&W[0]===wi});if(M){if(!kL(M,a)&&E.length>1){const W=p(M,_+1,S);return{...W,type:"array",title:typeof y.title=="string"?y.title:W.title,description:typeof y.description=="string"?y.description:W.description}}if(z){const W=p(M,_+1,S);return{...W,type:"array",title:typeof y.title=="string"?y.title:W.title,description:typeof y.description=="string"?y.description:W.description}}}if(P.length>0){const q=P.map(J=>{const te=J.properties?.__resolveType?.enum??[],ae=String(te[0]);return{resolveType:ae,title:typeof J.title=="string"?J.title:vt(ae),description:typeof J.description=="string"?J.description:void 0,schema:j(J,_+1,E.length)}}),W=[];for(const J of E){if(P.includes(J)||typeof J.$ref!="string")continue;const ee=a(J.$ref);let te;const ae=ee.properties?.__resolveType;if(Array.isArray(ae?.enum)&&typeof ae.enum[0]=="string"&&(te=ae.enum[0]),!te&&Array.isArray(ee.allOf))for(const se of ee.allOf){const oe=se.properties?.__resolveType?.enum;if(Array.isArray(oe)&&typeof oe[0]=="string"){te=oe[0];break}}te&&W.push({resolveType:te,title:typeof ee.title=="string"&&!ee.title.startsWith("#")?ee.title:vt(te),description:typeof ee.description=="string"?ee.description:void 0,schema:j(ee,_+1,E.length)})}const F=new Set(q.map(J=>J.resolveType)),X=[...q,...W.filter(J=>!F.has(J.resolveType))],Q=E.filter(J=>!P.includes(J)),Z=Q.length===1?j(Q[0],_+1,E.length):void 0;return{type:"block-ref",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,anyOfRefs:X,plainSchema:Z,hidden:f(y)||f(v)?!0:void 0}}const $=E.map(q=>d(q));if(E.length>1&&$.every(q=>typeof q=="string")){const q=E.map((W,F)=>{const X=c(W),Q=$[F];return{resolveType:Q,title:h(W,Q),description:typeof X.description=="string"?X.description:void 0,discriminatorValue:Q,schema:j(X,_+1,E.length,!1)}});return{type:"block-ref",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:void 0,description:typeof v.description=="string"?v.description:typeof y.description=="string"?y.description:void 0,discriminatorKey:"type",anyOfRefs:q,hidden:f(y)||f(v)?!0:void 0}}const U=q=>{const W=c(q);if(typeof W.title=="string"&&Zu(W.title))return!0;const F=W.properties?.__resolveType?.enum;if(Array.isArray(F)&&typeof F[0]=="string")return!0;if(Array.isArray(W.allOf))for(const X of W.allOf){const Q=X.properties?.__resolveType?.enum;if(Array.isArray(Q)&&typeof Q[0]=="string")return!0}return!1},H=q=>{if(U(q))return!1;const W=c(q);return W.type==="object"||!!W.properties},G=(Array.isArray(y.anyOf)||Array.isArray(y.oneOf))&&_<ea&&E.every(H);if(E.every(q=>typeof q.$ref=="string")&&!G){const q=[];for(const W of E){const F=a(W.$ref);let X,Q;if(typeof F.title=="string"){const J=Zu(F.title);J&&(X=J.blockId,Q=J.blockId)}if(!X&&Array.isArray(F.allOf))for(const J of F.allOf){const ae=((J.properties??{}).__resolveType??{}).enum;if(Array.isArray(ae)&&typeof ae[0]=="string"){X=ae[0];break}}if(!X){const ee=F.properties?.__resolveType?.enum;Array.isArray(ee)&&typeof ee[0]=="string"&&(X=ee[0])}X||(X=W.$ref.split("/").pop()??"");const Z=d(W);!Z&&!X.includes("/")||q.push({resolveType:Z??X,title:Q??(typeof F.title=="string"&&!F.title.startsWith("#")?F.title:vt(X)),description:typeof F.description=="string"?F.description:void 0,discriminatorValue:Z,schema:j(F,_+1,E.length)})}return{type:"block-ref",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,anyOfRefs:q,hidden:f(y)||f(v)?!0:void 0}}if(G){const q=F=>{if(typeof F.const=="string"||typeof F.const=="number"||typeof F.const=="boolean")return F.const;if(Array.isArray(F.enum)&&F.enum.length===1&&(typeof F.enum[0]=="string"||typeof F.enum[0]=="number"||typeof F.enum[0]=="boolean"))return F.enum[0]},W=E.map((F,X)=>{const Q=c(F).properties??{},Z={};for(const[J,ee]of Object.entries(Q)){const te=q(ee);te!==void 0&&(Z[J]=te)}return{title:h(F,`Option ${X+1}`),schema:p(F,_+1),discriminators:Object.keys(Z).length?Z:void 0}});return{type:"inline-union",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,inlineUnionBranches:W,hidden:f(y)||f(v)?!0:void 0}}k="object"}}else typeof v.$ref=="string"&&(k="object");let A;if(_<ea){const D=m(y),E=Object.entries(D).filter(([P])=>!P.startsWith("__")&&P!=="@type");if(E.length>0){A={};for(const[P,M]of E)A[P]=p(M,_+1,S)}}let N;if((k==="array"||y.type==="array")&&_<ea){let D=y.items;D&&(typeof D.$ref=="string"&&(D=a(D.$ref)),N=p(D,_+1,S),typeof D.title=="string"&&D.title.includes("{{")&&(N.titleBy=D.title))}const R=D=>{const E=T?.[D];return typeof E=="string"?E:void 0},I=()=>{if("default"in v)return v.default;if("default"in y)return y.default;if(T&&"default"in T)return T.default};return{type:k??"string",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:R("title"),description:typeof v.description=="string"?v.description:typeof y.description=="string"?y.description:R("description"),default:I(),enum:Array.isArray(y.enum)?y.enum:V??void 0,format:typeof y.format=="string"?y.format:R("format"),properties:A,items:N,hidden:f(y)||f(v)?!0:void 0,titleBy:typeof y.titleBy=="string"?y.titleBy:R("titleBy"),image:typeof y.image=="string"?y.image:R("image"),options:typeof y.options=="string"?y.options:R("options")}},g=m(l),x={};for(const[v,_]of Object.entries(g))v.startsWith("__")||v==="@type"||(x[v]=p(_,0));return Object.keys(x).length===0?null:{type:"object",title:typeof l.title=="string"?l.title:void 0,properties:x}}function AL(t,e){const s=e.schema??{},n=id(t,e),r=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?r[n.$ref.split("/").pop()??""]??{}:n,a=o.properties??{};if(Object.keys(a).some(d=>!d.startsWith("__")))return!1;if(o.additionalProperties===!0)return!0;const c=a.__resolveType;return!!c&&Array.isArray(c.enum)&&c.enum[0]===t}function TL(t){const e=n=>{switch(typeof n){case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(n===null)return{type:"string"};if(Array.isArray(n))return{type:"array",items:e(n[0])};const r={};for(const[o,a]of Object.entries(n))o.startsWith("__")||(r[o]=e(a));return{type:"object",properties:r}}default:return{type:"string"}}},s={};for(const[n,r]of Object.entries(t))n.startsWith("__")||(s[n]=e(r));return Object.keys(s).length===0?null:{type:"object",properties:s}}function Jn(t,e){const s=e.schema??{},n=id(t,e),r=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?r[n.$ref.split("/").pop()??""]??{}:Object.keys(n).length>0?n:{...s,...n},a=o.icon,l=o.logo,c=o,d=u=>u===!0||u==="true",h=d(c.hide)||d(c.ignore)||d(c.unlisted);return{title:typeof o.title=="string"?o.title:void 0,description:typeof o.description=="string"?o.description:void 0,icon:typeof a=="string"?a:void 0,logo:typeof l=="string"?l:void 0,hidden:h||void 0}}function EL(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([n])=>!e.includes(n)));return Object.keys(s).length>0?{...t,properties:s}:t}function RL(t,e,s){return typeof t!="string"?null:EL(Ln(t,e),s)}function H2(t,e,s){if(!e||typeof t!="string")return!1;const n=RL(t,e,s);return!!n&&Object.keys(n.properties??{}).length>0}const PL=700;function Bl(t){const e=B.c(21),{orgSlug:s,virtualMcpId:n,branch:r}=t,o=os();let a;e[0]!==r||e[1]!==s||e[2]!==n?(a=async u=>{const{blockKey:f,data:m}=u,p=Lm(f),g=JSON.stringify(m,null,2),x=await fetch(`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(r)}/write`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:p,content:g})});if(!x.ok){const v=await x.json().catch(IL);throw new Error(v.error??`Write failed (${x.status})`)}return x.json()},e[0]=r,e[1]=s,e[2]=n,e[3]=a):a=e[3];let l;e[4]!==r||e[5]!==s||e[6]!==o||e[7]!==n?(l=async u=>{const{blockKey:f,data:m}=u,p=`${s}/${n}/${r}`,g=Qe.decofile(p);await o.cancelQueries({queryKey:g});const x=o.getQueryData(g);return o.setQueryData(g,v=>({...v??{},[f]:m})),{previous:x,queryKey:g}},e[4]=r,e[5]=s,e[6]=o,e[7]=n,e[8]=l):l=e[8];let c;e[9]!==o?(c=(u,f,m)=>{m?.queryKey&&o.setQueryData(m.queryKey,m.previous)},e[9]=o,e[10]=c):c=e[10];let d;e[11]!==r||e[12]!==s||e[13]!==o||e[14]!==n?(d=(u,f)=>{const{blockKey:m,data:p}=f,g=`${s}/${n}/${r}`;o.setQueryData(Qe.decofile(g),x=>({...x??{},[m]:p}))},e[11]=r,e[12]=s,e[13]=o,e[14]=n,e[15]=d):d=e[15];let h;return e[16]!==a||e[17]!==l||e[18]!==c||e[19]!==d?(h={mutationFn:a,onMutate:l,onError:c,onSuccess:d},e[16]=a,e[17]=l,e[18]=c,e[19]=d,e[20]=h):h=e[20],Ds(h)}function IL(){return{}}function K2(t,e){const s=B.c(15),n=Bl(t);let r;s[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Map,s[0]=r):r=s[0];const o=C.useRef(r);let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,s[1]=a):a=s[1];const l=C.useRef(a);let c;s[2]!==e||s[3]!==n?(c=v=>{const _=o.current.get(v);if(!_)return;const b=typeof _=="function"?_():_;o.current.delete(v),b&&n.mutate({blockKey:v,data:b},{onSuccess:()=>e?.onSaved?.(),onError:DL})},s[2]=e,s[3]=n,s[4]=c):c=s[4];const d=c;let h;s[5]!==d?(h=()=>{for(const v of l.current.values())clearTimeout(v);l.current.clear();for(const v of[...o.current.keys()])d(v)},s[5]=d,s[6]=h):h=s[6];const u=h;let f,m;s[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const v=l.current;return()=>{for(const _ of v.values())clearTimeout(_)}},m=[],s[7]=f,s[8]=m):(f=s[7],m=s[8]),C.useEffect(f,m);let p;s[9]!==d?(p=(v,_)=>{o.current.set(v,_);const b=l.current.get(v);b&&clearTimeout(b),l.current.set(v,setTimeout(()=>{l.current.delete(v),d(v)},PL))},s[9]=d,s[10]=p):p=s[10];const g=p;let x;return s[11]!==u||s[12]!==g||s[13]!==n.isPending?(x={save:g,flush:u,isPending:n.isPending},s[11]=u,s[12]=g,s[13]=n.isPending,s[14]=x):x=s[14],x}function DL(t){return de.error(`Save failed: ${t.message}`)}function ML({orgSlug:t,virtualMcpId:e,branch:s}){const n=os();return Ds({mutationFn:async({blockKey:r})=>{const o=Lm(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=Qe.decofile(o);await n.cancelQueries({queryKey:a});const l=n.getQueryData(a);return n.setQueryData(a,c=>{if(!c)return c;const{[r]:d,...h}=c;return h}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&n.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;n.invalidateQueries({queryKey:Qe.liveMeta(r)})}})}function ai(t){return t.replace(/\/+$/,"")||"/"}function OL(t){const e=t.trim();return!(!e.startsWith("/")||e.startsWith("//")||e.includes("..")||e.includes("\\"))}function rd(t){const e=t.trim();return e?OL(e)?null:"Path must start with / and must not contain .. or //.":"Path is required."}const W2=/:([A-Za-z0-9_-]+)|\*/g;function m0(t){const e=[];let s=0;for(const n of t.matchAll(W2))n.index>s&&e.push({type:"text",text:t.slice(s,n.index)}),e.push({type:"param",name:n[1]??"*"}),s=n.index+n[0].length;return s<t.length&&e.push({type:"text",text:t.slice(s)}),e}function Sr(t,e){return t.replace(W2,(s,n)=>{const r=e[n??"*"]?.trim();return r?n!==void 0?encodeURIComponent(r):r.split("/").filter(Boolean).map(encodeURIComponent).join("/")||s:s})}const $L=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"],th="website/sections/Rendering/Lazy.tsx";function ss(t){return $L.some(e=>t.endsWith(e))}const q2=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],G2=new Set(q2),BL=new Set(["site/sections/Theme/Theme.tsx"]);function zl(t){return!!(BL.has(t)||ss(t)||t.toLowerCase().includes("preview"))}function p0(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const n of Object.keys(s))if(G2.has(n))return n;return q2[0]}function g0(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return g0(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(...g0(s));return e}return[]}function zL(t){const e=t.manifest?.blocks??{},s=[];for(const[n,r]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(r)){if(zl(o))continue;const a=Jn(o,t);s.push({resolveType:o,title:a.title??vt(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function FL(t){const e=t.manifest?.blocks??{},s=[];for(const[n,r]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(r))zl(o)||s.push({resolveType:o,title:vt(o)});return s.sort((n,r)=>n.title.localeCompare(r.title))}function Y2(t,e){const s=[];for(const[n,r]of Object.entries(e)){if(n.includes("/")||$l(n)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(G2.has(a)||typeof o.path!="string"&&(zl(a)||O2(t,a)&&s.push({resolveType:n,title:n,description:typeof o.name=="string"?o.name:void 0,previewBlock:n,isSavedBlock:!0})))}return s}function UL(t,e){const s=dn(e.resolveType),n=s?{}:Jn(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||n.title||vt(e.resolveType),description:e.description??n.description,previewBlock:e.resolveType,isSavedBlock:s}}function Hz(t,e){const s=p0(t),n=Ln(s,t),r=g0(n?.properties?.sections),o=new Map,a=l=>{if(!zl(l.resolveType)){if(dn(l.resolveType)){$l(l.resolveType)||o.set(l.resolveType,l);return}O2(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of zL(t))a(l);for(const l of r)a(UL(t,l));for(const l of Y2(t,e))a(l);return[...o.values()].sort((l,c)=>l.title.localeCompare(c.title))}function Kz(t){const e=t.site;if(!e||typeof e!="object"||Array.isArray(e))return;const s=e.theme;if(!(!s||typeof s!="object"||Array.isArray(s)))return s}function HL(t){let e=t;e.startsWith("pages-")&&(e=e.slice(6)),e=e.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,""),e=e.replace(/-[0-9a-f]{8,}$/i,"");try{return decodeURIComponent(e)}catch{return e}}function KL(t,e,s){const n=ai;if(s){const o=t.find(a=>a.key===s);if(o)return o}const r=t.filter(o=>n(o.path)===n(e));return r.length===0?null:r.length===1?r[0]??null:[...r].sort((o,a)=>o.key.localeCompare(a.key))[0]??null}const J2=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]),Mr="site",od="site/apps/site.ts";function sl(t,e){return t===Mr?!0:e.__resolveType===od}function ad(t,e){return t?ld(t).length>0?!0:e?cd(t,e).length>0||x0(t,e)?!0:WL(t,e).length>0:!1:!1}function ld(t){const e=[];for(const[s,n]of Object.entries(t))if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n;typeof r.__resolveType=="string"&&J2.has(r.__resolveType)&&typeof r.path=="string"&&e.push({key:s,name:typeof r.name=="string"?r.name:HL(s),path:r.path})}return e}function Fl(t,e){if(typeof e.name=="string"){const s=e.name.trim();if(s)return s}return t.replace(/[-_]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function nl(t,e,s){const n=typeof e.__resolveType=="string"?e.__resolveType:"",r=n?Jn(n,s):{};if(r.title)return r.title;if(typeof e.name=="string"){const o=e.name.trim();if(o)return o}return t.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase())}function x0(t,e){const s=t[Mr];if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s,r=n.__resolveType;if(typeof r=="string"&&(sl(Mr,n)||F2(e,r)))return{key:Mr,name:nl(Mr,n,e),resolveType:r}}for(const[n,r]of Object.entries(t)){if(n.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r;if(!sl(n,o))continue;const a=typeof o.__resolveType=="string"?o.__resolveType:od;return{key:n,name:nl(n,o,e),resolveType:a}}return null}function WL(t,e){const s=[];for(const[n,r]of Object.entries(t)){if(n.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(J2.has(a)||typeof o.path!="string"&&(sl(n,o)||!F2(e,a)&&!U2(a)||s.push({key:n,name:nl(n,o,e),resolveType:a})))}return s.sort((n,r)=>n.name.localeCompare(r.name))}function cd(t,e){return Y2(e,t).map(s=>{const n=t[s.resolveType],r=typeof n.__resolveType=="string"?n.__resolveType:"";return{key:s.resolveType,name:s.description??Fl(s.resolveType,n),resolveType:r}}).sort((s,n)=>s.name.localeCompare(n.name))}function Ul(t,e){return`${t}-${e}`}function X2(t,e){return`site/apps/${t}/${e}.ts`}function Q2(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);if(e)return{vendor:e[1],app:e[2]};const s=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return s?{vendor:s[1],app:s[2]}:null}function qL(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function GL(t){return t==="local"?"Custom":"Installed"}function Z2(t,e,s){const n=new Set([Ul(t,e),e].map(o=>o.toLowerCase())),r=X2(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(n.has(o.toLowerCase())||l.__resolveType===r)return o}return null}function YL(t,e){const s=t.vendor.alias,n=t.name,r=Z2(s,n,e);return{id:Ul(s,n),app:n,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:X2(s,n),blockKey:r,installed:r!==null}}function JL(t,e,s){if(t===od)return null;const n=Q2(t);if(!n)return null;const{vendor:r,app:o}=n,a=Z2(r,o,s),l=Jn(t,e);return{id:Ul(r,o),app:o,vendor:r,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function XL(t,e,s){const n=e.__resolveType;if(typeof n!="string"||sl(t,e)||!U2(n))return null;const r=Q2(n)??qL(t);if(!r)return null;const o=Jn(n,s),{vendor:a,app:l}=r;return{id:Ul(a,l),app:l,vendor:a,title:o.title??nl(t,e,s),description:o.description??"",category:GL(a),logo:o.logo??o.icon,resolveType:n,blockKey:t,installed:!0}}function QL(t,e,s){const n=new Map;for(const o of t){const a=YL(o,s);n.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=JL(o,e,s);!a||n.has(a.id)||n.set(a.id,a)}for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=XL(o,a,e);!l||n.has(l.id)||n.set(l.id,l)}return[...n.values()].sort(ZL)}function ZL(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function e7(){const t=await fetch("/api/deco-apps");if(!t.ok)throw new Error(`Failed to fetch deco apps: ${t.status}`);return(await t.json()).apps??[]}function t7(t,e,s){const n=B.c(12),r=s?.enabled??!0;let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=Qe.decoApps(),n[0]=o):o=n[0];let a;n[1]!==r?(a={queryKey:o,queryFn:e7,staleTime:3e5,retry:1,enabled:r},n[1]=r,n[2]=a):a=n[2];const l=gs(a);let c;n[3]!==e||n[4]!==t||n[5]!==l.data?(c=t&&e?QL(l.data??[],t,e):[],n[3]=e,n[4]=t,n[5]=l.data,n[6]=c):c=n[6];const d=c,h=l.isLoading&&!l.isError;let u;return n[7]!==d||n[8]!==l.isError||n[9]!==l.refetch||n[10]!==h?(u={catalog:d,isLoading:h,isError:l.isError,refetch:l.refetch},n[7]=d,n[8]=l.isError,n[9]=l.refetch,n[10]=h,n[11]=u):u=n[11],u}const s7=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function n7(t){return t.includes("matchers")||t.includes("Match")}function ep(t,e){const s=t.__resolveType;return typeof s!="string"||!s||s7.has(s)?!1:e?wL(e,s):n7(s)}function i7(t,e){const s=[];for(const[n,r]of Object.entries(e)){if(n.includes("/")||!dn(n)||$l(n)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r;ep(o,t)&&s.push({blockKey:n,matcherResolveType:o.__resolveType??"",name:typeof o.name=="string"?o.name:void 0})}return s.sort((n,r)=>(n.name??n.blockKey).localeCompare(r.name??r.blockKey))}function Bo(t,e,s){if(!t)return!1;const n=t.__resolveType;if(typeof n!="string"||!dn(n)||!Object.hasOwn(e,n))return!1;const r=e[n];return!r||typeof r!="object"||Array.isArray(r)?!1:ep(r,s)}function Wz(t,e,s){return Bo(t,e,s)?t?.__resolveType??null:null}function tp(t,e,s){if(!t)return null;const n=t.__resolveType??"";if(!n)return null;if(Bo(t,e,s)){const a=e[n]??{},l=a.__resolveType??n,{__resolveType:c,name:d,...h}=a;return{resolveType:l,data:h,blockKey:n}}const{__resolveType:r,...o}=t;return{resolveType:n,data:o}}function sp(t,e,s){const n=tp(t,e,s);return n?{__resolveType:n.resolveType,...n.data}:{__resolveType:""}}function qz(t,e,s){if(t)return Bo(t,e,s)?sp(t,e,s):t}function r7(t,e,s,n){if(!t)return"Default";if(Bo(t,e,n)){const r=t.__resolveType??"",o=e[r];return Fl(r,o)}return s(t)}function Gz(t,e,s){return{__resolveType:t,...e,name:s}}function o7(t){return{__resolveType:t}}function Yz(t,e,s){const n=tp(t,e,s);return n?{resolveType:n.resolveType,formValue:n.data}:{resolveType:"",formValue:{}}}function np(t){const e=t.__resolveType??"";return ss(e)?t.section??t:t}function il(t){const r=(ss(t.__resolveType??"")?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==Oo?null:r?.value??null}function Jz(t){const e=np(t);return{__resolveType:$o,variants:[{value:e,rule:{__resolveType:Oo}}]}}function Xz(t){const e=t.__resolveType??"";if(!e)return null;if(ss(e))return t.section??null;const s=il(t);return s?ss(s.__resolveType??"")?s:{__resolveType:th,section:np(s)}:{__resolveType:th,section:t}}function ta(t){const e=t.__resolveType??"";if(!e)return null;if(ss(e)){const s=t.section,n=s?.__resolveType??"";return!n||!s?null:{resolveType:n,data:s}}return{resolveType:e,data:t}}function Qz(t){const e=il(t);if(e)return ta(e);if(ss(t.__resolveType??"")){const n=t.section;if(!n)return null;const r=il(n);return ta(r||n)}return ta(t)}function Zz(t){return il(t)}const a7=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function dd(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:a7.includes(e)||e.includes("always")}function l7(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(n=>dd(n.rule));return s!==-1?s:e.length-1}function eF(t,e,s){const n=s.variants??[];if(n.length===0)return null;const r=l7(s),o=n[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function ip(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function tF(t,e){return Array.isArray(t.variants)?t.variants.map((s,n)=>({label:e(s.rule)||`Variant ${n+1}`,value:s.value??{},rule:s.rule})):[]}function sF(t,e){const s=t.__resolveType??"";if(!s)return null;if(ss(s)){const n=t.section??t,r=n.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...n},resolveType:r}}if(!s.includes("/")&&s in e){const n=e[s]??{};return{data:{...n},resolveType:n.__resolveType??s}}return{data:{...t},resolveType:s}}function c7(t,e){const s=t.__resolveType??"";return ss(s)?{...t,section:e}:e}function d7(t,e,s){return e.isLazy?{...t,section:s}:s}function nF(t,e,s){const n=[...t.variants??[]],r=n[e];if(!r)return t;const o=r.value??{};return n[e]={...r,value:c7(o,s)},{...t,variants:n}}function iF(t,e,s){const n=[...t.variants??[]];return n[e]?(n[e]={...n[e],rule:s},{...t,variants:n}):t}function rF(t,e){const s=[...t.variants??[]],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function oF(t,e,s){const n=[...t.variants??[]];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[r]=n.splice(e,1);return r?(n.splice(s,0,r),{...t,variants:n}):t}function aF(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}function v0(t){return{rule:Ji(),value:structuredClone(t)}}function rp(t,e){return{...e,__resolveType:$o,variants:t}}function lF(t){return t.isHidden!==!0&&t.isSavedBlock!==!0}function u7(t,e){if(e.isHidden)return null;if(e.isMultivariate){const n=ip(t,e)?.variants??[],r=n[n.length-1]?.value;return r?structuredClone(r):null}if(e.isLazy){const s=t.section;return s?structuredClone(s):null}return structuredClone(t)}function h7(t,e,s){if(e.isMultivariate||e.isHidden)return null;const n=u7(t,e);if(!n)return null;const r=rp([v0(n),v0(n)]);return e.isLazy?{...t,section:r}:r}function cF(t,e,s){if(e.isHidden||e.isSavedBlock)return null;if(e.isMultivariate){const r=ip(t,e);if(!r)return null;const o=r.variants??[],a=o[o.length-1]?.value;if(!a)return null;const l=rp([...o,v0(a)],r);return{section:d7(t,e,l),newVariantIndex:o.length}}const n=h7(t,e);return n?{section:n,newVariantIndex:1}:null}const f7=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function Hl(t){return t.anyOfRefs?.some(e=>e.resolveType!==wi?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function rl(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===wi}function m7(t){if(!rl(t))return null;const e=t.variants;if(!Array.isArray(e))return null;const s=e[0]?.value;return Array.isArray(s)?s:null}function p7(t,e){if(!rl(t))return e;const s=structuredClone(t),n=[...s.variants??[]];return n.length===0?n.push({rule:Ji(),value:e}):n[0]={...n[0],value:e},{...s,variants:n}}function g7(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&f7.has(e.__resolveType)&&typeof e.path=="string"}function op(t,e){const n=t[e]?.sections;if(!n||Array.isArray(n))return 1;const r=n;return Array.isArray(r.variants)?r.variants.length:1}function x7(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function dF(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const n=t;if(Array.isArray(n.variants)){const r=n.variants,o=r.map(c=>r7(c.rule,e,s)),a=o.reduce((c,d)=>(c[d]=(c[d]??0)+1,c),{}),l={};return r.map((c,d)=>{const h=o[d]??`Variant ${d+1}`,u=a[h]??1;let f=h;return u>1&&(l[h]=(l[h]??0)+1,f=`${h} ${l[h]}`),{label:f||`Variant ${d+1}`,sections:Array.isArray(c.value)?c.value:[],rule:c.rule}})}}return[]}function wr(t){return{rule:Ji(),value:t}}function Oi(t,e){return{...e,__resolveType:wi,variants:t}}function v7(t,e){const s=structuredClone(e);if(Array.isArray(t))return Oi([wr(t),wr(s)]);if(t&&typeof t=="object"){const n=t;return Array.isArray(n.variants)?Oi([...n.variants,wr(s)],n):null}return Oi([wr([]),wr(s)])}function uF(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function hF(t,e){const s=t[e];if(!s)return null;const n=[...t];return n.splice(e+1,0,structuredClone(s)),n}function fF(t,e){if(e.length===0)return Oi([],t);if(e.length===1){const s=e[0],n=s?.rule;if(!dd(n))return Oi(e,t);if(Array.isArray(s?.value))return s.value}return Oi(e,t)}function _7(t,e){for(const[s,n]of Object.entries(t)){if(!g7(n))continue;const r=n.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function mF(t,e,s){let n=0;return _7(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Bo(r,t,s)&&n++}),n}function pF(t,e,s,n,r){const o={...t[e]};if(r.length>1){const a=o.sections,l=[...a?.variants??[]];l[n]&&(l[n]={...l[n],value:s}),o.sections={...a,variants:l}}else o.sections=s;return o}function gF(t){return structuredClone(t)}function xF(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function ap(t){const e=t.replace(/[^A-Za-z0-9_ -]/g,"").replace(/\s+/g," ").trim();return/^[A-Za-z]/.test(e)?e:e?`Block ${e}`:""}function ud(t,e){const s=t.trim();return s?s.includes("/")?"Block name cannot contain slashes.":Object.hasOwn(e,s)?"A block with this name already exists.":/^[A-Za-z][A-Za-z0-9_ -]*$/.test(s)?null:"Use letters, numbers, spaces, hyphens, or underscores. Must start with a letter.":"Block name is required."}function lp(t){return(e,s)=>{Jx(e),t(e,s)}}var b7=j5.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(s=>e.updateAttributes(s,{textAlign:t})).some(s=>s):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:s})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?s.unsetTextAlign():s.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),y7=b7;const L7=new Set(["http:","https:","mailto:","tel:","ftp:"]);function S7(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return L7.has(e.protocol)}catch{return!1}}function _s(t){const e=B.c(8),{active:s,label:n,onClick:r,children:o}=t,a=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let l;e[0]!==a?(l=ne("flex h-7 w-7 items-center justify-center rounded transition-colors cursor-pointer",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==s||e[3]!==o||e[4]!==n||e[5]!==r||e[6]!==l?(c=i.jsx("button",{type:"button","aria-label":n,"aria-pressed":s,onMouseDown:w7,onClick:r,className:l,children:o}),e[2]=s,e[3]=o,e[4]=n,e[5]=r,e[6]=l,e[7]=c):c=e[7],c}function w7(t){return t.preventDefault()}function j7({schema:t,value:e,onChange:s,path:n,label:r}){const o=typeof e=="string"?e:"",a=C.useRef(s);a.current=s;const l=P1({extensions:[I1.configure({heading:{levels:[1,2,3]}}),y7.configure({types:["heading","paragraph"]})],content:o||"",editorProps:{attributes:{class:ne("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:c})=>{const d=c.getHTML();a.current(d==="<p></p>"?"":d)}});return l?i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(Xe,{htmlFor:n,children:r}),t.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),i.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border/60 bg-muted/30 px-1.5 py-1",children:[i.jsx(_s,{active:l.isActive("bold"),label:"Bold",onClick:()=>l.chain().focus().toggleBold().run(),children:i.jsx(ex,{size:14})}),i.jsx(_s,{active:l.isActive("italic"),label:"Italic",onClick:()=>l.chain().focus().toggleItalic().run(),children:i.jsx(tx,{size:14})}),i.jsx(_s,{active:l.isActive("underline"),label:"Underline",onClick:()=>l.chain().focus().toggleUnderline().run(),children:i.jsx(sx,{size:14})}),i.jsx(_s,{active:l.isActive("strike"),label:"Strikethrough",onClick:()=>l.chain().focus().toggleStrike().run(),children:i.jsx(nx,{size:14})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(_s,{active:l.isActive("heading",{level:1}),label:"Heading 1",onClick:()=>l.chain().focus().toggleHeading({level:1}).run(),children:i.jsx(ix,{size:14})}),i.jsx(_s,{active:l.isActive("heading",{level:2}),label:"Heading 2",onClick:()=>l.chain().focus().toggleHeading({level:2}).run(),children:i.jsx(rx,{size:14})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(_s,{active:l.isActive("bulletList"),label:"Bullet list",onClick:()=>l.chain().focus().toggleBulletList().run(),children:i.jsx(d6,{size:14})}),i.jsx(_s,{active:l.isActive("orderedList"),label:"Ordered list",onClick:()=>l.chain().focus().toggleOrderedList().run(),children:i.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(_s,{active:l.isActive("link"),label:"Link",onClick:()=>{const c=l.getAttributes("link").href,d=window.prompt("Link URL",c??"https://");d!==null&&(d===""?l.chain().focus().unsetLink().run():S7(d)&&l.chain().focus().setLink({href:d}).run())},children:i.jsx(hm,{size:14})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(_s,{active:l.isActive({textAlign:"left"}),label:"Align left",onClick:()=>l.chain().focus().setTextAlign("left").run(),children:i.jsx(J5,{size:14})}),i.jsx(_s,{active:l.isActive({textAlign:"center"}),label:"Align center",onClick:()=>l.chain().focus().setTextAlign("center").run(),children:i.jsx(ox,{size:14})}),i.jsx(_s,{active:l.isActive({textAlign:"right"}),label:"Align right",onClick:()=>l.chain().focus().setTextAlign("right").run(),children:i.jsx(ax,{size:14})}),i.jsx(_s,{active:l.isActive({textAlign:"justify"}),label:"Justify",onClick:()=>l.chain().focus().setTextAlign("justify").run(),children:i.jsx(lx,{size:14})})]}),i.jsx(D1,{editor:l})]})]}):null}const Pi=t=>String(t).padStart(2,"0"),C7="1900-01-01",V7="2099-12-31",k7="1900-01-01T00:00",N7="2099-12-31T23:59";function A7(t){if(!t)return"";const e=t.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;const s=new Date(t);return Number.isNaN(s.getTime())?"":`${s.getUTCFullYear()}-${Pi(s.getUTCMonth()+1)}-${Pi(s.getUTCDate())}`}function T7(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function E7(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${Pi(e.getMonth()+1)}-${Pi(e.getDate())}T${Pi(e.getHours())}:${Pi(e.getMinutes())}`}function R7(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function P7(t){const e=B.c(29),{id:s,withTime:n,value:r,onChange:o}=t,[a,l]=C.useState(!1);let c;e[0]!==r||e[1]!==n?(c=n?E7(r):A7(r),e[0]=r,e[1]=n,e[2]=c):c=e[2];const d=c;let h;e[3]!==o||e[4]!==n?(h=V=>{o(n?R7(V.target.value):T7(V.target.value))},e[3]=o,e[4]=n,e[5]=h):h=e[5];const u=h;let f;if(e[6]!==r){const V=r?new Date(r):null;f=V&&!Number.isNaN(V.getTime())?V:null,e[6]=r,e[7]=f}else f=e[7];const m=f;let p;e[8]!==o||e[9]!==m||e[10]!==n?(p=V=>{V&&(n&&m?V.setHours(m.getHours(),m.getMinutes(),0,0):V.setHours(0,0,0,0),o(V.toISOString()),l(!1))},e[8]=o,e[9]=m,e[10]=n,e[11]=p):p=e[11];const g=p,x=n?"datetime-local":"date",v=n?k7:C7,_=n?N7:V7;let b;e[12]!==u||e[13]!==s||e[14]!==d||e[15]!==x||e[16]!==v||e[17]!==_?(b=i.jsx(Ye,{id:s,type:x,min:v,max:_,value:d,onChange:u,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[12]=u,e[13]=s,e[14]=d,e[15]=x,e[16]=v,e[17]=_,e[18]=b):b=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Cs,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":"Open calendar",children:i.jsx(wm,{className:"h-4 w-4"})})}),e[19]=y):y=e[19];const L=m??void 0;let w;e[20]!==g||e[21]!==L?(w=i.jsx(Vs,{className:"w-auto p-0",align:"end",children:i.jsx(c6,{mode:"single",selected:L,onSelect:g,initialFocus:!0})}),e[20]=g,e[21]=L,e[22]=w):w=e[22];let S;e[23]!==a||e[24]!==w?(S=i.jsxs(ks,{open:a,onOpenChange:l,children:[y,w]}),e[23]=a,e[24]=w,e[25]=S):S=e[25];let j;return e[26]!==S||e[27]!==b?(j=i.jsxs("div",{className:"flex gap-1",children:[b,S]}),e[26]=S,e[27]=b,e[28]=j):j=e[28],j}function sa(t){const e=B.c(8),{htmlFor:s,label:n,description:r}=t;let o;e[0]!==s||e[1]!==n?(o=i.jsx(Xe,{htmlFor:s,children:n}),e[0]=s,e[1]=n,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=i.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function na(t){const e=B.c(67),{schema:s,value:n,onChange:r,path:o,label:a}=t,l=typeof n=="string"?n:"",c=s.format;if(c==="rich-text"||c==="rich-text-inline"||c==="html"){let g;return e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==n?(g=i.jsx(j7,{schema:s,value:n,onChange:r,path:o,label:a}),e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=n,e[5]=g):g=e[5],g}if(c==="textarea"||c==="markdown"){let g;e[6]!==a||e[7]!==o||e[8]!==s.description?(g=i.jsx(sa,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=g):g=e[9];let x;e[10]!==r?(x=b=>r(b.target.value),e[10]=r,e[11]=x):x=e[11];let v;e[12]!==o||e[13]!==l||e[14]!==x?(v=i.jsx(Yi,{id:o,value:l,onChange:x,rows:4}),e[12]=o,e[13]=l,e[14]=x,e[15]=v):v=e[15];let _;return e[16]!==g||e[17]!==v?(_=i.jsxs("div",{className:"space-y-2",children:[g,v]}),e[16]=g,e[17]=v,e[18]=_):_=e[18],_}if(c==="date"||c==="date-time"){let g;e[19]!==a||e[20]!==o||e[21]!==s.description?(g=i.jsx(sa,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=g):g=e[22];const x=c==="date-time";let v;e[23]!==r||e[24]!==o||e[25]!==l||e[26]!==x?(v=i.jsx(P7,{id:o,withTime:x,value:l,onChange:r}),e[23]=r,e[24]=o,e[25]=l,e[26]=x,e[27]=v):v=e[27];let _;return e[28]!==g||e[29]!==v?(_=i.jsxs("div",{className:"space-y-2",children:[g,v]}),e[28]=g,e[29]=v,e[30]=_):_=e[30],_}if(c==="color-input"||c==="color"){let g;e[31]!==a||e[32]!==o||e[33]!==s.description?(g=i.jsx(sa,{htmlFor:o,label:a,description:s.description}),e[31]=a,e[32]=o,e[33]=s.description,e[34]=g):g=e[34];const x=l||"#000000";let v;e[35]!==r?(v=S=>r(S.target.value),e[35]=r,e[36]=v):v=e[36];let _;e[37]!==x||e[38]!==v?(_=i.jsx("input",{type:"color",value:x,onChange:v,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[37]=x,e[38]=v,e[39]=_):_=e[39];let b;e[40]!==r?(b=S=>r(S.target.value),e[40]=r,e[41]=b):b=e[41];let y;e[42]!==o||e[43]!==l||e[44]!==b?(y=i.jsx(Ye,{id:o,value:l,onChange:b,placeholder:"#000000",className:"h-10 flex-1"}),e[42]=o,e[43]=l,e[44]=b,e[45]=y):y=e[45];let L;e[46]!==_||e[47]!==y?(L=i.jsxs("div",{className:"flex items-center gap-2",children:[_,y]}),e[46]=_,e[47]=y,e[48]=L):L=e[48];let w;return e[49]!==g||e[50]!==L?(w=i.jsxs("div",{className:"space-y-2",children:[g,L]}),e[49]=g,e[50]=L,e[51]=w):w=e[51],w}let d;e[52]!==a||e[53]!==o||e[54]!==s.description?(d=i.jsx(sa,{htmlFor:o,label:a,description:s.description}),e[52]=a,e[53]=o,e[54]=s.description,e[55]=d):d=e[55];const h=c==="url"?"url":"text";let u;e[56]!==r?(u=g=>r(g.target.value),e[56]=r,e[57]=u):u=e[57];const f=s.default!=null?String(s.default):void 0;let m;e[58]!==o||e[59]!==l||e[60]!==h||e[61]!==u||e[62]!==f?(m=i.jsx(Ye,{id:o,type:h,value:l,onChange:u,placeholder:f,className:"h-10"}),e[58]=o,e[59]=l,e[60]=h,e[61]=u,e[62]=f,e[63]=m):m=e[63];let p;return e[64]!==d||e[65]!==m?(p=i.jsxs("div",{className:"space-y-2",children:[d,m]}),e[64]=d,e[65]=m,e[66]=p):p=e[66],p}const I7=/^[+-]?\d*\.?\d*(?:[eE][+-]?\d*)?$/;function D7(t){const e=B.c(18),{schema:s,value:n,onChange:r,path:o,label:a}=t,l=typeof n=="number"?String(n):"",[c,d]=C.useState(l),[h,u]=C.useState(l);l!==h&&(u(l),c!==""&&l!==""&&Number(c)===Number(l)||d(l));let f;e[0]!==a||e[1]!==o?(f=i.jsx(Xe,{htmlFor:o,children:a}),e[0]=a,e[1]=o,e[2]=f):f=e[2];let m;e[3]!==s.description?(m=s.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=m):m=e[4];let p;e[5]!==f||e[6]!==m?(p=i.jsxs("div",{className:"space-y-0.5",children:[f,m]}),e[5]=f,e[6]=m,e[7]=p):p=e[7];const g=s.type==="integer"?"numeric":"decimal";let x;e[8]!==r?(x=b=>{const y=b.target.value;if(y!==""&&!I7.test(y))return;d(y);const L=Number(y);r(y===""||Number.isNaN(L)?void 0:L)},e[8]=r,e[9]=x):x=e[9];let v;e[10]!==o||e[11]!==c||e[12]!==g||e[13]!==x?(v=i.jsx(Ye,{id:o,type:"text",inputMode:g,value:c,onChange:x,className:"h-10"}),e[10]=o,e[11]=c,e[12]=g,e[13]=x,e[14]=v):v=e[14];let _;return e[15]!==p||e[16]!==v?(_=i.jsxs("div",{className:"space-y-2",children:[p,v]}),e[15]=p,e[16]=v,e[17]=_):_=e[17],_}function M7(t){const e=B.c(17),{value:s,onChange:n,path:r,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let c;e[0]!==o||e[1]!==r?(c=i.jsx(Xe,{htmlFor:r,children:o}),e[0]=o,e[1]=r,e[2]=c):c=e[2];let d;e[3]!==a.description?(d=a.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a.description}),e[3]=a.description,e[4]=d):d=e[4];let h;e[5]!==c||e[6]!==d?(h=i.jsxs("div",{className:"space-y-0.5",children:[c,d]}),e[5]=c,e[6]=d,e[7]=h):h=e[7];let u;e[8]!==n?(u=p=>n(p),e[8]=n,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==r||e[12]!==u?(f=i.jsx(ho,{id:r,checked:l,onCheckedChange:u}),e[10]=l,e[11]=r,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}const hd="__enum_empty__";function fd(t){return t===""?hd:String(t)}function O7(t,e){if(t===hd)return"";const s=e.find(n=>fd(n)===t);return s!==void 0?s:t}function $7(t,e){return t==null?e.some(s=>s==="")?hd:void 0:fd(t)}function B7(t){return t===""?"":String(t)}function z7(t){const e=B.c(28),{schema:s,value:n,onChange:r,path:o,label:a}=t;let l;e[0]!==s.enum?(l=s.enum??[],e[0]=s.enum,e[1]=l):l=e[1];const c=l;let d;e[2]!==c||e[3]!==n?(d=$7(n,c),e[2]=c,e[3]=n,e[4]=d):d=e[4];const h=d;let u;e[5]!==a||e[6]!==o?(u=i.jsx(Xe,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=u):u=e[7];let f;e[8]!==s.description?(f=s.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=f):f=e[9];let m;e[10]!==u||e[11]!==f?(m=i.jsxs("div",{className:"space-y-0.5",children:[u,f]}),e[10]=u,e[11]=f,e[12]=m):m=e[12];let p;e[13]!==r||e[14]!==c?(p=y=>r(O7(y,c)),e[13]=r,e[14]=c,e[15]=p):p=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(zt,{className:"h-10",children:i.jsx(Gt,{placeholder:"Select..."})}),e[16]=g):g=e[16];let x;e[17]!==c?(x=c.map(F7),e[17]=c,e[18]=x):x=e[18];let v;e[19]!==x?(v=i.jsx($t,{children:x}),e[19]=x,e[20]=v):v=e[20];let _;e[21]!==h||e[22]!==p||e[23]!==v?(_=i.jsxs(Bt,{value:h,onValueChange:p,children:[g,v]}),e[21]=h,e[22]=p,e[23]=v,e[24]=_):_=e[24];let b;return e[25]!==_||e[26]!==m?(b=i.jsxs("div",{className:"space-y-2",children:[m,_]}),e[25]=_,e[26]=m,e[27]=b):b=e[27],b}function F7(t){const e=fd(t);return i.jsx(nt,{value:e,children:B7(t)},e)}function U7(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return C.useMemo(()=>n=>{e.forEach(r=>r(n))},e)}const Kl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ur(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function md(t){return"nodeType"in t}function ls(t){var e,s;return t?ur(t)?t:md(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function pd(t){const{Document:e}=ls(t);return t instanceof e}function zo(t){return ur(t)?!1:t instanceof ls(t).HTMLElement}function cp(t){return t instanceof ls(t).SVGElement}function hr(t){return t?ur(t)?t.document:md(t)?pd(t)?t:zo(t)||cp(t)?t.ownerDocument:document:document:document}const Us=Kl?C.useLayoutEffect:C.useEffect;function Wl(t){const e=C.useRef(t);return Us(()=>{e.current=t}),C.useCallback(function(){for(var s=arguments.length,n=new Array(s),r=0;r<s;r++)n[r]=arguments[r];return e.current==null?void 0:e.current(...n)},[])}function H7(){const t=C.useRef(null),e=C.useCallback((n,r)=>{t.current=setInterval(n,r)},[]),s=C.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function go(t,e){e===void 0&&(e=[t]);const s=C.useRef(t);return Us(()=>{s.current!==t&&(s.current=t)},e),s}function Fo(t,e){const s=C.useRef();return C.useMemo(()=>{const n=t(s.current);return s.current=n,n},[...e])}function ol(t){const e=Wl(t),s=C.useRef(null),n=C.useCallback(r=>{r!==s.current&&e?.(r,s.current),s.current=r},[]);return[s,n]}function al(t){const e=C.useRef();return C.useEffect(()=>{e.current=t},[t]),e.current}let _c={};function Uo(t,e){return C.useMemo(()=>{if(e)return e;const s=_c[t]==null?0:_c[t]+1;return _c[t]=s,t+"-"+s},[t,e])}function dp(t){return function(e){for(var s=arguments.length,n=new Array(s>1?s-1:0),r=1;r<s;r++)n[r-1]=arguments[r];return n.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const h=o[c];h!=null&&(o[c]=h+t*d)}return o},{...e})}}const $i=dp(1),xo=dp(-1);function K7(t){return"clientX"in t&&"clientY"in t}function ql(t){if(!t)return!1;const{KeyboardEvent:e}=ls(t.target);return e&&t instanceof e}function W7(t){if(!t)return!1;const{TouchEvent:e}=ls(t.target);return e&&t instanceof e}function ll(t){if(W7(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return K7(t)?{x:t.clientX,y:t.clientY}:null}const un=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[un.Translate.toString(t),un.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:n}=t;return e+" "+s+"ms "+n}}}),sh="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function q7(t){return t.matches(sh)?t:t.querySelector(sh)}const G7={display:"none"};function Y7(t){let{id:e,value:s}=t;return Ge.createElement("div",{id:e,style:G7},s)}function J7(t){let{id:e,announcement:s,ariaLiveType:n="assertive"}=t;const r={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 Ge.createElement("div",{id:e,style:r,role:"status","aria-live":n,"aria-atomic":!0},s)}function X7(){const[t,e]=C.useState("");return{announce:C.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const up=C.createContext(null);function Q7(t){const e=C.useContext(up);C.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function Z7(){const[t]=C.useState(()=>new Set),e=C.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[C.useCallback(n=>{let{type:r,event:o}=n;t.forEach(a=>{var l;return(l=a[r])==null?void 0:l.call(a,o)})},[t]),e]}const eS={draggable:`
|
|
@@ -21,7 +21,7 @@ ${J}`}]}})},t[15]=f,t[16]=d,t[17]=h,t[18]=u,t[19]=R):R=t[19];const I=R,D=O_;let
|
|
|
21
21
|
8% { opacity: 1; }
|
|
22
22
|
22% { opacity: 0; }
|
|
23
23
|
}
|
|
24
|
-
`}),e[26]=y):y=e[26];let L;return e[27]!==b||e[28]!==h?(L=i.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,b,y]}),e[27]=b,e[28]=h,e[29]=L):L=e[29],L}function ca(t){const e=B.c(10),{phase:s,current:n,children:r}=t,o=s-n,a=o<0,l=o===0,c=a?90:o*-22,d=a?.94:1-Math.max(o,0)*.04,h=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=ne("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${c}px) scale(${d})`,g=l?"auto":"none";let x;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(x={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=x):x=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==x?(v=i.jsx("div",{"aria-hidden":f,className:m,style:x,children:r}),e[6]=r,e[7]=f,e[8]=x,e[9]=v):v=e[9],v}function sc(t){const e=B.c(7),{showUrl:s}=t,n=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),o=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),a=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==n?(l=n&&i.jsx("div",{className:ne("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",en)}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==l?(c=i.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=c):c=e[6],c}function hV(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(sc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"flex flex-1 px-8 py-5",children:i.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:oV.map(fV)})})]}),t[1]=s):s=t[1],s}function fV(t,e){if(e===i3)return i.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return i.jsx("div",{className:ne("relative rounded-md",Es),children:i.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${r3}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function mV(){const t=B.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(sc,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:ne("w-[18%] rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=n):n=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[n,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[i.jsx("div",{className:ne("rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),i.jsx("div",{className:ne("rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function pV(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(sc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:i.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:cV.map(gV)})})]}),t[1]=s):s=t[1],s}function gV(t,e){return i.jsx("div",{className:ne("aspect-square rounded-md",dV[e]?"bg-chart-2/70":Es),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function xV(){const t=B.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(sc,{showUrl:!0}),t[0]=e):e=t[0];let s,n,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),n=i.jsx("div",{className:ne("h-1.5 w-[70%] rounded-sm",Es)}),r=i.jsx("div",{className:ne("h-1.5 w-[55%] rounded-sm",Es)}),o=i.jsx("div",{className:ne("h-1.5 w-[80%] rounded-sm",Es)}),a=i.jsx("div",{className:ne("h-1.5 w-[50%] rounded-sm",Es)}),t[1]=s,t[2]=n,t[3]=r,t[4]=o,t[5]=a):(s=t[1],n=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,n,r,o,a,i.jsx("div",{className:"mt-auto",children:i.jsx("div",{className:ne("h-4 rounded-md",Es)})})]}),t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:i.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[i.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),i.jsx("div",{className:ne("h-1.5 w-[55%] rounded-sm",en)})]})}),t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[i.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),i.jsx("div",{className:ne("h-4 w-10 rounded-full",en)}),i.jsx("div",{className:ne("h-4 w-14 rounded-full",en)})]}),t[8]=d):d=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs("div",{className:ne("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",en),children:[i.jsx("div",{className:ne("h-1.5 w-[50%] rounded-sm",Es)}),i.jsx("div",{className:ne("h-1 w-[75%] rounded-sm",Es)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c,i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[d,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[i.jsx("div",{className:ne("rounded-md",en)}),i.jsx("div",{className:ne("rounded-md",en)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Bi(t){const e=B.c(25);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsx(uV,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}if(t.kind==="errored"){const l=t.error.code===h2.githubNotAuthenticated;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(nr,{className:"size-12 text-destructive"}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("h3",{className:"text-lg font-medium",children:Dh("errored")}),e[4]=d):d=e[4];const h=l?"This agent's GitHub repo isn't authenticated. Reconnect it in Connections, then retry.":t.error.message;let u;e[5]!==h?(u=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==t.connectionsHref?(f=l&&t.connectionsHref&&i.jsx(ie,{asChild:!0,children:i.jsx("a",{href:t.connectionsHref,children:"Reconnect GitHub"})}),e[7]=l,e[8]=t.connectionsHref,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(zi,{className:"size-4"}),e[10]=m):m=e[10];let p;e[11]!==t.onRetry?(p=i.jsxs(ie,{variant:"outline",onClick:t.onRetry,children:[m," Retry"]}),e[11]=t.onRetry,e[12]=p):p=e[12];let g;e[13]!==f||e[14]!==p?(g=i.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[f,p]}),e[13]=f,e[14]=p,e[15]=g):g=e[15];let x;return e[16]!==u||e[17]!==g?(x=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[c,d,u,g]})}),e[16]=u,e[17]=g,e[18]=x):x=e[18],x}let s;e[19]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(cx,{className:"size-12 text-blue-500"}),e[19]=s):s=e[19];let n,r;e[20]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("h3",{className:"text-lg font-medium",children:Dh("suspended")}),r=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[20]=n,e[21]=r):(n=e[20],r=e[21]);let o;e[22]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(fi,{className:"size-4"}),e[22]=o):o=e[22];let a;return e[23]!==t.onResume?(a=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,n,r,i.jsxs(ie,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[23]=t.onResume,e[24]=a):a=e[24],a}const Oh={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function Rd(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function o3(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:Oh.seoResolveType},__resolveType:Oh.resolveType}}function $h(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),n=`${s} (copy)`;if(!t.has(n))return n;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function vV(t,e){const s=ai,n=e.replace(/-copy(?:-\d+)?$/,""),r=`${n}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${n}-copy-${o}`;if(!t.has(s(a)))return a}return`${n}-copy-${Date.now()}`}function _V(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),n=`${s}_copy`;if(!Object.hasOwn(t,n))return n;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function bV(t){const e=Rd(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function yV(t,e){return o3(t,e)}const LV=1e3;function SV(t,e){for(let s=0;s<LV;s++){const n=Rd(e);if(!Object.hasOwn(t,n))return n}throw new Error("Could not generate a unique page block key")}const zn="__blank__";function a3(t){const e=B.c(44),{id:s,value:n,onChange:r,templates:o,disabled:a}=t,[l,c]=C.useState(!1);let d;if(e[0]!==o||e[1]!==n){let A;e[3]!==n?(A=N=>N.key===n,e[3]=n,e[4]=A):A=e[4],d=o.find(A),e[0]=o,e[1]=n,e[2]=d}else d=e[2];const h=d,u=h?.name??"Blank page";let f;e[5]!==u?(f=i.jsx("span",{className:"truncate",children:u}),e[5]=u,e[6]=f):f=e[6];let m;e[7]!==h?(m=h?.path?i.jsx("span",{className:"truncate text-muted-foreground",children:h.path}):null,e[7]=h,e[8]=m):m=e[8];let p;e[9]!==f||e[10]!==m?(p=i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[f,m]}),e[9]=f,e[10]=m,e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(S9,{className:"shrink-0 opacity-50"}),e[12]=g):g=e[12];let x;e[13]!==a||e[14]!==s||e[15]!==l||e[16]!==p?(x=i.jsx(Cs,{asChild:!0,children:i.jsxs(ie,{id:s,type:"button",variant:"outline",role:"combobox","aria-expanded":l,disabled:a,className:"w-full justify-between font-normal",children:[p,g]})}),e[13]=a,e[14]=s,e[15]=l,e[16]=p,e[17]=x):x=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v={width:"var(--radix-popover-trigger-width)"},e[18]=v):v=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(yi,{placeholder:"Search pages…",className:"h-9"}),e[19]=_):_=e[19];let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Li,{children:"No pages found."}),e[20]=b):b=e[20];let y;e[21]!==r?(y=()=>{r(zn),c(!1)},e[21]=r,e[22]=y):y=e[22];const L=n===zn?"opacity-100":"opacity-0";let w;e[23]!==L?(w=ne("ml-auto",L),e[23]=L,e[24]=w):w=e[24];let S;e[25]!==w?(S=i.jsx(Tt,{className:w}),e[25]=w,e[26]=S):S=e[26];let j;e[27]!==y||e[28]!==S?(j=i.jsxs(Ps,{value:"Blank page",onSelect:y,children:["Blank page",S]}),e[27]=y,e[28]=S,e[29]=j):j=e[29];let V;if(e[30]!==r||e[31]!==o||e[32]!==n){let A;e[34]!==r||e[35]!==n?(A=N=>i.jsxs(Ps,{value:`${N.name} ${N.path}`,onSelect:()=>{r(N.key),c(!1)},children:[i.jsxs("div",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{className:"truncate",children:N.name}),i.jsx("span",{className:"truncate text-xs text-muted-foreground",children:N.path})]}),i.jsx(Tt,{className:ne("ml-auto",n===N.key?"opacity-100":"opacity-0")})]},N.key),e[34]=r,e[35]=n,e[36]=A):A=e[36],V=o.map(A),e[30]=r,e[31]=o,e[32]=n,e[33]=V}else V=e[33];let k;e[37]!==j||e[38]!==V?(k=i.jsx(Vs,{className:"p-0",style:v,children:i.jsxs(lr,{children:[_,i.jsxs(Si,{onWheel:wV,children:[b,i.jsxs(Fs,{children:[j,V]})]})]})}),e[37]=j,e[38]=V,e[39]=k):k=e[39];let T;return e[40]!==l||e[41]!==k||e[42]!==x?(T=i.jsxs(ks,{open:l,onOpenChange:c,children:[x,k]}),e[40]=l,e[41]=k,e[42]=x,e[43]=T):T=e[43],T}function wV(t){const e=t.deltaMode===1?16:1;t.currentTarget.scrollTop=t.currentTarget.scrollTop+t.deltaY*e}const jV={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},CV={create:"Create",duplicate:"Duplicate",rename:"Save"},VV={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function kV(t){const e=B.c(62),{open:s,mode:n,initialName:r,initialPath:o,isPending:a,error:l,templates:c,validate:d,onSubmit:h,onOpenChange:u}=t,f=a===void 0?!1:a,[m,p]=C.useState(r),[g,x]=C.useState(o),[v,_]=C.useState(zn),[b,y]=C.useState(null),[L,w]=C.useState(s);s!==L&&(w(s),s&&(p(r),x(o),_(zn),y(null)));const S=n==="create"&&!!c?.length;let j;e[0]!==f||e[1]!==u?(j=Q=>{!Q&&!f&&(y(null),u(!1))},e[0]=f,e[1]=u,e[2]=j):j=e[2];const V=j;let k;e[3]!==f||e[4]!==m||e[5]!==h||e[6]!==g||e[7]!==S||e[8]!==v||e[9]!==d?(k=async Q=>{Q.preventDefault();const Z=m.trim(),J=g.trim();if(!Z||!J||f)return;const ee=rd(J);if(ee){y(ee);return}const te=d?.({name:Z,path:J});if(te){y(te);return}y(null),await h({name:Z,path:J,templateKey:S&&v!==zn?v:null})},e[3]=f,e[4]=m,e[5]=h,e[6]=g,e[7]=S,e[8]=v,e[9]=d,e[10]=k):k=e[10];const T=k,A=b??l,N=jV[n];let R;e[11]!==N?(R=i.jsx(ns,{children:i.jsx(is,{children:N})}),e[11]=N,e[12]=R):R=e[12];let I;e[13]!==f||e[14]!==S||e[15]!==v||e[16]!==c?(I=S&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{htmlFor:"page-form-template",className:"text-xs font-medium text-muted-foreground",children:"Template"}),i.jsx(a3,{id:"page-form-template",value:v,onChange:_,templates:c??[],disabled:f})]}),e[13]=f,e[14]=S,e[15]=v,e[16]=c,e[17]=I):I=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=i.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[18]=D):D=e[18];let E;e[19]===Symbol.for("react.memo_cache_sentinel")?(E=Q=>p(Q.target.value),e[19]=E):E=e[19];let P;e[20]!==f||e[21]!==m?(P=i.jsxs("div",{className:"space-y-1.5",children:[D,i.jsx(Ye,{id:"page-form-name",value:m,onChange:E,placeholder:"My page",autoFocus:!0,disabled:f})]}),e[20]=f,e[21]=m,e[22]=P):P=e[22];let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[23]=M):M=e[23];let z;e[24]===Symbol.for("react.memo_cache_sentinel")?(z=Q=>x(Q.target.value),e[24]=z):z=e[24];let $;e[25]!==f||e[26]!==g?($=i.jsxs("div",{className:"space-y-1.5",children:[M,i.jsx(Ye,{id:"page-form-path",value:g,onChange:z,placeholder:"/example",disabled:f})]}),e[25]=f,e[26]=g,e[27]=$):$=e[27];let O;e[28]!==A?(O=A&&i.jsx("p",{className:"text-xs text-destructive",children:A}),e[28]=A,e[29]=O):O=e[29];let U;e[30]!==$||e[31]!==O||e[32]!==I||e[33]!==P?(U=i.jsxs("div",{className:"space-y-4 py-4",children:[I,P,$,O]}),e[30]=$,e[31]=O,e[32]=I,e[33]=P,e[34]=U):U=e[34];let H;e[35]!==u?(H=()=>u(!1),e[35]=u,e[36]=H):H=e[36];let Y;e[37]!==f||e[38]!==H?(Y=i.jsx(ie,{type:"button",variant:"outline",onClick:H,disabled:f,children:"Cancel"}),e[37]=f,e[38]=H,e[39]=Y):Y=e[39];let G;e[40]!==f||e[41]!==m||e[42]!==g?(G=!m.trim()||!g.trim()||f,e[40]=f,e[41]=m,e[42]=g,e[43]=G):G=e[43];let K;e[44]!==f||e[45]!==n?(K=f?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),VV[n]]}):CV[n],e[44]=f,e[45]=n,e[46]=K):K=e[46];let q;e[47]!==G||e[48]!==K?(q=i.jsx(ie,{type:"submit",disabled:G,children:K}),e[47]=G,e[48]=K,e[49]=q):q=e[49];let W;e[50]!==Y||e[51]!==q?(W=i.jsxs(_i,{children:[Y,q]}),e[50]=Y,e[51]=q,e[52]=W):W=e[52];let F;e[53]!==T||e[54]!==U||e[55]!==W||e[56]!==R?(F=i.jsx(Ft,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:T,children:[R,U,W]})}),e[53]=T,e[54]=U,e[55]=W,e[56]=R,e[57]=F):F=e[57];let X;return e[58]!==V||e[59]!==s||e[60]!==F?(X=i.jsx(Ut,{open:s,onOpenChange:V,children:F}),e[58]=V,e[59]=s,e[60]=F,e[61]=X):X=e[61],X}function NV(t){const e=B.c(43),{open:s,blockKey:n,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,c=o===void 0?!1:o,[d,h]=C.useState(r),[u,f]=C.useState(s);s!==u&&(f(s),s&&h(r));let m;e[0]!==c||e[1]!==l?(m=D=>{!D&&!c&&l(!1)},e[0]=c,e[1]=l,e[2]=m):m=e[2];const p=m;let g;e[3]!==c||e[4]!==d||e[5]!==a?(g=async D=>{D.preventDefault();const E=d.trim();!E||c||await a(E)},e[3]=c,e[4]=d,e[5]=a,e[6]=g):g=e[6];const x=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsxs(ns,{children:[i.jsx(is,{children:"Rename section"}),i.jsx(qn,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=v):v=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=_):_=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=D=>h(D.target.value),e[9]=b):b=e[9];let y;e[10]!==c||e[11]!==d?(y=i.jsxs("div",{className:"space-y-1.5",children:[_,i.jsx(Ye,{id:"section-rename-name",value:d,onChange:b,autoFocus:!0,disabled:c})]}),e[10]=c,e[11]=d,e[12]=y):y=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=L):L=e[13];let w;e[14]!==n?(w=i.jsxs("div",{className:"space-y-1.5",children:[L,i.jsx(Ye,{value:n,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=n,e[15]=w):w=e[15];let S;e[16]!==y||e[17]!==w?(S=i.jsxs("div",{className:"space-y-4 py-4",children:[y,w]}),e[16]=y,e[17]=w,e[18]=S):S=e[18];let j;e[19]!==l?(j=()=>l(!1),e[19]=l,e[20]=j):j=e[20];let V;e[21]!==c||e[22]!==j?(V=i.jsx(ie,{type:"button",variant:"outline",onClick:j,disabled:c,children:"Cancel"}),e[21]=c,e[22]=j,e[23]=V):V=e[23];let k;e[24]!==c||e[25]!==d?(k=!d.trim()||c,e[24]=c,e[25]=d,e[26]=k):k=e[26];let T;e[27]!==c?(T=c?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=c,e[28]=T):T=e[28];let A;e[29]!==k||e[30]!==T?(A=i.jsx(ie,{type:"submit",disabled:k,children:T}),e[29]=k,e[30]=T,e[31]=A):A=e[31];let N;e[32]!==V||e[33]!==A?(N=i.jsxs(_i,{children:[V,A]}),e[32]=V,e[33]=A,e[34]=N):N=e[34];let R;e[35]!==x||e[36]!==S||e[37]!==N?(R=i.jsx(Ft,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:x,children:[v,S,N]})}),e[35]=x,e[36]=S,e[37]=N,e[38]=R):R=e[38];let I;return e[39]!==p||e[40]!==s||e[41]!==R?(I=i.jsx(Ut,{open:s,onOpenChange:p,children:R}),e[39]=p,e[40]=s,e[41]=R,e[42]=I):I=e[42],I}const Nc={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},Pd=["posts","authors","categories"],eo={posts:"post",authors:"author",categories:"category"};function to(t){return Pd.includes(t)}const Id={posts:"post",authors:"author",categories:"category"},l3={posts:Nc.post,authors:Nc.author,categories:Nc.category},AV=Object.fromEntries(Object.entries(l3).map(([t,e])=>[e,t]));function TV(t){return typeof t=="string"?AV[t]??null:null}function Qi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Bs(t){return typeof t=="string"?t:""}function EV(t,e){switch(t){case"posts":return{label:Bs(e.title)||"Untitled post",subtitle:Bs(e.slug)};case"authors":return{label:Bs(e.name)||"Unnamed author",subtitle:Bs(e.email)};case"categories":return{label:Bs(e.name)||"Unnamed category",subtitle:Bs(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function c3(t){const e={posts:[],authors:[],categories:[]};for(const[s,n]of Object.entries(t)){const r=Qi(n);if(!r)continue;const o=TV(r.__resolveType);if(!o)continue;const a=Qi(r[Id[o]])??{},{label:l,subtitle:c}=EV(o,a);e[o].push({key:s,kind:o,label:l,subtitle:c})}for(const s of Pd)e[s].sort((n,r)=>n.label.localeCompare(r.label));return e}function RV(t,e){return c3(t)[e]}function bo(t,e){return RV(t,e).map(s=>({key:s.key,payload:Ca(Qi(t[s.key])??void 0,e)}))}const Bh=Object.freeze({});function Ca(t,e){return t?Qi(t[Id[e]])??Bh:Bh}function da(t,e,s){return{name:t,__resolveType:l3[e],[Id[e]]:s}}function d3(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function Zi(t){return Array.isArray(t)?t:[]}function Fn(t){if(typeof t=="string")return t;const e=Qi(t);return e?Bs(e.slug):""}function PV(t){if(typeof t=="string")return t;const e=Qi(t);return e?Bs(e.email):""}function u3(t){return bo(t,"posts").map(({key:e,payload:s})=>({key:e,title:Bs(s.title)||"Untitled post",slug:Bs(s.slug),date:Bs(s.date),categorySlugs:Zi(s.categories).map(Fn).filter(Boolean),authorEmails:Zi(s.authors).map(PV).filter(Boolean)}))}function IV(t,e){const s=Zi(t.categories);return s.some(n=>Fn(n)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function DV(t,e){const s=Zi(t.categories);return s.length===1&&Fn(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function yF(t,e,s){const n=Zi(t.categories);if(!n.some(l=>Fn(l)===e))return t;const r=n.map(l=>{const c=Fn(l);return c===e||c===s.slug?{name:s.name,slug:s.slug}:l}),o=new Set,a=r.filter(l=>{const c=Fn(l);return c?o.has(c)?!1:(o.add(c),!0):!0});return{...t,categories:a}}function MV(t,e){const s=Zi(t.categories);return s.some(n=>Fn(n)===e)?{...t,categories:s.filter(n=>Fn(n)!==e)}:t}function S0(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function zh(t,e){const s=`collections/blog/${e}/${S0(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function OV(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${S0(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${S0(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const $V={Paragraph:{title:"Paragraph",description:"Rich text content",iconName:"Pilcrow01"},Heading:{title:"Heading",description:"Section title (H1–H6)",iconName:"HeadingSquare"},Quote:{title:"Quote",description:"Pull quote",iconName:"MessageTextSquare02"},Code:{title:"Code",description:"Code block with syntax highlighting",iconName:"Code02"},List:{title:"List",description:"Bulleted or numbered list",iconName:"List"},BlockImage:{title:"Image",description:"Image with optional caption",iconName:"Image01"},Video:{title:"Video",description:"Embedded video",iconName:"PlayCircle"},Divider:{title:"Divider",description:"Horizontal divider",iconName:"Divider"},Cta:{title:"Call to action",description:"Button linking to a URL",iconName:"CursorClick01"},Callout:{title:"Callout",description:"Highlighted note, tip or warning",iconName:"Lightbulb02"},Stat:{title:"Stat",description:"Single key metric",iconName:"BarChartSquareUp"},StatGroup:{title:"Stat group",description:"Row of metrics",iconName:"BarChartSquare02"},CardGroup:{title:"Card group",description:"Grid of cards",iconName:"LayoutGrid01"},Checklist:{title:"Checklist",description:"List of check items",iconName:"CheckSquare"},Steps:{title:"Steps",description:"Step-by-step guide",iconName:"LayersThree01"},Comparison:{title:"Comparison",description:"Side-by-side comparison",iconName:"Columns03"},Table:{title:"Table",description:"Rows and columns of structured data",iconName:"Table"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},Fh="Box";function BV(t){return t.startsWith("site/")?"site":"app"}function zV(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function jr(...t){for(const e of t)if(e!==void 0)return e}function LF(t){const e=new Set,s=[],n=t.manifest?.blocks??{};for(const r of Object.values(n))for(const o of Object.keys(r)){if(!HV(o)||e.has(o))continue;e.add(o);const a=Jn(o,t),l=FV(o),c=$V[l],d=BV(o),h=(d==="site"?jr(a.title,c?.title):jr(c?.title,a.title))??l,u=d==="site"?jr(a.description,c?.description):jr(c?.description,a.description),f=d==="site"?a.icon:void 0,m=f&&zV(f)?f:void 0,p=m!==void 0?c?.iconName??Fh:jr(f,c?.iconName)??Fh;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:d})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function FV(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const UV=["blog/sections/blocks/","site/sections/Blog/Post/"];function HV(t){return UV.some(e=>t.startsWith(e))}function h3({orgSlug:t,virtualMcpId:e,branch:s}){return Qe.decofile(`${t}/${e}/${s}`)}function f3({orgSlug:t,virtualMcpId:e,branch:s},n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${n}`}function KV(t){const e=B.c(11),s=os();let n;e[0]!==t?(n=async l=>{const{blockKey:c,data:d}=l,h=await fetch(f3(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:d3(c),content:JSON.stringify(d,null,2)})});if(!h.ok){const u=await h.json().catch(WV);throw new Error(u.error??`Write failed (${h.status})`)}return h.json()},e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:c,data:d}=l,h=h3(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[c]:d})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,c,d)=>{d?.queryKey&&s.setQueryData(d.queryKey,d.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==n||e[8]!==r||e[9]!==o?(a={mutationFn:n,onMutate:r,onError:o},e[7]=n,e[8]=r,e[9]=o,e[10]=a):a=e[10],Ds(a)}function WV(){return{}}function qV(t){const e=os();return Ds({mutationFn:async({blockKey:s})=>{const n=await fetch(f3(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:d3(s)})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??`Delete failed (${n.status})`)}return n.json()},onMutate:async({blockKey:s})=>{const n=h3(t);await e.cancelQueries({queryKey:n});const r=e.getQueryData(n);return e.setQueryData(n,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:n}},onError:(s,n,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)}})}function GV(t){const e=B.c(20),{open:s,onOpenChange:n,pageKey:r,decofile:o}=t,[a,l]=C.useState(!1),c=o[r];let d;e[0]!==c?(d=c===void 0?"// Page not found.":JSON.stringify(c,null,2),e[0]=c,e[1]=d):d=e[1];const h=d;let u;e[2]!==h?(u=()=>{navigator.clipboard.writeText(h).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=h,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(is,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?i.jsx(Tl,{size:12}):i.jsx(Ss,{size:12}),e[5]=a,e[6]=p):p=e[6];const g=a?"Copied":"Copy";let x;e[7]!==f||e[8]!==p||e[9]!==g?(x=i.jsxs(ns,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,i.jsxs(ie,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,g]})]}),e[7]=f,e[8]=p,e[9]=g,e[10]=x):x=e[10];let v;e[11]!==h?(v=i.jsx(Sn,{className:"max-h-[70vh]",children:i.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:h})}),e[11]=h,e[12]=v):v=e[12];let _;e[13]!==x||e[14]!==v?(_=i.jsxs(Ft,{className:"max-w-2xl p-0 gap-0",children:[x,v]}),e[13]=x,e[14]=v,e[15]=_):_=e[15];let b;return e[16]!==n||e[17]!==s||e[18]!==_?(b=i.jsx(Ut,{open:s,onOpenChange:n,children:_}),e[16]=n,e[17]=s,e[18]=_,e[19]=b):b=e[19],b}function YV(t){const e=B.c(3),{isPending:s,isError:n}=t;if(n){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[i.jsx(fn,{size:13}),"Couldn't save"]}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[i.jsx(qe,{size:13,className:"animate-spin"}),"Saving…"]}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70",children:[i.jsx(Tt,{size:13}),"Saved"]}),e[2]=r):r=e[2],r}const JV={loaders:"loader",actions:"action"},m3=new Set(["workflows"]);function p3(t){return JV[t]}function g3(t,e,s){const n=t.manifest?.blocks??{};for(const[r,o]of Object.entries(n))if(r.includes(s)&&e in o)return!0;return!1}function XV(t,e){return/\.tsx?$/.test(t)?!1:e.has(`${t}.ts`)||e.has(`${t}.tsx`)}function x3(t,e){const s=t.manifest?.blocks??{},n=[],r=new Set;for(const[o,a]of Object.entries(s))if(o.includes(e))for(const l of Object.keys(a))r.add(l);for(const o of r){if(o.toLowerCase().includes("preview")||m3.has(Dd(o))||XV(o,r))continue;const a=Jn(o,t);if(a.hidden)continue;const l=a.title&&a.title!==o?a.title:vt(o);n.push({resolveType:o,title:l})}return n.sort((o,a)=>o.title.localeCompare(a.title))}function Uh(t,e){return x3(t,e).length}function Dd(t){return t.startsWith("deco-sites/")?t.split("/")[1]||"site":t.startsWith("$live")||t.startsWith("deco/")?"deco":t.split("/")[0]||"other"}const QV={deco:"Deco",std:"Deco Standard",website:"Website"};function ZV(t){return QV[t]??t}function v3(t){const e=Dd(t);let n=t.split("/").filter(Boolean).slice(t.startsWith("deco-sites/")?2:1);return(n[0]==="loaders"||n[0]==="actions")&&(n=n.slice(1)),[e,...n.slice(0,-1)]}function ek(t,e,s){const n=[];for(const[r,o]of Object.entries(e)){if(r.includes("/")||$l(r)||!o||typeof o!="object"||Array.isArray(o))continue;const a=o,l=a.__resolveType;typeof l=="string"&&(m3.has(Dd(l))||g3(t,l,s)&&n.push({key:r,resolveType:l,title:typeof a.name=="string"&&a.name?a.name:r}))}return n.sort((r,o)=>r.title.localeCompare(o.title))}const Hh=3e4;function _3(t){return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-invoke`}function tk(t,e,s,n){const r=new URL(`/deco/invoke/${e}`,t);return r.searchParams.set("__cb",n.toString(36)),r.searchParams.set("__decoFBT","0"),r.searchParams.set("__d",`run-${n.toString(36)}`),r.searchParams.set("props",btoa(encodeURIComponent(JSON.stringify(s)))),r.href}async function sk(t,{resolveType:e,props:s}){let n;try{n=await fetch(_3(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(Hh)})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(`Run timed out after ${Hh/1e3}s — the block may be slow or the preview unresponsive.`):l}const r=await n.text();let o=null,a=!1;try{o=r?JSON.parse(r):null,a=!0}catch{}if(!n.ok){const l=a&&o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"?o.error:r||`Run failed (${n.status})`;throw new Error(l)}return a?o:r}function nk(t){const e=B.c(2);let s;return e[0]!==t?(s={mutationFn:n=>sk(t,n)},e[0]=t,e[1]=s):s=e[1],Ds(s)}function ik({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:r,decofile:o,kind:a,target:l,initialValue:c,isCreating:d,onCreate:h,onSaveReferencedBlock:u,onBack:f}){const m=Vn(),p=m?.entity?.id===e?m.entity.metadata?.siteSlug??null:null,g=Ln(l.resolveType,r),x=!g&&AL(l.resolveType,r),v=x?TL(c):null,_=g??v,[b,y]=C.useState(c),[L,w]=C.useState([]),[S,j]=C.useState(0),[V,k]=C.useState(!1),[T,A]=C.useState(null),[N,R]=C.useState(!1),[I,D]=C.useState(!1),[E,P]=C.useState(!1),M=T!==null,{save:z,flush:$,isPending:O}=K2({orgSlug:t,virtualMcpId:e,branch:s}),U=nk({orgSlug:t,virtualMcpId:e,branch:s});C.useEffect(()=>()=>{$()},[]);const H=p3(a),Y=l.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")??l.resolveType,G={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:p},K=ee=>{y(ee),l.mode==="saved"&&z(l.blockKey,{__resolveType:l.resolveType,...ee})},q=()=>{M?(A(null),k(!1),j(ee=>ee+1)):A(JSON.stringify(b,null,2))},W=ee=>{const te=ee??"";try{const ae=JSON.parse(te);if(ae&&typeof ae=="object"&&!Array.isArray(ae)){k(!1),K(ae);return}k(!0)}catch{k(!0)}},F=async ee=>{const te=ud(ee,o);if(te){de.error(te);return}await h(ee,{__resolveType:l.resolveType,...b}),R(!1)},X=()=>{D(!0),U.mutate({resolveType:l.resolveType,props:b})},Q=()=>{n&&window.open(tk(n,l.resolveType,b,Date.now()),"_blank","noopener")},Z=[l.title,...L],J=ee=>{w(L.slice(0,ee)),j(te=>te+1)};return i.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col",children:[i.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[f&&i.jsx(ie,{variant:"ghost",size:"icon",className:"size-8 shrink-0",onClick:f,"aria-label":"Back to list",children:i.jsx(Vl,{size:14})}),i.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:Z.map((ee,te)=>{const ae=te===Z.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[te>0&&i.jsx(cn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>J(te),title:ee,className:ne("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",ae?"font-medium text-foreground":"text-muted-foreground"),children:ee})]},`${ee}-${te}`)})}),l.mode==="saved"&&i.jsx(YV,{isPending:O,isError:!1}),i.jsxs(ie,{size:"sm",variant:"outline",className:"h-8 shrink-0 gap-1.5",onClick:X,disabled:U.isPending,"aria-label":`Run ${H}`,children:[U.isPending?i.jsx(qe,{size:14,className:"animate-spin"}):i.jsx(fi,{size:14}),"Run"]}),l.mode==="available"&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{size:"icon",className:"size-8 shrink-0",disabled:d,onClick:()=>R(!0),"aria-label":`Save as global ${H}`,children:i.jsx(N9,{size:14})})}),i.jsxs(Pe,{side:"bottom",children:["Save as global ",H]})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:M?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:q,"aria-label":M?"Close JSON editor":"Edit as JSON","aria-pressed":M,children:M?i.jsx(ms,{size:14}):i.jsx(Ao,{size:14})})}),i.jsx(Pe,{side:"bottom",children:M?"Close JSON editor":"Edit as JSON"})]})]}),i.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:l.mode==="saved"?`Global ${H} — changes save automatically. Run to invoke it against the live preview.`:`${Y} — edits stay local until you save this as a global ${H}. Run to invoke it against the live preview.`})]}),i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[i.jsxs("div",{className:ne("relative min-h-0 flex-1",I&&E&&"hidden"),children:[i.jsx(Sn,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:i.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:i.jsxs("div",{className:"mx-auto max-w-2xl",children:[v&&_===v&&i.jsxs("p",{className:"mb-3 rounded-md bg-muted px-3 py-2 text-xs leading-snug text-muted-foreground",children:["This ",H," doesn't publish a props schema — fields below are inferred from its saved values. Use the JSON editor to add props not shown here."]}),_?i.jsx(Xn,{schema:_,value:b,onChange:ee=>K(ee),basePath:"",breadcrumbPath:L,onBreadcrumbChange:w,meta:r,decofile:o,onSaveReferencedBlock:u,sandbox:G},S):i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:x?`This ${H} doesn't publish a props schema. Edit its props as JSON, then run it.`:`This ${H} takes no configurable input. Run it to see its output.`})]})})}),T!==null&&i.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[V&&i.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(Pl,{language:"json",height:"100%",code:T,onChange:W,onSave:ee=>{W(ee),$()}})})]})]}),I&&i.jsx(rk,{singular:H,result:{isPending:U.isPending,error:U.error,data:U.data,hasRun:U.status!=="idle"},expanded:E,onToggleExpand:()=>P(ee=>!ee),onOpenInNewTab:n?Q:void 0,onClose:()=>{D(!1),P(!1)}})]}),i.jsx(kd,{open:N,onOpenChange:R,defaultBlockId:"",isPending:d,onSubmit:F})]})}function rk(t){const e=B.c(37),{singular:s,result:n,expanded:r,onToggleExpand:o,onOpenInNewTab:a,onClose:l}=t;let c;e[0]!==n.data?(c=typeof n.data=="string"?n.data:JSON.stringify(n.data??null,null,2),e[0]=n.data,e[1]=c):c=e[1];const d=c,h=r?"flex-1":"h-[45%] shrink-0";let u;e[2]!==h?(u=ne("flex min-h-0 flex-col border-t",h),e[2]=h,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Result"}),e[4]=f):f=e[4];let m;e[5]!==a||e[6]!==s?(m=a&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",className:"size-7",onClick:a,"aria-label":"Open result in new tab",children:i.jsx(wn,{size:14})})}),i.jsxs(Pe,{side:"bottom",children:["Open in new tab (re-runs the ",s,")"]})]}),e[5]=a,e[6]=s,e[7]=m):m=e[7];const p=r?"Collapse result":"Expand result";let g;e[8]!==r?(g=r?i.jsx(dx,{size:14}):i.jsx(nm,{size:14}),e[8]=r,e[9]=g):g=e[9];let x;e[10]!==r||e[11]!==o||e[12]!==p||e[13]!==g?(x=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",className:"size-7",onClick:o,"aria-label":p,"aria-pressed":r,children:g})}),e[10]=r,e[11]=o,e[12]=p,e[13]=g,e[14]=x):x=e[14];const v=r?"Collapse":"Expand";let _;e[15]!==v?(_=i.jsx(Pe,{side:"bottom",children:v}),e[15]=v,e[16]=_):_=e[16];let b;e[17]!==_||e[18]!==x?(b=i.jsxs(Ie,{children:[x,_]}),e[17]=_,e[18]=x,e[19]=b):b=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ms,{size:14}),e[20]=y):y=e[20];let L;e[21]!==l?(L=i.jsx(ie,{variant:"ghost",size:"icon",className:"size-7",onClick:l,"aria-label":"Close result",children:y}),e[21]=l,e[22]=L):L=e[22];let w;e[23]!==b||e[24]!==L||e[25]!==m?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[f,i.jsxs("div",{className:"flex items-center gap-0.5",children:[m,b,L]})]}),e[23]=b,e[24]=L,e[25]=m,e[26]=w):w=e[26];let S;e[27]!==n.error||e[28]!==n.hasRun||e[29]!==n.isPending||e[30]!==d||e[31]!==s?(S=i.jsx("div",{className:"min-h-0 flex-1",children:n.isPending?i.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-muted-foreground",children:[i.jsx(qe,{size:16,className:"animate-spin"}),"Running ",s,"…"]}):n.error?i.jsxs("div",{className:"h-full overflow-auto px-4 py-3",children:[i.jsxs("p",{className:"text-xs font-medium text-destructive",children:["Failed to run ",s]}),i.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-destructive/90",children:n.error.message})]}):n.hasRun?i.jsx(Pl,{language:"json",height:"100%",code:d,readOnly:!0}):i.jsxs("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:["Press Run to invoke this ",s,"."]})}),e[27]=n.error,e[28]=n.hasRun,e[29]=n.isPending,e[30]=d,e[31]=s,e[32]=S):S=e[32];let j;return e[33]!==w||e[34]!==S||e[35]!==u?(j=i.jsxs("div",{className:u,children:[w,S]}),e[33]=w,e[34]=S,e[35]=u,e[36]=j):j=e[36],j}const ok={loaders:$a,actions:ui},ak={loaders:"Loaders",actions:"Actions"},lk={analytics:ux,blog:Ki,commerce:A9,site:Sv,website:Yn};function ck(t,e){return e===0?lk[t.toLowerCase()]??hi:hi}function ua(t,e){return e===0?ZV(t):t}function dk(t){const e=B.c(87),{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];const[h,u]=C.useState(d),[f,m]=C.useState(null),[p,g]=C.useState(""),[x,v]=C.useState(vk),[_,b]=C.useState(c);_!==c&&(b(c),u([]),m(null),g(""),v(new Set));let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=U=>{v(H=>{const Y=new Set(H);return Y.has(U)?Y.delete(U):Y.add(U),Y})},e[1]=y):y=e[1];const L=y;let w;e[2]!==r||e[3]!==s||e[4]!==n?(w={orgSlug:s,virtualMcpId:n,branch:r},e[2]=r,e[3]=s,e[4]=n,e[5]=w):w=e[5];const S=Bl(w);let j;e[6]!==S?(j=lp((U,H)=>S.mutate({blockKey:U,data:H})),e[6]=S,e[7]=j):j=e[7];const V=j;let k;e[8]!==c?(k=p3(c),e[8]=c,e[9]=k):k=e[9];const T=k,A=ok[c];let N,R,I,D,E,P,M;if(e[10]!==A||e[11]!==r||e[12]!==l||e[13]!==c||e[14]!==a||e[15]!==x||e[16]!==s||e[17]!==h||e[18]!==o||e[19]!==S||e[20]!==V||e[21]!==p||e[22]!==f||e[23]!==T||e[24]!==n){I=Symbol.for("react.early_return_sentinel");e:{const U=[...ek(a,l,c).map(xk),...x3(a,c).map(gk)],H=p.trim().toLowerCase(),Y=H.length>0,G=Y?U.filter(pe=>pe.title.toLowerCase().includes(H)||pe.resolveType.toLowerCase().includes(H)):[],K=new Map,q=[],W=new Map;if(!Y){for(const pe of U){const Ee=pe.folderPath;if(!(Ee.length<h.length)&&h.every((De,he)=>Ee[he]===De))if(Ee.length===h.length)if(pe.savedKey!==void 0){const De=W.get(pe.resolveType);De?De.push(pe):W.set(pe.resolveType,[pe])}else q.push(pe);else{const De=Ee[h.length],he=K.get(De)??{count:0,savedCount:0};pe.savedKey!==void 0?he.savedCount=he.savedCount+1:he.count=he.count+1,K.set(De,he)}}q.sort(pk);for(const pe of W.values())pe.sort(mk)}const F=[...W.entries()].filter(pe=>{const[Ee]=pe;return!q.some(De=>De.resolveType===Ee)}).flatMap(fk).sort(hk);let X;e[32]!==h?(X=(pe,Ee)=>ua(pe.name,h.length).localeCompare(ua(Ee.name,h.length)),e[32]=h,e[33]=X):X=e[33];const Q=[...K.entries()].map(uk).sort(X);let Z;e[34]===Symbol.for("react.memo_cache_sentinel")?(Z=pe=>{m(pe.savedKey!==void 0?{mode:"saved",key:pe.savedKey}:{mode:"available",resolveType:pe.resolveType,title:pe.title})},e[34]=Z):Z=e[34];const J=Z;let ee;e[35]!==S||e[36]!==T?(ee=async(pe,Ee)=>{await S.mutateAsync({blockKey:pe,data:Ee}),de.success(`Saved ${T} "${pe}"`),m({mode:"saved",key:pe})},e[35]=S,e[36]=T,e[37]=ee):ee=e[37];const te=ee;let ae;e[38]!==l||e[39]!==f?(ae=_k(f,l),e[38]=l,e[39]=f,e[40]=ae):ae=e[40];const se=ae;if(se){const pe=`${se.mode}:${se.mode==="saved"?se.blockKey:se.resolveType}`;let Ee;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>m(null),e[41]=Ee):Ee=e[41];let De;e[42]!==r||e[43]!==l||e[44]!==te||e[45]!==c||e[46]!==a||e[47]!==s||e[48]!==o||e[49]!==S.isPending||e[50]!==V||e[51]!==pe||e[52]!==se.editorTarget||e[53]!==se.initialValue||e[54]!==n?(De=i.jsx(ik,{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c,target:se.editorTarget,initialValue:se.initialValue,isCreating:S.isPending,onCreate:te,onSaveReferencedBlock:V,onBack:Ee},pe),e[42]=r,e[43]=l,e[44]=te,e[45]=c,e[46]=a,e[47]=s,e[48]=o,e[49]=S.isPending,e[50]=V,e[51]=pe,e[52]=se.editorTarget,e[53]=se.initialValue,e[54]=n,e[55]=De):De=e[55],I=De;break e}M="flex h-full w-full min-w-0 flex-col";let oe;e[56]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>u([]),e[56]=oe):oe=e[56];const ce=h.length===0?"font-medium text-foreground":"text-muted-foreground";let fe;e[57]!==ce?(fe=ne("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",ce),e[57]=ce,e[58]=fe):fe=e[58];const be=ak[c];let _e;e[59]!==fe||e[60]!==be?(_e=i.jsx("button",{type:"button",onClick:oe,className:fe,children:be}),e[59]=fe,e[60]=be,e[61]=_e):_e=e[61];let xe;e[62]!==h?(xe=h.map((pe,Ee)=>{const De=Ee===h.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[i.jsx(cn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>u(h.slice(0,Ee+1)),className:ne("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",De?"font-medium text-foreground":"text-muted-foreground"),children:ua(pe,Ee)})]},`${pe}-${Ee}`)}),e[62]=h,e[63]=xe):xe=e[63];let Ve;e[64]!==_e||e[65]!==xe?(Ve=i.jsxs("nav",{"aria-label":"Folder breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:[_e,xe]}),e[64]=_e,e[65]=xe,e[66]=Ve):Ve=e[66];let Ne;e[67]===Symbol.for("react.memo_cache_sentinel")?(Ne=i.jsx($9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[67]=Ne):Ne=e[67];let we;e[68]===Symbol.for("react.memo_cache_sentinel")?(we=pe=>g(pe.target.value),e[68]=we):we=e[68];const ye=`Search all ${c}…`,$e=`Search all ${c}`;let Fe;e[69]!==p||e[70]!==ye||e[71]!==$e?(Fe=i.jsxs("div",{className:"flex w-56 shrink-0 items-center gap-2",children:[Ne,i.jsx("input",{type:"text",value:p,onChange:we,placeholder:ye,"aria-label":$e,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[69]=p,e[70]=ye,e[71]=$e,e[72]=Fe):Fe=e[72],e[73]!==Ve||e[74]!==Fe?(R=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[Ve,Fe]}),e[73]=Ve,e[74]=Fe,e[75]=R):R=e[75],N=Sn,P="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",D="mx-auto w-full max-w-4xl px-6 py-5",E=Y?G.length===0?i.jsx(Mn,{title:`No ${c} match "${p.trim()}"`,description:"Search covers every folder — try a different term."}):i.jsx("div",{className:"flex flex-col gap-1",children:G.map(pe=>i.jsx(tn,{icon:A,accent:pe.savedKey!==void 0?"global":void 0,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>J(pe)},pe.savedKey??pe.resolveType))}):Q.length===0&&q.length===0&&F.length===0?i.jsx(Mn,{title:`No ${c} here`,description:h.length===0?"Start the preview dev server so its manifest loads.":"This folder is empty."}):i.jsxs(i.Fragment,{children:[Q.length>0&&i.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2",children:Q.map(pe=>{const Ee=ck(pe.name,h.length);return i.jsxs("button",{type:"button",onClick:()=>u([...h,pe.name]),className:"flex items-center gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[i.jsx(Ee,{size:18,className:"shrink-0 text-muted-foreground"}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium",children:ua(pe.name,h.length)}),i.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[pe.count," ",pe.count===1?T:c,pe.savedCount>0&&i.jsxs(i.Fragment,{children:[" · ",pe.savedCount," saved"]})]})]})]},pe.name)})}),(q.length>0||F.length>0)&&i.jsxs("div",{className:ne("flex flex-col gap-1",Q.length>0&&"mt-4"),children:[q.map(pe=>{const Ee=W.get(pe.resolveType)??[],De=x.has(pe.resolveType);return i.jsxs("div",{className:"flex flex-col",children:[i.jsx(tn,{icon:A,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>J(pe)}),Ee.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>L(pe.resolveType),"aria-expanded":De,className:"flex items-center gap-1 self-start rounded-md px-2.5 py-1 text-xs font-medium transition-colors hover:bg-global-section/10 cursor-pointer ml-11",style:{color:td},children:[De?i.jsx(Ht,{size:12,className:"shrink-0"}):i.jsx(cn,{size:12,className:"shrink-0"}),De?"Hide saved":"See saved"," (",Ee.length,")"]}),De&&i.jsx("div",{className:"ml-11 flex flex-col gap-1 pb-1",children:Ee.map(he=>i.jsx(tn,{icon:A,accent:"global",title:he.title,subtitle:he.resolveType,active:!1,onClick:()=>J(he)},he.savedKey))})]})]},pe.resolveType)}),F.map(pe=>i.jsx(tn,{icon:A,accent:"global",title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>J(pe)},pe.savedKey))]})]})}e[10]=A,e[11]=r,e[12]=l,e[13]=c,e[14]=a,e[15]=x,e[16]=s,e[17]=h,e[18]=o,e[19]=S,e[20]=V,e[21]=p,e[22]=f,e[23]=T,e[24]=n,e[25]=N,e[26]=R,e[27]=I,e[28]=D,e[29]=E,e[30]=P,e[31]=M}else N=e[25],R=e[26],I=e[27],D=e[28],E=e[29],P=e[30],M=e[31];if(I!==Symbol.for("react.early_return_sentinel"))return I;let z;e[76]!==D||e[77]!==E?(z=i.jsx("div",{className:D,children:E}),e[76]=D,e[77]=E,e[78]=z):z=e[78];let $;e[79]!==N||e[80]!==z||e[81]!==P?($=i.jsx(N,{className:P,children:z}),e[79]=N,e[80]=z,e[81]=P,e[82]=$):$=e[82];let O;return e[83]!==R||e[84]!==$||e[85]!==M?(O=i.jsxs("div",{className:M,children:[R,$]}),e[83]=R,e[84]=$,e[85]=M,e[86]=O):O=e[86],O}function uk(t){const[e,s]=t;return{name:e,...s}}function hk(t,e){return t.title.localeCompare(e.title)}function fk(t){const[,e]=t;return e}function mk(t,e){return t.title.localeCompare(e.title)}function pk(t,e){return t.title.localeCompare(e.title)}function gk(t){return{resolveType:t.resolveType,title:t.title,folderPath:v3(t.resolveType)}}function xk(t){return{resolveType:t.resolveType,title:t.title,folderPath:v3(t.resolveType),savedKey:t.key}}function vk(){return new Set}function _k(t,e){if(!t)return null;if(t.mode==="available")return{mode:"available",resolveType:t.resolveType,editorTarget:{mode:"available",resolveType:t.resolveType,title:t.title},initialValue:{}};const s=e[t.key],n=s&&typeof s.__resolveType=="string"?s.__resolveType:"",{__resolveType:r,...o}=s??{},a=s&&typeof s.name=="string"&&s.name?s.name:t.key;return{mode:"saved",blockKey:t.key,resolveType:n,editorTarget:{mode:"saved",blockKey:t.key,resolveType:n,title:a},initialValue:o}}const bk={target:null,editSeoPageKey:null,previewRevision:0};function yk(t,e){switch(e.type){case"select":return{...t,target:e.target};case"edit-seo":return{...t,target:e.target,editSeoPageKey:e.target.key};case"consume-edit-seo":return{...t,editSeoPageKey:null};case"saved":return{...t,previewRevision:t.previewRevision+1}}}const b3=C.createContext(null);function Lk(t){const e=B.c(9),{children:s}=t,[n,r]=C.useReducer(yk,bk);let o,a,l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u=>r({type:"select",target:u}),a=u=>r({type:"edit-seo",target:u}),l=()=>r({type:"consume-edit-seo"}),c=()=>r({type:"saved"}),e[0]=o,e[1]=a,e[2]=l,e[3]=c):(o=e[0],a=e[1],l=e[2],c=e[3]);let d;e[4]!==n?(d={state:n,selectTarget:o,editSeo:a,consumeEditSeo:l,notifySaved:c},e[4]=n,e[5]=d):d=e[5];let h;return e[6]!==s||e[7]!==d?(h=i.jsx(b3,{value:d,children:s}),e[6]=s,e[7]=d,e[8]=h):h=e[8],h}function y3(){const t=C.use(b3);if(!t)throw new Error("useBlocksPreviewWorkspace must be used inside BlocksPreviewWorkspaceProvider");return t}const Kh=C.lazy(()=>Ws(()=>import("./app-editor-BHj37cnk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.AppEditor}))),Sk=C.lazy(()=>Ws(()=>import("./post-editor-DSGnoUmA.js"),__vite__mapDeps([149,1,2,51,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,105,104,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,109,117,150,151,107,108,110,111,112,113,114,115,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.PostEditor}))),wk=C.lazy(()=>Ws(()=>import("./record-editor-BDKvL12x.js"),__vite__mapDeps([152,1,2,105,104,117,151,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,85,86,87,14,15,16,88,89,90,17,13,91,69,92,82,93,4,5,6,10,11,12,18,19,21,23,24,25,26,27,68,70,71,72,73,74,75,76,77,78,79,80,81,83,84,94,95,96,97,98,99,100,101,102,103,107,108,109,110,111,112,113,114,115,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.RecordEditor}))),jk=C.lazy(()=>Ws(()=>import("./category-editor-Bf6cCUx0.js"),__vite__mapDeps([153,1,2,35,31,28,32,33,34,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,96,105,104,150,73,74,75,76,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,97,98,99,100,101,102,103,151,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.CategoryEditor}))),Ck=C.lazy(()=>Ws(()=>import("./bulk-category-panel-BoL-CJ9Q.js"),__vite__mapDeps([154,1,2,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,104,155,5,6])).then(t=>({default:t.BulkCategoryPanel}))),Vk=C.lazy(()=>Ws(()=>import("./sections-editor-BXA6IVl3.js"),__vite__mapDeps([156,1,2,8,39,3,9,31,28,32,33,34,35,36,37,38,29,7,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,126,157,135,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SectionsEditor}))),kk=C.lazy(()=>Ws(()=>import("./seo-editor-gYApNiNE.js"),__vite__mapDeps([158,1,2,3,31,28,32,33,34,35,36,37,38,39,29,7,8,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,157,135,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SeoEditor}))),Nk=C.lazy(()=>Ws(()=>import("./variant-calendar-BMmdw5vi.js"),__vite__mapDeps([159,1,2,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,104,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,105,135,160])).then(t=>({default:t.VariantCalendar}))),w0="oklch(0.65 0.15 160)";function Ac(t){return t?t.kind==="page"?{collection:"pages",key:t.key,path:t.path}:{collection:"sections",key:t.key}:null}function Ak(t){return t?t.kind==="page"?`page:${t.key}:${t.path}`:`section:${t.key}`:null}function Tk(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function Ek(t){const e=new Map;for(const s of t){const n=Tk(s.resolveType),r=e.get(n);r?r.push(s):e.set(n,[s])}return[...e.entries()].map(([s,n])=>({label:s,sections:n})).sort((s,n)=>s.label.localeCompare(n.label))}function L3(t){const e=B.c(20),{mode:s}=t,n=s===void 0?"content":s,r=Vn(),{data:o}=vi.useSession(),{currentBranch:a}=as(),{org:l}=Ae(),c=r?.entity?.id??null,d=o?.user?.id,h=r?.entity?.metadata,u=d&&a?Ll(h?.sandboxMap?.[d]?.[a]):{},f=Object.values(u),p=(f.find(Rk)??f[0])?.previewUrl??null,g=Os(),x=r?.entity?.organization_id??"";let v;e[0]!==l.slug||e[1]!==x?(v={connectionId:b9,orgId:x,orgSlug:l.slug},e[0]=l.slug,e[1]=x,e[2]=v):v=e[2];const _=pt(v),b=Y9(_);let y;e[3]!==a||e[4]!==b||e[5]!==c?(y=()=>{if(!c)return;const V={virtualMcpId:c};a&&(V.branch=a),b.mutate(V)},e[3]=a,e[4]=b,e[5]=c,e[6]=y):y=e[6];const L=y,w=!!c&&!!a&&Za.isStopped(c,a),S=u2({previewUrl:p,appPaused:g.status.state==="paused",userStopped:w,startError:b.isError&&b.error?f2(b.error.message):null});if(S.kind!=="iframe"){const V=`/${l.slug}/settings/connections`;let k;return e[7]!==S||e[8]!==V||e[9]!==L||e[10]!==g.lifecycle||e[11]!==g.phase?(k=i.jsx(eN,{state:S,claimPhase:g.phase,lifecycle:g.lifecycle,onStart:L,connectionsHref:V}),e[7]=S,e[8]=V,e[9]=L,e[10]=g.lifecycle,e[11]=g.phase,e[12]=k):k=e[12],k}if(!c||!a){let V;return e[13]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx(Mn,{title:"Waiting for sandbox context…"}),e[13]=V):V=e[13],V}let j;return e[14]!==a||e[15]!==n||e[16]!==l.slug||e[17]!==p||e[18]!==c?(j=i.jsx(Ik,{orgSlug:l.slug,virtualMcpId:c,branch:a,previewUrl:p,mode:n}),e[14]=a,e[15]=n,e[16]=l.slug,e[17]=p,e[18]=c,e[19]=j):j=e[19],j}function Rk(t){return t.sandboxProviderKind!=="user-desktop"}const Wh=2e3,Pk=15;function qh(t,e,s,n){return typeof e!="string"||s&&(H2(e,s,n)||t.state.dataUpdateCount>=Pk)?!1:Wh}function Ik({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,mode:r}){const o=y3(),a={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n},{data:l,isLoading:c}=Ml(a),[d,h]=C.useState("pages"),[u,f]=C.useState(()=>r==="blocks"?Ac(o.state.target):null),[m,p]=C.useState(()=>r==="blocks"?o.state.editSeoPageKey:null),g=Ak(o.state.target),[x,v]=C.useState(g);if(r==="blocks"&&x!==g){v(g);const re=Ac(o.state.target);f(re),(re?.collection==="pages"||re?.collection==="sections")&&h(re.collection)}const[_,b]=C.useState(o.state.editSeoPageKey);if(r==="blocks"&&_!==o.state.editSeoPageKey&&(b(o.state.editSeoPageKey),o.state.editSeoPageKey)){const re=o.state.target;re?.kind==="page"&&(h("pages"),f(Ac(re)),p(re.key))}const[y,L]=C.useState(""),[w,S]=C.useState(null),[j,V]=C.useState(null),[k,T]=C.useState("date-desc"),[A,N]=C.useState(()=>new Set),[R,I]=C.useState(null),D=()=>{N(new Set),I(null)},E=re=>{f(re),p(null),!(r!=="blocks"||!re)&&(re.collection==="pages"?o.selectTarget({kind:"page",key:re.key,path:re.path}):re.collection==="sections"&&o.selectTarget({kind:"section",key:re.key}))},[P,M]=C.useState(d);P!==d&&(M(d),L(""),S(null),V(null),T("date-desc"),N(new Set),I(null));const{data:z,isLoading:$,isFetching:O}=Ol(a,{refetchInterval:re=>{const Le=re.state.data;if(d==="apps"&&u&&u.collection==="apps"){const Te=l?.[u.key];return qh(re,typeof Te?.__resolveType=="string"?Te.__resolveType:void 0,Le)}if(d==="site"&&l){const Te=Le?x0(l,Le):null,Oe=l.site,st=Te?.resolveType??(typeof Oe?.__resolveType=="string"?Oe.__resolveType:void 0);return qh(re,st,Le,["seo"])}return!1}}),U=(re,Le)=>!H2(re,z,Le)&&($||O),{catalog:H,isLoading:Y}=t7(z??void 0,l??void 0,{enabled:d==="apps"}),G=Bl(a),K=ML(a),q=KV(a),W=qV(a),[F,X]=C.useState(null),[Q,Z]=C.useState(),[J,ee]=C.useState(null),[te,ae]=C.useState(null),[se,oe]=C.useState(null);if(c||$)return i.jsx("div",{className:"h-full w-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})});if(!l||!z)return i.jsx(Mn,{title:"Could not load site data."});const ce=ld(l).sort((re,Le)=>re.name.localeCompare(Le.name)),fe=cd(l,z),be=d==="sections"?FL(z):[],_e=x0(l,z),xe=c3(l),Ve=Pd.some(re=>xe[re].length>0),Ne=to(d)?xe[d]:[],we=(Ve?bo(l,"categories"):[]).map(({key:re,payload:Le})=>{const Te=typeof Le.slug=="string"?Le.slug:"",Oe=typeof Le.name=="string"?Le.name:"";return{slug:Te||re,name:Oe||Te||re}}).filter(re=>re.slug).sort((re,Le)=>re.name.localeCompare(Le.name)),ye=d==="posts"&&(A.size>0||R!==null),$e=ye?u3(l).filter(re=>A.has(re.key)):[],Fe=Uh(z,"loaders"),pe=Uh(z,"actions");if(!ad(l,z)&&!Ve&&Fe===0&&pe===0)return i.jsx(Mn,{icon:fn,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, apps, loaders, or actions."});const Ee={pages:ce.length,sections:fe.length,apps:H.length,loaders:Fe,actions:pe,posts:xe.posts.length,authors:xe.authors.length,categories:xe.categories.length},De=new Set(ce.map(re=>ai(re.path))),he=new Set(ce.map(re=>re.name)),le=new Set(fe.map(re=>re.name)),ke=async re=>{const Le=l[re.key];if(!Le)return;const Te=op(l,re.key),Oe=x7(l,re.key,Math.max(0,Te-1)),st=v7(Le.sections,Oe);if(st)try{await G.mutateAsync({blockKey:re.key,data:{...Le,sections:st}}),de.success(`Variant added to "${re.name}"`),f({collection:"pages",key:re.key,path:re.path})}catch(ht){de.error(ht instanceof Error?ht.message:"Could not add variant")}},Be=()=>{Z(void 0),X({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},Ue=re=>{Z(void 0),X({mode:"duplicate",sourceKey:re.key,initialName:$h(he,re.name),initialPath:vV(De,re.path)})},it=re=>{Z(void 0),X({mode:"rename",sourceKey:re.key,initialName:re.name,initialPath:re.path})},Yt=async re=>{if(!F)return;const{mode:Le,sourceKey:Te}=F;try{if(Le==="create"){let Oe;if(re.templateKey){const ht=l[re.templateKey];if(!ht)throw new Error("Selected template no longer exists.");Oe={...ht,name:re.name,path:re.path}}else Oe=yV(re.name,re.path);const st=SV(l,re.name);await G.mutateAsync({blockKey:st,data:Oe}),de.success(`Created "${re.name}"`),f({collection:"pages",key:st,path:re.path})}else if(Le==="duplicate"&&Te){const Oe=l[Te];if(!Oe)throw new Error("Source page not found");const{key:st,data:ht}=bV({source:Oe,pages:ce,newName:re.name,newPath:re.path});await G.mutateAsync({blockKey:st,data:ht}),de.success(`Duplicated as "${re.name}"`),f({collection:"pages",key:st,path:re.path})}else if(Le==="rename"&&Te){const Oe=l[Te];if(!Oe)throw new Error("Page not found");const st={...Oe,name:re.name,path:re.path};await G.mutateAsync({blockKey:Te,data:st}),de.success("Page updated"),u?.collection==="pages"&&u.key===Te&&f({collection:"pages",key:Te,path:re.path})}X(null)}catch(Oe){Z(Oe instanceof Error?Oe.message:"Save failed")}},Rt=({path:re})=>{if(!F)return null;const Le=ai(re);return(F.mode==="rename"?ai(F.initialPath):null)!==Le&&De.has(Le)?`A page with path "${re}" already exists.`:null},rt=async(re,Le,Te)=>{await G.mutateAsync({blockKey:Le,data:{...Te,name:Le,__resolveType:re}}),de.success(`Created section "${Le}"`),f({collection:"sections",key:Le})},gt=lp((re,Le)=>G.mutate({blockKey:re,data:Le})),lt=async re=>{const Le=l[re.key];if(!Le){de.error("Section not found.");return}const Te=_V(l,re.key),Oe=$h(le,re.name),st={...Le,name:Oe};try{await G.mutateAsync({blockKey:Te,data:st}),de.success(`Duplicated "${re.name}"`),f({collection:"sections",key:Te})}catch(ht){de.error(ht instanceof Error?ht.message:"Duplicate failed")}},St=async re=>{if(!J)return;const Le=l[J];if(!Le){de.error("Section not found.");return}try{await G.mutateAsync({blockKey:J,data:{...Le,name:re}}),de.success("Section renamed"),ee(null)}catch(Te){de.error(Te instanceof Error?Te.message:"Rename failed")}},ct=async re=>{const Le=zh(l,re),Te=da(Le,re,OV(re));try{await q.mutateAsync({blockKey:Le,data:Te}),de.success(`Created ${eo[re]}`),f({collection:re,key:Le})}catch(Oe){de.error(Oe instanceof Error?Oe.message:"Could not create")}},me=async re=>{const Le=l[re.key];if(!Le){de.error("Record not found.");return}const Te=zh(l,re.kind),Oe=re.kind==="posts"?"title":"name",st={...structuredClone(Ca(Le,re.kind)),[Oe]:`${re.label} (copy)`};try{await q.mutateAsync({blockKey:Te,data:da(Te,re.kind,st)}),de.success(`Duplicated "${re.label}"`),f({collection:re.kind,key:Te})}catch(ht){de.error(ht instanceof Error?ht.message:"Duplicate failed")}},Me=re=>{N(Le=>{const Te=new Set(Le);return Te.has(re)?Te.delete(re):Te.add(re),Te})},et=re=>{h("posts"),M("posts"),f(null),p(null),L(""),S(null),V(null),T("date-desc"),N(new Set),I(re||null)},tt=async(re,Le)=>{const Te=[...A];let Oe=0;for(const st of Te){const ht=l[st],kn=Ca(ht,"posts"),Qn=re==="add"?IV(kn,Le):DV(kn,Le);Qn!==kn&&(await q.mutateAsync({blockKey:st,data:da(st,"posts",Qn)}),Oe+=1)}return Oe},vs=async(re,Le)=>{const Te=A.size;try{const Oe=await tt(re,Le),st=re==="add"?"Added to":"Moved",ht=Te-Oe;de.success(`${st} ${Oe} ${Oe===1?"post":"posts"}`+(ht>0?` (${ht} already set)`:"")),D()}catch(Oe){de.error(Oe instanceof Error?Oe.message:"Bulk update failed")}},us=async()=>{if(te)try{if(te.kind==="blog-bulk"){for(const Oe of te.keys)await W.mutateAsync({blockKey:Oe});de.success(`Deleted ${te.count} ${te.count===1?"post":"posts"}`),u&&u.collection!=="available-section"&&te.keys.includes(u.key)&&f(null),D(),ae(null);return}const{kind:re,key:Le,label:Te}=te;if(re==="blog"){if(te.blogKind==="categories"){const Oe=Ca(l[Le],"categories").slug,st=typeof Oe=="string"?Oe:"";if(st)for(const{key:ht,payload:kn}of bo(l,"posts")){const Qn=MV(kn,st);Qn!==kn&&await q.mutateAsync({blockKey:ht,data:da(ht,"posts",Qn)})}}await W.mutateAsync({blockKey:Le})}else await K.mutateAsync({blockKey:Le});de.success(`Deleted "${Te}"`),u&&u.collection!=="available-section"&&u.key===Le&&f(null),ae(null)}catch(re){de.error(re instanceof Error?re.message:"Delete failed")}},Jt=K.isPending||W.isPending||q.isPending,mn=te?.kind==="blog"?eo[te.blogKind]:te?.kind==="blog-bulk"?`${te.count} ${te.count===1?"post":"posts"}`:te?.kind??"item";return i.jsxs("div",{className:"flex h-full w-full",children:[r==="content"&&i.jsx(Mk,{active:d,counts:Ee,showBlog:Ve,onSelect:re=>{h(re),f(null),p(null)}}),d!=="seo"&&d!=="site"&&d!=="calendar"&&d!=="loaders"&&d!=="actions"&&i.jsx(Ok,{blocksMode:r==="blocks",activeCollection:d,pages:ce,sections:fe,availableSections:be,appCatalog:H,appCatalogLoading:Y,blogEntries:Ne,decofile:l,searchQuery:y,onSearchChange:L,postCategoryFilter:w,postAuthorFilter:j,postSort:k,onPostCategoryFilterChange:re=>{S(re),N(new Set)},onPostAuthorFilterChange:re=>{V(re),N(new Set)},onPostSortChange:T,selectedPostKeys:A,postBulkPanelOpen:ye,onTogglePostSelect:Me,onSelectAllPosts:re=>N(new Set(re)),onClearPostSelection:()=>N(new Set),onExitPostSelection:D,onBulkDeletePosts:()=>ae({kind:"blog-bulk",keys:[...A],count:A.size}),selection:u,onSelect:E,onCollectionSelect:re=>{h(re),f(null),p(null)},onCreate:()=>{d==="pages"?Be():to(d)&&ct(d)},onDuplicatePage:Ue,onRenamePage:it,onAddPageVariant:ke,onDeletePage:re=>ae({kind:"page",key:re.key,label:re.name}),onEditPageSeo:re=>{const Le={collection:"pages",key:re.key,path:re.path};f(Le),p(re.key),r==="blocks"&&o.editSeo({kind:"page",key:re.key,path:re.path})},onViewPageJson:re=>oe(re.key),onDuplicateSection:lt,onRenameSection:re=>ee(re.key),onDeleteSection:re=>ae({kind:"section",key:re.key,label:re.name}),onDuplicateBlog:me,onDeleteBlog:re=>ae({kind:"blog",blogKind:re.kind,key:re.key,label:re.label})}),i.jsx("div",{className:"flex-1 min-w-0",children:d==="loaders"||d==="actions"?i.jsx(dk,{orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:z,decofile:l,kind:d}):i.jsx(C.Suspense,{fallback:i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),children:d==="calendar"?i.jsx(Nk,{decofile:l}):d==="site"?_e?i.jsx(Kh,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:_e.key,block:l[_e.key],decofile:l,meta:z,title:"Site",excludeFields:["seo"],schemaPending:U(_e.resolveType,["seo"]),previewBaseUrl:n},`site:${_e.key}`):i.jsx(Mn,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):d==="seo"?i.jsx(kk,{orgSlug:t,virtualMcpId:e,branch:s,decofile:l,meta:z,target:{kind:"site"},previewBaseUrl:n}):d==="sections"?i.jsx(Dk,{selection:u?.collection==="sections"||u?.collection==="available-section"?u:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:z,decofile:l,isCreating:G.isPending,onCreateAvailable:rt,onSaveReferencedBlock:gt}):ye?i.jsx(Ck,{posts:$e,categories:we,initialSlug:R,isPending:q.isPending,onApply:(re,Le)=>{vs(re,Le)},onClose:D},R??"selection"):u&&u.collection!=="available-section"?u.collection==="apps"?i.jsx(Kh,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:z,previewBaseUrl:n,schemaPending:U(typeof l[u.key]?.__resolveType=="string"?String(l[u.key].__resolveType):void 0)},`app:${u.key}`):u.collection==="posts"?i.jsx(Sk,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:z,previewBaseUrl:n},`post:${u.key}`):u.collection==="categories"?i.jsx(jk,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:z,onManagePosts:et,onOpenPost:re=>{h("posts"),M("posts"),f({collection:"posts",key:re}),p(null)},previewBaseUrl:n},`category:${u.key}`):u.collection==="authors"?i.jsx(wk,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:u.key,block:l[u.key]},`authors:${u.key}`):i.jsx(Vk,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:n??void 0,currentPath:u.collection==="pages"?u.path:"/",activePageBlockKey:u.collection==="pages"?u.key:null,activeGlobalBlockKey:u.collection==="sections"?u.key:null,initialEditSeo:u.collection==="pages"&&m===u.key,onExitSeo:()=>{p(null),r==="blocks"&&o.consumeEditSeo()},onSaved:r==="blocks"?o.notifySaved:void 0},u.collection==="pages"?`page:${u.key}`:`section:${u.key}`):i.jsx(Mn,{title:`Select ${to(d)?`a ${eo[d]}`:d==="pages"?"a page":d==="apps"?"an app":"a section"} to edit`,description:d==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),F&&i.jsx(kV,{open:!!F,mode:F.mode,initialName:F.initialName,initialPath:F.initialPath,isPending:G.isPending,error:Q,templates:ce,validate:Rt,onSubmit:Yt,onOpenChange:re=>{re||(X(null),Z(void 0))}}),J&&i.jsx(NV,{open:!!J,blockKey:J,initialName:fe.find(re=>re.key===J)?.name??J,isPending:G.isPending,onSubmit:St,onOpenChange:re=>{re||ee(null)}}),se&&i.jsx(GV,{open:!!se,onOpenChange:re=>{re||oe(null)},pageKey:se,decofile:l}),i.jsx(Fa,{open:!!te,onOpenChange:re=>{!re&&!Jt&&ae(null)},children:i.jsxs(Ua,{children:[i.jsxs(Ha,{children:[i.jsx(Ka,{children:`Delete ${mn}?`}),i.jsx(Wa,{children:te?.kind==="section"?`"${te.label}" will be removed. Pages that still reference it will lose this section.`:te?.kind==="blog-bulk"?`${te.count} ${te.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:te?`"${te.label}" will be removed permanently. This can't be undone.`:null})]}),i.jsxs(qa,{children:[i.jsx(Ga,{disabled:Jt,children:"Cancel"}),i.jsx(Ya,{onClick:re=>{re.preventDefault(),us()},disabled:Jt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Jt?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function Dk(t){const e=B.c(30),{selection:s,orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,isCreating:d,onCreateAvailable:h,onSaveReferencedBlock:u}=t;if(!s){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Mn,{title:"Select a section to edit",description:"Pick a saved section to edit it, or an available one to customize and save as global."}),e[0]=p):p=e[0],p}if(s.collection==="available-section"){const p=`available:${s.resolveType}`,g=s.resolveType,x=s.title;let v;e[1]!==s.title?(v=ap(s.title),e[1]=s.title,e[2]=v):v=e[2];let _;e[3]!==h||e[4]!==s.resolveType?(_=(y,L)=>h(s.resolveType,y,L),e[3]=h,e[4]=s.resolveType,e[5]=_):_=e[5];let b;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==l||e[10]!==u||e[11]!==n||e[12]!==a||e[13]!==s.resolveType||e[14]!==s.title||e[15]!==p||e[16]!==v||e[17]!==_||e[18]!==r?(b=i.jsx(ZC,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,resolveType:g,title:x,defaultBlockId:v,isCreating:d,onCreate:_,onSaveReferencedBlock:u},p),e[6]=o,e[7]=c,e[8]=d,e[9]=l,e[10]=u,e[11]=n,e[12]=a,e[13]=s.resolveType,e[14]=s.title,e[15]=p,e[16]=v,e[17]=_,e[18]=r,e[19]=b):b=e[19],b}const f=`saved:${s.key}`;let m;return e[20]!==o||e[21]!==c||e[22]!==l||e[23]!==u||e[24]!==n||e[25]!==a||e[26]!==s.key||e[27]!==f||e[28]!==r?(m=i.jsx(nV,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,blockKey:s.key,onSaveReferencedBlock:u},f),e[20]=o,e[21]=c,e[22]=l,e[23]=u,e[24]=n,e[25]=a,e[26]=s.key,e[27]=f,e[28]=r,e[29]=m):m=e[29],m}function Gh(t){const e=B.c(8),{icon:s,label:n,className:r}=t;let o;e[0]!==r?(o=ne("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=i.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==n||e[5]!==o||e[6]!==a?(l=i.jsxs("div",{className:o,children:[a,n]}),e[4]=n,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function Mk(t){const e=B.c(47),{active:s,counts:n,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:i.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let c;e[1]!==n.pages||e[2]!==o||e[3]!==l?(c=i.jsx($s,{id:"pages",icon:Dn,label:"Pages",count:n.pages,active:l,onSelect:o}),e[1]=n.pages,e[2]=o,e[3]=l,e[4]=c):c=e[4];const d=s==="sections";let h;e[5]!==n.sections||e[6]!==o||e[7]!==d?(h=i.jsx($s,{id:"sections",icon:on,label:"Sections",count:n.sections,active:d,onSelect:o}),e[5]=n.sections,e[6]=o,e[7]=d,e[8]=h):h=e[8];const u=s==="apps";let f;e[9]!==n.apps||e[10]!==o||e[11]!==u?(f=i.jsx($s,{id:"apps",icon:N1,label:"Apps",count:n.apps,active:u,onSelect:o}),e[9]=n.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];const m=s==="loaders";let p;e[13]!==n.loaders||e[14]!==o||e[15]!==m?(p=i.jsx($s,{id:"loaders",icon:$a,label:"Loaders",count:n.loaders,active:m,onSelect:o}),e[13]=n.loaders,e[14]=o,e[15]=m,e[16]=p):p=e[16];const g=s==="actions";let x;e[17]!==n.actions||e[18]!==o||e[19]!==g?(x=i.jsx($s,{id:"actions",icon:ui,label:"Actions",count:n.actions,active:g,onSelect:o}),e[17]=n.actions,e[18]=o,e[19]=g,e[20]=x):x=e[20];const v=s==="site";let _;e[21]!==o||e[22]!==v?(_=i.jsx($s,{id:"site",icon:rm,label:"Site",active:v,onSelect:o}),e[21]=o,e[22]=v,e[23]=_):_=e[23];const b=s==="seo";let y;e[24]!==o||e[25]!==b?(y=i.jsx($s,{id:"seo",icon:Ba,label:"SEO",active:b,onSelect:o}),e[24]=o,e[25]=b,e[26]=y):y=e[26];const L=s==="calendar";let w;e[27]!==o||e[28]!==L?(w=i.jsx($s,{id:"calendar",icon:wm,label:"Calendar",active:L,onSelect:o}),e[27]=o,e[28]=L,e[29]=w):w=e[29];let S;e[30]!==s||e[31]!==n.authors||e[32]!==n.categories||e[33]!==n.posts||e[34]!==o||e[35]!==r?(S=r&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[i.jsx(Ki,{size:13,className:"shrink-0"}),"Blog"]}),i.jsx($s,{id:"posts",icon:Wi,label:"Posts",count:n.posts,active:s==="posts",onSelect:o}),i.jsx($s,{id:"authors",icon:B9,label:"Authors",count:n.authors,active:s==="authors",onSelect:o}),i.jsx($s,{id:"categories",icon:im,label:"Categories",count:n.categories,active:s==="categories",onSelect:o})]}),e[30]=s,e[31]=n.authors,e[32]=n.categories,e[33]=n.posts,e[34]=o,e[35]=r,e[36]=S):S=e[36];let j;return e[37]!==x||e[38]!==_||e[39]!==y||e[40]!==w||e[41]!==S||e[42]!==c||e[43]!==h||e[44]!==f||e[45]!==p?(j=i.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,i.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[c,h,f,p,x,_,y,w,S]})]}),e[37]=x,e[38]=_,e[39]=y,e[40]=w,e[41]=S,e[42]=c,e[43]=h,e[44]=f,e[45]=p,e[46]=j):j=e[46],j}function $s(t){const e=B.c(18),{id:s,icon:n,label:r,count:o,active:a,onSelect:l}=t;let c;e[0]!==s||e[1]!==l?(c=()=>l(s),e[0]=s,e[1]=l,e[2]=c):c=e[2];const d=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==d?(h=ne("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==n?(u=i.jsx(n,{size:16,className:"shrink-0"}),e[5]=n,e[6]=u):u=e[6];let f;e[7]!==r?(f=i.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&i.jsx("span",{className:ne("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==c||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=i.jsxs("button",{type:"button",onClick:c,className:h,children:[u,f,m]}),e[12]=c,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function Ok(t){const e=B.c(86),{blocksMode:s,activeCollection:n,pages:r,sections:o,availableSections:a,appCatalog:l,appCatalogLoading:c,blogEntries:d,decofile:h,searchQuery:u,onSearchChange:f,postCategoryFilter:m,postAuthorFilter:p,postSort:g,onPostCategoryFilterChange:x,onPostAuthorFilterChange:v,onPostSortChange:_,selectedPostKeys:b,postBulkPanelOpen:y,onTogglePostSelect:L,onSelectAllPosts:w,onClearPostSelection:S,onExitPostSelection:j,onBulkDeletePosts:V,selection:k,onSelect:T,onCollectionSelect:A,onCreate:N,onDuplicatePage:R,onRenamePage:I,onAddPageVariant:D,onDeletePage:E,onEditPageSeo:P,onViewPageJson:M,onDuplicateSection:z,onRenameSection:$,onDeleteSection:O,onDuplicateBlog:U,onDeleteBlog:H}=t;let Y,G,K,q,W,F,X,Q;if(e[0]!==n||e[1]!==l||e[2]!==c||e[3]!==a||e[4]!==s||e[5]!==d||e[6]!==h||e[7]!==D||e[8]!==V||e[9]!==S||e[10]!==A||e[11]!==N||e[12]!==H||e[13]!==E||e[14]!==O||e[15]!==U||e[16]!==R||e[17]!==z||e[18]!==P||e[19]!==j||e[20]!==v||e[21]!==x||e[22]!==_||e[23]!==I||e[24]!==$||e[25]!==f||e[26]!==T||e[27]!==w||e[28]!==L||e[29]!==M||e[30]!==r||e[31]!==p||e[32]!==y||e[33]!==m||e[34]!==g||e[35]!==u||e[36]!==o||e[37]!==b||e[38]!==k){const te=u.toLowerCase(),ae=r.filter(me=>!te||me.name.toLowerCase().includes(te)||me.path.toLowerCase().includes(te)),se=o.filter(me=>!te||me.name.toLowerCase().includes(te)||me.key.toLowerCase().includes(te)||me.resolveType.toLowerCase().includes(te)),oe=a.filter(me=>!te||me.title.toLowerCase().includes(te)||me.resolveType.toLowerCase().includes(te)||(me.description?.toLowerCase().includes(te)??!1)),ce=Ek(se),fe=l.filter(me=>!te||me.title.toLowerCase().includes(te)||me.app.toLowerCase().includes(te)||me.vendor.toLowerCase().includes(te)||me.category.toLowerCase().includes(te)),be=d.filter(me=>!te||me.label.toLowerCase().includes(te)||me.subtitle.toLowerCase().includes(te)),_e=n==="posts",xe=Fk,Ve=_e?u3(h):[],Ne=new Map,we=new Map;for(const me of Ve){for(const Me of me.categorySlugs)Ne.set(Me,(Ne.get(Me)??0)+1);for(const Me of me.authorEmails)we.set(Me,(we.get(Me)??0)+1)}const ye=(_e?bo(h,"categories"):[]).map(me=>{const{key:Me,payload:et}=me,tt=xe(et.slug)||Me;return{slug:tt,name:xe(et.name)||xe(et.slug)||Me,count:Ne.get(tt)??0}}).filter(zk),$e=(_e?bo(h,"authors"):[]).map(me=>{const{key:Me,payload:et}=me,tt=xe(et.email);return{email:tt,name:xe(et.name)||xe(et.email)||Me,count:we.get(tt)??0}}).filter(Bk);let Fe;e[47]!==m?(Fe=me=>!m||me.categorySlugs.includes(m),e[47]=m,e[48]=Fe):Fe=e[48];let pe;e[49]!==p?(pe=me=>!p||me.authorEmails.includes(p),e[49]=p,e[50]=pe):pe=e[50];let Ee;e[51]!==g?(Ee=(me,Me)=>{if(g==="az")return me.title.localeCompare(Me.title);if(g==="za")return Me.title.localeCompare(me.title);const et=me.date.localeCompare(Me.date);return g==="date-asc"?et:-et},e[51]=g,e[52]=Ee):Ee=e[52];const De=Ve.filter(me=>!te||me.title.toLowerCase().includes(te)||me.slug.toLowerCase().includes(te)).filter(Fe).filter(pe).sort(Ee),he=b.size,le=De.map($k),ke=le.length>0&&le.every(me=>b.has(me)),Be=he>0||y,Ue=()=>{ke?S():w(le)},it=`Search ${n}…`,Yt=to(n)?`Create new ${eo[n]}`:"Create new page",Rt=n!=="apps"&&n!=="sections",rt=s?"w-[240px]":"w-[300px]";e[53]!==rt?(W=ne("shrink-0 border-r flex flex-col min-h-0",rt),e[53]=rt,e[54]=W):W=e[54],e[55]!==n||e[56]!==s||e[57]!==A?(F=s&&i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[i.jsxs(ie,{variant:n==="pages"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("pages"),children:[i.jsx(Dn,{size:14}),"Pages"]}),i.jsxs(ie,{variant:n==="sections"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("sections"),children:[i.jsx(on,{size:14}),"Sections"]})]}),e[55]=n,e[56]=s,e[57]=A,e[58]=F):F=e[58];let gt;e[59]===Symbol.for("react.memo_cache_sentinel")?(gt=i.jsx($9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[59]=gt):gt=e[59];let lt;e[60]!==f?(lt=me=>f(me.target.value),e[60]=f,e[61]=lt):lt=e[61];let St;e[62]!==it||e[63]!==u||e[64]!==lt?(St=i.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[gt,i.jsx("input",{type:"text",value:u,onChange:lt,placeholder:it,"aria-label":it,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[62]=it,e[63]=u,e[64]=lt,e[65]=St):St=e[65];let ct;e[66]!==Yt||e[67]!==N||e[68]!==Rt?(ct=Rt&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:N,"aria-label":Yt,children:i.jsx(Lt,{size:14})})}),i.jsx(Pe,{side:"bottom",children:Yt})]}),e[66]=Yt,e[67]=N,e[68]=Rt,e[69]=ct):ct=e[69],e[70]!==St||e[71]!==ct?(X=i.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[St,ct]}),e[70]=St,e[71]=ct,e[72]=X):X=e[72],Q=_e&&(Be?i.jsx(Xk,{count:he,allSelected:ke,onToggleSelectAll:Ue,onDelete:V,onExit:j}):i.jsx(Hk,{categories:ye,authors:$e,categoryFilter:m,authorFilter:p,sort:g,onCategoryFilterChange:x,onAuthorFilterChange:v,onSortChange:_})),Y=Sn,q="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",G="flex flex-col gap-1 p-1.5",K=n==="pages"?ae.length===0?i.jsx(Cr,{hasItems:r.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):ae.map(me=>{const Me=k?.collection==="pages"&&k.key===me.key,et=op(h,me.key);return i.jsx(tn,{icon:Dn,title:me.name,subtitle:me.path,active:Me,variantCount:et,onClick:()=>T({collection:"pages",key:me.key,path:me.path}),menu:i.jsx(ha,{onDuplicate:()=>R(me),onRename:()=>I(me),onAddVariant:()=>D(me),onEditSeo:()=>P(me),onViewJson:()=>M(me),onDelete:()=>E(me)})},me.key)}):n==="sections"?se.length===0&&oe.length===0?i.jsx(Cr,{hasItems:o.length>0||a.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):i.jsxs(i.Fragment,{children:[ce.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(Gh,{icon:on,label:"Saved sections"}),ce.map(me=>i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:me.label}),me.sections.map(Me=>{const et=k?.collection==="sections"&&k.key===Me.key;return i.jsx(tn,{icon:on,accent:"global",title:Me.name,subtitle:me.label,active:et,onClick:()=>T({collection:"sections",key:Me.key}),menu:i.jsx(ha,{onDuplicate:()=>z(Me),onRename:()=>$(Me),onDelete:()=>O(Me)})},Me.key)})]},me.label))]}),oe.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(Gh,{icon:Dn,label:"Available sections",className:ne(ce.length>0&&"mt-3")}),oe.map(me=>{const Me=k?.collection==="available-section"&&k.resolveType===me.resolveType,et=me.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return i.jsx(tn,{icon:Dn,title:me.title,subtitle:et??me.resolveType,active:Me,onClick:()=>T({collection:"available-section",resolveType:me.resolveType,title:me.title})},me.resolveType)})]})]}):n==="apps"?c?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(qe,{size:18,className:"animate-spin text-muted-foreground"})}):fe.length===0?i.jsx(Cr,{hasItems:l.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):fe.map(me=>{const Me=k?.collection==="apps"&&me.blockKey!==null&&k.key===me.blockKey;return i.jsx(tn,{icon:N1,logoUrl:me.logo,title:me.title,subtitle:me.category,active:Me,trailing:me.installed?i.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",children:"Installed"}):void 0,onClick:()=>{if(!me.installed||!me.blockKey){de.message(`${me.title} is not installed on this site.`);return}T({collection:"apps",key:me.blockKey})}},me.id)}):_e?De.length===0?i.jsx(Cr,{hasItems:Ve.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):De.map(me=>{const Me={key:me.key,kind:"posts",label:me.title,subtitle:me.slug};return i.jsx(tn,{icon:Wi,title:me.title,subtitle:me.slug,active:k?.collection==="posts"&&k.key===me.key,selectable:!0,selectionActive:Be,selected:b.has(me.key),onToggleSelect:()=>L(me.key),onClick:()=>Be?L(me.key):T({collection:"posts",key:me.key}),menu:i.jsx(ha,{onDuplicate:()=>U(Me),onDelete:()=>H(Me)})},me.key)}):be.length===0?i.jsx(Cr,{hasItems:d.length>0,emptyLabel:`No ${n} yet.`,emptyHint:`Click "+" to create your first ${to(n)?eo[n]:"item"}.`}):be.map(me=>{const Me=k?.collection===me.kind&&k.key===me.key;return i.jsx(tn,{icon:me.kind==="posts"?Wi:me.kind==="authors"?B9:im,title:me.label,subtitle:me.subtitle,active:Me,onClick:()=>T({collection:me.kind,key:me.key}),menu:i.jsx(ha,{onDuplicate:()=>U(me),onDelete:()=>H(me)})},me.key)}),e[0]=n,e[1]=l,e[2]=c,e[3]=a,e[4]=s,e[5]=d,e[6]=h,e[7]=D,e[8]=V,e[9]=S,e[10]=A,e[11]=N,e[12]=H,e[13]=E,e[14]=O,e[15]=U,e[16]=R,e[17]=z,e[18]=P,e[19]=j,e[20]=v,e[21]=x,e[22]=_,e[23]=I,e[24]=$,e[25]=f,e[26]=T,e[27]=w,e[28]=L,e[29]=M,e[30]=r,e[31]=p,e[32]=y,e[33]=m,e[34]=g,e[35]=u,e[36]=o,e[37]=b,e[38]=k,e[39]=Y,e[40]=G,e[41]=K,e[42]=q,e[43]=W,e[44]=F,e[45]=X,e[46]=Q}else Y=e[39],G=e[40],K=e[41],q=e[42],W=e[43],F=e[44],X=e[45],Q=e[46];let Z;e[73]!==G||e[74]!==K?(Z=i.jsx("div",{className:G,children:K}),e[73]=G,e[74]=K,e[75]=Z):Z=e[75];let J;e[76]!==Y||e[77]!==q||e[78]!==Z?(J=i.jsx(Y,{className:q,children:Z}),e[76]=Y,e[77]=q,e[78]=Z,e[79]=J):J=e[79];let ee;return e[80]!==W||e[81]!==F||e[82]!==X||e[83]!==Q||e[84]!==J?(ee=i.jsxs("div",{className:W,children:[F,X,Q,J]}),e[80]=W,e[81]=F,e[82]=X,e[83]=Q,e[84]=J,e[85]=ee):ee=e[85],ee}function $k(t){return t.key}function Bk(t){return t.email}function zk(t){return t.slug}function Fk(t){return typeof t=="string"?t:""}const Yh="__all__",S3={"date-desc":"Newest first","date-asc":"Oldest first",az:"Title A–Z",za:"Title Z–A"},Uk={"date-desc":"Newest","date-asc":"Oldest",az:"A–Z",za:"Z–A"},Jh=C.forwardRef(function(e,s){const n=B.c(20);let r,o,a,l,c;n[0]!==e?({icon:r,active:o,value:c,className:a,...l}=e,n[0]=e,n[1]=r,n[2]=o,n[3]=a,n[4]=l,n[5]=c):(r=n[1],o=n[2],a=n[3],l=n[4],c=n[5]);const d=o?"text-foreground":"text-muted-foreground";let h;n[6]!==a||n[7]!==d?(h=ne("h-7 gap-1 px-1.5 text-xs",d,a),n[6]=a,n[7]=d,n[8]=h):h=n[8];let u;n[9]!==r?(u=i.jsx(r,{size:14,className:"shrink-0"}),n[9]=r,n[10]=u):u=n[10];let f;n[11]!==c?(f=c&&i.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),n[11]=c,n[12]=f):f=n[12];let m;n[13]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Ht,{size:12,className:"shrink-0 opacity-60"}),n[13]=m):m=n[13];let p;return n[14]!==l||n[15]!==s||n[16]!==h||n[17]!==u||n[18]!==f?(p=i.jsxs(ie,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),n[14]=l,n[15]=s,n[16]=h,n[17]=u,n[18]=f,n[19]=p):p=n[19],p});function w3(t){const e=B.c(2),{count:s}=t;let n;return e[0]!==s?(n=i.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=n):n=e[1],n}function Hk(t){const e=B.c(60),{categories:s,authors:n,categoryFilter:r,authorFilter:o,sort:a,onCategoryFilterChange:l,onAuthorFilterChange:c,onSortChange:d}=t;let h;if(e[0]!==s||e[1]!==r){let H;e[3]!==r?(H=Y=>Y.slug===r,e[3]=r,e[4]=H):H=e[4],h=s.find(H),e[0]=s,e[1]=r,e[2]=h}else h=e[2];const u=h;let f;if(e[5]!==o||e[6]!==n){let H;e[8]!==o?(H=Y=>Y.email===o,e[8]=o,e[9]=H):H=e[9],f=n.find(H),e[5]=o,e[6]=n,e[7]=f}else f=e[7];const m=f,p=!!(r||o),g=u?.name??m?.name??"Filter",x=r?`cat:${r}`:o?`author:${o}`:Yh;let v;e[10]!==c||e[11]!==l?(v=()=>{l(null),c(null)},e[10]=c,e[11]=l,e[12]=v):v=e[12];const _=v;let b;e[13]!==_||e[14]!==c||e[15]!==l?(b=H=>{H.startsWith("cat:")?(c(null),l(H.slice(4))):H.startsWith("author:")?(l(null),c(H.slice(7))):_()},e[13]=_,e[14]=c,e[15]=l,e[16]=b):b=e[16];const y=b;let L;e[17]!==g||e[18]!==p?(L=i.jsx(es,{asChild:!0,children:i.jsx(Jh,{icon:hx,active:p,value:g,className:"min-w-0 shrink"})}),e[17]=g,e[18]=p,e[19]=L):L=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(Ir,{children:"Filter by"}),e[20]=w):w=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(Po,{value:Yh,children:"All posts"}),e[21]=S):S=e[21];let j;e[22]!==s.length?(j=s.length>0&&i.jsx(Ir,{className:"text-muted-foreground/70",children:"Category"}),e[22]=s.length,e[23]=j):j=e[23];let V;e[24]!==s?(V=s.map(qk),e[24]=s,e[25]=V):V=e[25];let k;e[26]!==n.length?(k=n.length>0&&i.jsx(Ir,{className:"text-muted-foreground/70",children:"Author"}),e[26]=n.length,e[27]=k):k=e[27];let T;e[28]!==n?(T=n.map(Wk),e[28]=n,e[29]=T):T=e[29];let A;e[30]!==x||e[31]!==y||e[32]!==k||e[33]!==T||e[34]!==j||e[35]!==V?(A=i.jsxs(ts,{align:"start",className:"max-h-96 w-60 overflow-y-auto",children:[w,i.jsxs(l0,{value:x,onValueChange:y,children:[S,j,V,k,T]})]}),e[30]=x,e[31]=y,e[32]=k,e[33]=T,e[34]=j,e[35]=V,e[36]=A):A=e[36];let N;e[37]!==A||e[38]!==L?(N=i.jsxs(Zt,{children:[L,A]}),e[37]=A,e[38]=L,e[39]=N):N=e[39];let R;e[40]!==_||e[41]!==p?(R=p&&i.jsx(Gk,{label:"Clear filter",onClick:_}),e[40]=_,e[41]=p,e[42]=R):R=e[42];const I=Uk[a];let D;e[43]!==I?(D=i.jsx(es,{asChild:!0,children:i.jsx(Jh,{icon:fx,active:!0,value:I})}),e[43]=I,e[44]=D):D=e[44];let E;e[45]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsx(Ir,{children:"Sort by"}),e[45]=E):E=e[45];let P;e[46]!==d?(P=H=>d(H),e[46]=d,e[47]=P):P=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(S3),e[48]=M):M=e[48];let z;e[49]===Symbol.for("react.memo_cache_sentinel")?(z=M.map(Kk),e[49]=z):z=e[49];let $;e[50]!==a||e[51]!==P?($=i.jsxs(ts,{align:"end",className:"w-44",children:[E,i.jsx(l0,{value:a,onValueChange:P,children:z})]}),e[50]=a,e[51]=P,e[52]=$):$=e[52];let O;e[53]!==D||e[54]!==$?(O=i.jsx("div",{className:"ml-auto shrink-0",children:i.jsxs(Zt,{children:[D,$]})}),e[53]=D,e[54]=$,e[55]=O):O=e[55];let U;return e[56]!==N||e[57]!==R||e[58]!==O?(U=i.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden border-b px-2 py-1.5",children:[N,R,O]}),e[56]=N,e[57]=R,e[58]=O,e[59]=U):U=e[59],U}function Kk(t){return i.jsx(Po,{value:t,children:S3[t]},t)}function Wk(t){return i.jsxs(Po,{value:`author:${t.email}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(w3,{count:t.count})]},`author:${t.email}`)}function qk(t){return i.jsxs(Po,{value:`cat:${t.slug}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(w3,{count:t.count})]},`cat:${t.slug}`)}function Gk(t){const e=B.c(4),{label:s,onClick:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(ms,{size:12}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==n?(o=i.jsx("button",{type:"button","aria-label":s,onClick:n,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:r}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function Yk(t){const e=B.c(12),{checked:s,disabled:n,onToggle:r}=t;let o;e[0]!==r?(o=()=>r(),e[0]=r,e[1]=o):o=e[1];const a=s?"Deselect all posts":"Select all posts";let l;e[2]!==s||e[3]!==n||e[4]!==o||e[5]!==a?(l=i.jsx(Re,{asChild:!0,children:i.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:Jk,children:i.jsx(cr,{checked:s,disabled:n,onCheckedChange:o,"aria-label":a})})}),e[2]=s,e[3]=n,e[4]=o,e[5]=a,e[6]=l):l=e[6];const c=s?"Deselect all":"Select all";let d;e[7]!==c?(d=i.jsx(Pe,{side:"bottom",children:c}),e[7]=c,e[8]=d):d=e[8];let h;return e[9]!==l||e[10]!==d?(h=i.jsxs(Ie,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=h):h=e[11],h}function Jk(t){return t.stopPropagation()}function Xk(t){const e=B.c(25),{count:s,allSelected:n,onToggleSelectAll:r,onDelete:o,onExit:a}=t;let l;e[0]!==n||e[1]!==r?(l=i.jsx(Yk,{checked:n,onToggle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;e[3]!==s?(c=i.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s," selected"]}),e[3]=s,e[4]=c):c=e[4];const d=s===0;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(ws,{size:14}),e[5]=h):h=e[5];let u;e[6]!==o||e[7]!==d?(u=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:d,onClick:o,"aria-label":"Delete selected posts",children:h})}),e[6]=o,e[7]=d,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Pe,{side:"bottom",children:"Delete selected"}),e[9]=f):f=e[9];let m;e[10]!==u?(m=i.jsxs(Ie,{children:[u,f]}),e[10]=u,e[11]=m):m=e[11];let p;e[12]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(ms,{size:14}),e[12]=p):p=e[12];let g;e[13]!==a?(g=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,"aria-label":"Exit selection",children:p})}),e[13]=a,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Pe,{side:"bottom",children:"Exit selection"}),e[15]=x):x=e[15];let v;e[16]!==g?(v=i.jsxs(Ie,{children:[g,x]}),e[16]=g,e[17]=v):v=e[17];let _;e[18]!==v||e[19]!==m?(_=i.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m,v]}),e[18]=v,e[19]=m,e[20]=_):_=e[20];let b;return e[21]!==l||e[22]!==_||e[23]!==c?(b=i.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[l,c,_]}),e[21]=l,e[22]=_,e[23]=c,e[24]=b):b=e[24],b}function tn(t){const e=B.c(37),{icon:s,logoUrl:n,title:r,subtitle:o,active:a,accent:l,variantCount:c,trailing:d,selectable:h,selectionActive:u,selected:f,onToggleSelect:m,onClick:p,menu:g}=t,x=l==="global";let v;e[0]!==s||e[1]!==a||e[2]!==x||e[3]!==n||e[4]!==c?(v=c&&c>1?i.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(s,{size:16,className:"shrink-0",style:{color:w0}})}),i.jsxs(Pe,{side:"right",children:[c," variants"]})]})}):n?i.jsx("img",{src:n,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):i.jsx("span",{className:ne("flex size-8 shrink-0 items-center justify-center rounded-lg",x?"bg-global-section/15":"bg-muted"),children:i.jsx(s,{size:16,className:ne("shrink-0",!x&&(a?"text-accent-foreground":"text-muted-foreground")),style:x?{color:td}:void 0})}),e[0]=s,e[1]=a,e[2]=x,e[3]=n,e[4]=c,e[5]=v):v=e[5];const _=v,b=a?x?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":x?"hover:bg-global-section/10":"hover:bg-muted";let y;e[6]!==b?(y=ne("group relative flex min-w-0 items-center rounded-md transition-colors",b),e[6]=b,e[7]=y):y=e[7];let L;e[8]!==m||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==r?(L=h&&i.jsx("span",{className:ne("flex shrink-0 items-center pl-2.5 transition-opacity",f||u?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"),onClick:Qk,children:i.jsx(cr,{checked:f,onCheckedChange:()=>m?.(),"aria-label":`Select ${r}`})}),e[8]=m,e[9]=h,e[10]=f,e[11]=u,e[12]=r,e[13]=L):L=e[13];let w;e[14]!==r?(w=i.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[14]=r,e[15]=w):w=e[15];const S=a?"text-accent-foreground/70":"text-muted-foreground";let j;e[16]!==S?(j=ne("block truncate text-xs",S),e[16]=S,e[17]=j):j=e[17];let V;e[18]!==o||e[19]!==j?(V=i.jsx("span",{className:j,children:o}),e[18]=o,e[19]=j,e[20]=V):V=e[20];let k;e[21]!==w||e[22]!==V?(k=i.jsxs("span",{className:"min-w-0 flex-1",children:[w,V]}),e[21]=w,e[22]=V,e[23]=k):k=e[23];let T;e[24]!==p||e[25]!==_||e[26]!==k||e[27]!==d?(T=i.jsxs("button",{type:"button",onClick:p,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[_,k,d]}),e[24]=p,e[25]=_,e[26]=k,e[27]=d,e[28]=T):T=e[28];let A;e[29]!==a||e[30]!==g?(A=g&&i.jsx("div",{className:ne("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:g}),e[29]=a,e[30]=g,e[31]=A):A=e[31];let N;return e[32]!==T||e[33]!==A||e[34]!==y||e[35]!==L?(N=i.jsxs("div",{className:y,children:[L,T,A]}),e[32]=T,e[33]=A,e[34]=y,e[35]=L,e[36]=N):N=e[36],N}function Qk(t){return t.stopPropagation()}function ha(t){const e=B.c(21),{onDuplicate:s,onRename:n,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(es,{asChild:!0,children:i.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:Zk,children:i.jsx(Gn,{size:14})})}),e[0]=c):c=e[0];let d;e[1]!==n?(d=n&&i.jsxs(He,{onClick:n,children:[i.jsx(w9,{size:14}),"Rename"]}),e[1]=n,e[2]=d):d=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Ss,{size:14}),e[3]=h):h=e[3];let u;e[4]!==s?(u=i.jsxs(He,{onClick:s,children:[h,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),i.jsxs(He,{onClick:r,className:"cursor-pointer",style:{color:w0},children:[i.jsx(jm,{size:14,style:{color:w0}}),"Add variant"]})]}),e[6]=r,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=(o||a)&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),o&&i.jsxs(He,{onClick:o,children:[i.jsx(Ba,{size:14}),"Edit SEO"]}),a&&i.jsxs(He,{onClick:a,children:[i.jsx(Ao,{size:14}),"View JSON"]})]}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Di,{}),e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(ws,{size:14}),e[12]=g):g=e[12];let x;e[13]!==l?(x=i.jsxs(He,{onClick:l,className:"text-destructive focus:text-destructive",children:[g,"Delete"]}),e[13]=l,e[14]=x):x=e[14];let v;return e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==x?(v=i.jsxs(Zt,{children:[c,i.jsxs(ts,{align:"end",className:"w-44",children:[d,u,f,m,p,x]})]}),e[15]=d,e[16]=u,e[17]=f,e[18]=m,e[19]=x,e[20]=v):v=e[20],v}function Zk(t){return t.stopPropagation()}function Cr(t){const e=B.c(6),{hasItems:s,emptyLabel:n,emptyHint:r}=t;let o;e[0]!==r||e[1]!==n||e[2]!==s?(o=s?"No results match your search.":i.jsxs(i.Fragment,{children:[i.jsx("div",{children:n}),i.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=n,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function eN(t){const e=B.c(12),{state:s,claimPhase:n,lifecycle:r,onStart:o,connectionsHref:a}=t;switch(s.kind){case"starting":{let l;e[0]!==n||e[1]!==r?(l=n3({claimPhase:n,lifecycle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==l?(c=i.jsx(Bi,{kind:"starting",progress:l,claimPhase:n}),e[3]=n,e[4]=l,e[5]=c):c=e[5],c}case"suspended":{let l;return e[6]!==o?(l=i.jsx(Bi,{kind:"suspended",onResume:o}),e[6]=o,e[7]=l):l=e[7],l}case"errored":{let l;return e[8]!==a||e[9]!==o||e[10]!==s.error?(l=i.jsx(Bi,{kind:"errored",error:s.error,onRetry:o,connectionsHref:a}),e[8]=a,e[9]=o,e[10]=s.error,e[11]=l):l=e[11],l}}}function Mn(t){const e=B.c(10),{icon:s,title:n,description:r}=t;let o;e[0]!==s?(o=s&&i.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==n?(a=i.jsx("div",{children:n}),e[2]=n,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&i.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==a||e[8]!==l?(c=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}const tN=new Set(["clone-failed","install-failed","start-failed","crashed"]);function sN(t){return tN.has(t.lifecyclePhase)?{kind:"error",source:"sandbox"}:t.lifecyclePhase!=="running"?{kind:"loading"}:t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData?{kind:"error",source:"data"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty"}}const nN="https://github.com/decocms/blocks";function iN(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(mx,{size:48,className:"text-muted-foreground"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(qi,{image:e,title:"No editable Blocks found",description:"This project does not expose editable Blocks content yet. Learn how to add Blocks to your project.",actions:i.jsx(ie,{variant:"outline",size:"sm",asChild:!0,children:i.jsxs("a",{href:nN,target:"_blank",rel:"noreferrer",children:["View Blocks docs",i.jsx(wn,{size:14})]})})}),t[1]=s):s=t[1],s}function rN(t){const e=B.c(6),{source:s,onRetry:n}=t,r=s==="sandbox"?"The project preview could not start. Retry to make Blocks available.":"Studio could not load this project's Blocks metadata.";let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(fn,{size:48,className:"text-muted-foreground"}),e[0]=o):o=e[0];let a;e[1]!==n?(a=i.jsx(ie,{variant:"outline",size:"sm",onClick:n,children:"Retry"}),e[1]=n,e[2]=a):a=e[2];let l;return e[3]!==r||e[4]!==a?(l=i.jsx(qi,{image:o,title:"Blocks unavailable",description:r,actions:a}),e[3]=r,e[4]=a,e[5]=l):l=e[5],l}function pi(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}function j3(t){const e=B.c(28),{virtualMcpId:s}=t,{org:n}=Ae(),{currentBranch:r}=as(),o=Os(),a=dr(),l=o.lifecycle.phase==="running";let c;e[0]!==r||e[1]!==l||e[2]!==a||e[3]!==n||e[4]!==s?(c=r&&l?{orgSlug:n.slug,virtualMcpId:s,branch:r,previewUrl:a.previewUrl}:null,e[0]=r,e[1]=l,e[2]=a,e[3]=n,e[4]=s,e[5]=c):c=e[5];const d=c;let h;e[6]!==l?(h={fetchEnabled:l},e[6]=l,e[7]=h):h=e[7];const u=Ml(d,h);let f;e[8]!==l?(f={fetchEnabled:l},e[8]=l,e[9]=f):f=e[9];const m=Ol(d,f),p=u.data!==void 0;let g;e[10]!==u.data||e[11]!==u.status||e[12]!==m.data||e[13]!==m.status||e[14]!==o.lifecycle.phase||e[15]!==p?(g=sN({lifecyclePhase:o.lifecycle.phase,decofile:{status:u.status,hasData:p},meta:{status:m.status,hasData:m.data!==void 0},hasEditableContent:ad(u.data,m.data)}),e[10]=u.data,e[11]=u.status,e[12]=m.data,e[13]=m.status,e[14]=o.lifecycle.phase,e[15]=p,e[16]=g):g=e[16];const x=g;if(x.kind==="loading"){let _;return e[17]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(pi,{}),e[17]=_):_=e[17],_}if(x.kind==="empty"){let _;return e[18]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(iN,{}),e[18]=_):_=e[18],_}if(x.kind==="error"){let _;e[19]!==u||e[20]!==a||e[21]!==m||e[22]!==x.source?(_=()=>{if(x.source==="sandbox"){a.retry();return}Promise.all([u.refetch(),m.refetch()])},e[19]=u,e[20]=a,e[21]=m,e[22]=x.source,e[23]=_):_=e[23];const b=_;let y;return e[24]!==b||e[25]!==x.source?(y=i.jsx(rN,{source:x.source,onRetry:b}),e[24]=b,e[25]=x.source,e[26]=y):y=e[26],y}let v;return e[27]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx("div",{"data-testid":"blocks-panel",className:"h-full min-h-0 overflow-hidden",children:i.jsx(L3,{mode:"blocks"})}),e[27]=v):v=e[27],v}function Xh(t,e){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function oN(t){const e=B.c(10),s=F5[t];let n;e[0]!==t?(n=v1.sidePanelWidth(t),e[0]=t,e[1]=n):n=e[1];let r;e[2]!==s?(r=d=>Xh(d,s),e[2]=s,e[3]=r):r=e[3];const[o,a]=z4(n,r);let l;e[4]!==s||e[5]!==o?(l=Xh(o,s),e[4]=s,e[5]=o,e[6]=l):l=e[6];let c;return e[7]!==a||e[8]!==l?(c=[l,a],e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function aN(t){try{return JSON.parse(t)}catch{return null}}function lN(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,n=s?aN(s):null,r=e.structuredContent;return r==null?n:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?n??r:r}function ji(t){const e=lN(t);return e===null?null:e}function Md(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function cN(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],n=Md(s);return!n||!s?null:{number:n,htmlUrl:s}}const Qh=/[\r\n<>]/,dN=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Ko(t){const e=t?.userName?.trim();if(!e||Qh.test(e))return null;const s=t?.userEmail?.trim();return!s||Qh.test(s)?{userName:e}:dN.test(s)?{userName:e,userEmail:s}:{userName:e}}function uN(t){return t.split(`
|
|
24
|
+
`}),e[26]=y):y=e[26];let L;return e[27]!==b||e[28]!==h?(L=i.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,b,y]}),e[27]=b,e[28]=h,e[29]=L):L=e[29],L}function ca(t){const e=B.c(10),{phase:s,current:n,children:r}=t,o=s-n,a=o<0,l=o===0,c=a?90:o*-22,d=a?.94:1-Math.max(o,0)*.04,h=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=ne("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${c}px) scale(${d})`,g=l?"auto":"none";let x;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(x={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=x):x=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==x?(v=i.jsx("div",{"aria-hidden":f,className:m,style:x,children:r}),e[6]=r,e[7]=f,e[8]=x,e[9]=v):v=e[9],v}function sc(t){const e=B.c(7),{showUrl:s}=t,n=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),o=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),a=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==n?(l=n&&i.jsx("div",{className:ne("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",en)}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==l?(c=i.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=c):c=e[6],c}function hV(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(sc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"flex flex-1 px-8 py-5",children:i.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:oV.map(fV)})})]}),t[1]=s):s=t[1],s}function fV(t,e){if(e===i3)return i.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return i.jsx("div",{className:ne("relative rounded-md",Es),children:i.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${r3}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function mV(){const t=B.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(sc,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:ne("w-[18%] rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=n):n=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[n,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[i.jsx("div",{className:ne("rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),i.jsx("div",{className:ne("rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function pV(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(sc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:i.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:cV.map(gV)})})]}),t[1]=s):s=t[1],s}function gV(t,e){return i.jsx("div",{className:ne("aspect-square rounded-md",dV[e]?"bg-chart-2/70":Es),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function xV(){const t=B.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(sc,{showUrl:!0}),t[0]=e):e=t[0];let s,n,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),n=i.jsx("div",{className:ne("h-1.5 w-[70%] rounded-sm",Es)}),r=i.jsx("div",{className:ne("h-1.5 w-[55%] rounded-sm",Es)}),o=i.jsx("div",{className:ne("h-1.5 w-[80%] rounded-sm",Es)}),a=i.jsx("div",{className:ne("h-1.5 w-[50%] rounded-sm",Es)}),t[1]=s,t[2]=n,t[3]=r,t[4]=o,t[5]=a):(s=t[1],n=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,n,r,o,a,i.jsx("div",{className:"mt-auto",children:i.jsx("div",{className:ne("h-4 rounded-md",Es)})})]}),t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:i.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[i.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),i.jsx("div",{className:ne("h-1.5 w-[55%] rounded-sm",en)})]})}),t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[i.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),i.jsx("div",{className:ne("h-4 w-10 rounded-full",en)}),i.jsx("div",{className:ne("h-4 w-14 rounded-full",en)})]}),t[8]=d):d=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs("div",{className:ne("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",en),children:[i.jsx("div",{className:ne("h-1.5 w-[50%] rounded-sm",Es)}),i.jsx("div",{className:ne("h-1 w-[75%] rounded-sm",Es)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c,i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[d,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[i.jsx("div",{className:ne("rounded-md",en)}),i.jsx("div",{className:ne("rounded-md",en)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Bi(t){const e=B.c(25);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsx(uV,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}if(t.kind==="errored"){const l=t.error.code===h2.githubNotAuthenticated;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(nr,{className:"size-12 text-destructive"}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("h3",{className:"text-lg font-medium",children:Dh("errored")}),e[4]=d):d=e[4];const h=l?"This agent's GitHub repo isn't authenticated. Reconnect it in Connections, then retry.":t.error.message;let u;e[5]!==h?(u=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==t.connectionsHref?(f=l&&t.connectionsHref&&i.jsx(ie,{asChild:!0,children:i.jsx("a",{href:t.connectionsHref,children:"Reconnect GitHub"})}),e[7]=l,e[8]=t.connectionsHref,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(zi,{className:"size-4"}),e[10]=m):m=e[10];let p;e[11]!==t.onRetry?(p=i.jsxs(ie,{variant:"outline",onClick:t.onRetry,children:[m," Retry"]}),e[11]=t.onRetry,e[12]=p):p=e[12];let g;e[13]!==f||e[14]!==p?(g=i.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[f,p]}),e[13]=f,e[14]=p,e[15]=g):g=e[15];let x;return e[16]!==u||e[17]!==g?(x=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[c,d,u,g]})}),e[16]=u,e[17]=g,e[18]=x):x=e[18],x}let s;e[19]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(cx,{className:"size-12 text-blue-500"}),e[19]=s):s=e[19];let n,r;e[20]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("h3",{className:"text-lg font-medium",children:Dh("suspended")}),r=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[20]=n,e[21]=r):(n=e[20],r=e[21]);let o;e[22]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(fi,{className:"size-4"}),e[22]=o):o=e[22];let a;return e[23]!==t.onResume?(a=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,n,r,i.jsxs(ie,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[23]=t.onResume,e[24]=a):a=e[24],a}const Oh={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function Rd(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function o3(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:Oh.seoResolveType},__resolveType:Oh.resolveType}}function $h(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),n=`${s} (copy)`;if(!t.has(n))return n;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function vV(t,e){const s=ai,n=e.replace(/-copy(?:-\d+)?$/,""),r=`${n}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${n}-copy-${o}`;if(!t.has(s(a)))return a}return`${n}-copy-${Date.now()}`}function _V(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),n=`${s}_copy`;if(!Object.hasOwn(t,n))return n;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function bV(t){const e=Rd(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function yV(t,e){return o3(t,e)}const LV=1e3;function SV(t,e){for(let s=0;s<LV;s++){const n=Rd(e);if(!Object.hasOwn(t,n))return n}throw new Error("Could not generate a unique page block key")}const zn="__blank__";function a3(t){const e=B.c(44),{id:s,value:n,onChange:r,templates:o,disabled:a}=t,[l,c]=C.useState(!1);let d;if(e[0]!==o||e[1]!==n){let A;e[3]!==n?(A=N=>N.key===n,e[3]=n,e[4]=A):A=e[4],d=o.find(A),e[0]=o,e[1]=n,e[2]=d}else d=e[2];const h=d,u=h?.name??"Blank page";let f;e[5]!==u?(f=i.jsx("span",{className:"truncate",children:u}),e[5]=u,e[6]=f):f=e[6];let m;e[7]!==h?(m=h?.path?i.jsx("span",{className:"truncate text-muted-foreground",children:h.path}):null,e[7]=h,e[8]=m):m=e[8];let p;e[9]!==f||e[10]!==m?(p=i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[f,m]}),e[9]=f,e[10]=m,e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(S9,{className:"shrink-0 opacity-50"}),e[12]=g):g=e[12];let x;e[13]!==a||e[14]!==s||e[15]!==l||e[16]!==p?(x=i.jsx(Cs,{asChild:!0,children:i.jsxs(ie,{id:s,type:"button",variant:"outline",role:"combobox","aria-expanded":l,disabled:a,className:"w-full justify-between font-normal",children:[p,g]})}),e[13]=a,e[14]=s,e[15]=l,e[16]=p,e[17]=x):x=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v={width:"var(--radix-popover-trigger-width)"},e[18]=v):v=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(yi,{placeholder:"Search pages…",className:"h-9"}),e[19]=_):_=e[19];let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Li,{children:"No pages found."}),e[20]=b):b=e[20];let y;e[21]!==r?(y=()=>{r(zn),c(!1)},e[21]=r,e[22]=y):y=e[22];const L=n===zn?"opacity-100":"opacity-0";let w;e[23]!==L?(w=ne("ml-auto",L),e[23]=L,e[24]=w):w=e[24];let S;e[25]!==w?(S=i.jsx(Tt,{className:w}),e[25]=w,e[26]=S):S=e[26];let j;e[27]!==y||e[28]!==S?(j=i.jsxs(Ps,{value:"Blank page",onSelect:y,children:["Blank page",S]}),e[27]=y,e[28]=S,e[29]=j):j=e[29];let V;if(e[30]!==r||e[31]!==o||e[32]!==n){let A;e[34]!==r||e[35]!==n?(A=N=>i.jsxs(Ps,{value:`${N.name} ${N.path}`,onSelect:()=>{r(N.key),c(!1)},children:[i.jsxs("div",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{className:"truncate",children:N.name}),i.jsx("span",{className:"truncate text-xs text-muted-foreground",children:N.path})]}),i.jsx(Tt,{className:ne("ml-auto",n===N.key?"opacity-100":"opacity-0")})]},N.key),e[34]=r,e[35]=n,e[36]=A):A=e[36],V=o.map(A),e[30]=r,e[31]=o,e[32]=n,e[33]=V}else V=e[33];let k;e[37]!==j||e[38]!==V?(k=i.jsx(Vs,{className:"p-0",style:v,children:i.jsxs(lr,{children:[_,i.jsxs(Si,{onWheel:wV,children:[b,i.jsxs(Fs,{children:[j,V]})]})]})}),e[37]=j,e[38]=V,e[39]=k):k=e[39];let T;return e[40]!==l||e[41]!==k||e[42]!==x?(T=i.jsxs(ks,{open:l,onOpenChange:c,children:[x,k]}),e[40]=l,e[41]=k,e[42]=x,e[43]=T):T=e[43],T}function wV(t){const e=t.deltaMode===1?16:1;t.currentTarget.scrollTop=t.currentTarget.scrollTop+t.deltaY*e}const jV={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},CV={create:"Create",duplicate:"Duplicate",rename:"Save"},VV={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function kV(t){const e=B.c(62),{open:s,mode:n,initialName:r,initialPath:o,isPending:a,error:l,templates:c,validate:d,onSubmit:h,onOpenChange:u}=t,f=a===void 0?!1:a,[m,p]=C.useState(r),[g,x]=C.useState(o),[v,_]=C.useState(zn),[b,y]=C.useState(null),[L,w]=C.useState(s);s!==L&&(w(s),s&&(p(r),x(o),_(zn),y(null)));const S=n==="create"&&!!c?.length;let j;e[0]!==f||e[1]!==u?(j=Q=>{!Q&&!f&&(y(null),u(!1))},e[0]=f,e[1]=u,e[2]=j):j=e[2];const V=j;let k;e[3]!==f||e[4]!==m||e[5]!==h||e[6]!==g||e[7]!==S||e[8]!==v||e[9]!==d?(k=async Q=>{Q.preventDefault();const Z=m.trim(),J=g.trim();if(!Z||!J||f)return;const ee=rd(J);if(ee){y(ee);return}const te=d?.({name:Z,path:J});if(te){y(te);return}y(null),await h({name:Z,path:J,templateKey:S&&v!==zn?v:null})},e[3]=f,e[4]=m,e[5]=h,e[6]=g,e[7]=S,e[8]=v,e[9]=d,e[10]=k):k=e[10];const T=k,A=b??l,N=jV[n];let R;e[11]!==N?(R=i.jsx(ns,{children:i.jsx(is,{children:N})}),e[11]=N,e[12]=R):R=e[12];let I;e[13]!==f||e[14]!==S||e[15]!==v||e[16]!==c?(I=S&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{htmlFor:"page-form-template",className:"text-xs font-medium text-muted-foreground",children:"Template"}),i.jsx(a3,{id:"page-form-template",value:v,onChange:_,templates:c??[],disabled:f})]}),e[13]=f,e[14]=S,e[15]=v,e[16]=c,e[17]=I):I=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=i.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[18]=D):D=e[18];let E;e[19]===Symbol.for("react.memo_cache_sentinel")?(E=Q=>p(Q.target.value),e[19]=E):E=e[19];let P;e[20]!==f||e[21]!==m?(P=i.jsxs("div",{className:"space-y-1.5",children:[D,i.jsx(Ye,{id:"page-form-name",value:m,onChange:E,placeholder:"My page",autoFocus:!0,disabled:f})]}),e[20]=f,e[21]=m,e[22]=P):P=e[22];let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[23]=M):M=e[23];let z;e[24]===Symbol.for("react.memo_cache_sentinel")?(z=Q=>x(Q.target.value),e[24]=z):z=e[24];let $;e[25]!==f||e[26]!==g?($=i.jsxs("div",{className:"space-y-1.5",children:[M,i.jsx(Ye,{id:"page-form-path",value:g,onChange:z,placeholder:"/example",disabled:f})]}),e[25]=f,e[26]=g,e[27]=$):$=e[27];let O;e[28]!==A?(O=A&&i.jsx("p",{className:"text-xs text-destructive",children:A}),e[28]=A,e[29]=O):O=e[29];let U;e[30]!==$||e[31]!==O||e[32]!==I||e[33]!==P?(U=i.jsxs("div",{className:"space-y-4 py-4",children:[I,P,$,O]}),e[30]=$,e[31]=O,e[32]=I,e[33]=P,e[34]=U):U=e[34];let H;e[35]!==u?(H=()=>u(!1),e[35]=u,e[36]=H):H=e[36];let Y;e[37]!==f||e[38]!==H?(Y=i.jsx(ie,{type:"button",variant:"outline",onClick:H,disabled:f,children:"Cancel"}),e[37]=f,e[38]=H,e[39]=Y):Y=e[39];let G;e[40]!==f||e[41]!==m||e[42]!==g?(G=!m.trim()||!g.trim()||f,e[40]=f,e[41]=m,e[42]=g,e[43]=G):G=e[43];let K;e[44]!==f||e[45]!==n?(K=f?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),VV[n]]}):CV[n],e[44]=f,e[45]=n,e[46]=K):K=e[46];let q;e[47]!==G||e[48]!==K?(q=i.jsx(ie,{type:"submit",disabled:G,children:K}),e[47]=G,e[48]=K,e[49]=q):q=e[49];let W;e[50]!==Y||e[51]!==q?(W=i.jsxs(_i,{children:[Y,q]}),e[50]=Y,e[51]=q,e[52]=W):W=e[52];let F;e[53]!==T||e[54]!==U||e[55]!==W||e[56]!==R?(F=i.jsx(Ft,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:T,children:[R,U,W]})}),e[53]=T,e[54]=U,e[55]=W,e[56]=R,e[57]=F):F=e[57];let X;return e[58]!==V||e[59]!==s||e[60]!==F?(X=i.jsx(Ut,{open:s,onOpenChange:V,children:F}),e[58]=V,e[59]=s,e[60]=F,e[61]=X):X=e[61],X}function NV(t){const e=B.c(43),{open:s,blockKey:n,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,c=o===void 0?!1:o,[d,h]=C.useState(r),[u,f]=C.useState(s);s!==u&&(f(s),s&&h(r));let m;e[0]!==c||e[1]!==l?(m=D=>{!D&&!c&&l(!1)},e[0]=c,e[1]=l,e[2]=m):m=e[2];const p=m;let g;e[3]!==c||e[4]!==d||e[5]!==a?(g=async D=>{D.preventDefault();const E=d.trim();!E||c||await a(E)},e[3]=c,e[4]=d,e[5]=a,e[6]=g):g=e[6];const x=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsxs(ns,{children:[i.jsx(is,{children:"Rename section"}),i.jsx(qn,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=v):v=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=_):_=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=D=>h(D.target.value),e[9]=b):b=e[9];let y;e[10]!==c||e[11]!==d?(y=i.jsxs("div",{className:"space-y-1.5",children:[_,i.jsx(Ye,{id:"section-rename-name",value:d,onChange:b,autoFocus:!0,disabled:c})]}),e[10]=c,e[11]=d,e[12]=y):y=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=L):L=e[13];let w;e[14]!==n?(w=i.jsxs("div",{className:"space-y-1.5",children:[L,i.jsx(Ye,{value:n,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=n,e[15]=w):w=e[15];let S;e[16]!==y||e[17]!==w?(S=i.jsxs("div",{className:"space-y-4 py-4",children:[y,w]}),e[16]=y,e[17]=w,e[18]=S):S=e[18];let j;e[19]!==l?(j=()=>l(!1),e[19]=l,e[20]=j):j=e[20];let V;e[21]!==c||e[22]!==j?(V=i.jsx(ie,{type:"button",variant:"outline",onClick:j,disabled:c,children:"Cancel"}),e[21]=c,e[22]=j,e[23]=V):V=e[23];let k;e[24]!==c||e[25]!==d?(k=!d.trim()||c,e[24]=c,e[25]=d,e[26]=k):k=e[26];let T;e[27]!==c?(T=c?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=c,e[28]=T):T=e[28];let A;e[29]!==k||e[30]!==T?(A=i.jsx(ie,{type:"submit",disabled:k,children:T}),e[29]=k,e[30]=T,e[31]=A):A=e[31];let N;e[32]!==V||e[33]!==A?(N=i.jsxs(_i,{children:[V,A]}),e[32]=V,e[33]=A,e[34]=N):N=e[34];let R;e[35]!==x||e[36]!==S||e[37]!==N?(R=i.jsx(Ft,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:x,children:[v,S,N]})}),e[35]=x,e[36]=S,e[37]=N,e[38]=R):R=e[38];let I;return e[39]!==p||e[40]!==s||e[41]!==R?(I=i.jsx(Ut,{open:s,onOpenChange:p,children:R}),e[39]=p,e[40]=s,e[41]=R,e[42]=I):I=e[42],I}const Nc={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},Pd=["posts","authors","categories"],eo={posts:"post",authors:"author",categories:"category"};function to(t){return Pd.includes(t)}const Id={posts:"post",authors:"author",categories:"category"},l3={posts:Nc.post,authors:Nc.author,categories:Nc.category},AV=Object.fromEntries(Object.entries(l3).map(([t,e])=>[e,t]));function TV(t){return typeof t=="string"?AV[t]??null:null}function Qi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Bs(t){return typeof t=="string"?t:""}function EV(t,e){switch(t){case"posts":return{label:Bs(e.title)||"Untitled post",subtitle:Bs(e.slug)};case"authors":return{label:Bs(e.name)||"Unnamed author",subtitle:Bs(e.email)};case"categories":return{label:Bs(e.name)||"Unnamed category",subtitle:Bs(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function c3(t){const e={posts:[],authors:[],categories:[]};for(const[s,n]of Object.entries(t)){const r=Qi(n);if(!r)continue;const o=TV(r.__resolveType);if(!o)continue;const a=Qi(r[Id[o]])??{},{label:l,subtitle:c}=EV(o,a);e[o].push({key:s,kind:o,label:l,subtitle:c})}for(const s of Pd)e[s].sort((n,r)=>n.label.localeCompare(r.label));return e}function RV(t,e){return c3(t)[e]}function bo(t,e){return RV(t,e).map(s=>({key:s.key,payload:Ca(Qi(t[s.key])??void 0,e)}))}const Bh=Object.freeze({});function Ca(t,e){return t?Qi(t[Id[e]])??Bh:Bh}function da(t,e,s){return{name:t,__resolveType:l3[e],[Id[e]]:s}}function d3(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function Zi(t){return Array.isArray(t)?t:[]}function Fn(t){if(typeof t=="string")return t;const e=Qi(t);return e?Bs(e.slug):""}function PV(t){if(typeof t=="string")return t;const e=Qi(t);return e?Bs(e.email):""}function u3(t){return bo(t,"posts").map(({key:e,payload:s})=>({key:e,title:Bs(s.title)||"Untitled post",slug:Bs(s.slug),date:Bs(s.date),categorySlugs:Zi(s.categories).map(Fn).filter(Boolean),authorEmails:Zi(s.authors).map(PV).filter(Boolean)}))}function IV(t,e){const s=Zi(t.categories);return s.some(n=>Fn(n)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function DV(t,e){const s=Zi(t.categories);return s.length===1&&Fn(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function yF(t,e,s){const n=Zi(t.categories);if(!n.some(l=>Fn(l)===e))return t;const r=n.map(l=>{const c=Fn(l);return c===e||c===s.slug?{name:s.name,slug:s.slug}:l}),o=new Set,a=r.filter(l=>{const c=Fn(l);return c?o.has(c)?!1:(o.add(c),!0):!0});return{...t,categories:a}}function MV(t,e){const s=Zi(t.categories);return s.some(n=>Fn(n)===e)?{...t,categories:s.filter(n=>Fn(n)!==e)}:t}function S0(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function zh(t,e){const s=`collections/blog/${e}/${S0(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function OV(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${S0(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${S0(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const $V={Paragraph:{title:"Paragraph",description:"Rich text content",iconName:"Pilcrow01"},Heading:{title:"Heading",description:"Section title (H1–H6)",iconName:"HeadingSquare"},Quote:{title:"Quote",description:"Pull quote",iconName:"MessageTextSquare02"},Code:{title:"Code",description:"Code block with syntax highlighting",iconName:"Code02"},List:{title:"List",description:"Bulleted or numbered list",iconName:"List"},BlockImage:{title:"Image",description:"Image with optional caption",iconName:"Image01"},Video:{title:"Video",description:"Embedded video",iconName:"PlayCircle"},Divider:{title:"Divider",description:"Horizontal divider",iconName:"Divider"},Cta:{title:"Call to action",description:"Button linking to a URL",iconName:"CursorClick01"},Callout:{title:"Callout",description:"Highlighted note, tip or warning",iconName:"Lightbulb02"},Stat:{title:"Stat",description:"Single key metric",iconName:"BarChartSquareUp"},StatGroup:{title:"Stat group",description:"Row of metrics",iconName:"BarChartSquare02"},CardGroup:{title:"Card group",description:"Grid of cards",iconName:"LayoutGrid01"},Checklist:{title:"Checklist",description:"List of check items",iconName:"CheckSquare"},Steps:{title:"Steps",description:"Step-by-step guide",iconName:"LayersThree01"},Comparison:{title:"Comparison",description:"Side-by-side comparison",iconName:"Columns03"},Table:{title:"Table",description:"Rows and columns of structured data",iconName:"Table"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},Fh="Box";function BV(t){return t.startsWith("site/")?"site":"app"}function zV(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function jr(...t){for(const e of t)if(e!==void 0)return e}function LF(t){const e=new Set,s=[],n=t.manifest?.blocks??{};for(const r of Object.values(n))for(const o of Object.keys(r)){if(!HV(o)||e.has(o))continue;e.add(o);const a=Jn(o,t),l=FV(o),c=$V[l],d=BV(o),h=(d==="site"?jr(a.title,c?.title):jr(c?.title,a.title))??l,u=d==="site"?jr(a.description,c?.description):jr(c?.description,a.description),f=d==="site"?a.icon:void 0,m=f&&zV(f)?f:void 0,p=m!==void 0?c?.iconName??Fh:jr(f,c?.iconName)??Fh;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:d})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function FV(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const UV=["blog/sections/blocks/","site/sections/Blog/Post/"];function HV(t){return UV.some(e=>t.startsWith(e))}function h3({orgSlug:t,virtualMcpId:e,branch:s}){return Qe.decofile(`${t}/${e}/${s}`)}function f3({orgSlug:t,virtualMcpId:e,branch:s},n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${n}`}function KV(t){const e=B.c(11),s=os();let n;e[0]!==t?(n=async l=>{const{blockKey:c,data:d}=l,h=await fetch(f3(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:d3(c),content:JSON.stringify(d,null,2)})});if(!h.ok){const u=await h.json().catch(WV);throw new Error(u.error??`Write failed (${h.status})`)}return h.json()},e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:c,data:d}=l,h=h3(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[c]:d})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,c,d)=>{d?.queryKey&&s.setQueryData(d.queryKey,d.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==n||e[8]!==r||e[9]!==o?(a={mutationFn:n,onMutate:r,onError:o},e[7]=n,e[8]=r,e[9]=o,e[10]=a):a=e[10],Ds(a)}function WV(){return{}}function qV(t){const e=os();return Ds({mutationFn:async({blockKey:s})=>{const n=await fetch(f3(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:d3(s)})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??`Delete failed (${n.status})`)}return n.json()},onMutate:async({blockKey:s})=>{const n=h3(t);await e.cancelQueries({queryKey:n});const r=e.getQueryData(n);return e.setQueryData(n,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:n}},onError:(s,n,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)}})}function GV(t){const e=B.c(20),{open:s,onOpenChange:n,pageKey:r,decofile:o}=t,[a,l]=C.useState(!1),c=o[r];let d;e[0]!==c?(d=c===void 0?"// Page not found.":JSON.stringify(c,null,2),e[0]=c,e[1]=d):d=e[1];const h=d;let u;e[2]!==h?(u=()=>{navigator.clipboard.writeText(h).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=h,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(is,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?i.jsx(Tl,{size:12}):i.jsx(Ss,{size:12}),e[5]=a,e[6]=p):p=e[6];const g=a?"Copied":"Copy";let x;e[7]!==f||e[8]!==p||e[9]!==g?(x=i.jsxs(ns,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,i.jsxs(ie,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,g]})]}),e[7]=f,e[8]=p,e[9]=g,e[10]=x):x=e[10];let v;e[11]!==h?(v=i.jsx(Sn,{className:"max-h-[70vh]",children:i.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:h})}),e[11]=h,e[12]=v):v=e[12];let _;e[13]!==x||e[14]!==v?(_=i.jsxs(Ft,{className:"max-w-2xl p-0 gap-0",children:[x,v]}),e[13]=x,e[14]=v,e[15]=_):_=e[15];let b;return e[16]!==n||e[17]!==s||e[18]!==_?(b=i.jsx(Ut,{open:s,onOpenChange:n,children:_}),e[16]=n,e[17]=s,e[18]=_,e[19]=b):b=e[19],b}function YV(t){const e=B.c(3),{isPending:s,isError:n}=t;if(n){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[i.jsx(fn,{size:13}),"Couldn't save"]}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[i.jsx(qe,{size:13,className:"animate-spin"}),"Saving…"]}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70",children:[i.jsx(Tt,{size:13}),"Saved"]}),e[2]=r):r=e[2],r}const JV={loaders:"loader",actions:"action"},m3=new Set(["workflows"]);function p3(t){return JV[t]}function g3(t,e,s){const n=t.manifest?.blocks??{};for(const[r,o]of Object.entries(n))if(r.includes(s)&&e in o)return!0;return!1}function XV(t,e){return/\.tsx?$/.test(t)?!1:e.has(`${t}.ts`)||e.has(`${t}.tsx`)}function x3(t,e){const s=t.manifest?.blocks??{},n=[],r=new Set;for(const[o,a]of Object.entries(s))if(o.includes(e))for(const l of Object.keys(a))r.add(l);for(const o of r){if(o.toLowerCase().includes("preview")||m3.has(Dd(o))||XV(o,r))continue;const a=Jn(o,t);if(a.hidden)continue;const l=a.title&&a.title!==o?a.title:vt(o);n.push({resolveType:o,title:l})}return n.sort((o,a)=>o.title.localeCompare(a.title))}function Uh(t,e){return x3(t,e).length}function Dd(t){return t.startsWith("deco-sites/")?t.split("/")[1]||"site":t.startsWith("$live")||t.startsWith("deco/")?"deco":t.split("/")[0]||"other"}const QV={deco:"Deco",std:"Deco Standard",website:"Website"};function ZV(t){return QV[t]??t}function v3(t){const e=Dd(t);let n=t.split("/").filter(Boolean).slice(t.startsWith("deco-sites/")?2:1);return(n[0]==="loaders"||n[0]==="actions")&&(n=n.slice(1)),[e,...n.slice(0,-1)]}function ek(t,e,s){const n=[];for(const[r,o]of Object.entries(e)){if(r.includes("/")||$l(r)||!o||typeof o!="object"||Array.isArray(o))continue;const a=o,l=a.__resolveType;typeof l=="string"&&(m3.has(Dd(l))||g3(t,l,s)&&n.push({key:r,resolveType:l,title:typeof a.name=="string"&&a.name?a.name:r}))}return n.sort((r,o)=>r.title.localeCompare(o.title))}const Hh=3e4;function _3(t){return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-invoke`}function tk(t,e,s,n){const r=new URL(`/deco/invoke/${e}`,t);return r.searchParams.set("__cb",n.toString(36)),r.searchParams.set("__decoFBT","0"),r.searchParams.set("__d",`run-${n.toString(36)}`),r.searchParams.set("props",btoa(encodeURIComponent(JSON.stringify(s)))),r.href}async function sk(t,{resolveType:e,props:s}){let n;try{n=await fetch(_3(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(Hh)})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(`Run timed out after ${Hh/1e3}s — the block may be slow or the preview unresponsive.`):l}const r=await n.text();let o=null,a=!1;try{o=r?JSON.parse(r):null,a=!0}catch{}if(!n.ok){const l=a&&o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"?o.error:r||`Run failed (${n.status})`;throw new Error(l)}return a?o:r}function nk(t){const e=B.c(2);let s;return e[0]!==t?(s={mutationFn:n=>sk(t,n)},e[0]=t,e[1]=s):s=e[1],Ds(s)}function ik({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:r,decofile:o,kind:a,target:l,initialValue:c,isCreating:d,onCreate:h,onSaveReferencedBlock:u,onBack:f}){const m=Vn(),p=m?.entity?.id===e?m.entity.metadata?.siteSlug??null:null,g=Ln(l.resolveType,r),x=!g&&AL(l.resolveType,r),v=x?TL(c):null,_=g??v,[b,y]=C.useState(c),[L,w]=C.useState([]),[S,j]=C.useState(0),[V,k]=C.useState(!1),[T,A]=C.useState(null),[N,R]=C.useState(!1),[I,D]=C.useState(!1),[E,P]=C.useState(!1),M=T!==null,{save:z,flush:$,isPending:O}=K2({orgSlug:t,virtualMcpId:e,branch:s}),U=nk({orgSlug:t,virtualMcpId:e,branch:s});C.useEffect(()=>()=>{$()},[]);const H=p3(a),Y=l.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")??l.resolveType,G={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:p},K=ee=>{y(ee),l.mode==="saved"&&z(l.blockKey,{__resolveType:l.resolveType,...ee})},q=()=>{M?(A(null),k(!1),j(ee=>ee+1)):A(JSON.stringify(b,null,2))},W=ee=>{const te=ee??"";try{const ae=JSON.parse(te);if(ae&&typeof ae=="object"&&!Array.isArray(ae)){k(!1),K(ae);return}k(!0)}catch{k(!0)}},F=async ee=>{const te=ud(ee,o);if(te){de.error(te);return}await h(ee,{__resolveType:l.resolveType,...b}),R(!1)},X=()=>{D(!0),U.mutate({resolveType:l.resolveType,props:b})},Q=()=>{n&&window.open(tk(n,l.resolveType,b,Date.now()),"_blank","noopener")},Z=[l.title,...L],J=ee=>{w(L.slice(0,ee)),j(te=>te+1)};return i.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col",children:[i.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[f&&i.jsx(ie,{variant:"ghost",size:"icon",className:"size-8 shrink-0",onClick:f,"aria-label":"Back to list",children:i.jsx(Vl,{size:14})}),i.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:Z.map((ee,te)=>{const ae=te===Z.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[te>0&&i.jsx(cn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>J(te),title:ee,className:ne("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",ae?"font-medium text-foreground":"text-muted-foreground"),children:ee})]},`${ee}-${te}`)})}),l.mode==="saved"&&i.jsx(YV,{isPending:O,isError:!1}),i.jsxs(ie,{size:"sm",variant:"outline",className:"h-8 shrink-0 gap-1.5",onClick:X,disabled:U.isPending,"aria-label":`Run ${H}`,children:[U.isPending?i.jsx(qe,{size:14,className:"animate-spin"}):i.jsx(fi,{size:14}),"Run"]}),l.mode==="available"&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{size:"icon",className:"size-8 shrink-0",disabled:d,onClick:()=>R(!0),"aria-label":`Save as global ${H}`,children:i.jsx(N9,{size:14})})}),i.jsxs(Pe,{side:"bottom",children:["Save as global ",H]})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:M?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:q,"aria-label":M?"Close JSON editor":"Edit as JSON","aria-pressed":M,children:M?i.jsx(ms,{size:14}):i.jsx(Ao,{size:14})})}),i.jsx(Pe,{side:"bottom",children:M?"Close JSON editor":"Edit as JSON"})]})]}),i.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:l.mode==="saved"?`Global ${H} — changes save automatically. Run to invoke it against the live preview.`:`${Y} — edits stay local until you save this as a global ${H}. Run to invoke it against the live preview.`})]}),i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[i.jsxs("div",{className:ne("relative min-h-0 flex-1",I&&E&&"hidden"),children:[i.jsx(Sn,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:i.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:i.jsxs("div",{className:"mx-auto max-w-2xl",children:[v&&_===v&&i.jsxs("p",{className:"mb-3 rounded-md bg-muted px-3 py-2 text-xs leading-snug text-muted-foreground",children:["This ",H," doesn't publish a props schema — fields below are inferred from its saved values. Use the JSON editor to add props not shown here."]}),_?i.jsx(Xn,{schema:_,value:b,onChange:ee=>K(ee),basePath:"",breadcrumbPath:L,onBreadcrumbChange:w,meta:r,decofile:o,onSaveReferencedBlock:u,sandbox:G},S):i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:x?`This ${H} doesn't publish a props schema. Edit its props as JSON, then run it.`:`This ${H} takes no configurable input. Run it to see its output.`})]})})}),T!==null&&i.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[V&&i.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(Pl,{language:"json",height:"100%",code:T,onChange:W,onSave:ee=>{W(ee),$()}})})]})]}),I&&i.jsx(rk,{singular:H,result:{isPending:U.isPending,error:U.error,data:U.data,hasRun:U.status!=="idle"},expanded:E,onToggleExpand:()=>P(ee=>!ee),onOpenInNewTab:n?Q:void 0,onClose:()=>{D(!1),P(!1)}})]}),i.jsx(kd,{open:N,onOpenChange:R,defaultBlockId:"",isPending:d,onSubmit:F})]})}function rk(t){const e=B.c(37),{singular:s,result:n,expanded:r,onToggleExpand:o,onOpenInNewTab:a,onClose:l}=t;let c;e[0]!==n.data?(c=typeof n.data=="string"?n.data:JSON.stringify(n.data??null,null,2),e[0]=n.data,e[1]=c):c=e[1];const d=c,h=r?"flex-1":"h-[45%] shrink-0";let u;e[2]!==h?(u=ne("flex min-h-0 flex-col border-t",h),e[2]=h,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Result"}),e[4]=f):f=e[4];let m;e[5]!==a||e[6]!==s?(m=a&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",className:"size-7",onClick:a,"aria-label":"Open result in new tab",children:i.jsx(wn,{size:14})})}),i.jsxs(Pe,{side:"bottom",children:["Open in new tab (re-runs the ",s,")"]})]}),e[5]=a,e[6]=s,e[7]=m):m=e[7];const p=r?"Collapse result":"Expand result";let g;e[8]!==r?(g=r?i.jsx(dx,{size:14}):i.jsx(nm,{size:14}),e[8]=r,e[9]=g):g=e[9];let x;e[10]!==r||e[11]!==o||e[12]!==p||e[13]!==g?(x=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",className:"size-7",onClick:o,"aria-label":p,"aria-pressed":r,children:g})}),e[10]=r,e[11]=o,e[12]=p,e[13]=g,e[14]=x):x=e[14];const v=r?"Collapse":"Expand";let _;e[15]!==v?(_=i.jsx(Pe,{side:"bottom",children:v}),e[15]=v,e[16]=_):_=e[16];let b;e[17]!==_||e[18]!==x?(b=i.jsxs(Ie,{children:[x,_]}),e[17]=_,e[18]=x,e[19]=b):b=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ms,{size:14}),e[20]=y):y=e[20];let L;e[21]!==l?(L=i.jsx(ie,{variant:"ghost",size:"icon",className:"size-7",onClick:l,"aria-label":"Close result",children:y}),e[21]=l,e[22]=L):L=e[22];let w;e[23]!==b||e[24]!==L||e[25]!==m?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[f,i.jsxs("div",{className:"flex items-center gap-0.5",children:[m,b,L]})]}),e[23]=b,e[24]=L,e[25]=m,e[26]=w):w=e[26];let S;e[27]!==n.error||e[28]!==n.hasRun||e[29]!==n.isPending||e[30]!==d||e[31]!==s?(S=i.jsx("div",{className:"min-h-0 flex-1",children:n.isPending?i.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-muted-foreground",children:[i.jsx(qe,{size:16,className:"animate-spin"}),"Running ",s,"…"]}):n.error?i.jsxs("div",{className:"h-full overflow-auto px-4 py-3",children:[i.jsxs("p",{className:"text-xs font-medium text-destructive",children:["Failed to run ",s]}),i.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-destructive/90",children:n.error.message})]}):n.hasRun?i.jsx(Pl,{language:"json",height:"100%",code:d,readOnly:!0}):i.jsxs("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:["Press Run to invoke this ",s,"."]})}),e[27]=n.error,e[28]=n.hasRun,e[29]=n.isPending,e[30]=d,e[31]=s,e[32]=S):S=e[32];let j;return e[33]!==w||e[34]!==S||e[35]!==u?(j=i.jsxs("div",{className:u,children:[w,S]}),e[33]=w,e[34]=S,e[35]=u,e[36]=j):j=e[36],j}const ok={loaders:$a,actions:ui},ak={loaders:"Loaders",actions:"Actions"},lk={analytics:ux,blog:Ki,commerce:A9,site:Sv,website:Yn};function ck(t,e){return e===0?lk[t.toLowerCase()]??hi:hi}function ua(t,e){return e===0?ZV(t):t}function dk(t){const e=B.c(87),{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];const[h,u]=C.useState(d),[f,m]=C.useState(null),[p,g]=C.useState(""),[x,v]=C.useState(vk),[_,b]=C.useState(c);_!==c&&(b(c),u([]),m(null),g(""),v(new Set));let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=U=>{v(H=>{const Y=new Set(H);return Y.has(U)?Y.delete(U):Y.add(U),Y})},e[1]=y):y=e[1];const L=y;let w;e[2]!==r||e[3]!==s||e[4]!==n?(w={orgSlug:s,virtualMcpId:n,branch:r},e[2]=r,e[3]=s,e[4]=n,e[5]=w):w=e[5];const S=Bl(w);let j;e[6]!==S?(j=lp((U,H)=>S.mutate({blockKey:U,data:H})),e[6]=S,e[7]=j):j=e[7];const V=j;let k;e[8]!==c?(k=p3(c),e[8]=c,e[9]=k):k=e[9];const T=k,A=ok[c];let N,R,I,D,E,P,M;if(e[10]!==A||e[11]!==r||e[12]!==l||e[13]!==c||e[14]!==a||e[15]!==x||e[16]!==s||e[17]!==h||e[18]!==o||e[19]!==S||e[20]!==V||e[21]!==p||e[22]!==f||e[23]!==T||e[24]!==n){I=Symbol.for("react.early_return_sentinel");e:{const U=[...ek(a,l,c).map(xk),...x3(a,c).map(gk)],H=p.trim().toLowerCase(),Y=H.length>0,G=Y?U.filter(pe=>pe.title.toLowerCase().includes(H)||pe.resolveType.toLowerCase().includes(H)):[],K=new Map,q=[],W=new Map;if(!Y){for(const pe of U){const Ee=pe.folderPath;if(!(Ee.length<h.length)&&h.every((De,he)=>Ee[he]===De))if(Ee.length===h.length)if(pe.savedKey!==void 0){const De=W.get(pe.resolveType);De?De.push(pe):W.set(pe.resolveType,[pe])}else q.push(pe);else{const De=Ee[h.length],he=K.get(De)??{count:0,savedCount:0};pe.savedKey!==void 0?he.savedCount=he.savedCount+1:he.count=he.count+1,K.set(De,he)}}q.sort(pk);for(const pe of W.values())pe.sort(mk)}const F=[...W.entries()].filter(pe=>{const[Ee]=pe;return!q.some(De=>De.resolveType===Ee)}).flatMap(fk).sort(hk);let X;e[32]!==h?(X=(pe,Ee)=>ua(pe.name,h.length).localeCompare(ua(Ee.name,h.length)),e[32]=h,e[33]=X):X=e[33];const Q=[...K.entries()].map(uk).sort(X);let Z;e[34]===Symbol.for("react.memo_cache_sentinel")?(Z=pe=>{m(pe.savedKey!==void 0?{mode:"saved",key:pe.savedKey}:{mode:"available",resolveType:pe.resolveType,title:pe.title})},e[34]=Z):Z=e[34];const J=Z;let ee;e[35]!==S||e[36]!==T?(ee=async(pe,Ee)=>{await S.mutateAsync({blockKey:pe,data:Ee}),de.success(`Saved ${T} "${pe}"`),m({mode:"saved",key:pe})},e[35]=S,e[36]=T,e[37]=ee):ee=e[37];const te=ee;let ae;e[38]!==l||e[39]!==f?(ae=_k(f,l),e[38]=l,e[39]=f,e[40]=ae):ae=e[40];const se=ae;if(se){const pe=`${se.mode}:${se.mode==="saved"?se.blockKey:se.resolveType}`;let Ee;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>m(null),e[41]=Ee):Ee=e[41];let De;e[42]!==r||e[43]!==l||e[44]!==te||e[45]!==c||e[46]!==a||e[47]!==s||e[48]!==o||e[49]!==S.isPending||e[50]!==V||e[51]!==pe||e[52]!==se.editorTarget||e[53]!==se.initialValue||e[54]!==n?(De=i.jsx(ik,{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c,target:se.editorTarget,initialValue:se.initialValue,isCreating:S.isPending,onCreate:te,onSaveReferencedBlock:V,onBack:Ee},pe),e[42]=r,e[43]=l,e[44]=te,e[45]=c,e[46]=a,e[47]=s,e[48]=o,e[49]=S.isPending,e[50]=V,e[51]=pe,e[52]=se.editorTarget,e[53]=se.initialValue,e[54]=n,e[55]=De):De=e[55],I=De;break e}M="flex h-full w-full min-w-0 flex-col";let oe;e[56]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>u([]),e[56]=oe):oe=e[56];const ce=h.length===0?"font-medium text-foreground":"text-muted-foreground";let fe;e[57]!==ce?(fe=ne("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",ce),e[57]=ce,e[58]=fe):fe=e[58];const be=ak[c];let _e;e[59]!==fe||e[60]!==be?(_e=i.jsx("button",{type:"button",onClick:oe,className:fe,children:be}),e[59]=fe,e[60]=be,e[61]=_e):_e=e[61];let xe;e[62]!==h?(xe=h.map((pe,Ee)=>{const De=Ee===h.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[i.jsx(cn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>u(h.slice(0,Ee+1)),className:ne("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",De?"font-medium text-foreground":"text-muted-foreground"),children:ua(pe,Ee)})]},`${pe}-${Ee}`)}),e[62]=h,e[63]=xe):xe=e[63];let Ve;e[64]!==_e||e[65]!==xe?(Ve=i.jsxs("nav",{"aria-label":"Folder breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:[_e,xe]}),e[64]=_e,e[65]=xe,e[66]=Ve):Ve=e[66];let Ne;e[67]===Symbol.for("react.memo_cache_sentinel")?(Ne=i.jsx($9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[67]=Ne):Ne=e[67];let we;e[68]===Symbol.for("react.memo_cache_sentinel")?(we=pe=>g(pe.target.value),e[68]=we):we=e[68];const ye=`Search all ${c}…`,$e=`Search all ${c}`;let Fe;e[69]!==p||e[70]!==ye||e[71]!==$e?(Fe=i.jsxs("div",{className:"flex w-56 shrink-0 items-center gap-2",children:[Ne,i.jsx("input",{type:"text",value:p,onChange:we,placeholder:ye,"aria-label":$e,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[69]=p,e[70]=ye,e[71]=$e,e[72]=Fe):Fe=e[72],e[73]!==Ve||e[74]!==Fe?(R=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[Ve,Fe]}),e[73]=Ve,e[74]=Fe,e[75]=R):R=e[75],N=Sn,P="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",D="mx-auto w-full max-w-4xl px-6 py-5",E=Y?G.length===0?i.jsx(Mn,{title:`No ${c} match "${p.trim()}"`,description:"Search covers every folder — try a different term."}):i.jsx("div",{className:"flex flex-col gap-1",children:G.map(pe=>i.jsx(tn,{icon:A,accent:pe.savedKey!==void 0?"global":void 0,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>J(pe)},pe.savedKey??pe.resolveType))}):Q.length===0&&q.length===0&&F.length===0?i.jsx(Mn,{title:`No ${c} here`,description:h.length===0?"Start the preview dev server so its manifest loads.":"This folder is empty."}):i.jsxs(i.Fragment,{children:[Q.length>0&&i.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2",children:Q.map(pe=>{const Ee=ck(pe.name,h.length);return i.jsxs("button",{type:"button",onClick:()=>u([...h,pe.name]),className:"flex items-center gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[i.jsx(Ee,{size:18,className:"shrink-0 text-muted-foreground"}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium",children:ua(pe.name,h.length)}),i.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[pe.count," ",pe.count===1?T:c,pe.savedCount>0&&i.jsxs(i.Fragment,{children:[" · ",pe.savedCount," saved"]})]})]})]},pe.name)})}),(q.length>0||F.length>0)&&i.jsxs("div",{className:ne("flex flex-col gap-1",Q.length>0&&"mt-4"),children:[q.map(pe=>{const Ee=W.get(pe.resolveType)??[],De=x.has(pe.resolveType);return i.jsxs("div",{className:"flex flex-col",children:[i.jsx(tn,{icon:A,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>J(pe)}),Ee.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>L(pe.resolveType),"aria-expanded":De,className:"flex items-center gap-1 self-start rounded-md px-2.5 py-1 text-xs font-medium transition-colors hover:bg-global-section/10 cursor-pointer ml-11",style:{color:td},children:[De?i.jsx(Ht,{size:12,className:"shrink-0"}):i.jsx(cn,{size:12,className:"shrink-0"}),De?"Hide saved":"See saved"," (",Ee.length,")"]}),De&&i.jsx("div",{className:"ml-11 flex flex-col gap-1 pb-1",children:Ee.map(he=>i.jsx(tn,{icon:A,accent:"global",title:he.title,subtitle:he.resolveType,active:!1,onClick:()=>J(he)},he.savedKey))})]})]},pe.resolveType)}),F.map(pe=>i.jsx(tn,{icon:A,accent:"global",title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>J(pe)},pe.savedKey))]})]})}e[10]=A,e[11]=r,e[12]=l,e[13]=c,e[14]=a,e[15]=x,e[16]=s,e[17]=h,e[18]=o,e[19]=S,e[20]=V,e[21]=p,e[22]=f,e[23]=T,e[24]=n,e[25]=N,e[26]=R,e[27]=I,e[28]=D,e[29]=E,e[30]=P,e[31]=M}else N=e[25],R=e[26],I=e[27],D=e[28],E=e[29],P=e[30],M=e[31];if(I!==Symbol.for("react.early_return_sentinel"))return I;let z;e[76]!==D||e[77]!==E?(z=i.jsx("div",{className:D,children:E}),e[76]=D,e[77]=E,e[78]=z):z=e[78];let $;e[79]!==N||e[80]!==z||e[81]!==P?($=i.jsx(N,{className:P,children:z}),e[79]=N,e[80]=z,e[81]=P,e[82]=$):$=e[82];let O;return e[83]!==R||e[84]!==$||e[85]!==M?(O=i.jsxs("div",{className:M,children:[R,$]}),e[83]=R,e[84]=$,e[85]=M,e[86]=O):O=e[86],O}function uk(t){const[e,s]=t;return{name:e,...s}}function hk(t,e){return t.title.localeCompare(e.title)}function fk(t){const[,e]=t;return e}function mk(t,e){return t.title.localeCompare(e.title)}function pk(t,e){return t.title.localeCompare(e.title)}function gk(t){return{resolveType:t.resolveType,title:t.title,folderPath:v3(t.resolveType)}}function xk(t){return{resolveType:t.resolveType,title:t.title,folderPath:v3(t.resolveType),savedKey:t.key}}function vk(){return new Set}function _k(t,e){if(!t)return null;if(t.mode==="available")return{mode:"available",resolveType:t.resolveType,editorTarget:{mode:"available",resolveType:t.resolveType,title:t.title},initialValue:{}};const s=e[t.key],n=s&&typeof s.__resolveType=="string"?s.__resolveType:"",{__resolveType:r,...o}=s??{},a=s&&typeof s.name=="string"&&s.name?s.name:t.key;return{mode:"saved",blockKey:t.key,resolveType:n,editorTarget:{mode:"saved",blockKey:t.key,resolveType:n,title:a},initialValue:o}}const bk={target:null,editSeoPageKey:null,previewRevision:0};function yk(t,e){switch(e.type){case"select":return{...t,target:e.target};case"edit-seo":return{...t,target:e.target,editSeoPageKey:e.target.key};case"consume-edit-seo":return{...t,editSeoPageKey:null};case"saved":return{...t,previewRevision:t.previewRevision+1}}}const b3=C.createContext(null);function Lk(t){const e=B.c(9),{children:s}=t,[n,r]=C.useReducer(yk,bk);let o,a,l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u=>r({type:"select",target:u}),a=u=>r({type:"edit-seo",target:u}),l=()=>r({type:"consume-edit-seo"}),c=()=>r({type:"saved"}),e[0]=o,e[1]=a,e[2]=l,e[3]=c):(o=e[0],a=e[1],l=e[2],c=e[3]);let d;e[4]!==n?(d={state:n,selectTarget:o,editSeo:a,consumeEditSeo:l,notifySaved:c},e[4]=n,e[5]=d):d=e[5];let h;return e[6]!==s||e[7]!==d?(h=i.jsx(b3,{value:d,children:s}),e[6]=s,e[7]=d,e[8]=h):h=e[8],h}function y3(){const t=C.use(b3);if(!t)throw new Error("useBlocksPreviewWorkspace must be used inside BlocksPreviewWorkspaceProvider");return t}const Kh=C.lazy(()=>Ws(()=>import("./app-editor-hzVyG0y7.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.AppEditor}))),Sk=C.lazy(()=>Ws(()=>import("./post-editor-NfJoTyDC.js"),__vite__mapDeps([149,1,2,51,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,105,104,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,109,117,150,151,107,108,110,111,112,113,114,115,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.PostEditor}))),wk=C.lazy(()=>Ws(()=>import("./record-editor-CgHrbjzN.js"),__vite__mapDeps([152,1,2,105,104,117,151,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,85,86,87,14,15,16,88,89,90,17,13,91,69,92,82,93,4,5,6,10,11,12,18,19,21,23,24,25,26,27,68,70,71,72,73,74,75,76,77,78,79,80,81,83,84,94,95,96,97,98,99,100,101,102,103,107,108,109,110,111,112,113,114,115,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.RecordEditor}))),jk=C.lazy(()=>Ws(()=>import("./category-editor-Nlp7pH1k.js"),__vite__mapDeps([153,1,2,35,31,28,32,33,34,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,96,105,104,150,73,74,75,76,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,97,98,99,100,101,102,103,151,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.CategoryEditor}))),Ck=C.lazy(()=>Ws(()=>import("./bulk-category-panel-C3uWZXv5.js"),__vite__mapDeps([154,1,2,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,104,155,5,6])).then(t=>({default:t.BulkCategoryPanel}))),Vk=C.lazy(()=>Ws(()=>import("./sections-editor-BIBNvxJf.js"),__vite__mapDeps([156,1,2,8,39,3,9,31,28,32,33,34,35,36,37,38,29,7,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,126,157,135,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SectionsEditor}))),kk=C.lazy(()=>Ws(()=>import("./seo-editor-Cxn7J1o3.js"),__vite__mapDeps([158,1,2,3,31,28,32,33,34,35,36,37,38,39,29,7,8,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,157,135,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SeoEditor}))),Nk=C.lazy(()=>Ws(()=>import("./variant-calendar-FLrb-T5o.js"),__vite__mapDeps([159,1,2,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,104,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,105,135,160])).then(t=>({default:t.VariantCalendar}))),w0="oklch(0.65 0.15 160)";function Ac(t){return t?t.kind==="page"?{collection:"pages",key:t.key,path:t.path}:{collection:"sections",key:t.key}:null}function Ak(t){return t?t.kind==="page"?`page:${t.key}:${t.path}`:`section:${t.key}`:null}function Tk(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function Ek(t){const e=new Map;for(const s of t){const n=Tk(s.resolveType),r=e.get(n);r?r.push(s):e.set(n,[s])}return[...e.entries()].map(([s,n])=>({label:s,sections:n})).sort((s,n)=>s.label.localeCompare(n.label))}function L3(t){const e=B.c(20),{mode:s}=t,n=s===void 0?"content":s,r=Vn(),{data:o}=vi.useSession(),{currentBranch:a}=as(),{org:l}=Ae(),c=r?.entity?.id??null,d=o?.user?.id,h=r?.entity?.metadata,u=d&&a?Ll(h?.sandboxMap?.[d]?.[a]):{},f=Object.values(u),p=(f.find(Rk)??f[0])?.previewUrl??null,g=Os(),x=r?.entity?.organization_id??"";let v;e[0]!==l.slug||e[1]!==x?(v={connectionId:b9,orgId:x,orgSlug:l.slug},e[0]=l.slug,e[1]=x,e[2]=v):v=e[2];const _=pt(v),b=Y9(_);let y;e[3]!==a||e[4]!==b||e[5]!==c?(y=()=>{if(!c)return;const V={virtualMcpId:c};a&&(V.branch=a),b.mutate(V)},e[3]=a,e[4]=b,e[5]=c,e[6]=y):y=e[6];const L=y,w=!!c&&!!a&&Za.isStopped(c,a),S=u2({previewUrl:p,appPaused:g.status.state==="paused",userStopped:w,startError:b.isError&&b.error?f2(b.error.message):null});if(S.kind!=="iframe"){const V=`/${l.slug}/settings/connections`;let k;return e[7]!==S||e[8]!==V||e[9]!==L||e[10]!==g.lifecycle||e[11]!==g.phase?(k=i.jsx(eN,{state:S,claimPhase:g.phase,lifecycle:g.lifecycle,onStart:L,connectionsHref:V}),e[7]=S,e[8]=V,e[9]=L,e[10]=g.lifecycle,e[11]=g.phase,e[12]=k):k=e[12],k}if(!c||!a){let V;return e[13]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx(Mn,{title:"Waiting for sandbox context…"}),e[13]=V):V=e[13],V}let j;return e[14]!==a||e[15]!==n||e[16]!==l.slug||e[17]!==p||e[18]!==c?(j=i.jsx(Ik,{orgSlug:l.slug,virtualMcpId:c,branch:a,previewUrl:p,mode:n}),e[14]=a,e[15]=n,e[16]=l.slug,e[17]=p,e[18]=c,e[19]=j):j=e[19],j}function Rk(t){return t.sandboxProviderKind!=="user-desktop"}const Wh=2e3,Pk=15;function qh(t,e,s,n){return typeof e!="string"||s&&(H2(e,s,n)||t.state.dataUpdateCount>=Pk)?!1:Wh}function Ik({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,mode:r}){const o=y3(),a={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n},{data:l,isLoading:c}=Ml(a),[d,h]=C.useState("pages"),[u,f]=C.useState(()=>r==="blocks"?Ac(o.state.target):null),[m,p]=C.useState(()=>r==="blocks"?o.state.editSeoPageKey:null),g=Ak(o.state.target),[x,v]=C.useState(g);if(r==="blocks"&&x!==g){v(g);const re=Ac(o.state.target);f(re),(re?.collection==="pages"||re?.collection==="sections")&&h(re.collection)}const[_,b]=C.useState(o.state.editSeoPageKey);if(r==="blocks"&&_!==o.state.editSeoPageKey&&(b(o.state.editSeoPageKey),o.state.editSeoPageKey)){const re=o.state.target;re?.kind==="page"&&(h("pages"),f(Ac(re)),p(re.key))}const[y,L]=C.useState(""),[w,S]=C.useState(null),[j,V]=C.useState(null),[k,T]=C.useState("date-desc"),[A,N]=C.useState(()=>new Set),[R,I]=C.useState(null),D=()=>{N(new Set),I(null)},E=re=>{f(re),p(null),!(r!=="blocks"||!re)&&(re.collection==="pages"?o.selectTarget({kind:"page",key:re.key,path:re.path}):re.collection==="sections"&&o.selectTarget({kind:"section",key:re.key}))},[P,M]=C.useState(d);P!==d&&(M(d),L(""),S(null),V(null),T("date-desc"),N(new Set),I(null));const{data:z,isLoading:$,isFetching:O}=Ol(a,{refetchInterval:re=>{const Le=re.state.data;if(d==="apps"&&u&&u.collection==="apps"){const Te=l?.[u.key];return qh(re,typeof Te?.__resolveType=="string"?Te.__resolveType:void 0,Le)}if(d==="site"&&l){const Te=Le?x0(l,Le):null,Oe=l.site,st=Te?.resolveType??(typeof Oe?.__resolveType=="string"?Oe.__resolveType:void 0);return qh(re,st,Le,["seo"])}return!1}}),U=(re,Le)=>!H2(re,z,Le)&&($||O),{catalog:H,isLoading:Y}=t7(z??void 0,l??void 0,{enabled:d==="apps"}),G=Bl(a),K=ML(a),q=KV(a),W=qV(a),[F,X]=C.useState(null),[Q,Z]=C.useState(),[J,ee]=C.useState(null),[te,ae]=C.useState(null),[se,oe]=C.useState(null);if(c||$)return i.jsx("div",{className:"h-full w-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})});if(!l||!z)return i.jsx(Mn,{title:"Could not load site data."});const ce=ld(l).sort((re,Le)=>re.name.localeCompare(Le.name)),fe=cd(l,z),be=d==="sections"?FL(z):[],_e=x0(l,z),xe=c3(l),Ve=Pd.some(re=>xe[re].length>0),Ne=to(d)?xe[d]:[],we=(Ve?bo(l,"categories"):[]).map(({key:re,payload:Le})=>{const Te=typeof Le.slug=="string"?Le.slug:"",Oe=typeof Le.name=="string"?Le.name:"";return{slug:Te||re,name:Oe||Te||re}}).filter(re=>re.slug).sort((re,Le)=>re.name.localeCompare(Le.name)),ye=d==="posts"&&(A.size>0||R!==null),$e=ye?u3(l).filter(re=>A.has(re.key)):[],Fe=Uh(z,"loaders"),pe=Uh(z,"actions");if(!ad(l,z)&&!Ve&&Fe===0&&pe===0)return i.jsx(Mn,{icon:fn,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, apps, loaders, or actions."});const Ee={pages:ce.length,sections:fe.length,apps:H.length,loaders:Fe,actions:pe,posts:xe.posts.length,authors:xe.authors.length,categories:xe.categories.length},De=new Set(ce.map(re=>ai(re.path))),he=new Set(ce.map(re=>re.name)),le=new Set(fe.map(re=>re.name)),ke=async re=>{const Le=l[re.key];if(!Le)return;const Te=op(l,re.key),Oe=x7(l,re.key,Math.max(0,Te-1)),st=v7(Le.sections,Oe);if(st)try{await G.mutateAsync({blockKey:re.key,data:{...Le,sections:st}}),de.success(`Variant added to "${re.name}"`),f({collection:"pages",key:re.key,path:re.path})}catch(ht){de.error(ht instanceof Error?ht.message:"Could not add variant")}},Be=()=>{Z(void 0),X({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},Ue=re=>{Z(void 0),X({mode:"duplicate",sourceKey:re.key,initialName:$h(he,re.name),initialPath:vV(De,re.path)})},it=re=>{Z(void 0),X({mode:"rename",sourceKey:re.key,initialName:re.name,initialPath:re.path})},Yt=async re=>{if(!F)return;const{mode:Le,sourceKey:Te}=F;try{if(Le==="create"){let Oe;if(re.templateKey){const ht=l[re.templateKey];if(!ht)throw new Error("Selected template no longer exists.");Oe={...ht,name:re.name,path:re.path}}else Oe=yV(re.name,re.path);const st=SV(l,re.name);await G.mutateAsync({blockKey:st,data:Oe}),de.success(`Created "${re.name}"`),f({collection:"pages",key:st,path:re.path})}else if(Le==="duplicate"&&Te){const Oe=l[Te];if(!Oe)throw new Error("Source page not found");const{key:st,data:ht}=bV({source:Oe,pages:ce,newName:re.name,newPath:re.path});await G.mutateAsync({blockKey:st,data:ht}),de.success(`Duplicated as "${re.name}"`),f({collection:"pages",key:st,path:re.path})}else if(Le==="rename"&&Te){const Oe=l[Te];if(!Oe)throw new Error("Page not found");const st={...Oe,name:re.name,path:re.path};await G.mutateAsync({blockKey:Te,data:st}),de.success("Page updated"),u?.collection==="pages"&&u.key===Te&&f({collection:"pages",key:Te,path:re.path})}X(null)}catch(Oe){Z(Oe instanceof Error?Oe.message:"Save failed")}},Rt=({path:re})=>{if(!F)return null;const Le=ai(re);return(F.mode==="rename"?ai(F.initialPath):null)!==Le&&De.has(Le)?`A page with path "${re}" already exists.`:null},rt=async(re,Le,Te)=>{await G.mutateAsync({blockKey:Le,data:{...Te,name:Le,__resolveType:re}}),de.success(`Created section "${Le}"`),f({collection:"sections",key:Le})},gt=lp((re,Le)=>G.mutate({blockKey:re,data:Le})),lt=async re=>{const Le=l[re.key];if(!Le){de.error("Section not found.");return}const Te=_V(l,re.key),Oe=$h(le,re.name),st={...Le,name:Oe};try{await G.mutateAsync({blockKey:Te,data:st}),de.success(`Duplicated "${re.name}"`),f({collection:"sections",key:Te})}catch(ht){de.error(ht instanceof Error?ht.message:"Duplicate failed")}},St=async re=>{if(!J)return;const Le=l[J];if(!Le){de.error("Section not found.");return}try{await G.mutateAsync({blockKey:J,data:{...Le,name:re}}),de.success("Section renamed"),ee(null)}catch(Te){de.error(Te instanceof Error?Te.message:"Rename failed")}},ct=async re=>{const Le=zh(l,re),Te=da(Le,re,OV(re));try{await q.mutateAsync({blockKey:Le,data:Te}),de.success(`Created ${eo[re]}`),f({collection:re,key:Le})}catch(Oe){de.error(Oe instanceof Error?Oe.message:"Could not create")}},me=async re=>{const Le=l[re.key];if(!Le){de.error("Record not found.");return}const Te=zh(l,re.kind),Oe=re.kind==="posts"?"title":"name",st={...structuredClone(Ca(Le,re.kind)),[Oe]:`${re.label} (copy)`};try{await q.mutateAsync({blockKey:Te,data:da(Te,re.kind,st)}),de.success(`Duplicated "${re.label}"`),f({collection:re.kind,key:Te})}catch(ht){de.error(ht instanceof Error?ht.message:"Duplicate failed")}},Me=re=>{N(Le=>{const Te=new Set(Le);return Te.has(re)?Te.delete(re):Te.add(re),Te})},et=re=>{h("posts"),M("posts"),f(null),p(null),L(""),S(null),V(null),T("date-desc"),N(new Set),I(re||null)},tt=async(re,Le)=>{const Te=[...A];let Oe=0;for(const st of Te){const ht=l[st],kn=Ca(ht,"posts"),Qn=re==="add"?IV(kn,Le):DV(kn,Le);Qn!==kn&&(await q.mutateAsync({blockKey:st,data:da(st,"posts",Qn)}),Oe+=1)}return Oe},vs=async(re,Le)=>{const Te=A.size;try{const Oe=await tt(re,Le),st=re==="add"?"Added to":"Moved",ht=Te-Oe;de.success(`${st} ${Oe} ${Oe===1?"post":"posts"}`+(ht>0?` (${ht} already set)`:"")),D()}catch(Oe){de.error(Oe instanceof Error?Oe.message:"Bulk update failed")}},us=async()=>{if(te)try{if(te.kind==="blog-bulk"){for(const Oe of te.keys)await W.mutateAsync({blockKey:Oe});de.success(`Deleted ${te.count} ${te.count===1?"post":"posts"}`),u&&u.collection!=="available-section"&&te.keys.includes(u.key)&&f(null),D(),ae(null);return}const{kind:re,key:Le,label:Te}=te;if(re==="blog"){if(te.blogKind==="categories"){const Oe=Ca(l[Le],"categories").slug,st=typeof Oe=="string"?Oe:"";if(st)for(const{key:ht,payload:kn}of bo(l,"posts")){const Qn=MV(kn,st);Qn!==kn&&await q.mutateAsync({blockKey:ht,data:da(ht,"posts",Qn)})}}await W.mutateAsync({blockKey:Le})}else await K.mutateAsync({blockKey:Le});de.success(`Deleted "${Te}"`),u&&u.collection!=="available-section"&&u.key===Le&&f(null),ae(null)}catch(re){de.error(re instanceof Error?re.message:"Delete failed")}},Jt=K.isPending||W.isPending||q.isPending,mn=te?.kind==="blog"?eo[te.blogKind]:te?.kind==="blog-bulk"?`${te.count} ${te.count===1?"post":"posts"}`:te?.kind??"item";return i.jsxs("div",{className:"flex h-full w-full",children:[r==="content"&&i.jsx(Mk,{active:d,counts:Ee,showBlog:Ve,onSelect:re=>{h(re),f(null),p(null)}}),d!=="seo"&&d!=="site"&&d!=="calendar"&&d!=="loaders"&&d!=="actions"&&i.jsx(Ok,{blocksMode:r==="blocks",activeCollection:d,pages:ce,sections:fe,availableSections:be,appCatalog:H,appCatalogLoading:Y,blogEntries:Ne,decofile:l,searchQuery:y,onSearchChange:L,postCategoryFilter:w,postAuthorFilter:j,postSort:k,onPostCategoryFilterChange:re=>{S(re),N(new Set)},onPostAuthorFilterChange:re=>{V(re),N(new Set)},onPostSortChange:T,selectedPostKeys:A,postBulkPanelOpen:ye,onTogglePostSelect:Me,onSelectAllPosts:re=>N(new Set(re)),onClearPostSelection:()=>N(new Set),onExitPostSelection:D,onBulkDeletePosts:()=>ae({kind:"blog-bulk",keys:[...A],count:A.size}),selection:u,onSelect:E,onCollectionSelect:re=>{h(re),f(null),p(null)},onCreate:()=>{d==="pages"?Be():to(d)&&ct(d)},onDuplicatePage:Ue,onRenamePage:it,onAddPageVariant:ke,onDeletePage:re=>ae({kind:"page",key:re.key,label:re.name}),onEditPageSeo:re=>{const Le={collection:"pages",key:re.key,path:re.path};f(Le),p(re.key),r==="blocks"&&o.editSeo({kind:"page",key:re.key,path:re.path})},onViewPageJson:re=>oe(re.key),onDuplicateSection:lt,onRenameSection:re=>ee(re.key),onDeleteSection:re=>ae({kind:"section",key:re.key,label:re.name}),onDuplicateBlog:me,onDeleteBlog:re=>ae({kind:"blog",blogKind:re.kind,key:re.key,label:re.label})}),i.jsx("div",{className:"flex-1 min-w-0",children:d==="loaders"||d==="actions"?i.jsx(dk,{orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:z,decofile:l,kind:d}):i.jsx(C.Suspense,{fallback:i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),children:d==="calendar"?i.jsx(Nk,{decofile:l}):d==="site"?_e?i.jsx(Kh,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:_e.key,block:l[_e.key],decofile:l,meta:z,title:"Site",excludeFields:["seo"],schemaPending:U(_e.resolveType,["seo"]),previewBaseUrl:n},`site:${_e.key}`):i.jsx(Mn,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):d==="seo"?i.jsx(kk,{orgSlug:t,virtualMcpId:e,branch:s,decofile:l,meta:z,target:{kind:"site"},previewBaseUrl:n}):d==="sections"?i.jsx(Dk,{selection:u?.collection==="sections"||u?.collection==="available-section"?u:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:z,decofile:l,isCreating:G.isPending,onCreateAvailable:rt,onSaveReferencedBlock:gt}):ye?i.jsx(Ck,{posts:$e,categories:we,initialSlug:R,isPending:q.isPending,onApply:(re,Le)=>{vs(re,Le)},onClose:D},R??"selection"):u&&u.collection!=="available-section"?u.collection==="apps"?i.jsx(Kh,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:z,previewBaseUrl:n,schemaPending:U(typeof l[u.key]?.__resolveType=="string"?String(l[u.key].__resolveType):void 0)},`app:${u.key}`):u.collection==="posts"?i.jsx(Sk,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:z,previewBaseUrl:n},`post:${u.key}`):u.collection==="categories"?i.jsx(jk,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:z,onManagePosts:et,onOpenPost:re=>{h("posts"),M("posts"),f({collection:"posts",key:re}),p(null)},previewBaseUrl:n},`category:${u.key}`):u.collection==="authors"?i.jsx(wk,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:u.key,block:l[u.key]},`authors:${u.key}`):i.jsx(Vk,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:n??void 0,currentPath:u.collection==="pages"?u.path:"/",activePageBlockKey:u.collection==="pages"?u.key:null,activeGlobalBlockKey:u.collection==="sections"?u.key:null,initialEditSeo:u.collection==="pages"&&m===u.key,onExitSeo:()=>{p(null),r==="blocks"&&o.consumeEditSeo()},onSaved:r==="blocks"?o.notifySaved:void 0},u.collection==="pages"?`page:${u.key}`:`section:${u.key}`):i.jsx(Mn,{title:`Select ${to(d)?`a ${eo[d]}`:d==="pages"?"a page":d==="apps"?"an app":"a section"} to edit`,description:d==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),F&&i.jsx(kV,{open:!!F,mode:F.mode,initialName:F.initialName,initialPath:F.initialPath,isPending:G.isPending,error:Q,templates:ce,validate:Rt,onSubmit:Yt,onOpenChange:re=>{re||(X(null),Z(void 0))}}),J&&i.jsx(NV,{open:!!J,blockKey:J,initialName:fe.find(re=>re.key===J)?.name??J,isPending:G.isPending,onSubmit:St,onOpenChange:re=>{re||ee(null)}}),se&&i.jsx(GV,{open:!!se,onOpenChange:re=>{re||oe(null)},pageKey:se,decofile:l}),i.jsx(Fa,{open:!!te,onOpenChange:re=>{!re&&!Jt&&ae(null)},children:i.jsxs(Ua,{children:[i.jsxs(Ha,{children:[i.jsx(Ka,{children:`Delete ${mn}?`}),i.jsx(Wa,{children:te?.kind==="section"?`"${te.label}" will be removed. Pages that still reference it will lose this section.`:te?.kind==="blog-bulk"?`${te.count} ${te.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:te?`"${te.label}" will be removed permanently. This can't be undone.`:null})]}),i.jsxs(qa,{children:[i.jsx(Ga,{disabled:Jt,children:"Cancel"}),i.jsx(Ya,{onClick:re=>{re.preventDefault(),us()},disabled:Jt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Jt?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function Dk(t){const e=B.c(30),{selection:s,orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,isCreating:d,onCreateAvailable:h,onSaveReferencedBlock:u}=t;if(!s){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Mn,{title:"Select a section to edit",description:"Pick a saved section to edit it, or an available one to customize and save as global."}),e[0]=p):p=e[0],p}if(s.collection==="available-section"){const p=`available:${s.resolveType}`,g=s.resolveType,x=s.title;let v;e[1]!==s.title?(v=ap(s.title),e[1]=s.title,e[2]=v):v=e[2];let _;e[3]!==h||e[4]!==s.resolveType?(_=(y,L)=>h(s.resolveType,y,L),e[3]=h,e[4]=s.resolveType,e[5]=_):_=e[5];let b;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==l||e[10]!==u||e[11]!==n||e[12]!==a||e[13]!==s.resolveType||e[14]!==s.title||e[15]!==p||e[16]!==v||e[17]!==_||e[18]!==r?(b=i.jsx(ZC,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,resolveType:g,title:x,defaultBlockId:v,isCreating:d,onCreate:_,onSaveReferencedBlock:u},p),e[6]=o,e[7]=c,e[8]=d,e[9]=l,e[10]=u,e[11]=n,e[12]=a,e[13]=s.resolveType,e[14]=s.title,e[15]=p,e[16]=v,e[17]=_,e[18]=r,e[19]=b):b=e[19],b}const f=`saved:${s.key}`;let m;return e[20]!==o||e[21]!==c||e[22]!==l||e[23]!==u||e[24]!==n||e[25]!==a||e[26]!==s.key||e[27]!==f||e[28]!==r?(m=i.jsx(nV,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,blockKey:s.key,onSaveReferencedBlock:u},f),e[20]=o,e[21]=c,e[22]=l,e[23]=u,e[24]=n,e[25]=a,e[26]=s.key,e[27]=f,e[28]=r,e[29]=m):m=e[29],m}function Gh(t){const e=B.c(8),{icon:s,label:n,className:r}=t;let o;e[0]!==r?(o=ne("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=i.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==n||e[5]!==o||e[6]!==a?(l=i.jsxs("div",{className:o,children:[a,n]}),e[4]=n,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function Mk(t){const e=B.c(47),{active:s,counts:n,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:i.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let c;e[1]!==n.pages||e[2]!==o||e[3]!==l?(c=i.jsx($s,{id:"pages",icon:Dn,label:"Pages",count:n.pages,active:l,onSelect:o}),e[1]=n.pages,e[2]=o,e[3]=l,e[4]=c):c=e[4];const d=s==="sections";let h;e[5]!==n.sections||e[6]!==o||e[7]!==d?(h=i.jsx($s,{id:"sections",icon:on,label:"Sections",count:n.sections,active:d,onSelect:o}),e[5]=n.sections,e[6]=o,e[7]=d,e[8]=h):h=e[8];const u=s==="apps";let f;e[9]!==n.apps||e[10]!==o||e[11]!==u?(f=i.jsx($s,{id:"apps",icon:N1,label:"Apps",count:n.apps,active:u,onSelect:o}),e[9]=n.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];const m=s==="loaders";let p;e[13]!==n.loaders||e[14]!==o||e[15]!==m?(p=i.jsx($s,{id:"loaders",icon:$a,label:"Loaders",count:n.loaders,active:m,onSelect:o}),e[13]=n.loaders,e[14]=o,e[15]=m,e[16]=p):p=e[16];const g=s==="actions";let x;e[17]!==n.actions||e[18]!==o||e[19]!==g?(x=i.jsx($s,{id:"actions",icon:ui,label:"Actions",count:n.actions,active:g,onSelect:o}),e[17]=n.actions,e[18]=o,e[19]=g,e[20]=x):x=e[20];const v=s==="site";let _;e[21]!==o||e[22]!==v?(_=i.jsx($s,{id:"site",icon:rm,label:"Site",active:v,onSelect:o}),e[21]=o,e[22]=v,e[23]=_):_=e[23];const b=s==="seo";let y;e[24]!==o||e[25]!==b?(y=i.jsx($s,{id:"seo",icon:Ba,label:"SEO",active:b,onSelect:o}),e[24]=o,e[25]=b,e[26]=y):y=e[26];const L=s==="calendar";let w;e[27]!==o||e[28]!==L?(w=i.jsx($s,{id:"calendar",icon:wm,label:"Calendar",active:L,onSelect:o}),e[27]=o,e[28]=L,e[29]=w):w=e[29];let S;e[30]!==s||e[31]!==n.authors||e[32]!==n.categories||e[33]!==n.posts||e[34]!==o||e[35]!==r?(S=r&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[i.jsx(Ki,{size:13,className:"shrink-0"}),"Blog"]}),i.jsx($s,{id:"posts",icon:Wi,label:"Posts",count:n.posts,active:s==="posts",onSelect:o}),i.jsx($s,{id:"authors",icon:B9,label:"Authors",count:n.authors,active:s==="authors",onSelect:o}),i.jsx($s,{id:"categories",icon:im,label:"Categories",count:n.categories,active:s==="categories",onSelect:o})]}),e[30]=s,e[31]=n.authors,e[32]=n.categories,e[33]=n.posts,e[34]=o,e[35]=r,e[36]=S):S=e[36];let j;return e[37]!==x||e[38]!==_||e[39]!==y||e[40]!==w||e[41]!==S||e[42]!==c||e[43]!==h||e[44]!==f||e[45]!==p?(j=i.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,i.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[c,h,f,p,x,_,y,w,S]})]}),e[37]=x,e[38]=_,e[39]=y,e[40]=w,e[41]=S,e[42]=c,e[43]=h,e[44]=f,e[45]=p,e[46]=j):j=e[46],j}function $s(t){const e=B.c(18),{id:s,icon:n,label:r,count:o,active:a,onSelect:l}=t;let c;e[0]!==s||e[1]!==l?(c=()=>l(s),e[0]=s,e[1]=l,e[2]=c):c=e[2];const d=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==d?(h=ne("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==n?(u=i.jsx(n,{size:16,className:"shrink-0"}),e[5]=n,e[6]=u):u=e[6];let f;e[7]!==r?(f=i.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&i.jsx("span",{className:ne("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==c||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=i.jsxs("button",{type:"button",onClick:c,className:h,children:[u,f,m]}),e[12]=c,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function Ok(t){const e=B.c(86),{blocksMode:s,activeCollection:n,pages:r,sections:o,availableSections:a,appCatalog:l,appCatalogLoading:c,blogEntries:d,decofile:h,searchQuery:u,onSearchChange:f,postCategoryFilter:m,postAuthorFilter:p,postSort:g,onPostCategoryFilterChange:x,onPostAuthorFilterChange:v,onPostSortChange:_,selectedPostKeys:b,postBulkPanelOpen:y,onTogglePostSelect:L,onSelectAllPosts:w,onClearPostSelection:S,onExitPostSelection:j,onBulkDeletePosts:V,selection:k,onSelect:T,onCollectionSelect:A,onCreate:N,onDuplicatePage:R,onRenamePage:I,onAddPageVariant:D,onDeletePage:E,onEditPageSeo:P,onViewPageJson:M,onDuplicateSection:z,onRenameSection:$,onDeleteSection:O,onDuplicateBlog:U,onDeleteBlog:H}=t;let Y,G,K,q,W,F,X,Q;if(e[0]!==n||e[1]!==l||e[2]!==c||e[3]!==a||e[4]!==s||e[5]!==d||e[6]!==h||e[7]!==D||e[8]!==V||e[9]!==S||e[10]!==A||e[11]!==N||e[12]!==H||e[13]!==E||e[14]!==O||e[15]!==U||e[16]!==R||e[17]!==z||e[18]!==P||e[19]!==j||e[20]!==v||e[21]!==x||e[22]!==_||e[23]!==I||e[24]!==$||e[25]!==f||e[26]!==T||e[27]!==w||e[28]!==L||e[29]!==M||e[30]!==r||e[31]!==p||e[32]!==y||e[33]!==m||e[34]!==g||e[35]!==u||e[36]!==o||e[37]!==b||e[38]!==k){const te=u.toLowerCase(),ae=r.filter(me=>!te||me.name.toLowerCase().includes(te)||me.path.toLowerCase().includes(te)),se=o.filter(me=>!te||me.name.toLowerCase().includes(te)||me.key.toLowerCase().includes(te)||me.resolveType.toLowerCase().includes(te)),oe=a.filter(me=>!te||me.title.toLowerCase().includes(te)||me.resolveType.toLowerCase().includes(te)||(me.description?.toLowerCase().includes(te)??!1)),ce=Ek(se),fe=l.filter(me=>!te||me.title.toLowerCase().includes(te)||me.app.toLowerCase().includes(te)||me.vendor.toLowerCase().includes(te)||me.category.toLowerCase().includes(te)),be=d.filter(me=>!te||me.label.toLowerCase().includes(te)||me.subtitle.toLowerCase().includes(te)),_e=n==="posts",xe=Fk,Ve=_e?u3(h):[],Ne=new Map,we=new Map;for(const me of Ve){for(const Me of me.categorySlugs)Ne.set(Me,(Ne.get(Me)??0)+1);for(const Me of me.authorEmails)we.set(Me,(we.get(Me)??0)+1)}const ye=(_e?bo(h,"categories"):[]).map(me=>{const{key:Me,payload:et}=me,tt=xe(et.slug)||Me;return{slug:tt,name:xe(et.name)||xe(et.slug)||Me,count:Ne.get(tt)??0}}).filter(zk),$e=(_e?bo(h,"authors"):[]).map(me=>{const{key:Me,payload:et}=me,tt=xe(et.email);return{email:tt,name:xe(et.name)||xe(et.email)||Me,count:we.get(tt)??0}}).filter(Bk);let Fe;e[47]!==m?(Fe=me=>!m||me.categorySlugs.includes(m),e[47]=m,e[48]=Fe):Fe=e[48];let pe;e[49]!==p?(pe=me=>!p||me.authorEmails.includes(p),e[49]=p,e[50]=pe):pe=e[50];let Ee;e[51]!==g?(Ee=(me,Me)=>{if(g==="az")return me.title.localeCompare(Me.title);if(g==="za")return Me.title.localeCompare(me.title);const et=me.date.localeCompare(Me.date);return g==="date-asc"?et:-et},e[51]=g,e[52]=Ee):Ee=e[52];const De=Ve.filter(me=>!te||me.title.toLowerCase().includes(te)||me.slug.toLowerCase().includes(te)).filter(Fe).filter(pe).sort(Ee),he=b.size,le=De.map($k),ke=le.length>0&&le.every(me=>b.has(me)),Be=he>0||y,Ue=()=>{ke?S():w(le)},it=`Search ${n}…`,Yt=to(n)?`Create new ${eo[n]}`:"Create new page",Rt=n!=="apps"&&n!=="sections",rt=s?"w-[240px]":"w-[300px]";e[53]!==rt?(W=ne("shrink-0 border-r flex flex-col min-h-0",rt),e[53]=rt,e[54]=W):W=e[54],e[55]!==n||e[56]!==s||e[57]!==A?(F=s&&i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[i.jsxs(ie,{variant:n==="pages"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("pages"),children:[i.jsx(Dn,{size:14}),"Pages"]}),i.jsxs(ie,{variant:n==="sections"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("sections"),children:[i.jsx(on,{size:14}),"Sections"]})]}),e[55]=n,e[56]=s,e[57]=A,e[58]=F):F=e[58];let gt;e[59]===Symbol.for("react.memo_cache_sentinel")?(gt=i.jsx($9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[59]=gt):gt=e[59];let lt;e[60]!==f?(lt=me=>f(me.target.value),e[60]=f,e[61]=lt):lt=e[61];let St;e[62]!==it||e[63]!==u||e[64]!==lt?(St=i.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[gt,i.jsx("input",{type:"text",value:u,onChange:lt,placeholder:it,"aria-label":it,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[62]=it,e[63]=u,e[64]=lt,e[65]=St):St=e[65];let ct;e[66]!==Yt||e[67]!==N||e[68]!==Rt?(ct=Rt&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:N,"aria-label":Yt,children:i.jsx(Lt,{size:14})})}),i.jsx(Pe,{side:"bottom",children:Yt})]}),e[66]=Yt,e[67]=N,e[68]=Rt,e[69]=ct):ct=e[69],e[70]!==St||e[71]!==ct?(X=i.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[St,ct]}),e[70]=St,e[71]=ct,e[72]=X):X=e[72],Q=_e&&(Be?i.jsx(Xk,{count:he,allSelected:ke,onToggleSelectAll:Ue,onDelete:V,onExit:j}):i.jsx(Hk,{categories:ye,authors:$e,categoryFilter:m,authorFilter:p,sort:g,onCategoryFilterChange:x,onAuthorFilterChange:v,onSortChange:_})),Y=Sn,q="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",G="flex flex-col gap-1 p-1.5",K=n==="pages"?ae.length===0?i.jsx(Cr,{hasItems:r.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):ae.map(me=>{const Me=k?.collection==="pages"&&k.key===me.key,et=op(h,me.key);return i.jsx(tn,{icon:Dn,title:me.name,subtitle:me.path,active:Me,variantCount:et,onClick:()=>T({collection:"pages",key:me.key,path:me.path}),menu:i.jsx(ha,{onDuplicate:()=>R(me),onRename:()=>I(me),onAddVariant:()=>D(me),onEditSeo:()=>P(me),onViewJson:()=>M(me),onDelete:()=>E(me)})},me.key)}):n==="sections"?se.length===0&&oe.length===0?i.jsx(Cr,{hasItems:o.length>0||a.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):i.jsxs(i.Fragment,{children:[ce.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(Gh,{icon:on,label:"Saved sections"}),ce.map(me=>i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:me.label}),me.sections.map(Me=>{const et=k?.collection==="sections"&&k.key===Me.key;return i.jsx(tn,{icon:on,accent:"global",title:Me.name,subtitle:me.label,active:et,onClick:()=>T({collection:"sections",key:Me.key}),menu:i.jsx(ha,{onDuplicate:()=>z(Me),onRename:()=>$(Me),onDelete:()=>O(Me)})},Me.key)})]},me.label))]}),oe.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(Gh,{icon:Dn,label:"Available sections",className:ne(ce.length>0&&"mt-3")}),oe.map(me=>{const Me=k?.collection==="available-section"&&k.resolveType===me.resolveType,et=me.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return i.jsx(tn,{icon:Dn,title:me.title,subtitle:et??me.resolveType,active:Me,onClick:()=>T({collection:"available-section",resolveType:me.resolveType,title:me.title})},me.resolveType)})]})]}):n==="apps"?c?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(qe,{size:18,className:"animate-spin text-muted-foreground"})}):fe.length===0?i.jsx(Cr,{hasItems:l.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):fe.map(me=>{const Me=k?.collection==="apps"&&me.blockKey!==null&&k.key===me.blockKey;return i.jsx(tn,{icon:N1,logoUrl:me.logo,title:me.title,subtitle:me.category,active:Me,trailing:me.installed?i.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",children:"Installed"}):void 0,onClick:()=>{if(!me.installed||!me.blockKey){de.message(`${me.title} is not installed on this site.`);return}T({collection:"apps",key:me.blockKey})}},me.id)}):_e?De.length===0?i.jsx(Cr,{hasItems:Ve.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):De.map(me=>{const Me={key:me.key,kind:"posts",label:me.title,subtitle:me.slug};return i.jsx(tn,{icon:Wi,title:me.title,subtitle:me.slug,active:k?.collection==="posts"&&k.key===me.key,selectable:!0,selectionActive:Be,selected:b.has(me.key),onToggleSelect:()=>L(me.key),onClick:()=>Be?L(me.key):T({collection:"posts",key:me.key}),menu:i.jsx(ha,{onDuplicate:()=>U(Me),onDelete:()=>H(Me)})},me.key)}):be.length===0?i.jsx(Cr,{hasItems:d.length>0,emptyLabel:`No ${n} yet.`,emptyHint:`Click "+" to create your first ${to(n)?eo[n]:"item"}.`}):be.map(me=>{const Me=k?.collection===me.kind&&k.key===me.key;return i.jsx(tn,{icon:me.kind==="posts"?Wi:me.kind==="authors"?B9:im,title:me.label,subtitle:me.subtitle,active:Me,onClick:()=>T({collection:me.kind,key:me.key}),menu:i.jsx(ha,{onDuplicate:()=>U(me),onDelete:()=>H(me)})},me.key)}),e[0]=n,e[1]=l,e[2]=c,e[3]=a,e[4]=s,e[5]=d,e[6]=h,e[7]=D,e[8]=V,e[9]=S,e[10]=A,e[11]=N,e[12]=H,e[13]=E,e[14]=O,e[15]=U,e[16]=R,e[17]=z,e[18]=P,e[19]=j,e[20]=v,e[21]=x,e[22]=_,e[23]=I,e[24]=$,e[25]=f,e[26]=T,e[27]=w,e[28]=L,e[29]=M,e[30]=r,e[31]=p,e[32]=y,e[33]=m,e[34]=g,e[35]=u,e[36]=o,e[37]=b,e[38]=k,e[39]=Y,e[40]=G,e[41]=K,e[42]=q,e[43]=W,e[44]=F,e[45]=X,e[46]=Q}else Y=e[39],G=e[40],K=e[41],q=e[42],W=e[43],F=e[44],X=e[45],Q=e[46];let Z;e[73]!==G||e[74]!==K?(Z=i.jsx("div",{className:G,children:K}),e[73]=G,e[74]=K,e[75]=Z):Z=e[75];let J;e[76]!==Y||e[77]!==q||e[78]!==Z?(J=i.jsx(Y,{className:q,children:Z}),e[76]=Y,e[77]=q,e[78]=Z,e[79]=J):J=e[79];let ee;return e[80]!==W||e[81]!==F||e[82]!==X||e[83]!==Q||e[84]!==J?(ee=i.jsxs("div",{className:W,children:[F,X,Q,J]}),e[80]=W,e[81]=F,e[82]=X,e[83]=Q,e[84]=J,e[85]=ee):ee=e[85],ee}function $k(t){return t.key}function Bk(t){return t.email}function zk(t){return t.slug}function Fk(t){return typeof t=="string"?t:""}const Yh="__all__",S3={"date-desc":"Newest first","date-asc":"Oldest first",az:"Title A–Z",za:"Title Z–A"},Uk={"date-desc":"Newest","date-asc":"Oldest",az:"A–Z",za:"Z–A"},Jh=C.forwardRef(function(e,s){const n=B.c(20);let r,o,a,l,c;n[0]!==e?({icon:r,active:o,value:c,className:a,...l}=e,n[0]=e,n[1]=r,n[2]=o,n[3]=a,n[4]=l,n[5]=c):(r=n[1],o=n[2],a=n[3],l=n[4],c=n[5]);const d=o?"text-foreground":"text-muted-foreground";let h;n[6]!==a||n[7]!==d?(h=ne("h-7 gap-1 px-1.5 text-xs",d,a),n[6]=a,n[7]=d,n[8]=h):h=n[8];let u;n[9]!==r?(u=i.jsx(r,{size:14,className:"shrink-0"}),n[9]=r,n[10]=u):u=n[10];let f;n[11]!==c?(f=c&&i.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),n[11]=c,n[12]=f):f=n[12];let m;n[13]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Ht,{size:12,className:"shrink-0 opacity-60"}),n[13]=m):m=n[13];let p;return n[14]!==l||n[15]!==s||n[16]!==h||n[17]!==u||n[18]!==f?(p=i.jsxs(ie,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),n[14]=l,n[15]=s,n[16]=h,n[17]=u,n[18]=f,n[19]=p):p=n[19],p});function w3(t){const e=B.c(2),{count:s}=t;let n;return e[0]!==s?(n=i.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=n):n=e[1],n}function Hk(t){const e=B.c(60),{categories:s,authors:n,categoryFilter:r,authorFilter:o,sort:a,onCategoryFilterChange:l,onAuthorFilterChange:c,onSortChange:d}=t;let h;if(e[0]!==s||e[1]!==r){let H;e[3]!==r?(H=Y=>Y.slug===r,e[3]=r,e[4]=H):H=e[4],h=s.find(H),e[0]=s,e[1]=r,e[2]=h}else h=e[2];const u=h;let f;if(e[5]!==o||e[6]!==n){let H;e[8]!==o?(H=Y=>Y.email===o,e[8]=o,e[9]=H):H=e[9],f=n.find(H),e[5]=o,e[6]=n,e[7]=f}else f=e[7];const m=f,p=!!(r||o),g=u?.name??m?.name??"Filter",x=r?`cat:${r}`:o?`author:${o}`:Yh;let v;e[10]!==c||e[11]!==l?(v=()=>{l(null),c(null)},e[10]=c,e[11]=l,e[12]=v):v=e[12];const _=v;let b;e[13]!==_||e[14]!==c||e[15]!==l?(b=H=>{H.startsWith("cat:")?(c(null),l(H.slice(4))):H.startsWith("author:")?(l(null),c(H.slice(7))):_()},e[13]=_,e[14]=c,e[15]=l,e[16]=b):b=e[16];const y=b;let L;e[17]!==g||e[18]!==p?(L=i.jsx(es,{asChild:!0,children:i.jsx(Jh,{icon:hx,active:p,value:g,className:"min-w-0 shrink"})}),e[17]=g,e[18]=p,e[19]=L):L=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(Ir,{children:"Filter by"}),e[20]=w):w=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(Po,{value:Yh,children:"All posts"}),e[21]=S):S=e[21];let j;e[22]!==s.length?(j=s.length>0&&i.jsx(Ir,{className:"text-muted-foreground/70",children:"Category"}),e[22]=s.length,e[23]=j):j=e[23];let V;e[24]!==s?(V=s.map(qk),e[24]=s,e[25]=V):V=e[25];let k;e[26]!==n.length?(k=n.length>0&&i.jsx(Ir,{className:"text-muted-foreground/70",children:"Author"}),e[26]=n.length,e[27]=k):k=e[27];let T;e[28]!==n?(T=n.map(Wk),e[28]=n,e[29]=T):T=e[29];let A;e[30]!==x||e[31]!==y||e[32]!==k||e[33]!==T||e[34]!==j||e[35]!==V?(A=i.jsxs(ts,{align:"start",className:"max-h-96 w-60 overflow-y-auto",children:[w,i.jsxs(l0,{value:x,onValueChange:y,children:[S,j,V,k,T]})]}),e[30]=x,e[31]=y,e[32]=k,e[33]=T,e[34]=j,e[35]=V,e[36]=A):A=e[36];let N;e[37]!==A||e[38]!==L?(N=i.jsxs(Zt,{children:[L,A]}),e[37]=A,e[38]=L,e[39]=N):N=e[39];let R;e[40]!==_||e[41]!==p?(R=p&&i.jsx(Gk,{label:"Clear filter",onClick:_}),e[40]=_,e[41]=p,e[42]=R):R=e[42];const I=Uk[a];let D;e[43]!==I?(D=i.jsx(es,{asChild:!0,children:i.jsx(Jh,{icon:fx,active:!0,value:I})}),e[43]=I,e[44]=D):D=e[44];let E;e[45]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsx(Ir,{children:"Sort by"}),e[45]=E):E=e[45];let P;e[46]!==d?(P=H=>d(H),e[46]=d,e[47]=P):P=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(S3),e[48]=M):M=e[48];let z;e[49]===Symbol.for("react.memo_cache_sentinel")?(z=M.map(Kk),e[49]=z):z=e[49];let $;e[50]!==a||e[51]!==P?($=i.jsxs(ts,{align:"end",className:"w-44",children:[E,i.jsx(l0,{value:a,onValueChange:P,children:z})]}),e[50]=a,e[51]=P,e[52]=$):$=e[52];let O;e[53]!==D||e[54]!==$?(O=i.jsx("div",{className:"ml-auto shrink-0",children:i.jsxs(Zt,{children:[D,$]})}),e[53]=D,e[54]=$,e[55]=O):O=e[55];let U;return e[56]!==N||e[57]!==R||e[58]!==O?(U=i.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden border-b px-2 py-1.5",children:[N,R,O]}),e[56]=N,e[57]=R,e[58]=O,e[59]=U):U=e[59],U}function Kk(t){return i.jsx(Po,{value:t,children:S3[t]},t)}function Wk(t){return i.jsxs(Po,{value:`author:${t.email}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(w3,{count:t.count})]},`author:${t.email}`)}function qk(t){return i.jsxs(Po,{value:`cat:${t.slug}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(w3,{count:t.count})]},`cat:${t.slug}`)}function Gk(t){const e=B.c(4),{label:s,onClick:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(ms,{size:12}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==n?(o=i.jsx("button",{type:"button","aria-label":s,onClick:n,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:r}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function Yk(t){const e=B.c(12),{checked:s,disabled:n,onToggle:r}=t;let o;e[0]!==r?(o=()=>r(),e[0]=r,e[1]=o):o=e[1];const a=s?"Deselect all posts":"Select all posts";let l;e[2]!==s||e[3]!==n||e[4]!==o||e[5]!==a?(l=i.jsx(Re,{asChild:!0,children:i.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:Jk,children:i.jsx(cr,{checked:s,disabled:n,onCheckedChange:o,"aria-label":a})})}),e[2]=s,e[3]=n,e[4]=o,e[5]=a,e[6]=l):l=e[6];const c=s?"Deselect all":"Select all";let d;e[7]!==c?(d=i.jsx(Pe,{side:"bottom",children:c}),e[7]=c,e[8]=d):d=e[8];let h;return e[9]!==l||e[10]!==d?(h=i.jsxs(Ie,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=h):h=e[11],h}function Jk(t){return t.stopPropagation()}function Xk(t){const e=B.c(25),{count:s,allSelected:n,onToggleSelectAll:r,onDelete:o,onExit:a}=t;let l;e[0]!==n||e[1]!==r?(l=i.jsx(Yk,{checked:n,onToggle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;e[3]!==s?(c=i.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s," selected"]}),e[3]=s,e[4]=c):c=e[4];const d=s===0;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(ws,{size:14}),e[5]=h):h=e[5];let u;e[6]!==o||e[7]!==d?(u=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:d,onClick:o,"aria-label":"Delete selected posts",children:h})}),e[6]=o,e[7]=d,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Pe,{side:"bottom",children:"Delete selected"}),e[9]=f):f=e[9];let m;e[10]!==u?(m=i.jsxs(Ie,{children:[u,f]}),e[10]=u,e[11]=m):m=e[11];let p;e[12]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(ms,{size:14}),e[12]=p):p=e[12];let g;e[13]!==a?(g=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,"aria-label":"Exit selection",children:p})}),e[13]=a,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Pe,{side:"bottom",children:"Exit selection"}),e[15]=x):x=e[15];let v;e[16]!==g?(v=i.jsxs(Ie,{children:[g,x]}),e[16]=g,e[17]=v):v=e[17];let _;e[18]!==v||e[19]!==m?(_=i.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m,v]}),e[18]=v,e[19]=m,e[20]=_):_=e[20];let b;return e[21]!==l||e[22]!==_||e[23]!==c?(b=i.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[l,c,_]}),e[21]=l,e[22]=_,e[23]=c,e[24]=b):b=e[24],b}function tn(t){const e=B.c(37),{icon:s,logoUrl:n,title:r,subtitle:o,active:a,accent:l,variantCount:c,trailing:d,selectable:h,selectionActive:u,selected:f,onToggleSelect:m,onClick:p,menu:g}=t,x=l==="global";let v;e[0]!==s||e[1]!==a||e[2]!==x||e[3]!==n||e[4]!==c?(v=c&&c>1?i.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(s,{size:16,className:"shrink-0",style:{color:w0}})}),i.jsxs(Pe,{side:"right",children:[c," variants"]})]})}):n?i.jsx("img",{src:n,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):i.jsx("span",{className:ne("flex size-8 shrink-0 items-center justify-center rounded-lg",x?"bg-global-section/15":"bg-muted"),children:i.jsx(s,{size:16,className:ne("shrink-0",!x&&(a?"text-accent-foreground":"text-muted-foreground")),style:x?{color:td}:void 0})}),e[0]=s,e[1]=a,e[2]=x,e[3]=n,e[4]=c,e[5]=v):v=e[5];const _=v,b=a?x?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":x?"hover:bg-global-section/10":"hover:bg-muted";let y;e[6]!==b?(y=ne("group relative flex min-w-0 items-center rounded-md transition-colors",b),e[6]=b,e[7]=y):y=e[7];let L;e[8]!==m||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==r?(L=h&&i.jsx("span",{className:ne("flex shrink-0 items-center pl-2.5 transition-opacity",f||u?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"),onClick:Qk,children:i.jsx(cr,{checked:f,onCheckedChange:()=>m?.(),"aria-label":`Select ${r}`})}),e[8]=m,e[9]=h,e[10]=f,e[11]=u,e[12]=r,e[13]=L):L=e[13];let w;e[14]!==r?(w=i.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[14]=r,e[15]=w):w=e[15];const S=a?"text-accent-foreground/70":"text-muted-foreground";let j;e[16]!==S?(j=ne("block truncate text-xs",S),e[16]=S,e[17]=j):j=e[17];let V;e[18]!==o||e[19]!==j?(V=i.jsx("span",{className:j,children:o}),e[18]=o,e[19]=j,e[20]=V):V=e[20];let k;e[21]!==w||e[22]!==V?(k=i.jsxs("span",{className:"min-w-0 flex-1",children:[w,V]}),e[21]=w,e[22]=V,e[23]=k):k=e[23];let T;e[24]!==p||e[25]!==_||e[26]!==k||e[27]!==d?(T=i.jsxs("button",{type:"button",onClick:p,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[_,k,d]}),e[24]=p,e[25]=_,e[26]=k,e[27]=d,e[28]=T):T=e[28];let A;e[29]!==a||e[30]!==g?(A=g&&i.jsx("div",{className:ne("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:g}),e[29]=a,e[30]=g,e[31]=A):A=e[31];let N;return e[32]!==T||e[33]!==A||e[34]!==y||e[35]!==L?(N=i.jsxs("div",{className:y,children:[L,T,A]}),e[32]=T,e[33]=A,e[34]=y,e[35]=L,e[36]=N):N=e[36],N}function Qk(t){return t.stopPropagation()}function ha(t){const e=B.c(21),{onDuplicate:s,onRename:n,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(es,{asChild:!0,children:i.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:Zk,children:i.jsx(Gn,{size:14})})}),e[0]=c):c=e[0];let d;e[1]!==n?(d=n&&i.jsxs(He,{onClick:n,children:[i.jsx(w9,{size:14}),"Rename"]}),e[1]=n,e[2]=d):d=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Ss,{size:14}),e[3]=h):h=e[3];let u;e[4]!==s?(u=i.jsxs(He,{onClick:s,children:[h,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),i.jsxs(He,{onClick:r,className:"cursor-pointer",style:{color:w0},children:[i.jsx(jm,{size:14,style:{color:w0}}),"Add variant"]})]}),e[6]=r,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=(o||a)&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),o&&i.jsxs(He,{onClick:o,children:[i.jsx(Ba,{size:14}),"Edit SEO"]}),a&&i.jsxs(He,{onClick:a,children:[i.jsx(Ao,{size:14}),"View JSON"]})]}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Di,{}),e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(ws,{size:14}),e[12]=g):g=e[12];let x;e[13]!==l?(x=i.jsxs(He,{onClick:l,className:"text-destructive focus:text-destructive",children:[g,"Delete"]}),e[13]=l,e[14]=x):x=e[14];let v;return e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==x?(v=i.jsxs(Zt,{children:[c,i.jsxs(ts,{align:"end",className:"w-44",children:[d,u,f,m,p,x]})]}),e[15]=d,e[16]=u,e[17]=f,e[18]=m,e[19]=x,e[20]=v):v=e[20],v}function Zk(t){return t.stopPropagation()}function Cr(t){const e=B.c(6),{hasItems:s,emptyLabel:n,emptyHint:r}=t;let o;e[0]!==r||e[1]!==n||e[2]!==s?(o=s?"No results match your search.":i.jsxs(i.Fragment,{children:[i.jsx("div",{children:n}),i.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=n,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function eN(t){const e=B.c(12),{state:s,claimPhase:n,lifecycle:r,onStart:o,connectionsHref:a}=t;switch(s.kind){case"starting":{let l;e[0]!==n||e[1]!==r?(l=n3({claimPhase:n,lifecycle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==l?(c=i.jsx(Bi,{kind:"starting",progress:l,claimPhase:n}),e[3]=n,e[4]=l,e[5]=c):c=e[5],c}case"suspended":{let l;return e[6]!==o?(l=i.jsx(Bi,{kind:"suspended",onResume:o}),e[6]=o,e[7]=l):l=e[7],l}case"errored":{let l;return e[8]!==a||e[9]!==o||e[10]!==s.error?(l=i.jsx(Bi,{kind:"errored",error:s.error,onRetry:o,connectionsHref:a}),e[8]=a,e[9]=o,e[10]=s.error,e[11]=l):l=e[11],l}}}function Mn(t){const e=B.c(10),{icon:s,title:n,description:r}=t;let o;e[0]!==s?(o=s&&i.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==n?(a=i.jsx("div",{children:n}),e[2]=n,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&i.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==a||e[8]!==l?(c=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}const tN=new Set(["clone-failed","install-failed","start-failed","crashed"]);function sN(t){return tN.has(t.lifecyclePhase)?{kind:"error",source:"sandbox"}:t.lifecyclePhase!=="running"?{kind:"loading"}:t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData?{kind:"error",source:"data"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty"}}const nN="https://github.com/decocms/blocks";function iN(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(mx,{size:48,className:"text-muted-foreground"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(qi,{image:e,title:"No editable Blocks found",description:"This project does not expose editable Blocks content yet. Learn how to add Blocks to your project.",actions:i.jsx(ie,{variant:"outline",size:"sm",asChild:!0,children:i.jsxs("a",{href:nN,target:"_blank",rel:"noreferrer",children:["View Blocks docs",i.jsx(wn,{size:14})]})})}),t[1]=s):s=t[1],s}function rN(t){const e=B.c(6),{source:s,onRetry:n}=t,r=s==="sandbox"?"The project preview could not start. Retry to make Blocks available.":"Studio could not load this project's Blocks metadata.";let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(fn,{size:48,className:"text-muted-foreground"}),e[0]=o):o=e[0];let a;e[1]!==n?(a=i.jsx(ie,{variant:"outline",size:"sm",onClick:n,children:"Retry"}),e[1]=n,e[2]=a):a=e[2];let l;return e[3]!==r||e[4]!==a?(l=i.jsx(qi,{image:o,title:"Blocks unavailable",description:r,actions:a}),e[3]=r,e[4]=a,e[5]=l):l=e[5],l}function pi(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}function j3(t){const e=B.c(28),{virtualMcpId:s}=t,{org:n}=Ae(),{currentBranch:r}=as(),o=Os(),a=dr(),l=o.lifecycle.phase==="running";let c;e[0]!==r||e[1]!==l||e[2]!==a||e[3]!==n||e[4]!==s?(c=r&&l?{orgSlug:n.slug,virtualMcpId:s,branch:r,previewUrl:a.previewUrl}:null,e[0]=r,e[1]=l,e[2]=a,e[3]=n,e[4]=s,e[5]=c):c=e[5];const d=c;let h;e[6]!==l?(h={fetchEnabled:l},e[6]=l,e[7]=h):h=e[7];const u=Ml(d,h);let f;e[8]!==l?(f={fetchEnabled:l},e[8]=l,e[9]=f):f=e[9];const m=Ol(d,f),p=u.data!==void 0;let g;e[10]!==u.data||e[11]!==u.status||e[12]!==m.data||e[13]!==m.status||e[14]!==o.lifecycle.phase||e[15]!==p?(g=sN({lifecyclePhase:o.lifecycle.phase,decofile:{status:u.status,hasData:p},meta:{status:m.status,hasData:m.data!==void 0},hasEditableContent:ad(u.data,m.data)}),e[10]=u.data,e[11]=u.status,e[12]=m.data,e[13]=m.status,e[14]=o.lifecycle.phase,e[15]=p,e[16]=g):g=e[16];const x=g;if(x.kind==="loading"){let _;return e[17]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(pi,{}),e[17]=_):_=e[17],_}if(x.kind==="empty"){let _;return e[18]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(iN,{}),e[18]=_):_=e[18],_}if(x.kind==="error"){let _;e[19]!==u||e[20]!==a||e[21]!==m||e[22]!==x.source?(_=()=>{if(x.source==="sandbox"){a.retry();return}Promise.all([u.refetch(),m.refetch()])},e[19]=u,e[20]=a,e[21]=m,e[22]=x.source,e[23]=_):_=e[23];const b=_;let y;return e[24]!==b||e[25]!==x.source?(y=i.jsx(rN,{source:x.source,onRetry:b}),e[24]=b,e[25]=x.source,e[26]=y):y=e[26],y}let v;return e[27]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx("div",{"data-testid":"blocks-panel",className:"h-full min-h-0 overflow-hidden",children:i.jsx(L3,{mode:"blocks"})}),e[27]=v):v=e[27],v}function Xh(t,e){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function oN(t){const e=B.c(10),s=F5[t];let n;e[0]!==t?(n=v1.sidePanelWidth(t),e[0]=t,e[1]=n):n=e[1];let r;e[2]!==s?(r=d=>Xh(d,s),e[2]=s,e[3]=r):r=e[3];const[o,a]=z4(n,r);let l;e[4]!==s||e[5]!==o?(l=Xh(o,s),e[4]=s,e[5]=o,e[6]=l):l=e[6];let c;return e[7]!==a||e[8]!==l?(c=[l,a],e[7]=a,e[8]=l,e[9]=c):c=e[9],c}function aN(t){try{return JSON.parse(t)}catch{return null}}function lN(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,n=s?aN(s):null,r=e.structuredContent;return r==null?n:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?n??r:r}function ji(t){const e=lN(t);return e===null?null:e}function Md(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function cN(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],n=Md(s);return!n||!s?null:{number:n,htmlUrl:s}}const Qh=/[\r\n<>]/,dN=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Ko(t){const e=t?.userName?.trim();if(!e||Qh.test(e))return null;const s=t?.userEmail?.trim();return!s||Qh.test(s)?{userName:e}:dN.test(s)?{userName:e,userEmail:s}:{userName:e}}function uN(t){return t.split(`
|
|
25
25
|
`).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
|
|
26
26
|
`).trimEnd()}function hN(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function C3(t,e){const s=Ko(e);if(!s)return t;const n=uN(t),r=hN(s);if(n.includes(r))return n;const o=n.trimEnd();return o.length>0?`${o}
|
|
27
27
|
|
|
@@ -178,7 +178,7 @@ ${X}`:X;d.setValue("metadata.instructions",Q,{shouldDirty:!0})},Y=new Set(h.map(
|
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
})();`;function ki(t){return t.replace(/[`*_]/g,"\\$&")}function tP(t,e){const s=[`The user selected an element on the live preview and asked: **"${ki(e.trim())}"**`,"","For text content changes, locate the correct source file and apply the change.","For code and CSS changes, understand which component the user is referring to and apply changes to the correct component.",""];t.manifestKey&&s.push(`**Section resolveType:** \`${ki(t.manifestKey)}\``,"","This is a Deco resolveType, not a literal file path. The leading segment is the app name, not a directory — the actual source file lives under a sections directory whose root varies by site (commonly `sections/`, `src/sections/`, or `site/sections/`). Locate the file by searching for the trailing path (e.g. the component filename), don't assume the resolveType is a valid path on disk.","");const n=`<${t.tag}${t.classes?` class="${ki(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${n}\``),t.parents&&s.push(`**DOM breadcrumb:** ${ki(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${ki(t.text)}"`),t.componentName&&s.push(`**Component name:** ${ki(t.componentName)}`);const r=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",r,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
|
|
181
|
-
`)}function sP(t,e,s=320,n=44,r=12){const{x:o,y:a}=t,{width:l,height:c}=e,d=Math.max(r,Math.min(o-s/2,l-s-r)),u=a/c>.68?Math.max(r,a-n-18):Math.min(a+18,c-n-r);return{leftPct:d/l*100,topPct:u/c*100}}function nP(t){const e=B.c(32),{element:s,onDismiss:n}=t,[r,o]=C.useState(""),a=C.useRef(null),{sendMessage:l}=js(),{setChatOpen:c}=ko();let d;e[0]!==s||e[1]!==r||e[2]!==n||e[3]!==l||e[4]!==c?(d=()=>{if(!r.trim())return;const k=tP(s,r);c(!0),l({parts:[{type:"text",text:k}]}),n()},e[0]=s,e[1]=r,e[2]=n,e[3]=l,e[4]=c,e[5]=d):d=e[5];const h=d;let u;e[6]!==s.position||e[7]!==s.viewport?(u=sP(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const f=u,m=`${f.leftPct}%`,p=`${f.topPct}%`;let g;e[9]!==m||e[10]!==p?(g={left:m,top:p,width:"320px"},e[9]=m,e[10]=p,e[11]=g):g=e[11];let x;e[12]!==h?(x=k=>{k.preventDefault(),h()},e[12]=h,e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=k=>o(k.target.value),e[14]=v):v=e[14];let _;e[15]!==n?(_=k=>{k.key==="Escape"&&n()},e[15]=n,e[16]=_):_=e[16];let b;e[17]!==r||e[18]!==_?(b=i.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:v,onKeyDown:_,placeholder:"Ask the AI...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[17]=r,e[18]=_,e[19]=b):b=e[19];let y;e[20]!==r?(y=r.trim(),e[20]=r,e[21]=y):y=e[21];const L=!y;let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[i.jsx("title",{children:"Send"}),i.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=w):w=e[22];let S;e[23]!==L?(S=i.jsx("button",{type:"submit",disabled:L,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:"Send",children:w}),e[23]=L,e[24]=S):S=e[24];let j;e[25]!==S||e[26]!==x||e[27]!==b?(j=i.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:x,children:[b,S]}),e[25]=S,e[26]=x,e[27]=b,e[28]=j):j=e[28];let V;return e[29]!==j||e[30]!==g?(V=i.jsx("div",{className:"absolute z-30 pointer-events-none",style:g,children:j}),e[29]=j,e[30]=g,e[31]=V):V=e[31],V}function iP(t,e,s){return`deco:preview:last-page:${t}:${e}:${s}`}function rP(t){if(!t)return null;try{const e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e)||typeof e.path!="string"||!e.path.startsWith("/"))return null;const s=typeof e.pageKey=="string"?e.pageKey:null,n={};if(e.params&&typeof e.params=="object")for(const[r,o]of Object.entries(e.params))typeof o=="string"&&(n[r]=o);return{path:e.path,pageKey:s,params:n}}catch{return null}}function oP(t){try{return rP(localStorage.getItem(t))}catch{return null}}function aP(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function pl(t,e){const n=e.replace(/\\/g,"/").replace(/^(?!\/)/,"/").split("/").map(r=>encodeURIComponent(r).replace(/%3A/gi,":")).join("/");return`${t}://file${n}?windowId=_blank`}const ka={product:"vtex/loaders/intelligentSearch/productList.ts",category:"vtex/loaders/categories/tree.ts"};function lP(t,e){const s=m0(ai(t));if(e==="*")return s.some(o=>o.type==="param"&&o.name==="*")?"category":null;const n=s[s.length-1],r=s[s.length-2];return n?.type==="text"&&n.text==="/p"&&r?.type==="param"&&r.name===e?"product":null}function cP(t,e){if(t==="category")return[{resolveType:ka.category,props:{}}];const s=e.trim(),n=[];/^\d+$/.test(s)&&n.push({resolveType:ka.product,props:{ids:[s]}});const o=s.includes("-")&&!/\s/.test(s)?s.replace(/-+/g," "):s;return n.push({resolveType:ka.product,props:{query:o,count:10}}),n}function dP(t){const e=new Set,s=[];for(const n of t)for(const r of n)e.has(r.value)||(e.add(r.value),s.push(r));return s}function Na(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function vg(t){try{return decodeURIComponent(t)}catch{return t}}function uP(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.match(/^\/([^/]+)\/p\/?$/)?.[1];return s?vg(s):null}function hP(t){if(!Array.isArray(t))return[];const e=[],s=new Set;for(const n of t){const r=Na(n);if(!r)continue;const o=uP(r.url);if(!o||s.has(o))continue;s.add(o);const a=Na(r.isVariantOf),l=typeof a?.name=="string"&&a.name||typeof r.name=="string"&&r.name||o,c=Array.isArray(r.image)?Na(r.image[0]):null,d=typeof c?.url=="string"?c.url:void 0;e.push({value:o,label:l,image:d})}return e}function fP(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.replace(/^\/+|\/+$/g,"");return s?vg(s):null}function mP(t){const e=[],s=new Set,n=(r,o)=>{const a=Na(r);if(!a)return;const l=typeof a.name=="string"&&a.name?a.name:"",c=l?[...o,l]:o,d=fP(a.url);if(d&&!s.has(d)&&(s.add(d),e.push({value:d,label:c.join(" › ")||d})),Array.isArray(a.children))for(const h of a.children)n(h,c)};if(Array.isArray(t))for(const r of t)n(r,[]);return e}function pP(t,e,s=50){const n=e.trim().toLowerCase();return(n?t.filter(o=>o.label.toLowerCase().includes(n)||o.value.toLowerCase().includes(n)):t).slice(0,s)}const gP=1e4;async function xP(t,{resolveType:e,props:s}){const n=await fetch(_3(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(gP)});if(!n.ok)throw new Error(`Failed to fetch options: ${n.status}`);return n.json()}async function vP(t,e,s){const n=cP(e,s),r=await Promise.allSettled(n.map(a=>xP(t,a))),o=r.filter(a=>a.status==="fulfilled").map(a=>a.value);if(o.length===0){const a=r.find(l=>l.status==="rejected");throw a?a.reason:new Error("Failed to fetch options")}return dP(o.map(a=>e==="product"?hP(a):mP(a)))}function _P(t){const e=B.c(78),{kind:s,paramName:n,value:r,sandboxRef:o,onCommit:a}=t,[l,c]=C.useState(!1),[d,h]=C.useState(""),[u,f]=C.useState(""),m=C.useRef(null),p=s==="product"?"product":"category",g=n==="*"?"*":`:${n}`;let x;e[0]!==r?(x=ee=>{c(ee),m.current&&clearTimeout(m.current),h(ee?r:""),f(ee?r:"")},e[0]=r,e[1]=x):x=e[1];const v=x;let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=ee=>{h(ee),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{f(ee)},300)},e[2]=_):_=e[2];const b=_;let y;e[3]!==v||e[4]!==a?(y=ee=>{a(ee),v(!1)},e[3]=v,e[4]=a,e[5]=y):y=e[5];const L=y;let w;e[6]!==u||e[7]!==s||e[8]!==o.branch||e[9]!==o.orgSlug||e[10]!==o.virtualMcpId?(w=Qe.sandboxInvoke(`${o.orgSlug}/${o.virtualMcpId}/${o.branch}`,`path-param-${s}:${s==="product"?u:""}`),e[6]=u,e[7]=s,e[8]=o.branch,e[9]=o.orgSlug,e[10]=o.virtualMcpId,e[11]=w):w=e[11];let S;e[12]!==u||e[13]!==s||e[14]!==o?(S=()=>vP(o,s,u),e[12]=u,e[13]=s,e[14]=o,e[15]=S):S=e[15];let j;e[16]!==l||e[17]!==w||e[18]!==S?(j={queryKey:w,queryFn:S,enabled:l,staleTime:6e4,retry:1},e[16]=l,e[17]=w,e[18]=S,e[19]=j):j=e[19];const V=gs(j);let k;e[20]!==s||e[21]!==V.data||e[22]!==d?(k=s==="product"?V.data??[]:pP(V.data??[],d),e[20]=s,e[21]=V.data,e[22]=d,e[23]=k):k=e[23];const T=k;let A;e[24]!==d?(A=d.trim(),e[24]=d,e[25]=A):A=e[25];const N=A,R=s==="product"?`/${N}/p`:`/${N}`,I=`Value for ${g} — click to pick a ${p}`;let D;e[26]!==v?(D=ee=>{ee.stopPropagation(),v(!0)},e[26]=v,e[27]=D):D=e[27];const E=r||g;let P;e[28]!==D||e[29]!==E||e[30]!==I?(P=i.jsx("button",{type:"button",title:I,className:"max-w-64 shrink-0 cursor-pointer truncate rounded-sm bg-violet-500/15 px-1 py-0.5 text-[12px] text-violet-600 hover:bg-violet-500/25 dark:text-violet-400",onClick:D,children:E}),e[28]=D,e[29]=E,e[30]=I,e[31]=P):P=e[31];let M;e[32]!==p||e[33]!==g?(M=i.jsx(ns,{className:"sr-only",children:i.jsxs(is,{children:["Pick a ",p," or enter a value for ",g]})}),e[32]=p,e[33]=g,e[34]=M):M=e[34];let z;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=i.jsx(r0,{size:16,className:"shrink-0 text-foreground"}),e[35]=z):z=e[35];let $;e[36]!==g?($=i.jsx("span",{className:"rounded-sm bg-violet-500/15 px-1 py-0.5 font-mono text-[12px] text-violet-600 dark:text-violet-400",children:g}),e[36]=g,e[37]=$):$=e[37];let O;e[38]!==p||e[39]!==$?(O=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[z,i.jsxs("span",{className:"text-sm font-medium text-foreground",children:["Pick a ",p," for"," ",$]})]}),e[38]=p,e[39]=$,e[40]=O):O=e[40];const U=s==="product"?"Search products or enter a slug...":"Search categories or enter a path...";let H;e[41]!==d||e[42]!==U?(H=i.jsx(yi,{autoFocus:!0,placeholder:U,value:d,onValueChange:b}),e[41]=d,e[42]=U,e[43]=H):H=e[43];const Y=V.isLoading?"Loading...":V.isError?"Couldn't load — is the dev server running?":"No results.";let G;e[44]!==Y?(G=i.jsx(Li,{children:Y}),e[44]=Y,e[45]=G):G=e[45];let K;e[46]!==L||e[47]!==g||e[48]!==R||e[49]!==N?(K=N&&i.jsx(Fs,{children:i.jsxs(Ps,{value:`__raw__:${N}`,className:"gap-3 py-2",onSelect:()=>L(N),children:[i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted",children:i.jsx(To,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsxs("span",{className:"block truncate text-sm",children:["Use “",N,"” as ",g]}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:R})]})]})}),e[46]=L,e[47]=g,e[48]=R,e[49]=N,e[50]=K):K=e[50];let q;if(e[51]!==L||e[52]!==s||e[53]!==T){let ee;e[55]!==L||e[56]!==s?(ee=te=>i.jsxs(Ps,{value:te.value,className:"gap-3 py-2",onSelect:()=>L(te.value),children:[s==="product"&&i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:te.image?i.jsx("img",{src:te.image,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):i.jsx(r0,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm",children:te.label}),i.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:["/",s==="product"?`${te.value}/p`:te.value]})]})]},te.value),e[55]=L,e[56]=s,e[57]=ee):ee=e[57],q=T.map(ee),e[51]=L,e[52]=s,e[53]=T,e[54]=q}else q=e[54];let W;e[58]!==q?(W=i.jsx(Fs,{children:q}),e[58]=q,e[59]=W):W=e[59];let F;e[60]!==G||e[61]!==K||e[62]!==W?(F=i.jsxs(Si,{className:"max-h-none flex-1",children:[G,K,W]}),e[60]=G,e[61]=K,e[62]=W,e[63]=F):F=e[63];let X;e[64]!==H||e[65]!==F?(X=i.jsxs(lr,{shouldFilter:!1,className:"min-h-0 flex-1",children:[H,F]}),e[64]=H,e[65]=F,e[66]=X):X=e[66];let Q;e[67]!==M||e[68]!==O||e[69]!==X?(Q=i.jsxs(Ft,{className:"flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",onClick:bP,children:[M,O,X]}),e[67]=M,e[68]=O,e[69]=X,e[70]=Q):Q=e[70];let Z;e[71]!==v||e[72]!==l||e[73]!==Q?(Z=i.jsx(Ut,{open:l,onOpenChange:v,children:Q}),e[71]=v,e[72]=l,e[73]=Q,e[74]=Z):Z=e[74];let J;return e[75]!==P||e[76]!==Z?(J=i.jsxs(i.Fragment,{children:[P,Z]}),e[75]=P,e[76]=Z,e[77]=J):J=e[77],J}function bP(t){return t.stopPropagation()}function _g(t){const e=B.c(12),{orgSlug:s,virtualMcpId:n,branch:r,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==r||e[1]!==s||e[2]!==n?(l=Qe.sandboxRepoDir(s,n,r),e[0]=r,e[1]=s,e[2]=n,e[3]=l):l=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==n?(c=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(r)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=r,e[5]=s,e[6]=n,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d={queryKey:l,queryFn:c,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],gs(d).data??null}const yP="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",LP="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",SP=C.lazy(()=>Ws(()=>import("./page-seo-sheet-DlP_RlkU.js"),__vite__mapDeps([161,1,2,19,20,21,22,6,4,5,7,8,9,10,11,12,13,14,15,16,17,18,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,3,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,157,135,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SeoSheet}))),vf=500,wP={mobile:375,tablet:768,desktop:null},$c=["desktop","mobile","tablet"],_f={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function jP(t){const e=B.c(24),{name:s,value:n,onCommit:r}=t,[o,a]=C.useState(n),[l,c]=C.useState(!1),d=C.useRef(!1),h=s==="*"?"*":`:${s}`,u=o||h;let f;e[0]!==u?(f=i.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-[12px]",children:u}),e[0]=u,e[1]=f):f=e[1];const m=`Value for ${h}`;let p,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=w=>a(w.target.value),g=()=>c(!0),e[2]=p,e[3]=g):(p=e[2],g=e[3]);let x;e[4]!==n?(x=w=>{w.key==="Enter"&&w.currentTarget.blur(),w.key==="Escape"&&(d.current=!0,a(n),w.currentTarget.blur())},e[4]=n,e[5]=x):x=e[5];let v;e[6]!==o||e[7]!==r||e[8]!==n?(v=()=>{if(c(!1),d.current){d.current=!1;return}const w=o.trim();a(w),w!==n&&r(w)},e[6]=o,e[7]=r,e[8]=n,e[9]=v):v=e[9];let _;e[10]!==o||e[11]!==h||e[12]!==m||e[13]!==x||e[14]!==v?(_=i.jsx("input",{type:"text",value:o,placeholder:h,title:m,spellCheck:!1,className:"absolute inset-0 rounded-sm bg-violet-500/15 px-1 text-[12px] text-violet-600 outline-none placeholder:text-violet-500/60 focus:bg-violet-500/25 dark:text-violet-400",onClick:CP,onChange:p,onFocus:g,onKeyDown:x,onBlur:v}),e[10]=o,e[11]=h,e[12]=m,e[13]=x,e[14]=v,e[15]=_):_=e[15];let b;e[16]!==f||e[17]!==_?(b=i.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[f,_]}),e[16]=f,e[17]=_,e[18]=b):b=e[18];let y;e[19]!==l?(y=l&&i.jsxs("span",{className:"pointer-events-none ml-1.5 flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[i.jsx(jx,{size:10}),"Enter to go"]}),e[19]=l,e[20]=y):y=e[20];let L;return e[21]!==b||e[22]!==y?(L=i.jsxs(i.Fragment,{children:[b,y]}),e[21]=b,e[22]=y,e[23]=L):L=e[23],L}function CP(t){return t.stopPropagation()}function VP(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function kP(){const t=Vn(),e=Ct(),{currentBranch:s}=as(),n=y3(),r=ue=>{e({to:".",search:je=>({...je,main:ue}),replace:!0})},[o,a]=C.useState("preview"),[l,c]=C.useState("desktop"),[d,h]=C.useState(null),u=C.useRef(null),[f,m]=C.useState(!1),[p,g]=C.useState(""),x=C.useRef(null),[v,_]=C.useState(!1),[b,y]=C.useState(),[L,w]=C.useState(null),[S,j]=C.useState(null),[V,k]=C.useState("/"),[T,A]=C.useState(null),[N,R]=C.useState({}),[I,D]=C.useState(!1),E=C.useRef(null),P=()=>{D(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>D(!1),15e3)},M=()=>{E.current&&(clearTimeout(E.current),E.current=null),D(!1)},[z,$]=C.useState(!1),O=t?.entity?.id??null,{org:U}=Ae(),H=Os(),Y=dr(),G=Y.vmEntry,K=Y.previewUrl,q=H.lifecycle.phase,W=q==="running",F=G?.sandboxProviderKind==="user-desktop",X=_g({orgSlug:U.slug,virtualMcpId:O??"",branch:s??"",enabled:F&&W&&!!O&&!!s}),Q=F?X:null,Z=O&&s&&W?{orgSlug:U.slug,virtualMcpId:O,branch:s,previewUrl:K}:null,{data:J}=Ml(Z,{fetchEnabled:W}),{data:ee}=Ol(Z,{fetchEnabled:W}),te=O&&s?{orgSlug:U.slug,virtualMcpId:O,branch:s}:null,ae=XR(te),se=J?ld(J).sort((ue,je)=>ue.name.localeCompare(je.name)):[],oe=J&&ee?cd(J,ee):[],ce=ai,fe=se.filter(ue=>{if(!p)return!0;const je=p.toLowerCase();return ue.name.toLowerCase().includes(je)||ue.path.toLowerCase().includes(je)}),be=oe.filter(ue=>{if(!p)return!0;const je=p.toLowerCase();return ue.name.toLowerCase().includes(je)||ue.key.toLowerCase().includes(je)||ue.resolveType.toLowerCase().includes(je)}),_e=L?null:KL(se,V,T),xe=L?L.name:_e?.name,Ve=_e?.key??null,Ne=(Ve?N[Ve]:void 0)??{},we=Sr(V,Ne),ye={};if(W&&K&&ee)for(const ue of m0(V)){if(ue.type!=="param")continue;const je=ue.name,ot=lP(V,je);ot&&g3(ee,ka[ot],"loaders")&&(ye[je]=ot)}const $e=O&&s?{orgSlug:U.slug,virtualMcpId:O,branch:s}:null,Fe=C.useRef(null),pe=C.useRef(null);hb(()=>{const ue=u.current,je=Fe.current;!ue||!je||(ue.src=je)});const Ee=H.status.state==="paused",De=H.phase,he=n3({claimPhase:De,lifecycle:H.lifecycle}),le=Y.previewState,ke=Y.userStopped,Be=le.kind==="starting"||le.kind==="iframe"&&he.status==="doing",Ue=le.kind==="iframe"?VP(S??new URL(we,le.previewUrl).href,l):null,it=O&&s?iP(U.slug,O,s):null,Yt=ue=>{it&&aP(it,ue)},Rt=n.state.target;C.useEffect(()=>{if(!(!Rt||!K||!ee))if(Rt.kind==="page"){const ue=N[Rt.key]??{};pe.current=Sr(Rt.path,ue),w(null),j(null),A(Rt.key),k(Rt.path),Yt({path:Rt.path,pageKey:Rt.key,params:ue})}else{const ue=oe.find(je=>je.key===Rt.key);if(ue){pe.current=null;const je=p0(ee);w(ue),j(xf(K,je,ue.key))}}},[Rt,K,ee,N]);const[rt,gt]=C.useState(null);if(le.kind==="iframe"&&rt!==le.previewUrl){const ue=rt!==null;gt(le.previewUrl);const je=it?oP(it):null;if(je){if(pe.current=Sr(je.path,je.params),k(je.path),A(je.pageKey),j(null),w(null),je.pageKey&&Object.keys(je.params).length>0){const ot=je.pageKey;R(Vt=>({...Vt,[ot]:je.params}))}}else ue&&(pe.current=null,k("/"),j(null),A(null),w(null))}Fe.current=Ue;const lt=!!O&&!!s&&!H.notFound&&!ke&&!Ee&&(De?.kind==="ready"||q!=="idle"),St=le.kind!=="iframe"&&o==="visual"?"preview":o;C.useEffect(()=>{if(!K)return;let ue;try{ue=new URL(K,window.location.href).origin}catch{return}const je=ot=>{if(ot.origin===ue&&ot.data?.type==="visual-editor::element-clicked"){const Vt=ZR.safeParse(ot.data.payload);Vt.success&&h(Vt.data)}};return window.addEventListener("message",je),()=>window.removeEventListener("message",je)},[K]),C.useEffect(()=>{if(!f)return;const ue=je=>{x.current?.contains(je.target)||(m(!1),g(""))};return document.addEventListener("pointerdown",ue),()=>document.removeEventListener("pointerdown",ue)},[f]);const ct=()=>{const ue=u.current?.contentWindow;ue&&ue.postMessage({type:"visual-editor::activate",script:eP},"*")},me=()=>{const ue=u.current?.contentWindow;ue&&ue.postMessage({type:"visual-editor::deactivate"},"*")},Me=ue=>{const je=o;a(ue),h(null),je==="visual"&&me(),ue==="visual"&&ct()},et=()=>{if(!u.current||!Ue)return;const ue=u.current;ue.src=Ue},tt=()=>{const ue=u.current;if(!ue)return;const je=document.activeElement,ot=ue.tabIndex;ue.tabIndex=-1,ue.style.pointerEvents="none",ue.blur();try{ue.contentWindow?.location.reload()}catch{const Nn=Fe.current;Nn&&(ue.src=Nn)}const Vt=()=>{ue.tabIndex=ot,ue.style.pointerEvents="",je?.focus(),ue.removeEventListener("load",Vt)};ue.addEventListener("load",Vt),setTimeout(Vt,3e3)},[vs,us]=C.useState(n.state.previewRevision);C.useEffect(()=>{vs!==n.state.previewRevision&&(us(n.state.previewRevision),tt())},[vs,n.state.previewRevision]);const Jt=()=>{if(!u.current||!Ue)return;const ue=Ue.includes("?")?"&":"?";u.current.src=`${Ue}${ue}_r=${Date.now()}`},mn=()=>{const ue=$c.indexOf(l);c($c[(ue+1)%$c.length])},re=()=>{const ue=u.current?.contentWindow?.location?.href??Ue??K;ue&&navigator.clipboard.writeText(ue)},Le=(()=>{if(!K)return"No server running";if(L)return L.name;try{const ue=new URL(K),je=we==="/"?"":we;return`${ue.host}${je}`}catch{return K}})(),Te=ue=>{const je=N[ue.key]??{},ot=Sr(ue.path,je);(L||ce(ot)!==ce(we))&&P(),pe.current=ot,w(null),j(null),A(ue.key),k(ue.path),Yt({path:ue.path,pageKey:ue.key,params:je}),n.selectTarget({kind:"page",key:ue.key,path:ue.path})},Oe=(ue,je)=>{if(!Ve)return;const ot=Ve,Vt={...Ne,[ue]:je};pe.current=Sr(V,Vt),R(Nn=>({...Nn,[ot]:Vt})),Yt({path:V,pageKey:ot,params:Vt})},st=ue=>{if(!K||!ee){de.error("Preview metadata not ready yet");return}P(),pe.current=null;const je=p0(ee),ot=xf(K,je,ue.key);w(ue),j(ot),n.selectTarget({kind:"section",key:ue.key})},ht=async({name:ue,path:je,templateKey:ot})=>{if(!O||!s)return;const Vt=rd(je);if(Vt){y(Vt);return}const Nn=je.trim().startsWith("/")?je.trim():`/${je.trim()}`;if(se.some(An=>ce(An.path)===ce(Nn))){y(`A page with path "${Nn}" already exists.`);return}let cc;if(ot&&(cc=J?.[ot],!cc)){y("Selected template no longer exists.");return}y(void 0);try{const An=await ae.mutateAsync({name:ue,path:Nn,template:cc});_(!1),de.success(`Page "${ue}" created`),await s6(vf),Te({key:An.key,name:An.name,path:An.path}),e({to:".",search:L4=>({...L4,...mu("blocks")}),replace:!0})}catch(An){y(An instanceof Error?An.message:"Failed to create page")}},kn=le.kind==="iframe",Qn=ue=>Me(o===ue?"preview":ue);return i.jsxs("div",{className:"flex flex-col w-full h-full",children:[lt&&le.kind==="iframe"&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:le.kind==="iframe"&&i.jsx("div",{className:"flex w-full items-center justify-center",children:i.jsxs("div",{className:"flex w-full max-w-[500px] items-center gap-0.5",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:et,children:i.jsx(zi,{size:14})})}),i.jsx(Pe,{side:"bottom",children:"Refresh"})]}),i.jsxs("div",{ref:x,className:"relative min-w-0 flex-1",children:[i.jsxs("div",{className:"flex h-8 w-full min-w-0 items-center rounded-md border border-border bg-background transition-colors duration-200 hover:bg-accent",children:[i.jsxs("div",{className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1 pl-2 pr-1",onClick:()=>m(ue=>!ue),children:[L&&i.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[i.jsx(on,{size:11}),"Global"]}),i.jsx("span",{className:ne("text-[13px] font-medium text-foreground",xe==null?"min-w-0 flex-1 truncate":"shrink-0"),children:xe??Le}),!L&&xe!=null&&V&&i.jsx("span",{className:"flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap text-[12px] text-muted-foreground",children:m0(V).map((ue,je)=>{if(ue.type==="text")return i.jsx("span",{className:ne(je===0?"min-w-0 truncate":"shrink-0"),children:ue.text},`text-${je}`);const ot=ye[ue.name];return ot&&$e?i.jsx(_P,{kind:ot,paramName:ue.name,value:Ne[ue.name]??"",sandboxRef:$e,onCommit:Vt=>Oe(ue.name,Vt)},`${Ve}:${ue.name}`):i.jsx(jP,{name:ue.name,value:Ne[ue.name]??"",onCommit:Vt=>Oe(ue.name,Vt)},`${Ve}:${ue.name}`)})})]}),i.jsx("button",{type:"button",className:"flex h-full shrink-0 items-center pl-1 pr-2",onClick:()=>m(ue=>!ue),"aria-label":"Choose page",children:i.jsx(Ht,{size:12,className:ne("shrink-0 text-muted-foreground transition-transform",f&&"rotate-180")})})]}),f&&i.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[i.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[i.jsx($9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{type:"text",value:p,onChange:ue=>g(ue.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),i.jsx("div",{className:"p-1.5 border-b",children:i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ue=>{ue.preventDefault(),m(!1),g(""),y(void 0),_(!0)},children:[i.jsx(Lt,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),fe.length===0&&be.length===0?i.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:se.length===0&&oe.length===0?"No pages found in this site.":"No results match your search."}):i.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[fe.length>0&&i.jsx("div",{className:"p-1.5",children:fe.map(ue=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),m(!1),g(""),Te(ue)},children:[i.jsx(Dn,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ue.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ue.path})]},ue.key))}),be.length>0&&i.jsxs("div",{className:ne("p-1.5",fe.length>0&&"border-t"),children:[i.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),be.map(ue=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),m(!1),g(""),st(ue)},children:[i.jsx(on,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ue.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ue.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},ue.key))]})]})]})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>{const ue=Ue??le.previewUrl;ue&&window.open(ue,"_blank","noopener")},children:i.jsx(wn,{size:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in new tab"})]}),i.jsx("div",{className:"absolute inset-y-0 right-3 flex items-center md:right-4",children:i.jsxs(Zt,{children:[i.jsx(es,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",children:i.jsx(Gn,{size:14})})}),i.jsxs(ts,{align:"end",className:"w-44",children:[i.jsx(He,{onClick:Jt,children:"Hard Reload"}),i.jsx(He,{onClick:re,children:"Copy Current URL"}),J&&ee&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),Ve&&i.jsxs(He,{onClick:()=>{n.editSeo({kind:"page",key:Ve,path:V}),e({to:".",search:ue=>({...ue,...mu("blocks")}),replace:!0})},children:[i.jsx(Ba,{size:14}),"Edit SEO"]}),Ve&&i.jsxs(He,{onClick:()=>{try{r(Vv(sv(Ve)))}catch{de.error("Invalid page block key")}},children:[i.jsx(Ao,{size:14}),"View JSON"]}),i.jsxs(He,{onClick:()=>$(!0),children:[i.jsx(Ba,{size:14}),"Site SEO"]})]}),Q&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),i.jsxs(He,{onClick:()=>window.open(pl("vscode",Q)),children:[i.jsx("img",{src:yP,alt:"VSCode",width:14,height:14}),"Open in VSCode"]}),i.jsxs(He,{onClick:()=>window.open(pl("cursor",Q)),children:[i.jsx("img",{src:LP,alt:"Cursor",width:14,height:14}),"Open in Cursor"]})]})]})]})})]})})}),i.jsx("div",{className:"flex-1 flex overflow-hidden",children:i.jsxs("div",{className:ne("flex-1 relative overflow-hidden",l!=="desktop"&&le.kind==="iframe"&&"flex justify-center bg-muted/30"),children:[I&&le.kind==="iframe"&&i.jsx("div",{className:"absolute inset-x-0 top-0 z-40 h-0.5 overflow-hidden bg-primary/15",children:i.jsx("div",{className:"absolute inset-y-0 w-2/5 rounded-full bg-primary animate-preview-nav"})}),Be&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"starting",progress:he,claimPhase:De})}),le.kind==="suspended"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"suspended",onResume:Y.resume})}),le.kind==="errored"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"errored",error:le.error,onRetry:Y.retry,connectionsHref:`/${U.slug}/settings/connections`})}),St==="visual"&&!d&&i.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[i.jsx(xu,{size:12}),"Click any element to ask the AI"]}),St==="visual"&&d&&i.jsx(nP,{element:d,onDismiss:()=>h(null)}),kn&&i.jsx("div",{className:"absolute bottom-4 left-1/2 z-20 -translate-x-1/2",children:i.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border bg-background/90 p-1 shadow-lg backdrop-blur-sm",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Lu,{onClick:()=>Qn("visual"),"aria-pressed":o==="visual","aria-label":"Visual editor",active:o==="visual",children:i.jsx(xu,{size:16})})}),i.jsx(Pe,{side:"top",children:"Visual editor"})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Lu,{onClick:mn,"aria-label":_f[l],children:i.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[l==="mobile"&&i.jsx(Lx,{size:16}),l==="tablet"&&i.jsx(Sx,{size:16}),l==="desktop"&&i.jsx(wx,{size:16})]},l)})}),i.jsx(Pe,{side:"top",children:_f[l]})]})]})}),le.kind==="iframe"&&Ue&&i.jsx("div",{className:ne("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",l!=="desktop"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:l==="desktop"?"100%":`${wP[l]}px`},children:i.jsx("iframe",{ref:u,src:Ue,className:"w-full h-full border-0",title:"Dev Server Preview",onLoad:()=>{if(M(),Ce("vm_preview_loaded",{view_mode:o,vm_id:G?.sandboxHandle??null}),!L)try{const ue=u.current?.contentWindow?.location?.pathname;if(!ue)return;const je=pe.current;if(je!==null&&(pe.current=null,ce(ue)!==ce(je))||ce(ue)===ce(we))return;k(ue),Yt({path:ue,pageKey:T,params:Ne})}catch{}o==="visual"&&ct()}},le.previewUrl)})]})}),i.jsx(QR,{open:v,onOpenChange:_,isPending:ae.isPending,error:b,templates:se,onSubmit:ht}),z&&J&&ee&&i.jsx(C.Suspense,{fallback:null,children:i.jsx(SP,{open:z,onOpenChange:$,orgSlug:U.slug,virtualMcpId:O??"",branch:s??"",decofile:J,meta:ee,onSaved:()=>{setTimeout(()=>{const ue=u.current;if(ue)try{ue.contentWindow?.location.reload()}catch{const je=Fe.current;je&&(ue.src=je)}},vf)},target:{kind:"site"}})})]})}function NP(t){const e=B.c(2),{virtualMcpId:s}=t,n=qs(s);if(!bn(n?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[i.jsx(fn,{size:24,className:"text-muted-foreground/60"}),i.jsx("div",{children:"No source to preview."}),i.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(kP,{}),e[1]=o):o=e[1],o}const AP="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",TP="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",EP=C.lazy(()=>Ws(()=>import("./file-explorer-QRM6gqgi.js"),__vite__mapDeps([162,1,2,84,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,127,123,128,129,126,117,107,108,109,110,111,112,113,114,115,116,118,119,120,121,122,124,125,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.FileExplorer})));function RP(t){const e=B.c(17),{openPath:s}=t,n=Vn(),{org:r}=Ae(),{currentBranch:o}=as(),a=n?.entity?.id??null,l=dr(),c=Os(),d=l.vmEntry,h=c.lifecycle.phase==="running",u=d?.sandboxProviderKind==="user-desktop",f=a??"",m=o??"",p=u&&h&&!!a&&!!o;let g;e[0]!==r.slug||e[1]!==f||e[2]!==m||e[3]!==p?(g={orgSlug:r.slug,virtualMcpId:f,branch:m,enabled:p},e[0]=r.slug,e[1]=f,e[2]=m,e[3]=p,e[4]=g):g=e[4];const x=_g(g),v=u?x:null;if(!a||!o){let w;return e[5]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No sandbox to browse."}),e[5]=w):w=e[5],w}let _;e[6]!==v?(_=v&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center border-b border-border/60 px-3 md:px-4",children:i.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in VSCode",onClick:()=>window.open(pl("vscode",v)),children:i.jsx("img",{src:AP,alt:"VSCode",width:14,height:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in VSCode"})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in Cursor",onClick:()=>window.open(pl("cursor",v)),children:i.jsx("img",{src:TP,alt:"Cursor",width:14,height:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in Cursor"})]})]})}),e[6]=v,e[7]=_):_=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),e[8]=b):b=e[8];let y;e[9]!==o||e[10]!==s||e[11]!==r.slug||e[12]!==a?(y=i.jsx("div",{className:"flex-1 relative overflow-hidden bg-background",children:i.jsx(C.Suspense,{fallback:b,children:i.jsx(EP,{orgSlug:r.slug,virtualMcpId:a,branch:o,openPath:s})})}),e[9]=o,e[10]=s,e[11]=r.slug,e[12]=a,e[13]=y):y=e[13];let L;return e[14]!==_||e[15]!==y?(L=i.jsxs("div",{className:"flex flex-col w-full h-full",children:[_,y]}),e[14]=_,e[15]=y,e[16]=L):L=e[16],L}function PP(t){const e=B.c(2),{virtualMcpId:s}=t,n=qs(s);if(!bn(n?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[i.jsx(fn,{size:24,className:"text-muted-foreground/60"}),i.jsx("div",{children:"No content to edit."}),i.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(L3,{}),e[1]=o):o=e[1],o}const Bc={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:k9},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Bn},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:Q1}},IP=["fast","smart","thinking"];function DP(t){const e=B.c(15),{tier:s,onSelect:n}=t,[r,o]=C.useState(!1),a=Bc[s].icon;let l;e[0]!==a?(l=i.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const c=Bc[s];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Ht,{size:14,className:"text-muted-foreground"}),e[2]=d):d=e[2];let h;e[3]!==l||e[4]!==c.label?(h=i.jsx(Cs,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,c.label,d]})}),e[3]=l,e[4]=c.label,e[5]=h):h=e[5];let u;e[6]!==n||e[7]!==s?(u=IP.map(p=>{const g=Bc[p],x=g.icon;return i.jsxs("button",{type:"button",onClick:()=>{n(p),o(!1)},className:ne("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[i.jsx(x,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"text-sm",children:g.label}),i.jsx("div",{className:"text-xs text-muted-foreground",children:g.subtitle})]}),p===s&&i.jsx(Tt,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=n,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=i.jsx(Vs,{align:"start",className:"p-1 w-64",children:i.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==f?(m=i.jsxs(ks,{open:r,onOpenChange:o,children:[h,f]}),e[11]=r,e[12]=h,e[13]=f,e[14]=m):m=e[14],m}function MP(t){const e=B.c(15),{tier:s,onTierChange:n,override:r,onOverrideChange:o}=t,[a,l]=C.useState(r!==null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=c):c=e[0];let d;e[1]!==o||e[2]!==n||e[3]!==r||e[4]!==s||e[5]!==a?(d=a?i.jsx(C.Suspense,{fallback:i.jsx(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:i.jsx(OP,{override:r,onOverrideChange:o})}):i.jsx(DP,{tier:s,onSelect:n}),e[1]=o,e[2]=n,e[3]=r,e[4]=s,e[5]=a,e[6]=d):d=e[6];let h;e[7]!==o?(h=m=>{l(m),m||o(null)},e[7]=o,e[8]=h):h=e[8];let u;e[9]!==h||e[10]!==a?(u=i.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[i.jsx(ho,{checked:a,onCheckedChange:h,className:"cursor-pointer"}),"Specific model"]}),e[9]=h,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=i.jsxs("div",{className:"flex flex-col gap-2",children:[c,i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d,u]})]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function OP(t){const e=B.c(10),{override:s,onOverrideChange:n}=t,r=Sm(),o=r[0]?.id??null,[a,l]=C.useState(s?.credentialId??o);let c;e[0]!==s?(c=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=c):c=e[1];const d=c;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let h;e[3]!==a||e[4]!==n?(h=f=>{const m=f.keyId??a??"";l(m),n({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=n,e[5]=h):h=e[5];let u;return e[6]!==a||e[7]!==d||e[8]!==h?(u=i.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:i.jsx(Hx,{variant:"bordered",placeholder:"Pick a model",model:d,credentialId:a,onCredentialChange:l,onModelChange:h})}),e[6]=a,e[7]=d,e[8]=h,e[9]=u):u=e[9],u}const bg=[{key:"capabilities",heading:"Built-in capabilities",icon:j9,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Yn},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:_n},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:an},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:Cx}]},{key:"files",heading:"Files & code",icon:hi,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Cm},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:w9},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:C9},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:fo},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:hi},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:Vx}]},{key:"context",heading:"Context",icon:$a,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:$a},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:Ki},{name:"skill",title:"Load Skill",description:"Load a skill's full instructions (SKILL.md) by id",icon:Ki}]},{key:"browser",heading:"Browser",icon:on,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:ar},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:on},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:Ao}]}],$P=bg.flatMap(t=>t.tools.map(e=>e.name));function BP(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function zP(t){const e=B.c(5),{agentId:s,value:n,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==n?(a=i.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?i.jsx(C.Suspense,{fallback:i.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[i.jsx(j9,{size:14}),"Loading tools…"]}),children:i.jsx(FP,{agentId:s,value:n,onChange:r})}):i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=n,e[4]=a):a=e[4],a}function bf(t){const e=B.c(17),{value:s,checked:n,onToggle:r,title:o,description:a,leading:l}=t;let c;e[0]!==n?(c=i.jsx(cr,{checked:n,className:"pointer-events-none mt-0.5"}),e[0]=n,e[1]=c):c=e[1];let d;e[2]!==l?(d=l&&i.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=d):d=e[3];let h;e[4]!==o?(h=i.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&i.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=i.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==s?(m=i.jsxs(Ps,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[c,d,f]}),e[11]=r,e[12]=c,e[13]=d,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function yf(t){const e=B.c(20),{conn:s,label:n,icon:r,on:o,total:a,onToggle:l}=t,c=o===a;let d;e[0]!==r||e[1]!==s?(d=s?i.jsx(Gs,{icon:s.icon,name:s.title,size:"2xs"}):r?i.jsx(r,{size:14,className:"text-muted-foreground"}):i.jsx(kx,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=d):d=e[2];const h=s?.title??n??"Other tools";let u;e[3]!==h?(u=i.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=i.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=_=>{_.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=c?"None":"All";let g;e[10]!==m||e[11]!==p?(g=i.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==f||e[14]!==g?(x=i.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,g]}),e[13]=f,e[14]=g,e[15]=x):x=e[15];let v;return e[16]!==d||e[17]!==u||e[18]!==x?(v=i.jsxs("div",{className:"flex items-center gap-2",children:[d,u,x]}),e[16]=d,e[17]=u,e[18]=x,e[19]=v):v=e[19],v}function FP(t){const e=B.c(70),{agentId:s,value:n,onChange:r}=t,{org:o}=Ae(),[a,l]=C.useState(!1);let c;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(c={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=c):c=e[3];const d=pt(c);let h;e[4]!==d?(h={client:d},e[4]=d,e[5]=h):h=e[5];const{data:u,isLoading:f}=F9(h),m=Do();let p,g,x,v,_,b,y,L,w,S,j,V,k;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==n){const I=new Map(m.map(qP)),D=new Map;for(const se of u?.tools??[]){const oe=rn(se._meta)??"__other__",ce=rr(se.name,oe==="__other__"?void 0:oe),fe=se.title,be=fe&&fe!==se.name?fe:BP(ce);D.has(oe)||D.set(oe,{clientId:oe,conn:I.get(oe),tools:[]}),D.get(oe).tools.push({name:se.name,display:be,description:se.description})}const E=[...D.values()].sort(WP),P=(u?.tools??[]).map(KP),M=[...$P,...P],z=n===null?new Set(M):new Set(n),$=M.every(se=>z.has(se)),O=se=>r(M.every(oe=>se.has(oe))?null:[...se]),U=se=>{const oe=new Set(z);oe.has(se)?oe.delete(se):oe.add(se),O(oe)},H=(se,oe)=>{const ce=new Set(z);for(const fe of se)oe?ce.add(fe):ce.delete(fe);O(ce)};v=ks,k=a,_=l;let Y;e[25]===Symbol.for("react.memo_cache_sentinel")?(Y=i.jsx(j9,{size:14,className:"text-muted-foreground"}),e[25]=Y):Y=e[25];const G=$?"All tools":"Tools",K=!$&&i.jsxs(n6,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[z.size,"/",M.length]});let q;e[26]===Symbol.for("react.memo_cache_sentinel")?(q=i.jsx(Ht,{size:14,className:"text-muted-foreground"}),e[26]=q):q=e[26],e[27]!==G||e[28]!==K?(b=i.jsx(Cs,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[Y,G,K,q]})}),e[27]=G,e[28]=K,e[29]=b):b=e[29],x=Vs,j="p-0 w-80",V="start",g=lr,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(yi,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const W=$?`All ${M.length} tools enabled`:`${z.size} of ${M.length} enabled`;let F;e[31]!==W?(F=i.jsx("span",{className:"text-xs text-muted-foreground",children:W}),e[31]=W,e[32]=F):F=e[32];let X;e[33]!==r?(X=()=>r(null),e[33]=r,e[34]=X):X=e[34];let Q;e[35]!==$||e[36]!==X?(Q=i.jsx("button",{type:"button",onClick:X,disabled:$,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=$,e[36]=X,e[37]=Q):Q=e[37];let Z;e[38]===Symbol.for("react.memo_cache_sentinel")?(Z=i.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=Z):Z=e[38];let J;e[39]!==r?(J=()=>r([]),e[39]=r,e[40]=J):J=e[40];const ee=z.size===0;let te;e[41]!==J||e[42]!==ee?(te=i.jsx("button",{type:"button",onClick:J,disabled:ee,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=J,e[42]=ee,e[43]=te):te=e[43];let ae;e[44]!==Q||e[45]!==te?(ae=i.jsxs("div",{className:"flex items-center gap-2",children:[Q,Z,te]}),e[44]=Q,e[45]=te,e[46]=ae):ae=e[46],e[47]!==F||e[48]!==ae?(S=i.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[F,ae]}),e[47]=F,e[48]=ae,e[49]=S):S=e[49],p=Si,y="max-h-80",L=f?i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):i.jsxs(i.Fragment,{children:[i.jsx(Li,{children:"No tools found"}),bg.map(se=>{const oe=se.tools.map(HP),ce=oe.filter(fe=>z.has(fe)).length;return i.jsx(Fs,{heading:i.jsx(yf,{label:se.heading,icon:se.icon,on:ce,total:oe.length,onToggle:()=>H(oe,ce!==oe.length)}),children:se.tools.map(fe=>i.jsx(bf,{value:`${fe.title} ${fe.name}`,checked:z.has(fe.name),onToggle:()=>U(fe.name),title:fe.title,description:fe.description,leading:i.jsx(fe.icon,{size:16,className:"text-muted-foreground"})},fe.name))},se.key)}),E.map(se=>{const oe=se.tools.map(UP),ce=oe.filter(fe=>z.has(fe)).length;return i.jsx(Fs,{heading:i.jsx(yf,{conn:se.conn,on:ce,total:oe.length,onToggle:()=>H(oe,ce!==oe.length)}),children:se.tools.map(fe=>i.jsx(bf,{value:`${fe.display} ${fe.name} ${se.conn?.title??""}`,checked:z.has(fe.name),onToggle:()=>U(fe.name),title:fe.display,description:fe.description},fe.name))},se.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=n,e[12]=p,e[13]=g,e[14]=x,e[15]=v,e[16]=_,e[17]=b,e[18]=y,e[19]=L,e[20]=w,e[21]=S,e[22]=j,e[23]=V,e[24]=k}else p=e[12],g=e[13],x=e[14],v=e[15],_=e[16],b=e[17],y=e[18],L=e[19],w=e[20],S=e[21],j=e[22],V=e[23],k=e[24];let T;e[50]!==p||e[51]!==y||e[52]!==L?(T=i.jsx(p,{className:y,children:L}),e[50]=p,e[51]=y,e[52]=L,e[53]=T):T=e[53];let A;e[54]!==g||e[55]!==T||e[56]!==w||e[57]!==S?(A=i.jsxs(g,{children:[w,S,T]}),e[54]=g,e[55]=T,e[56]=w,e[57]=S,e[58]=A):A=e[58];let N;e[59]!==x||e[60]!==A||e[61]!==j||e[62]!==V?(N=i.jsx(x,{className:j,align:V,children:A}),e[59]=x,e[60]=A,e[61]=j,e[62]=V,e[63]=N):N=e[63];let R;return e[64]!==v||e[65]!==_||e[66]!==b||e[67]!==N||e[68]!==k?(R=i.jsxs(v,{open:k,onOpenChange:_,children:[b,N]}),e[64]=v,e[65]=_,e[66]=b,e[67]=N,e[68]=k,e[69]=R):R=e[69],R}function UP(t){return t.name}function HP(t){return t.name}function KP(t){return t.name}function WP(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function qP(t){return[t.id,t]}function so(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function GP(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return`Every ${n[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),c=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${c} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",d=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${c} at ${d}:${h} UTC`}return t}function YP(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function JP(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return{count:parseInt(n[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);return r?{count:parseInt(r[1]),unit:"days"}:null}function XP(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const QP=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function ZP({automationId:t,open:e,onOpenChange:s,onCustomSelect:n,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=Mo(),[l,c]=C.useState(!1),d=e??l,h=m=>{s?s(m):c(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),de.success("Starter added"),h(!1)}catch(p){const g=p instanceof Error?p.message:"Failed to add starter";de.error(g)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});h(!1),m.webhook?o?.(m.webhook):de.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";de.error(p)}};return i.jsxs(Zt,{open:d,onOpenChange:h,children:[i.jsx(es,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",children:[i.jsx(Lt,{size:14}),"Add Starter"]})}),i.jsxs(ts,{align:"end",className:"w-[200px]",children:[i.jsxs(oo,{children:[i.jsxs(ao,{className:"gap-2.5",children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),i.jsx(lo,{className:"w-[160px]",children:QP.map(m=>i.jsxs(He,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{h(!1),n?.()},children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{h(!1),r?.()},children:[i.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[i.jsx(Yn,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function yg(t){const e=B.c(31),{open:s,onOpenChange:n,url:r,token:o,title:a,description:l}=t,c=a===void 0?"Webhook ready":a,d=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[h,u]=C.useState(null),[f,m]=C.useState("curl"),[p,g]=C.useState("header"),x=C.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=async(I,D)=>{try{await navigator.clipboard.writeText(I),u(D),de.success("Copied"),setTimeout(()=>u(null),1500)}catch{de.error("Failed to copy")}},e[0]=v):v=e[0];const _=v;let b;e[1]!==p||e[2]!==o||e[3]!==r?(b=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=b):b=e[4];const y=b,L=r&&o?p==="header"?`curl -X POST "${y}" \\
|
|
181
|
+
`)}function sP(t,e,s=320,n=44,r=12){const{x:o,y:a}=t,{width:l,height:c}=e,d=Math.max(r,Math.min(o-s/2,l-s-r)),u=a/c>.68?Math.max(r,a-n-18):Math.min(a+18,c-n-r);return{leftPct:d/l*100,topPct:u/c*100}}function nP(t){const e=B.c(32),{element:s,onDismiss:n}=t,[r,o]=C.useState(""),a=C.useRef(null),{sendMessage:l}=js(),{setChatOpen:c}=ko();let d;e[0]!==s||e[1]!==r||e[2]!==n||e[3]!==l||e[4]!==c?(d=()=>{if(!r.trim())return;const k=tP(s,r);c(!0),l({parts:[{type:"text",text:k}]}),n()},e[0]=s,e[1]=r,e[2]=n,e[3]=l,e[4]=c,e[5]=d):d=e[5];const h=d;let u;e[6]!==s.position||e[7]!==s.viewport?(u=sP(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const f=u,m=`${f.leftPct}%`,p=`${f.topPct}%`;let g;e[9]!==m||e[10]!==p?(g={left:m,top:p,width:"320px"},e[9]=m,e[10]=p,e[11]=g):g=e[11];let x;e[12]!==h?(x=k=>{k.preventDefault(),h()},e[12]=h,e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=k=>o(k.target.value),e[14]=v):v=e[14];let _;e[15]!==n?(_=k=>{k.key==="Escape"&&n()},e[15]=n,e[16]=_):_=e[16];let b;e[17]!==r||e[18]!==_?(b=i.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:v,onKeyDown:_,placeholder:"Ask the AI...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[17]=r,e[18]=_,e[19]=b):b=e[19];let y;e[20]!==r?(y=r.trim(),e[20]=r,e[21]=y):y=e[21];const L=!y;let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[i.jsx("title",{children:"Send"}),i.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=w):w=e[22];let S;e[23]!==L?(S=i.jsx("button",{type:"submit",disabled:L,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:"Send",children:w}),e[23]=L,e[24]=S):S=e[24];let j;e[25]!==S||e[26]!==x||e[27]!==b?(j=i.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:x,children:[b,S]}),e[25]=S,e[26]=x,e[27]=b,e[28]=j):j=e[28];let V;return e[29]!==j||e[30]!==g?(V=i.jsx("div",{className:"absolute z-30 pointer-events-none",style:g,children:j}),e[29]=j,e[30]=g,e[31]=V):V=e[31],V}function iP(t,e,s){return`deco:preview:last-page:${t}:${e}:${s}`}function rP(t){if(!t)return null;try{const e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e)||typeof e.path!="string"||!e.path.startsWith("/"))return null;const s=typeof e.pageKey=="string"?e.pageKey:null,n={};if(e.params&&typeof e.params=="object")for(const[r,o]of Object.entries(e.params))typeof o=="string"&&(n[r]=o);return{path:e.path,pageKey:s,params:n}}catch{return null}}function oP(t){try{return rP(localStorage.getItem(t))}catch{return null}}function aP(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function pl(t,e){const n=e.replace(/\\/g,"/").replace(/^(?!\/)/,"/").split("/").map(r=>encodeURIComponent(r).replace(/%3A/gi,":")).join("/");return`${t}://file${n}?windowId=_blank`}const ka={product:"vtex/loaders/intelligentSearch/productList.ts",category:"vtex/loaders/categories/tree.ts"};function lP(t,e){const s=m0(ai(t));if(e==="*")return s.some(o=>o.type==="param"&&o.name==="*")?"category":null;const n=s[s.length-1],r=s[s.length-2];return n?.type==="text"&&n.text==="/p"&&r?.type==="param"&&r.name===e?"product":null}function cP(t,e){if(t==="category")return[{resolveType:ka.category,props:{}}];const s=e.trim(),n=[];/^\d+$/.test(s)&&n.push({resolveType:ka.product,props:{ids:[s]}});const o=s.includes("-")&&!/\s/.test(s)?s.replace(/-+/g," "):s;return n.push({resolveType:ka.product,props:{query:o,count:10}}),n}function dP(t){const e=new Set,s=[];for(const n of t)for(const r of n)e.has(r.value)||(e.add(r.value),s.push(r));return s}function Na(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function vg(t){try{return decodeURIComponent(t)}catch{return t}}function uP(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.match(/^\/([^/]+)\/p\/?$/)?.[1];return s?vg(s):null}function hP(t){if(!Array.isArray(t))return[];const e=[],s=new Set;for(const n of t){const r=Na(n);if(!r)continue;const o=uP(r.url);if(!o||s.has(o))continue;s.add(o);const a=Na(r.isVariantOf),l=typeof a?.name=="string"&&a.name||typeof r.name=="string"&&r.name||o,c=Array.isArray(r.image)?Na(r.image[0]):null,d=typeof c?.url=="string"?c.url:void 0;e.push({value:o,label:l,image:d})}return e}function fP(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.replace(/^\/+|\/+$/g,"");return s?vg(s):null}function mP(t){const e=[],s=new Set,n=(r,o)=>{const a=Na(r);if(!a)return;const l=typeof a.name=="string"&&a.name?a.name:"",c=l?[...o,l]:o,d=fP(a.url);if(d&&!s.has(d)&&(s.add(d),e.push({value:d,label:c.join(" › ")||d})),Array.isArray(a.children))for(const h of a.children)n(h,c)};if(Array.isArray(t))for(const r of t)n(r,[]);return e}function pP(t,e,s=50){const n=e.trim().toLowerCase();return(n?t.filter(o=>o.label.toLowerCase().includes(n)||o.value.toLowerCase().includes(n)):t).slice(0,s)}const gP=1e4;async function xP(t,{resolveType:e,props:s}){const n=await fetch(_3(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(gP)});if(!n.ok)throw new Error(`Failed to fetch options: ${n.status}`);return n.json()}async function vP(t,e,s){const n=cP(e,s),r=await Promise.allSettled(n.map(a=>xP(t,a))),o=r.filter(a=>a.status==="fulfilled").map(a=>a.value);if(o.length===0){const a=r.find(l=>l.status==="rejected");throw a?a.reason:new Error("Failed to fetch options")}return dP(o.map(a=>e==="product"?hP(a):mP(a)))}function _P(t){const e=B.c(78),{kind:s,paramName:n,value:r,sandboxRef:o,onCommit:a}=t,[l,c]=C.useState(!1),[d,h]=C.useState(""),[u,f]=C.useState(""),m=C.useRef(null),p=s==="product"?"product":"category",g=n==="*"?"*":`:${n}`;let x;e[0]!==r?(x=ee=>{c(ee),m.current&&clearTimeout(m.current),h(ee?r:""),f(ee?r:"")},e[0]=r,e[1]=x):x=e[1];const v=x;let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=ee=>{h(ee),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{f(ee)},300)},e[2]=_):_=e[2];const b=_;let y;e[3]!==v||e[4]!==a?(y=ee=>{a(ee),v(!1)},e[3]=v,e[4]=a,e[5]=y):y=e[5];const L=y;let w;e[6]!==u||e[7]!==s||e[8]!==o.branch||e[9]!==o.orgSlug||e[10]!==o.virtualMcpId?(w=Qe.sandboxInvoke(`${o.orgSlug}/${o.virtualMcpId}/${o.branch}`,`path-param-${s}:${s==="product"?u:""}`),e[6]=u,e[7]=s,e[8]=o.branch,e[9]=o.orgSlug,e[10]=o.virtualMcpId,e[11]=w):w=e[11];let S;e[12]!==u||e[13]!==s||e[14]!==o?(S=()=>vP(o,s,u),e[12]=u,e[13]=s,e[14]=o,e[15]=S):S=e[15];let j;e[16]!==l||e[17]!==w||e[18]!==S?(j={queryKey:w,queryFn:S,enabled:l,staleTime:6e4,retry:1},e[16]=l,e[17]=w,e[18]=S,e[19]=j):j=e[19];const V=gs(j);let k;e[20]!==s||e[21]!==V.data||e[22]!==d?(k=s==="product"?V.data??[]:pP(V.data??[],d),e[20]=s,e[21]=V.data,e[22]=d,e[23]=k):k=e[23];const T=k;let A;e[24]!==d?(A=d.trim(),e[24]=d,e[25]=A):A=e[25];const N=A,R=s==="product"?`/${N}/p`:`/${N}`,I=`Value for ${g} — click to pick a ${p}`;let D;e[26]!==v?(D=ee=>{ee.stopPropagation(),v(!0)},e[26]=v,e[27]=D):D=e[27];const E=r||g;let P;e[28]!==D||e[29]!==E||e[30]!==I?(P=i.jsx("button",{type:"button",title:I,className:"max-w-64 shrink-0 cursor-pointer truncate rounded-sm bg-violet-500/15 px-1 py-0.5 text-[12px] text-violet-600 hover:bg-violet-500/25 dark:text-violet-400",onClick:D,children:E}),e[28]=D,e[29]=E,e[30]=I,e[31]=P):P=e[31];let M;e[32]!==p||e[33]!==g?(M=i.jsx(ns,{className:"sr-only",children:i.jsxs(is,{children:["Pick a ",p," or enter a value for ",g]})}),e[32]=p,e[33]=g,e[34]=M):M=e[34];let z;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=i.jsx(r0,{size:16,className:"shrink-0 text-foreground"}),e[35]=z):z=e[35];let $;e[36]!==g?($=i.jsx("span",{className:"rounded-sm bg-violet-500/15 px-1 py-0.5 font-mono text-[12px] text-violet-600 dark:text-violet-400",children:g}),e[36]=g,e[37]=$):$=e[37];let O;e[38]!==p||e[39]!==$?(O=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[z,i.jsxs("span",{className:"text-sm font-medium text-foreground",children:["Pick a ",p," for"," ",$]})]}),e[38]=p,e[39]=$,e[40]=O):O=e[40];const U=s==="product"?"Search products or enter a slug...":"Search categories or enter a path...";let H;e[41]!==d||e[42]!==U?(H=i.jsx(yi,{autoFocus:!0,placeholder:U,value:d,onValueChange:b}),e[41]=d,e[42]=U,e[43]=H):H=e[43];const Y=V.isLoading?"Loading...":V.isError?"Couldn't load — is the dev server running?":"No results.";let G;e[44]!==Y?(G=i.jsx(Li,{children:Y}),e[44]=Y,e[45]=G):G=e[45];let K;e[46]!==L||e[47]!==g||e[48]!==R||e[49]!==N?(K=N&&i.jsx(Fs,{children:i.jsxs(Ps,{value:`__raw__:${N}`,className:"gap-3 py-2",onSelect:()=>L(N),children:[i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted",children:i.jsx(To,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsxs("span",{className:"block truncate text-sm",children:["Use “",N,"” as ",g]}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:R})]})]})}),e[46]=L,e[47]=g,e[48]=R,e[49]=N,e[50]=K):K=e[50];let q;if(e[51]!==L||e[52]!==s||e[53]!==T){let ee;e[55]!==L||e[56]!==s?(ee=te=>i.jsxs(Ps,{value:te.value,className:"gap-3 py-2",onSelect:()=>L(te.value),children:[s==="product"&&i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:te.image?i.jsx("img",{src:te.image,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):i.jsx(r0,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm",children:te.label}),i.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:["/",s==="product"?`${te.value}/p`:te.value]})]})]},te.value),e[55]=L,e[56]=s,e[57]=ee):ee=e[57],q=T.map(ee),e[51]=L,e[52]=s,e[53]=T,e[54]=q}else q=e[54];let W;e[58]!==q?(W=i.jsx(Fs,{children:q}),e[58]=q,e[59]=W):W=e[59];let F;e[60]!==G||e[61]!==K||e[62]!==W?(F=i.jsxs(Si,{className:"max-h-none flex-1",children:[G,K,W]}),e[60]=G,e[61]=K,e[62]=W,e[63]=F):F=e[63];let X;e[64]!==H||e[65]!==F?(X=i.jsxs(lr,{shouldFilter:!1,className:"min-h-0 flex-1",children:[H,F]}),e[64]=H,e[65]=F,e[66]=X):X=e[66];let Q;e[67]!==M||e[68]!==O||e[69]!==X?(Q=i.jsxs(Ft,{className:"flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",onClick:bP,children:[M,O,X]}),e[67]=M,e[68]=O,e[69]=X,e[70]=Q):Q=e[70];let Z;e[71]!==v||e[72]!==l||e[73]!==Q?(Z=i.jsx(Ut,{open:l,onOpenChange:v,children:Q}),e[71]=v,e[72]=l,e[73]=Q,e[74]=Z):Z=e[74];let J;return e[75]!==P||e[76]!==Z?(J=i.jsxs(i.Fragment,{children:[P,Z]}),e[75]=P,e[76]=Z,e[77]=J):J=e[77],J}function bP(t){return t.stopPropagation()}function _g(t){const e=B.c(12),{orgSlug:s,virtualMcpId:n,branch:r,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==r||e[1]!==s||e[2]!==n?(l=Qe.sandboxRepoDir(s,n,r),e[0]=r,e[1]=s,e[2]=n,e[3]=l):l=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==n?(c=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(r)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=r,e[5]=s,e[6]=n,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d={queryKey:l,queryFn:c,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],gs(d).data??null}const yP="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",LP="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",SP=C.lazy(()=>Ws(()=>import("./page-seo-sheet-CXtm2wdS.js"),__vite__mapDeps([161,1,2,19,20,21,22,6,4,5,7,8,9,10,11,12,13,14,15,16,17,18,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,3,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,157,135,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SeoSheet}))),vf=500,wP={mobile:375,tablet:768,desktop:null},$c=["desktop","mobile","tablet"],_f={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function jP(t){const e=B.c(24),{name:s,value:n,onCommit:r}=t,[o,a]=C.useState(n),[l,c]=C.useState(!1),d=C.useRef(!1),h=s==="*"?"*":`:${s}`,u=o||h;let f;e[0]!==u?(f=i.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-[12px]",children:u}),e[0]=u,e[1]=f):f=e[1];const m=`Value for ${h}`;let p,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=w=>a(w.target.value),g=()=>c(!0),e[2]=p,e[3]=g):(p=e[2],g=e[3]);let x;e[4]!==n?(x=w=>{w.key==="Enter"&&w.currentTarget.blur(),w.key==="Escape"&&(d.current=!0,a(n),w.currentTarget.blur())},e[4]=n,e[5]=x):x=e[5];let v;e[6]!==o||e[7]!==r||e[8]!==n?(v=()=>{if(c(!1),d.current){d.current=!1;return}const w=o.trim();a(w),w!==n&&r(w)},e[6]=o,e[7]=r,e[8]=n,e[9]=v):v=e[9];let _;e[10]!==o||e[11]!==h||e[12]!==m||e[13]!==x||e[14]!==v?(_=i.jsx("input",{type:"text",value:o,placeholder:h,title:m,spellCheck:!1,className:"absolute inset-0 rounded-sm bg-violet-500/15 px-1 text-[12px] text-violet-600 outline-none placeholder:text-violet-500/60 focus:bg-violet-500/25 dark:text-violet-400",onClick:CP,onChange:p,onFocus:g,onKeyDown:x,onBlur:v}),e[10]=o,e[11]=h,e[12]=m,e[13]=x,e[14]=v,e[15]=_):_=e[15];let b;e[16]!==f||e[17]!==_?(b=i.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[f,_]}),e[16]=f,e[17]=_,e[18]=b):b=e[18];let y;e[19]!==l?(y=l&&i.jsxs("span",{className:"pointer-events-none ml-1.5 flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[i.jsx(jx,{size:10}),"Enter to go"]}),e[19]=l,e[20]=y):y=e[20];let L;return e[21]!==b||e[22]!==y?(L=i.jsxs(i.Fragment,{children:[b,y]}),e[21]=b,e[22]=y,e[23]=L):L=e[23],L}function CP(t){return t.stopPropagation()}function VP(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function kP(){const t=Vn(),e=Ct(),{currentBranch:s}=as(),n=y3(),r=ue=>{e({to:".",search:je=>({...je,main:ue}),replace:!0})},[o,a]=C.useState("preview"),[l,c]=C.useState("desktop"),[d,h]=C.useState(null),u=C.useRef(null),[f,m]=C.useState(!1),[p,g]=C.useState(""),x=C.useRef(null),[v,_]=C.useState(!1),[b,y]=C.useState(),[L,w]=C.useState(null),[S,j]=C.useState(null),[V,k]=C.useState("/"),[T,A]=C.useState(null),[N,R]=C.useState({}),[I,D]=C.useState(!1),E=C.useRef(null),P=()=>{D(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>D(!1),15e3)},M=()=>{E.current&&(clearTimeout(E.current),E.current=null),D(!1)},[z,$]=C.useState(!1),O=t?.entity?.id??null,{org:U}=Ae(),H=Os(),Y=dr(),G=Y.vmEntry,K=Y.previewUrl,q=H.lifecycle.phase,W=q==="running",F=G?.sandboxProviderKind==="user-desktop",X=_g({orgSlug:U.slug,virtualMcpId:O??"",branch:s??"",enabled:F&&W&&!!O&&!!s}),Q=F?X:null,Z=O&&s&&W?{orgSlug:U.slug,virtualMcpId:O,branch:s,previewUrl:K}:null,{data:J}=Ml(Z,{fetchEnabled:W}),{data:ee}=Ol(Z,{fetchEnabled:W}),te=O&&s?{orgSlug:U.slug,virtualMcpId:O,branch:s}:null,ae=XR(te),se=J?ld(J).sort((ue,je)=>ue.name.localeCompare(je.name)):[],oe=J&&ee?cd(J,ee):[],ce=ai,fe=se.filter(ue=>{if(!p)return!0;const je=p.toLowerCase();return ue.name.toLowerCase().includes(je)||ue.path.toLowerCase().includes(je)}),be=oe.filter(ue=>{if(!p)return!0;const je=p.toLowerCase();return ue.name.toLowerCase().includes(je)||ue.key.toLowerCase().includes(je)||ue.resolveType.toLowerCase().includes(je)}),_e=L?null:KL(se,V,T),xe=L?L.name:_e?.name,Ve=_e?.key??null,Ne=(Ve?N[Ve]:void 0)??{},we=Sr(V,Ne),ye={};if(W&&K&&ee)for(const ue of m0(V)){if(ue.type!=="param")continue;const je=ue.name,ot=lP(V,je);ot&&g3(ee,ka[ot],"loaders")&&(ye[je]=ot)}const $e=O&&s?{orgSlug:U.slug,virtualMcpId:O,branch:s}:null,Fe=C.useRef(null),pe=C.useRef(null);hb(()=>{const ue=u.current,je=Fe.current;!ue||!je||(ue.src=je)});const Ee=H.status.state==="paused",De=H.phase,he=n3({claimPhase:De,lifecycle:H.lifecycle}),le=Y.previewState,ke=Y.userStopped,Be=le.kind==="starting"||le.kind==="iframe"&&he.status==="doing",Ue=le.kind==="iframe"?VP(S??new URL(we,le.previewUrl).href,l):null,it=O&&s?iP(U.slug,O,s):null,Yt=ue=>{it&&aP(it,ue)},Rt=n.state.target;C.useEffect(()=>{if(!(!Rt||!K||!ee))if(Rt.kind==="page"){const ue=N[Rt.key]??{};pe.current=Sr(Rt.path,ue),w(null),j(null),A(Rt.key),k(Rt.path),Yt({path:Rt.path,pageKey:Rt.key,params:ue})}else{const ue=oe.find(je=>je.key===Rt.key);if(ue){pe.current=null;const je=p0(ee);w(ue),j(xf(K,je,ue.key))}}},[Rt,K,ee,N]);const[rt,gt]=C.useState(null);if(le.kind==="iframe"&&rt!==le.previewUrl){const ue=rt!==null;gt(le.previewUrl);const je=it?oP(it):null;if(je){if(pe.current=Sr(je.path,je.params),k(je.path),A(je.pageKey),j(null),w(null),je.pageKey&&Object.keys(je.params).length>0){const ot=je.pageKey;R(Vt=>({...Vt,[ot]:je.params}))}}else ue&&(pe.current=null,k("/"),j(null),A(null),w(null))}Fe.current=Ue;const lt=!!O&&!!s&&!H.notFound&&!ke&&!Ee&&(De?.kind==="ready"||q!=="idle"),St=le.kind!=="iframe"&&o==="visual"?"preview":o;C.useEffect(()=>{if(!K)return;let ue;try{ue=new URL(K,window.location.href).origin}catch{return}const je=ot=>{if(ot.origin===ue&&ot.data?.type==="visual-editor::element-clicked"){const Vt=ZR.safeParse(ot.data.payload);Vt.success&&h(Vt.data)}};return window.addEventListener("message",je),()=>window.removeEventListener("message",je)},[K]),C.useEffect(()=>{if(!f)return;const ue=je=>{x.current?.contains(je.target)||(m(!1),g(""))};return document.addEventListener("pointerdown",ue),()=>document.removeEventListener("pointerdown",ue)},[f]);const ct=()=>{const ue=u.current?.contentWindow;ue&&ue.postMessage({type:"visual-editor::activate",script:eP},"*")},me=()=>{const ue=u.current?.contentWindow;ue&&ue.postMessage({type:"visual-editor::deactivate"},"*")},Me=ue=>{const je=o;a(ue),h(null),je==="visual"&&me(),ue==="visual"&&ct()},et=()=>{if(!u.current||!Ue)return;const ue=u.current;ue.src=Ue},tt=()=>{const ue=u.current;if(!ue)return;const je=document.activeElement,ot=ue.tabIndex;ue.tabIndex=-1,ue.style.pointerEvents="none",ue.blur();try{ue.contentWindow?.location.reload()}catch{const Nn=Fe.current;Nn&&(ue.src=Nn)}const Vt=()=>{ue.tabIndex=ot,ue.style.pointerEvents="",je?.focus(),ue.removeEventListener("load",Vt)};ue.addEventListener("load",Vt),setTimeout(Vt,3e3)},[vs,us]=C.useState(n.state.previewRevision);C.useEffect(()=>{vs!==n.state.previewRevision&&(us(n.state.previewRevision),tt())},[vs,n.state.previewRevision]);const Jt=()=>{if(!u.current||!Ue)return;const ue=Ue.includes("?")?"&":"?";u.current.src=`${Ue}${ue}_r=${Date.now()}`},mn=()=>{const ue=$c.indexOf(l);c($c[(ue+1)%$c.length])},re=()=>{const ue=u.current?.contentWindow?.location?.href??Ue??K;ue&&navigator.clipboard.writeText(ue)},Le=(()=>{if(!K)return"No server running";if(L)return L.name;try{const ue=new URL(K),je=we==="/"?"":we;return`${ue.host}${je}`}catch{return K}})(),Te=ue=>{const je=N[ue.key]??{},ot=Sr(ue.path,je);(L||ce(ot)!==ce(we))&&P(),pe.current=ot,w(null),j(null),A(ue.key),k(ue.path),Yt({path:ue.path,pageKey:ue.key,params:je}),n.selectTarget({kind:"page",key:ue.key,path:ue.path})},Oe=(ue,je)=>{if(!Ve)return;const ot=Ve,Vt={...Ne,[ue]:je};pe.current=Sr(V,Vt),R(Nn=>({...Nn,[ot]:Vt})),Yt({path:V,pageKey:ot,params:Vt})},st=ue=>{if(!K||!ee){de.error("Preview metadata not ready yet");return}P(),pe.current=null;const je=p0(ee),ot=xf(K,je,ue.key);w(ue),j(ot),n.selectTarget({kind:"section",key:ue.key})},ht=async({name:ue,path:je,templateKey:ot})=>{if(!O||!s)return;const Vt=rd(je);if(Vt){y(Vt);return}const Nn=je.trim().startsWith("/")?je.trim():`/${je.trim()}`;if(se.some(An=>ce(An.path)===ce(Nn))){y(`A page with path "${Nn}" already exists.`);return}let cc;if(ot&&(cc=J?.[ot],!cc)){y("Selected template no longer exists.");return}y(void 0);try{const An=await ae.mutateAsync({name:ue,path:Nn,template:cc});_(!1),de.success(`Page "${ue}" created`),await s6(vf),Te({key:An.key,name:An.name,path:An.path}),e({to:".",search:L4=>({...L4,...mu("blocks")}),replace:!0})}catch(An){y(An instanceof Error?An.message:"Failed to create page")}},kn=le.kind==="iframe",Qn=ue=>Me(o===ue?"preview":ue);return i.jsxs("div",{className:"flex flex-col w-full h-full",children:[lt&&le.kind==="iframe"&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:le.kind==="iframe"&&i.jsx("div",{className:"flex w-full items-center justify-center",children:i.jsxs("div",{className:"flex w-full max-w-[500px] items-center gap-0.5",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:et,children:i.jsx(zi,{size:14})})}),i.jsx(Pe,{side:"bottom",children:"Refresh"})]}),i.jsxs("div",{ref:x,className:"relative min-w-0 flex-1",children:[i.jsxs("div",{className:"flex h-8 w-full min-w-0 items-center rounded-md border border-border bg-background transition-colors duration-200 hover:bg-accent",children:[i.jsxs("div",{className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1 pl-2 pr-1",onClick:()=>m(ue=>!ue),children:[L&&i.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[i.jsx(on,{size:11}),"Global"]}),i.jsx("span",{className:ne("text-[13px] font-medium text-foreground",xe==null?"min-w-0 flex-1 truncate":"shrink-0"),children:xe??Le}),!L&&xe!=null&&V&&i.jsx("span",{className:"flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap text-[12px] text-muted-foreground",children:m0(V).map((ue,je)=>{if(ue.type==="text")return i.jsx("span",{className:ne(je===0?"min-w-0 truncate":"shrink-0"),children:ue.text},`text-${je}`);const ot=ye[ue.name];return ot&&$e?i.jsx(_P,{kind:ot,paramName:ue.name,value:Ne[ue.name]??"",sandboxRef:$e,onCommit:Vt=>Oe(ue.name,Vt)},`${Ve}:${ue.name}`):i.jsx(jP,{name:ue.name,value:Ne[ue.name]??"",onCommit:Vt=>Oe(ue.name,Vt)},`${Ve}:${ue.name}`)})})]}),i.jsx("button",{type:"button",className:"flex h-full shrink-0 items-center pl-1 pr-2",onClick:()=>m(ue=>!ue),"aria-label":"Choose page",children:i.jsx(Ht,{size:12,className:ne("shrink-0 text-muted-foreground transition-transform",f&&"rotate-180")})})]}),f&&i.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[i.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[i.jsx($9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{type:"text",value:p,onChange:ue=>g(ue.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),i.jsx("div",{className:"p-1.5 border-b",children:i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ue=>{ue.preventDefault(),m(!1),g(""),y(void 0),_(!0)},children:[i.jsx(Lt,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),fe.length===0&&be.length===0?i.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:se.length===0&&oe.length===0?"No pages found in this site.":"No results match your search."}):i.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[fe.length>0&&i.jsx("div",{className:"p-1.5",children:fe.map(ue=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),m(!1),g(""),Te(ue)},children:[i.jsx(Dn,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ue.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ue.path})]},ue.key))}),be.length>0&&i.jsxs("div",{className:ne("p-1.5",fe.length>0&&"border-t"),children:[i.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),be.map(ue=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),m(!1),g(""),st(ue)},children:[i.jsx(on,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ue.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ue.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},ue.key))]})]})]})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:()=>{const ue=Ue??le.previewUrl;ue&&window.open(ue,"_blank","noopener")},children:i.jsx(wn,{size:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in new tab"})]}),i.jsx("div",{className:"absolute inset-y-0 right-3 flex items-center md:right-4",children:i.jsxs(Zt,{children:[i.jsx(es,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",children:i.jsx(Gn,{size:14})})}),i.jsxs(ts,{align:"end",className:"w-44",children:[i.jsx(He,{onClick:Jt,children:"Hard Reload"}),i.jsx(He,{onClick:re,children:"Copy Current URL"}),J&&ee&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),Ve&&i.jsxs(He,{onClick:()=>{n.editSeo({kind:"page",key:Ve,path:V}),e({to:".",search:ue=>({...ue,...mu("blocks")}),replace:!0})},children:[i.jsx(Ba,{size:14}),"Edit SEO"]}),Ve&&i.jsxs(He,{onClick:()=>{try{r(Vv(sv(Ve)))}catch{de.error("Invalid page block key")}},children:[i.jsx(Ao,{size:14}),"View JSON"]}),i.jsxs(He,{onClick:()=>$(!0),children:[i.jsx(Ba,{size:14}),"Site SEO"]})]}),Q&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),i.jsxs(He,{onClick:()=>window.open(pl("vscode",Q)),children:[i.jsx("img",{src:yP,alt:"VSCode",width:14,height:14}),"Open in VSCode"]}),i.jsxs(He,{onClick:()=>window.open(pl("cursor",Q)),children:[i.jsx("img",{src:LP,alt:"Cursor",width:14,height:14}),"Open in Cursor"]})]})]})]})})]})})}),i.jsx("div",{className:"flex-1 flex overflow-hidden",children:i.jsxs("div",{className:ne("flex-1 relative overflow-hidden",l!=="desktop"&&le.kind==="iframe"&&"flex justify-center bg-muted/30"),children:[I&&le.kind==="iframe"&&i.jsx("div",{className:"absolute inset-x-0 top-0 z-40 h-0.5 overflow-hidden bg-primary/15",children:i.jsx("div",{className:"absolute inset-y-0 w-2/5 rounded-full bg-primary animate-preview-nav"})}),Be&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"starting",progress:he,claimPhase:De})}),le.kind==="suspended"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"suspended",onResume:Y.resume})}),le.kind==="errored"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"errored",error:le.error,onRetry:Y.retry,connectionsHref:`/${U.slug}/settings/connections`})}),St==="visual"&&!d&&i.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[i.jsx(xu,{size:12}),"Click any element to ask the AI"]}),St==="visual"&&d&&i.jsx(nP,{element:d,onDismiss:()=>h(null)}),kn&&i.jsx("div",{className:"absolute bottom-4 left-1/2 z-20 -translate-x-1/2",children:i.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border bg-background/90 p-1 shadow-lg backdrop-blur-sm",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Lu,{onClick:()=>Qn("visual"),"aria-pressed":o==="visual","aria-label":"Visual editor",active:o==="visual",children:i.jsx(xu,{size:16})})}),i.jsx(Pe,{side:"top",children:"Visual editor"})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Lu,{onClick:mn,"aria-label":_f[l],children:i.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[l==="mobile"&&i.jsx(Lx,{size:16}),l==="tablet"&&i.jsx(Sx,{size:16}),l==="desktop"&&i.jsx(wx,{size:16})]},l)})}),i.jsx(Pe,{side:"top",children:_f[l]})]})]})}),le.kind==="iframe"&&Ue&&i.jsx("div",{className:ne("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",l!=="desktop"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:l==="desktop"?"100%":`${wP[l]}px`},children:i.jsx("iframe",{ref:u,src:Ue,className:"w-full h-full border-0",title:"Dev Server Preview",onLoad:()=>{if(M(),Ce("vm_preview_loaded",{view_mode:o,vm_id:G?.sandboxHandle??null}),!L)try{const ue=u.current?.contentWindow?.location?.pathname;if(!ue)return;const je=pe.current;if(je!==null&&(pe.current=null,ce(ue)!==ce(je))||ce(ue)===ce(we))return;k(ue),Yt({path:ue,pageKey:T,params:Ne})}catch{}o==="visual"&&ct()}},le.previewUrl)})]})}),i.jsx(QR,{open:v,onOpenChange:_,isPending:ae.isPending,error:b,templates:se,onSubmit:ht}),z&&J&&ee&&i.jsx(C.Suspense,{fallback:null,children:i.jsx(SP,{open:z,onOpenChange:$,orgSlug:U.slug,virtualMcpId:O??"",branch:s??"",decofile:J,meta:ee,onSaved:()=>{setTimeout(()=>{const ue=u.current;if(ue)try{ue.contentWindow?.location.reload()}catch{const je=Fe.current;je&&(ue.src=je)}},vf)},target:{kind:"site"}})})]})}function NP(t){const e=B.c(2),{virtualMcpId:s}=t,n=qs(s);if(!bn(n?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[i.jsx(fn,{size:24,className:"text-muted-foreground/60"}),i.jsx("div",{children:"No source to preview."}),i.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(kP,{}),e[1]=o):o=e[1],o}const AP="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",TP="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",EP=C.lazy(()=>Ws(()=>import("./file-explorer-grrkdCaR.js"),__vite__mapDeps([162,1,2,84,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,127,123,128,129,126,117,107,108,109,110,111,112,113,114,115,116,118,119,120,121,122,124,125,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.FileExplorer})));function RP(t){const e=B.c(17),{openPath:s}=t,n=Vn(),{org:r}=Ae(),{currentBranch:o}=as(),a=n?.entity?.id??null,l=dr(),c=Os(),d=l.vmEntry,h=c.lifecycle.phase==="running",u=d?.sandboxProviderKind==="user-desktop",f=a??"",m=o??"",p=u&&h&&!!a&&!!o;let g;e[0]!==r.slug||e[1]!==f||e[2]!==m||e[3]!==p?(g={orgSlug:r.slug,virtualMcpId:f,branch:m,enabled:p},e[0]=r.slug,e[1]=f,e[2]=m,e[3]=p,e[4]=g):g=e[4];const x=_g(g),v=u?x:null;if(!a||!o){let w;return e[5]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No sandbox to browse."}),e[5]=w):w=e[5],w}let _;e[6]!==v?(_=v&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center border-b border-border/60 px-3 md:px-4",children:i.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in VSCode",onClick:()=>window.open(pl("vscode",v)),children:i.jsx("img",{src:AP,alt:"VSCode",width:14,height:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in VSCode"})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon","aria-label":"Open in Cursor",onClick:()=>window.open(pl("cursor",v)),children:i.jsx("img",{src:TP,alt:"Cursor",width:14,height:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in Cursor"})]})]})}),e[6]=v,e[7]=_):_=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),e[8]=b):b=e[8];let y;e[9]!==o||e[10]!==s||e[11]!==r.slug||e[12]!==a?(y=i.jsx("div",{className:"flex-1 relative overflow-hidden bg-background",children:i.jsx(C.Suspense,{fallback:b,children:i.jsx(EP,{orgSlug:r.slug,virtualMcpId:a,branch:o,openPath:s})})}),e[9]=o,e[10]=s,e[11]=r.slug,e[12]=a,e[13]=y):y=e[13];let L;return e[14]!==_||e[15]!==y?(L=i.jsxs("div",{className:"flex flex-col w-full h-full",children:[_,y]}),e[14]=_,e[15]=y,e[16]=L):L=e[16],L}function PP(t){const e=B.c(2),{virtualMcpId:s}=t,n=qs(s);if(!bn(n?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[i.jsx(fn,{size:24,className:"text-muted-foreground/60"}),i.jsx("div",{children:"No content to edit."}),i.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(L3,{}),e[1]=o):o=e[1],o}const Bc={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:k9},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Bn},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:Q1}},IP=["fast","smart","thinking"];function DP(t){const e=B.c(15),{tier:s,onSelect:n}=t,[r,o]=C.useState(!1),a=Bc[s].icon;let l;e[0]!==a?(l=i.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const c=Bc[s];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Ht,{size:14,className:"text-muted-foreground"}),e[2]=d):d=e[2];let h;e[3]!==l||e[4]!==c.label?(h=i.jsx(Cs,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,c.label,d]})}),e[3]=l,e[4]=c.label,e[5]=h):h=e[5];let u;e[6]!==n||e[7]!==s?(u=IP.map(p=>{const g=Bc[p],x=g.icon;return i.jsxs("button",{type:"button",onClick:()=>{n(p),o(!1)},className:ne("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[i.jsx(x,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"text-sm",children:g.label}),i.jsx("div",{className:"text-xs text-muted-foreground",children:g.subtitle})]}),p===s&&i.jsx(Tt,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=n,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=i.jsx(Vs,{align:"start",className:"p-1 w-64",children:i.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==f?(m=i.jsxs(ks,{open:r,onOpenChange:o,children:[h,f]}),e[11]=r,e[12]=h,e[13]=f,e[14]=m):m=e[14],m}function MP(t){const e=B.c(15),{tier:s,onTierChange:n,override:r,onOverrideChange:o}=t,[a,l]=C.useState(r!==null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=c):c=e[0];let d;e[1]!==o||e[2]!==n||e[3]!==r||e[4]!==s||e[5]!==a?(d=a?i.jsx(C.Suspense,{fallback:i.jsx(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:i.jsx(OP,{override:r,onOverrideChange:o})}):i.jsx(DP,{tier:s,onSelect:n}),e[1]=o,e[2]=n,e[3]=r,e[4]=s,e[5]=a,e[6]=d):d=e[6];let h;e[7]!==o?(h=m=>{l(m),m||o(null)},e[7]=o,e[8]=h):h=e[8];let u;e[9]!==h||e[10]!==a?(u=i.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[i.jsx(ho,{checked:a,onCheckedChange:h,className:"cursor-pointer"}),"Specific model"]}),e[9]=h,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=i.jsxs("div",{className:"flex flex-col gap-2",children:[c,i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d,u]})]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function OP(t){const e=B.c(10),{override:s,onOverrideChange:n}=t,r=Sm(),o=r[0]?.id??null,[a,l]=C.useState(s?.credentialId??o);let c;e[0]!==s?(c=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=c):c=e[1];const d=c;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let h;e[3]!==a||e[4]!==n?(h=f=>{const m=f.keyId??a??"";l(m),n({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=n,e[5]=h):h=e[5];let u;return e[6]!==a||e[7]!==d||e[8]!==h?(u=i.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:i.jsx(Hx,{variant:"bordered",placeholder:"Pick a model",model:d,credentialId:a,onCredentialChange:l,onModelChange:h})}),e[6]=a,e[7]=d,e[8]=h,e[9]=u):u=e[9],u}const bg=[{key:"capabilities",heading:"Built-in capabilities",icon:j9,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Yn},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:_n},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:an},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:Cx}]},{key:"files",heading:"Files & code",icon:hi,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Cm},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:w9},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:C9},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:fo},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:hi},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:Vx}]},{key:"context",heading:"Context",icon:$a,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:$a},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:Ki},{name:"skill",title:"Load Skill",description:"Load a skill's full instructions (SKILL.md) by id",icon:Ki}]},{key:"browser",heading:"Browser",icon:on,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:ar},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:on},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:Ao}]}],$P=bg.flatMap(t=>t.tools.map(e=>e.name));function BP(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function zP(t){const e=B.c(5),{agentId:s,value:n,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==n?(a=i.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?i.jsx(C.Suspense,{fallback:i.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[i.jsx(j9,{size:14}),"Loading tools…"]}),children:i.jsx(FP,{agentId:s,value:n,onChange:r})}):i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=n,e[4]=a):a=e[4],a}function bf(t){const e=B.c(17),{value:s,checked:n,onToggle:r,title:o,description:a,leading:l}=t;let c;e[0]!==n?(c=i.jsx(cr,{checked:n,className:"pointer-events-none mt-0.5"}),e[0]=n,e[1]=c):c=e[1];let d;e[2]!==l?(d=l&&i.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=d):d=e[3];let h;e[4]!==o?(h=i.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&i.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=i.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==s?(m=i.jsxs(Ps,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[c,d,f]}),e[11]=r,e[12]=c,e[13]=d,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function yf(t){const e=B.c(20),{conn:s,label:n,icon:r,on:o,total:a,onToggle:l}=t,c=o===a;let d;e[0]!==r||e[1]!==s?(d=s?i.jsx(Gs,{icon:s.icon,name:s.title,size:"2xs"}):r?i.jsx(r,{size:14,className:"text-muted-foreground"}):i.jsx(kx,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=d):d=e[2];const h=s?.title??n??"Other tools";let u;e[3]!==h?(u=i.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=i.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=_=>{_.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=c?"None":"All";let g;e[10]!==m||e[11]!==p?(g=i.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==f||e[14]!==g?(x=i.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,g]}),e[13]=f,e[14]=g,e[15]=x):x=e[15];let v;return e[16]!==d||e[17]!==u||e[18]!==x?(v=i.jsxs("div",{className:"flex items-center gap-2",children:[d,u,x]}),e[16]=d,e[17]=u,e[18]=x,e[19]=v):v=e[19],v}function FP(t){const e=B.c(70),{agentId:s,value:n,onChange:r}=t,{org:o}=Ae(),[a,l]=C.useState(!1);let c;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(c={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=c):c=e[3];const d=pt(c);let h;e[4]!==d?(h={client:d},e[4]=d,e[5]=h):h=e[5];const{data:u,isLoading:f}=F9(h),m=Do();let p,g,x,v,_,b,y,L,w,S,j,V,k;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==n){const I=new Map(m.map(qP)),D=new Map;for(const se of u?.tools??[]){const oe=rn(se._meta)??"__other__",ce=rr(se.name,oe==="__other__"?void 0:oe),fe=se.title,be=fe&&fe!==se.name?fe:BP(ce);D.has(oe)||D.set(oe,{clientId:oe,conn:I.get(oe),tools:[]}),D.get(oe).tools.push({name:se.name,display:be,description:se.description})}const E=[...D.values()].sort(WP),P=(u?.tools??[]).map(KP),M=[...$P,...P],z=n===null?new Set(M):new Set(n),$=M.every(se=>z.has(se)),O=se=>r(M.every(oe=>se.has(oe))?null:[...se]),U=se=>{const oe=new Set(z);oe.has(se)?oe.delete(se):oe.add(se),O(oe)},H=(se,oe)=>{const ce=new Set(z);for(const fe of se)oe?ce.add(fe):ce.delete(fe);O(ce)};v=ks,k=a,_=l;let Y;e[25]===Symbol.for("react.memo_cache_sentinel")?(Y=i.jsx(j9,{size:14,className:"text-muted-foreground"}),e[25]=Y):Y=e[25];const G=$?"All tools":"Tools",K=!$&&i.jsxs(n6,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[z.size,"/",M.length]});let q;e[26]===Symbol.for("react.memo_cache_sentinel")?(q=i.jsx(Ht,{size:14,className:"text-muted-foreground"}),e[26]=q):q=e[26],e[27]!==G||e[28]!==K?(b=i.jsx(Cs,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[Y,G,K,q]})}),e[27]=G,e[28]=K,e[29]=b):b=e[29],x=Vs,j="p-0 w-80",V="start",g=lr,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(yi,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const W=$?`All ${M.length} tools enabled`:`${z.size} of ${M.length} enabled`;let F;e[31]!==W?(F=i.jsx("span",{className:"text-xs text-muted-foreground",children:W}),e[31]=W,e[32]=F):F=e[32];let X;e[33]!==r?(X=()=>r(null),e[33]=r,e[34]=X):X=e[34];let Q;e[35]!==$||e[36]!==X?(Q=i.jsx("button",{type:"button",onClick:X,disabled:$,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=$,e[36]=X,e[37]=Q):Q=e[37];let Z;e[38]===Symbol.for("react.memo_cache_sentinel")?(Z=i.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=Z):Z=e[38];let J;e[39]!==r?(J=()=>r([]),e[39]=r,e[40]=J):J=e[40];const ee=z.size===0;let te;e[41]!==J||e[42]!==ee?(te=i.jsx("button",{type:"button",onClick:J,disabled:ee,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=J,e[42]=ee,e[43]=te):te=e[43];let ae;e[44]!==Q||e[45]!==te?(ae=i.jsxs("div",{className:"flex items-center gap-2",children:[Q,Z,te]}),e[44]=Q,e[45]=te,e[46]=ae):ae=e[46],e[47]!==F||e[48]!==ae?(S=i.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[F,ae]}),e[47]=F,e[48]=ae,e[49]=S):S=e[49],p=Si,y="max-h-80",L=f?i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):i.jsxs(i.Fragment,{children:[i.jsx(Li,{children:"No tools found"}),bg.map(se=>{const oe=se.tools.map(HP),ce=oe.filter(fe=>z.has(fe)).length;return i.jsx(Fs,{heading:i.jsx(yf,{label:se.heading,icon:se.icon,on:ce,total:oe.length,onToggle:()=>H(oe,ce!==oe.length)}),children:se.tools.map(fe=>i.jsx(bf,{value:`${fe.title} ${fe.name}`,checked:z.has(fe.name),onToggle:()=>U(fe.name),title:fe.title,description:fe.description,leading:i.jsx(fe.icon,{size:16,className:"text-muted-foreground"})},fe.name))},se.key)}),E.map(se=>{const oe=se.tools.map(UP),ce=oe.filter(fe=>z.has(fe)).length;return i.jsx(Fs,{heading:i.jsx(yf,{conn:se.conn,on:ce,total:oe.length,onToggle:()=>H(oe,ce!==oe.length)}),children:se.tools.map(fe=>i.jsx(bf,{value:`${fe.display} ${fe.name} ${se.conn?.title??""}`,checked:z.has(fe.name),onToggle:()=>U(fe.name),title:fe.display,description:fe.description},fe.name))},se.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=n,e[12]=p,e[13]=g,e[14]=x,e[15]=v,e[16]=_,e[17]=b,e[18]=y,e[19]=L,e[20]=w,e[21]=S,e[22]=j,e[23]=V,e[24]=k}else p=e[12],g=e[13],x=e[14],v=e[15],_=e[16],b=e[17],y=e[18],L=e[19],w=e[20],S=e[21],j=e[22],V=e[23],k=e[24];let T;e[50]!==p||e[51]!==y||e[52]!==L?(T=i.jsx(p,{className:y,children:L}),e[50]=p,e[51]=y,e[52]=L,e[53]=T):T=e[53];let A;e[54]!==g||e[55]!==T||e[56]!==w||e[57]!==S?(A=i.jsxs(g,{children:[w,S,T]}),e[54]=g,e[55]=T,e[56]=w,e[57]=S,e[58]=A):A=e[58];let N;e[59]!==x||e[60]!==A||e[61]!==j||e[62]!==V?(N=i.jsx(x,{className:j,align:V,children:A}),e[59]=x,e[60]=A,e[61]=j,e[62]=V,e[63]=N):N=e[63];let R;return e[64]!==v||e[65]!==_||e[66]!==b||e[67]!==N||e[68]!==k?(R=i.jsxs(v,{open:k,onOpenChange:_,children:[b,N]}),e[64]=v,e[65]=_,e[66]=b,e[67]=N,e[68]=k,e[69]=R):R=e[69],R}function UP(t){return t.name}function HP(t){return t.name}function KP(t){return t.name}function WP(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function qP(t){return[t.id,t]}function so(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function GP(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return`Every ${n[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),c=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${c} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",d=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${c} at ${d}:${h} UTC`}return t}function YP(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function JP(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return{count:parseInt(n[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);return r?{count:parseInt(r[1]),unit:"days"}:null}function XP(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const QP=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function ZP({automationId:t,open:e,onOpenChange:s,onCustomSelect:n,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=Mo(),[l,c]=C.useState(!1),d=e??l,h=m=>{s?s(m):c(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),de.success("Starter added"),h(!1)}catch(p){const g=p instanceof Error?p.message:"Failed to add starter";de.error(g)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});h(!1),m.webhook?o?.(m.webhook):de.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";de.error(p)}};return i.jsxs(Zt,{open:d,onOpenChange:h,children:[i.jsx(es,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",children:[i.jsx(Lt,{size:14}),"Add Starter"]})}),i.jsxs(ts,{align:"end",className:"w-[200px]",children:[i.jsxs(oo,{children:[i.jsxs(ao,{className:"gap-2.5",children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),i.jsx(lo,{className:"w-[160px]",children:QP.map(m=>i.jsxs(He,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{h(!1),n?.()},children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{h(!1),r?.()},children:[i.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[i.jsx(Yn,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function yg(t){const e=B.c(31),{open:s,onOpenChange:n,url:r,token:o,title:a,description:l}=t,c=a===void 0?"Webhook ready":a,d=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[h,u]=C.useState(null),[f,m]=C.useState("curl"),[p,g]=C.useState("header"),x=C.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=async(I,D)=>{try{await navigator.clipboard.writeText(I),u(D),de.success("Copied"),setTimeout(()=>u(null),1500)}catch{de.error("Failed to copy")}},e[0]=v):v=e[0];const _=v;let b;e[1]!==p||e[2]!==o||e[3]!==r?(b=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=b):b=e[4];const y=b,L=r&&o?p==="header"?`curl -X POST "${y}" \\
|
|
182
182
|
-H "Authorization: Bearer ${o}" \\
|
|
183
183
|
-H "Content-Type: application/json" \\
|
|
184
184
|
-d '{"hello":"world"}'`:`curl -X POST "${y}" \\
|
|
@@ -197,7 +197,7 @@ ${X}`:X;d.setValue("metadata.instructions",Q,{shouldDirty:!0})},Y=new Set(h.map(
|
|
|
197
197
|
},
|
|
198
198
|
body: JSON.stringify({ hello: "world" }),
|
|
199
199
|
});`:"",S=f==="curl"?L:w;let j;e[5]!==c?(j=i.jsx(is,{children:c}),e[5]=c,e[6]=j):j=e[6];let V;e[7]!==d?(V=i.jsx(qn,{children:d}),e[7]=d,e[8]=V):V=e[8];let k;e[9]!==j||e[10]!==V?(k=i.jsxs(ns,{children:[j,V]}),e[9]=j,e[10]=V,e[11]=k):k=e[11];let T;e[12]!==p||e[13]!==h||e[14]!==y||e[15]!==f||e[16]!==S||e[17]!==o||e[18]!==x||e[19]!==r?(T=r&&o?i.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"URL"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:y}),i.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>_(y,"url"),children:[i.jsx(Ss,{size:13}),h==="url"?"Copied":"Copy"]})]})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Token (shown once)"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),i.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>_(o,"token"),children:[i.jsx(Ss,{size:13}),h==="token"?"Copied":"Copy"]})]})]}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Snippet"}),i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Eo,{value:f,onValueChange:I=>m(I),children:i.jsxs(kl,{className:"h-8 p-[2px]",children:[i.jsx($n,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),i.jsx($n,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),i.jsxs("label",{htmlFor:x,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[i.jsx(cr,{id:x,checked:p==="url",onCheckedChange:I=>g(I?"url":"header")}),"Token in URL"]})]}),i.jsxs(ie,{size:"sm",variant:"outline",onClick:()=>_(S,"example"),children:[i.jsx(Ss,{size:13}),h==="example"?"Copied":"Copy"]})]}),i.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:i.jsx(Pl,{code:S,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=p,e[13]=h,e[14]=y,e[15]=f,e[16]=S,e[17]=o,e[18]=x,e[19]=r,e[20]=T):T=e[20];let A;e[21]!==n?(A=i.jsx(_i,{children:i.jsx(ie,{onClick:()=>n(!1),children:"Done"})}),e[21]=n,e[22]=A):A=e[22];let N;e[23]!==k||e[24]!==T||e[25]!==A?(N=i.jsxs(Ft,{className:"max-w-lg",children:[k,T,A]}),e[23]=k,e[24]=T,e[25]=A,e[26]=N):N=e[26];let R;return e[27]!==n||e[28]!==s||e[29]!==N?(R=i.jsx(Ut,{open:s,onOpenChange:n,children:N}),e[27]=n,e[28]=s,e[29]=N,e[30]=R):R=e[30],R}function eI(t){const e=B.c(83),{trigger:s,automationId:n,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=Mo(),[c,d]=C.useState(!1),[h,u]=C.useState(!1),[f,m]=C.useState(null);let p;e[0]!==s.cron_expression?(p=s.cron_expression?JP(s.cron_expression):null,e[0]=s.cron_expression,e[1]=p):p=e[1];const g=p,[x,v]=C.useState(g?.count??1),[_,b]=C.useState(!1),[y,L]=C.useState(s.cron_expression??""),w=a.isPending||o.isPending||l.isPending,S=s.type==="cron",j=s.type==="webhook";let V;e[2]!==n||e[3]!==a||e[4]!==s.id?(V=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:n}),de.success("Starter removed")}catch{de.error("Failed to remove starter")}d(!1)},e[2]=n,e[3]=a,e[4]=s.id,e[5]=V):V=e[5];const k=V;let T;e[6]!==o||e[7]!==n||e[8]!==y||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(T=async()=>{const oe=y.trim();if(!oe||!so(oe)||oe===s.cron_expression){b(!1),L(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:n,type:"cron",cron_expression:oe}),await a.mutateAsync({trigger_id:s.id,automation_id:n}),b(!1)}catch{de.error("Failed to update starter"),L(s.cron_expression??""),b(!1)}},e[6]=o,e[7]=n,e[8]=y,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=T):T=e[12];const A=T;let N;e[13]!==n||e[14]!==l||e[15]!==s.id?(N=async()=>{u(!1);try{const oe=await l.mutateAsync({trigger_id:s.id,automation_id:n});m({url:oe.url,token:oe.token})}catch(oe){const ce=oe,fe=ce instanceof Error?ce.message:"Failed to rotate token";de.error(fe)}},e[13]=n,e[14]=l,e[15]=s.id,e[16]=N):N=e[16];const R=N;let I;e[17]!==o||e[18]!==n||e[19]!==g||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(I=async oe=>{if(!g)return;const ce=g.unit==="minutes"?5:1,fe=Math.max(ce,oe);fe!==oe&&v(fe);const be=YP(fe,g.unit);if(be!==s.cron_expression)try{await o.mutateAsync({automation_id:n,type:"cron",cron_expression:be}),await a.mutateAsync({trigger_id:s.id,automation_id:n})}catch{de.error("Failed to update starter"),v(g.count)}},e[17]=o,e[18]=n,e[19]=g,e[20]=a,e[21]=s.cron_expression,e[22]=s.id,e[23]=I):I=e[23];const D=I;let E;e[24]!==S||e[25]!==j?(E=S?i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}):j?i.jsx(Yn,{size:14,className:"text-muted-foreground shrink-0"}):i.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=S,e[25]=j,e[26]=E):E=e[26];let P;e[27]!==r||e[28]!==x||e[29]!==y||e[30]!==D||e[31]!==A||e[32]!==g||e[33]!==S||e[34]!==_||e[35]!==w||e[36]!==j||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(P=g&&S?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),i.jsx("input",{type:"number",min:g.unit==="minutes"?5:1,value:x,onChange:oe=>v(parseInt(oe.target.value)||1),onBlur:()=>D(x),onKeyDown:oe=>{oe.key==="Enter"&&oe.target.blur(),oe.key==="Escape"&&v(g.count)},disabled:w,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),i.jsx("span",{className:"text-sm",children:XP(g.unit,x)})]}):S&&_?i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",value:y,onChange:oe=>L(oe.target.value),onBlur:A,onKeyDown:oe=>{oe.key==="Enter"&&oe.target.blur(),oe.key==="Escape"&&(b(!1),L(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),y&&!so(y)&&i.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):i.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[i.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:S?GP(s.cron_expression??""):j?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!S&&!j&&s.params&&Object.keys(s.params).length>0&&i.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(tI).join(", ")})]}),e[27]=r,e[28]=x,e[29]=y,e[30]=D,e[31]=A,e[32]=g,e[33]=S,e[34]=_,e[35]=w,e[36]=j,e[37]=s.cron_expression,e[38]=s.event_type,e[39]=s.params,e[40]=P):P=e[40];let M;e[41]!==w?(M=w&&i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=w,e[42]=M):M=e[42];let z;e[43]!==g||e[44]!==S||e[45]!==_||e[46]!==s.cron_expression?(z=S&&!g&&!_&&i.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{L(s.cron_expression??""),b(!0)},children:i.jsx(w9,{size:13,className:"text-muted-foreground"})}),e[43]=g,e[44]=S,e[45]=_,e[46]=s.cron_expression,e[47]=z):z=e[47];let $;e[48]!==j?($=j&&i.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:"Rotate token",onClick:()=>u(!0),children:i.jsx(zi,{size:13,className:"text-muted-foreground"})}),e[48]=j,e[49]=$):$=e[49];let O;e[50]===Symbol.for("react.memo_cache_sentinel")?(O=i.jsx(ie,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(!0),children:i.jsx(yn,{size:13,className:"text-muted-foreground"})}),e[50]=O):O=e[50];let U;e[51]!==$||e[52]!==M||e[53]!==z?(U=i.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[M,z,$,O]}),e[51]=$,e[52]=M,e[53]=z,e[54]=U):U=e[54];let H;e[55]!==U||e[56]!==E||e[57]!==P?(H=i.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[E,P,U]}),e[55]=U,e[56]=E,e[57]=P,e[58]=H):H=e[58];let Y;e[59]===Symbol.for("react.memo_cache_sentinel")?(Y=i.jsxs(Ha,{children:[i.jsx(Ka,{children:"Remove Starter"}),i.jsx(Wa,{children:"Are you sure you want to remove this starter?"})]}),e[59]=Y):Y=e[59];let G;e[60]===Symbol.for("react.memo_cache_sentinel")?(G=i.jsx(Ga,{children:"Cancel"}),e[60]=G):G=e[60];let K;e[61]!==k?(K=i.jsxs(Ua,{children:[Y,i.jsxs(qa,{children:[G,i.jsx(Ya,{onClick:k,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=k,e[62]=K):K=e[62];let q;e[63]!==c||e[64]!==K?(q=i.jsx(Fa,{open:c,onOpenChange:d,children:K}),e[63]=c,e[64]=K,e[65]=q):q=e[65];let W;e[66]===Symbol.for("react.memo_cache_sentinel")?(W=i.jsxs(Ha,{children:[i.jsx(Ka,{children:"Rotate webhook token"}),i.jsx(Wa,{children:"A new token will be generated and the current token will stop working. Any senders using the old token must be updated."})]}),e[66]=W):W=e[66];let F;e[67]===Symbol.for("react.memo_cache_sentinel")?(F=i.jsx(Ga,{children:"Cancel"}),e[67]=F):F=e[67];let X;e[68]!==R?(X=i.jsxs(Ua,{children:[W,i.jsxs(qa,{children:[F,i.jsx(Ya,{onClick:R,children:"Rotate"})]})]}),e[68]=R,e[69]=X):X=e[69];let Q;e[70]!==h||e[71]!==X?(Q=i.jsx(Fa,{open:h,onOpenChange:u,children:X}),e[70]=h,e[71]=X,e[72]=Q):Q=e[72];const Z=f!==null;let J;e[73]===Symbol.for("react.memo_cache_sentinel")?(J=oe=>{oe||m(null)},e[73]=J):J=e[73];const ee=f?.url??null,te=f?.token??null;let ae;e[74]!==Z||e[75]!==ee||e[76]!==te?(ae=i.jsx(yg,{open:Z,onOpenChange:J,url:ee,token:te,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=Z,e[75]=ee,e[76]=te,e[77]=ae):ae=e[77];let se;return e[78]!==H||e[79]!==q||e[80]!==Q||e[81]!==ae?(se=i.jsxs(i.Fragment,{children:[H,q,Q,ae]}),e[78]=H,e[79]=q,e[80]=Q,e[81]=ae,e[82]=se):se=e[82],se}function tI(t){const[e,s]=t;return`${e}: ${s}`}const sI=30;function nI(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},n=new Set(s.fields);for(const r of e.fields)n.add(r);return{...s,fields:n,saveCount:s.saveCount+1}}case"reset":return null}}function iI(t){const e=B.c(55),{automationId:s,onDone:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const o=Do(r),[a,l]=C.useState(),[c,d]=C.useState();let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h={},e[1]=h):h=e[1];const[u,f]=C.useState(h),{triggerAdd:m}=Mo(),{data:p,isLoading:g}=i6(a);let x,v,_,b,y,L;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==c||e[6]!==g||e[7]!==n||e[8]!==u||e[9]!==o||e[10]!==p){const j=p?.find(P=>P.type===c);let V;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==c||e[21]!==n||e[22]!==u?(V=async()=>{if(!(!a||!c))try{await m.mutateAsync({automation_id:s,type:"event",event_type:c,connection_id:a,params:u}),Ce("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:c}),de.success("Event trigger added"),n()}catch{de.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=c,e[21]=n,e[22]=u,e[23]=V):V=e[23],x=V,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let k,T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),k=i.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=k,e[25]=T):(k=e[24],T=e[25]);let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx(yn,{size:13}),e[26]=A):A=e[26],e[27]!==n?(_=i.jsxs("div",{className:"flex items-center gap-2",children:[T,k,i.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:n,children:A})]}),e[27]=n,e[28]=_):_=e[28];const N=a??"";let R;e[29]===Symbol.for("react.memo_cache_sentinel")?(R=P=>{l(P),d(void 0),f({})},e[29]=R):R=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(zt,{className:"w-full",children:i.jsx(Gt,{placeholder:"Select connection..."})}),e[30]=I):I=e[30];let D;e[31]!==o?(D=o.length===0?i.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):o.map(aI),e[31]=o,e[32]=D):D=e[32];let E;e[33]!==D?(E=i.jsx($t,{children:D}),e[33]=D,e[34]=E):E=e[34],e[35]!==N||e[36]!==E?(b=i.jsxs(Bt,{value:N,onValueChange:R,children:[I,E]}),e[35]=N,e[36]=E,e[37]=b):b=e[37],e[38]!==a||e[39]!==c||e[40]!==g||e[41]!==p?(y=a&&i.jsxs(Bt,{value:c??"",onValueChange:P=>{d(P),f({})},children:[i.jsx(zt,{className:"w-full",children:g?i.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[i.jsx(qe,{size:13,className:"animate-spin"}),"Loading events..."]}):i.jsx(Gt,{placeholder:"Select event type...",children:c??"Select event type..."})}),i.jsx($t,{children:p?.map(oI)})]}),e[38]=a,e[39]=c,e[40]=g,e[41]=p,e[42]=y):y=e[42],L=j?.paramsSchema&&Object.keys(j.paramsSchema).length>0&&i.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(j.paramsSchema).map(P=>{const[M,z]=P;return i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsxs("label",{className:"text-xs text-muted-foreground",children:[M,z.description&&i.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",z.description]})]}),z.enum?i.jsxs(Bt,{value:u[M]??"",onValueChange:$=>f(O=>({...O,[M]:$})),children:[i.jsx(zt,{className:"w-full",children:i.jsx(Gt,{placeholder:`Select ${M}...`})}),i.jsx($t,{children:z.enum.map(rI)})]}):i.jsx("input",{type:"text",value:u[M]??"",onChange:$=>f(O=>({...O,[M]:$.target.value})),placeholder:z.description??M,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},M)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=c,e[6]=g,e[7]=n,e[8]=u,e[9]=o,e[10]=p,e[11]=x,e[12]=v,e[13]=_,e[14]=b,e[15]=y,e[16]=L}else x=e[11],v=e[12],_=e[13],b=e[14],y=e[15],L=e[16];let w;e[43]!==m||e[44]!==a||e[45]!==c||e[46]!==x?(w=a&&c&&i.jsx(ie,{size:"sm",onClick:x,disabled:m.isPending,children:m.isPending?i.jsx(qe,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=c,e[46]=x,e[47]=w):w=e[47];let S;return e[48]!==v||e[49]!==_||e[50]!==b||e[51]!==y||e[52]!==L||e[53]!==w?(S=i.jsxs("div",{className:v,children:[_,b,y,L,w]}),e[48]=v,e[49]=_,e[50]=b,e[51]=y,e[52]=L,e[53]=w,e[54]=S):S=e[54],S}function rI(t){return i.jsx(nt,{value:t,children:t},t)}function oI(t){return i.jsx(nt,{value:t.type,children:i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{children:t.type}),i.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function aI(t){return i.jsx(nt,{value:t.id,children:t.title},t.id)}function lI({automationId:t,automation:e,onBack:s,onDelete:n}){const r=e.virtual_mcp_id,{org:o}=Ae(),{update:a,triggerAdd:l,run:c}=Mo(),d=Do(),h=new Map(d.map(J=>[J.id,J.title])),{openTask:u}=as(),{setChatOpen:f}=ko(),{sendMessage:m}=js(),p=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[g,x]=C.useState(p),[v,_]=C.useState(!1),[b,y]=C.useState(!1),[L,w]=C.useState(!1),[S,j]=C.useState(""),[V,k]=C.useState(!1),[T,A]=C.useState(null),[N,R]=C.useState(!1),[I,D]=C.useState(!1),[E,P]=C.useState(!1),M=async()=>{if(N)return;const ee=o5(g).filter(te=>te.type==="text").map(te=>te.text).join(`
|
|
200
|
-
`);if(ee.trim()){R(!0);try{X(),Ce("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ee.length}),f(!0),await m({tiptapDoc:R3({managerAgentId:U1.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ee})})}finally{R(!1)}}},z=e.models?.tier??"smart",$=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,O=f9({defaultValues:{name:e.name,active:e.active,tier:z,modelOverride:$,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),U=O.watch("active"),[H,Y]=C.useReducer(nI,null),G=()=>{H!==null&&(Ce("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(H.fields),save_count:H.saveCount,edit_duration_ms:Date.now()-H.start}),Y({type:"reset"}))},K=async()=>{const J=O.control._formState.dirtyFields,ee=Object.keys(J);if(ee.length===0&&!E)return!0;const te=O.getValues(),ae=O.control._defaultValues;O.reset(te,{keepValues:!0});const se=E;P(!1);const oe={tier:te.tier,...te.modelOverride?{modelId:te.modelOverride.modelId,credentialId:te.modelOverride.credentialId,modelTitle:te.modelOverride.title}:{}},ce={id:t,name:te.name,active:te.active,models:oe,tools:te.tools,maxAgentSteps:te.maxAgentSteps,messages:r5(g),temperature:0};try{await a.mutateAsync(ce)}catch{return O.reset(ae,{keepValues:!0}),se&&P(!0),!1}const fe=[...ee];return se&&fe.push("messages"),Y({type:"accumulate",now:Date.now(),fields:fe}),F(),!0},{schedule:q,flush:W}=Xa({save:K}),{schedule:F,flush:X}=Xa({delayMs:3e4,save:async()=>G()});C.useEffect(()=>{const J=O.watch(()=>q());return()=>J.unsubscribe()},[]);const Q=J=>{if(x(J),!I){D(!0);return}P(!0),q()},Z=async()=>{Ce("automation_test_clicked",{automation_id:t,agent_id:r});const J=await W();if(X(),!!J){if(!g){de.error("No instructions configured for this automation");return}try{const ee=await c.mutateAsync(t);ee.threadId&&(f(!0),u(ee.threadId))}catch{}}};return i.jsxs(i.Fragment,{children:[s&&i.jsx("div",{className:"flex items-center pb-4 shrink-0",children:i.jsxs(ie,{variant:"ghost",size:"sm",onClick:s,children:[i.jsx(Vl,{size:14}),"Back to list"]})}),i.jsxs("div",{className:"flex flex-col gap-8",children:[i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx(fs,{control:O.control,name:"name",render:({field:J})=>i.jsx(Ye,{...J,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),n&&i.jsx(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:i.jsx(ws,{size:14})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(fs,{control:O.control,name:"active",render:({field:J})=>i.jsx(ho,{checked:J.value,onCheckedChange:ee=>{J.onChange(ee),W()},className:"cursor-pointer"})}),i.jsx("span",{className:"text-sm text-muted-foreground",children:U?"Active":"Inactive"}),i.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),i.jsx(P3,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),i.jsx(ZP,{automationId:t,open:v,onOpenChange:_,onCustomSelect:()=>{w(!0),k(!1),j("")},onEventSelect:()=>{k(!0),w(!1)},onWebhookCreated:J=>{Ce("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),A(J)}})]}),e.triggers.length===0&&!L?i.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:i.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",i.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>_(!0),children:"Add a starter"})," ","to get going."]})}):i.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(J=>i.jsx(eI,{trigger:J,automationId:t,connectionName:J.connection_id?h.get(J.connection_id):void 0},J.id))}),L&&i.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),i.jsx("input",{type:"text",value:S,onChange:J=>j(J.target.value),onBlur:async()=>{const J=S.trim();if(!(!J||!so(J)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:J}),Ce("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),de.success("Starter added"),w(!1),j("")}catch{de.error("Failed to add starter")}},onKeyDown:async J=>{const ee=S.trim();J.key==="Enter"&&ee&&so(ee)&&J.target.blur(),J.key==="Escape"&&(w(!1),j(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),S&&!so(S)&&i.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),i.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),j("")},children:i.jsx(yn,{size:13})})]}),V&&i.jsx(C.Suspense,{fallback:i.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:i.jsx(iI,{automationId:t,onDone:()=>k(!1)})}),i.jsx(yg,{open:T!==null,onOpenChange:J=>{J||A(null)},url:T?.url??null,token:T?.token??null})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),i.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:N||!g,onClick:M,children:[i.jsx(Bn,{size:13}),"Improve"]})]}),i.jsx(E2,{tiptapDoc:g,setTiptapDoc:Q,placeholder:"What should this automation do?",children:i.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[i.jsx(R2,{virtualMcpId:r||null,className:"max-h-[45vh]"}),i.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Z,disabled:!r,children:[i.jsx(g9,{size:16}),"Test"]})}),i.jsx(Pe,{children:"Test Automation"})]})})]})})]}),i.jsxs(A5,{open:b,onOpenChange:y,className:"flex flex-col gap-2.5",children:[i.jsxs(T5,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),i.jsx(Ht,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),i.jsxs(E5,{className:"flex flex-col gap-5 pt-0.5",children:[i.jsx(MP,{tier:O.watch("tier"),onTierChange:J=>O.setValue("tier",J,{shouldDirty:!0}),override:O.watch("modelOverride"),onOverrideChange:J=>O.setValue("modelOverride",J,{shouldDirty:!0})}),i.jsx(zP,{agentId:r||null,value:O.watch("tools"),onChange:J=>O.setValue("tools",J,{shouldDirty:!0})}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),i.jsx(Ye,{type:"number",min:1,max:100,className:"w-40",placeholder:`${sI} (default)`,value:O.watch("maxAgentSteps")??"",onChange:J=>{const ee=J.target.value.trim(),te=ee===""?null:Number(ee);O.setValue("maxAgentSteps",te===null||Number.isNaN(te)?null:te,{shouldDirty:!0})}})]})]})]})]})]})}const Lg=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function Sg(t){const e=Lg.find(n=>n.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function cI(t){const e=B.c(12),{automationId:s,triggerIds:n}=t,[r,o]=C.useState("30d"),[a,l]=C.useState(uI);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=p=>{const g=p;o(g),l(Sg(g))},e[0]=c):c=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(zt,{className:"w-44",children:i.jsx(Gt,{})}),e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx($t,{children:Lg.map(dI)}),e[2]=h):h=e[2];let u;e[3]!==r?(u=i.jsx("div",{className:"flex items-center justify-end",children:i.jsxs(Bt,{value:r,onValueChange:c,children:[d,h]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==n?(f=i.jsx(R5,{automationId:s,triggerIds:n,range:a}),e[5]=s,e[6]=a,e[7]=n,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=i.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function dI(t){return i.jsx(nt,{value:t.key,children:t.label},t.key)}function uI(){return Sg("30d")}function hI(t){const e=B.c(5),{tabId:s}=t;let n;e[0]!==s?(n=Vm(s),e[0]=s,e[1]=n):n=e[1];const r=n;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(pi,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=i.jsx(C.Suspense,{fallback:o,children:i.jsx(fI,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function fI(t){const e=B.c(24),{id:s}=t,n=Ct(),{data:r,isLoading:o}=r6(s),[a,l]=C.useState("settings");let c;e[0]!==n?(c=()=>{n({to:".",search:pI,replace:!0})},e[0]=n,e[1]=c):c=e[1];const d=c;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(pi,{}),e[2]=y):y=e[2],y}if(!r){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=y):y=e[3],y}let h;e[4]!==r.triggers?(h=r.triggers.map(mI),e[4]=r.triggers,e[5]=h):h=e[5];const u=h;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Vl,{size:14}),e[6]=f):f=e[6];let m;e[7]!==d?(m=i.jsxs(ie,{variant:"ghost",size:"sm",onClick:d,children:[f,"Back to list"]}),e[7]=d,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=y=>l(y),e[10]=g):g=e[10];let x;e[11]!==a?(x=i.jsx(Om,{tabs:p,activeTab:a,onTabChange:g}),e[11]=a,e[12]=x):x=e[12];let v;e[13]!==m||e[14]!==x?(v=i.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,x]}),e[13]=m,e[14]=x,e[15]=v):v=e[15];let _;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(_=a==="settings"?i.jsx(lI,{automationId:s,automation:r}):i.jsx(cI,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=_):_=e[20];let b;return e[21]!==v||e[22]!==_?(b=i.jsx(zs,{children:i.jsx(zs.Content,{children:i.jsxs(zs.Body,{children:[v,_]})})}),e[21]=v,e[22]=_,e[23]=b):b=e[23],b}function mI(t){return t.id}function pI(t){return{...t,main:"automations"}}function gI(t){const e=B.c(20),{virtualMcpId:s}=t,n=Ct(),{data:r}=o6(s),o=r===void 0?[]:r,{create:a}=Mo(),[l,c]=C.useState(""),d=l.toLowerCase(),h=o.filter(T=>T.name.toLowerCase().includes(d));let u;e[0]!==n?(u=T=>n({to:".",search:A=>({...A,main:"automation:"+T}),replace:!0}),e[0]=n,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ce("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const T=await a.mutateAsync(a6(s));f(T.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Lt,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=i.jsxs(ie,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];const x=g,v=zs,_=zs,b=zs;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(zs.Title,{children:"Automations"}),e[6]=y):y=e[6];const L=o.length>0&&i.jsx(K9,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==x||e[8]!==L?(w=i.jsxs("div",{className:"flex flex-col gap-6",children:[y,i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[L,x]})]}),e[7]=x,e[8]=L,e[9]=w):w=e[9];const S=o.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(qi,{image:i.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:x})}):h.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(qi,{image:i.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):i.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:h.map(T=>i.jsx(l6,{automation:T,onClick:()=>f(T.id)},T.id))});let j;e[10]!==S||e[11]!==b.Body||e[12]!==w?(j=i.jsxs(b.Body,{children:[w,S]}),e[10]=S,e[11]=b.Body,e[12]=w,e[13]=j):j=e[13];let V;e[14]!==j||e[15]!==_.Content?(V=i.jsx(_.Content,{children:j}),e[14]=j,e[15]=_.Content,e[16]=V):V=e[16];let k;return e[17]!==v||e[18]!==V?(k=i.jsx(v,{children:V}),e[17]=v,e[18]=V,e[19]=k):k=e[19],k}function xI(t){const e=B.c(3),{virtualMcpId:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(pi,{}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsx(C.Suspense,{fallback:n,children:i.jsx(gI,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function vI(t){const e=B.c(37),{file:s,onClose:n}=t;let r,o;e[0]!==s.filename?(r=i.jsx(Gi,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=rv(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let c;e[7]!==r||e[8]!==o||e[9]!==l?(c=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=c):c=e[10];let d;e[11]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Rv,{size:14}),e[11]=d):d=e[11];let h;e[12]!==s.downloadUrl||e[13]!==s.filename?(h=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",asChild:!0,children:i.jsx("a",{href:s.downloadUrl,download:s.filename,children:d})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Pe,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==h?(f=i.jsxs(Ie,{children:[h,u]}),e[16]=h,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(wn,{size:14}),e[20]=p):p=e[20];let g;e[21]!==m?(g=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=g):g=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Pe,{side:"bottom",children:"Open in new tab"}),e[23]=x):x=e[23];let v;e[24]!==g?(v=i.jsxs(Ie,{children:[g,x]}),e[24]=g,e[25]=v):v=e[25];let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(yn,{size:14}),e[26]=_):_=e[26];let b;e[27]!==n?(b=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:n,children:_})}),e[27]=n,e[28]=b):b=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Pe,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let L;e[30]!==b?(L=i.jsxs(Ie,{children:[b,y]}),e[30]=b,e[31]=L):L=e[31];let w;return e[32]!==v||e[33]!==L||e[34]!==c||e[35]!==f?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,f,v,L]}),e[32]=v,e[33]=L,e[34]=c,e[35]=f,e[36]=w):w=e[36],w}function _I(t){const e=B.c(24),{fileKey:s,taskId:n}=t,r=Ct(),{data:o,isPending:a}=O1(n);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const c=l;let d;e[3]!==r?(d=()=>r({to:".",search:bI,replace:!0}),e[3]=r,e[4]=d):d=e[4];const h=d;if(!c){if(a){let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full w-full bg-background",children:i.jsx(nv,{})}),e[5]=b):b=e[5],b}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let g;e[8]!==p?(g=i.jsx(Gi,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=g):g=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=x):x=e[10];let v;e[11]!==h?(v=i.jsx(ie,{variant:"ghost",size:"sm",onClick:h,children:"Close"}),e[11]=h,e[12]=v):v=e[12];let _;return e[13]!==g||e[14]!==v?(_=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[g,x,v]}),e[13]=g,e[14]=v,e[15]=_):_=e[15],_}let u;e[16]!==c||e[17]!==h?(u=i.jsx(vI,{file:c,onClose:h}),e[16]=c,e[17]=h,e[18]=u):u=e[18];let f;e[19]!==c?(f=i.jsx("div",{className:"relative min-h-0 flex-1",children:i.jsx(iv,{file:c})}),e[19]=c,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=i.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function bI(t){return{...t,main:0}}const zc="home";function yI(t){const e=B.c(5),{label:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(yt,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=n):n=e[0];let r;e[1]!==s?(r=s&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[n,r]}),e[3]=r,e[4]=o):o=e[4],o}function LI(t){const e=B.c(15),{path:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={refetchIntervalWhenAbsent:2e3},e[0]=n):n=e[0];const r=ov(zc,s,n),o=av(zc)(s);if(r.isPending||!r.data){const f=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=i.jsx(yI,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==r.data?(a=lv(r.data),e[3]=r.data,e[4]=a):a=e[4];const l=r.data.shareMode??"private",c=r.data.effectivePublic??!1,d=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==d?(h=i.jsx(cv,{volume:zc,path:s,shareMode:l,effectivePublic:c,url:d}),e[5]=s,e[6]=l,e[7]=c,e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=i.jsx(dv,{readUrl:o,marker:a,title:s,savePath:s,trailing:h}),e[10]=s,e[11]=o,e[12]=a,e[13]=h,e[14]=u):u=e[14],u}function SI(t){const e=B.c(5),{path:s}=t,n=Ct();let r;e[0]!==n?(r=()=>n({to:".",search:wI,replace:!0}),e[0]=n,e[1]=r):r=e[1];const o=r;let a;return e[2]!==o||e[3]!==s?(a=i.jsx(uv,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function wI(t){return{...t,main:0}}function jI(){const t=B.c(12),e=Ct(),[s,n]=C.useState(null),[r,o]=C.useState(null);let a;t[0]!==e?(a=f=>e({to:".",search:m=>({...m,main:f}),replace:!0}),t[0]=e,t[1]=a):a=t[1];const l=a;let c;t[2]!==l?(c=i.jsx(hv,{onOpenFile:f=>l(kv(f)),onOpenSkill:n,onOpenBrand:o}),t[2]=l,t[3]=c):c=t[3];let d;t[4]!==s?(d=s&&i.jsx(fv,{skillPath:s,onClose:()=>n(null)},s),t[4]=s,t[5]=d):d=t[5];let h;t[6]!==r?(h=r&&i.jsx(mv,{brandPath:r,onClose:()=>o(null)},r),t[6]=r,t[7]=h):h=t[7];let u;return t[8]!==c||t[9]!==d||t[10]!==h?(u=i.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[c,d,h]}),t[8]=c,t[9]=d,t[10]=h,t[11]=u):u=t[11],u}const Lf=C.lazy(()=>Ws(()=>import("./project-app-view-D3NA74TU.js"),__vite__mapDeps([163,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,3,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,132,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.AppViewContent})));function CI(t){const e=B.c(60),{activeTab:s,virtualMcpId:n,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(s==="overview"){let L;return e[0]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(qE,{}),e[0]=L):L=e[0],L}if(s==="board"){let L;return e[1]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:i.jsx(Gv,{})}),e[1]=L):L=e[1],L}if(Nv(s)){let L;return e[2]!==n?(L=i.jsx(lf,{virtualMcpId:n}),e[2]=n,e[3]=L):L=e[3],L}if(s==="git"){let L;return e[4]!==n?(L=i.jsx(GR,{virtualMcpId:n}),e[4]=n,e[5]=L):L=e[5],L}if(s==="automations"){let L;return e[6]!==n?(L=i.jsx(xI,{virtualMcpId:n}),e[6]=n,e[7]=L):L=e[7],L}if(s==="preview"){let L;return e[8]!==n?(L=i.jsx(NP,{virtualMcpId:n}),e[8]=n,e[9]=L):L=e[9],L}let c;e[10]!==s?(c=Av(s),e[10]=s,e[11]=c):c=e[11];const d=c;if(d){let L;return e[12]!==d.path?(L=i.jsx(RP,{openPath:d.path}),e[12]=d.path,e[13]=L):L=e[13],L}if(s==="content"){let L;return e[14]!==n?(L=i.jsx(PP,{virtualMcpId:n}),e[14]=n,e[15]=L):L=e[15],L}if(s==="files"){let L;return e[16]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(jI,{}),e[16]=L):L=e[16],L}if(l){let L;return e[17]!==s?(L=i.jsx(hI,{tabId:s}),e[17]=s,e[18]=L):L=e[18],L}let h;e[19]!==s?(h=Nm(s),e[19]=s,e[20]=h):h=e[20];const u=h;if(u){let L;return e[21]!==u.path?(L=i.jsx(LI,{path:u.path},u.path),e[21]=u.path,e[22]=L):L=e[22],L}let f;e[23]!==s?(f=km(s),e[23]=s,e[24]=f):f=e[24];const m=f;if(m){let L;return e[25]!==m.key||e[26]!==r?(L=i.jsx(_I,{fileKey:m.key,taskId:r}),e[25]=m.key,e[26]=r,e[27]=L):L=e[27],L}let p;e[28]!==s?(p=Am(s),e[28]=s,e[29]=p):p=e[29];const g=p;if(g){let L;return e[30]!==g.path?(L=i.jsx(SI,{path:g.path},g.path),e[30]=g.path,e[31]=L):L=e[31],L}let x;e[32]!==s?(x=Tv(s),e[32]=s,e[33]=x):x=e[33];const v=x;if(v){let L;if(e[34]!==a||e[35]!==v.connectionId||e[36]!==v.toolName){let k;e[38]!==v.connectionId||e[39]!==v.toolName?(k=T=>T.appId===v.connectionId&&T.toolName===v.toolName,e[38]=v.connectionId,e[39]=v.toolName,e[40]=k):k=e[40],L=a.find(k),e[34]=a,e[35]=v.connectionId,e[36]=v.toolName,e[37]=L}else L=e[37];const w=L;let S;e[41]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(pi,{}),e[41]=S):S=e[41];const j=w?.args;let V;return e[42]!==s||e[43]!==v.connectionId||e[44]!==v.toolName||e[45]!==j?(V=i.jsx(C.Suspense,{fallback:S,children:i.jsx(Lf,{connectionId:v.connectionId,toolName:v.toolName,args:j},s)}),e[42]=s,e[43]=v.connectionId,e[44]=v.toolName,e[45]=j,e[46]=V):V=e[46],V}let _;if(e[47]!==s||e[48]!==o){let L;e[50]!==s?(L=w=>w.id===s,e[50]=s,e[51]=L):L=e[51],_=o.find(L),e[47]=s,e[48]=o,e[49]=_}else _=e[49];const b=_;if(b){let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(pi,{}),e[52]=L):L=e[52];let w;return e[53]!==s||e[54]!==b.id||e[55]!==b.view.appId||e[56]!==b.view.args?(w=i.jsx(C.Suspense,{fallback:L,children:i.jsx(Lf,{connectionId:b.view.appId,toolName:b.id,args:b.view.args},s)}),e[53]=s,e[54]=b.id,e[55]=b.view.appId,e[56]=b.view.args,e[57]=w):w=e[57],w}let y;return e[58]!==n?(y=i.jsx(lf,{virtualMcpId:n}),e[58]=n,e[59]=y):y=e[59],y}function VI(t){const e=B.c(14),{taskId:s,virtualMcpId:n}=t;let r;e[0]!==s||e[1]!==n?(r={virtualMcpId:n,taskId:s},e[0]=s,e[1]=n,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=Fd(r);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(pi,{}),e[3]=d):d=e[3];let h;e[4]!==o||e[5]!==c||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==n?(h=i.jsx(C.Suspense,{fallback:d,children:i.jsx(CI,{activeTab:o,virtualMcpId:n,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:c})}),e[4]=o,e[5]=c,e[6]=l,e[7]=a,e[8]=s,e[9]=n,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=i.jsx(ps,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const li="setup";function kI(t){const e=B.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const n=s;let r;e[5]!==t?(r=()=>{t.active===li?t.onToggle():t.onSelectTab(li)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===li;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=i.jsx(NI,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==t?(c=t.scriptTabs.map(m=>i.jsx(TI,{active:t.active===m,onClick:()=>{t.active===m?t.onToggle():t.onSelectTab(m)},onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=c):c=e[12];let d;e[13]!==n||e[14]!==t.onAddScript?(d=i.jsx(EI,{scripts:n,onRun:t.onAddScript}),e[13]=n,e[14]=t.onAddScript,e[15]=d):d=e[15];let h;e[16]!==l||e[17]!==c||e[18]!==d?(h=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,c,d]}),e[16]=l,e[17]=c,e[18]=d,e[19]=h):h=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?i.jsx(RI,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):i.jsx(AI,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==h||e[33]!==u?(f=i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[h,u]}),e[32]=h,e[33]=u,e[34]=f):f=e[34],f}function NI(t){const e=B.c(8),{active:s,open:n,onClick:r}=t,o=s&&n,a=s&&n,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let c;e[0]!==l?(c=ne("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Nx,{className:"size-3.5"}),e[2]=d):d=e[2];let h;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==c?(h=i.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:c,children:[d,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=c,e[7]=h):h=e[7],h}function AI(t){const e=B.c(24),{status:s,onStart:n,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&n){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(fi,{className:"size-3.5"}),e[0]=c):c=e[0];let d;return e[1]!==n?(d=i.jsxs(ie,{variant:"outline",size:"sm",onClick:n,children:[c," Start"]}),e[1]=n,e[2]=d):d=e[2],d}if(s==="suspended"&&a){let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(fi,{className:"size-3.5"}),e[3]=c):c=e[3];let d;return e[4]!==a?(d=i.jsxs(ie,{variant:"outline",size:"sm",onClick:a,children:[c," Resume"]}),e[4]=a,e[5]=d):d=e[5],d}if(s==="errored"&&l){let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(zi,{className:"size-3.5"}),e[6]=c):c=e[6];let d;return e[7]!==l?(d=i.jsxs(ie,{variant:"outline",size:"sm",onClick:l,children:[c," Retry"]}),e[7]=l,e[8]=d):d=e[8],d}if(s==="starting"||s==="running"){const c=s==="running"&&!!o,d=c?"rounded-r-none border-r-0":void 0;let h;e[9]!==d?(h=ne(d),e[9]=d,e[10]=h):h=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(dm,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==h?(f=i.jsx(Re,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",onClick:r,className:h,children:[u," Stop"]})}),e[12]=r,e[13]=h,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Pe,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=i.jsxs(Ie,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==o||e[19]!==c?(g=c&&i.jsxs(Zt,{children:[i.jsx(es,{asChild:!0,children:i.jsx(ie,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:i.jsx(Ht,{className:"size-3"})})}),i.jsx(ts,{align:"end",children:i.jsxs(He,{onClick:o,children:[i.jsx(zi,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=c,e[20]=g):g=e[20];let x;return e[21]!==p||e[22]!==g?(x=i.jsxs("div",{className:"flex items-center",children:[p,g]}),e[21]=p,e[22]=g,e[23]=x):x=e[23],x}return null}function TI(t){const e=B.c(16),{active:s,onClick:n,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=ne("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const c=r?"pl-2.5 pr-1":"px-2.5",d=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let h;e[2]!==c||e[3]!==d?(h=ne("flex h-full items-center",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==o||e[6]!==n||e[7]!==h?(u=i.jsx("button",{type:"button",onClick:n,className:h,children:o}),e[5]=o,e[6]=n,e[7]=h,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&i.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:i.jsx(ms,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=i.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function EI(t){const e=B.c(10),{scripts:s,onRun:n}=t,[r,o]=C.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Cs,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"sm","aria-label":"Run script",children:i.jsx(Lt,{className:"size-3.5"})})})}),i.jsx(Pe,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==s?(c=s.length===0?i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>i.jsxs("button",{type:"button",onClick:()=>{o(!1),n(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=n,e[3]=s,e[4]=c):c=e[4];let d;e[5]!==c?(d=i.jsxs(Vs,{align:"start",className:"p-1 w-56",children:[l,c]}),e[5]=c,e[6]=d):d=e[6];let h;return e[7]!==r||e[8]!==d?(h=i.jsxs(ks,{open:r,onOpenChange:o,children:[a,d]}),e[7]=r,e[8]=d,e[9]=h):h=e[9],h}function RI(t){const e=B.c(13),{isRunning:s,isKilling:n,onRun:r,onStop:o}=t;if(n){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[i.jsx(qe,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=h):h=e[0],h}if(!s){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(fi,{className:"size-3.5"}),e[1]=h):h=e[1];let u;e[2]!==r?(u=i.jsx(Re,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",onClick:r,children:[h," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Pe,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=i.jsxs(Ie,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(dm,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=i.jsx(Re,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let c;e[10]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Pe,{children:"Stop process"}),e[10]=c):c=e[10];let d;return e[11]!==l?(d=i.jsxs(Ie,{children:[l,c]}),e[11]=l,e[12]=d):d=e[12],d}var wg=Object.defineProperty,PI=Object.getOwnPropertyDescriptor,II=(t,e)=>{for(var s in e)wg(t,s,{get:e[s],enumerable:!0})},_t=(t,e,s,n)=>{for(var r=n>1?void 0:n?PI(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(e,s,r):a(r))||r);return n&&r&&wg(e,s,r),r},Se=(t,e)=>(s,n)=>e(s,n,t),Sf="Terminal input",N0={get:()=>Sf,set:t=>Sf=t},wf="Too much output to announce, navigate to rows manually to read",A0={get:()=>wf,set:t=>wf=t};function DI(t){return t.replace(/\r?\n/g,"\r")}function MI(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function OI(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function $I(t,e,s,n){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");jg(r,e,s,n)}}function jg(t,e,s,n){t=DI(t),t=MI(t,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Cg(t,e,s){let n=s.getBoundingClientRect(),r=t.clientX-n.left-10,o=t.clientY-n.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function jf(t,e,s,n,r){Cg(t,e,s),r&&n.rightClickSelect(t),e.value=n.selectionText,e.select()}function In(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function rc(t,e=0,s=t.length){let n="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,n+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):n+=String.fromCharCode(o)}return n}var BI=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[n++]=(this._interim-55296)*1024+o-56320+65536:(e[n++]=this._interim,e[n++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,n;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[n++]=(a-55296)*1024+l-56320+65536:(e[n++]=a,e[n++]=l);continue}a!==65279&&(e[n++]=a)}return n}},zI=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r,o,a,l,c=0,d=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)m<<=6,m|=g;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=x-p;for(;d<v;){if(d>=s)return 0;if(g=t[d++],(g&192)!==128){d--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(x===2?m<128?d--:e[n++]=m:x===3?m<2048||m>=55296&&m<=57343||m===65279||(e[n++]=m):m<65536||m>1114111||(e[n++]=m)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[n++]=r,e[n++]=o,e[n++]=a,e[n++]=l,u+=4;if(r=t[u++],r<128)e[n++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(c=(r&31)<<6|o&63,c<128){u--;continue}e[n++]=c}else if((r&240)===224){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(c=(r&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;e[n++]=c}else if((r&248)===240){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,n;if(l=t[u++],(l&192)!==128){u--;continue}if(c=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;e[n++]=c}}return n}},Vg="",On=" ",qo=class kg{constructor(){this.fg=0,this.bg=0,this.extended=new gl}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new kg;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},gl=class Ng{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Ng(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Is=class Ag extends qo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new gl,this.combinedData=""}static fromCharData(e){let s=new Ag;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?In(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Cf="di$target",T0="di$dependencies",Fc=new Map;function FI(t){return t[T0]||[]}function Kt(t){if(Fc.has(t))return Fc.get(t);let e=function(s,n,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");UI(e,s,r)};return e._id=t,Fc.set(t,e),e}function UI(t,e,s){e[Cf]===e?e[T0].push({id:t,index:s}):(e[T0]=[{id:t,index:s}],e[Cf]=e)}var cs=Kt("BufferService"),Tg=Kt("CoreMouseService"),Vi=Kt("CoreService"),HI=Kt("CharsetService"),eu=Kt("InstantiationService"),Eg=Kt("LogService"),ds=Kt("OptionsService"),Rg=Kt("OscLinkService"),KI=Kt("UnicodeService"),Go=Kt("DecorationService"),E0=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let n=[],r=this._optionsService.rawOptions.linkHandler,o=new Is,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let h=0;h<a;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else c!==-1&&(d=!0);if(d||c!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:c+1,y:t},end:{x:h+(!d&&h===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||n.push({text:u,range:f,activate:(p,g)=>r?r.activate(p,g,f):WI(p,g),hover:(p,g)=>r?.hover?.(p,g,f),leave:(p,g)=>r?.leave?.(p,g,f)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,l=o.extended.urlId):(c=-1,l=-1)}}e(n)}};E0=_t([Se(0,cs),Se(1,ds),Se(2,Rg)],E0);function WI(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
200
|
+
`);if(ee.trim()){R(!0);try{X(),Ce("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ee.length}),f(!0),await m({tiptapDoc:R3({managerAgentId:U1.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ee})})}finally{R(!1)}}},z=e.models?.tier??"smart",$=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,O=f9({defaultValues:{name:e.name,active:e.active,tier:z,modelOverride:$,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),U=O.watch("active"),[H,Y]=C.useReducer(nI,null),G=()=>{H!==null&&(Ce("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(H.fields),save_count:H.saveCount,edit_duration_ms:Date.now()-H.start}),Y({type:"reset"}))},K=async()=>{const J=O.control._formState.dirtyFields,ee=Object.keys(J);if(ee.length===0&&!E)return!0;const te=O.getValues(),ae=O.control._defaultValues;O.reset(te,{keepValues:!0});const se=E;P(!1);const oe={tier:te.tier,...te.modelOverride?{modelId:te.modelOverride.modelId,credentialId:te.modelOverride.credentialId,modelTitle:te.modelOverride.title}:{}},ce={id:t,name:te.name,active:te.active,models:oe,tools:te.tools,maxAgentSteps:te.maxAgentSteps,messages:r5(g),temperature:0};try{await a.mutateAsync(ce)}catch{return O.reset(ae,{keepValues:!0}),se&&P(!0),!1}const fe=[...ee];return se&&fe.push("messages"),Y({type:"accumulate",now:Date.now(),fields:fe}),F(),!0},{schedule:q,flush:W}=Xa({save:K}),{schedule:F,flush:X}=Xa({delayMs:3e4,save:async()=>G()});C.useEffect(()=>{const J=O.watch(()=>q());return()=>J.unsubscribe()},[]);const Q=J=>{if(x(J),!I){D(!0);return}P(!0),q()},Z=async()=>{Ce("automation_test_clicked",{automation_id:t,agent_id:r});const J=await W();if(X(),!!J){if(!g){de.error("No instructions configured for this automation");return}try{const ee=await c.mutateAsync(t);ee.threadId&&(f(!0),u(ee.threadId))}catch{}}};return i.jsxs(i.Fragment,{children:[s&&i.jsx("div",{className:"flex items-center pb-4 shrink-0",children:i.jsxs(ie,{variant:"ghost",size:"sm",onClick:s,children:[i.jsx(Vl,{size:14}),"Back to list"]})}),i.jsxs("div",{className:"flex flex-col gap-8",children:[i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx(fs,{control:O.control,name:"name",render:({field:J})=>i.jsx(Ye,{...J,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),n&&i.jsx(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:i.jsx(ws,{size:14})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(fs,{control:O.control,name:"active",render:({field:J})=>i.jsx(ho,{checked:J.value,onCheckedChange:ee=>{J.onChange(ee),W()},className:"cursor-pointer"})}),i.jsx("span",{className:"text-sm text-muted-foreground",children:U?"Active":"Inactive"}),i.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),i.jsx(P3,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),i.jsx(ZP,{automationId:t,open:v,onOpenChange:_,onCustomSelect:()=>{w(!0),k(!1),j("")},onEventSelect:()=>{k(!0),w(!1)},onWebhookCreated:J=>{Ce("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),A(J)}})]}),e.triggers.length===0&&!L?i.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:i.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",i.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>_(!0),children:"Add a starter"})," ","to get going."]})}):i.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(J=>i.jsx(eI,{trigger:J,automationId:t,connectionName:J.connection_id?h.get(J.connection_id):void 0},J.id))}),L&&i.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),i.jsx("input",{type:"text",value:S,onChange:J=>j(J.target.value),onBlur:async()=>{const J=S.trim();if(!(!J||!so(J)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:J}),Ce("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),de.success("Starter added"),w(!1),j("")}catch{de.error("Failed to add starter")}},onKeyDown:async J=>{const ee=S.trim();J.key==="Enter"&&ee&&so(ee)&&J.target.blur(),J.key==="Escape"&&(w(!1),j(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),S&&!so(S)&&i.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),i.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),j("")},children:i.jsx(yn,{size:13})})]}),V&&i.jsx(C.Suspense,{fallback:i.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:i.jsx(iI,{automationId:t,onDone:()=>k(!1)})}),i.jsx(yg,{open:T!==null,onOpenChange:J=>{J||A(null)},url:T?.url??null,token:T?.token??null})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),i.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:N||!g,onClick:M,children:[i.jsx(Bn,{size:13}),"Improve"]})]}),i.jsx(E2,{tiptapDoc:g,setTiptapDoc:Q,placeholder:"What should this automation do?",children:i.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[i.jsx(R2,{virtualMcpId:r||null,className:"max-h-[45vh]"}),i.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsxs(ie,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Z,disabled:!r,children:[i.jsx(g9,{size:16}),"Test"]})}),i.jsx(Pe,{children:"Test Automation"})]})})]})})]}),i.jsxs(A5,{open:b,onOpenChange:y,className:"flex flex-col gap-2.5",children:[i.jsxs(T5,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),i.jsx(Ht,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),i.jsxs(E5,{className:"flex flex-col gap-5 pt-0.5",children:[i.jsx(MP,{tier:O.watch("tier"),onTierChange:J=>O.setValue("tier",J,{shouldDirty:!0}),override:O.watch("modelOverride"),onOverrideChange:J=>O.setValue("modelOverride",J,{shouldDirty:!0})}),i.jsx(zP,{agentId:r||null,value:O.watch("tools"),onChange:J=>O.setValue("tools",J,{shouldDirty:!0})}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),i.jsx(Ye,{type:"number",min:1,max:100,className:"w-40",placeholder:`${sI} (default)`,value:O.watch("maxAgentSteps")??"",onChange:J=>{const ee=J.target.value.trim(),te=ee===""?null:Number(ee);O.setValue("maxAgentSteps",te===null||Number.isNaN(te)?null:te,{shouldDirty:!0})}})]})]})]})]})]})}const Lg=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function Sg(t){const e=Lg.find(n=>n.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function cI(t){const e=B.c(12),{automationId:s,triggerIds:n}=t,[r,o]=C.useState("30d"),[a,l]=C.useState(uI);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=p=>{const g=p;o(g),l(Sg(g))},e[0]=c):c=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(zt,{className:"w-44",children:i.jsx(Gt,{})}),e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx($t,{children:Lg.map(dI)}),e[2]=h):h=e[2];let u;e[3]!==r?(u=i.jsx("div",{className:"flex items-center justify-end",children:i.jsxs(Bt,{value:r,onValueChange:c,children:[d,h]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==n?(f=i.jsx(R5,{automationId:s,triggerIds:n,range:a}),e[5]=s,e[6]=a,e[7]=n,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=i.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function dI(t){return i.jsx(nt,{value:t.key,children:t.label},t.key)}function uI(){return Sg("30d")}function hI(t){const e=B.c(5),{tabId:s}=t;let n;e[0]!==s?(n=Vm(s),e[0]=s,e[1]=n):n=e[1];const r=n;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(pi,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=i.jsx(C.Suspense,{fallback:o,children:i.jsx(fI,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function fI(t){const e=B.c(24),{id:s}=t,n=Ct(),{data:r,isLoading:o}=r6(s),[a,l]=C.useState("settings");let c;e[0]!==n?(c=()=>{n({to:".",search:pI,replace:!0})},e[0]=n,e[1]=c):c=e[1];const d=c;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(pi,{}),e[2]=y):y=e[2],y}if(!r){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=y):y=e[3],y}let h;e[4]!==r.triggers?(h=r.triggers.map(mI),e[4]=r.triggers,e[5]=h):h=e[5];const u=h;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Vl,{size:14}),e[6]=f):f=e[6];let m;e[7]!==d?(m=i.jsxs(ie,{variant:"ghost",size:"sm",onClick:d,children:[f,"Back to list"]}),e[7]=d,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=y=>l(y),e[10]=g):g=e[10];let x;e[11]!==a?(x=i.jsx(Om,{tabs:p,activeTab:a,onTabChange:g}),e[11]=a,e[12]=x):x=e[12];let v;e[13]!==m||e[14]!==x?(v=i.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,x]}),e[13]=m,e[14]=x,e[15]=v):v=e[15];let _;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(_=a==="settings"?i.jsx(lI,{automationId:s,automation:r}):i.jsx(cI,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=_):_=e[20];let b;return e[21]!==v||e[22]!==_?(b=i.jsx(zs,{children:i.jsx(zs.Content,{children:i.jsxs(zs.Body,{children:[v,_]})})}),e[21]=v,e[22]=_,e[23]=b):b=e[23],b}function mI(t){return t.id}function pI(t){return{...t,main:"automations"}}function gI(t){const e=B.c(20),{virtualMcpId:s}=t,n=Ct(),{data:r}=o6(s),o=r===void 0?[]:r,{create:a}=Mo(),[l,c]=C.useState(""),d=l.toLowerCase(),h=o.filter(T=>T.name.toLowerCase().includes(d));let u;e[0]!==n?(u=T=>n({to:".",search:A=>({...A,main:"automation:"+T}),replace:!0}),e[0]=n,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ce("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const T=await a.mutateAsync(a6(s));f(T.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Lt,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=i.jsxs(ie,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];const x=g,v=zs,_=zs,b=zs;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(zs.Title,{children:"Automations"}),e[6]=y):y=e[6];const L=o.length>0&&i.jsx(K9,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==x||e[8]!==L?(w=i.jsxs("div",{className:"flex flex-col gap-6",children:[y,i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[L,x]})]}),e[7]=x,e[8]=L,e[9]=w):w=e[9];const S=o.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(qi,{image:i.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:x})}):h.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(qi,{image:i.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):i.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:h.map(T=>i.jsx(l6,{automation:T,onClick:()=>f(T.id)},T.id))});let j;e[10]!==S||e[11]!==b.Body||e[12]!==w?(j=i.jsxs(b.Body,{children:[w,S]}),e[10]=S,e[11]=b.Body,e[12]=w,e[13]=j):j=e[13];let V;e[14]!==j||e[15]!==_.Content?(V=i.jsx(_.Content,{children:j}),e[14]=j,e[15]=_.Content,e[16]=V):V=e[16];let k;return e[17]!==v||e[18]!==V?(k=i.jsx(v,{children:V}),e[17]=v,e[18]=V,e[19]=k):k=e[19],k}function xI(t){const e=B.c(3),{virtualMcpId:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(pi,{}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsx(C.Suspense,{fallback:n,children:i.jsx(gI,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function vI(t){const e=B.c(37),{file:s,onClose:n}=t;let r,o;e[0]!==s.filename?(r=i.jsx(Gi,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=rv(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let c;e[7]!==r||e[8]!==o||e[9]!==l?(c=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=c):c=e[10];let d;e[11]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Rv,{size:14}),e[11]=d):d=e[11];let h;e[12]!==s.downloadUrl||e[13]!==s.filename?(h=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",asChild:!0,children:i.jsx("a",{href:s.downloadUrl,download:s.filename,children:d})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Pe,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==h?(f=i.jsxs(Ie,{children:[h,u]}),e[16]=h,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(wn,{size:14}),e[20]=p):p=e[20];let g;e[21]!==m?(g=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=g):g=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Pe,{side:"bottom",children:"Open in new tab"}),e[23]=x):x=e[23];let v;e[24]!==g?(v=i.jsxs(Ie,{children:[g,x]}),e[24]=g,e[25]=v):v=e[25];let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(yn,{size:14}),e[26]=_):_=e[26];let b;e[27]!==n?(b=i.jsx(Re,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"icon",onClick:n,children:_})}),e[27]=n,e[28]=b):b=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Pe,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let L;e[30]!==b?(L=i.jsxs(Ie,{children:[b,y]}),e[30]=b,e[31]=L):L=e[31];let w;return e[32]!==v||e[33]!==L||e[34]!==c||e[35]!==f?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,f,v,L]}),e[32]=v,e[33]=L,e[34]=c,e[35]=f,e[36]=w):w=e[36],w}function _I(t){const e=B.c(24),{fileKey:s,taskId:n}=t,r=Ct(),{data:o,isPending:a}=O1(n);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const c=l;let d;e[3]!==r?(d=()=>r({to:".",search:bI,replace:!0}),e[3]=r,e[4]=d):d=e[4];const h=d;if(!c){if(a){let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full w-full bg-background",children:i.jsx(nv,{})}),e[5]=b):b=e[5],b}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let g;e[8]!==p?(g=i.jsx(Gi,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=g):g=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=x):x=e[10];let v;e[11]!==h?(v=i.jsx(ie,{variant:"ghost",size:"sm",onClick:h,children:"Close"}),e[11]=h,e[12]=v):v=e[12];let _;return e[13]!==g||e[14]!==v?(_=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[g,x,v]}),e[13]=g,e[14]=v,e[15]=_):_=e[15],_}let u;e[16]!==c||e[17]!==h?(u=i.jsx(vI,{file:c,onClose:h}),e[16]=c,e[17]=h,e[18]=u):u=e[18];let f;e[19]!==c?(f=i.jsx("div",{className:"relative min-h-0 flex-1",children:i.jsx(iv,{file:c})}),e[19]=c,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=i.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function bI(t){return{...t,main:0}}const zc="home";function yI(t){const e=B.c(5),{label:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(yt,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=n):n=e[0];let r;e[1]!==s?(r=s&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[n,r]}),e[3]=r,e[4]=o):o=e[4],o}function LI(t){const e=B.c(15),{path:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={refetchIntervalWhenAbsent:2e3},e[0]=n):n=e[0];const r=ov(zc,s,n),o=av(zc)(s);if(r.isPending||!r.data){const f=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=i.jsx(yI,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==r.data?(a=lv(r.data),e[3]=r.data,e[4]=a):a=e[4];const l=r.data.shareMode??"private",c=r.data.effectivePublic??!1,d=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==d?(h=i.jsx(cv,{volume:zc,path:s,shareMode:l,effectivePublic:c,url:d}),e[5]=s,e[6]=l,e[7]=c,e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=i.jsx(dv,{readUrl:o,marker:a,title:s,savePath:s,trailing:h}),e[10]=s,e[11]=o,e[12]=a,e[13]=h,e[14]=u):u=e[14],u}function SI(t){const e=B.c(5),{path:s}=t,n=Ct();let r;e[0]!==n?(r=()=>n({to:".",search:wI,replace:!0}),e[0]=n,e[1]=r):r=e[1];const o=r;let a;return e[2]!==o||e[3]!==s?(a=i.jsx(uv,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function wI(t){return{...t,main:0}}function jI(){const t=B.c(12),e=Ct(),[s,n]=C.useState(null),[r,o]=C.useState(null);let a;t[0]!==e?(a=f=>e({to:".",search:m=>({...m,main:f}),replace:!0}),t[0]=e,t[1]=a):a=t[1];const l=a;let c;t[2]!==l?(c=i.jsx(hv,{onOpenFile:f=>l(kv(f)),onOpenSkill:n,onOpenBrand:o}),t[2]=l,t[3]=c):c=t[3];let d;t[4]!==s?(d=s&&i.jsx(fv,{skillPath:s,onClose:()=>n(null)},s),t[4]=s,t[5]=d):d=t[5];let h;t[6]!==r?(h=r&&i.jsx(mv,{brandPath:r,onClose:()=>o(null)},r),t[6]=r,t[7]=h):h=t[7];let u;return t[8]!==c||t[9]!==d||t[10]!==h?(u=i.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[c,d,h]}),t[8]=c,t[9]=d,t[10]=h,t[11]=u):u=t[11],u}const Lf=C.lazy(()=>Ws(()=>import("./project-app-view-C9GFnxtU.js"),__vite__mapDeps([163,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,3,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,132,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.AppViewContent})));function CI(t){const e=B.c(60),{activeTab:s,virtualMcpId:n,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(s==="overview"){let L;return e[0]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(qE,{}),e[0]=L):L=e[0],L}if(s==="board"){let L;return e[1]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:i.jsx(Gv,{})}),e[1]=L):L=e[1],L}if(Nv(s)){let L;return e[2]!==n?(L=i.jsx(lf,{virtualMcpId:n}),e[2]=n,e[3]=L):L=e[3],L}if(s==="git"){let L;return e[4]!==n?(L=i.jsx(GR,{virtualMcpId:n}),e[4]=n,e[5]=L):L=e[5],L}if(s==="automations"){let L;return e[6]!==n?(L=i.jsx(xI,{virtualMcpId:n}),e[6]=n,e[7]=L):L=e[7],L}if(s==="preview"){let L;return e[8]!==n?(L=i.jsx(NP,{virtualMcpId:n}),e[8]=n,e[9]=L):L=e[9],L}let c;e[10]!==s?(c=Av(s),e[10]=s,e[11]=c):c=e[11];const d=c;if(d){let L;return e[12]!==d.path?(L=i.jsx(RP,{openPath:d.path}),e[12]=d.path,e[13]=L):L=e[13],L}if(s==="content"){let L;return e[14]!==n?(L=i.jsx(PP,{virtualMcpId:n}),e[14]=n,e[15]=L):L=e[15],L}if(s==="files"){let L;return e[16]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(jI,{}),e[16]=L):L=e[16],L}if(l){let L;return e[17]!==s?(L=i.jsx(hI,{tabId:s}),e[17]=s,e[18]=L):L=e[18],L}let h;e[19]!==s?(h=Nm(s),e[19]=s,e[20]=h):h=e[20];const u=h;if(u){let L;return e[21]!==u.path?(L=i.jsx(LI,{path:u.path},u.path),e[21]=u.path,e[22]=L):L=e[22],L}let f;e[23]!==s?(f=km(s),e[23]=s,e[24]=f):f=e[24];const m=f;if(m){let L;return e[25]!==m.key||e[26]!==r?(L=i.jsx(_I,{fileKey:m.key,taskId:r}),e[25]=m.key,e[26]=r,e[27]=L):L=e[27],L}let p;e[28]!==s?(p=Am(s),e[28]=s,e[29]=p):p=e[29];const g=p;if(g){let L;return e[30]!==g.path?(L=i.jsx(SI,{path:g.path},g.path),e[30]=g.path,e[31]=L):L=e[31],L}let x;e[32]!==s?(x=Tv(s),e[32]=s,e[33]=x):x=e[33];const v=x;if(v){let L;if(e[34]!==a||e[35]!==v.connectionId||e[36]!==v.toolName){let k;e[38]!==v.connectionId||e[39]!==v.toolName?(k=T=>T.appId===v.connectionId&&T.toolName===v.toolName,e[38]=v.connectionId,e[39]=v.toolName,e[40]=k):k=e[40],L=a.find(k),e[34]=a,e[35]=v.connectionId,e[36]=v.toolName,e[37]=L}else L=e[37];const w=L;let S;e[41]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(pi,{}),e[41]=S):S=e[41];const j=w?.args;let V;return e[42]!==s||e[43]!==v.connectionId||e[44]!==v.toolName||e[45]!==j?(V=i.jsx(C.Suspense,{fallback:S,children:i.jsx(Lf,{connectionId:v.connectionId,toolName:v.toolName,args:j},s)}),e[42]=s,e[43]=v.connectionId,e[44]=v.toolName,e[45]=j,e[46]=V):V=e[46],V}let _;if(e[47]!==s||e[48]!==o){let L;e[50]!==s?(L=w=>w.id===s,e[50]=s,e[51]=L):L=e[51],_=o.find(L),e[47]=s,e[48]=o,e[49]=_}else _=e[49];const b=_;if(b){let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(pi,{}),e[52]=L):L=e[52];let w;return e[53]!==s||e[54]!==b.id||e[55]!==b.view.appId||e[56]!==b.view.args?(w=i.jsx(C.Suspense,{fallback:L,children:i.jsx(Lf,{connectionId:b.view.appId,toolName:b.id,args:b.view.args},s)}),e[53]=s,e[54]=b.id,e[55]=b.view.appId,e[56]=b.view.args,e[57]=w):w=e[57],w}let y;return e[58]!==n?(y=i.jsx(lf,{virtualMcpId:n}),e[58]=n,e[59]=y):y=e[59],y}function VI(t){const e=B.c(14),{taskId:s,virtualMcpId:n}=t;let r;e[0]!==s||e[1]!==n?(r={virtualMcpId:n,taskId:s},e[0]=s,e[1]=n,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=Fd(r);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(pi,{}),e[3]=d):d=e[3];let h;e[4]!==o||e[5]!==c||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==n?(h=i.jsx(C.Suspense,{fallback:d,children:i.jsx(CI,{activeTab:o,virtualMcpId:n,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:c})}),e[4]=o,e[5]=c,e[6]=l,e[7]=a,e[8]=s,e[9]=n,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=i.jsx(ps,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const li="setup";function kI(t){const e=B.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const n=s;let r;e[5]!==t?(r=()=>{t.active===li?t.onToggle():t.onSelectTab(li)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===li;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=i.jsx(NI,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==t?(c=t.scriptTabs.map(m=>i.jsx(TI,{active:t.active===m,onClick:()=>{t.active===m?t.onToggle():t.onSelectTab(m)},onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=c):c=e[12];let d;e[13]!==n||e[14]!==t.onAddScript?(d=i.jsx(EI,{scripts:n,onRun:t.onAddScript}),e[13]=n,e[14]=t.onAddScript,e[15]=d):d=e[15];let h;e[16]!==l||e[17]!==c||e[18]!==d?(h=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,c,d]}),e[16]=l,e[17]=c,e[18]=d,e[19]=h):h=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?i.jsx(RI,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):i.jsx(AI,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==h||e[33]!==u?(f=i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[h,u]}),e[32]=h,e[33]=u,e[34]=f):f=e[34],f}function NI(t){const e=B.c(8),{active:s,open:n,onClick:r}=t,o=s&&n,a=s&&n,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let c;e[0]!==l?(c=ne("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Nx,{className:"size-3.5"}),e[2]=d):d=e[2];let h;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==c?(h=i.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:c,children:[d,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=c,e[7]=h):h=e[7],h}function AI(t){const e=B.c(24),{status:s,onStart:n,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&n){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(fi,{className:"size-3.5"}),e[0]=c):c=e[0];let d;return e[1]!==n?(d=i.jsxs(ie,{variant:"outline",size:"sm",onClick:n,children:[c," Start"]}),e[1]=n,e[2]=d):d=e[2],d}if(s==="suspended"&&a){let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(fi,{className:"size-3.5"}),e[3]=c):c=e[3];let d;return e[4]!==a?(d=i.jsxs(ie,{variant:"outline",size:"sm",onClick:a,children:[c," Resume"]}),e[4]=a,e[5]=d):d=e[5],d}if(s==="errored"&&l){let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(zi,{className:"size-3.5"}),e[6]=c):c=e[6];let d;return e[7]!==l?(d=i.jsxs(ie,{variant:"outline",size:"sm",onClick:l,children:[c," Retry"]}),e[7]=l,e[8]=d):d=e[8],d}if(s==="starting"||s==="running"){const c=s==="running"&&!!o,d=c?"rounded-r-none border-r-0":void 0;let h;e[9]!==d?(h=ne(d),e[9]=d,e[10]=h):h=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(dm,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==h?(f=i.jsx(Re,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",onClick:r,className:h,children:[u," Stop"]})}),e[12]=r,e[13]=h,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Pe,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=i.jsxs(Ie,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==o||e[19]!==c?(g=c&&i.jsxs(Zt,{children:[i.jsx(es,{asChild:!0,children:i.jsx(ie,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:i.jsx(Ht,{className:"size-3"})})}),i.jsx(ts,{align:"end",children:i.jsxs(He,{onClick:o,children:[i.jsx(zi,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=c,e[20]=g):g=e[20];let x;return e[21]!==p||e[22]!==g?(x=i.jsxs("div",{className:"flex items-center",children:[p,g]}),e[21]=p,e[22]=g,e[23]=x):x=e[23],x}return null}function TI(t){const e=B.c(16),{active:s,onClick:n,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=ne("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const c=r?"pl-2.5 pr-1":"px-2.5",d=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let h;e[2]!==c||e[3]!==d?(h=ne("flex h-full items-center",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==o||e[6]!==n||e[7]!==h?(u=i.jsx("button",{type:"button",onClick:n,className:h,children:o}),e[5]=o,e[6]=n,e[7]=h,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&i.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:i.jsx(ms,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=i.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function EI(t){const e=B.c(10),{scripts:s,onRun:n}=t,[r,o]=C.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Cs,{asChild:!0,children:i.jsx(ie,{variant:"ghost",size:"sm","aria-label":"Run script",children:i.jsx(Lt,{className:"size-3.5"})})})}),i.jsx(Pe,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==s?(c=s.length===0?i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>i.jsxs("button",{type:"button",onClick:()=>{o(!1),n(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=n,e[3]=s,e[4]=c):c=e[4];let d;e[5]!==c?(d=i.jsxs(Vs,{align:"start",className:"p-1 w-56",children:[l,c]}),e[5]=c,e[6]=d):d=e[6];let h;return e[7]!==r||e[8]!==d?(h=i.jsxs(ks,{open:r,onOpenChange:o,children:[a,d]}),e[7]=r,e[8]=d,e[9]=h):h=e[9],h}function RI(t){const e=B.c(13),{isRunning:s,isKilling:n,onRun:r,onStop:o}=t;if(n){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[i.jsx(qe,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=h):h=e[0],h}if(!s){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(fi,{className:"size-3.5"}),e[1]=h):h=e[1];let u;e[2]!==r?(u=i.jsx(Re,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",onClick:r,children:[h," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Pe,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=i.jsxs(Ie,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(dm,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=i.jsx(Re,{asChild:!0,children:i.jsxs(ie,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let c;e[10]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Pe,{children:"Stop process"}),e[10]=c):c=e[10];let d;return e[11]!==l?(d=i.jsxs(Ie,{children:[l,c]}),e[11]=l,e[12]=d):d=e[12],d}var wg=Object.defineProperty,PI=Object.getOwnPropertyDescriptor,II=(t,e)=>{for(var s in e)wg(t,s,{get:e[s],enumerable:!0})},_t=(t,e,s,n)=>{for(var r=n>1?void 0:n?PI(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(e,s,r):a(r))||r);return n&&r&&wg(e,s,r),r},Se=(t,e)=>(s,n)=>e(s,n,t),Sf="Terminal input",N0={get:()=>Sf,set:t=>Sf=t},wf="Too much output to announce, navigate to rows manually to read",A0={get:()=>wf,set:t=>wf=t};function DI(t){return t.replace(/\r?\n/g,"\r")}function MI(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function OI(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function $I(t,e,s,n){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");jg(r,e,s,n)}}function jg(t,e,s,n){t=DI(t),t=MI(t,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Cg(t,e,s){let n=s.getBoundingClientRect(),r=t.clientX-n.left-10,o=t.clientY-n.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function jf(t,e,s,n,r){Cg(t,e,s),r&&n.rightClickSelect(t),e.value=n.selectionText,e.select()}function In(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function rc(t,e=0,s=t.length){let n="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,n+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):n+=String.fromCharCode(o)}return n}var BI=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[n++]=(this._interim-55296)*1024+o-56320+65536:(e[n++]=this._interim,e[n++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,n;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[n++]=(a-55296)*1024+l-56320+65536:(e[n++]=a,e[n++]=l);continue}a!==65279&&(e[n++]=a)}return n}},zI=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r,o,a,l,c=0,d=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)m<<=6,m|=g;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=x-p;for(;d<v;){if(d>=s)return 0;if(g=t[d++],(g&192)!==128){d--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(x===2?m<128?d--:e[n++]=m:x===3?m<2048||m>=55296&&m<=57343||m===65279||(e[n++]=m):m<65536||m>1114111||(e[n++]=m)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[n++]=r,e[n++]=o,e[n++]=a,e[n++]=l,u+=4;if(r=t[u++],r<128)e[n++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(c=(r&31)<<6|o&63,c<128){u--;continue}e[n++]=c}else if((r&240)===224){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(c=(r&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;e[n++]=c}else if((r&248)===240){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,n;if(l=t[u++],(l&192)!==128){u--;continue}if(c=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;e[n++]=c}}return n}},Vg="",On=" ",qo=class kg{constructor(){this.fg=0,this.bg=0,this.extended=new gl}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new kg;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},gl=class Ng{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Ng(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Is=class Ag extends qo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new gl,this.combinedData=""}static fromCharData(e){let s=new Ag;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?In(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Cf="di$target",T0="di$dependencies",Fc=new Map;function FI(t){return t[T0]||[]}function Kt(t){if(Fc.has(t))return Fc.get(t);let e=function(s,n,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");UI(e,s,r)};return e._id=t,Fc.set(t,e),e}function UI(t,e,s){e[Cf]===e?e[T0].push({id:t,index:s}):(e[T0]=[{id:t,index:s}],e[Cf]=e)}var cs=Kt("BufferService"),Tg=Kt("CoreMouseService"),Vi=Kt("CoreService"),HI=Kt("CharsetService"),eu=Kt("InstantiationService"),Eg=Kt("LogService"),ds=Kt("OptionsService"),Rg=Kt("OscLinkService"),KI=Kt("UnicodeService"),Go=Kt("DecorationService"),E0=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let n=[],r=this._optionsService.rawOptions.linkHandler,o=new Is,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let h=0;h<a;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else c!==-1&&(d=!0);if(d||c!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:c+1,y:t},end:{x:h+(!d&&h===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||n.push({text:u,range:f,activate:(p,g)=>r?r.activate(p,g,f):WI(p,g),hover:(p,g)=>r?.hover?.(p,g,f),leave:(p,g)=>r?.leave?.(p,g,f)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,l=o.extended.urlId):(c=-1,l=-1)}}e(n)}};E0=_t([Se(0,cs),Se(1,ds),Se(2,Rg)],E0);function WI(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
201
201
|
|
|
202
202
|
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var oc=Kt("CharSizeService"),jn=Kt("CoreBrowserService"),tu=Kt("MouseService"),Cn=Kt("RenderService"),qI=Kt("SelectionService"),Pg=Kt("CharacterJoinerService"),_r=Kt("ThemeService"),Ig=Kt("LinkProviderService"),GI=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Vf.isErrorNoTelemetry(t)?new Vf(t.message+`
|
|
203
203
|
|